Use actionsUtil.computeAutomationID on upload-lib

This commit is contained in:
David Verdeguer 2021-05-03 19:56:04 +02:00
parent c93cbc943a
commit 3b741b35ad
12 changed files with 67 additions and 157 deletions

20
lib/upload-lib.js generated
View file

@ -70,25 +70,7 @@ function getAutomationID(category, analysis_key, environment) {
}
return automationID;
}
return computeAutomationID(analysis_key, environment);
}
function computeAutomationID(analysis_key, environment) {
let automationID = `${analysis_key}/`;
// the id has to be deterministic so we sort the fields
if (environment !== undefined && environment !== "null") {
const environmentObject = JSON.parse(environment);
for (const entry of Object.entries(environmentObject).sort()) {
if (typeof entry[1] === "string") {
automationID += `${entry[0]}:${entry[1]}/`;
}
else {
// In code scanning we just handle the string values,
// the rest get converted to the empty string
automationID += `${entry[0]}:/`;
}
}
}
return automationID;
return actionsUtil.computeAutomationID(analysis_key, environment);
}
// Upload the given payload.
// If the request fails then this will retry a small number of times.