snyk 1.720.0 → 1.721.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.
@@ -183441,10 +183441,6 @@ function createAssets() {
183441
183441
  // https://www.npmjs.com/package/pkg#detecting-assets-in-source-code
183442
183442
  return [
183443
183443
  path.join(__dirname, '../gosrc/resolve-deps.go'),
183444
- path.join(__dirname, '../gosrc/resolver/pkg.go'),
183445
- path.join(__dirname, '../gosrc/resolver/resolver.go'),
183446
- path.join(__dirname, '../gosrc/resolver/dirwalk/dirwalk.go'),
183447
- path.join(__dirname, '../gosrc/resolver/graph/graph.go'),
183448
183444
  ];
183449
183445
  }
183450
183446
  function writeFile(writeFilePath, contents) {
@@ -183505,7 +183501,7 @@ async function getDependencies(root, targetFile) {
183505
183501
  }
183506
183502
  const args = ['run', goResolveTool, ignorePkgsParam];
183507
183503
  debug('executing go deps resolver', { cmd: 'go' + args.join(' ') });
183508
- const graphStr = await subProcess.execute('go', args, { cwd: root });
183504
+ const graphStr = await runGo(args, { cwd: root, env: { GO111MODULE: 'off' } });
183509
183505
  tempDirObj.removeCallback();
183510
183506
  debug('loading deps resolver graph output to graphlib', { jsonSize: graphStr.length });
183511
183507
  const graph = graphlib.json.read(JSON.parse(graphStr));
@@ -183693,9 +183689,12 @@ async function buildDepGraphFromImportsAndModules(root = '.', targetFile = 'go.m
183693
183689
  let goDepsOutput;
183694
183690
  try {
183695
183691
  const goModAbsolutPath = path.resolve(root, path.dirname(targetFile));
183696
- goDepsOutput = await subProcess.execute('go list', ['-json', '-deps', './...'], { cwd: goModAbsolutPath });
183692
+ goDepsOutput = await runGo(['list', '-json', '-deps', './...'], { cwd: goModAbsolutPath });
183697
183693
  }
183698
183694
  catch (err) {
183695
+ if (/cannot find main module, but found/.test(err)) {
183696
+ return depGraphBuilder.build();
183697
+ }
183699
183698
  const userError = new custom_error_1.CustomError(err);
183700
183699
  userError.userMessage = "'go list -json -deps ./...' command failed with error: " + userError.message;
183701
183700
  throw userError;
@@ -183725,6 +183724,21 @@ async function buildDepGraphFromImportsAndModules(root = '.', targetFile = 'go.m
183725
183724
  return depGraphBuilder.build();
183726
183725
  }
183727
183726
  exports.buildDepGraphFromImportsAndModules = buildDepGraphFromImportsAndModules;
183727
+ async function runGo(args, options, additionalGoCommands = []) {
183728
+ try {
183729
+ return await subProcess.execute('go', args, options);
183730
+ }
183731
+ catch (err) {
183732
+ const [command] = /(go mod download)|(go get [^"]*)/.exec(err) || [];
183733
+ if (command && !additionalGoCommands.includes(command)) {
183734
+ debug('running command:', command);
183735
+ const [_, ...newArgs] = command.split(' ');
183736
+ await subProcess.execute('go', newArgs, options);
183737
+ return runGo(args, options, additionalGoCommands.concat(command));
183738
+ }
183739
+ throw err;
183740
+ }
183741
+ }
183728
183742
  function buildGraph(depGraphBuilder, depPackages, packagesByName, currentParent, childrenChain, ancestorsChain) {
183729
183743
  var _a;
183730
183744
  const depPackagesLen = depPackages.length;
@@ -183812,9 +183826,12 @@ function execute(command, args, options) {
183812
183826
  // Even just running `go version > 1.txt` in the terminal produces an empty file.
183813
183827
  }
183814
183828
  const spawnOptions = { shell: true };
183815
- if (options && options.cwd) {
183829
+ if (options === null || options === void 0 ? void 0 : options.cwd) {
183816
183830
  spawnOptions.cwd = options.cwd;
183817
183831
  }
183832
+ if (options === null || options === void 0 ? void 0 : options.env) {
183833
+ spawnOptions.env = Object.assign(Object.assign({}, process.env), options.env);
183834
+ }
183818
183835
  return new Promise((resolve, reject) => {
183819
183836
  let stdout = '';
183820
183837
  let stderr = '';