snyk 1.848.0 → 1.849.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/562.index.js +105 -58
- package/dist/cli/562.index.js.map +1 -1
- package/dist/cli/index.js +1 -28
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/thirdPartyNotice.json +4 -4
- package/dist/lib/analytics/sources.d.ts +0 -1
- package/dist/lib/analytics/types.d.ts +0 -4
- package/package.json +7 -7
- package/help/README.md +0 -21
package/dist/cli/562.index.js
CHANGED
|
@@ -158856,12 +158856,13 @@ const admzip = __webpack_require__(55285);
|
|
|
158856
158856
|
const path = __webpack_require__(85622);
|
|
158857
158857
|
const buffer_utils_1 = __webpack_require__(29098);
|
|
158858
158858
|
function groupJarFingerprintsByPath(input) {
|
|
158859
|
-
const jarFingerprints = Object.entries(input).map(([filePath,
|
|
158859
|
+
const jarFingerprints = Object.entries(input).map(([filePath, buffer]) => {
|
|
158860
158860
|
return {
|
|
158861
158861
|
location: filePath,
|
|
158862
|
-
|
|
158862
|
+
buffer,
|
|
158863
158863
|
coords: null,
|
|
158864
158864
|
dependencies: [],
|
|
158865
|
+
nestedJars: [],
|
|
158865
158866
|
};
|
|
158866
158867
|
});
|
|
158867
158868
|
const resultAggregatedByPath = jarFingerprints.reduce((jarsAggregatedByPath, jarFingerprint) => {
|
|
@@ -158900,10 +158901,13 @@ async function jarFilesToScannedProjects(filePathToContent, targetImage, desired
|
|
|
158900
158901
|
}
|
|
158901
158902
|
exports.jarFilesToScannedProjects = jarFilesToScannedProjects;
|
|
158902
158903
|
function getFingerprints(desiredLevelsOfUnpacking, jarBuffers) {
|
|
158903
|
-
|
|
158904
|
+
const fingerprints = new Set([
|
|
158905
|
+
...unpackJars(jarBuffers, desiredLevelsOfUnpacking),
|
|
158906
|
+
]);
|
|
158907
|
+
return Array.from(fingerprints);
|
|
158904
158908
|
}
|
|
158905
158909
|
/**
|
|
158906
|
-
*
|
|
158910
|
+
* Unpacks a JAR and attempts to add coords to the
|
|
158907
158911
|
* package and it's dependencies.
|
|
158908
158912
|
*
|
|
158909
158913
|
* JARs will always be unpacked one level more than requested
|
|
@@ -158920,12 +158924,11 @@ function getFingerprints(desiredLevelsOfUnpacking, jarBuffers) {
|
|
|
158920
158924
|
* @param { number } props.desiredLevelsOfUnpacking
|
|
158921
158925
|
* @param { number } props.requiredLevelsOfUnpacking
|
|
158922
158926
|
* @param { number } props.unpackedLevels
|
|
158923
|
-
* @param { JarBuffer[] } props.jarBuffers
|
|
158924
|
-
* @param { JarCoords | null } props.coords
|
|
158925
|
-
* @param { JarCoords[] } props.dependencies
|
|
158926
158927
|
*/
|
|
158927
|
-
function
|
|
158928
|
-
|
|
158928
|
+
function unpackJar({ jarBuffer, jarPath, desiredLevelsOfUnpacking, requiredLevelsOfUnpacking, unpackedLevels, }) {
|
|
158929
|
+
const dependencies = [];
|
|
158930
|
+
const nestedJars = [];
|
|
158931
|
+
let coords = null;
|
|
158929
158932
|
let zip;
|
|
158930
158933
|
let zipEntries;
|
|
158931
158934
|
try {
|
|
@@ -158933,17 +158936,14 @@ function unpackJarsTraverse({ jarBuffer, jarPath, desiredLevelsOfUnpacking, requ
|
|
|
158933
158936
|
zipEntries = zip.getEntries();
|
|
158934
158937
|
}
|
|
158935
158938
|
catch (err) {
|
|
158936
|
-
|
|
158939
|
+
return {
|
|
158937
158940
|
location: jarPath,
|
|
158938
|
-
|
|
158939
|
-
dependencies,
|
|
158941
|
+
buffer: jarBuffer,
|
|
158940
158942
|
coords: null,
|
|
158941
|
-
|
|
158942
|
-
|
|
158943
|
+
dependencies,
|
|
158944
|
+
nestedJars,
|
|
158945
|
+
};
|
|
158943
158946
|
}
|
|
158944
|
-
// technically the level should be increased only if a JAR is found, but increasing here to make
|
|
158945
|
-
// sure it states the level, and not counting all the jars found, regardless of level.
|
|
158946
|
-
unpackedLevels = unpackedLevels + 1;
|
|
158947
158947
|
for (const zipEntry of zipEntries) {
|
|
158948
158948
|
// pom.properties is file describing a package or package dependency
|
|
158949
158949
|
// using this file allows resolution of shaded jars
|
|
@@ -158953,8 +158953,8 @@ function unpackJarsTraverse({ jarBuffer, jarPath, desiredLevelsOfUnpacking, requ
|
|
|
158953
158953
|
if (entryCoords) {
|
|
158954
158954
|
if (
|
|
158955
158955
|
// sometimes the path does not have the version
|
|
158956
|
-
jarPath.
|
|
158957
|
-
jarPath.
|
|
158956
|
+
jarPath.indexOf(`${entryCoords.artifactId}-${entryCoords.version}`) !== -1 ||
|
|
158957
|
+
jarPath.indexOf(`${entryCoords.artifactId}`) !== -1) {
|
|
158958
158958
|
coords = entryCoords;
|
|
158959
158959
|
}
|
|
158960
158960
|
else {
|
|
@@ -158968,33 +158968,33 @@ function unpackJarsTraverse({ jarBuffer, jarPath, desiredLevelsOfUnpacking, requ
|
|
|
158968
158968
|
if (desiredLevelsOfUnpacking > 0 &&
|
|
158969
158969
|
unpackedLevels < requiredLevelsOfUnpacking &&
|
|
158970
158970
|
zipEntry.entryName.endsWith(".jar")) {
|
|
158971
|
-
isFatJar = true;
|
|
158972
158971
|
const entryData = zipEntry.getData();
|
|
158973
158972
|
const entryName = zipEntry.entryName;
|
|
158974
|
-
|
|
158975
|
-
|
|
158976
|
-
|
|
158977
|
-
jarPath,
|
|
158978
|
-
desiredLevelsOfUnpacking,
|
|
158979
|
-
requiredLevelsOfUnpacking,
|
|
158980
|
-
unpackedLevels,
|
|
158981
|
-
jarBuffers,
|
|
158982
|
-
coords,
|
|
158983
|
-
dependencies,
|
|
158973
|
+
nestedJars.push({
|
|
158974
|
+
buffer: entryData,
|
|
158975
|
+
location: `${jarPath}/${entryName}`,
|
|
158984
158976
|
});
|
|
158985
158977
|
}
|
|
158986
158978
|
}
|
|
158987
|
-
|
|
158988
|
-
|
|
158989
|
-
|
|
158990
|
-
|
|
158991
|
-
|
|
158992
|
-
|
|
158993
|
-
|
|
158994
|
-
}
|
|
158995
|
-
return jarBuffers;
|
|
158979
|
+
return {
|
|
158980
|
+
location: jarPath,
|
|
158981
|
+
buffer: jarBuffer,
|
|
158982
|
+
coords,
|
|
158983
|
+
dependencies,
|
|
158984
|
+
nestedJars,
|
|
158985
|
+
};
|
|
158996
158986
|
}
|
|
158997
|
-
|
|
158987
|
+
/**
|
|
158988
|
+
* Manages the unpacking an array of JarBuffer objects and returns the resulting
|
|
158989
|
+
* fingerprints. Recursion to required depth is handled here when the returned
|
|
158990
|
+
* info from each JAR that is unpacked has nestedJars.
|
|
158991
|
+
*
|
|
158992
|
+
* @param {JarBuffer[]} jarBuffers
|
|
158993
|
+
* @param {number} desiredLevelsOfUnpacking
|
|
158994
|
+
* @param {number} unpackedLevels
|
|
158995
|
+
* @returns JarFingerprint[]
|
|
158996
|
+
*/
|
|
158997
|
+
function unpackJars(jarBuffers, desiredLevelsOfUnpacking, unpackedLevels = 0) {
|
|
158998
158998
|
// We have to unpack jars to get the pom.properties manifest which
|
|
158999
158999
|
// we use to support shaded jars and get the package coords (if exists)
|
|
159000
159000
|
// to reduce the dependency on maven search and support private jars.
|
|
@@ -159006,23 +159006,28 @@ function unpackJars(jarBuffers, desiredLevelsOfUnpacking) {
|
|
|
159006
159006
|
// requiredLevelsOfUnpacking = implementation control variable
|
|
159007
159007
|
const requiredLevelsOfUnpacking = desiredLevelsOfUnpacking + 1;
|
|
159008
159008
|
const fingerprints = [];
|
|
159009
|
+
// jarBuffers is the array of JARS found in the image layers;
|
|
159010
|
+
// this represents the 1st "level" which we will unpack by
|
|
159011
|
+
// default to analyse. Any JARs found when analysing are nested
|
|
159012
|
+
// and we will keep going until we have no more nested JARs or
|
|
159013
|
+
// the desired level of unpacking is met
|
|
159009
159014
|
for (const jarBuffer of jarBuffers) {
|
|
159010
|
-
const
|
|
159011
|
-
|
|
159012
|
-
jarBuffer: jarBuffer.digest,
|
|
159015
|
+
const jarInfo = unpackJar({
|
|
159016
|
+
jarBuffer: jarBuffer.buffer,
|
|
159013
159017
|
jarPath: jarBuffer.location,
|
|
159018
|
+
unpackedLevels: unpackedLevels + 1,
|
|
159014
159019
|
desiredLevelsOfUnpacking,
|
|
159015
159020
|
requiredLevelsOfUnpacking,
|
|
159016
|
-
unpackedLevels,
|
|
159017
|
-
coords: null,
|
|
159018
|
-
jarBuffers: [],
|
|
159019
159021
|
});
|
|
159020
159022
|
// if any of the coords are null for this JAR we didn't manage to get
|
|
159021
159023
|
// anything from the JAR's pom.properties manifest, so calculate the
|
|
159022
159024
|
// sha so maven-deps can fallback to searching maven central
|
|
159023
|
-
|
|
159024
|
-
|
|
159025
|
-
|
|
159025
|
+
fingerprints.push(Object.assign({ location: jarInfo.location, digest: jarInfo.coords ? null : buffer_utils_1.bufferToSha1(jarInfo.buffer), dependencies: jarInfo.dependencies }, jarInfo.coords));
|
|
159026
|
+
if (jarInfo.nestedJars.length > 0) {
|
|
159027
|
+
// this is an uber/fat JAR so we need to unpack the nested JARs to
|
|
159028
|
+
// analyse them for coords and further nested JARs (depth flag allowing)
|
|
159029
|
+
fingerprints.push(...unpackJars(jarInfo.nestedJars, desiredLevelsOfUnpacking, unpackedLevels + 1));
|
|
159030
|
+
}
|
|
159026
159031
|
}
|
|
159027
159032
|
return fingerprints;
|
|
159028
159033
|
}
|
|
@@ -159240,7 +159245,7 @@ async function pullWithDockerBinary(docker, targetImage, saveLocation, username,
|
|
|
159240
159245
|
}
|
|
159241
159246
|
}
|
|
159242
159247
|
async function pullFromContainerRegistry(docker, targetImage, imageSavePath, username, password) {
|
|
159243
|
-
const { hostname, imageName, tag } =
|
|
159248
|
+
const { hostname, imageName, tag } = extractImageDetails(targetImage);
|
|
159244
159249
|
debug(`Attempting to pull: registry: ${hostname}, image: ${imageName}, tag: ${tag}`);
|
|
159245
159250
|
await docker.pull(hostname, imageName, tag, imageSavePath, username, password);
|
|
159246
159251
|
}
|
|
@@ -159310,7 +159315,7 @@ async function getImageArchive(targetImage, imageSavePath, username, password, p
|
|
|
159310
159315
|
};
|
|
159311
159316
|
}
|
|
159312
159317
|
exports.getImageArchive = getImageArchive;
|
|
159313
|
-
|
|
159318
|
+
function extractImageDetails(targetImage) {
|
|
159314
159319
|
let remainder;
|
|
159315
159320
|
let hostname;
|
|
159316
159321
|
let imageName;
|
|
@@ -161058,6 +161063,10 @@ async function extractImageContent(imageType, fileSystemPath, extractActions) {
|
|
|
161058
161063
|
imageId: ociExtractor.getImageIdFromManifest(ociArchive.manifest),
|
|
161059
161064
|
manifestLayers: ociExtractor.getManifestLayers(ociArchive.manifest),
|
|
161060
161065
|
extractedLayers: layersWithLatestFileModifications(ociArchive.layers),
|
|
161066
|
+
rootFsLayers: dockerExtractor.getRootFsLayersFromConfig(ociArchive.imageConfig),
|
|
161067
|
+
autoDetectedUserInstructions: dockerExtractor.getDetectedLayersInfoFromConfig(ociArchive.imageConfig),
|
|
161068
|
+
platform: dockerExtractor.getPlatformFromConfig(ociArchive.imageConfig),
|
|
161069
|
+
imageLabels: ociArchive.imageConfig.config.Labels,
|
|
161061
161070
|
};
|
|
161062
161071
|
default:
|
|
161063
161072
|
const dockerArchive = await dockerExtractor.extractArchive(fileSystemPath, extractActions);
|
|
@@ -161226,6 +161235,7 @@ async function extractArchive(ociArchiveFilesystemPath, extractActions) {
|
|
|
161226
161235
|
const tarExtractor = tar_stream_1.extract();
|
|
161227
161236
|
const layers = {};
|
|
161228
161237
|
const manifests = {};
|
|
161238
|
+
let imageConfig;
|
|
161229
161239
|
let imageIndex;
|
|
161230
161240
|
tarExtractor.on("entry", async (header, stream, next) => {
|
|
161231
161241
|
if (header.type === "file") {
|
|
@@ -161252,6 +161262,9 @@ async function extractArchive(ociArchiveFilesystemPath, extractActions) {
|
|
|
161252
161262
|
if (isArchiveManifest(manifest)) {
|
|
161253
161263
|
manifests[digest] = manifest;
|
|
161254
161264
|
}
|
|
161265
|
+
else if (isImageConfigFile(manifest)) {
|
|
161266
|
+
imageConfig = manifest;
|
|
161267
|
+
}
|
|
161255
161268
|
if (layer !== undefined) {
|
|
161256
161269
|
layers[digest] = layer;
|
|
161257
161270
|
}
|
|
@@ -161262,7 +161275,7 @@ async function extractArchive(ociArchiveFilesystemPath, extractActions) {
|
|
|
161262
161275
|
});
|
|
161263
161276
|
tarExtractor.on("finish", () => {
|
|
161264
161277
|
try {
|
|
161265
|
-
resolve(getLayersContentAndArchiveManifest(imageIndex, manifests, layers));
|
|
161278
|
+
resolve(getLayersContentAndArchiveManifest(imageIndex, manifests, imageConfig, layers));
|
|
161266
161279
|
}
|
|
161267
161280
|
catch (error) {
|
|
161268
161281
|
debug(`Error getting layers and manifest content from oci archive: '${JSON.stringify(error)}'`);
|
|
@@ -161278,22 +161291,26 @@ async function extractArchive(ociArchiveFilesystemPath, extractActions) {
|
|
|
161278
161291
|
});
|
|
161279
161292
|
}
|
|
161280
161293
|
exports.extractArchive = extractArchive;
|
|
161281
|
-
function getLayersContentAndArchiveManifest(imageIndex, manifestCollection, layers) {
|
|
161294
|
+
function getLayersContentAndArchiveManifest(imageIndex, manifestCollection, imageConfig, layers) {
|
|
161282
161295
|
// filter empty layers
|
|
161283
161296
|
// get the layers content without the name
|
|
161284
161297
|
// reverse layers order from last to first
|
|
161285
161298
|
// get manifest file first
|
|
161286
161299
|
const manifest = getManifest(imageIndex, manifestCollection);
|
|
161287
161300
|
const filteredLayers = manifest.layers
|
|
161288
|
-
.filter((layer) =>
|
|
161301
|
+
.filter((layer) => layers[layer.digest])
|
|
161289
161302
|
.map((layer) => layers[layer.digest])
|
|
161290
161303
|
.reverse();
|
|
161291
161304
|
if (filteredLayers.length === 0) {
|
|
161292
161305
|
throw new Error("We found no layers in the provided image");
|
|
161293
161306
|
}
|
|
161307
|
+
if (imageConfig === undefined) {
|
|
161308
|
+
throw new Error("Could not find the image config in the provided image");
|
|
161309
|
+
}
|
|
161294
161310
|
return {
|
|
161295
161311
|
layers: filteredLayers,
|
|
161296
161312
|
manifest,
|
|
161313
|
+
imageConfig,
|
|
161297
161314
|
};
|
|
161298
161315
|
}
|
|
161299
161316
|
function getManifest(imageIndex, manifestCollection) {
|
|
@@ -161311,6 +161328,9 @@ function getManifest(imageIndex, manifestCollection) {
|
|
|
161311
161328
|
function isArchiveManifest(manifest) {
|
|
161312
161329
|
return (manifest !== undefined && manifest.layers && manifest.layers.length >= 0);
|
|
161313
161330
|
}
|
|
161331
|
+
function isImageConfigFile(json) {
|
|
161332
|
+
return json !== undefined && json.architecture && json.rootfs;
|
|
161333
|
+
}
|
|
161314
161334
|
function isImageIndexFile(name) {
|
|
161315
161335
|
return name === "index.json";
|
|
161316
161336
|
}
|
|
@@ -162705,6 +162725,7 @@ exports.streamToJson = exports.streamToSha1 = exports.streamToSha256 = exports.s
|
|
|
162705
162725
|
const crypto = __webpack_require__(76417);
|
|
162706
162726
|
const types_1 = __webpack_require__(93677);
|
|
162707
162727
|
const HASH_ENCODING = "hex";
|
|
162728
|
+
const MEGABYTE = 1 * 1024 * 1024;
|
|
162708
162729
|
async function streamToString(stream, streamSize, encoding = "utf8") {
|
|
162709
162730
|
const chunks = [];
|
|
162710
162731
|
return new Promise((resolve, reject) => {
|
|
@@ -162751,9 +162772,33 @@ async function streamToSha1(stream) {
|
|
|
162751
162772
|
return streamToHash(stream, types_1.HashAlgorithm.Sha1);
|
|
162752
162773
|
}
|
|
162753
162774
|
exports.streamToSha1 = streamToSha1;
|
|
162775
|
+
/**
|
|
162776
|
+
* Reads up to 2 megabytes from the stream and tries to JSON.parse the result.
|
|
162777
|
+
* Will reject if an error occurs from within the stream or when parsing cannot be done.
|
|
162778
|
+
*/
|
|
162754
162779
|
async function streamToJson(stream) {
|
|
162755
|
-
|
|
162756
|
-
|
|
162780
|
+
return new Promise((resolve, reject) => {
|
|
162781
|
+
const chunks = [];
|
|
162782
|
+
let bytes = 0;
|
|
162783
|
+
stream.on("end", () => {
|
|
162784
|
+
try {
|
|
162785
|
+
resolve(JSON.parse(chunks.join("")));
|
|
162786
|
+
}
|
|
162787
|
+
catch (error) {
|
|
162788
|
+
reject(error);
|
|
162789
|
+
}
|
|
162790
|
+
});
|
|
162791
|
+
stream.on("error", (error) => reject(error));
|
|
162792
|
+
stream.on("data", (chunk) => {
|
|
162793
|
+
bytes += chunk.length;
|
|
162794
|
+
if (bytes <= 2 * MEGABYTE) {
|
|
162795
|
+
chunks.push(chunk.toString("utf8"));
|
|
162796
|
+
}
|
|
162797
|
+
else {
|
|
162798
|
+
reject(new Error("The stream is too large to parse as JSON"));
|
|
162799
|
+
}
|
|
162800
|
+
});
|
|
162801
|
+
});
|
|
162757
162802
|
}
|
|
162758
162803
|
exports.streamToJson = streamToJson;
|
|
162759
162804
|
//# sourceMappingURL=stream-utils.js.map
|
|
@@ -170709,7 +170754,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
170709
170754
|
exports.LockParserBase = void 0;
|
|
170710
170755
|
const _cloneDeep = __webpack_require__(83465);
|
|
170711
170756
|
const _isEmpty = __webpack_require__(99245);
|
|
170712
|
-
const _set = __webpack_require__(31468);
|
|
170713
170757
|
const _toPairs = __webpack_require__(28052);
|
|
170714
170758
|
const graphlib = __webpack_require__(39322);
|
|
170715
170759
|
const uuid_1 = __webpack_require__(42277);
|
|
@@ -170740,7 +170784,10 @@ class LockParserBase {
|
|
|
170740
170784
|
};
|
|
170741
170785
|
const nodeVersion = (_a = manifestFile === null || manifestFile === void 0 ? void 0 : manifestFile.engines) === null || _a === void 0 ? void 0 : _a.node;
|
|
170742
170786
|
if (nodeVersion) {
|
|
170743
|
-
|
|
170787
|
+
if (!depTree.meta) {
|
|
170788
|
+
depTree.meta = {};
|
|
170789
|
+
}
|
|
170790
|
+
depTree.meta.nodeVersion = nodeVersion;
|
|
170744
170791
|
}
|
|
170745
170792
|
// asked to process empty deps
|
|
170746
170793
|
if (_isEmpty(manifestFile.dependencies) && !includeDev) {
|