Use subdirectory for combined SARIF file
This commit is contained in:
parent
ccc609bf1a
commit
7e30c622b0
3 changed files with 17 additions and 16 deletions
12
lib/upload-lib.js
generated
12
lib/upload-lib.js
generated
|
|
@ -91,8 +91,8 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
|||
// Initialize CodeQL, either by using the config file from the 'init' step,
|
||||
// or by initializing it here.
|
||||
let codeQL;
|
||||
let tempDir;
|
||||
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||
let tempDir = actionsUtil.getTemporaryDirectory();
|
||||
const config = await (0, config_utils_1.getConfig)(tempDir, logger);
|
||||
if (config !== undefined) {
|
||||
codeQL = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
tempDir = config.tempDir;
|
||||
|
|
@ -107,11 +107,13 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
|
|||
};
|
||||
const codeQLDefaultVersionInfo = await features.getDefaultCliVersion(gitHubVersion.type);
|
||||
const initCodeQLResult = await (0, init_1.initCodeQL)(undefined, // There is no tools input on the upload action
|
||||
apiDetails, (0, actions_util_1.getTemporaryDirectory)(), gitHubVersion.type, codeQLDefaultVersionInfo, logger);
|
||||
apiDetails, tempDir, gitHubVersion.type, codeQLDefaultVersionInfo, logger);
|
||||
codeQL = initCodeQLResult.codeql;
|
||||
tempDir = (0, actions_util_1.getTemporaryDirectory)();
|
||||
}
|
||||
const outputFile = path.resolve(tempDir, "combined-sarif.sarif");
|
||||
const baseTempDir = path.resolve(tempDir, "combined-sarif");
|
||||
fs.mkdirSync(baseTempDir, { recursive: true });
|
||||
const outputDirectory = fs.mkdtempSync(path.resolve(baseTempDir, "output-"));
|
||||
const outputFile = path.resolve(outputDirectory, "combined-sarif.sarif");
|
||||
await codeQL.mergeResults(sarifFiles, outputFile, true);
|
||||
return JSON.parse(fs.readFileSync(outputFile, "utf8"));
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -8,11 +8,7 @@ import fileUrl from "file-url";
|
|||
import * as jsonschema from "jsonschema";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import {
|
||||
getOptionalInput,
|
||||
getRequiredInput,
|
||||
getTemporaryDirectory,
|
||||
} from "./actions-util";
|
||||
import { getOptionalInput, getRequiredInput } from "./actions-util";
|
||||
import * as api from "./api-client";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { CodeQL, getCodeQL } from "./codeql";
|
||||
|
|
@ -104,9 +100,9 @@ async function combineSarifFilesUsingCLI(
|
|||
// Initialize CodeQL, either by using the config file from the 'init' step,
|
||||
// or by initializing it here.
|
||||
let codeQL: CodeQL;
|
||||
let tempDir: string;
|
||||
let tempDir: string = actionsUtil.getTemporaryDirectory();
|
||||
|
||||
const config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
||||
const config = await getConfig(tempDir, logger);
|
||||
if (config !== undefined) {
|
||||
codeQL = await getCodeQL(config.codeQLCmd);
|
||||
tempDir = config.tempDir;
|
||||
|
|
@ -129,17 +125,20 @@ async function combineSarifFilesUsingCLI(
|
|||
const initCodeQLResult = await initCodeQL(
|
||||
undefined, // There is no tools input on the upload action
|
||||
apiDetails,
|
||||
getTemporaryDirectory(),
|
||||
tempDir,
|
||||
gitHubVersion.type,
|
||||
codeQLDefaultVersionInfo,
|
||||
logger,
|
||||
);
|
||||
|
||||
codeQL = initCodeQLResult.codeql;
|
||||
tempDir = getTemporaryDirectory();
|
||||
}
|
||||
|
||||
const outputFile = path.resolve(tempDir, "combined-sarif.sarif");
|
||||
const baseTempDir = path.resolve(tempDir, "combined-sarif");
|
||||
fs.mkdirSync(baseTempDir, { recursive: true });
|
||||
const outputDirectory = fs.mkdtempSync(path.resolve(baseTempDir, "output-"));
|
||||
|
||||
const outputFile = path.resolve(outputDirectory, "combined-sarif.sarif");
|
||||
|
||||
await codeQL.mergeResults(sarifFiles, outputFile, true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue