snyk 1.796.0 → 1.800.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.
@@ -169854,7 +169854,7 @@ Object.defineProperty(exports, "nodeFilesToScannedProjects", ({ enumerable: true
169854
169854
  "use strict";
169855
169855
 
169856
169856
  Object.defineProperty(exports, "__esModule", ({ value: true }));
169857
- exports.jarFilesToScannedProjects = void 0;
169857
+ exports.parsePomProperties = exports.getDependencyFromPomProperties = exports.jarFilesToScannedProjects = void 0;
169858
169858
  const admzip = __webpack_require__(55285);
169859
169859
  const path = __webpack_require__(85622);
169860
169860
  const buffer_utils_1 = __webpack_require__(29098);
@@ -169863,6 +169863,7 @@ function groupJarFingerprintsByPath(input) {
169863
169863
  return {
169864
169864
  location: filePath,
169865
169865
  digest,
169866
+ dependencies: [],
169866
169867
  };
169867
169868
  });
169868
169869
  const resultAggregatedByPath = jarFingerprints.reduce((jarsAggregatedByPath, jarFingerprint) => {
@@ -169911,12 +169912,13 @@ function getJarShas(jarBuffers) {
169911
169912
  return Object.assign(Object.assign({}, element), { digest: buffer_utils_1.bufferToSha1(element.digest) });
169912
169913
  });
169913
169914
  }
169914
- function unpackJarsTraverse({ jarBuffer, jarPath, desiredLevelsOfUnpacking, unpackedLevels, jarBuffers, }) {
169915
+ function unpackJarsTraverse({ jarBuffer, jarPath, desiredLevelsOfUnpacking, unpackedLevels, jarBuffers, dependencies = [], }) {
169915
169916
  let isFatJar = false;
169916
169917
  if (unpackedLevels >= desiredLevelsOfUnpacking) {
169917
169918
  jarBuffers.push({
169918
169919
  location: jarPath,
169919
169920
  digest: jarBuffer,
169921
+ dependencies,
169920
169922
  });
169921
169923
  }
169922
169924
  else {
@@ -169926,6 +169928,15 @@ function unpackJarsTraverse({ jarBuffer, jarPath, desiredLevelsOfUnpacking, unpa
169926
169928
  // sure it states the level, and not counting all the jars found, regardless of level.
169927
169929
  unpackedLevels = unpackedLevels + 1;
169928
169930
  for (const zipEntry of zipEntries) {
169931
+ // pom.properties is file describing a dependency within a JAR
169932
+ // using this file allows resolution of shaded jars
169933
+ if (zipEntry.entryName.endsWith("pom.properties")) {
169934
+ const entryData = zipEntry.getData().toString();
169935
+ const dep = getDependencyFromPomProperties(entryData, jarPath);
169936
+ if (dep) {
169937
+ dependencies.push(dep);
169938
+ }
169939
+ }
169929
169940
  if (zipEntry.entryName.endsWith(".jar")) {
169930
169941
  isFatJar = true;
169931
169942
  const entryData = zipEntry.getData();
@@ -169937,6 +169948,7 @@ function unpackJarsTraverse({ jarBuffer, jarPath, desiredLevelsOfUnpacking, unpa
169937
169948
  desiredLevelsOfUnpacking,
169938
169949
  unpackedLevels,
169939
169950
  jarBuffers,
169951
+ dependencies,
169940
169952
  });
169941
169953
  }
169942
169954
  }
@@ -169944,6 +169956,7 @@ function unpackJarsTraverse({ jarBuffer, jarPath, desiredLevelsOfUnpacking, unpa
169944
169956
  jarBuffers.push({
169945
169957
  location: jarPath,
169946
169958
  digest: jarBuffer,
169959
+ dependencies,
169947
169960
  });
169948
169961
  }
169949
169962
  }
@@ -169964,6 +169977,47 @@ function unpackFatJars(jarBuffers, desiredLevelsOfUnpacking) {
169964
169977
  }
169965
169978
  return fingerprints;
169966
169979
  }
169980
+ /**
169981
+ * Gets a formatted dependency object from the contents of
169982
+ * a pom.properties file that describes a JAR dependency
169983
+ * @param {string} fileContent
169984
+ * @param {string} jarPath
169985
+ */
169986
+ function getDependencyFromPomProperties(fileContent, jarPath) {
169987
+ const dep = parsePomProperties(fileContent);
169988
+ // we need all of these props to allow us to inject the dependency
169989
+ // into the depGraph
169990
+ if (!dep.name || !dep.parentName || !dep.version) {
169991
+ return null;
169992
+ }
169993
+ // Dependency shouldn't be a reference for the JAR itself
169994
+ if (dep && !jarPath.endsWith(`${dep.name}-${dep.version}.jar`)) {
169995
+ return dep;
169996
+ }
169997
+ return null;
169998
+ }
169999
+ exports.getDependencyFromPomProperties = getDependencyFromPomProperties;
170000
+ /**
170001
+ * Parses the file content of a pom.properties file to extract
170002
+ * the "fields" for a JAR dependency.
170003
+ * @param {string} fileContent
170004
+ */
170005
+ function parsePomProperties(fileContent) {
170006
+ const fileContentLines = fileContent
170007
+ .split(/\n/)
170008
+ .filter((line) => /^(groupId|artifactId|version)=/.test(line)); // These are the only properties we are interested in
170009
+ const dep = fileContentLines.reduce((dep, line) => {
170010
+ const [key, value] = line.split("=");
170011
+ dep[key] = value.trim(); // Getting rid of EOL
170012
+ return dep;
170013
+ }, {});
170014
+ return {
170015
+ name: dep.artifactId,
170016
+ parentName: dep.groupId,
170017
+ version: dep.version,
170018
+ };
170019
+ }
170020
+ exports.parsePomProperties = parsePomProperties;
169967
170021
  //# sourceMappingURL=java.js.map
169968
170022
 
169969
170023
  /***/ }),