mirror of
https://github.com/github/codeql-action.git
synced 2026-01-05 06:00:32 +08:00
Ignore non-string values in populateRunAutomationDetails
This commit is contained in:
@@ -164,7 +164,17 @@ test("populateRunAutomationDetails", (t) => {
|
||||
);
|
||||
t.deepEqual(modifiedSarif, expectedSarif);
|
||||
|
||||
// check that an empty environment produces the right results
|
||||
// check non string environment values
|
||||
expectedSarif =
|
||||
'{"runs":[{"automationDetails":{"id":".github/workflows/codeql-analysis.yml:analyze/number:/object:/"}}]}';
|
||||
modifiedSarif = uploadLib.populateRunAutomationDetails(
|
||||
sarif,
|
||||
analysisKey,
|
||||
'{"number": 1, "object": {"language": "javascript"}}'
|
||||
);
|
||||
t.deepEqual(modifiedSarif, expectedSarif);
|
||||
|
||||
// check that the automation details doesn't get overwritten
|
||||
sarif = '{"runs":[{"automationDetails":{"id":"my_id"}}]}';
|
||||
expectedSarif = '{"runs":[{"automationDetails":{"id":"my_id"}}]}';
|
||||
modifiedSarif = uploadLib.populateRunAutomationDetails(
|
||||
|
||||
@@ -56,7 +56,13 @@ export function populateRunAutomationDetails(
|
||||
if (environment !== undefined && environment !== "null") {
|
||||
const environmentObject = JSON.parse(environment);
|
||||
for (const entry of Object.entries(environmentObject).sort()) {
|
||||
automationID += `${entry[0]}:${entry[1]}/`;
|
||||
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]}:/`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user