snyk 1.808.0 → 1.809.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/727.index.js +112 -69
- package/dist/cli/727.index.js.map +1 -1
- package/dist/cli/thirdPartyNotice.json +2 -2
- package/package.json +2 -2
package/dist/cli/727.index.js
CHANGED
|
@@ -169907,7 +169907,7 @@ Object.defineProperty(exports, "nodeFilesToScannedProjects", ({ enumerable: true
|
|
|
169907
169907
|
"use strict";
|
|
169908
169908
|
|
|
169909
169909
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
169910
|
-
exports.parsePomProperties = exports.
|
|
169910
|
+
exports.parsePomProperties = exports.getCoordsFromPomProperties = exports.jarFilesToScannedProjects = void 0;
|
|
169911
169911
|
const admzip = __webpack_require__(55285);
|
|
169912
169912
|
const path = __webpack_require__(85622);
|
|
169913
169913
|
const buffer_utils_1 = __webpack_require__(29098);
|
|
@@ -169916,6 +169916,7 @@ function groupJarFingerprintsByPath(input) {
|
|
|
169916
169916
|
return {
|
|
169917
169917
|
location: filePath,
|
|
169918
169918
|
digest,
|
|
169919
|
+
coords: null,
|
|
169919
169920
|
dependencies: [],
|
|
169920
169921
|
};
|
|
169921
169922
|
});
|
|
@@ -169955,67 +169956,111 @@ async function jarFilesToScannedProjects(filePathToContent, targetImage, desired
|
|
|
169955
169956
|
}
|
|
169956
169957
|
exports.jarFilesToScannedProjects = jarFilesToScannedProjects;
|
|
169957
169958
|
function getFingerprints(desiredLevelsOfUnpacking, jarBuffers) {
|
|
169958
|
-
|
|
169959
|
-
|
|
169960
|
-
|
|
169961
|
-
|
|
169962
|
-
|
|
169963
|
-
|
|
169964
|
-
|
|
169965
|
-
|
|
169966
|
-
|
|
169967
|
-
|
|
169968
|
-
|
|
169959
|
+
return unpackJars(jarBuffers, desiredLevelsOfUnpacking);
|
|
169960
|
+
}
|
|
169961
|
+
/**
|
|
169962
|
+
* Recursively unpacks JARs and attempts to add coords to the
|
|
169963
|
+
* package and it's dependencies.
|
|
169964
|
+
*
|
|
169965
|
+
* JARs will always be unpacked one level more than requested
|
|
169966
|
+
* by the end-user in order to look for manifest files but will
|
|
169967
|
+
* ignore any JARs found for a level deeper than the user request.
|
|
169968
|
+
*
|
|
169969
|
+
* NOTE: desiredLevelsOfUnpacking and requiredLevelsOfUnpacking
|
|
169970
|
+
* are used to be explicit in nature and distinguish between the
|
|
169971
|
+
* level of JAR detection requested by the user and the level of
|
|
169972
|
+
* unpacking used in the implementation.
|
|
169973
|
+
* @param { object } props
|
|
169974
|
+
* @param { Buffer } props.jarBuffer
|
|
169975
|
+
* @param { string } props.jarPath
|
|
169976
|
+
* @param { number } props.desiredLevelsOfUnpacking
|
|
169977
|
+
* @param { number } props.requiredLevelsOfUnpacking
|
|
169978
|
+
* @param { number } props.unpackedLevels
|
|
169979
|
+
* @param { JarBuffer[] } props.jarBuffers
|
|
169980
|
+
* @param { JarCoords | null } props.coords
|
|
169981
|
+
* @param { JarCoords[] } props.dependencies
|
|
169982
|
+
*/
|
|
169983
|
+
function unpackJarsTraverse({ jarBuffer, jarPath, desiredLevelsOfUnpacking, requiredLevelsOfUnpacking, unpackedLevels, jarBuffers, coords = null, dependencies = [], }) {
|
|
169969
169984
|
let isFatJar = false;
|
|
169970
|
-
|
|
169985
|
+
let zip;
|
|
169986
|
+
let zipEntries;
|
|
169987
|
+
try {
|
|
169988
|
+
zip = new admzip(jarBuffer);
|
|
169989
|
+
zipEntries = zip.getEntries();
|
|
169990
|
+
}
|
|
169991
|
+
catch (err) {
|
|
169971
169992
|
jarBuffers.push({
|
|
169972
169993
|
location: jarPath,
|
|
169973
169994
|
digest: jarBuffer,
|
|
169974
169995
|
dependencies,
|
|
169996
|
+
coords: null,
|
|
169975
169997
|
});
|
|
169976
|
-
|
|
169977
|
-
|
|
169978
|
-
|
|
169979
|
-
|
|
169980
|
-
|
|
169981
|
-
|
|
169982
|
-
|
|
169983
|
-
|
|
169984
|
-
|
|
169985
|
-
|
|
169986
|
-
|
|
169987
|
-
|
|
169988
|
-
|
|
169989
|
-
|
|
169990
|
-
|
|
169998
|
+
return jarBuffers;
|
|
169999
|
+
}
|
|
170000
|
+
// technically the level should be increased only if a JAR is found, but increasing here to make
|
|
170001
|
+
// sure it states the level, and not counting all the jars found, regardless of level.
|
|
170002
|
+
unpackedLevels = unpackedLevels + 1;
|
|
170003
|
+
for (const zipEntry of zipEntries) {
|
|
170004
|
+
// pom.properties is file describing a package or package dependency
|
|
170005
|
+
// using this file allows resolution of shaded jars
|
|
170006
|
+
if (zipEntry.entryName.endsWith("pom.properties")) {
|
|
170007
|
+
const entryData = zipEntry.getData().toString();
|
|
170008
|
+
const entryCoords = getCoordsFromPomProperties(entryData);
|
|
170009
|
+
if (entryCoords) {
|
|
170010
|
+
if (
|
|
170011
|
+
// sometimes the path does not have the version
|
|
170012
|
+
jarPath.endsWith(`${entryCoords.artifactId}-${entryCoords.version}.jar`) ||
|
|
170013
|
+
jarPath.endsWith(`${entryCoords.artifactId}.jar`)) {
|
|
170014
|
+
coords = entryCoords;
|
|
170015
|
+
}
|
|
170016
|
+
else {
|
|
170017
|
+
dependencies.push(entryCoords);
|
|
169991
170018
|
}
|
|
169992
|
-
}
|
|
169993
|
-
if (zipEntry.entryName.endsWith(".jar")) {
|
|
169994
|
-
isFatJar = true;
|
|
169995
|
-
const entryData = zipEntry.getData();
|
|
169996
|
-
const entryName = zipEntry.entryName;
|
|
169997
|
-
jarPath = `${jarPath}/${entryName}`;
|
|
169998
|
-
unpackJarsTraverse({
|
|
169999
|
-
jarBuffer: entryData,
|
|
170000
|
-
jarPath,
|
|
170001
|
-
desiredLevelsOfUnpacking,
|
|
170002
|
-
unpackedLevels,
|
|
170003
|
-
jarBuffers,
|
|
170004
|
-
dependencies,
|
|
170005
|
-
});
|
|
170006
170019
|
}
|
|
170007
170020
|
}
|
|
170008
|
-
if
|
|
170009
|
-
|
|
170010
|
-
|
|
170011
|
-
|
|
170021
|
+
// We only want to include JARs found at this level if the user asked for
|
|
170022
|
+
// unpacking using the --nested-jar-depth flag and we are in a level less
|
|
170023
|
+
// than the required level
|
|
170024
|
+
if (desiredLevelsOfUnpacking > 0 &&
|
|
170025
|
+
unpackedLevels < requiredLevelsOfUnpacking &&
|
|
170026
|
+
zipEntry.entryName.endsWith(".jar")) {
|
|
170027
|
+
isFatJar = true;
|
|
170028
|
+
const entryData = zipEntry.getData();
|
|
170029
|
+
const entryName = zipEntry.entryName;
|
|
170030
|
+
jarPath = `${jarPath}/${entryName}`;
|
|
170031
|
+
unpackJarsTraverse({
|
|
170032
|
+
jarBuffer: entryData,
|
|
170033
|
+
jarPath,
|
|
170034
|
+
desiredLevelsOfUnpacking,
|
|
170035
|
+
requiredLevelsOfUnpacking,
|
|
170036
|
+
unpackedLevels,
|
|
170037
|
+
jarBuffers,
|
|
170038
|
+
coords,
|
|
170012
170039
|
dependencies,
|
|
170013
170040
|
});
|
|
170014
170041
|
}
|
|
170015
170042
|
}
|
|
170043
|
+
if (!isFatJar) {
|
|
170044
|
+
jarBuffers.push({
|
|
170045
|
+
location: jarPath,
|
|
170046
|
+
digest: jarBuffer,
|
|
170047
|
+
coords,
|
|
170048
|
+
dependencies,
|
|
170049
|
+
});
|
|
170050
|
+
}
|
|
170016
170051
|
return jarBuffers;
|
|
170017
170052
|
}
|
|
170018
|
-
function
|
|
170053
|
+
function unpackJars(jarBuffers, desiredLevelsOfUnpacking) {
|
|
170054
|
+
// We have to unpack jars to get the pom.properties manifest which
|
|
170055
|
+
// we use to support shaded jars and get the package coords (if exists)
|
|
170056
|
+
// to reduce the dependency on maven search and support private jars.
|
|
170057
|
+
// This means that we must unpack 1 more level than customer requests
|
|
170058
|
+
// via --nested-jar-depth option in CLI and the default value for
|
|
170059
|
+
// K8S and DRA integrations
|
|
170060
|
+
//
|
|
170061
|
+
// desiredLevelsOfUnpacking = user specified (--nested-jar-depth) or default
|
|
170062
|
+
// requiredLevelsOfUnpacking = implementation control variable
|
|
170063
|
+
const requiredLevelsOfUnpacking = desiredLevelsOfUnpacking + 1;
|
|
170019
170064
|
const fingerprints = [];
|
|
170020
170065
|
for (const jarBuffer of jarBuffers) {
|
|
170021
170066
|
const unpackedLevels = 0;
|
|
@@ -170023,52 +170068,50 @@ function unpackFatJars(jarBuffers, desiredLevelsOfUnpacking) {
|
|
|
170023
170068
|
jarBuffer: jarBuffer.digest,
|
|
170024
170069
|
jarPath: jarBuffer.location,
|
|
170025
170070
|
desiredLevelsOfUnpacking,
|
|
170071
|
+
requiredLevelsOfUnpacking,
|
|
170026
170072
|
unpackedLevels,
|
|
170073
|
+
coords: null,
|
|
170027
170074
|
jarBuffers: [],
|
|
170028
170075
|
});
|
|
170029
|
-
|
|
170076
|
+
// if any of the coords are null for this JAR we didn't manage to get
|
|
170077
|
+
// anything from the JAR's pom.properties manifest, so calculate the
|
|
170078
|
+
// sha so maven-deps can fallback to searching maven central
|
|
170079
|
+
jars.forEach((jar) => {
|
|
170080
|
+
fingerprints.push(Object.assign({ location: jar.location, digest: jar.coords ? null : buffer_utils_1.bufferToSha1(jar.digest), dependencies: jar.dependencies }, jar.coords));
|
|
170081
|
+
});
|
|
170030
170082
|
}
|
|
170031
170083
|
return fingerprints;
|
|
170032
170084
|
}
|
|
170033
170085
|
/**
|
|
170034
|
-
* Gets
|
|
170035
|
-
* a pom.properties file that describes a JAR dependency
|
|
170086
|
+
* Gets coords from the contents of a pom.properties file
|
|
170036
170087
|
* @param {string} fileContent
|
|
170037
170088
|
* @param {string} jarPath
|
|
170038
170089
|
*/
|
|
170039
|
-
function
|
|
170040
|
-
const
|
|
170041
|
-
// we need all of these props to allow us to inject the
|
|
170090
|
+
function getCoordsFromPomProperties(fileContent) {
|
|
170091
|
+
const coords = parsePomProperties(fileContent);
|
|
170092
|
+
// we need all of these props to allow us to inject the package
|
|
170042
170093
|
// into the depGraph
|
|
170043
|
-
if (!
|
|
170094
|
+
if (!coords.artifactId || !coords.groupId || !coords.version) {
|
|
170044
170095
|
return null;
|
|
170045
170096
|
}
|
|
170046
|
-
|
|
170047
|
-
if (dep && !jarPath.endsWith(`${dep.name}-${dep.version}.jar`)) {
|
|
170048
|
-
return dep;
|
|
170049
|
-
}
|
|
170050
|
-
return null;
|
|
170097
|
+
return coords;
|
|
170051
170098
|
}
|
|
170052
|
-
exports.
|
|
170099
|
+
exports.getCoordsFromPomProperties = getCoordsFromPomProperties;
|
|
170053
170100
|
/**
|
|
170054
170101
|
* Parses the file content of a pom.properties file to extract
|
|
170055
|
-
* the
|
|
170102
|
+
* the coords for a package.
|
|
170056
170103
|
* @param {string} fileContent
|
|
170057
170104
|
*/
|
|
170058
170105
|
function parsePomProperties(fileContent) {
|
|
170059
170106
|
const fileContentLines = fileContent
|
|
170060
170107
|
.split(/\n/)
|
|
170061
170108
|
.filter((line) => /^(groupId|artifactId|version)=/.test(line)); // These are the only properties we are interested in
|
|
170062
|
-
const
|
|
170109
|
+
const coords = fileContentLines.reduce((coords, line) => {
|
|
170063
170110
|
const [key, value] = line.split("=");
|
|
170064
|
-
|
|
170065
|
-
return
|
|
170111
|
+
coords[key] = value.trim(); // Getting rid of EOL
|
|
170112
|
+
return coords;
|
|
170066
170113
|
}, {});
|
|
170067
|
-
return
|
|
170068
|
-
name: dep.artifactId,
|
|
170069
|
-
parentName: dep.groupId,
|
|
170070
|
-
version: dep.version,
|
|
170071
|
-
};
|
|
170114
|
+
return coords;
|
|
170072
170115
|
}
|
|
170073
170116
|
exports.parsePomProperties = parsePomProperties;
|
|
170074
170117
|
//# sourceMappingURL=java.js.map
|