snyk 1.869.0 → 1.870.0
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/dist/cli/245.index.js
CHANGED
|
@@ -150523,11 +150523,12 @@ const path_1 = __webpack_require__(85622);
|
|
|
150523
150523
|
const common_1 = __webpack_require__(51469);
|
|
150524
150524
|
const debug_1 = __webpack_require__(36583);
|
|
150525
150525
|
const extract_1 = __webpack_require__(18293);
|
|
150526
|
+
const minimatch = __webpack_require__(91171);
|
|
150526
150527
|
exports.readdir = fs_1.promises.readdir, exports.lstat = fs_1.promises.lstat;
|
|
150527
|
-
async function find(src) {
|
|
150528
|
+
async function find(src, excludePatterns = []) {
|
|
150528
150529
|
const fileResults = [];
|
|
150529
150530
|
const archiveResults = [];
|
|
150530
|
-
|
|
150531
|
+
const handler = async (path, stats) => {
|
|
150531
150532
|
if (!common_1.isSupportedSize(stats.size)) {
|
|
150532
150533
|
return;
|
|
150533
150534
|
}
|
|
@@ -150536,12 +150537,20 @@ async function find(src) {
|
|
|
150536
150537
|
return;
|
|
150537
150538
|
}
|
|
150538
150539
|
fileResults.push(path);
|
|
150539
|
-
}
|
|
150540
|
+
};
|
|
150541
|
+
const isExcluded = (path) => {
|
|
150542
|
+
path = common_1.isWindowsOS() ? path.split(path_1.sep).join(path_1.posix.sep) : path;
|
|
150543
|
+
return !!excludePatterns.find((pattern) => minimatch(path, pattern));
|
|
150544
|
+
};
|
|
150545
|
+
await traverse(src, handler, isExcluded);
|
|
150540
150546
|
return [fileResults, archiveResults];
|
|
150541
150547
|
}
|
|
150542
150548
|
exports.find = find;
|
|
150543
|
-
async function traverse(src, handle) {
|
|
150549
|
+
async function traverse(src, handle, isExcluded) {
|
|
150544
150550
|
try {
|
|
150551
|
+
if (isExcluded(src)) {
|
|
150552
|
+
return;
|
|
150553
|
+
}
|
|
150545
150554
|
const stats = await exports.lstat(src);
|
|
150546
150555
|
if (stats.isSymbolicLink()) {
|
|
150547
150556
|
return;
|
|
@@ -150554,7 +150563,7 @@ async function traverse(src, handle) {
|
|
|
150554
150563
|
const entries = await exports.readdir(src);
|
|
150555
150564
|
for (const entry of entries) {
|
|
150556
150565
|
const absolute = path_1.join(src, entry);
|
|
150557
|
-
await traverse(absolute, handle);
|
|
150566
|
+
await traverse(absolute, handle, isExcluded);
|
|
150558
150567
|
}
|
|
150559
150568
|
}
|
|
150560
150569
|
}
|
|
@@ -150673,7 +150682,7 @@ Object.defineProperty(exports, "scan", ({ enumerable: true, get: function () { r
|
|
|
150673
150682
|
"use strict";
|
|
150674
150683
|
|
|
150675
150684
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
150676
|
-
exports.scan = void 0;
|
|
150685
|
+
exports.getExcludedPatterns = exports.scan = exports.toRelativePaths = void 0;
|
|
150677
150686
|
const fs = __webpack_require__(35747);
|
|
150678
150687
|
const path = __webpack_require__(85622);
|
|
150679
150688
|
const path_1 = __webpack_require__(85622);
|
|
@@ -150685,6 +150694,17 @@ const git_1 = __webpack_require__(68361);
|
|
|
150685
150694
|
const extract_1 = __webpack_require__(18293);
|
|
150686
150695
|
const fs_1 = __webpack_require__(93689);
|
|
150687
150696
|
const common_1 = __webpack_require__(51469);
|
|
150697
|
+
const dotSnyk = __webpack_require__(24221);
|
|
150698
|
+
const invariants_1 = __webpack_require__(92141);
|
|
150699
|
+
function toRelativePaths(basedir, signatures, extractionWorkspace) {
|
|
150700
|
+
signatures.forEach((s) => {
|
|
150701
|
+
const src = extractionWorkspace && s.path.includes(extractionWorkspace)
|
|
150702
|
+
? extractionWorkspace
|
|
150703
|
+
: basedir;
|
|
150704
|
+
s.path = path.relative(src, s.path);
|
|
150705
|
+
});
|
|
150706
|
+
}
|
|
150707
|
+
exports.toRelativePaths = toRelativePaths;
|
|
150688
150708
|
async function scan(options) {
|
|
150689
150709
|
try {
|
|
150690
150710
|
debug_1.debug.enabled = !!(options === null || options === void 0 ? void 0 : options.debug);
|
|
@@ -150700,13 +150720,15 @@ async function scan(options) {
|
|
|
150700
150720
|
throw `'${options.path}' does not exist.`;
|
|
150701
150721
|
}
|
|
150702
150722
|
const start = Date.now();
|
|
150703
|
-
const
|
|
150704
|
-
|
|
150723
|
+
const projectRoot = options.path;
|
|
150724
|
+
const excludedPatterns = getExcludedPatterns(projectRoot, options['policy-path']);
|
|
150725
|
+
const [filePaths, archivePaths] = await find_1.find(projectRoot, excludedPatterns);
|
|
150726
|
+
let extractionWorkspace = undefined;
|
|
150705
150727
|
if (0 < extractionDepthLimit && 0 < archivePaths.length) {
|
|
150706
150728
|
const temporaryDir = await fs_1.createTemporaryDir();
|
|
150707
150729
|
extractionWorkspace = path_1.join(temporaryDir, common_1.DECOMPRESSING_WORKSPACE_DIR);
|
|
150708
150730
|
await extract_1.extract(archivePaths, temporaryDir, extractionDepthLimit);
|
|
150709
|
-
const [newFilePaths, newArchivePaths] = await find_1.find(extractionWorkspace);
|
|
150731
|
+
const [newFilePaths, newArchivePaths] = await find_1.find(extractionWorkspace, excludedPatterns);
|
|
150710
150732
|
filePaths.push(...newFilePaths, ...newArchivePaths);
|
|
150711
150733
|
}
|
|
150712
150734
|
else {
|
|
@@ -150714,12 +150736,7 @@ async function scan(options) {
|
|
|
150714
150736
|
}
|
|
150715
150737
|
debug_1.debug('%d files found \n', filePaths.length);
|
|
150716
150738
|
const signatures = await signatures_1.computeSignaturesConcurrently(filePaths);
|
|
150717
|
-
|
|
150718
|
-
const src = extractionWorkspace && s.path.includes(extractionWorkspace)
|
|
150719
|
-
? extractionWorkspace
|
|
150720
|
-
: options.path;
|
|
150721
|
-
s.path = path.relative(src, s.path);
|
|
150722
|
-
});
|
|
150739
|
+
toRelativePaths(projectRoot, signatures, extractionWorkspace);
|
|
150723
150740
|
const end = Date.now();
|
|
150724
150741
|
const totalMilliseconds = end - start;
|
|
150725
150742
|
const totalFileSignatures = signatures.length;
|
|
@@ -150739,7 +150756,7 @@ async function scan(options) {
|
|
|
150739
150756
|
const target = await git_1.getTarget();
|
|
150740
150757
|
debug_1.debug('target %o \n', target);
|
|
150741
150758
|
const gitInfo = hosted_git_info_1.fromUrl(target.remoteUrl);
|
|
150742
|
-
const name = options.projectName || (gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.project) || path.basename(
|
|
150759
|
+
const name = options.projectName || (gitInfo === null || gitInfo === void 0 ? void 0 : gitInfo.project) || path.basename(projectRoot);
|
|
150743
150760
|
debug_1.debug('name %o \n', name);
|
|
150744
150761
|
const scanResults = [
|
|
150745
150762
|
{
|
|
@@ -150761,6 +150778,18 @@ async function scan(options) {
|
|
|
150761
150778
|
}
|
|
150762
150779
|
}
|
|
150763
150780
|
exports.scan = scan;
|
|
150781
|
+
function getExcludedPatterns(projectRoot, policyFilePath = path_1.join(projectRoot, invariants_1.DEFAULT_SNYK_POLICY_FILE)) {
|
|
150782
|
+
var _a;
|
|
150783
|
+
if (!dotSnyk.exists(policyFilePath)) {
|
|
150784
|
+
return [];
|
|
150785
|
+
}
|
|
150786
|
+
const config = dotSnyk.parse(policyFilePath);
|
|
150787
|
+
return [
|
|
150788
|
+
policyFilePath,
|
|
150789
|
+
...dotSnyk.toAbsolutePaths(projectRoot, (_a = config === null || config === void 0 ? void 0 : config.exclude) === null || _a === void 0 ? void 0 : _a.unmanaged),
|
|
150790
|
+
];
|
|
150791
|
+
}
|
|
150792
|
+
exports.getExcludedPatterns = getExcludedPatterns;
|
|
150764
150793
|
//# sourceMappingURL=scan.js.map
|
|
150765
150794
|
|
|
150766
150795
|
/***/ }),
|
|
@@ -150803,6 +150832,60 @@ exports.isBinary = isBinary;
|
|
|
150803
150832
|
|
|
150804
150833
|
/***/ }),
|
|
150805
150834
|
|
|
150835
|
+
/***/ 24221:
|
|
150836
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
150837
|
+
|
|
150838
|
+
"use strict";
|
|
150839
|
+
|
|
150840
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
150841
|
+
exports.toAbsolutePaths = exports.parse = exports.exists = void 0;
|
|
150842
|
+
const fs_1 = __webpack_require__(35747);
|
|
150843
|
+
const yaml_1 = __webpack_require__(6792);
|
|
150844
|
+
const path_1 = __webpack_require__(85622);
|
|
150845
|
+
/**
|
|
150846
|
+
* Checks if the snyk policy file exists in the provided path
|
|
150847
|
+
* @param {string} policyPath - the path of the policy file.
|
|
150848
|
+
* @returns {[boolean, Object]} - snyk policy file is present or not and the error in case of failure
|
|
150849
|
+
*/
|
|
150850
|
+
function exists(policyPath) {
|
|
150851
|
+
return fs_1.existsSync(policyPath);
|
|
150852
|
+
}
|
|
150853
|
+
exports.exists = exists;
|
|
150854
|
+
/**
|
|
150855
|
+
* Parses the snyk policy file content
|
|
150856
|
+
* @param {string} policyPath - the path of the policy file.
|
|
150857
|
+
* @returns {Object} - the content of the policy file
|
|
150858
|
+
*/
|
|
150859
|
+
function parse(policyPath) {
|
|
150860
|
+
return yaml_1.parse(fs_1.readFileSync(policyPath, 'utf-8'));
|
|
150861
|
+
}
|
|
150862
|
+
exports.parse = parse;
|
|
150863
|
+
/**
|
|
150864
|
+
* Resolves an array of paths relative to the basedir
|
|
150865
|
+
* @param {string} basedir - the basedir used for resolving the paths
|
|
150866
|
+
* @param {Array} paths - the paths to be resolved
|
|
150867
|
+
* @returns {Array} - the resolved paths
|
|
150868
|
+
*/
|
|
150869
|
+
function toAbsolutePaths(basedir, paths = []) {
|
|
150870
|
+
return paths.map((p) => path_1.resolve(basedir, p));
|
|
150871
|
+
}
|
|
150872
|
+
exports.toAbsolutePaths = toAbsolutePaths;
|
|
150873
|
+
//# sourceMappingURL=index.js.map
|
|
150874
|
+
|
|
150875
|
+
/***/ }),
|
|
150876
|
+
|
|
150877
|
+
/***/ 92141:
|
|
150878
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
150879
|
+
|
|
150880
|
+
"use strict";
|
|
150881
|
+
|
|
150882
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
150883
|
+
exports.DEFAULT_SNYK_POLICY_FILE = void 0;
|
|
150884
|
+
exports.DEFAULT_SNYK_POLICY_FILE = '.snyk';
|
|
150885
|
+
//# sourceMappingURL=invariants.js.map
|
|
150886
|
+
|
|
150887
|
+
/***/ }),
|
|
150888
|
+
|
|
150806
150889
|
/***/ 68268:
|
|
150807
150890
|
/***/ ((__unused_webpack_module, exports) => {
|
|
150808
150891
|
|