Apply suggestions from code review
Co-authored-by: Henry Mercer <henry.mercer@me.com>
This commit is contained in:
parent
e2f72f11e4
commit
3c81243bb1
15 changed files with 130 additions and 91 deletions
18
lib/codeql.js
generated
18
lib/codeql.js
generated
|
|
@ -99,7 +99,7 @@ exports.CODEQL_VERSION_BETTER_RESOLVE_LANGUAGES = "2.10.3";
|
|||
*/
|
||||
exports.CODEQL_VERSION_SECURITY_EXPERIMENTAL_SUITE = "2.12.1";
|
||||
/**
|
||||
* Versions 2.12.2+ of the CodeQL CLI support the `--qlconfig` flag in calls to `database init`.
|
||||
* Versions 2.12.3+ of the CodeQL CLI support the `--qlconfig` flag in calls to `database init`.
|
||||
*/
|
||||
exports.CODEQL_VERSION_INIT_WITH_QLCONFIG = "2.12.3";
|
||||
/**
|
||||
|
|
@ -324,13 +324,13 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||
extraArgs.push("--no-internal-use-lua-tracing");
|
||||
}
|
||||
}
|
||||
// A config file is only generated if the CliConfigFileEnabled feature flag is enabled.
|
||||
const configLocation = await generateCodeScanningConfig(codeql, config, featureEnablement, logger);
|
||||
// A code scanning config file is only generated if the CliConfigFileEnabled feature flag is enabled.
|
||||
const codeScanningConfigFile = await generateCodeScanningConfig(codeql, config, featureEnablement, logger);
|
||||
// Only pass external repository token if a config file is going to be parsed by the CLI.
|
||||
let externalRepositoryToken;
|
||||
if (configLocation) {
|
||||
if (codeScanningConfigFile) {
|
||||
externalRepositoryToken = (0, actions_util_1.getOptionalInput)("external-repository-token");
|
||||
extraArgs.push(`--codescanning-config=${configLocation}`);
|
||||
extraArgs.push(`--codescanning-config=${codeScanningConfigFile}`);
|
||||
if (externalRepositoryToken) {
|
||||
extraArgs.push("--external-repository-token-stdin");
|
||||
}
|
||||
|
|
@ -722,7 +722,7 @@ async function generateCodeScanningConfig(codeql, config, featureEnablement, log
|
|||
if (!(await util.useCodeScanningConfigInCli(codeql, featureEnablement))) {
|
||||
return;
|
||||
}
|
||||
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
||||
const codeScanningConfigFile = path.resolve(config.tempDir, "user-config.yaml");
|
||||
// make a copy so we can modify it
|
||||
const augmentedConfig = cloneObject(config.originalUserInput);
|
||||
// Inject the queries from the input
|
||||
|
|
@ -776,12 +776,12 @@ async function generateCodeScanningConfig(codeql, config, featureEnablement, log
|
|||
augmentedConfig.packs["javascript"].push(packString);
|
||||
}
|
||||
}
|
||||
logger.info(`Writing augmented user configuration file to ${configLocation}`);
|
||||
logger.info(`Writing augmented user configuration file to ${codeScanningConfigFile}`);
|
||||
logger.startGroup("Augmented user configuration file contents");
|
||||
logger.info(yaml.dump(augmentedConfig));
|
||||
logger.endGroup();
|
||||
fs.writeFileSync(configLocation, yaml.dump(augmentedConfig));
|
||||
return configLocation;
|
||||
fs.writeFileSync(codeScanningConfigFile, yaml.dump(augmentedConfig));
|
||||
return codeScanningConfigFile;
|
||||
}
|
||||
function cloneObject(obj) {
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue