Clone packs from configuration to prevent modifications

This commit is contained in:
Remco Vermeulen 2024-07-31 17:56:53 -07:00
parent 7be3a64c02
commit ba3ac6f096
3 changed files with 14 additions and 7 deletions

8
lib/init-action.js generated
View file

@ -87,12 +87,14 @@ async function sendCompletedStatusReport(startedAt, config, toolsDownloadDuratio
if ((config.augmentationProperties.packsInputCombines ||
!config.augmentationProperties.packsInput) &&
config.originalUserInput.packs) {
// Make a copy, because we might modify `packs`.
const copyPacksFromOriginalUserInput = (0, util_1.cloneObject)(config.originalUserInput.packs);
// If it is an array, then assume there is only a single language being analyzed.
if (Array.isArray(config.originalUserInput.packs)) {
packs[config.languages[0]] = config.originalUserInput.packs;
if (Array.isArray(copyPacksFromOriginalUserInput)) {
packs[config.languages[0]] = copyPacksFromOriginalUserInput;
}
else {
packs = config.originalUserInput.packs;
packs = copyPacksFromOriginalUserInput;
}
}
if (config.augmentationProperties.packsInput) {

File diff suppressed because one or more lines are too long

View file

@ -60,6 +60,7 @@ import {
ConfigurationError,
wrapError,
checkActionVersion,
cloneObject,
} from "./util";
import { validateWorkflow } from "./workflow";
@ -187,11 +188,15 @@ async function sendCompletedStatusReport(
!config.augmentationProperties.packsInput) &&
config.originalUserInput.packs
) {
// Make a copy, because we might modify `packs`.
const copyPacksFromOriginalUserInput = cloneObject(
config.originalUserInput.packs,
);
// If it is an array, then assume there is only a single language being analyzed.
if (Array.isArray(config.originalUserInput.packs)) {
packs[config.languages[0]] = config.originalUserInput.packs;
if (Array.isArray(copyPacksFromOriginalUserInput)) {
packs[config.languages[0]] = copyPacksFromOriginalUserInput;
} else {
packs = config.originalUserInput.packs;
packs = copyPacksFromOriginalUserInput;
}
}