@snyk/protect
Advanced tools
Comparing version 1.1280.0 to 1.1280.1
@@ -7,5 +7,5 @@ "use strict"; | ||
const projectPath = process.cwd(); | ||
await lib_1.default(projectPath); | ||
await (0, lib_1.default)(projectPath); | ||
} | ||
exports.protect = protect; | ||
//# sourceMappingURL=index.js.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
function getVersion() { | ||
return JSON.parse(fs_1.readFileSync(path.resolve(__dirname, '../../package.json'), 'utf-8')).version; | ||
return JSON.parse((0, fs_1.readFileSync)(path.resolve(__dirname, '../../package.json'), 'utf-8')).version; | ||
} | ||
@@ -29,3 +29,3 @@ function getAnalyticsData(result) { | ||
try { | ||
const apiBaseUrl = snyk_api_1.getApiBaseUrl(); | ||
const apiBaseUrl = (0, snyk_api_1.getApiBaseUrl)(); | ||
const apiUrl = `${apiBaseUrl}/v1/analytics/cli`; | ||
@@ -35,3 +35,3 @@ const data = { | ||
}; | ||
await http_1.postJson(apiUrl, data); | ||
await (0, http_1.postJson)(apiUrl, data); | ||
} | ||
@@ -46,4 +46,4 @@ catch (err) { | ||
const snykConfigFile = getSnykConfigFilePath(); | ||
if (fs_1.existsSync(snykConfigFile)) { | ||
const config = JSON.parse(fs_1.readFileSync(snykConfigFile, 'utf-8')); | ||
if ((0, fs_1.existsSync)(snykConfigFile)) { | ||
const config = JSON.parse((0, fs_1.readFileSync)(snykConfigFile, 'utf-8')); | ||
if (config['disable-analytics'] === '1' || | ||
@@ -50,0 +50,0 @@ config['disable-analytics'] === 1) { |
@@ -7,5 +7,5 @@ "use strict"; | ||
async function fetchPatches(vulnId, packageName, packageVersion) { | ||
const apiBaseUrl = snyk_api_1.getApiBaseUrl(); | ||
const apiBaseUrl = (0, snyk_api_1.getApiBaseUrl)(); | ||
const apiUrl = `${apiBaseUrl}/v1/patches/${vulnId}?packageVersion=${packageVersion}`; | ||
const { res, body } = await http_1.request(apiUrl); | ||
const { res, body } = await (0, http_1.request)(apiUrl); | ||
if (res.statusCode !== 200 && res.statusCode !== 201) { | ||
@@ -24,3 +24,3 @@ throw new Error(JSON.parse(body).error); | ||
for (const url of p.urls) { | ||
const { body: diff } = await http_1.request(url); | ||
const { body: diff } = await (0, http_1.request)(url); | ||
diffs.push(diff); | ||
@@ -27,0 +27,0 @@ } |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { IncomingMessage } from 'http'; | ||
import { RequestOptions } from 'https'; | ||
export declare type SnykResponse = { | ||
export type SnykResponse = { | ||
res: IncomingMessage; | ||
@@ -6,0 +8,0 @@ body: any; |
@@ -25,3 +25,3 @@ "use strict"; | ||
console.log('No .snyk file found.'); | ||
analytics_1.sendAnalytics({ | ||
(0, analytics_1.sendAnalytics)({ | ||
type: types_1.ProtectResultType.NO_SNYK_FILE, | ||
@@ -32,9 +32,9 @@ }); | ||
const snykFileContents = fs.readFileSync(snykFilePath, 'utf8'); | ||
const snykFilePatchMetadata = snyk_file_1.extractPatchMetadata(snykFileContents); | ||
const snykFilePatchMetadata = (0, snyk_file_1.extractPatchMetadata)(snykFileContents); | ||
const vulnIdAndPackageNames = snykFilePatchMetadata; | ||
const targetPackageNames = [ | ||
...new Set(snykFilePatchMetadata.map((vpn) => vpn.packageName)), | ||
...new Set(snykFilePatchMetadata.map((vpn) => vpn.packageName)), // get a list of unique package names by converting to Set and then back to array | ||
]; | ||
// find instances of the target packages by spelunking through the node_modules looking for modules with a target packageName | ||
const foundPhysicalPackages = explore_node_modules_1.findPhysicalModules(projectFolderPath, targetPackageNames); | ||
const foundPhysicalPackages = (0, explore_node_modules_1.findPhysicalModules)(projectFolderPath, targetPackageNames); | ||
// Map of package name to versions (for the target package names). | ||
@@ -55,6 +55,6 @@ // For each package name, we might have found multiple versions and we'll need to fetch patches for each version. | ||
}); | ||
const packageAtVersionsToPatches = await fetch_patches_1.getAllPatches(vulnIdAndPackageNames, packageNameToVersionsMap); | ||
const packageAtVersionsToPatches = await (0, fetch_patches_1.getAllPatches)(vulnIdAndPackageNames, packageNameToVersionsMap); | ||
if (packageAtVersionsToPatches.size === 0) { | ||
console.log('Nothing to patch.'); | ||
analytics_1.sendAnalytics({ | ||
(0, analytics_1.sendAnalytics)({ | ||
type: types_1.ProtectResultType.NOTHING_TO_PATCH, | ||
@@ -71,3 +71,3 @@ }); | ||
patchDiffs.patchDiffs.forEach((diff) => { | ||
const patchedPath = patch_1.applyPatchToFile(diff, fpp.path, vp.vulnId); | ||
const patchedPath = (0, patch_1.applyPatchToFile)(diff, fpp.path, vp.vulnId); | ||
console.log(`Patched: ${patchedPath}`); | ||
@@ -84,3 +84,3 @@ }); | ||
console.log('Applied Snyk patches.'); | ||
analytics_1.sendAnalytics({ | ||
(0, analytics_1.sendAnalytics)({ | ||
type: types_1.ProtectResultType.APPLIED_PATCHES, | ||
@@ -87,0 +87,0 @@ patchedModules, |
@@ -54,3 +54,3 @@ "use strict"; | ||
vulnIdAndPackageNames.push({ | ||
vulnId: utils_1.deQuote(vulnId.trim()), | ||
vulnId: (0, utils_1.deQuote)(vulnId.trim()), | ||
packageName: packageNames[0], | ||
@@ -57,0 +57,0 @@ }); |
@@ -1,10 +0,10 @@ | ||
export declare type PatchInfo = { | ||
export type PatchInfo = { | ||
patchableVersions?: string; | ||
urls: string[]; | ||
}; | ||
export declare type VulnIdAndPackageName = { | ||
export type VulnIdAndPackageName = { | ||
vulnId: string; | ||
packageName: string; | ||
}; | ||
export declare type FoundPhysicalPackage = { | ||
export type FoundPhysicalPackage = { | ||
packageName: string; | ||
@@ -14,11 +14,11 @@ packageVersion: string; | ||
}; | ||
export declare type Patch = { | ||
export type Patch = { | ||
patchableVersions?: string; | ||
patchDiffs: string[]; | ||
}; | ||
export declare type VulnPatches = { | ||
export type VulnPatches = { | ||
vulnId: string; | ||
patches: Patch[]; | ||
}; | ||
export declare type PatchedModule = { | ||
export type PatchedModule = { | ||
vulnId: string; | ||
@@ -33,3 +33,3 @@ packageName: string; | ||
} | ||
export declare type AnalyticsPayload = { | ||
export type AnalyticsPayload = { | ||
command: string; | ||
@@ -43,12 +43,12 @@ args: string[]; | ||
}; | ||
export declare type NoSnykFile = { | ||
export type NoSnykFile = { | ||
type: ProtectResultType.NO_SNYK_FILE; | ||
}; | ||
export declare type NothingToPatch = { | ||
export type NothingToPatch = { | ||
type: ProtectResultType.NOTHING_TO_PATCH; | ||
}; | ||
export declare type AppliedPatches = { | ||
export type AppliedPatches = { | ||
type: ProtectResultType.APPLIED_PATCHES; | ||
patchedModules: PatchedModule[]; | ||
}; | ||
export declare type ProtectResult = NoSnykFile | NothingToPatch | AppliedPatches; | ||
export type ProtectResult = NoSnykFile | NothingToPatch | AppliedPatches; |
{ | ||
"name": "@snyk/protect", | ||
"version": "1.1280.0", | ||
"version": "1.1280.1", | ||
"description": "Snyk protect library and utility", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47812
606