mirror of
https://github.com/github/codeql-action.git
synced 2026-10-21 10:11:28 +00:00
Omit --sarif-codescanning-config if the config file doesn't exist
This commit is contained in:
8
lib/entry-points.js
generated
8
lib/entry-points.js
generated
@@ -177438,14 +177438,16 @@ async function getCodeQLForCmd(logger2, cmd, checkVersion) {
|
||||
await new toolrunner3.ToolRunner(cmd, args).exec();
|
||||
},
|
||||
async diagnosticsExport(sarifFile, automationDetailsId, config, diagnosticDir) {
|
||||
let configPath = getGeneratedCodeScanningConfigPath(config);
|
||||
if (diagnosticDir !== void 0 && !fs17.existsSync(configPath)) {
|
||||
configPath = void 0;
|
||||
}
|
||||
const args = [
|
||||
"diagnostics",
|
||||
"export",
|
||||
"--format=sarif-latest",
|
||||
`--output=${sarifFile}`,
|
||||
`--sarif-codescanning-config=${getGeneratedCodeScanningConfigPath(
|
||||
config
|
||||
)}`,
|
||||
...configPath !== void 0 ? [`--sarif-codescanning-config=${configPath}`] : [],
|
||||
...diagnosticDir !== void 0 ? [`--diagnostic-dir=${diagnosticDir}`] : [],
|
||||
...getExtraOptionsFromEnv(["diagnostics", "export"])
|
||||
];
|
||||
|
||||
@@ -918,14 +918,27 @@ async function getCodeQLForCmd(
|
||||
config: ActionConfig<"tempDir">,
|
||||
diagnosticDir: string | undefined,
|
||||
): Promise<void> {
|
||||
// We may be exporting diagnostics for a failed SARIF, in which case the configuration
|
||||
// file may not have been written to disk and there may not be a database. The CLI
|
||||
// will produce a SARIF for diagnostics from `diagnosticDir` without it. Therefore,
|
||||
// if `diagnosticDir` is set, we check whether `configPath` exists and only provide
|
||||
// it to the CLI if it does. Although not needed, the CLI will produce an error if it
|
||||
// is provided with an argument to `--sarif-codescanning-config` that does not exist.
|
||||
let configPath: string | undefined =
|
||||
getGeneratedCodeScanningConfigPath(config);
|
||||
|
||||
if (diagnosticDir !== undefined && !fs.existsSync(configPath)) {
|
||||
configPath = undefined;
|
||||
}
|
||||
|
||||
const args = [
|
||||
"diagnostics",
|
||||
"export",
|
||||
"--format=sarif-latest",
|
||||
`--output=${sarifFile}`,
|
||||
`--sarif-codescanning-config=${getGeneratedCodeScanningConfigPath(
|
||||
config,
|
||||
)}`,
|
||||
...(configPath !== undefined
|
||||
? [`--sarif-codescanning-config=${configPath}`]
|
||||
: []),
|
||||
...(diagnosticDir !== undefined
|
||||
? [`--diagnostic-dir=${diagnosticDir}`]
|
||||
: []),
|
||||
|
||||
Reference in New Issue
Block a user