snyk 1.1028.0 → 1.1030.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
CHANGED
|
@@ -1021,8 +1021,8 @@ const plugin_analytics_1 = __webpack_require__(33077);
|
|
|
1021
1021
|
const policy_1 = __webpack_require__(32615);
|
|
1022
1022
|
const policy_2 = __webpack_require__(4669);
|
|
1023
1023
|
const feature_flags_1 = __webpack_require__(63011);
|
|
1024
|
-
const common_1 = __webpack_require__(74434);
|
|
1025
1024
|
const utils_1 = __webpack_require__(97875);
|
|
1025
|
+
const common_1 = __webpack_require__(70527);
|
|
1026
1026
|
async function resolveAndTestFacts(ecosystem, scans, options) {
|
|
1027
1027
|
const unmanagedDepsOverride = process.env.USE_UNMANAGED_DEPS;
|
|
1028
1028
|
const featureFlagEnabled = await feature_flags_1.hasFeatureFlag('snykNewUnmanagedTest', options);
|
|
@@ -1035,20 +1035,22 @@ async function submitHashes(hashes, orgId) {
|
|
|
1035
1035
|
const response = await polling_test_1.createDepGraph(hashes, orgId);
|
|
1036
1036
|
return response.data.id;
|
|
1037
1037
|
}
|
|
1038
|
-
async function
|
|
1039
|
-
|
|
1040
|
-
const
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1038
|
+
async function pollDepGraphAttributes(id, orgId) {
|
|
1039
|
+
const maxIntervalMs = 60000;
|
|
1040
|
+
const minIntervalMs = 5000;
|
|
1041
|
+
const maxAttempts = 31; // Corresponds to 25.5 minutes
|
|
1042
|
+
// Loop until we receive a response that is not in progress,
|
|
1043
|
+
// or we receive something else than http status code 200.
|
|
1044
|
+
for (let i = 1; i <= maxAttempts; i++) {
|
|
1045
|
+
const graph = await polling_test_1.getDepGraph(id, orgId);
|
|
1046
|
+
if (graph.data.attributes.in_progress) {
|
|
1047
|
+
const pollInterval = Math.max(maxIntervalMs, minIntervalMs * i);
|
|
1048
|
+
await common_1.sleep(pollInterval * i);
|
|
1049
|
+
continue;
|
|
1049
1050
|
}
|
|
1051
|
+
return graph.data.attributes;
|
|
1050
1052
|
}
|
|
1051
|
-
|
|
1053
|
+
throw new Error('max retries reached');
|
|
1052
1054
|
}
|
|
1053
1055
|
async function fetchIssues(start_time, dep_graph_data, component_details, orgId) {
|
|
1054
1056
|
var _a, _b;
|
|
@@ -1093,7 +1095,7 @@ async function resolveAndTestFactsUnmanagedDeps(scans, options) {
|
|
|
1093
1095
|
for (const scanResult of scanResults) {
|
|
1094
1096
|
try {
|
|
1095
1097
|
const id = await submitHashes({ hashes: (_a = scanResult === null || scanResult === void 0 ? void 0 : scanResult.facts[0]) === null || _a === void 0 ? void 0 : _a.data }, orgId);
|
|
1096
|
-
const { start_time, dep_graph_data, component_details, } = await
|
|
1098
|
+
const { start_time, dep_graph_data, component_details, } = await pollDepGraphAttributes(id, orgId);
|
|
1097
1099
|
const { issues, issuesData, depGraphData, dependencyCount, depsFilePaths, fileSignaturesDetails, } = await fetchIssues(start_time, dep_graph_data, component_details, orgId);
|
|
1098
1100
|
const issuesMap = new Map();
|
|
1099
1101
|
issues.forEach((i) => {
|
|
@@ -1101,8 +1103,8 @@ async function resolveAndTestFactsUnmanagedDeps(scans, options) {
|
|
|
1101
1103
|
});
|
|
1102
1104
|
const vulnerabilities = [];
|
|
1103
1105
|
for (const issuesDataKey in issuesData) {
|
|
1104
|
-
const issueData = issuesData[issuesDataKey];
|
|
1105
1106
|
const pkgCoordinate = `${(_b = issuesMap[issuesDataKey]) === null || _b === void 0 ? void 0 : _b.pkgName}@${(_c = issuesMap[issuesDataKey]) === null || _c === void 0 ? void 0 : _c.pkgVersion}`;
|
|
1107
|
+
const issueData = issuesData[issuesDataKey];
|
|
1106
1108
|
issueData.from = [pkgCoordinate];
|
|
1107
1109
|
issueData.name = pkgCoordinate;
|
|
1108
1110
|
issueData.packageManager = packageManager;
|
|
@@ -5115,7 +5117,6 @@ const promise_1 = __webpack_require__(90430);
|
|
|
5115
5117
|
const common_1 = __webpack_require__(53110);
|
|
5116
5118
|
const api_token_1 = __webpack_require__(95181);
|
|
5117
5119
|
const common_2 = __webpack_require__(74434);
|
|
5118
|
-
const common_3 = __webpack_require__(70527);
|
|
5119
5120
|
async function getIssues(issuesRequestAttributes, orgId) {
|
|
5120
5121
|
const payload = {
|
|
5121
5122
|
method: 'POST',
|
|
@@ -5143,25 +5144,7 @@ async function getDepGraph(id, orgId) {
|
|
|
5143
5144
|
authorization: api_token_1.getAuthHeader(),
|
|
5144
5145
|
},
|
|
5145
5146
|
};
|
|
5146
|
-
const
|
|
5147
|
-
const pollIntervalMs = 5000;
|
|
5148
|
-
let waitingTimeMs = pollIntervalMs;
|
|
5149
|
-
let result = {};
|
|
5150
|
-
while (waitingTimeMs <= maxWaitingTimeMs) {
|
|
5151
|
-
try {
|
|
5152
|
-
await common_3.sleep(waitingTimeMs);
|
|
5153
|
-
result = await promise_1.makeRequest(payload);
|
|
5154
|
-
break;
|
|
5155
|
-
}
|
|
5156
|
-
catch (e) {
|
|
5157
|
-
if (waitingTimeMs < maxWaitingTimeMs) {
|
|
5158
|
-
waitingTimeMs += pollIntervalMs;
|
|
5159
|
-
}
|
|
5160
|
-
else {
|
|
5161
|
-
throw e;
|
|
5162
|
-
}
|
|
5163
|
-
}
|
|
5164
|
-
}
|
|
5147
|
+
const result = await promise_1.makeRequest(payload);
|
|
5165
5148
|
return JSON.parse(result.toString());
|
|
5166
5149
|
}
|
|
5167
5150
|
exports.getDepGraph = getDepGraph;
|