snyk 1.1191.0 → 1.1192.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/784.index.js +92 -50
- package/dist/cli/784.index.js.map +1 -1
- package/dist/cli/95.index.js +6090 -644
- package/dist/cli/95.index.js.map +1 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/thirdPartyNotice.json +2 -2
- package/dist/lib/plugins/sast/analysis.d.ts +3 -0
- package/dist/lib/plugins/sast/types.d.ts +3 -3
- package/dist/lib/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/generated/sha256sums.txt +10 -10
- package/src/generated/version +1 -1
- package/wrapper_dist/generated/sha256sums.txt +10 -10
- package/wrapper_dist/generated/version +1 -1
package/dist/cli/784.index.js
CHANGED
|
@@ -4712,31 +4712,19 @@ const chalk_1 = __webpack_require__(32589);
|
|
|
4712
4712
|
const debugLib = __webpack_require__(15158);
|
|
4713
4713
|
const code_config_1 = __webpack_require__(55203);
|
|
4714
4714
|
const debug = debugLib('snyk-code');
|
|
4715
|
+
/**
|
|
4716
|
+
* Bootstrap and trigger a Code test, then return the results.
|
|
4717
|
+
*/
|
|
4715
4718
|
async function getCodeTestResults(root, options, sastSettings, requestId) {
|
|
4716
4719
|
await spinner_1.spinner.clearAll();
|
|
4717
4720
|
utils_1.analysisProgressUpdate();
|
|
4718
|
-
const codeAnalysis = await getCodeAnalysis(root, options, sastSettings, requestId);
|
|
4719
|
-
spinner_1.spinner.clearAll();
|
|
4720
|
-
if (!codeAnalysis) {
|
|
4721
|
-
return null;
|
|
4722
|
-
}
|
|
4723
|
-
return {
|
|
4724
|
-
reportResults: codeAnalysis.reportResults,
|
|
4725
|
-
analysisResults: codeAnalysis.analysisResults,
|
|
4726
|
-
};
|
|
4727
|
-
}
|
|
4728
|
-
exports.getCodeTestResults = getCodeTestResults;
|
|
4729
|
-
async function getCodeAnalysis(root, options, sastSettings, requestId) {
|
|
4730
|
-
var _a, _b;
|
|
4731
4721
|
const isLocalCodeEngineEnabled = isLocalCodeEngine(sastSettings);
|
|
4732
4722
|
if (isLocalCodeEngineEnabled) {
|
|
4733
4723
|
validateLocalCodeEngineUrl(sastSettings.localCodeEngine.url);
|
|
4734
4724
|
}
|
|
4735
|
-
const source = 'snyk-cli';
|
|
4736
4725
|
const baseURL = isLocalCodeEngineEnabled
|
|
4737
4726
|
? sastSettings.localCodeEngine.url
|
|
4738
4727
|
: code_config_1.getCodeClientProxyUrl();
|
|
4739
|
-
const org = sastSettings.org;
|
|
4740
4728
|
// TODO(james) This mirrors the implementation in request.ts and we need to use this for deeproxy calls
|
|
4741
4729
|
// This ensures we support lowercase http(s)_proxy values as well
|
|
4742
4730
|
// The weird IF around it ensures we don't create an envvar with
|
|
@@ -4754,46 +4742,100 @@ async function getCodeAnalysis(root, options, sastSettings, requestId) {
|
|
|
4754
4742
|
environmentVariableNamespace: '',
|
|
4755
4743
|
});
|
|
4756
4744
|
}
|
|
4757
|
-
const
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4745
|
+
const analysisArgs = {
|
|
4746
|
+
options,
|
|
4747
|
+
fileOptions: {
|
|
4748
|
+
paths: [root],
|
|
4749
|
+
},
|
|
4750
|
+
connectionOptions: {
|
|
4763
4751
|
baseURL,
|
|
4764
|
-
sessionToken,
|
|
4765
|
-
source,
|
|
4752
|
+
sessionToken: api_token_1.getAuthHeader(),
|
|
4753
|
+
source: 'snyk-cli',
|
|
4766
4754
|
requestId,
|
|
4767
|
-
org,
|
|
4755
|
+
org: sastSettings.org,
|
|
4756
|
+
},
|
|
4757
|
+
analysisOptions: {
|
|
4758
|
+
severity: options.severityThreshold
|
|
4759
|
+
? severityToAnalysisSeverity(options.severityThreshold)
|
|
4760
|
+
: code_client_1.AnalysisSeverity.info,
|
|
4761
|
+
},
|
|
4762
|
+
supportedLanguages: sastSettings.supportedLanguages,
|
|
4763
|
+
};
|
|
4764
|
+
const codeAnalysis = await getCodeAnalysis(analysisArgs);
|
|
4765
|
+
spinner_1.spinner.clearAll();
|
|
4766
|
+
if (!codeAnalysis) {
|
|
4767
|
+
return null;
|
|
4768
|
+
}
|
|
4769
|
+
return {
|
|
4770
|
+
reportResults: codeAnalysis.reportResults,
|
|
4771
|
+
analysisResults: codeAnalysis.analysisResults,
|
|
4772
|
+
};
|
|
4773
|
+
}
|
|
4774
|
+
exports.getCodeTestResults = getCodeTestResults;
|
|
4775
|
+
/**
|
|
4776
|
+
* Performs Code analysis and returns normalised results.
|
|
4777
|
+
* Analysis method (i.e. file-based or SCM) is chosen based on flow options.
|
|
4778
|
+
*/
|
|
4779
|
+
async function getCodeAnalysis(args) {
|
|
4780
|
+
var _a, _b;
|
|
4781
|
+
const { options, fileOptions, analysisOptions, connectionOptions, supportedLanguages, } = args;
|
|
4782
|
+
const analysisContext = {
|
|
4783
|
+
initiator: 'CLI',
|
|
4784
|
+
flow: connectionOptions.source,
|
|
4785
|
+
projectName: config_1.default.PROJECT_NAME,
|
|
4786
|
+
project: {
|
|
4787
|
+
name: options['project-name'] || config_1.default.PROJECT_NAME || 'unknown',
|
|
4788
|
+
publicId: options['project-id'] || 'unknown',
|
|
4789
|
+
type: 'sast',
|
|
4768
4790
|
},
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4791
|
+
org: {
|
|
4792
|
+
name: connectionOptions.org || 'unknown',
|
|
4793
|
+
displayName: 'unknown',
|
|
4794
|
+
publicId: 'unknown',
|
|
4795
|
+
flags: {},
|
|
4796
|
+
},
|
|
4797
|
+
};
|
|
4798
|
+
let result = null;
|
|
4799
|
+
// When the "report" arg is provided the test results are published on the platform.
|
|
4800
|
+
const isReportFlow = (_a = options.report) !== null && _a !== void 0 ? _a : false;
|
|
4801
|
+
// We differentiate between file-based reporting flows
|
|
4802
|
+
// and SCM-based ones by looking at the "project-id" arg.
|
|
4803
|
+
const isScmReportFlow = isReportFlow && options['project-id'];
|
|
4804
|
+
if (isScmReportFlow) {
|
|
4805
|
+
// Run an SCM analysis test with reporting.
|
|
4806
|
+
result = await code_client_1.analyzeScmProject({
|
|
4807
|
+
connection: connectionOptions,
|
|
4808
|
+
analysisOptions,
|
|
4772
4809
|
reportOptions: {
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
targetName: options['target-name'],
|
|
4776
|
-
targetRef: options['target-reference'],
|
|
4777
|
-
remoteRepoUrl: options['remote-repo-url'],
|
|
4810
|
+
projectId: options['project-id'],
|
|
4811
|
+
commitId: options['commit-id'],
|
|
4778
4812
|
},
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4813
|
+
analysisContext,
|
|
4814
|
+
});
|
|
4815
|
+
}
|
|
4816
|
+
else {
|
|
4817
|
+
// Run a file-based test, optionally with reporting.
|
|
4818
|
+
result = await code_client_1.analyzeFolders({
|
|
4819
|
+
connection: connectionOptions,
|
|
4820
|
+
analysisOptions,
|
|
4821
|
+
fileOptions,
|
|
4822
|
+
...(isReportFlow && {
|
|
4823
|
+
reportOptions: {
|
|
4824
|
+
enabled: true,
|
|
4825
|
+
projectName: options['project-name'],
|
|
4826
|
+
targetName: options['target-name'],
|
|
4827
|
+
targetRef: options['target-reference'],
|
|
4828
|
+
remoteRepoUrl: options['remote-repo-url'],
|
|
4829
|
+
},
|
|
4830
|
+
}),
|
|
4831
|
+
analysisContext,
|
|
4832
|
+
languages: supportedLanguages,
|
|
4833
|
+
});
|
|
4834
|
+
if ((_b = result === null || result === void 0 ? void 0 : result.fileBundle.skippedOversizedFiles) === null || _b === void 0 ? void 0 : _b.length) {
|
|
4835
|
+
debug('\n', chalk_1.default.yellow(`Warning!\nFiles were skipped in the analysis due to their size being greater than ${code_client_1.MAX_FILE_SIZE}B. Skipped files: ${[
|
|
4836
|
+
...result.fileBundle.skippedOversizedFiles,
|
|
4837
|
+
].join(', ')}`));
|
|
4838
|
+
}
|
|
4797
4839
|
}
|
|
4798
4840
|
if (!result || result.analysisResults.type !== 'sarif') {
|
|
4799
4841
|
return null;
|