snyk 1.1277.0 → 1.1278.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.
@@ -232396,6 +232396,7 @@ exports.inspect = inspect;
232396
232396
  Object.defineProperty(exports, "__esModule", ({ value: true }));
232397
232397
  exports.publish = exports.run = exports.restore = exports.validate = void 0;
232398
232398
  const debugModule = __webpack_require__(15158);
232399
+ const errors = __webpack_require__(62153);
232399
232400
  const errors_1 = __webpack_require__(62153);
232400
232401
  const path = __webpack_require__(71017);
232401
232402
  const subprocess = __webpack_require__(24862);
@@ -232432,9 +232433,21 @@ async function validate() {
232432
232433
  exports.validate = validate;
232433
232434
  async function restore(projectPath) {
232434
232435
  const command = 'dotnet';
232435
- const args = ['restore', '--no-cache', projectPath];
232436
- await handle('restore', command, args);
232437
- return;
232436
+ const args = ['restore', '--no-cache', '--verbosity', 'normal', projectPath];
232437
+ const result = await handle('restore', command, args);
232438
+ // A customer can define a <BaseOutPutPath> that redirects where `dotnet` saves the assets file. This will
232439
+ // get picked up by the dotnet tool and reported in the output logs.
232440
+ const regex = /Path:\s+(\S+project.assets.json)/g;
232441
+ const matches = result.stdout.matchAll(regex);
232442
+ const manifestFiles = [];
232443
+ for (const match of matches) {
232444
+ manifestFiles.push(match[1]);
232445
+ }
232446
+ if (manifestFiles.length === 0) {
232447
+ throw new errors.FileNotProcessableError('found no information in stdout about the whereabouts of the assets file');
232448
+ }
232449
+ // Return the last element in the log, as it might be mentioning local asset files in reverse order.
232450
+ return manifestFiles[manifestFiles.length - 1];
232438
232451
  }
232439
232452
  exports.restore = restore;
232440
232453
  async function run(projectPath, options) {
@@ -232806,7 +232819,6 @@ async function buildDepGraphFromFiles(root, targetFile, manifestType, useProject
232806
232819
  const safeTargetFile = targetFile || '.';
232807
232820
  const fileContentPath = path.resolve(safeRoot, safeTargetFile);
232808
232821
  const fileContent = getFileContents(fileContentPath);
232809
- const projectRootFolder = path.resolve(fileContentPath, '../../');
232810
232822
  const parser = PARSERS['dotnet-core-v2'];
232811
232823
  const projectAssets = await parser.fileContentParser.parse(fileContent);
232812
232824
  if (!((_a = projectAssets.project) === null || _a === void 0 ? void 0 : _a.frameworks)) {
@@ -232816,14 +232828,14 @@ async function buildDepGraphFromFiles(root, targetFile, manifestType, useProject
232816
232828
  // otherwise the raw key name, as it's not guaranteed that all framework objects contains a targetAlias.
232817
232829
  const targetFrameworks = Object.entries(projectAssets.project.frameworks).map(([key, value]) => ('targetAlias' in value ? value.targetAlias : key));
232818
232830
  if (targetFrameworks.length <= 0) {
232819
- throw new errors_1.FileNotProcessableError(`unable to detect a target framework in ${projectRootFolder}, a valid one is needed to continue down this path.`);
232831
+ throw new errors_1.FileNotProcessableError(`unable to detect a target framework in ${safeTargetFile}, a valid one is needed to continue down this path.`);
232820
232832
  }
232821
232833
  if (targetFramework && !targetFrameworks.includes(targetFramework)) {
232822
232834
  console.log(`\x1b[33m⚠ WARNING\x1b[0m: Supplied targetframework \x1b[1m${targetFramework}\x1b[0m was not detected in the supplied
232823
232835
  manifest file. Available targetFrameworks detected was \x1b[1m${targetFrameworks.join(',')}\x1b[0m.
232824
232836
  Will attempt to build dependency graph anyway, but the operation might fail.`);
232825
232837
  }
232826
- let resolvedProjectName = getRootName(root, projectRootFolder, projectNamePrefix);
232838
+ let resolvedProjectName = getRootName(root, safeRoot, projectNamePrefix);
232827
232839
  const projectNameFromManifestFile = (_c = (_b = projectAssets === null || projectAssets === void 0 ? void 0 : projectAssets.project) === null || _b === void 0 ? void 0 : _b.restore) === null || _c === void 0 ? void 0 : _c.projectName;
232828
232840
  if (manifestType === types_1.ManifestType.DOTNET_CORE &&
232829
232841
  useProjectNameFromAssetsFile) {
@@ -232847,12 +232859,12 @@ Will attempt to build dependency graph anyway, but the operation might fail.`);
232847
232859
  if (decidedTargetFrameworks.length == 0) {
232848
232860
  throw new errors_1.InvalidManifestError(`Was not able to find any supported TargetFrameworks to scan, aborting`);
232849
232861
  }
232862
+ // Ensure `dotnet` is installed on the system or fail trying.
232863
+ await dotnet.validate();
232850
232864
  const results = [];
232851
232865
  for (const decidedTargetFramework of decidedTargetFrameworks) {
232852
- // Ensure `dotnet` is installed on the system or fail trying.
232853
- await dotnet.validate();
232854
232866
  // Run `dotnet publish` to create a self-contained publishable binary with included .dlls for assembly version inspection.
232855
- const publishDir = await dotnet.publish(projectRootFolder, decidedTargetFramework);
232867
+ const publishDir = await dotnet.publish(safeRoot, decidedTargetFramework);
232856
232868
  // Then inspect the dependency graph for the runtimepackage's assembly versions.
232857
232869
  const depsFilePath = path.resolve(publishDir, `${projectNameFromManifestFile}.deps.json`);
232858
232870
  const depsFile = fs.readFileSync(depsFilePath);
@@ -233715,6 +233727,7 @@ const parseXML = __webpack_require__(5055);
233715
233727
  const debugModule = __webpack_require__(15158);
233716
233728
  const depsParser = __webpack_require__(91885);
233717
233729
  const framework_1 = __webpack_require__(93935);
233730
+ const errors_1 = __webpack_require__(62153);
233718
233731
  const debug = debugModule('snyk');
233719
233732
  function fromPackagesConfigEntry(manifest) {
233720
233733
  debug('Extracting by packages.config entry:' +
@@ -233736,13 +233749,14 @@ function parse(fileContent) {
233736
233749
  if (err) {
233737
233750
  throw err;
233738
233751
  }
233739
- else {
233740
- const packages = result.packages.package || [];
233741
- packages.forEach(function scanPackagesConfigNode(node) {
233742
- const installedDependency = fromPackagesConfigEntry(node);
233743
- installedPackages.push(installedDependency);
233744
- });
233752
+ if (!('packages' in result)) {
233753
+ throw new errors_1.InvalidManifestError(`Could not find a <packages> tag in your packages.config file. Please read this guide \x1b[4mhttps://learn.microsoft.com/en-us/nuget/reference/packages-config#schema\x1b[0m.`);
233745
233754
  }
233755
+ const packages = result.packages.package || [];
233756
+ packages.forEach(function scanPackagesConfigNode(node) {
233757
+ const installedDependency = fromPackagesConfigEntry(node);
233758
+ installedPackages.push(installedDependency);
233759
+ });
233746
233760
  });
233747
233761
  return installedPackages;
233748
233762
  }