snyk 1.807.0 → 1.808.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/917.index.js +30 -26
- package/dist/cli/917.index.js.map +1 -1
- package/dist/cli/989.index.js +389 -255
- package/dist/cli/989.index.js.map +1 -1
- package/dist/cli/commands/log4shell-hashes.d.ts +12 -1
- package/dist/cli/commands/test/iac-local-execution/file-loader.d.ts +1 -1
- package/package.json +2 -2
package/dist/cli/917.index.js
CHANGED
|
@@ -321,45 +321,49 @@ const errors_1 = __webpack_require__(55191);
|
|
|
321
321
|
const error_utils_1 = __webpack_require__(23872);
|
|
322
322
|
const DEFAULT_ENCODING = 'utf-8';
|
|
323
323
|
async function loadFiles(pathToScan, options = {}) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
324
|
+
const filePaths = getFilePathsFromDirectory(pathToScan, {
|
|
325
|
+
maxDepth: options.detectionDepth,
|
|
326
|
+
});
|
|
327
|
+
if (filePaths.length === 0) {
|
|
328
|
+
throw new NoFilesToScanError();
|
|
329
329
|
}
|
|
330
|
-
const
|
|
331
|
-
for (const filePath of filePaths) {
|
|
330
|
+
const loadedFiles = await Promise.all(filePaths.map(async (filePath) => {
|
|
332
331
|
try {
|
|
333
|
-
|
|
334
|
-
if (fileData) {
|
|
335
|
-
filesToScan.push(fileData);
|
|
336
|
-
}
|
|
332
|
+
return await tryLoadFileData(filePath);
|
|
337
333
|
}
|
|
338
334
|
catch (e) {
|
|
339
335
|
throw new FailedToLoadFileError(filePath);
|
|
340
336
|
}
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
throw new NoFilesToScanError();
|
|
344
|
-
}
|
|
345
|
-
return filesToScan.filter((file) => file.fileContent !== '');
|
|
337
|
+
}));
|
|
338
|
+
return loadedFiles.filter((file) => file.fileContent !== '');
|
|
346
339
|
}
|
|
347
340
|
exports.loadFiles = loadFiles;
|
|
341
|
+
function hasValidFileType(filePath) {
|
|
342
|
+
return types_1.VALID_FILE_TYPES.includes(iac_parser_1.getFileType(filePath));
|
|
343
|
+
}
|
|
348
344
|
function getFilePathsFromDirectory(pathToScan, options = {}) {
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
345
|
+
const resFilePaths = [];
|
|
346
|
+
if (detect_1.isLocalFolder(pathToScan)) {
|
|
347
|
+
// Directory
|
|
348
|
+
const dirIterator = makeDirectoryIterator_1.makeDirectoryIterator(pathToScan, {
|
|
349
|
+
maxDepth: options.maxDepth,
|
|
350
|
+
});
|
|
351
|
+
for (const filePath of dirIterator) {
|
|
352
|
+
if (hasValidFileType(filePath)) {
|
|
353
|
+
resFilePaths.push(filePath);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
355
356
|
}
|
|
356
|
-
|
|
357
|
+
else {
|
|
358
|
+
// File
|
|
359
|
+
if (hasValidFileType(pathToScan)) {
|
|
360
|
+
resFilePaths.push(pathToScan);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return resFilePaths;
|
|
357
364
|
}
|
|
358
365
|
async function tryLoadFileData(pathToScan) {
|
|
359
366
|
const fileType = iac_parser_1.getFileType(pathToScan);
|
|
360
|
-
if (!types_1.VALID_FILE_TYPES.includes(fileType)) {
|
|
361
|
-
return null;
|
|
362
|
-
}
|
|
363
367
|
const fileContent = (await fs_1.promises.readFile(pathToScan, DEFAULT_ENCODING)).toString();
|
|
364
368
|
return {
|
|
365
369
|
filePath: pathToScan,
|