socket 1.1.39 → 1.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cli.js +15 -6
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +4 -4
- package/dist/constants.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/utils.js +100 -100
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coana-fix.d.mts","sourceRoot":"","sources":["../../../../src/commands/fix/coana-fix.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"coana-fix.d.mts","sourceRoot":"","sources":["../../../../src/commands/fix/coana-fix.mts"],"names":[],"mappings":"AAkDA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAgD9C,wBAAsB,QAAQ,CAC5B,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,OAAO,CAAC;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC,CAmetD"}
|
package/dist/utils.js
CHANGED
|
@@ -4061,6 +4061,105 @@ async function setGitRemoteGithubRepoUrl(owner, repo, token, cwd = process.cwd()
|
|
|
4061
4061
|
return false;
|
|
4062
4062
|
}
|
|
4063
4063
|
|
|
4064
|
+
/**
|
|
4065
|
+
* Converts CVE IDs to GHSA IDs using GitHub API.
|
|
4066
|
+
* CVE to GHSA mappings are permanent, so we cache for 30 days.
|
|
4067
|
+
*/
|
|
4068
|
+
async function convertCveToGhsa(cveId) {
|
|
4069
|
+
try {
|
|
4070
|
+
const cacheKey = `cve-to-ghsa-${cveId}`;
|
|
4071
|
+
const octokit = getOctokit();
|
|
4072
|
+
const THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1000;
|
|
4073
|
+
const response = await cacheFetch(cacheKey, () => octokit.rest.securityAdvisories.listGlobalAdvisories({
|
|
4074
|
+
cve_id: cveId,
|
|
4075
|
+
per_page: 1
|
|
4076
|
+
}), THIRTY_DAYS_MS);
|
|
4077
|
+
if (!response.data.length) {
|
|
4078
|
+
return {
|
|
4079
|
+
ok: false,
|
|
4080
|
+
message: `No GHSA found for CVE ${cveId}`
|
|
4081
|
+
};
|
|
4082
|
+
}
|
|
4083
|
+
return {
|
|
4084
|
+
ok: true,
|
|
4085
|
+
data: response.data[0].ghsa_id
|
|
4086
|
+
};
|
|
4087
|
+
} catch (e) {
|
|
4088
|
+
const errorCause = getErrorCause(e);
|
|
4089
|
+
const errorLower = errorCause.toLowerCase();
|
|
4090
|
+
// Detect GitHub API rate limit and network errors.
|
|
4091
|
+
const isRateLimitOrNetworkError = errorLower.includes('rate limit') || errorLower.includes('epipe') || errorLower.includes('econnreset') || errorLower.includes('status: 403') || errorLower.includes('status code 403');
|
|
4092
|
+
return {
|
|
4093
|
+
ok: false,
|
|
4094
|
+
message: isRateLimitOrNetworkError ? 'GitHub API rate limit exceeded while converting CVE to GHSA. Wait an hour or set SOCKET_CLI_GITHUB_TOKEN environment variable with a personal access token for higher limits.' : `Failed to convert CVE to GHSA: ${errorCause}`
|
|
4095
|
+
};
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
|
|
4099
|
+
const PURL_TO_GITHUB_ECOSYSTEM_MAPPING = {
|
|
4100
|
+
__proto__: null,
|
|
4101
|
+
// GitHub Advisory Database supported ecosystems
|
|
4102
|
+
cargo: 'rust',
|
|
4103
|
+
composer: 'composer',
|
|
4104
|
+
gem: 'rubygems',
|
|
4105
|
+
go: 'go',
|
|
4106
|
+
golang: 'go',
|
|
4107
|
+
maven: 'maven',
|
|
4108
|
+
npm: 'npm',
|
|
4109
|
+
nuget: 'nuget',
|
|
4110
|
+
pypi: 'pip',
|
|
4111
|
+
swift: 'swift'
|
|
4112
|
+
};
|
|
4113
|
+
|
|
4114
|
+
/**
|
|
4115
|
+
* Converts PURL to GHSA IDs using GitHub API.
|
|
4116
|
+
*/
|
|
4117
|
+
async function convertPurlToGhsas(purl) {
|
|
4118
|
+
try {
|
|
4119
|
+
const purlObj = getPurlObject(purl, {
|
|
4120
|
+
throws: false
|
|
4121
|
+
});
|
|
4122
|
+
if (!purlObj) {
|
|
4123
|
+
return {
|
|
4124
|
+
ok: false,
|
|
4125
|
+
message: `Invalid PURL format: ${purl}`
|
|
4126
|
+
};
|
|
4127
|
+
}
|
|
4128
|
+
const {
|
|
4129
|
+
name,
|
|
4130
|
+
type: ecosystem,
|
|
4131
|
+
version
|
|
4132
|
+
} = purlObj;
|
|
4133
|
+
|
|
4134
|
+
// Map PURL ecosystem to GitHub ecosystem.
|
|
4135
|
+
const githubEcosystem = PURL_TO_GITHUB_ECOSYSTEM_MAPPING[ecosystem];
|
|
4136
|
+
if (!githubEcosystem) {
|
|
4137
|
+
return {
|
|
4138
|
+
ok: false,
|
|
4139
|
+
message: `Unsupported PURL ecosystem: ${ecosystem}`
|
|
4140
|
+
};
|
|
4141
|
+
}
|
|
4142
|
+
|
|
4143
|
+
// Search for advisories affecting this package.
|
|
4144
|
+
const cacheKey = `purl-to-ghsa-${ecosystem}-${name}-${version || constants.LATEST}`;
|
|
4145
|
+
const octokit = getOctokit();
|
|
4146
|
+
const affects = version ? `${name}@${version}` : name;
|
|
4147
|
+
const response = await cacheFetch(cacheKey, () => octokit.rest.securityAdvisories.listGlobalAdvisories({
|
|
4148
|
+
ecosystem: githubEcosystem,
|
|
4149
|
+
affects
|
|
4150
|
+
}));
|
|
4151
|
+
return {
|
|
4152
|
+
ok: true,
|
|
4153
|
+
data: response.data.map(a => a.ghsa_id)
|
|
4154
|
+
};
|
|
4155
|
+
} catch (e) {
|
|
4156
|
+
return {
|
|
4157
|
+
ok: false,
|
|
4158
|
+
message: `Failed to convert PURL to GHSA: ${getErrorCause(e)}`
|
|
4159
|
+
};
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
4162
|
+
|
|
4064
4163
|
/**
|
|
4065
4164
|
* Command-line utilities for Socket CLI.
|
|
4066
4165
|
* Handles argument parsing, flag processing, and command formatting.
|
|
@@ -4218,105 +4317,6 @@ function isPnpmLockfileScanCommand(command) {
|
|
|
4218
4317
|
return command === 'install' || command === 'i' || command === 'update' || command === 'up';
|
|
4219
4318
|
}
|
|
4220
4319
|
|
|
4221
|
-
/**
|
|
4222
|
-
* Converts CVE IDs to GHSA IDs using GitHub API.
|
|
4223
|
-
* CVE to GHSA mappings are permanent, so we cache for 30 days.
|
|
4224
|
-
*/
|
|
4225
|
-
async function convertCveToGhsa(cveId) {
|
|
4226
|
-
try {
|
|
4227
|
-
const cacheKey = `cve-to-ghsa-${cveId}`;
|
|
4228
|
-
const octokit = getOctokit();
|
|
4229
|
-
const THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1000;
|
|
4230
|
-
const response = await cacheFetch(cacheKey, () => octokit.rest.securityAdvisories.listGlobalAdvisories({
|
|
4231
|
-
cve_id: cveId,
|
|
4232
|
-
per_page: 1
|
|
4233
|
-
}), THIRTY_DAYS_MS);
|
|
4234
|
-
if (!response.data.length) {
|
|
4235
|
-
return {
|
|
4236
|
-
ok: false,
|
|
4237
|
-
message: `No GHSA found for CVE ${cveId}`
|
|
4238
|
-
};
|
|
4239
|
-
}
|
|
4240
|
-
return {
|
|
4241
|
-
ok: true,
|
|
4242
|
-
data: response.data[0].ghsa_id
|
|
4243
|
-
};
|
|
4244
|
-
} catch (e) {
|
|
4245
|
-
const errorCause = getErrorCause(e);
|
|
4246
|
-
const errorLower = errorCause.toLowerCase();
|
|
4247
|
-
// Detect GitHub API rate limit and network errors.
|
|
4248
|
-
const isRateLimitOrNetworkError = errorLower.includes('rate limit') || errorLower.includes('epipe') || errorLower.includes('econnreset') || errorLower.includes('status: 403') || errorLower.includes('status code 403');
|
|
4249
|
-
return {
|
|
4250
|
-
ok: false,
|
|
4251
|
-
message: isRateLimitOrNetworkError ? 'GitHub API rate limit exceeded while converting CVE to GHSA. Wait an hour or set SOCKET_CLI_GITHUB_TOKEN environment variable with a personal access token for higher limits.' : `Failed to convert CVE to GHSA: ${errorCause}`
|
|
4252
|
-
};
|
|
4253
|
-
}
|
|
4254
|
-
}
|
|
4255
|
-
|
|
4256
|
-
const PURL_TO_GITHUB_ECOSYSTEM_MAPPING = {
|
|
4257
|
-
__proto__: null,
|
|
4258
|
-
// GitHub Advisory Database supported ecosystems
|
|
4259
|
-
cargo: 'rust',
|
|
4260
|
-
composer: 'composer',
|
|
4261
|
-
gem: 'rubygems',
|
|
4262
|
-
go: 'go',
|
|
4263
|
-
golang: 'go',
|
|
4264
|
-
maven: 'maven',
|
|
4265
|
-
npm: 'npm',
|
|
4266
|
-
nuget: 'nuget',
|
|
4267
|
-
pypi: 'pip',
|
|
4268
|
-
swift: 'swift'
|
|
4269
|
-
};
|
|
4270
|
-
|
|
4271
|
-
/**
|
|
4272
|
-
* Converts PURL to GHSA IDs using GitHub API.
|
|
4273
|
-
*/
|
|
4274
|
-
async function convertPurlToGhsas(purl) {
|
|
4275
|
-
try {
|
|
4276
|
-
const purlObj = getPurlObject(purl, {
|
|
4277
|
-
throws: false
|
|
4278
|
-
});
|
|
4279
|
-
if (!purlObj) {
|
|
4280
|
-
return {
|
|
4281
|
-
ok: false,
|
|
4282
|
-
message: `Invalid PURL format: ${purl}`
|
|
4283
|
-
};
|
|
4284
|
-
}
|
|
4285
|
-
const {
|
|
4286
|
-
name,
|
|
4287
|
-
type: ecosystem,
|
|
4288
|
-
version
|
|
4289
|
-
} = purlObj;
|
|
4290
|
-
|
|
4291
|
-
// Map PURL ecosystem to GitHub ecosystem.
|
|
4292
|
-
const githubEcosystem = PURL_TO_GITHUB_ECOSYSTEM_MAPPING[ecosystem];
|
|
4293
|
-
if (!githubEcosystem) {
|
|
4294
|
-
return {
|
|
4295
|
-
ok: false,
|
|
4296
|
-
message: `Unsupported PURL ecosystem: ${ecosystem}`
|
|
4297
|
-
};
|
|
4298
|
-
}
|
|
4299
|
-
|
|
4300
|
-
// Search for advisories affecting this package.
|
|
4301
|
-
const cacheKey = `purl-to-ghsa-${ecosystem}-${name}-${version || constants.LATEST}`;
|
|
4302
|
-
const octokit = getOctokit();
|
|
4303
|
-
const affects = version ? `${name}@${version}` : name;
|
|
4304
|
-
const response = await cacheFetch(cacheKey, () => octokit.rest.securityAdvisories.listGlobalAdvisories({
|
|
4305
|
-
ecosystem: githubEcosystem,
|
|
4306
|
-
affects
|
|
4307
|
-
}));
|
|
4308
|
-
return {
|
|
4309
|
-
ok: true,
|
|
4310
|
-
data: response.data.map(a => a.ghsa_id)
|
|
4311
|
-
};
|
|
4312
|
-
} catch (e) {
|
|
4313
|
-
return {
|
|
4314
|
-
ok: false,
|
|
4315
|
-
message: `Failed to convert PURL to GHSA: ${getErrorCause(e)}`
|
|
4316
|
-
};
|
|
4317
|
-
}
|
|
4318
|
-
}
|
|
4319
|
-
|
|
4320
4320
|
const RangeStyles = ['pin', 'preserve'];
|
|
4321
4321
|
function getMajor(version) {
|
|
4322
4322
|
try {
|
|
@@ -6221,5 +6221,5 @@ exports.updateConfigValue = updateConfigValue;
|
|
|
6221
6221
|
exports.walkNestedMap = walkNestedMap;
|
|
6222
6222
|
exports.webLink = webLink;
|
|
6223
6223
|
exports.writeSocketJson = writeSocketJson;
|
|
6224
|
-
//# debugId=
|
|
6224
|
+
//# debugId=9654f015-4a5a-4e8b-b934-395a88591a9
|
|
6225
6225
|
//# sourceMappingURL=utils.js.map
|