Add wrapper around JSON.parse to sarif module

This commit is contained in:
Michael B. Gale
2026-03-01 13:52:45 +00:00
parent d7cfd19fb8
commit 2fce45b8e6
6 changed files with 680 additions and 679 deletions

260
lib/analyze-action.js generated
View File

@@ -204,7 +204,7 @@ var require_file_command = __commonJS({
exports2.issueFileCommand = issueFileCommand; exports2.issueFileCommand = issueFileCommand;
exports2.prepareKeyValueMessage = prepareKeyValueMessage; exports2.prepareKeyValueMessage = prepareKeyValueMessage;
var crypto3 = __importStar2(require("crypto")); var crypto3 = __importStar2(require("crypto"));
var fs17 = __importStar2(require("fs")); var fs18 = __importStar2(require("fs"));
var os5 = __importStar2(require("os")); var os5 = __importStar2(require("os"));
var utils_1 = require_utils(); var utils_1 = require_utils();
function issueFileCommand(command, message) { function issueFileCommand(command, message) {
@@ -212,10 +212,10 @@ var require_file_command = __commonJS({
if (!filePath) { if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`); throw new Error(`Unable to find environment variable for file command ${command}`);
} }
if (!fs17.existsSync(filePath)) { if (!fs18.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`); throw new Error(`Missing file at path: ${filePath}`);
} }
fs17.appendFileSync(filePath, `${(0, utils_1.toCommandValue)(message)}${os5.EOL}`, { fs18.appendFileSync(filePath, `${(0, utils_1.toCommandValue)(message)}${os5.EOL}`, {
encoding: "utf8" encoding: "utf8"
}); });
} }
@@ -20123,13 +20123,13 @@ var require_io_util = __commonJS({
exports2.isRooted = isRooted; exports2.isRooted = isRooted;
exports2.tryGetExecutablePath = tryGetExecutablePath; exports2.tryGetExecutablePath = tryGetExecutablePath;
exports2.getCmdPath = getCmdPath; exports2.getCmdPath = getCmdPath;
var fs17 = __importStar2(require("fs")); var fs18 = __importStar2(require("fs"));
var path16 = __importStar2(require("path")); var path16 = __importStar2(require("path"));
_a = fs17.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink; _a = fs18.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink;
exports2.IS_WINDOWS = process.platform === "win32"; exports2.IS_WINDOWS = process.platform === "win32";
function readlink(fsPath) { function readlink(fsPath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const result = yield fs17.promises.readlink(fsPath); const result = yield fs18.promises.readlink(fsPath);
if (exports2.IS_WINDOWS && !result.endsWith("\\")) { if (exports2.IS_WINDOWS && !result.endsWith("\\")) {
return `${result}\\`; return `${result}\\`;
} }
@@ -20137,7 +20137,7 @@ var require_io_util = __commonJS({
}); });
} }
exports2.UV_FS_O_EXLOCK = 268435456; exports2.UV_FS_O_EXLOCK = 268435456;
exports2.READONLY = fs17.constants.O_RDONLY; exports2.READONLY = fs18.constants.O_RDONLY;
function exists(fsPath) { function exists(fsPath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
try { try {
@@ -50403,7 +50403,7 @@ var require_internal_globber = __commonJS({
Object.defineProperty(exports2, "__esModule", { value: true }); Object.defineProperty(exports2, "__esModule", { value: true });
exports2.DefaultGlobber = void 0; exports2.DefaultGlobber = void 0;
var core15 = __importStar2(require_core()); var core15 = __importStar2(require_core());
var fs17 = __importStar2(require("fs")); var fs18 = __importStar2(require("fs"));
var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var globOptionsHelper = __importStar2(require_internal_glob_options_helper());
var path16 = __importStar2(require("path")); var path16 = __importStar2(require("path"));
var patternHelper = __importStar2(require_internal_pattern_helper()); var patternHelper = __importStar2(require_internal_pattern_helper());
@@ -50457,7 +50457,7 @@ var require_internal_globber = __commonJS({
for (const searchPath of patternHelper.getSearchPaths(patterns)) { for (const searchPath of patternHelper.getSearchPaths(patterns)) {
core15.debug(`Search path '${searchPath}'`); core15.debug(`Search path '${searchPath}'`);
try { try {
yield __await2(fs17.promises.lstat(searchPath)); yield __await2(fs18.promises.lstat(searchPath));
} catch (err) { } catch (err) {
if (err.code === "ENOENT") { if (err.code === "ENOENT") {
continue; continue;
@@ -50491,7 +50491,7 @@ var require_internal_globber = __commonJS({
continue; continue;
} }
const childLevel = item.level + 1; const childLevel = item.level + 1;
const childItems = (yield __await2(fs17.promises.readdir(item.path))).map((x) => new internal_search_state_1.SearchState(path16.join(item.path, x), childLevel)); const childItems = (yield __await2(fs18.promises.readdir(item.path))).map((x) => new internal_search_state_1.SearchState(path16.join(item.path, x), childLevel));
stack.push(...childItems.reverse()); stack.push(...childItems.reverse());
} else if (match & internal_match_kind_1.MatchKind.File) { } else if (match & internal_match_kind_1.MatchKind.File) {
yield yield __await2(item.path); yield yield __await2(item.path);
@@ -50526,7 +50526,7 @@ var require_internal_globber = __commonJS({
let stats; let stats;
if (options.followSymbolicLinks) { if (options.followSymbolicLinks) {
try { try {
stats = yield fs17.promises.stat(item.path); stats = yield fs18.promises.stat(item.path);
} catch (err) { } catch (err) {
if (err.code === "ENOENT") { if (err.code === "ENOENT") {
if (options.omitBrokenSymbolicLinks) { if (options.omitBrokenSymbolicLinks) {
@@ -50538,10 +50538,10 @@ var require_internal_globber = __commonJS({
throw err; throw err;
} }
} else { } else {
stats = yield fs17.promises.lstat(item.path); stats = yield fs18.promises.lstat(item.path);
} }
if (stats.isDirectory() && options.followSymbolicLinks) { if (stats.isDirectory() && options.followSymbolicLinks) {
const realPath = yield fs17.promises.realpath(item.path); const realPath = yield fs18.promises.realpath(item.path);
while (traversalChain.length >= item.level) { while (traversalChain.length >= item.level) {
traversalChain.pop(); traversalChain.pop();
} }
@@ -50650,7 +50650,7 @@ var require_internal_hash_files = __commonJS({
exports2.hashFiles = hashFiles2; exports2.hashFiles = hashFiles2;
var crypto3 = __importStar2(require("crypto")); var crypto3 = __importStar2(require("crypto"));
var core15 = __importStar2(require_core()); var core15 = __importStar2(require_core());
var fs17 = __importStar2(require("fs")); var fs18 = __importStar2(require("fs"));
var stream2 = __importStar2(require("stream")); var stream2 = __importStar2(require("stream"));
var util = __importStar2(require("util")); var util = __importStar2(require("util"));
var path16 = __importStar2(require("path")); var path16 = __importStar2(require("path"));
@@ -50673,13 +50673,13 @@ var require_internal_hash_files = __commonJS({
writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`); writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
continue; continue;
} }
if (fs17.statSync(file).isDirectory()) { if (fs18.statSync(file).isDirectory()) {
writeDelegate(`Skip directory '${file}'.`); writeDelegate(`Skip directory '${file}'.`);
continue; continue;
} }
const hash2 = crypto3.createHash("sha256"); const hash2 = crypto3.createHash("sha256");
const pipeline = util.promisify(stream2.pipeline); const pipeline = util.promisify(stream2.pipeline);
yield pipeline(fs17.createReadStream(file), hash2); yield pipeline(fs18.createReadStream(file), hash2);
result.write(hash2.digest()); result.write(hash2.digest());
count++; count++;
if (!hasMatch) { if (!hasMatch) {
@@ -52054,7 +52054,7 @@ var require_cacheUtils = __commonJS({
var glob2 = __importStar2(require_glob()); var glob2 = __importStar2(require_glob());
var io7 = __importStar2(require_io()); var io7 = __importStar2(require_io());
var crypto3 = __importStar2(require("crypto")); var crypto3 = __importStar2(require("crypto"));
var fs17 = __importStar2(require("fs")); var fs18 = __importStar2(require("fs"));
var path16 = __importStar2(require("path")); var path16 = __importStar2(require("path"));
var semver9 = __importStar2(require_semver3()); var semver9 = __importStar2(require_semver3());
var util = __importStar2(require("util")); var util = __importStar2(require("util"));
@@ -52083,7 +52083,7 @@ var require_cacheUtils = __commonJS({
}); });
} }
function getArchiveFileSizeInBytes(filePath) { function getArchiveFileSizeInBytes(filePath) {
return fs17.statSync(filePath).size; return fs18.statSync(filePath).size;
} }
function resolvePaths(patterns) { function resolvePaths(patterns) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
@@ -52121,7 +52121,7 @@ var require_cacheUtils = __commonJS({
} }
function unlinkFile(filePath) { function unlinkFile(filePath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
return util.promisify(fs17.unlink)(filePath); return util.promisify(fs18.unlink)(filePath);
}); });
} }
function getVersion(app_1) { function getVersion(app_1) {
@@ -52163,7 +52163,7 @@ var require_cacheUtils = __commonJS({
} }
function getGnuTarPathOnWindows() { function getGnuTarPathOnWindows() {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
if (fs17.existsSync(constants_1.GnuTarPathOnWindows)) { if (fs18.existsSync(constants_1.GnuTarPathOnWindows)) {
return constants_1.GnuTarPathOnWindows; return constants_1.GnuTarPathOnWindows;
} }
const versionOutput = yield getVersion("tar"); const versionOutput = yield getVersion("tar");
@@ -92320,7 +92320,7 @@ var require_downloadUtils = __commonJS({
var http_client_1 = require_lib(); var http_client_1 = require_lib();
var storage_blob_1 = require_commonjs15(); var storage_blob_1 = require_commonjs15();
var buffer = __importStar2(require("buffer")); var buffer = __importStar2(require("buffer"));
var fs17 = __importStar2(require("fs")); var fs18 = __importStar2(require("fs"));
var stream2 = __importStar2(require("stream")); var stream2 = __importStar2(require("stream"));
var util = __importStar2(require("util")); var util = __importStar2(require("util"));
var utils = __importStar2(require_cacheUtils()); var utils = __importStar2(require_cacheUtils());
@@ -92431,7 +92431,7 @@ var require_downloadUtils = __commonJS({
exports2.DownloadProgress = DownloadProgress; exports2.DownloadProgress = DownloadProgress;
function downloadCacheHttpClient(archiveLocation, archivePath) { function downloadCacheHttpClient(archiveLocation, archivePath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const writeStream = fs17.createWriteStream(archivePath); const writeStream = fs18.createWriteStream(archivePath);
const httpClient = new http_client_1.HttpClient("actions/cache"); const httpClient = new http_client_1.HttpClient("actions/cache");
const downloadResponse = yield (0, requestUtils_1.retryHttpClientResponse)("downloadCache", () => __awaiter2(this, void 0, void 0, function* () { const downloadResponse = yield (0, requestUtils_1.retryHttpClientResponse)("downloadCache", () => __awaiter2(this, void 0, void 0, function* () {
return httpClient.get(archiveLocation); return httpClient.get(archiveLocation);
@@ -92456,7 +92456,7 @@ var require_downloadUtils = __commonJS({
function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options) { function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
var _a; var _a;
const archiveDescriptor = yield fs17.promises.open(archivePath, "w"); const archiveDescriptor = yield fs18.promises.open(archivePath, "w");
const httpClient = new http_client_1.HttpClient("actions/cache", void 0, { const httpClient = new http_client_1.HttpClient("actions/cache", void 0, {
socketTimeout: options.timeoutInMs, socketTimeout: options.timeoutInMs,
keepAlive: true keepAlive: true
@@ -92572,7 +92572,7 @@ var require_downloadUtils = __commonJS({
} else { } else {
const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH);
const downloadProgress = new DownloadProgress(contentLength); const downloadProgress = new DownloadProgress(contentLength);
const fd = fs17.openSync(archivePath, "w"); const fd = fs18.openSync(archivePath, "w");
try { try {
downloadProgress.startDisplayTimer(); downloadProgress.startDisplayTimer();
const controller = new abort_controller_1.AbortController(); const controller = new abort_controller_1.AbortController();
@@ -92590,12 +92590,12 @@ var require_downloadUtils = __commonJS({
controller.abort(); controller.abort();
throw new Error("Aborting cache download as the download time exceeded the timeout."); throw new Error("Aborting cache download as the download time exceeded the timeout.");
} else if (Buffer.isBuffer(result)) { } else if (Buffer.isBuffer(result)) {
fs17.writeFileSync(fd, result); fs18.writeFileSync(fd, result);
} }
} }
} finally { } finally {
downloadProgress.stopDisplayTimer(); downloadProgress.stopDisplayTimer();
fs17.closeSync(fd); fs18.closeSync(fd);
} }
} }
}); });
@@ -92917,7 +92917,7 @@ var require_cacheHttpClient = __commonJS({
var core15 = __importStar2(require_core()); var core15 = __importStar2(require_core());
var http_client_1 = require_lib(); var http_client_1 = require_lib();
var auth_1 = require_auth(); var auth_1 = require_auth();
var fs17 = __importStar2(require("fs")); var fs18 = __importStar2(require("fs"));
var url_1 = require("url"); var url_1 = require("url");
var utils = __importStar2(require_cacheUtils()); var utils = __importStar2(require_cacheUtils());
var uploadUtils_1 = require_uploadUtils(); var uploadUtils_1 = require_uploadUtils();
@@ -93052,7 +93052,7 @@ Other caches with similar key:`);
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const fileSize = utils.getArchiveFileSizeInBytes(archivePath); const fileSize = utils.getArchiveFileSizeInBytes(archivePath);
const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`); const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
const fd = fs17.openSync(archivePath, "r"); const fd = fs18.openSync(archivePath, "r");
const uploadOptions = (0, options_1.getUploadOptions)(options); const uploadOptions = (0, options_1.getUploadOptions)(options);
const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency);
const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize);
@@ -93066,7 +93066,7 @@ Other caches with similar key:`);
const start = offset; const start = offset;
const end = offset + chunkSize - 1; const end = offset + chunkSize - 1;
offset += maxChunkSize; offset += maxChunkSize;
yield uploadChunk(httpClient, resourceUrl, () => fs17.createReadStream(archivePath, { yield uploadChunk(httpClient, resourceUrl, () => fs18.createReadStream(archivePath, {
fd, fd,
start, start,
end, end,
@@ -93077,7 +93077,7 @@ Other caches with similar key:`);
} }
}))); })));
} finally { } finally {
fs17.closeSync(fd); fs18.closeSync(fd);
} }
return; return;
}); });
@@ -99033,7 +99033,7 @@ var require_manifest = __commonJS({
var core_1 = require_core(); var core_1 = require_core();
var os5 = require("os"); var os5 = require("os");
var cp = require("child_process"); var cp = require("child_process");
var fs17 = require("fs"); var fs18 = require("fs");
function _findMatch(versionSpec, stable, candidates, archFilter) { function _findMatch(versionSpec, stable, candidates, archFilter) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const platFilter = os5.platform(); const platFilter = os5.platform();
@@ -99095,10 +99095,10 @@ var require_manifest = __commonJS({
const lsbReleaseFile = "/etc/lsb-release"; const lsbReleaseFile = "/etc/lsb-release";
const osReleaseFile = "/etc/os-release"; const osReleaseFile = "/etc/os-release";
let contents = ""; let contents = "";
if (fs17.existsSync(lsbReleaseFile)) { if (fs18.existsSync(lsbReleaseFile)) {
contents = fs17.readFileSync(lsbReleaseFile).toString(); contents = fs18.readFileSync(lsbReleaseFile).toString();
} else if (fs17.existsSync(osReleaseFile)) { } else if (fs18.existsSync(osReleaseFile)) {
contents = fs17.readFileSync(osReleaseFile).toString(); contents = fs18.readFileSync(osReleaseFile).toString();
} }
return contents; return contents;
} }
@@ -99307,7 +99307,7 @@ var require_tool_cache = __commonJS({
var core15 = __importStar2(require_core()); var core15 = __importStar2(require_core());
var io7 = __importStar2(require_io()); var io7 = __importStar2(require_io());
var crypto3 = __importStar2(require("crypto")); var crypto3 = __importStar2(require("crypto"));
var fs17 = __importStar2(require("fs")); var fs18 = __importStar2(require("fs"));
var mm = __importStar2(require_manifest()); var mm = __importStar2(require_manifest());
var os5 = __importStar2(require("os")); var os5 = __importStar2(require("os"));
var path16 = __importStar2(require("path")); var path16 = __importStar2(require("path"));
@@ -99353,7 +99353,7 @@ var require_tool_cache = __commonJS({
} }
function downloadToolAttempt(url2, dest, auth2, headers) { function downloadToolAttempt(url2, dest, auth2, headers) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
if (fs17.existsSync(dest)) { if (fs18.existsSync(dest)) {
throw new Error(`Destination file path ${dest} already exists`); throw new Error(`Destination file path ${dest} already exists`);
} }
const http = new httpm.HttpClient(userAgent2, [], { const http = new httpm.HttpClient(userAgent2, [], {
@@ -99377,7 +99377,7 @@ var require_tool_cache = __commonJS({
const readStream = responseMessageFactory(); const readStream = responseMessageFactory();
let succeeded = false; let succeeded = false;
try { try {
yield pipeline(readStream, fs17.createWriteStream(dest)); yield pipeline(readStream, fs18.createWriteStream(dest));
core15.debug("download complete"); core15.debug("download complete");
succeeded = true; succeeded = true;
return dest; return dest;
@@ -99589,11 +99589,11 @@ var require_tool_cache = __commonJS({
arch2 = arch2 || os5.arch(); arch2 = arch2 || os5.arch();
core15.debug(`Caching tool ${tool} ${version} ${arch2}`); core15.debug(`Caching tool ${tool} ${version} ${arch2}`);
core15.debug(`source dir: ${sourceDir}`); core15.debug(`source dir: ${sourceDir}`);
if (!fs17.statSync(sourceDir).isDirectory()) { if (!fs18.statSync(sourceDir).isDirectory()) {
throw new Error("sourceDir is not a directory"); throw new Error("sourceDir is not a directory");
} }
const destPath = yield _createToolPath(tool, version, arch2); const destPath = yield _createToolPath(tool, version, arch2);
for (const itemName of fs17.readdirSync(sourceDir)) { for (const itemName of fs18.readdirSync(sourceDir)) {
const s = path16.join(sourceDir, itemName); const s = path16.join(sourceDir, itemName);
yield io7.cp(s, destPath, { recursive: true }); yield io7.cp(s, destPath, { recursive: true });
} }
@@ -99607,7 +99607,7 @@ var require_tool_cache = __commonJS({
arch2 = arch2 || os5.arch(); arch2 = arch2 || os5.arch();
core15.debug(`Caching tool ${tool} ${version} ${arch2}`); core15.debug(`Caching tool ${tool} ${version} ${arch2}`);
core15.debug(`source file: ${sourceFile}`); core15.debug(`source file: ${sourceFile}`);
if (!fs17.statSync(sourceFile).isFile()) { if (!fs18.statSync(sourceFile).isFile()) {
throw new Error("sourceFile is not a file"); throw new Error("sourceFile is not a file");
} }
const destFolder = yield _createToolPath(tool, version, arch2); const destFolder = yield _createToolPath(tool, version, arch2);
@@ -99636,7 +99636,7 @@ var require_tool_cache = __commonJS({
versionSpec = semver9.clean(versionSpec) || ""; versionSpec = semver9.clean(versionSpec) || "";
const cachePath = path16.join(_getCacheDirectory(), toolName, versionSpec, arch2); const cachePath = path16.join(_getCacheDirectory(), toolName, versionSpec, arch2);
core15.debug(`checking cache: ${cachePath}`); core15.debug(`checking cache: ${cachePath}`);
if (fs17.existsSync(cachePath) && fs17.existsSync(`${cachePath}.complete`)) { if (fs18.existsSync(cachePath) && fs18.existsSync(`${cachePath}.complete`)) {
core15.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); core15.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`);
toolPath = cachePath; toolPath = cachePath;
} else { } else {
@@ -99649,12 +99649,12 @@ var require_tool_cache = __commonJS({
const versions = []; const versions = [];
arch2 = arch2 || os5.arch(); arch2 = arch2 || os5.arch();
const toolPath = path16.join(_getCacheDirectory(), toolName); const toolPath = path16.join(_getCacheDirectory(), toolName);
if (fs17.existsSync(toolPath)) { if (fs18.existsSync(toolPath)) {
const children = fs17.readdirSync(toolPath); const children = fs18.readdirSync(toolPath);
for (const child of children) { for (const child of children) {
if (isExplicitVersion(child)) { if (isExplicitVersion(child)) {
const fullPath = path16.join(toolPath, child, arch2 || ""); const fullPath = path16.join(toolPath, child, arch2 || "");
if (fs17.existsSync(fullPath) && fs17.existsSync(`${fullPath}.complete`)) { if (fs18.existsSync(fullPath) && fs18.existsSync(`${fullPath}.complete`)) {
versions.push(child); versions.push(child);
} }
} }
@@ -99725,7 +99725,7 @@ var require_tool_cache = __commonJS({
function _completeToolPath(tool, version, arch2) { function _completeToolPath(tool, version, arch2) {
const folderPath = path16.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); const folderPath = path16.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || "");
const markerPath = `${folderPath}.complete`; const markerPath = `${folderPath}.complete`;
fs17.writeFileSync(markerPath, ""); fs18.writeFileSync(markerPath, "");
core15.debug("finished caching tool"); core15.debug("finished caching tool");
} }
function isExplicitVersion(versionSpec) { function isExplicitVersion(versionSpec) {
@@ -103232,13 +103232,13 @@ __export(analyze_action_exports, {
runPromise: () => runPromise runPromise: () => runPromise
}); });
module.exports = __toCommonJS(analyze_action_exports); module.exports = __toCommonJS(analyze_action_exports);
var fs16 = __toESM(require("fs")); var fs17 = __toESM(require("fs"));
var import_path4 = __toESM(require("path")); var import_path4 = __toESM(require("path"));
var import_perf_hooks3 = require("perf_hooks"); var import_perf_hooks3 = require("perf_hooks");
var core14 = __toESM(require_core()); var core14 = __toESM(require_core());
// src/actions-util.ts // src/actions-util.ts
var fs2 = __toESM(require("fs")); var fs3 = __toESM(require("fs"));
var path2 = __toESM(require("path")); var path2 = __toESM(require("path"));
var core4 = __toESM(require_core()); var core4 = __toESM(require_core());
var toolrunner = __toESM(require_toolrunner()); var toolrunner = __toESM(require_toolrunner());
@@ -103246,7 +103246,7 @@ var github = __toESM(require_github());
var io2 = __toESM(require_io()); var io2 = __toESM(require_io());
// src/util.ts // src/util.ts
var fs = __toESM(require("fs")); var fs2 = __toESM(require("fs"));
var fsPromises = __toESM(require("fs/promises")); var fsPromises = __toESM(require("fs/promises"));
var os = __toESM(require("os")); var os = __toESM(require("os"));
var path = __toESM(require("path")); var path = __toESM(require("path"));
@@ -103261,21 +103261,21 @@ async function getFolderSize(itemPath, options) {
getFolderSize.loose = async (itemPath, options) => await core(itemPath, options); getFolderSize.loose = async (itemPath, options) => await core(itemPath, options);
getFolderSize.strict = async (itemPath, options) => await core(itemPath, options, { strict: true }); getFolderSize.strict = async (itemPath, options) => await core(itemPath, options, { strict: true });
async function core(rootItemPath, options = {}, returnType = {}) { async function core(rootItemPath, options = {}, returnType = {}) {
const fs17 = options.fs || await import("node:fs/promises"); const fs18 = options.fs || await import("node:fs/promises");
let folderSize = 0n; let folderSize = 0n;
const foundInos = /* @__PURE__ */ new Set(); const foundInos = /* @__PURE__ */ new Set();
const errors = []; const errors = [];
await processItem(rootItemPath); await processItem(rootItemPath);
async function processItem(itemPath) { async function processItem(itemPath) {
if (options.ignore?.test(itemPath)) return; if (options.ignore?.test(itemPath)) return;
const stats = returnType.strict ? await fs17.lstat(itemPath, { bigint: true }) : await fs17.lstat(itemPath, { bigint: true }).catch((error3) => errors.push(error3)); const stats = returnType.strict ? await fs18.lstat(itemPath, { bigint: true }) : await fs18.lstat(itemPath, { bigint: true }).catch((error3) => errors.push(error3));
if (typeof stats !== "object") return; if (typeof stats !== "object") return;
if (!foundInos.has(stats.ino)) { if (!foundInos.has(stats.ino)) {
foundInos.add(stats.ino); foundInos.add(stats.ino);
folderSize += stats.size; folderSize += stats.size;
} }
if (stats.isDirectory()) { if (stats.isDirectory()) {
const directoryItems = returnType.strict ? await fs17.readdir(itemPath) : await fs17.readdir(itemPath).catch((error3) => errors.push(error3)); const directoryItems = returnType.strict ? await fs18.readdir(itemPath) : await fs18.readdir(itemPath).catch((error3) => errors.push(error3));
if (typeof directoryItems !== "object") return; if (typeof directoryItems !== "object") return;
await Promise.all( await Promise.all(
directoryItems.map( directoryItems.map(
@@ -105898,6 +105898,7 @@ var safeDump = renamed("safeDump", "dump");
var semver = __toESM(require_semver2()); var semver = __toESM(require_semver2());
// src/sarif/index.ts // src/sarif/index.ts
var fs = __toESM(require("fs"));
function getToolNames(sarif) { function getToolNames(sarif) {
const toolNames = {}; const toolNames = {};
for (const run2 of sarif.runs || []) { for (const run2 of sarif.runs || []) {
@@ -105909,6 +105910,9 @@ function getToolNames(sarif) {
} }
return Object.keys(toolNames); return Object.keys(toolNames);
} }
function readSarifFile(sarifFilePath) {
return JSON.parse(fs.readFileSync(sarifFilePath, "utf8"));
}
// src/util.ts // src/util.ts
var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json";
@@ -105982,13 +105986,13 @@ function getTotalMemoryBytes(logger) {
return limit; return limit;
} }
function getCgroupMemoryLimitBytes(limitFile, logger) { function getCgroupMemoryLimitBytes(limitFile, logger) {
if (!fs.existsSync(limitFile)) { if (!fs2.existsSync(limitFile)) {
logger.debug( logger.debug(
`While resolving RAM, did not find a cgroup memory limit at ${limitFile}.` `While resolving RAM, did not find a cgroup memory limit at ${limitFile}.`
); );
return void 0; return void 0;
} }
const limit = Number(fs.readFileSync(limitFile, "utf8")); const limit = Number(fs2.readFileSync(limitFile, "utf8"));
if (!Number.isInteger(limit)) { if (!Number.isInteger(limit)) {
logger.debug( logger.debug(
`While resolving RAM, ignored the file ${limitFile} that may contain a cgroup memory limit as this file did not contain an integer.` `While resolving RAM, ignored the file ${limitFile} that may contain a cgroup memory limit as this file did not contain an integer.`
@@ -106062,13 +106066,13 @@ function getThreadsFlagValue(userInput, logger) {
return numThreads; return numThreads;
} }
function getCgroupCpuCountFromCpuMax(cpuMaxFile, logger) { function getCgroupCpuCountFromCpuMax(cpuMaxFile, logger) {
if (!fs.existsSync(cpuMaxFile)) { if (!fs2.existsSync(cpuMaxFile)) {
logger.debug( logger.debug(
`While resolving threads, did not find a cgroup CPU file at ${cpuMaxFile}.` `While resolving threads, did not find a cgroup CPU file at ${cpuMaxFile}.`
); );
return void 0; return void 0;
} }
const cpuMaxString = fs.readFileSync(cpuMaxFile, "utf-8"); const cpuMaxString = fs2.readFileSync(cpuMaxFile, "utf-8");
const cpuMaxStringSplit = cpuMaxString.split(" "); const cpuMaxStringSplit = cpuMaxString.split(" ");
if (cpuMaxStringSplit.length !== 2) { if (cpuMaxStringSplit.length !== 2) {
logger.debug( logger.debug(
@@ -106088,14 +106092,14 @@ function getCgroupCpuCountFromCpuMax(cpuMaxFile, logger) {
return cpuCount; return cpuCount;
} }
function getCgroupCpuCountFromCpus(cpusFile, logger) { function getCgroupCpuCountFromCpus(cpusFile, logger) {
if (!fs.existsSync(cpusFile)) { if (!fs2.existsSync(cpusFile)) {
logger.debug( logger.debug(
`While resolving threads, did not find a cgroup CPUs file at ${cpusFile}.` `While resolving threads, did not find a cgroup CPUs file at ${cpusFile}.`
); );
return void 0; return void 0;
} }
let cpuCount = 0; let cpuCount = 0;
const cpusString = fs.readFileSync(cpusFile, "utf-8").trim(); const cpusString = fs2.readFileSync(cpusFile, "utf-8").trim();
if (cpusString.length === 0) { if (cpusString.length === 0) {
return void 0; return void 0;
} }
@@ -106225,12 +106229,12 @@ function getBaseDatabaseOidsFilePath(config) {
async function bundleDb(config, language, codeql, dbName, { includeDiagnostics }) { async function bundleDb(config, language, codeql, dbName, { includeDiagnostics }) {
const databasePath = getCodeQLDatabasePath(config, language); const databasePath = getCodeQLDatabasePath(config, language);
const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`); const databaseBundlePath = path.resolve(config.dbLocation, `${dbName}.zip`);
if (fs.existsSync(databaseBundlePath)) { if (fs2.existsSync(databaseBundlePath)) {
await fs.promises.rm(databaseBundlePath, { force: true }); await fs2.promises.rm(databaseBundlePath, { force: true });
} }
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config); const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
const additionalFiles = []; const additionalFiles = [];
if (fs.existsSync(baseDatabaseOidsFilePath)) { if (fs2.existsSync(baseDatabaseOidsFilePath)) {
await fsPromises.copyFile( await fsPromises.copyFile(
baseDatabaseOidsFilePath, baseDatabaseOidsFilePath,
path.join(databasePath, BASE_DATABASE_OIDS_FILE_NAME) path.join(databasePath, BASE_DATABASE_OIDS_FILE_NAME)
@@ -106378,7 +106382,7 @@ function cloneObject(obj) {
async function cleanUpPath(file, name, logger) { async function cleanUpPath(file, name, logger) {
logger.debug(`Cleaning up ${name}.`); logger.debug(`Cleaning up ${name}.`);
try { try {
await fs.promises.rm(file, { await fs2.promises.rm(file, {
force: true, force: true,
recursive: true recursive: true
}); });
@@ -106441,7 +106445,7 @@ function getRelativeScriptPath() {
function getWorkflowEvent() { function getWorkflowEvent() {
const eventJsonFile = getRequiredEnvParam("GITHUB_EVENT_PATH"); const eventJsonFile = getRequiredEnvParam("GITHUB_EVENT_PATH");
try { try {
return JSON.parse(fs2.readFileSync(eventJsonFile, "utf-8")); return JSON.parse(fs3.readFileSync(eventJsonFile, "utf-8"));
} catch (e) { } catch (e) {
throw new Error( throw new Error(
`Unable to read workflow event JSON from ${eventJsonFile}: ${e}` `Unable to read workflow event JSON from ${eventJsonFile}: ${e}`
@@ -106687,7 +106691,7 @@ var SarifScanOrder = [
]; ];
// src/analyze.ts // src/analyze.ts
var fs12 = __toESM(require("fs")); var fs13 = __toESM(require("fs"));
var path12 = __toESM(require("path")); var path12 = __toESM(require("path"));
var import_perf_hooks2 = require("perf_hooks"); var import_perf_hooks2 = require("perf_hooks");
var io5 = __toESM(require_io()); var io5 = __toESM(require_io());
@@ -106969,7 +106973,7 @@ function wrapApiConfigurationError(e) {
} }
// src/codeql.ts // src/codeql.ts
var fs11 = __toESM(require("fs")); var fs12 = __toESM(require("fs"));
var path11 = __toESM(require("path")); var path11 = __toESM(require("path"));
var core10 = __toESM(require_core()); var core10 = __toESM(require_core());
var toolrunner3 = __toESM(require_toolrunner()); var toolrunner3 = __toESM(require_toolrunner());
@@ -107217,7 +107221,7 @@ function wrapCliConfigurationError(cliError) {
} }
// src/config-utils.ts // src/config-utils.ts
var fs6 = __toESM(require("fs")); var fs7 = __toESM(require("fs"));
var path7 = __toESM(require("path")); var path7 = __toESM(require("path"));
// src/caching-utils.ts // src/caching-utils.ts
@@ -107355,11 +107359,11 @@ function writeDiagnostic(config, language, diagnostic) {
} }
// src/diff-informed-analysis-utils.ts // src/diff-informed-analysis-utils.ts
var fs5 = __toESM(require("fs")); var fs6 = __toESM(require("fs"));
var path6 = __toESM(require("path")); var path6 = __toESM(require("path"));
// src/feature-flags.ts // src/feature-flags.ts
var fs4 = __toESM(require("fs")); var fs5 = __toESM(require("fs"));
var path5 = __toESM(require("path")); var path5 = __toESM(require("path"));
var semver5 = __toESM(require_semver2()); var semver5 = __toESM(require_semver2());
@@ -107368,7 +107372,7 @@ var bundleVersion = "codeql-bundle-v2.24.2";
var cliVersion = "2.24.2"; var cliVersion = "2.24.2";
// src/overlay/index.ts // src/overlay/index.ts
var fs3 = __toESM(require("fs")); var fs4 = __toESM(require("fs"));
var path4 = __toESM(require("path")); var path4 = __toESM(require("path"));
var actionsCache = __toESM(require_cache5()); var actionsCache = __toESM(require_cache5());
@@ -107579,12 +107583,12 @@ async function writeBaseDatabaseOidsFile(config, sourceRoot) {
const gitFileOids = await getFileOidsUnderPath(sourceRoot); const gitFileOids = await getFileOidsUnderPath(sourceRoot);
const gitFileOidsJson = JSON.stringify(gitFileOids); const gitFileOidsJson = JSON.stringify(gitFileOids);
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config); const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
await fs3.promises.writeFile(baseDatabaseOidsFilePath, gitFileOidsJson); await fs4.promises.writeFile(baseDatabaseOidsFilePath, gitFileOidsJson);
} }
async function readBaseDatabaseOidsFile(config, logger) { async function readBaseDatabaseOidsFile(config, logger) {
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config); const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
try { try {
const contents = await fs3.promises.readFile( const contents = await fs4.promises.readFile(
baseDatabaseOidsFilePath, baseDatabaseOidsFilePath,
"utf-8" "utf-8"
); );
@@ -107611,7 +107615,7 @@ async function writeOverlayChangesFile(config, sourceRoot, logger) {
logger.debug( logger.debug(
`Writing overlay changed files to ${overlayChangesFile}: ${changedFilesJson}` `Writing overlay changed files to ${overlayChangesFile}: ${changedFilesJson}`
); );
await fs3.promises.writeFile(overlayChangesFile, changedFilesJson); await fs4.promises.writeFile(overlayChangesFile, changedFilesJson);
return overlayChangesFile; return overlayChangesFile;
} }
function computeChangedFiles(baseFileOids, overlayFileOids) { function computeChangedFiles(baseFileOids, overlayFileOids) {
@@ -107633,7 +107637,7 @@ var CACHE_PREFIX = "codeql-overlay-base-database";
var MAX_CACHE_OPERATION_MS = 6e5; var MAX_CACHE_OPERATION_MS = 6e5;
async function checkOverlayBaseDatabase(codeql, config, logger, warningPrefix) { async function checkOverlayBaseDatabase(codeql, config, logger, warningPrefix) {
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config); const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
if (!fs3.existsSync(baseDatabaseOidsFilePath)) { if (!fs4.existsSync(baseDatabaseOidsFilePath)) {
logger.warning( logger.warning(
`${warningPrefix}: ${baseDatabaseOidsFilePath} does not exist` `${warningPrefix}: ${baseDatabaseOidsFilePath} does not exist`
); );
@@ -108248,12 +108252,12 @@ var GitHubFeatureFlags = class {
} }
async readLocalFlags() { async readLocalFlags() {
try { try {
if (fs4.existsSync(this.featureFlagsFile)) { if (fs5.existsSync(this.featureFlagsFile)) {
this.logger.debug( this.logger.debug(
`Loading feature flags from ${this.featureFlagsFile}` `Loading feature flags from ${this.featureFlagsFile}`
); );
return JSON.parse( return JSON.parse(
fs4.readFileSync(this.featureFlagsFile, "utf8") fs5.readFileSync(this.featureFlagsFile, "utf8")
); );
} }
} catch (e) { } catch (e) {
@@ -108266,7 +108270,7 @@ var GitHubFeatureFlags = class {
async writeLocalFlags(flags) { async writeLocalFlags(flags) {
try { try {
this.logger.debug(`Writing feature flags to ${this.featureFlagsFile}`); this.logger.debug(`Writing feature flags to ${this.featureFlagsFile}`);
fs4.writeFileSync(this.featureFlagsFile, JSON.stringify(flags)); fs5.writeFileSync(this.featureFlagsFile, JSON.stringify(flags));
} catch (e) { } catch (e) {
this.logger.warning( this.logger.warning(
`Error writing cached feature flags file ${this.featureFlagsFile}: ${e}.` `Error writing cached feature flags file ${this.featureFlagsFile}: ${e}.`
@@ -108359,7 +108363,7 @@ function getDiffRangesJsonFilePath() {
function writeDiffRangesJsonFile(logger, ranges) { function writeDiffRangesJsonFile(logger, ranges) {
const jsonContents = JSON.stringify(ranges, null, 2); const jsonContents = JSON.stringify(ranges, null, 2);
const jsonFilePath = getDiffRangesJsonFilePath(); const jsonFilePath = getDiffRangesJsonFilePath();
fs5.writeFileSync(jsonFilePath, jsonContents); fs6.writeFileSync(jsonFilePath, jsonContents);
logger.debug( logger.debug(
`Wrote pr-diff-range JSON file to ${jsonFilePath}: `Wrote pr-diff-range JSON file to ${jsonFilePath}:
${jsonContents}` ${jsonContents}`
@@ -108367,11 +108371,11 @@ ${jsonContents}`
} }
function readDiffRangesJsonFile(logger) { function readDiffRangesJsonFile(logger) {
const jsonFilePath = getDiffRangesJsonFilePath(); const jsonFilePath = getDiffRangesJsonFilePath();
if (!fs5.existsSync(jsonFilePath)) { if (!fs6.existsSync(jsonFilePath)) {
logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`); logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`);
return void 0; return void 0;
} }
const jsonContents = fs5.readFileSync(jsonFilePath, "utf8"); const jsonContents = fs6.readFileSync(jsonFilePath, "utf8");
logger.debug( logger.debug(
`Read pr-diff-range JSON file from ${jsonFilePath}: `Read pr-diff-range JSON file from ${jsonFilePath}:
${jsonContents}` ${jsonContents}`
@@ -108650,10 +108654,10 @@ function getPathToParsedConfigFile(tempDir) {
} }
async function getConfig(tempDir, logger) { async function getConfig(tempDir, logger) {
const configFile = getPathToParsedConfigFile(tempDir); const configFile = getPathToParsedConfigFile(tempDir);
if (!fs6.existsSync(configFile)) { if (!fs7.existsSync(configFile)) {
return void 0; return void 0;
} }
const configString = fs6.readFileSync(configFile, "utf8"); const configString = fs7.readFileSync(configFile, "utf8");
logger.debug("Loaded config:"); logger.debug("Loaded config:");
logger.debug(configString); logger.debug(configString);
const config = JSON.parse(configString); const config = JSON.parse(configString);
@@ -108704,7 +108708,7 @@ function getPrimaryAnalysisConfig(config) {
} }
// src/setup-codeql.ts // src/setup-codeql.ts
var fs9 = __toESM(require("fs")); var fs10 = __toESM(require("fs"));
var path9 = __toESM(require("path")); var path9 = __toESM(require("path"));
var toolcache3 = __toESM(require_tool_cache()); var toolcache3 = __toESM(require_tool_cache());
var import_fast_deep_equal = __toESM(require_fast_deep_equal()); var import_fast_deep_equal = __toESM(require_fast_deep_equal());
@@ -108766,7 +108770,7 @@ var v4_default = v4;
// src/tar.ts // src/tar.ts
var import_child_process = require("child_process"); var import_child_process = require("child_process");
var fs7 = __toESM(require("fs")); var fs8 = __toESM(require("fs"));
var stream = __toESM(require("stream")); var stream = __toESM(require("stream"));
var import_toolrunner = __toESM(require_toolrunner()); var import_toolrunner = __toESM(require_toolrunner());
var io4 = __toESM(require_io()); var io4 = __toESM(require_io());
@@ -108839,7 +108843,7 @@ async function isZstdAvailable(logger) {
} }
} }
async function extract(tarPath, dest, compressionMethod, tarVersion, logger) { async function extract(tarPath, dest, compressionMethod, tarVersion, logger) {
fs7.mkdirSync(dest, { recursive: true }); fs8.mkdirSync(dest, { recursive: true });
switch (compressionMethod) { switch (compressionMethod) {
case "gzip": case "gzip":
return await toolcache.extractTar(tarPath, dest); return await toolcache.extractTar(tarPath, dest);
@@ -108923,7 +108927,7 @@ function inferCompressionMethod(tarPath) {
} }
// src/tools-download.ts // src/tools-download.ts
var fs8 = __toESM(require("fs")); var fs9 = __toESM(require("fs"));
var os2 = __toESM(require("os")); var os2 = __toESM(require("os"));
var path8 = __toESM(require("path")); var path8 = __toESM(require("path"));
var import_perf_hooks = require("perf_hooks"); var import_perf_hooks = require("perf_hooks");
@@ -109030,7 +109034,7 @@ async function downloadAndExtract(codeqlURL, compressionMethod, dest, authorizat
}; };
} }
async function downloadAndExtractZstdWithStreaming(codeqlURL, dest, authorization, headers, tarVersion, logger) { async function downloadAndExtractZstdWithStreaming(codeqlURL, dest, authorization, headers, tarVersion, logger) {
fs8.mkdirSync(dest, { recursive: true }); fs9.mkdirSync(dest, { recursive: true });
const agent = new import_http_client.HttpClient().getAgent(codeqlURL); const agent = new import_http_client.HttpClient().getAgent(codeqlURL);
headers = Object.assign( headers = Object.assign(
{ "User-Agent": "CodeQL Action" }, { "User-Agent": "CodeQL Action" },
@@ -109067,7 +109071,7 @@ function getToolcacheDirectory(version) {
} }
function writeToolcacheMarkerFile(extractedPath, logger) { function writeToolcacheMarkerFile(extractedPath, logger) {
const markerFilePath = `${extractedPath}.complete`; const markerFilePath = `${extractedPath}.complete`;
fs8.writeFileSync(markerFilePath, ""); fs9.writeFileSync(markerFilePath, "");
logger.info(`Created toolcache marker file ${markerFilePath}`); logger.info(`Created toolcache marker file ${markerFilePath}`);
} }
function sanitizeUrlForStatusReport(url2) { function sanitizeUrlForStatusReport(url2) {
@@ -109202,7 +109206,7 @@ async function findOverridingToolsInCache(humanReadableVersion, logger) {
const candidates = toolcache3.findAllVersions("CodeQL").filter(isGoodVersion).map((version) => ({ const candidates = toolcache3.findAllVersions("CodeQL").filter(isGoodVersion).map((version) => ({
folder: toolcache3.find("CodeQL", version), folder: toolcache3.find("CodeQL", version),
version version
})).filter(({ folder }) => fs9.existsSync(path9.join(folder, "pinned-version"))); })).filter(({ folder }) => fs10.existsSync(path9.join(folder, "pinned-version")));
if (candidates.length === 1) { if (candidates.length === 1) {
const candidate = candidates[0]; const candidate = candidates[0];
logger.debug( logger.debug(
@@ -109649,7 +109653,7 @@ function isReservedToolsValue(tools) {
} }
// src/tracer-config.ts // src/tracer-config.ts
var fs10 = __toESM(require("fs")); var fs11 = __toESM(require("fs"));
var path10 = __toESM(require("path")); var path10 = __toESM(require("path"));
async function shouldEnableIndirectTracing(codeql, config) { async function shouldEnableIndirectTracing(codeql, config) {
if (config.buildMode === "none" /* None */) { if (config.buildMode === "none" /* None */) {
@@ -109669,14 +109673,14 @@ async function endTracingForCluster(codeql, config, logger) {
config.dbLocation, config.dbLocation,
"temp/tracingEnvironment/end-tracing.json" "temp/tracingEnvironment/end-tracing.json"
); );
if (!fs10.existsSync(envVariablesFile)) { if (!fs11.existsSync(envVariablesFile)) {
throw new Error( throw new Error(
`Environment file for ending tracing not found: ${envVariablesFile}` `Environment file for ending tracing not found: ${envVariablesFile}`
); );
} }
try { try {
const endTracingEnvVariables = JSON.parse( const endTracingEnvVariables = JSON.parse(
fs10.readFileSync(envVariablesFile, "utf8") fs11.readFileSync(envVariablesFile, "utf8")
); );
for (const [key, value] of Object.entries(endTracingEnvVariables)) { for (const [key, value] of Object.entries(endTracingEnvVariables)) {
if (value !== null) { if (value !== null) {
@@ -109789,7 +109793,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
"tools", "tools",
"tracing-config.lua" "tracing-config.lua"
); );
return fs11.existsSync(tracingConfigPath); return fs12.existsSync(tracingConfigPath);
}, },
async isScannedLanguage(language) { async isScannedLanguage(language) {
return !await this.isTracedLanguage(language); return !await this.isTracedLanguage(language);
@@ -110269,7 +110273,7 @@ async function writeCodeScanningConfigFile(config, logger) {
logger.startGroup("Augmented user configuration file contents"); logger.startGroup("Augmented user configuration file contents");
logger.info(dump(augmentedConfig)); logger.info(dump(augmentedConfig));
logger.endGroup(); logger.endGroup();
fs11.writeFileSync(codeScanningConfigFile, dump(augmentedConfig)); fs12.writeFileSync(codeScanningConfigFile, dump(augmentedConfig));
return codeScanningConfigFile; return codeScanningConfigFile;
} }
var TRAP_CACHE_SIZE_MB = 1024; var TRAP_CACHE_SIZE_MB = 1024;
@@ -110616,7 +110620,7 @@ function dbIsFinalized(config, language, logger) {
const dbPath = getCodeQLDatabasePath(config, language); const dbPath = getCodeQLDatabasePath(config, language);
try { try {
const dbInfo = load( const dbInfo = load(
fs12.readFileSync(path12.resolve(dbPath, "codeql-database.yml"), "utf8") fs13.readFileSync(path12.resolve(dbPath, "codeql-database.yml"), "utf8")
); );
return !("inProgress" in dbInfo); return !("inProgress" in dbInfo);
} catch { } catch {
@@ -110683,8 +110687,8 @@ function writeDiffRangeDataExtensionPack(logger, ranges) {
ranges = [{ path: "", startLine: 0, endLine: 0 }]; ranges = [{ path: "", startLine: 0, endLine: 0 }];
} }
const diffRangeDir = path12.join(getTemporaryDirectory(), "pr-diff-range"); const diffRangeDir = path12.join(getTemporaryDirectory(), "pr-diff-range");
fs12.mkdirSync(diffRangeDir, { recursive: true }); fs13.mkdirSync(diffRangeDir, { recursive: true });
fs12.writeFileSync( fs13.writeFileSync(
path12.join(diffRangeDir, "qlpack.yml"), path12.join(diffRangeDir, "qlpack.yml"),
` `
name: codeql-action/pr-diff-range name: codeql-action/pr-diff-range
@@ -110718,7 +110722,7 @@ extensions:
} }
const extensionContents = header + data; const extensionContents = header + data;
const extensionFilePath = path12.join(diffRangeDir, "pr-diff-range.yml"); const extensionFilePath = path12.join(diffRangeDir, "pr-diff-range.yml");
fs12.writeFileSync(extensionFilePath, extensionContents); fs13.writeFileSync(extensionFilePath, extensionContents);
logger.debug( logger.debug(
`Wrote pr-diff-range extension pack to ${extensionFilePath}: `Wrote pr-diff-range extension pack to ${extensionFilePath}:
${extensionContents}` ${extensionContents}`
@@ -110871,7 +110875,7 @@ async function runQueries(sarifFolder, memoryFlag, threadsFlag, diffRangePackDir
} }
function getPerQueryAlertCounts(sarifPath) { function getPerQueryAlertCounts(sarifPath) {
const sarifObject = JSON.parse( const sarifObject = JSON.parse(
fs12.readFileSync(sarifPath, "utf8") fs13.readFileSync(sarifPath, "utf8")
); );
const perQueryAlertCounts = {}; const perQueryAlertCounts = {};
for (const sarifRun of sarifObject.runs) { for (const sarifRun of sarifObject.runs) {
@@ -110889,13 +110893,13 @@ async function runQueries(sarifFolder, memoryFlag, threadsFlag, diffRangePackDir
} }
async function runFinalize(features, outputDir, threadsFlag, memoryFlag, codeql, config, logger) { async function runFinalize(features, outputDir, threadsFlag, memoryFlag, codeql, config, logger) {
try { try {
await fs12.promises.rm(outputDir, { force: true, recursive: true }); await fs13.promises.rm(outputDir, { force: true, recursive: true });
} catch (error3) { } catch (error3) {
if (error3?.code !== "ENOENT") { if (error3?.code !== "ENOENT") {
throw error3; throw error3;
} }
} }
await fs12.promises.mkdir(outputDir, { recursive: true }); await fs13.promises.mkdir(outputDir, { recursive: true });
const timings = await finalizeDatabaseCreation( const timings = await finalizeDatabaseCreation(
codeql, codeql,
features, features,
@@ -110939,7 +110943,7 @@ async function warnIfGoInstalledAfterInit(config, logger) {
} }
// src/database-upload.ts // src/database-upload.ts
var fs13 = __toESM(require("fs")); var fs14 = __toESM(require("fs"));
async function cleanupAndUploadDatabases(repositoryNwo, codeql, config, apiDetails, features, logger) { async function cleanupAndUploadDatabases(repositoryNwo, codeql, config, apiDetails, features, logger) {
if (getRequiredInput("upload-database") !== "true") { if (getRequiredInput("upload-database") !== "true") {
logger.debug("Database upload disabled in workflow. Skipping upload."); logger.debug("Database upload disabled in workflow. Skipping upload.");
@@ -110982,8 +110986,8 @@ async function cleanupAndUploadDatabases(repositoryNwo, codeql, config, apiDetai
const bundledDb = await bundleDb(config, language, codeql, language, { const bundledDb = await bundleDb(config, language, codeql, language, {
includeDiagnostics: false includeDiagnostics: false
}); });
bundledDbSize = fs13.statSync(bundledDb).size; bundledDbSize = fs14.statSync(bundledDb).size;
const bundledDbReadStream = fs13.createReadStream(bundledDb); const bundledDbReadStream = fs14.createReadStream(bundledDb);
const commitOid = await getCommitOid( const commitOid = await getCommitOid(
getRequiredInput("checkout_path") getRequiredInput("checkout_path")
); );
@@ -111239,7 +111243,7 @@ async function sendUnhandledErrorStatusReport(actionName, actionStartedAt, error
} }
// src/upload-lib.ts // src/upload-lib.ts
var fs15 = __toESM(require("fs")); var fs16 = __toESM(require("fs"));
var path14 = __toESM(require("path")); var path14 = __toESM(require("path"));
var url = __toESM(require("url")); var url = __toESM(require("url"));
var import_zlib = __toESM(require("zlib")); var import_zlib = __toESM(require("zlib"));
@@ -111247,7 +111251,7 @@ var core13 = __toESM(require_core());
var jsonschema2 = __toESM(require_lib2()); var jsonschema2 = __toESM(require_lib2());
// src/fingerprints.ts // src/fingerprints.ts
var fs14 = __toESM(require("fs")); var fs15 = __toESM(require("fs"));
var import_path3 = __toESM(require("path")); var import_path3 = __toESM(require("path"));
// node_modules/long/index.js // node_modules/long/index.js
@@ -112235,7 +112239,7 @@ async function hash(callback, filepath) {
} }
updateHash(current); updateHash(current);
}; };
const readStream = fs14.createReadStream(filepath, "utf8"); const readStream = fs15.createReadStream(filepath, "utf8");
for await (const data of readStream) { for await (const data of readStream) {
for (let i = 0; i < data.length; ++i) { for (let i = 0; i < data.length; ++i) {
processCharacter(data.charCodeAt(i)); processCharacter(data.charCodeAt(i));
@@ -112310,11 +112314,11 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
if (!import_path3.default.isAbsolute(uri)) { if (!import_path3.default.isAbsolute(uri)) {
uri = srcRootPrefix + uri; uri = srcRootPrefix + uri;
} }
if (!fs14.existsSync(uri)) { if (!fs15.existsSync(uri)) {
logger.debug(`Unable to compute fingerprint for non-existent file: ${uri}`); logger.debug(`Unable to compute fingerprint for non-existent file: ${uri}`);
return void 0; return void 0;
} }
if (fs14.statSync(uri).isDirectory()) { if (fs15.statSync(uri).isDirectory()) {
logger.debug(`Unable to compute fingerprint for directory: ${uri}`); logger.debug(`Unable to compute fingerprint for directory: ${uri}`);
return void 0; return void 0;
} }
@@ -112411,9 +112415,7 @@ function combineSarifFiles(sarifFiles, logger) {
}; };
for (const sarifFile of sarifFiles) { for (const sarifFile of sarifFiles) {
logger.debug(`Loading SARIF file: ${sarifFile}`); logger.debug(`Loading SARIF file: ${sarifFile}`);
const sarifObject = JSON.parse( const sarifObject = readSarifFile(sarifFile);
fs15.readFileSync(sarifFile, "utf8")
);
if (combinedSarif.version === null) { if (combinedSarif.version === null) {
combinedSarif.version = sarifObject.version; combinedSarif.version = sarifObject.version;
} else if (combinedSarif.version !== sarifObject.version) { } else if (combinedSarif.version !== sarifObject.version) {
@@ -112483,9 +112485,7 @@ async function shouldDisableCombineSarifFiles(sarifObjects, githubVersion) {
} }
async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, logger) { async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, logger) {
logger.info("Combining SARIF files using the CodeQL CLI"); logger.info("Combining SARIF files using the CodeQL CLI");
const sarifObjects = sarifFiles.map((sarifFile) => { const sarifObjects = sarifFiles.map(readSarifFile);
return JSON.parse(fs15.readFileSync(sarifFile, "utf8"));
});
const deprecationWarningMessage = gitHubVersion.type === "GitHub Enterprise Server" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025"; const deprecationWarningMessage = gitHubVersion.type === "GitHub Enterprise Server" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025";
const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload"; const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload";
if (!areAllRunsProducedByCodeQL(sarifObjects)) { if (!areAllRunsProducedByCodeQL(sarifObjects)) {
@@ -112538,13 +112538,13 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
codeQL = initCodeQLResult.codeql; codeQL = initCodeQLResult.codeql;
} }
const baseTempDir = path14.resolve(tempDir, "combined-sarif"); const baseTempDir = path14.resolve(tempDir, "combined-sarif");
fs15.mkdirSync(baseTempDir, { recursive: true }); fs16.mkdirSync(baseTempDir, { recursive: true });
const outputDirectory = fs15.mkdtempSync(path14.resolve(baseTempDir, "output-")); const outputDirectory = fs16.mkdtempSync(path14.resolve(baseTempDir, "output-"));
const outputFile = path14.resolve(outputDirectory, "combined-sarif.sarif"); const outputFile = path14.resolve(outputDirectory, "combined-sarif.sarif");
await codeQL.mergeResults(sarifFiles, outputFile, { await codeQL.mergeResults(sarifFiles, outputFile, {
mergeRunsFromEqualCategory: true mergeRunsFromEqualCategory: true
}); });
return JSON.parse(fs15.readFileSync(outputFile, "utf8")); return readSarifFile(outputFile);
} }
function populateRunAutomationDetails(sarif, category, analysis_key, environment) { function populateRunAutomationDetails(sarif, category, analysis_key, environment) {
const automationID = getAutomationID2(category, analysis_key, environment); const automationID = getAutomationID2(category, analysis_key, environment);
@@ -112581,7 +112581,7 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) {
`SARIF upload disabled by an environment variable. Saving to ${payloadSaveFile}` `SARIF upload disabled by an environment variable. Saving to ${payloadSaveFile}`
); );
logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`); logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`);
fs15.writeFileSync(payloadSaveFile, JSON.stringify(payload, null, 2)); fs16.writeFileSync(payloadSaveFile, JSON.stringify(payload, null, 2));
return "dummy-sarif-id"; return "dummy-sarif-id";
} }
const client = getApiClient(); const client = getApiClient();
@@ -112615,7 +112615,7 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) {
function findSarifFilesInDir(sarifPath, isSarif) { function findSarifFilesInDir(sarifPath, isSarif) {
const sarifFiles = []; const sarifFiles = [];
const walkSarifFiles = (dir) => { const walkSarifFiles = (dir) => {
const entries = fs15.readdirSync(dir, { withFileTypes: true }); const entries = fs16.readdirSync(dir, { withFileTypes: true });
for (const entry of entries) { for (const entry of entries) {
if (entry.isFile() && isSarif(entry.name)) { if (entry.isFile() && isSarif(entry.name)) {
sarifFiles.push(path14.resolve(dir, entry.name)); sarifFiles.push(path14.resolve(dir, entry.name));
@@ -112628,7 +112628,7 @@ function findSarifFilesInDir(sarifPath, isSarif) {
return sarifFiles; return sarifFiles;
} }
async function getGroupedSarifFilePaths(logger, sarifPath) { async function getGroupedSarifFilePaths(logger, sarifPath) {
const stats = fs15.statSync(sarifPath, { throwIfNoEntry: false }); const stats = fs16.statSync(sarifPath, { throwIfNoEntry: false });
if (stats === void 0) { if (stats === void 0) {
throw new ConfigurationError(`Path does not exist: ${sarifPath}`); throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
} }
@@ -112691,9 +112691,9 @@ function countResultsInSarif(sarif) {
} }
return numResults; return numResults;
} }
function readSarifFile(sarifFilePath) { function readSarifFile2(sarifFilePath) {
try { try {
return JSON.parse(fs15.readFileSync(sarifFilePath, "utf8")); return readSarifFile(sarifFilePath);
} catch (e) { } catch (e) {
throw new InvalidSarifUploadError( throw new InvalidSarifUploadError(
`Invalid SARIF. JSON syntax error: ${getErrorMessage(e)}` `Invalid SARIF. JSON syntax error: ${getErrorMessage(e)}`
@@ -112762,7 +112762,7 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
payloadObj.base_sha = mergeBaseCommitOid; payloadObj.base_sha = mergeBaseCommitOid;
} else if (process.env.GITHUB_EVENT_PATH) { } else if (process.env.GITHUB_EVENT_PATH) {
const githubEvent = JSON.parse( const githubEvent = JSON.parse(
fs15.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8") fs16.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8")
); );
payloadObj.base_ref = `refs/heads/${githubEvent.pull_request.base.ref}`; payloadObj.base_ref = `refs/heads/${githubEvent.pull_request.base.ref}`;
payloadObj.base_sha = githubEvent.pull_request.base.sha; payloadObj.base_sha = githubEvent.pull_request.base.sha;
@@ -112777,7 +112777,7 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths,
category = analysis.fixCategory(logger, category); category = analysis.fixCategory(logger, category);
if (sarifPaths.length > 1) { if (sarifPaths.length > 1) {
for (const sarifPath of sarifPaths) { for (const sarifPath of sarifPaths) {
const parsedSarif = readSarifFile(sarifPath); const parsedSarif = readSarifFile2(sarifPath);
validateSarifFileSchema(parsedSarif, sarifPath, logger); validateSarifFileSchema(parsedSarif, sarifPath, logger);
} }
sarif = await combineSarifFilesUsingCLI( sarif = await combineSarifFilesUsingCLI(
@@ -112788,7 +112788,7 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths,
); );
} else { } else {
const sarifPath = sarifPaths[0]; const sarifPath = sarifPaths[0];
sarif = readSarifFile(sarifPath); sarif = readSarifFile2(sarifPath);
validateSarifFileSchema(sarif, sarifPath, logger); validateSarifFileSchema(sarif, sarifPath, logger);
await throwIfCombineSarifFilesDisabled([sarif], gitHubVersion); await throwIfCombineSarifFilesDisabled([sarif], gitHubVersion);
} }
@@ -112866,9 +112866,9 @@ async function uploadPostProcessedFiles(logger, checkoutPath, uploadTarget, post
}; };
} }
function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) { function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) {
if (!fs15.existsSync(outputDir)) { if (!fs16.existsSync(outputDir)) {
fs15.mkdirSync(outputDir, { recursive: true }); fs16.mkdirSync(outputDir, { recursive: true });
} else if (!fs15.lstatSync(outputDir).isDirectory()) { } else if (!fs16.lstatSync(outputDir).isDirectory()) {
throw new ConfigurationError( throw new ConfigurationError(
`The path that processed SARIF files should be written to exists, but is not a directory: ${outputDir}` `The path that processed SARIF files should be written to exists, but is not a directory: ${outputDir}`
); );
@@ -112878,7 +112878,7 @@ function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) {
`upload${uploadTarget.sarifExtension}` `upload${uploadTarget.sarifExtension}`
); );
logger.info(`Writing processed SARIF file to ${outputFile}`); logger.info(`Writing processed SARIF file to ${outputFile}`);
fs15.writeFileSync(outputFile, sarifPayload); fs16.writeFileSync(outputFile, sarifPayload);
} }
var STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1e3; var STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1e3;
var STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1e3; var STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1e3;
@@ -113111,7 +113111,7 @@ function doesGoExtractionOutputExist(config) {
"go" /* go */ "go" /* go */
); );
const trapDirectory = import_path4.default.join(golangDbDirectory, "trap", "go" /* go */); const trapDirectory = import_path4.default.join(golangDbDirectory, "trap", "go" /* go */);
return fs16.existsSync(trapDirectory) && fs16.readdirSync(trapDirectory).some( return fs17.existsSync(trapDirectory) && fs17.readdirSync(trapDirectory).some(
(fileName) => [ (fileName) => [
".trap", ".trap",
".trap.gz", ".trap.gz",

668
lib/init-action-post.js generated

File diff suppressed because it is too large Load Diff

204
lib/upload-lib.js generated
View File

@@ -204,7 +204,7 @@ var require_file_command = __commonJS({
exports2.issueFileCommand = issueFileCommand; exports2.issueFileCommand = issueFileCommand;
exports2.prepareKeyValueMessage = prepareKeyValueMessage; exports2.prepareKeyValueMessage = prepareKeyValueMessage;
var crypto2 = __importStar2(require("crypto")); var crypto2 = __importStar2(require("crypto"));
var fs12 = __importStar2(require("fs")); var fs13 = __importStar2(require("fs"));
var os2 = __importStar2(require("os")); var os2 = __importStar2(require("os"));
var utils_1 = require_utils(); var utils_1 = require_utils();
function issueFileCommand(command, message) { function issueFileCommand(command, message) {
@@ -212,10 +212,10 @@ var require_file_command = __commonJS({
if (!filePath) { if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`); throw new Error(`Unable to find environment variable for file command ${command}`);
} }
if (!fs12.existsSync(filePath)) { if (!fs13.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`); throw new Error(`Missing file at path: ${filePath}`);
} }
fs12.appendFileSync(filePath, `${(0, utils_1.toCommandValue)(message)}${os2.EOL}`, { fs13.appendFileSync(filePath, `${(0, utils_1.toCommandValue)(message)}${os2.EOL}`, {
encoding: "utf8" encoding: "utf8"
}); });
} }
@@ -20123,13 +20123,13 @@ var require_io_util = __commonJS({
exports2.isRooted = isRooted; exports2.isRooted = isRooted;
exports2.tryGetExecutablePath = tryGetExecutablePath; exports2.tryGetExecutablePath = tryGetExecutablePath;
exports2.getCmdPath = getCmdPath; exports2.getCmdPath = getCmdPath;
var fs12 = __importStar2(require("fs")); var fs13 = __importStar2(require("fs"));
var path12 = __importStar2(require("path")); var path12 = __importStar2(require("path"));
_a = fs12.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink; _a = fs13.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink;
exports2.IS_WINDOWS = process.platform === "win32"; exports2.IS_WINDOWS = process.platform === "win32";
function readlink(fsPath) { function readlink(fsPath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const result = yield fs12.promises.readlink(fsPath); const result = yield fs13.promises.readlink(fsPath);
if (exports2.IS_WINDOWS && !result.endsWith("\\")) { if (exports2.IS_WINDOWS && !result.endsWith("\\")) {
return `${result}\\`; return `${result}\\`;
} }
@@ -20137,7 +20137,7 @@ var require_io_util = __commonJS({
}); });
} }
exports2.UV_FS_O_EXLOCK = 268435456; exports2.UV_FS_O_EXLOCK = 268435456;
exports2.READONLY = fs12.constants.O_RDONLY; exports2.READONLY = fs13.constants.O_RDONLY;
function exists(fsPath) { function exists(fsPath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
try { try {
@@ -50403,7 +50403,7 @@ var require_internal_globber = __commonJS({
Object.defineProperty(exports2, "__esModule", { value: true }); Object.defineProperty(exports2, "__esModule", { value: true });
exports2.DefaultGlobber = void 0; exports2.DefaultGlobber = void 0;
var core12 = __importStar2(require_core()); var core12 = __importStar2(require_core());
var fs12 = __importStar2(require("fs")); var fs13 = __importStar2(require("fs"));
var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var globOptionsHelper = __importStar2(require_internal_glob_options_helper());
var path12 = __importStar2(require("path")); var path12 = __importStar2(require("path"));
var patternHelper = __importStar2(require_internal_pattern_helper()); var patternHelper = __importStar2(require_internal_pattern_helper());
@@ -50457,7 +50457,7 @@ var require_internal_globber = __commonJS({
for (const searchPath of patternHelper.getSearchPaths(patterns)) { for (const searchPath of patternHelper.getSearchPaths(patterns)) {
core12.debug(`Search path '${searchPath}'`); core12.debug(`Search path '${searchPath}'`);
try { try {
yield __await2(fs12.promises.lstat(searchPath)); yield __await2(fs13.promises.lstat(searchPath));
} catch (err) { } catch (err) {
if (err.code === "ENOENT") { if (err.code === "ENOENT") {
continue; continue;
@@ -50491,7 +50491,7 @@ var require_internal_globber = __commonJS({
continue; continue;
} }
const childLevel = item.level + 1; const childLevel = item.level + 1;
const childItems = (yield __await2(fs12.promises.readdir(item.path))).map((x) => new internal_search_state_1.SearchState(path12.join(item.path, x), childLevel)); const childItems = (yield __await2(fs13.promises.readdir(item.path))).map((x) => new internal_search_state_1.SearchState(path12.join(item.path, x), childLevel));
stack.push(...childItems.reverse()); stack.push(...childItems.reverse());
} else if (match & internal_match_kind_1.MatchKind.File) { } else if (match & internal_match_kind_1.MatchKind.File) {
yield yield __await2(item.path); yield yield __await2(item.path);
@@ -50526,7 +50526,7 @@ var require_internal_globber = __commonJS({
let stats; let stats;
if (options.followSymbolicLinks) { if (options.followSymbolicLinks) {
try { try {
stats = yield fs12.promises.stat(item.path); stats = yield fs13.promises.stat(item.path);
} catch (err) { } catch (err) {
if (err.code === "ENOENT") { if (err.code === "ENOENT") {
if (options.omitBrokenSymbolicLinks) { if (options.omitBrokenSymbolicLinks) {
@@ -50538,10 +50538,10 @@ var require_internal_globber = __commonJS({
throw err; throw err;
} }
} else { } else {
stats = yield fs12.promises.lstat(item.path); stats = yield fs13.promises.lstat(item.path);
} }
if (stats.isDirectory() && options.followSymbolicLinks) { if (stats.isDirectory() && options.followSymbolicLinks) {
const realPath = yield fs12.promises.realpath(item.path); const realPath = yield fs13.promises.realpath(item.path);
while (traversalChain.length >= item.level) { while (traversalChain.length >= item.level) {
traversalChain.pop(); traversalChain.pop();
} }
@@ -50650,7 +50650,7 @@ var require_internal_hash_files = __commonJS({
exports2.hashFiles = hashFiles; exports2.hashFiles = hashFiles;
var crypto2 = __importStar2(require("crypto")); var crypto2 = __importStar2(require("crypto"));
var core12 = __importStar2(require_core()); var core12 = __importStar2(require_core());
var fs12 = __importStar2(require("fs")); var fs13 = __importStar2(require("fs"));
var stream2 = __importStar2(require("stream")); var stream2 = __importStar2(require("stream"));
var util = __importStar2(require("util")); var util = __importStar2(require("util"));
var path12 = __importStar2(require("path")); var path12 = __importStar2(require("path"));
@@ -50673,13 +50673,13 @@ var require_internal_hash_files = __commonJS({
writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`); writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
continue; continue;
} }
if (fs12.statSync(file).isDirectory()) { if (fs13.statSync(file).isDirectory()) {
writeDelegate(`Skip directory '${file}'.`); writeDelegate(`Skip directory '${file}'.`);
continue; continue;
} }
const hash2 = crypto2.createHash("sha256"); const hash2 = crypto2.createHash("sha256");
const pipeline = util.promisify(stream2.pipeline); const pipeline = util.promisify(stream2.pipeline);
yield pipeline(fs12.createReadStream(file), hash2); yield pipeline(fs13.createReadStream(file), hash2);
result.write(hash2.digest()); result.write(hash2.digest());
count++; count++;
if (!hasMatch) { if (!hasMatch) {
@@ -52054,7 +52054,7 @@ var require_cacheUtils = __commonJS({
var glob = __importStar2(require_glob()); var glob = __importStar2(require_glob());
var io6 = __importStar2(require_io()); var io6 = __importStar2(require_io());
var crypto2 = __importStar2(require("crypto")); var crypto2 = __importStar2(require("crypto"));
var fs12 = __importStar2(require("fs")); var fs13 = __importStar2(require("fs"));
var path12 = __importStar2(require("path")); var path12 = __importStar2(require("path"));
var semver9 = __importStar2(require_semver3()); var semver9 = __importStar2(require_semver3());
var util = __importStar2(require("util")); var util = __importStar2(require("util"));
@@ -52083,7 +52083,7 @@ var require_cacheUtils = __commonJS({
}); });
} }
function getArchiveFileSizeInBytes(filePath) { function getArchiveFileSizeInBytes(filePath) {
return fs12.statSync(filePath).size; return fs13.statSync(filePath).size;
} }
function resolvePaths(patterns) { function resolvePaths(patterns) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
@@ -52121,7 +52121,7 @@ var require_cacheUtils = __commonJS({
} }
function unlinkFile(filePath) { function unlinkFile(filePath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
return util.promisify(fs12.unlink)(filePath); return util.promisify(fs13.unlink)(filePath);
}); });
} }
function getVersion(app_1) { function getVersion(app_1) {
@@ -52163,7 +52163,7 @@ var require_cacheUtils = __commonJS({
} }
function getGnuTarPathOnWindows() { function getGnuTarPathOnWindows() {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
if (fs12.existsSync(constants_1.GnuTarPathOnWindows)) { if (fs13.existsSync(constants_1.GnuTarPathOnWindows)) {
return constants_1.GnuTarPathOnWindows; return constants_1.GnuTarPathOnWindows;
} }
const versionOutput = yield getVersion("tar"); const versionOutput = yield getVersion("tar");
@@ -92320,7 +92320,7 @@ var require_downloadUtils = __commonJS({
var http_client_1 = require_lib(); var http_client_1 = require_lib();
var storage_blob_1 = require_commonjs15(); var storage_blob_1 = require_commonjs15();
var buffer = __importStar2(require("buffer")); var buffer = __importStar2(require("buffer"));
var fs12 = __importStar2(require("fs")); var fs13 = __importStar2(require("fs"));
var stream2 = __importStar2(require("stream")); var stream2 = __importStar2(require("stream"));
var util = __importStar2(require("util")); var util = __importStar2(require("util"));
var utils = __importStar2(require_cacheUtils()); var utils = __importStar2(require_cacheUtils());
@@ -92431,7 +92431,7 @@ var require_downloadUtils = __commonJS({
exports2.DownloadProgress = DownloadProgress; exports2.DownloadProgress = DownloadProgress;
function downloadCacheHttpClient(archiveLocation, archivePath) { function downloadCacheHttpClient(archiveLocation, archivePath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const writeStream = fs12.createWriteStream(archivePath); const writeStream = fs13.createWriteStream(archivePath);
const httpClient = new http_client_1.HttpClient("actions/cache"); const httpClient = new http_client_1.HttpClient("actions/cache");
const downloadResponse = yield (0, requestUtils_1.retryHttpClientResponse)("downloadCache", () => __awaiter2(this, void 0, void 0, function* () { const downloadResponse = yield (0, requestUtils_1.retryHttpClientResponse)("downloadCache", () => __awaiter2(this, void 0, void 0, function* () {
return httpClient.get(archiveLocation); return httpClient.get(archiveLocation);
@@ -92456,7 +92456,7 @@ var require_downloadUtils = __commonJS({
function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options) { function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
var _a; var _a;
const archiveDescriptor = yield fs12.promises.open(archivePath, "w"); const archiveDescriptor = yield fs13.promises.open(archivePath, "w");
const httpClient = new http_client_1.HttpClient("actions/cache", void 0, { const httpClient = new http_client_1.HttpClient("actions/cache", void 0, {
socketTimeout: options.timeoutInMs, socketTimeout: options.timeoutInMs,
keepAlive: true keepAlive: true
@@ -92572,7 +92572,7 @@ var require_downloadUtils = __commonJS({
} else { } else {
const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH);
const downloadProgress = new DownloadProgress(contentLength); const downloadProgress = new DownloadProgress(contentLength);
const fd = fs12.openSync(archivePath, "w"); const fd = fs13.openSync(archivePath, "w");
try { try {
downloadProgress.startDisplayTimer(); downloadProgress.startDisplayTimer();
const controller = new abort_controller_1.AbortController(); const controller = new abort_controller_1.AbortController();
@@ -92590,12 +92590,12 @@ var require_downloadUtils = __commonJS({
controller.abort(); controller.abort();
throw new Error("Aborting cache download as the download time exceeded the timeout."); throw new Error("Aborting cache download as the download time exceeded the timeout.");
} else if (Buffer.isBuffer(result)) { } else if (Buffer.isBuffer(result)) {
fs12.writeFileSync(fd, result); fs13.writeFileSync(fd, result);
} }
} }
} finally { } finally {
downloadProgress.stopDisplayTimer(); downloadProgress.stopDisplayTimer();
fs12.closeSync(fd); fs13.closeSync(fd);
} }
} }
}); });
@@ -92917,7 +92917,7 @@ var require_cacheHttpClient = __commonJS({
var core12 = __importStar2(require_core()); var core12 = __importStar2(require_core());
var http_client_1 = require_lib(); var http_client_1 = require_lib();
var auth_1 = require_auth(); var auth_1 = require_auth();
var fs12 = __importStar2(require("fs")); var fs13 = __importStar2(require("fs"));
var url_1 = require("url"); var url_1 = require("url");
var utils = __importStar2(require_cacheUtils()); var utils = __importStar2(require_cacheUtils());
var uploadUtils_1 = require_uploadUtils(); var uploadUtils_1 = require_uploadUtils();
@@ -93052,7 +93052,7 @@ Other caches with similar key:`);
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const fileSize = utils.getArchiveFileSizeInBytes(archivePath); const fileSize = utils.getArchiveFileSizeInBytes(archivePath);
const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`); const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
const fd = fs12.openSync(archivePath, "r"); const fd = fs13.openSync(archivePath, "r");
const uploadOptions = (0, options_1.getUploadOptions)(options); const uploadOptions = (0, options_1.getUploadOptions)(options);
const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency);
const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize);
@@ -93066,7 +93066,7 @@ Other caches with similar key:`);
const start = offset; const start = offset;
const end = offset + chunkSize - 1; const end = offset + chunkSize - 1;
offset += maxChunkSize; offset += maxChunkSize;
yield uploadChunk(httpClient, resourceUrl, () => fs12.createReadStream(archivePath, { yield uploadChunk(httpClient, resourceUrl, () => fs13.createReadStream(archivePath, {
fd, fd,
start, start,
end, end,
@@ -93077,7 +93077,7 @@ Other caches with similar key:`);
} }
}))); })));
} finally { } finally {
fs12.closeSync(fd); fs13.closeSync(fd);
} }
return; return;
}); });
@@ -99033,7 +99033,7 @@ var require_manifest = __commonJS({
var core_1 = require_core(); var core_1 = require_core();
var os2 = require("os"); var os2 = require("os");
var cp = require("child_process"); var cp = require("child_process");
var fs12 = require("fs"); var fs13 = require("fs");
function _findMatch(versionSpec, stable, candidates, archFilter) { function _findMatch(versionSpec, stable, candidates, archFilter) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const platFilter = os2.platform(); const platFilter = os2.platform();
@@ -99095,10 +99095,10 @@ var require_manifest = __commonJS({
const lsbReleaseFile = "/etc/lsb-release"; const lsbReleaseFile = "/etc/lsb-release";
const osReleaseFile = "/etc/os-release"; const osReleaseFile = "/etc/os-release";
let contents = ""; let contents = "";
if (fs12.existsSync(lsbReleaseFile)) { if (fs13.existsSync(lsbReleaseFile)) {
contents = fs12.readFileSync(lsbReleaseFile).toString(); contents = fs13.readFileSync(lsbReleaseFile).toString();
} else if (fs12.existsSync(osReleaseFile)) { } else if (fs13.existsSync(osReleaseFile)) {
contents = fs12.readFileSync(osReleaseFile).toString(); contents = fs13.readFileSync(osReleaseFile).toString();
} }
return contents; return contents;
} }
@@ -99307,7 +99307,7 @@ var require_tool_cache = __commonJS({
var core12 = __importStar2(require_core()); var core12 = __importStar2(require_core());
var io6 = __importStar2(require_io()); var io6 = __importStar2(require_io());
var crypto2 = __importStar2(require("crypto")); var crypto2 = __importStar2(require("crypto"));
var fs12 = __importStar2(require("fs")); var fs13 = __importStar2(require("fs"));
var mm = __importStar2(require_manifest()); var mm = __importStar2(require_manifest());
var os2 = __importStar2(require("os")); var os2 = __importStar2(require("os"));
var path12 = __importStar2(require("path")); var path12 = __importStar2(require("path"));
@@ -99353,7 +99353,7 @@ var require_tool_cache = __commonJS({
} }
function downloadToolAttempt(url2, dest, auth2, headers) { function downloadToolAttempt(url2, dest, auth2, headers) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
if (fs12.existsSync(dest)) { if (fs13.existsSync(dest)) {
throw new Error(`Destination file path ${dest} already exists`); throw new Error(`Destination file path ${dest} already exists`);
} }
const http = new httpm.HttpClient(userAgent2, [], { const http = new httpm.HttpClient(userAgent2, [], {
@@ -99377,7 +99377,7 @@ var require_tool_cache = __commonJS({
const readStream = responseMessageFactory(); const readStream = responseMessageFactory();
let succeeded = false; let succeeded = false;
try { try {
yield pipeline(readStream, fs12.createWriteStream(dest)); yield pipeline(readStream, fs13.createWriteStream(dest));
core12.debug("download complete"); core12.debug("download complete");
succeeded = true; succeeded = true;
return dest; return dest;
@@ -99589,11 +99589,11 @@ var require_tool_cache = __commonJS({
arch2 = arch2 || os2.arch(); arch2 = arch2 || os2.arch();
core12.debug(`Caching tool ${tool} ${version} ${arch2}`); core12.debug(`Caching tool ${tool} ${version} ${arch2}`);
core12.debug(`source dir: ${sourceDir}`); core12.debug(`source dir: ${sourceDir}`);
if (!fs12.statSync(sourceDir).isDirectory()) { if (!fs13.statSync(sourceDir).isDirectory()) {
throw new Error("sourceDir is not a directory"); throw new Error("sourceDir is not a directory");
} }
const destPath = yield _createToolPath(tool, version, arch2); const destPath = yield _createToolPath(tool, version, arch2);
for (const itemName of fs12.readdirSync(sourceDir)) { for (const itemName of fs13.readdirSync(sourceDir)) {
const s = path12.join(sourceDir, itemName); const s = path12.join(sourceDir, itemName);
yield io6.cp(s, destPath, { recursive: true }); yield io6.cp(s, destPath, { recursive: true });
} }
@@ -99607,7 +99607,7 @@ var require_tool_cache = __commonJS({
arch2 = arch2 || os2.arch(); arch2 = arch2 || os2.arch();
core12.debug(`Caching tool ${tool} ${version} ${arch2}`); core12.debug(`Caching tool ${tool} ${version} ${arch2}`);
core12.debug(`source file: ${sourceFile}`); core12.debug(`source file: ${sourceFile}`);
if (!fs12.statSync(sourceFile).isFile()) { if (!fs13.statSync(sourceFile).isFile()) {
throw new Error("sourceFile is not a file"); throw new Error("sourceFile is not a file");
} }
const destFolder = yield _createToolPath(tool, version, arch2); const destFolder = yield _createToolPath(tool, version, arch2);
@@ -99636,7 +99636,7 @@ var require_tool_cache = __commonJS({
versionSpec = semver9.clean(versionSpec) || ""; versionSpec = semver9.clean(versionSpec) || "";
const cachePath = path12.join(_getCacheDirectory(), toolName, versionSpec, arch2); const cachePath = path12.join(_getCacheDirectory(), toolName, versionSpec, arch2);
core12.debug(`checking cache: ${cachePath}`); core12.debug(`checking cache: ${cachePath}`);
if (fs12.existsSync(cachePath) && fs12.existsSync(`${cachePath}.complete`)) { if (fs13.existsSync(cachePath) && fs13.existsSync(`${cachePath}.complete`)) {
core12.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); core12.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`);
toolPath = cachePath; toolPath = cachePath;
} else { } else {
@@ -99649,12 +99649,12 @@ var require_tool_cache = __commonJS({
const versions = []; const versions = [];
arch2 = arch2 || os2.arch(); arch2 = arch2 || os2.arch();
const toolPath = path12.join(_getCacheDirectory(), toolName); const toolPath = path12.join(_getCacheDirectory(), toolName);
if (fs12.existsSync(toolPath)) { if (fs13.existsSync(toolPath)) {
const children = fs12.readdirSync(toolPath); const children = fs13.readdirSync(toolPath);
for (const child of children) { for (const child of children) {
if (isExplicitVersion(child)) { if (isExplicitVersion(child)) {
const fullPath = path12.join(toolPath, child, arch2 || ""); const fullPath = path12.join(toolPath, child, arch2 || "");
if (fs12.existsSync(fullPath) && fs12.existsSync(`${fullPath}.complete`)) { if (fs13.existsSync(fullPath) && fs13.existsSync(`${fullPath}.complete`)) {
versions.push(child); versions.push(child);
} }
} }
@@ -99725,7 +99725,7 @@ var require_tool_cache = __commonJS({
function _completeToolPath(tool, version, arch2) { function _completeToolPath(tool, version, arch2) {
const folderPath = path12.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); const folderPath = path12.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || "");
const markerPath = `${folderPath}.complete`; const markerPath = `${folderPath}.complete`;
fs12.writeFileSync(markerPath, ""); fs13.writeFileSync(markerPath, "");
core12.debug("finished caching tool"); core12.debug("finished caching tool");
} }
function isExplicitVersion(versionSpec) { function isExplicitVersion(versionSpec) {
@@ -103235,7 +103235,7 @@ __export(upload_lib_exports, {
getGroupedSarifFilePaths: () => getGroupedSarifFilePaths, getGroupedSarifFilePaths: () => getGroupedSarifFilePaths,
populateRunAutomationDetails: () => populateRunAutomationDetails, populateRunAutomationDetails: () => populateRunAutomationDetails,
postProcessSarifFiles: () => postProcessSarifFiles, postProcessSarifFiles: () => postProcessSarifFiles,
readSarifFile: () => readSarifFile, readSarifFile: () => readSarifFile2,
shouldConsiderConfigurationError: () => shouldConsiderConfigurationError, shouldConsiderConfigurationError: () => shouldConsiderConfigurationError,
shouldConsiderInvalidRequest: () => shouldConsiderInvalidRequest, shouldConsiderInvalidRequest: () => shouldConsiderInvalidRequest,
shouldShowCombineSarifFilesDeprecationWarning: () => shouldShowCombineSarifFilesDeprecationWarning, shouldShowCombineSarifFilesDeprecationWarning: () => shouldShowCombineSarifFilesDeprecationWarning,
@@ -103249,7 +103249,7 @@ __export(upload_lib_exports, {
writePostProcessedFiles: () => writePostProcessedFiles writePostProcessedFiles: () => writePostProcessedFiles
}); });
module.exports = __toCommonJS(upload_lib_exports); module.exports = __toCommonJS(upload_lib_exports);
var fs11 = __toESM(require("fs")); var fs12 = __toESM(require("fs"));
var path11 = __toESM(require("path")); var path11 = __toESM(require("path"));
var url = __toESM(require("url")); var url = __toESM(require("url"));
var import_zlib = __toESM(require("zlib")); var import_zlib = __toESM(require("zlib"));
@@ -103257,7 +103257,7 @@ var core11 = __toESM(require_core());
var jsonschema2 = __toESM(require_lib2()); var jsonschema2 = __toESM(require_lib2());
// src/actions-util.ts // src/actions-util.ts
var fs2 = __toESM(require("fs")); var fs3 = __toESM(require("fs"));
var path2 = __toESM(require("path")); var path2 = __toESM(require("path"));
var core4 = __toESM(require_core()); var core4 = __toESM(require_core());
var toolrunner = __toESM(require_toolrunner()); var toolrunner = __toESM(require_toolrunner());
@@ -103265,7 +103265,7 @@ var github = __toESM(require_github());
var io2 = __toESM(require_io()); var io2 = __toESM(require_io());
// src/util.ts // src/util.ts
var fs = __toESM(require("fs")); var fs2 = __toESM(require("fs"));
var path = __toESM(require("path")); var path = __toESM(require("path"));
var core3 = __toESM(require_core()); var core3 = __toESM(require_core());
var io = __toESM(require_io()); var io = __toESM(require_io());
@@ -103278,21 +103278,21 @@ async function getFolderSize(itemPath, options) {
getFolderSize.loose = async (itemPath, options) => await core(itemPath, options); getFolderSize.loose = async (itemPath, options) => await core(itemPath, options);
getFolderSize.strict = async (itemPath, options) => await core(itemPath, options, { strict: true }); getFolderSize.strict = async (itemPath, options) => await core(itemPath, options, { strict: true });
async function core(rootItemPath, options = {}, returnType = {}) { async function core(rootItemPath, options = {}, returnType = {}) {
const fs12 = options.fs || await import("node:fs/promises"); const fs13 = options.fs || await import("node:fs/promises");
let folderSize = 0n; let folderSize = 0n;
const foundInos = /* @__PURE__ */ new Set(); const foundInos = /* @__PURE__ */ new Set();
const errors = []; const errors = [];
await processItem(rootItemPath); await processItem(rootItemPath);
async function processItem(itemPath) { async function processItem(itemPath) {
if (options.ignore?.test(itemPath)) return; if (options.ignore?.test(itemPath)) return;
const stats = returnType.strict ? await fs12.lstat(itemPath, { bigint: true }) : await fs12.lstat(itemPath, { bigint: true }).catch((error3) => errors.push(error3)); const stats = returnType.strict ? await fs13.lstat(itemPath, { bigint: true }) : await fs13.lstat(itemPath, { bigint: true }).catch((error3) => errors.push(error3));
if (typeof stats !== "object") return; if (typeof stats !== "object") return;
if (!foundInos.has(stats.ino)) { if (!foundInos.has(stats.ino)) {
foundInos.add(stats.ino); foundInos.add(stats.ino);
folderSize += stats.size; folderSize += stats.size;
} }
if (stats.isDirectory()) { if (stats.isDirectory()) {
const directoryItems = returnType.strict ? await fs12.readdir(itemPath) : await fs12.readdir(itemPath).catch((error3) => errors.push(error3)); const directoryItems = returnType.strict ? await fs13.readdir(itemPath) : await fs13.readdir(itemPath).catch((error3) => errors.push(error3));
if (typeof directoryItems !== "object") return; if (typeof directoryItems !== "object") return;
await Promise.all( await Promise.all(
directoryItems.map( directoryItems.map(
@@ -105915,6 +105915,7 @@ var safeDump = renamed("safeDump", "dump");
var semver = __toESM(require_semver2()); var semver = __toESM(require_semver2());
// src/sarif/index.ts // src/sarif/index.ts
var fs = __toESM(require("fs"));
function getToolNames(sarif) { function getToolNames(sarif) {
const toolNames = {}; const toolNames = {};
for (const run of sarif.runs || []) { for (const run of sarif.runs || []) {
@@ -105926,6 +105927,9 @@ function getToolNames(sarif) {
} }
return Object.keys(toolNames); return Object.keys(toolNames);
} }
function readSarifFile(sarifFilePath) {
return JSON.parse(fs.readFileSync(sarifFilePath, "utf8"));
}
// src/util.ts // src/util.ts
var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json";
@@ -106089,7 +106093,7 @@ function cloneObject(obj) {
async function cleanUpPath(file, name, logger) { async function cleanUpPath(file, name, logger) {
logger.debug(`Cleaning up ${name}.`); logger.debug(`Cleaning up ${name}.`);
try { try {
await fs.promises.rm(file, { await fs2.promises.rm(file, {
force: true, force: true,
recursive: true recursive: true
}); });
@@ -106147,7 +106151,7 @@ function getRelativeScriptPath() {
function getWorkflowEvent() { function getWorkflowEvent() {
const eventJsonFile = getRequiredEnvParam("GITHUB_EVENT_PATH"); const eventJsonFile = getRequiredEnvParam("GITHUB_EVENT_PATH");
try { try {
return JSON.parse(fs2.readFileSync(eventJsonFile, "utf-8")); return JSON.parse(fs3.readFileSync(eventJsonFile, "utf-8"));
} catch (e) { } catch (e) {
throw new Error( throw new Error(
`Unable to read workflow event JSON from ${eventJsonFile}: ${e}` `Unable to read workflow event JSON from ${eventJsonFile}: ${e}`
@@ -106579,7 +106583,7 @@ function wrapApiConfigurationError(e) {
} }
// src/codeql.ts // src/codeql.ts
var fs9 = __toESM(require("fs")); var fs10 = __toESM(require("fs"));
var path9 = __toESM(require("path")); var path9 = __toESM(require("path"));
var core10 = __toESM(require_core()); var core10 = __toESM(require_core());
var toolrunner3 = __toESM(require_toolrunner()); var toolrunner3 = __toESM(require_toolrunner());
@@ -106827,7 +106831,7 @@ function wrapCliConfigurationError(cliError) {
} }
// src/config-utils.ts // src/config-utils.ts
var fs5 = __toESM(require("fs")); var fs6 = __toESM(require("fs"));
var path6 = __toESM(require("path")); var path6 = __toESM(require("path"));
// src/caching-utils.ts // src/caching-utils.ts
@@ -106942,7 +106946,7 @@ function writeDiagnostic(config, language, diagnostic) {
} }
// src/diff-informed-analysis-utils.ts // src/diff-informed-analysis-utils.ts
var fs4 = __toESM(require("fs")); var fs5 = __toESM(require("fs"));
var path5 = __toESM(require("path")); var path5 = __toESM(require("path"));
// src/feature-flags.ts // src/feature-flags.ts
@@ -106953,7 +106957,7 @@ var bundleVersion = "codeql-bundle-v2.24.2";
var cliVersion = "2.24.2"; var cliVersion = "2.24.2";
// src/overlay/index.ts // src/overlay/index.ts
var fs3 = __toESM(require("fs")); var fs4 = __toESM(require("fs"));
var path4 = __toESM(require("path")); var path4 = __toESM(require("path"));
var actionsCache = __toESM(require_cache5()); var actionsCache = __toESM(require_cache5());
@@ -107164,12 +107168,12 @@ async function writeBaseDatabaseOidsFile(config, sourceRoot) {
const gitFileOids = await getFileOidsUnderPath(sourceRoot); const gitFileOids = await getFileOidsUnderPath(sourceRoot);
const gitFileOidsJson = JSON.stringify(gitFileOids); const gitFileOidsJson = JSON.stringify(gitFileOids);
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config); const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
await fs3.promises.writeFile(baseDatabaseOidsFilePath, gitFileOidsJson); await fs4.promises.writeFile(baseDatabaseOidsFilePath, gitFileOidsJson);
} }
async function readBaseDatabaseOidsFile(config, logger) { async function readBaseDatabaseOidsFile(config, logger) {
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config); const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
try { try {
const contents = await fs3.promises.readFile( const contents = await fs4.promises.readFile(
baseDatabaseOidsFilePath, baseDatabaseOidsFilePath,
"utf-8" "utf-8"
); );
@@ -107196,7 +107200,7 @@ async function writeOverlayChangesFile(config, sourceRoot, logger) {
logger.debug( logger.debug(
`Writing overlay changed files to ${overlayChangesFile}: ${changedFilesJson}` `Writing overlay changed files to ${overlayChangesFile}: ${changedFilesJson}`
); );
await fs3.promises.writeFile(overlayChangesFile, changedFilesJson); await fs4.promises.writeFile(overlayChangesFile, changedFilesJson);
return overlayChangesFile; return overlayChangesFile;
} }
function computeChangedFiles(baseFileOids, overlayFileOids) { function computeChangedFiles(baseFileOids, overlayFileOids) {
@@ -107467,11 +107471,11 @@ function getDiffRangesJsonFilePath() {
} }
function readDiffRangesJsonFile(logger) { function readDiffRangesJsonFile(logger) {
const jsonFilePath = getDiffRangesJsonFilePath(); const jsonFilePath = getDiffRangesJsonFilePath();
if (!fs4.existsSync(jsonFilePath)) { if (!fs5.existsSync(jsonFilePath)) {
logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`); logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`);
return void 0; return void 0;
} }
const jsonContents = fs4.readFileSync(jsonFilePath, "utf8"); const jsonContents = fs5.readFileSync(jsonFilePath, "utf8");
logger.debug( logger.debug(
`Read pr-diff-range JSON file from ${jsonFilePath}: `Read pr-diff-range JSON file from ${jsonFilePath}:
${jsonContents}` ${jsonContents}`
@@ -107520,10 +107524,10 @@ function getPathToParsedConfigFile(tempDir) {
} }
async function getConfig(tempDir, logger) { async function getConfig(tempDir, logger) {
const configFile = getPathToParsedConfigFile(tempDir); const configFile = getPathToParsedConfigFile(tempDir);
if (!fs5.existsSync(configFile)) { if (!fs6.existsSync(configFile)) {
return void 0; return void 0;
} }
const configString = fs5.readFileSync(configFile, "utf8"); const configString = fs6.readFileSync(configFile, "utf8");
logger.debug("Loaded config:"); logger.debug("Loaded config:");
logger.debug(configString); logger.debug(configString);
const config = JSON.parse(configString); const config = JSON.parse(configString);
@@ -107559,7 +107563,7 @@ function appendExtraQueryExclusions(extraQueryExclusions, cliConfig) {
} }
// src/setup-codeql.ts // src/setup-codeql.ts
var fs8 = __toESM(require("fs")); var fs9 = __toESM(require("fs"));
var path8 = __toESM(require("path")); var path8 = __toESM(require("path"));
var toolcache3 = __toESM(require_tool_cache()); var toolcache3 = __toESM(require_tool_cache());
var import_fast_deep_equal = __toESM(require_fast_deep_equal()); var import_fast_deep_equal = __toESM(require_fast_deep_equal());
@@ -107621,7 +107625,7 @@ var v4_default = v4;
// src/tar.ts // src/tar.ts
var import_child_process = require("child_process"); var import_child_process = require("child_process");
var fs6 = __toESM(require("fs")); var fs7 = __toESM(require("fs"));
var stream = __toESM(require("stream")); var stream = __toESM(require("stream"));
var import_toolrunner = __toESM(require_toolrunner()); var import_toolrunner = __toESM(require_toolrunner());
var io4 = __toESM(require_io()); var io4 = __toESM(require_io());
@@ -107694,7 +107698,7 @@ async function isZstdAvailable(logger) {
} }
} }
async function extract(tarPath, dest, compressionMethod, tarVersion, logger) { async function extract(tarPath, dest, compressionMethod, tarVersion, logger) {
fs6.mkdirSync(dest, { recursive: true }); fs7.mkdirSync(dest, { recursive: true });
switch (compressionMethod) { switch (compressionMethod) {
case "gzip": case "gzip":
return await toolcache.extractTar(tarPath, dest); return await toolcache.extractTar(tarPath, dest);
@@ -107778,7 +107782,7 @@ function inferCompressionMethod(tarPath) {
} }
// src/tools-download.ts // src/tools-download.ts
var fs7 = __toESM(require("fs")); var fs8 = __toESM(require("fs"));
var os = __toESM(require("os")); var os = __toESM(require("os"));
var path7 = __toESM(require("path")); var path7 = __toESM(require("path"));
var import_perf_hooks = require("perf_hooks"); var import_perf_hooks = require("perf_hooks");
@@ -107885,7 +107889,7 @@ async function downloadAndExtract(codeqlURL, compressionMethod, dest, authorizat
}; };
} }
async function downloadAndExtractZstdWithStreaming(codeqlURL, dest, authorization, headers, tarVersion, logger) { async function downloadAndExtractZstdWithStreaming(codeqlURL, dest, authorization, headers, tarVersion, logger) {
fs7.mkdirSync(dest, { recursive: true }); fs8.mkdirSync(dest, { recursive: true });
const agent = new import_http_client.HttpClient().getAgent(codeqlURL); const agent = new import_http_client.HttpClient().getAgent(codeqlURL);
headers = Object.assign( headers = Object.assign(
{ "User-Agent": "CodeQL Action" }, { "User-Agent": "CodeQL Action" },
@@ -107922,7 +107926,7 @@ function getToolcacheDirectory(version) {
} }
function writeToolcacheMarkerFile(extractedPath, logger) { function writeToolcacheMarkerFile(extractedPath, logger) {
const markerFilePath = `${extractedPath}.complete`; const markerFilePath = `${extractedPath}.complete`;
fs7.writeFileSync(markerFilePath, ""); fs8.writeFileSync(markerFilePath, "");
logger.info(`Created toolcache marker file ${markerFilePath}`); logger.info(`Created toolcache marker file ${markerFilePath}`);
} }
function sanitizeUrlForStatusReport(url2) { function sanitizeUrlForStatusReport(url2) {
@@ -108057,7 +108061,7 @@ async function findOverridingToolsInCache(humanReadableVersion, logger) {
const candidates = toolcache3.findAllVersions("CodeQL").filter(isGoodVersion).map((version) => ({ const candidates = toolcache3.findAllVersions("CodeQL").filter(isGoodVersion).map((version) => ({
folder: toolcache3.find("CodeQL", version), folder: toolcache3.find("CodeQL", version),
version version
})).filter(({ folder }) => fs8.existsSync(path8.join(folder, "pinned-version"))); })).filter(({ folder }) => fs9.existsSync(path8.join(folder, "pinned-version")));
if (candidates.length === 1) { if (candidates.length === 1) {
const candidate = candidates[0]; const candidate = candidates[0];
logger.debug( logger.debug(
@@ -108611,7 +108615,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
"tools", "tools",
"tracing-config.lua" "tracing-config.lua"
); );
return fs9.existsSync(tracingConfigPath); return fs10.existsSync(tracingConfigPath);
}, },
async isScannedLanguage(language) { async isScannedLanguage(language) {
return !await this.isTracedLanguage(language); return !await this.isTracedLanguage(language);
@@ -109091,7 +109095,7 @@ async function writeCodeScanningConfigFile(config, logger) {
logger.startGroup("Augmented user configuration file contents"); logger.startGroup("Augmented user configuration file contents");
logger.info(dump(augmentedConfig)); logger.info(dump(augmentedConfig));
logger.endGroup(); logger.endGroup();
fs9.writeFileSync(codeScanningConfigFile, dump(augmentedConfig)); fs10.writeFileSync(codeScanningConfigFile, dump(augmentedConfig));
return codeScanningConfigFile; return codeScanningConfigFile;
} }
var TRAP_CACHE_SIZE_MB = 1024; var TRAP_CACHE_SIZE_MB = 1024;
@@ -109135,7 +109139,7 @@ async function getJobRunUuidSarifOptions(codeql) {
} }
// src/fingerprints.ts // src/fingerprints.ts
var fs10 = __toESM(require("fs")); var fs11 = __toESM(require("fs"));
var import_path2 = __toESM(require("path")); var import_path2 = __toESM(require("path"));
// node_modules/long/index.js // node_modules/long/index.js
@@ -110123,7 +110127,7 @@ async function hash(callback, filepath) {
} }
updateHash(current); updateHash(current);
}; };
const readStream = fs10.createReadStream(filepath, "utf8"); const readStream = fs11.createReadStream(filepath, "utf8");
for await (const data of readStream) { for await (const data of readStream) {
for (let i = 0; i < data.length; ++i) { for (let i = 0; i < data.length; ++i) {
processCharacter(data.charCodeAt(i)); processCharacter(data.charCodeAt(i));
@@ -110198,11 +110202,11 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
if (!import_path2.default.isAbsolute(uri)) { if (!import_path2.default.isAbsolute(uri)) {
uri = srcRootPrefix + uri; uri = srcRootPrefix + uri;
} }
if (!fs10.existsSync(uri)) { if (!fs11.existsSync(uri)) {
logger.debug(`Unable to compute fingerprint for non-existent file: ${uri}`); logger.debug(`Unable to compute fingerprint for non-existent file: ${uri}`);
return void 0; return void 0;
} }
if (fs10.statSync(uri).isDirectory()) { if (fs11.statSync(uri).isDirectory()) {
logger.debug(`Unable to compute fingerprint for directory: ${uri}`); logger.debug(`Unable to compute fingerprint for directory: ${uri}`);
return void 0; return void 0;
} }
@@ -110299,9 +110303,7 @@ function combineSarifFiles(sarifFiles, logger) {
}; };
for (const sarifFile of sarifFiles) { for (const sarifFile of sarifFiles) {
logger.debug(`Loading SARIF file: ${sarifFile}`); logger.debug(`Loading SARIF file: ${sarifFile}`);
const sarifObject = JSON.parse( const sarifObject = readSarifFile(sarifFile);
fs11.readFileSync(sarifFile, "utf8")
);
if (combinedSarif.version === null) { if (combinedSarif.version === null) {
combinedSarif.version = sarifObject.version; combinedSarif.version = sarifObject.version;
} else if (combinedSarif.version !== sarifObject.version) { } else if (combinedSarif.version !== sarifObject.version) {
@@ -110371,9 +110373,7 @@ async function shouldDisableCombineSarifFiles(sarifObjects, githubVersion) {
} }
async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, logger) { async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, logger) {
logger.info("Combining SARIF files using the CodeQL CLI"); logger.info("Combining SARIF files using the CodeQL CLI");
const sarifObjects = sarifFiles.map((sarifFile) => { const sarifObjects = sarifFiles.map(readSarifFile);
return JSON.parse(fs11.readFileSync(sarifFile, "utf8"));
});
const deprecationWarningMessage = gitHubVersion.type === "GitHub Enterprise Server" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025"; const deprecationWarningMessage = gitHubVersion.type === "GitHub Enterprise Server" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025";
const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload"; const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload";
if (!areAllRunsProducedByCodeQL(sarifObjects)) { if (!areAllRunsProducedByCodeQL(sarifObjects)) {
@@ -110426,13 +110426,13 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
codeQL = initCodeQLResult.codeql; codeQL = initCodeQLResult.codeql;
} }
const baseTempDir = path11.resolve(tempDir, "combined-sarif"); const baseTempDir = path11.resolve(tempDir, "combined-sarif");
fs11.mkdirSync(baseTempDir, { recursive: true }); fs12.mkdirSync(baseTempDir, { recursive: true });
const outputDirectory = fs11.mkdtempSync(path11.resolve(baseTempDir, "output-")); const outputDirectory = fs12.mkdtempSync(path11.resolve(baseTempDir, "output-"));
const outputFile = path11.resolve(outputDirectory, "combined-sarif.sarif"); const outputFile = path11.resolve(outputDirectory, "combined-sarif.sarif");
await codeQL.mergeResults(sarifFiles, outputFile, { await codeQL.mergeResults(sarifFiles, outputFile, {
mergeRunsFromEqualCategory: true mergeRunsFromEqualCategory: true
}); });
return JSON.parse(fs11.readFileSync(outputFile, "utf8")); return readSarifFile(outputFile);
} }
function populateRunAutomationDetails(sarif, category, analysis_key, environment) { function populateRunAutomationDetails(sarif, category, analysis_key, environment) {
const automationID = getAutomationID2(category, analysis_key, environment); const automationID = getAutomationID2(category, analysis_key, environment);
@@ -110469,7 +110469,7 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) {
`SARIF upload disabled by an environment variable. Saving to ${payloadSaveFile}` `SARIF upload disabled by an environment variable. Saving to ${payloadSaveFile}`
); );
logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`); logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`);
fs11.writeFileSync(payloadSaveFile, JSON.stringify(payload, null, 2)); fs12.writeFileSync(payloadSaveFile, JSON.stringify(payload, null, 2));
return "dummy-sarif-id"; return "dummy-sarif-id";
} }
const client = getApiClient(); const client = getApiClient();
@@ -110503,7 +110503,7 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) {
function findSarifFilesInDir(sarifPath, isSarif) { function findSarifFilesInDir(sarifPath, isSarif) {
const sarifFiles = []; const sarifFiles = [];
const walkSarifFiles = (dir) => { const walkSarifFiles = (dir) => {
const entries = fs11.readdirSync(dir, { withFileTypes: true }); const entries = fs12.readdirSync(dir, { withFileTypes: true });
for (const entry of entries) { for (const entry of entries) {
if (entry.isFile() && isSarif(entry.name)) { if (entry.isFile() && isSarif(entry.name)) {
sarifFiles.push(path11.resolve(dir, entry.name)); sarifFiles.push(path11.resolve(dir, entry.name));
@@ -110516,11 +110516,11 @@ function findSarifFilesInDir(sarifPath, isSarif) {
return sarifFiles; return sarifFiles;
} }
function getSarifFilePaths(sarifPath, isSarif) { function getSarifFilePaths(sarifPath, isSarif) {
if (!fs11.existsSync(sarifPath)) { if (!fs12.existsSync(sarifPath)) {
throw new ConfigurationError(`Path does not exist: ${sarifPath}`); throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
} }
let sarifFiles; let sarifFiles;
if (fs11.lstatSync(sarifPath).isDirectory()) { if (fs12.lstatSync(sarifPath).isDirectory()) {
sarifFiles = findSarifFilesInDir(sarifPath, isSarif); sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
if (sarifFiles.length === 0) { if (sarifFiles.length === 0) {
throw new ConfigurationError( throw new ConfigurationError(
@@ -110533,7 +110533,7 @@ function getSarifFilePaths(sarifPath, isSarif) {
return sarifFiles; return sarifFiles;
} }
async function getGroupedSarifFilePaths(logger, sarifPath) { async function getGroupedSarifFilePaths(logger, sarifPath) {
const stats = fs11.statSync(sarifPath, { throwIfNoEntry: false }); const stats = fs12.statSync(sarifPath, { throwIfNoEntry: false });
if (stats === void 0) { if (stats === void 0) {
throw new ConfigurationError(`Path does not exist: ${sarifPath}`); throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
} }
@@ -110596,9 +110596,9 @@ function countResultsInSarif(sarif) {
} }
return numResults; return numResults;
} }
function readSarifFile(sarifFilePath) { function readSarifFile2(sarifFilePath) {
try { try {
return JSON.parse(fs11.readFileSync(sarifFilePath, "utf8")); return readSarifFile(sarifFilePath);
} catch (e) { } catch (e) {
throw new InvalidSarifUploadError( throw new InvalidSarifUploadError(
`Invalid SARIF. JSON syntax error: ${getErrorMessage(e)}` `Invalid SARIF. JSON syntax error: ${getErrorMessage(e)}`
@@ -110667,7 +110667,7 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
payloadObj.base_sha = mergeBaseCommitOid; payloadObj.base_sha = mergeBaseCommitOid;
} else if (process.env.GITHUB_EVENT_PATH) { } else if (process.env.GITHUB_EVENT_PATH) {
const githubEvent = JSON.parse( const githubEvent = JSON.parse(
fs11.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8") fs12.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8")
); );
payloadObj.base_ref = `refs/heads/${githubEvent.pull_request.base.ref}`; payloadObj.base_ref = `refs/heads/${githubEvent.pull_request.base.ref}`;
payloadObj.base_sha = githubEvent.pull_request.base.sha; payloadObj.base_sha = githubEvent.pull_request.base.sha;
@@ -110682,7 +110682,7 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths,
category = analysis.fixCategory(logger, category); category = analysis.fixCategory(logger, category);
if (sarifPaths.length > 1) { if (sarifPaths.length > 1) {
for (const sarifPath of sarifPaths) { for (const sarifPath of sarifPaths) {
const parsedSarif = readSarifFile(sarifPath); const parsedSarif = readSarifFile2(sarifPath);
validateSarifFileSchema(parsedSarif, sarifPath, logger); validateSarifFileSchema(parsedSarif, sarifPath, logger);
} }
sarif = await combineSarifFilesUsingCLI( sarif = await combineSarifFilesUsingCLI(
@@ -110693,7 +110693,7 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths,
); );
} else { } else {
const sarifPath = sarifPaths[0]; const sarifPath = sarifPaths[0];
sarif = readSarifFile(sarifPath); sarif = readSarifFile2(sarifPath);
validateSarifFileSchema(sarif, sarifPath, logger); validateSarifFileSchema(sarif, sarifPath, logger);
await throwIfCombineSarifFilesDisabled([sarif], gitHubVersion); await throwIfCombineSarifFilesDisabled([sarif], gitHubVersion);
} }
@@ -110801,9 +110801,9 @@ async function uploadPostProcessedFiles(logger, checkoutPath, uploadTarget, post
}; };
} }
function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) { function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) {
if (!fs11.existsSync(outputDir)) { if (!fs12.existsSync(outputDir)) {
fs11.mkdirSync(outputDir, { recursive: true }); fs12.mkdirSync(outputDir, { recursive: true });
} else if (!fs11.lstatSync(outputDir).isDirectory()) { } else if (!fs12.lstatSync(outputDir).isDirectory()) {
throw new ConfigurationError( throw new ConfigurationError(
`The path that processed SARIF files should be written to exists, but is not a directory: ${outputDir}` `The path that processed SARIF files should be written to exists, but is not a directory: ${outputDir}`
); );
@@ -110813,7 +110813,7 @@ function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) {
`upload${uploadTarget.sarifExtension}` `upload${uploadTarget.sarifExtension}`
); );
logger.info(`Writing processed SARIF file to ${outputFile}`); logger.info(`Writing processed SARIF file to ${outputFile}`);
fs11.writeFileSync(outputFile, sarifPayload); fs12.writeFileSync(outputFile, sarifPayload);
} }
var STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1e3; var STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1e3;
var STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1e3; var STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1e3;

View File

@@ -204,7 +204,7 @@ var require_file_command = __commonJS({
exports2.issueFileCommand = issueFileCommand; exports2.issueFileCommand = issueFileCommand;
exports2.prepareKeyValueMessage = prepareKeyValueMessage; exports2.prepareKeyValueMessage = prepareKeyValueMessage;
var crypto2 = __importStar2(require("crypto")); var crypto2 = __importStar2(require("crypto"));
var fs13 = __importStar2(require("fs")); var fs14 = __importStar2(require("fs"));
var os3 = __importStar2(require("os")); var os3 = __importStar2(require("os"));
var utils_1 = require_utils(); var utils_1 = require_utils();
function issueFileCommand(command, message) { function issueFileCommand(command, message) {
@@ -212,10 +212,10 @@ var require_file_command = __commonJS({
if (!filePath) { if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`); throw new Error(`Unable to find environment variable for file command ${command}`);
} }
if (!fs13.existsSync(filePath)) { if (!fs14.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`); throw new Error(`Missing file at path: ${filePath}`);
} }
fs13.appendFileSync(filePath, `${(0, utils_1.toCommandValue)(message)}${os3.EOL}`, { fs14.appendFileSync(filePath, `${(0, utils_1.toCommandValue)(message)}${os3.EOL}`, {
encoding: "utf8" encoding: "utf8"
}); });
} }
@@ -20123,13 +20123,13 @@ var require_io_util = __commonJS({
exports2.isRooted = isRooted; exports2.isRooted = isRooted;
exports2.tryGetExecutablePath = tryGetExecutablePath; exports2.tryGetExecutablePath = tryGetExecutablePath;
exports2.getCmdPath = getCmdPath; exports2.getCmdPath = getCmdPath;
var fs13 = __importStar2(require("fs")); var fs14 = __importStar2(require("fs"));
var path13 = __importStar2(require("path")); var path13 = __importStar2(require("path"));
_a = fs13.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink; _a = fs14.promises, exports2.chmod = _a.chmod, exports2.copyFile = _a.copyFile, exports2.lstat = _a.lstat, exports2.mkdir = _a.mkdir, exports2.open = _a.open, exports2.readdir = _a.readdir, exports2.rename = _a.rename, exports2.rm = _a.rm, exports2.rmdir = _a.rmdir, exports2.stat = _a.stat, exports2.symlink = _a.symlink, exports2.unlink = _a.unlink;
exports2.IS_WINDOWS = process.platform === "win32"; exports2.IS_WINDOWS = process.platform === "win32";
function readlink(fsPath) { function readlink(fsPath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const result = yield fs13.promises.readlink(fsPath); const result = yield fs14.promises.readlink(fsPath);
if (exports2.IS_WINDOWS && !result.endsWith("\\")) { if (exports2.IS_WINDOWS && !result.endsWith("\\")) {
return `${result}\\`; return `${result}\\`;
} }
@@ -20137,7 +20137,7 @@ var require_io_util = __commonJS({
}); });
} }
exports2.UV_FS_O_EXLOCK = 268435456; exports2.UV_FS_O_EXLOCK = 268435456;
exports2.READONLY = fs13.constants.O_RDONLY; exports2.READONLY = fs14.constants.O_RDONLY;
function exists(fsPath) { function exists(fsPath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
try { try {
@@ -49106,7 +49106,7 @@ var require_internal_globber = __commonJS({
Object.defineProperty(exports2, "__esModule", { value: true }); Object.defineProperty(exports2, "__esModule", { value: true });
exports2.DefaultGlobber = void 0; exports2.DefaultGlobber = void 0;
var core14 = __importStar2(require_core()); var core14 = __importStar2(require_core());
var fs13 = __importStar2(require("fs")); var fs14 = __importStar2(require("fs"));
var globOptionsHelper = __importStar2(require_internal_glob_options_helper()); var globOptionsHelper = __importStar2(require_internal_glob_options_helper());
var path13 = __importStar2(require("path")); var path13 = __importStar2(require("path"));
var patternHelper = __importStar2(require_internal_pattern_helper()); var patternHelper = __importStar2(require_internal_pattern_helper());
@@ -49160,7 +49160,7 @@ var require_internal_globber = __commonJS({
for (const searchPath of patternHelper.getSearchPaths(patterns)) { for (const searchPath of patternHelper.getSearchPaths(patterns)) {
core14.debug(`Search path '${searchPath}'`); core14.debug(`Search path '${searchPath}'`);
try { try {
yield __await2(fs13.promises.lstat(searchPath)); yield __await2(fs14.promises.lstat(searchPath));
} catch (err) { } catch (err) {
if (err.code === "ENOENT") { if (err.code === "ENOENT") {
continue; continue;
@@ -49194,7 +49194,7 @@ var require_internal_globber = __commonJS({
continue; continue;
} }
const childLevel = item.level + 1; const childLevel = item.level + 1;
const childItems = (yield __await2(fs13.promises.readdir(item.path))).map((x) => new internal_search_state_1.SearchState(path13.join(item.path, x), childLevel)); const childItems = (yield __await2(fs14.promises.readdir(item.path))).map((x) => new internal_search_state_1.SearchState(path13.join(item.path, x), childLevel));
stack.push(...childItems.reverse()); stack.push(...childItems.reverse());
} else if (match & internal_match_kind_1.MatchKind.File) { } else if (match & internal_match_kind_1.MatchKind.File) {
yield yield __await2(item.path); yield yield __await2(item.path);
@@ -49229,7 +49229,7 @@ var require_internal_globber = __commonJS({
let stats; let stats;
if (options.followSymbolicLinks) { if (options.followSymbolicLinks) {
try { try {
stats = yield fs13.promises.stat(item.path); stats = yield fs14.promises.stat(item.path);
} catch (err) { } catch (err) {
if (err.code === "ENOENT") { if (err.code === "ENOENT") {
if (options.omitBrokenSymbolicLinks) { if (options.omitBrokenSymbolicLinks) {
@@ -49241,10 +49241,10 @@ var require_internal_globber = __commonJS({
throw err; throw err;
} }
} else { } else {
stats = yield fs13.promises.lstat(item.path); stats = yield fs14.promises.lstat(item.path);
} }
if (stats.isDirectory() && options.followSymbolicLinks) { if (stats.isDirectory() && options.followSymbolicLinks) {
const realPath = yield fs13.promises.realpath(item.path); const realPath = yield fs14.promises.realpath(item.path);
while (traversalChain.length >= item.level) { while (traversalChain.length >= item.level) {
traversalChain.pop(); traversalChain.pop();
} }
@@ -49353,7 +49353,7 @@ var require_internal_hash_files = __commonJS({
exports2.hashFiles = hashFiles; exports2.hashFiles = hashFiles;
var crypto2 = __importStar2(require("crypto")); var crypto2 = __importStar2(require("crypto"));
var core14 = __importStar2(require_core()); var core14 = __importStar2(require_core());
var fs13 = __importStar2(require("fs")); var fs14 = __importStar2(require("fs"));
var stream2 = __importStar2(require("stream")); var stream2 = __importStar2(require("stream"));
var util = __importStar2(require("util")); var util = __importStar2(require("util"));
var path13 = __importStar2(require("path")); var path13 = __importStar2(require("path"));
@@ -49376,13 +49376,13 @@ var require_internal_hash_files = __commonJS({
writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`); writeDelegate(`Ignore '${file}' since it is not under GITHUB_WORKSPACE.`);
continue; continue;
} }
if (fs13.statSync(file).isDirectory()) { if (fs14.statSync(file).isDirectory()) {
writeDelegate(`Skip directory '${file}'.`); writeDelegate(`Skip directory '${file}'.`);
continue; continue;
} }
const hash2 = crypto2.createHash("sha256"); const hash2 = crypto2.createHash("sha256");
const pipeline = util.promisify(stream2.pipeline); const pipeline = util.promisify(stream2.pipeline);
yield pipeline(fs13.createReadStream(file), hash2); yield pipeline(fs14.createReadStream(file), hash2);
result.write(hash2.digest()); result.write(hash2.digest());
count++; count++;
if (!hasMatch) { if (!hasMatch) {
@@ -50757,7 +50757,7 @@ var require_cacheUtils = __commonJS({
var glob = __importStar2(require_glob()); var glob = __importStar2(require_glob());
var io6 = __importStar2(require_io()); var io6 = __importStar2(require_io());
var crypto2 = __importStar2(require("crypto")); var crypto2 = __importStar2(require("crypto"));
var fs13 = __importStar2(require("fs")); var fs14 = __importStar2(require("fs"));
var path13 = __importStar2(require("path")); var path13 = __importStar2(require("path"));
var semver9 = __importStar2(require_semver3()); var semver9 = __importStar2(require_semver3());
var util = __importStar2(require("util")); var util = __importStar2(require("util"));
@@ -50786,7 +50786,7 @@ var require_cacheUtils = __commonJS({
}); });
} }
function getArchiveFileSizeInBytes(filePath) { function getArchiveFileSizeInBytes(filePath) {
return fs13.statSync(filePath).size; return fs14.statSync(filePath).size;
} }
function resolvePaths(patterns) { function resolvePaths(patterns) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
@@ -50824,7 +50824,7 @@ var require_cacheUtils = __commonJS({
} }
function unlinkFile(filePath) { function unlinkFile(filePath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
return util.promisify(fs13.unlink)(filePath); return util.promisify(fs14.unlink)(filePath);
}); });
} }
function getVersion(app_1) { function getVersion(app_1) {
@@ -50866,7 +50866,7 @@ var require_cacheUtils = __commonJS({
} }
function getGnuTarPathOnWindows() { function getGnuTarPathOnWindows() {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
if (fs13.existsSync(constants_1.GnuTarPathOnWindows)) { if (fs14.existsSync(constants_1.GnuTarPathOnWindows)) {
return constants_1.GnuTarPathOnWindows; return constants_1.GnuTarPathOnWindows;
} }
const versionOutput = yield getVersion("tar"); const versionOutput = yield getVersion("tar");
@@ -91023,7 +91023,7 @@ var require_downloadUtils = __commonJS({
var http_client_1 = require_lib(); var http_client_1 = require_lib();
var storage_blob_1 = require_commonjs15(); var storage_blob_1 = require_commonjs15();
var buffer = __importStar2(require("buffer")); var buffer = __importStar2(require("buffer"));
var fs13 = __importStar2(require("fs")); var fs14 = __importStar2(require("fs"));
var stream2 = __importStar2(require("stream")); var stream2 = __importStar2(require("stream"));
var util = __importStar2(require("util")); var util = __importStar2(require("util"));
var utils = __importStar2(require_cacheUtils()); var utils = __importStar2(require_cacheUtils());
@@ -91134,7 +91134,7 @@ var require_downloadUtils = __commonJS({
exports2.DownloadProgress = DownloadProgress; exports2.DownloadProgress = DownloadProgress;
function downloadCacheHttpClient(archiveLocation, archivePath) { function downloadCacheHttpClient(archiveLocation, archivePath) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const writeStream = fs13.createWriteStream(archivePath); const writeStream = fs14.createWriteStream(archivePath);
const httpClient = new http_client_1.HttpClient("actions/cache"); const httpClient = new http_client_1.HttpClient("actions/cache");
const downloadResponse = yield (0, requestUtils_1.retryHttpClientResponse)("downloadCache", () => __awaiter2(this, void 0, void 0, function* () { const downloadResponse = yield (0, requestUtils_1.retryHttpClientResponse)("downloadCache", () => __awaiter2(this, void 0, void 0, function* () {
return httpClient.get(archiveLocation); return httpClient.get(archiveLocation);
@@ -91159,7 +91159,7 @@ var require_downloadUtils = __commonJS({
function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options) { function downloadCacheHttpClientConcurrent(archiveLocation, archivePath, options) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
var _a; var _a;
const archiveDescriptor = yield fs13.promises.open(archivePath, "w"); const archiveDescriptor = yield fs14.promises.open(archivePath, "w");
const httpClient = new http_client_1.HttpClient("actions/cache", void 0, { const httpClient = new http_client_1.HttpClient("actions/cache", void 0, {
socketTimeout: options.timeoutInMs, socketTimeout: options.timeoutInMs,
keepAlive: true keepAlive: true
@@ -91275,7 +91275,7 @@ var require_downloadUtils = __commonJS({
} else { } else {
const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH); const maxSegmentSize = Math.min(134217728, buffer.constants.MAX_LENGTH);
const downloadProgress = new DownloadProgress(contentLength); const downloadProgress = new DownloadProgress(contentLength);
const fd = fs13.openSync(archivePath, "w"); const fd = fs14.openSync(archivePath, "w");
try { try {
downloadProgress.startDisplayTimer(); downloadProgress.startDisplayTimer();
const controller = new abort_controller_1.AbortController(); const controller = new abort_controller_1.AbortController();
@@ -91293,12 +91293,12 @@ var require_downloadUtils = __commonJS({
controller.abort(); controller.abort();
throw new Error("Aborting cache download as the download time exceeded the timeout."); throw new Error("Aborting cache download as the download time exceeded the timeout.");
} else if (Buffer.isBuffer(result)) { } else if (Buffer.isBuffer(result)) {
fs13.writeFileSync(fd, result); fs14.writeFileSync(fd, result);
} }
} }
} finally { } finally {
downloadProgress.stopDisplayTimer(); downloadProgress.stopDisplayTimer();
fs13.closeSync(fd); fs14.closeSync(fd);
} }
} }
}); });
@@ -91620,7 +91620,7 @@ var require_cacheHttpClient = __commonJS({
var core14 = __importStar2(require_core()); var core14 = __importStar2(require_core());
var http_client_1 = require_lib(); var http_client_1 = require_lib();
var auth_1 = require_auth(); var auth_1 = require_auth();
var fs13 = __importStar2(require("fs")); var fs14 = __importStar2(require("fs"));
var url_1 = require("url"); var url_1 = require("url");
var utils = __importStar2(require_cacheUtils()); var utils = __importStar2(require_cacheUtils());
var uploadUtils_1 = require_uploadUtils(); var uploadUtils_1 = require_uploadUtils();
@@ -91755,7 +91755,7 @@ Other caches with similar key:`);
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const fileSize = utils.getArchiveFileSizeInBytes(archivePath); const fileSize = utils.getArchiveFileSizeInBytes(archivePath);
const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`); const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
const fd = fs13.openSync(archivePath, "r"); const fd = fs14.openSync(archivePath, "r");
const uploadOptions = (0, options_1.getUploadOptions)(options); const uploadOptions = (0, options_1.getUploadOptions)(options);
const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency); const concurrency = utils.assertDefined("uploadConcurrency", uploadOptions.uploadConcurrency);
const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize); const maxChunkSize = utils.assertDefined("uploadChunkSize", uploadOptions.uploadChunkSize);
@@ -91769,7 +91769,7 @@ Other caches with similar key:`);
const start = offset; const start = offset;
const end = offset + chunkSize - 1; const end = offset + chunkSize - 1;
offset += maxChunkSize; offset += maxChunkSize;
yield uploadChunk(httpClient, resourceUrl, () => fs13.createReadStream(archivePath, { yield uploadChunk(httpClient, resourceUrl, () => fs14.createReadStream(archivePath, {
fd, fd,
start, start,
end, end,
@@ -91780,7 +91780,7 @@ Other caches with similar key:`);
} }
}))); })));
} finally { } finally {
fs13.closeSync(fd); fs14.closeSync(fd);
} }
return; return;
}); });
@@ -99033,7 +99033,7 @@ var require_manifest = __commonJS({
var core_1 = require_core(); var core_1 = require_core();
var os3 = require("os"); var os3 = require("os");
var cp = require("child_process"); var cp = require("child_process");
var fs13 = require("fs"); var fs14 = require("fs");
function _findMatch(versionSpec, stable, candidates, archFilter) { function _findMatch(versionSpec, stable, candidates, archFilter) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
const platFilter = os3.platform(); const platFilter = os3.platform();
@@ -99095,10 +99095,10 @@ var require_manifest = __commonJS({
const lsbReleaseFile = "/etc/lsb-release"; const lsbReleaseFile = "/etc/lsb-release";
const osReleaseFile = "/etc/os-release"; const osReleaseFile = "/etc/os-release";
let contents = ""; let contents = "";
if (fs13.existsSync(lsbReleaseFile)) { if (fs14.existsSync(lsbReleaseFile)) {
contents = fs13.readFileSync(lsbReleaseFile).toString(); contents = fs14.readFileSync(lsbReleaseFile).toString();
} else if (fs13.existsSync(osReleaseFile)) { } else if (fs14.existsSync(osReleaseFile)) {
contents = fs13.readFileSync(osReleaseFile).toString(); contents = fs14.readFileSync(osReleaseFile).toString();
} }
return contents; return contents;
} }
@@ -99307,7 +99307,7 @@ var require_tool_cache = __commonJS({
var core14 = __importStar2(require_core()); var core14 = __importStar2(require_core());
var io6 = __importStar2(require_io()); var io6 = __importStar2(require_io());
var crypto2 = __importStar2(require("crypto")); var crypto2 = __importStar2(require("crypto"));
var fs13 = __importStar2(require("fs")); var fs14 = __importStar2(require("fs"));
var mm = __importStar2(require_manifest()); var mm = __importStar2(require_manifest());
var os3 = __importStar2(require("os")); var os3 = __importStar2(require("os"));
var path13 = __importStar2(require("path")); var path13 = __importStar2(require("path"));
@@ -99353,7 +99353,7 @@ var require_tool_cache = __commonJS({
} }
function downloadToolAttempt(url2, dest, auth2, headers) { function downloadToolAttempt(url2, dest, auth2, headers) {
return __awaiter2(this, void 0, void 0, function* () { return __awaiter2(this, void 0, void 0, function* () {
if (fs13.existsSync(dest)) { if (fs14.existsSync(dest)) {
throw new Error(`Destination file path ${dest} already exists`); throw new Error(`Destination file path ${dest} already exists`);
} }
const http = new httpm.HttpClient(userAgent2, [], { const http = new httpm.HttpClient(userAgent2, [], {
@@ -99377,7 +99377,7 @@ var require_tool_cache = __commonJS({
const readStream = responseMessageFactory(); const readStream = responseMessageFactory();
let succeeded = false; let succeeded = false;
try { try {
yield pipeline(readStream, fs13.createWriteStream(dest)); yield pipeline(readStream, fs14.createWriteStream(dest));
core14.debug("download complete"); core14.debug("download complete");
succeeded = true; succeeded = true;
return dest; return dest;
@@ -99589,11 +99589,11 @@ var require_tool_cache = __commonJS({
arch2 = arch2 || os3.arch(); arch2 = arch2 || os3.arch();
core14.debug(`Caching tool ${tool} ${version} ${arch2}`); core14.debug(`Caching tool ${tool} ${version} ${arch2}`);
core14.debug(`source dir: ${sourceDir}`); core14.debug(`source dir: ${sourceDir}`);
if (!fs13.statSync(sourceDir).isDirectory()) { if (!fs14.statSync(sourceDir).isDirectory()) {
throw new Error("sourceDir is not a directory"); throw new Error("sourceDir is not a directory");
} }
const destPath = yield _createToolPath(tool, version, arch2); const destPath = yield _createToolPath(tool, version, arch2);
for (const itemName of fs13.readdirSync(sourceDir)) { for (const itemName of fs14.readdirSync(sourceDir)) {
const s = path13.join(sourceDir, itemName); const s = path13.join(sourceDir, itemName);
yield io6.cp(s, destPath, { recursive: true }); yield io6.cp(s, destPath, { recursive: true });
} }
@@ -99607,7 +99607,7 @@ var require_tool_cache = __commonJS({
arch2 = arch2 || os3.arch(); arch2 = arch2 || os3.arch();
core14.debug(`Caching tool ${tool} ${version} ${arch2}`); core14.debug(`Caching tool ${tool} ${version} ${arch2}`);
core14.debug(`source file: ${sourceFile}`); core14.debug(`source file: ${sourceFile}`);
if (!fs13.statSync(sourceFile).isFile()) { if (!fs14.statSync(sourceFile).isFile()) {
throw new Error("sourceFile is not a file"); throw new Error("sourceFile is not a file");
} }
const destFolder = yield _createToolPath(tool, version, arch2); const destFolder = yield _createToolPath(tool, version, arch2);
@@ -99636,7 +99636,7 @@ var require_tool_cache = __commonJS({
versionSpec = semver9.clean(versionSpec) || ""; versionSpec = semver9.clean(versionSpec) || "";
const cachePath = path13.join(_getCacheDirectory(), toolName, versionSpec, arch2); const cachePath = path13.join(_getCacheDirectory(), toolName, versionSpec, arch2);
core14.debug(`checking cache: ${cachePath}`); core14.debug(`checking cache: ${cachePath}`);
if (fs13.existsSync(cachePath) && fs13.existsSync(`${cachePath}.complete`)) { if (fs14.existsSync(cachePath) && fs14.existsSync(`${cachePath}.complete`)) {
core14.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`); core14.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch2}`);
toolPath = cachePath; toolPath = cachePath;
} else { } else {
@@ -99649,12 +99649,12 @@ var require_tool_cache = __commonJS({
const versions = []; const versions = [];
arch2 = arch2 || os3.arch(); arch2 = arch2 || os3.arch();
const toolPath = path13.join(_getCacheDirectory(), toolName); const toolPath = path13.join(_getCacheDirectory(), toolName);
if (fs13.existsSync(toolPath)) { if (fs14.existsSync(toolPath)) {
const children = fs13.readdirSync(toolPath); const children = fs14.readdirSync(toolPath);
for (const child of children) { for (const child of children) {
if (isExplicitVersion(child)) { if (isExplicitVersion(child)) {
const fullPath = path13.join(toolPath, child, arch2 || ""); const fullPath = path13.join(toolPath, child, arch2 || "");
if (fs13.existsSync(fullPath) && fs13.existsSync(`${fullPath}.complete`)) { if (fs14.existsSync(fullPath) && fs14.existsSync(`${fullPath}.complete`)) {
versions.push(child); versions.push(child);
} }
} }
@@ -99725,7 +99725,7 @@ var require_tool_cache = __commonJS({
function _completeToolPath(tool, version, arch2) { function _completeToolPath(tool, version, arch2) {
const folderPath = path13.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || ""); const folderPath = path13.join(_getCacheDirectory(), tool, semver9.clean(version) || version, arch2 || "");
const markerPath = `${folderPath}.complete`; const markerPath = `${folderPath}.complete`;
fs13.writeFileSync(markerPath, ""); fs14.writeFileSync(markerPath, "");
core14.debug("finished caching tool"); core14.debug("finished caching tool");
} }
function isExplicitVersion(versionSpec) { function isExplicitVersion(versionSpec) {
@@ -103230,7 +103230,7 @@ var require_sarif_schema_2_1_0 = __commonJS({
var core13 = __toESM(require_core()); var core13 = __toESM(require_core());
// src/actions-util.ts // src/actions-util.ts
var fs2 = __toESM(require("fs")); var fs3 = __toESM(require("fs"));
var path2 = __toESM(require("path")); var path2 = __toESM(require("path"));
var core4 = __toESM(require_core()); var core4 = __toESM(require_core());
var toolrunner = __toESM(require_toolrunner()); var toolrunner = __toESM(require_toolrunner());
@@ -103238,7 +103238,7 @@ var github = __toESM(require_github());
var io2 = __toESM(require_io()); var io2 = __toESM(require_io());
// src/util.ts // src/util.ts
var fs = __toESM(require("fs")); var fs2 = __toESM(require("fs"));
var fsPromises = __toESM(require("fs/promises")); var fsPromises = __toESM(require("fs/promises"));
var path = __toESM(require("path")); var path = __toESM(require("path"));
var core3 = __toESM(require_core()); var core3 = __toESM(require_core());
@@ -103252,21 +103252,21 @@ async function getFolderSize(itemPath, options) {
getFolderSize.loose = async (itemPath, options) => await core(itemPath, options); getFolderSize.loose = async (itemPath, options) => await core(itemPath, options);
getFolderSize.strict = async (itemPath, options) => await core(itemPath, options, { strict: true }); getFolderSize.strict = async (itemPath, options) => await core(itemPath, options, { strict: true });
async function core(rootItemPath, options = {}, returnType = {}) { async function core(rootItemPath, options = {}, returnType = {}) {
const fs13 = options.fs || await import("node:fs/promises"); const fs14 = options.fs || await import("node:fs/promises");
let folderSize = 0n; let folderSize = 0n;
const foundInos = /* @__PURE__ */ new Set(); const foundInos = /* @__PURE__ */ new Set();
const errors = []; const errors = [];
await processItem(rootItemPath); await processItem(rootItemPath);
async function processItem(itemPath) { async function processItem(itemPath) {
if (options.ignore?.test(itemPath)) return; if (options.ignore?.test(itemPath)) return;
const stats = returnType.strict ? await fs13.lstat(itemPath, { bigint: true }) : await fs13.lstat(itemPath, { bigint: true }).catch((error3) => errors.push(error3)); const stats = returnType.strict ? await fs14.lstat(itemPath, { bigint: true }) : await fs14.lstat(itemPath, { bigint: true }).catch((error3) => errors.push(error3));
if (typeof stats !== "object") return; if (typeof stats !== "object") return;
if (!foundInos.has(stats.ino)) { if (!foundInos.has(stats.ino)) {
foundInos.add(stats.ino); foundInos.add(stats.ino);
folderSize += stats.size; folderSize += stats.size;
} }
if (stats.isDirectory()) { if (stats.isDirectory()) {
const directoryItems = returnType.strict ? await fs13.readdir(itemPath) : await fs13.readdir(itemPath).catch((error3) => errors.push(error3)); const directoryItems = returnType.strict ? await fs14.readdir(itemPath) : await fs14.readdir(itemPath).catch((error3) => errors.push(error3));
if (typeof directoryItems !== "object") return; if (typeof directoryItems !== "object") return;
await Promise.all( await Promise.all(
directoryItems.map( directoryItems.map(
@@ -105889,6 +105889,7 @@ var safeDump = renamed("safeDump", "dump");
var semver = __toESM(require_semver2()); var semver = __toESM(require_semver2());
// src/sarif/index.ts // src/sarif/index.ts
var fs = __toESM(require("fs"));
function getToolNames(sarif) { function getToolNames(sarif) {
const toolNames = {}; const toolNames = {};
for (const run2 of sarif.runs || []) { for (const run2 of sarif.runs || []) {
@@ -105900,6 +105901,9 @@ function getToolNames(sarif) {
} }
return Object.keys(toolNames); return Object.keys(toolNames);
} }
function readSarifFile(sarifFilePath) {
return JSON.parse(fs.readFileSync(sarifFilePath, "utf8"));
}
// src/util.ts // src/util.ts
var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json"; var BASE_DATABASE_OIDS_FILE_NAME = "base-database-oids.json";
@@ -106112,7 +106116,7 @@ function cloneObject(obj) {
async function cleanUpPath(file, name, logger) { async function cleanUpPath(file, name, logger) {
logger.debug(`Cleaning up ${name}.`); logger.debug(`Cleaning up ${name}.`);
try { try {
await fs.promises.rm(file, { await fs2.promises.rm(file, {
force: true, force: true,
recursive: true recursive: true
}); });
@@ -106175,7 +106179,7 @@ function getRelativeScriptPath() {
function getWorkflowEvent() { function getWorkflowEvent() {
const eventJsonFile = getRequiredEnvParam("GITHUB_EVENT_PATH"); const eventJsonFile = getRequiredEnvParam("GITHUB_EVENT_PATH");
try { try {
return JSON.parse(fs2.readFileSync(eventJsonFile, "utf-8")); return JSON.parse(fs3.readFileSync(eventJsonFile, "utf-8"));
} catch (e) { } catch (e) {
throw new Error( throw new Error(
`Unable to read workflow event JSON from ${eventJsonFile}: ${e}` `Unable to read workflow event JSON from ${eventJsonFile}: ${e}`
@@ -106627,7 +106631,7 @@ function wrapApiConfigurationError(e) {
} }
// src/feature-flags.ts // src/feature-flags.ts
var fs4 = __toESM(require("fs")); var fs5 = __toESM(require("fs"));
var path4 = __toESM(require("path")); var path4 = __toESM(require("path"));
var semver4 = __toESM(require_semver2()); var semver4 = __toESM(require_semver2());
@@ -106636,7 +106640,7 @@ var bundleVersion = "codeql-bundle-v2.24.2";
var cliVersion = "2.24.2"; var cliVersion = "2.24.2";
// src/overlay/index.ts // src/overlay/index.ts
var fs3 = __toESM(require("fs")); var fs4 = __toESM(require("fs"));
var path3 = __toESM(require("path")); var path3 = __toESM(require("path"));
var actionsCache = __toESM(require_cache5()); var actionsCache = __toESM(require_cache5());
@@ -106875,12 +106879,12 @@ async function writeBaseDatabaseOidsFile(config, sourceRoot) {
const gitFileOids = await getFileOidsUnderPath(sourceRoot); const gitFileOids = await getFileOidsUnderPath(sourceRoot);
const gitFileOidsJson = JSON.stringify(gitFileOids); const gitFileOidsJson = JSON.stringify(gitFileOids);
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config); const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
await fs3.promises.writeFile(baseDatabaseOidsFilePath, gitFileOidsJson); await fs4.promises.writeFile(baseDatabaseOidsFilePath, gitFileOidsJson);
} }
async function readBaseDatabaseOidsFile(config, logger) { async function readBaseDatabaseOidsFile(config, logger) {
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config); const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
try { try {
const contents = await fs3.promises.readFile( const contents = await fs4.promises.readFile(
baseDatabaseOidsFilePath, baseDatabaseOidsFilePath,
"utf-8" "utf-8"
); );
@@ -106907,7 +106911,7 @@ async function writeOverlayChangesFile(config, sourceRoot, logger) {
logger.debug( logger.debug(
`Writing overlay changed files to ${overlayChangesFile}: ${changedFilesJson}` `Writing overlay changed files to ${overlayChangesFile}: ${changedFilesJson}`
); );
await fs3.promises.writeFile(overlayChangesFile, changedFilesJson); await fs4.promises.writeFile(overlayChangesFile, changedFilesJson);
return overlayChangesFile; return overlayChangesFile;
} }
function computeChangedFiles(baseFileOids, overlayFileOids) { function computeChangedFiles(baseFileOids, overlayFileOids) {
@@ -107409,12 +107413,12 @@ var GitHubFeatureFlags = class {
} }
async readLocalFlags() { async readLocalFlags() {
try { try {
if (fs4.existsSync(this.featureFlagsFile)) { if (fs5.existsSync(this.featureFlagsFile)) {
this.logger.debug( this.logger.debug(
`Loading feature flags from ${this.featureFlagsFile}` `Loading feature flags from ${this.featureFlagsFile}`
); );
return JSON.parse( return JSON.parse(
fs4.readFileSync(this.featureFlagsFile, "utf8") fs5.readFileSync(this.featureFlagsFile, "utf8")
); );
} }
} catch (e) { } catch (e) {
@@ -107427,7 +107431,7 @@ var GitHubFeatureFlags = class {
async writeLocalFlags(flags) { async writeLocalFlags(flags) {
try { try {
this.logger.debug(`Writing feature flags to ${this.featureFlagsFile}`); this.logger.debug(`Writing feature flags to ${this.featureFlagsFile}`);
fs4.writeFileSync(this.featureFlagsFile, JSON.stringify(flags)); fs5.writeFileSync(this.featureFlagsFile, JSON.stringify(flags));
} catch (e) { } catch (e) {
this.logger.warning( this.logger.warning(
`Error writing cached feature flags file ${this.featureFlagsFile}: ${e}.` `Error writing cached feature flags file ${this.featureFlagsFile}: ${e}.`
@@ -107502,7 +107506,7 @@ var os = __toESM(require("os"));
var core9 = __toESM(require_core()); var core9 = __toESM(require_core());
// src/config-utils.ts // src/config-utils.ts
var fs6 = __toESM(require("fs")); var fs7 = __toESM(require("fs"));
var path7 = __toESM(require("path")); var path7 = __toESM(require("path"));
// src/config/db-config.ts // src/config/db-config.ts
@@ -107587,18 +107591,18 @@ function writeDiagnostic(config, language, diagnostic) {
} }
// src/diff-informed-analysis-utils.ts // src/diff-informed-analysis-utils.ts
var fs5 = __toESM(require("fs")); var fs6 = __toESM(require("fs"));
var path6 = __toESM(require("path")); var path6 = __toESM(require("path"));
function getDiffRangesJsonFilePath() { function getDiffRangesJsonFilePath() {
return path6.join(getTemporaryDirectory(), "pr-diff-range.json"); return path6.join(getTemporaryDirectory(), "pr-diff-range.json");
} }
function readDiffRangesJsonFile(logger) { function readDiffRangesJsonFile(logger) {
const jsonFilePath = getDiffRangesJsonFilePath(); const jsonFilePath = getDiffRangesJsonFilePath();
if (!fs5.existsSync(jsonFilePath)) { if (!fs6.existsSync(jsonFilePath)) {
logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`); logger.debug(`Diff ranges JSON file does not exist at ${jsonFilePath}`);
return void 0; return void 0;
} }
const jsonContents = fs5.readFileSync(jsonFilePath, "utf8"); const jsonContents = fs6.readFileSync(jsonFilePath, "utf8");
logger.debug( logger.debug(
`Read pr-diff-range JSON file from ${jsonFilePath}: `Read pr-diff-range JSON file from ${jsonFilePath}:
${jsonContents}` ${jsonContents}`
@@ -107647,10 +107651,10 @@ function getPathToParsedConfigFile(tempDir) {
} }
async function getConfig(tempDir, logger) { async function getConfig(tempDir, logger) {
const configFile = getPathToParsedConfigFile(tempDir); const configFile = getPathToParsedConfigFile(tempDir);
if (!fs6.existsSync(configFile)) { if (!fs7.existsSync(configFile)) {
return void 0; return void 0;
} }
const configString = fs6.readFileSync(configFile, "utf8"); const configString = fs7.readFileSync(configFile, "utf8");
logger.debug("Loaded config:"); logger.debug("Loaded config:");
logger.debug(configString); logger.debug(configString);
const config = JSON.parse(configString); const config = JSON.parse(configString);
@@ -107894,7 +107898,7 @@ async function sendUnhandledErrorStatusReport(actionName, actionStartedAt, error
} }
// src/upload-lib.ts // src/upload-lib.ts
var fs12 = __toESM(require("fs")); var fs13 = __toESM(require("fs"));
var path12 = __toESM(require("path")); var path12 = __toESM(require("path"));
var url = __toESM(require("url")); var url = __toESM(require("url"));
var import_zlib = __toESM(require("zlib")); var import_zlib = __toESM(require("zlib"));
@@ -107902,7 +107906,7 @@ var core12 = __toESM(require_core());
var jsonschema2 = __toESM(require_lib2()); var jsonschema2 = __toESM(require_lib2());
// src/codeql.ts // src/codeql.ts
var fs10 = __toESM(require("fs")); var fs11 = __toESM(require("fs"));
var path10 = __toESM(require("path")); var path10 = __toESM(require("path"));
var core11 = __toESM(require_core()); var core11 = __toESM(require_core());
var toolrunner3 = __toESM(require_toolrunner()); var toolrunner3 = __toESM(require_toolrunner());
@@ -108150,7 +108154,7 @@ function wrapCliConfigurationError(cliError) {
} }
// src/setup-codeql.ts // src/setup-codeql.ts
var fs9 = __toESM(require("fs")); var fs10 = __toESM(require("fs"));
var path9 = __toESM(require("path")); var path9 = __toESM(require("path"));
var toolcache3 = __toESM(require_tool_cache()); var toolcache3 = __toESM(require_tool_cache());
var import_fast_deep_equal = __toESM(require_fast_deep_equal()); var import_fast_deep_equal = __toESM(require_fast_deep_equal());
@@ -108212,7 +108216,7 @@ var v4_default = v4;
// src/tar.ts // src/tar.ts
var import_child_process = require("child_process"); var import_child_process = require("child_process");
var fs7 = __toESM(require("fs")); var fs8 = __toESM(require("fs"));
var stream = __toESM(require("stream")); var stream = __toESM(require("stream"));
var import_toolrunner = __toESM(require_toolrunner()); var import_toolrunner = __toESM(require_toolrunner());
var io4 = __toESM(require_io()); var io4 = __toESM(require_io());
@@ -108285,7 +108289,7 @@ async function isZstdAvailable(logger) {
} }
} }
async function extract(tarPath, dest, compressionMethod, tarVersion, logger) { async function extract(tarPath, dest, compressionMethod, tarVersion, logger) {
fs7.mkdirSync(dest, { recursive: true }); fs8.mkdirSync(dest, { recursive: true });
switch (compressionMethod) { switch (compressionMethod) {
case "gzip": case "gzip":
return await toolcache.extractTar(tarPath, dest); return await toolcache.extractTar(tarPath, dest);
@@ -108369,7 +108373,7 @@ function inferCompressionMethod(tarPath) {
} }
// src/tools-download.ts // src/tools-download.ts
var fs8 = __toESM(require("fs")); var fs9 = __toESM(require("fs"));
var os2 = __toESM(require("os")); var os2 = __toESM(require("os"));
var path8 = __toESM(require("path")); var path8 = __toESM(require("path"));
var import_perf_hooks = require("perf_hooks"); var import_perf_hooks = require("perf_hooks");
@@ -108476,7 +108480,7 @@ async function downloadAndExtract(codeqlURL, compressionMethod, dest, authorizat
}; };
} }
async function downloadAndExtractZstdWithStreaming(codeqlURL, dest, authorization, headers, tarVersion, logger) { async function downloadAndExtractZstdWithStreaming(codeqlURL, dest, authorization, headers, tarVersion, logger) {
fs8.mkdirSync(dest, { recursive: true }); fs9.mkdirSync(dest, { recursive: true });
const agent = new import_http_client.HttpClient().getAgent(codeqlURL); const agent = new import_http_client.HttpClient().getAgent(codeqlURL);
headers = Object.assign( headers = Object.assign(
{ "User-Agent": "CodeQL Action" }, { "User-Agent": "CodeQL Action" },
@@ -108513,7 +108517,7 @@ function getToolcacheDirectory(version) {
} }
function writeToolcacheMarkerFile(extractedPath, logger) { function writeToolcacheMarkerFile(extractedPath, logger) {
const markerFilePath = `${extractedPath}.complete`; const markerFilePath = `${extractedPath}.complete`;
fs8.writeFileSync(markerFilePath, ""); fs9.writeFileSync(markerFilePath, "");
logger.info(`Created toolcache marker file ${markerFilePath}`); logger.info(`Created toolcache marker file ${markerFilePath}`);
} }
function sanitizeUrlForStatusReport(url2) { function sanitizeUrlForStatusReport(url2) {
@@ -108648,7 +108652,7 @@ async function findOverridingToolsInCache(humanReadableVersion, logger) {
const candidates = toolcache3.findAllVersions("CodeQL").filter(isGoodVersion).map((version) => ({ const candidates = toolcache3.findAllVersions("CodeQL").filter(isGoodVersion).map((version) => ({
folder: toolcache3.find("CodeQL", version), folder: toolcache3.find("CodeQL", version),
version version
})).filter(({ folder }) => fs9.existsSync(path9.join(folder, "pinned-version"))); })).filter(({ folder }) => fs10.existsSync(path9.join(folder, "pinned-version")));
if (candidates.length === 1) { if (candidates.length === 1) {
const candidate = candidates[0]; const candidate = candidates[0];
logger.debug( logger.debug(
@@ -109202,7 +109206,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
"tools", "tools",
"tracing-config.lua" "tracing-config.lua"
); );
return fs10.existsSync(tracingConfigPath); return fs11.existsSync(tracingConfigPath);
}, },
async isScannedLanguage(language) { async isScannedLanguage(language) {
return !await this.isTracedLanguage(language); return !await this.isTracedLanguage(language);
@@ -109682,7 +109686,7 @@ async function writeCodeScanningConfigFile(config, logger) {
logger.startGroup("Augmented user configuration file contents"); logger.startGroup("Augmented user configuration file contents");
logger.info(dump(augmentedConfig)); logger.info(dump(augmentedConfig));
logger.endGroup(); logger.endGroup();
fs10.writeFileSync(codeScanningConfigFile, dump(augmentedConfig)); fs11.writeFileSync(codeScanningConfigFile, dump(augmentedConfig));
return codeScanningConfigFile; return codeScanningConfigFile;
} }
var TRAP_CACHE_SIZE_MB = 1024; var TRAP_CACHE_SIZE_MB = 1024;
@@ -109726,7 +109730,7 @@ async function getJobRunUuidSarifOptions(codeql) {
} }
// src/fingerprints.ts // src/fingerprints.ts
var fs11 = __toESM(require("fs")); var fs12 = __toESM(require("fs"));
var import_path2 = __toESM(require("path")); var import_path2 = __toESM(require("path"));
// node_modules/long/index.js // node_modules/long/index.js
@@ -110714,7 +110718,7 @@ async function hash(callback, filepath) {
} }
updateHash(current); updateHash(current);
}; };
const readStream = fs11.createReadStream(filepath, "utf8"); const readStream = fs12.createReadStream(filepath, "utf8");
for await (const data of readStream) { for await (const data of readStream) {
for (let i = 0; i < data.length; ++i) { for (let i = 0; i < data.length; ++i) {
processCharacter(data.charCodeAt(i)); processCharacter(data.charCodeAt(i));
@@ -110789,11 +110793,11 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
if (!import_path2.default.isAbsolute(uri)) { if (!import_path2.default.isAbsolute(uri)) {
uri = srcRootPrefix + uri; uri = srcRootPrefix + uri;
} }
if (!fs11.existsSync(uri)) { if (!fs12.existsSync(uri)) {
logger.debug(`Unable to compute fingerprint for non-existent file: ${uri}`); logger.debug(`Unable to compute fingerprint for non-existent file: ${uri}`);
return void 0; return void 0;
} }
if (fs11.statSync(uri).isDirectory()) { if (fs12.statSync(uri).isDirectory()) {
logger.debug(`Unable to compute fingerprint for directory: ${uri}`); logger.debug(`Unable to compute fingerprint for directory: ${uri}`);
return void 0; return void 0;
} }
@@ -110890,9 +110894,7 @@ function combineSarifFiles(sarifFiles, logger) {
}; };
for (const sarifFile of sarifFiles) { for (const sarifFile of sarifFiles) {
logger.debug(`Loading SARIF file: ${sarifFile}`); logger.debug(`Loading SARIF file: ${sarifFile}`);
const sarifObject = JSON.parse( const sarifObject = readSarifFile(sarifFile);
fs12.readFileSync(sarifFile, "utf8")
);
if (combinedSarif.version === null) { if (combinedSarif.version === null) {
combinedSarif.version = sarifObject.version; combinedSarif.version = sarifObject.version;
} else if (combinedSarif.version !== sarifObject.version) { } else if (combinedSarif.version !== sarifObject.version) {
@@ -110962,9 +110964,7 @@ async function shouldDisableCombineSarifFiles(sarifObjects, githubVersion) {
} }
async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, logger) { async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, logger) {
logger.info("Combining SARIF files using the CodeQL CLI"); logger.info("Combining SARIF files using the CodeQL CLI");
const sarifObjects = sarifFiles.map((sarifFile) => { const sarifObjects = sarifFiles.map(readSarifFile);
return JSON.parse(fs12.readFileSync(sarifFile, "utf8"));
});
const deprecationWarningMessage = gitHubVersion.type === "GitHub Enterprise Server" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025"; const deprecationWarningMessage = gitHubVersion.type === "GitHub Enterprise Server" /* GHES */ ? "and will be removed in GitHub Enterprise Server 3.18" : "and will be removed in July 2025";
const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload"; const deprecationMoreInformationMessage = "For more information, see https://github.blog/changelog/2024-05-06-code-scanning-will-stop-combining-runs-from-a-single-upload";
if (!areAllRunsProducedByCodeQL(sarifObjects)) { if (!areAllRunsProducedByCodeQL(sarifObjects)) {
@@ -111017,13 +111017,13 @@ async function combineSarifFilesUsingCLI(sarifFiles, gitHubVersion, features, lo
codeQL = initCodeQLResult.codeql; codeQL = initCodeQLResult.codeql;
} }
const baseTempDir = path12.resolve(tempDir, "combined-sarif"); const baseTempDir = path12.resolve(tempDir, "combined-sarif");
fs12.mkdirSync(baseTempDir, { recursive: true }); fs13.mkdirSync(baseTempDir, { recursive: true });
const outputDirectory = fs12.mkdtempSync(path12.resolve(baseTempDir, "output-")); const outputDirectory = fs13.mkdtempSync(path12.resolve(baseTempDir, "output-"));
const outputFile = path12.resolve(outputDirectory, "combined-sarif.sarif"); const outputFile = path12.resolve(outputDirectory, "combined-sarif.sarif");
await codeQL.mergeResults(sarifFiles, outputFile, { await codeQL.mergeResults(sarifFiles, outputFile, {
mergeRunsFromEqualCategory: true mergeRunsFromEqualCategory: true
}); });
return JSON.parse(fs12.readFileSync(outputFile, "utf8")); return readSarifFile(outputFile);
} }
function populateRunAutomationDetails(sarif, category, analysis_key, environment) { function populateRunAutomationDetails(sarif, category, analysis_key, environment) {
const automationID = getAutomationID2(category, analysis_key, environment); const automationID = getAutomationID2(category, analysis_key, environment);
@@ -111060,7 +111060,7 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) {
`SARIF upload disabled by an environment variable. Saving to ${payloadSaveFile}` `SARIF upload disabled by an environment variable. Saving to ${payloadSaveFile}`
); );
logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`); logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`);
fs12.writeFileSync(payloadSaveFile, JSON.stringify(payload, null, 2)); fs13.writeFileSync(payloadSaveFile, JSON.stringify(payload, null, 2));
return "dummy-sarif-id"; return "dummy-sarif-id";
} }
const client = getApiClient(); const client = getApiClient();
@@ -111094,7 +111094,7 @@ async function uploadPayload(payload, repositoryNwo, logger, analysis) {
function findSarifFilesInDir(sarifPath, isSarif) { function findSarifFilesInDir(sarifPath, isSarif) {
const sarifFiles = []; const sarifFiles = [];
const walkSarifFiles = (dir) => { const walkSarifFiles = (dir) => {
const entries = fs12.readdirSync(dir, { withFileTypes: true }); const entries = fs13.readdirSync(dir, { withFileTypes: true });
for (const entry of entries) { for (const entry of entries) {
if (entry.isFile() && isSarif(entry.name)) { if (entry.isFile() && isSarif(entry.name)) {
sarifFiles.push(path12.resolve(dir, entry.name)); sarifFiles.push(path12.resolve(dir, entry.name));
@@ -111107,7 +111107,7 @@ function findSarifFilesInDir(sarifPath, isSarif) {
return sarifFiles; return sarifFiles;
} }
async function getGroupedSarifFilePaths(logger, sarifPath) { async function getGroupedSarifFilePaths(logger, sarifPath) {
const stats = fs12.statSync(sarifPath, { throwIfNoEntry: false }); const stats = fs13.statSync(sarifPath, { throwIfNoEntry: false });
if (stats === void 0) { if (stats === void 0) {
throw new ConfigurationError(`Path does not exist: ${sarifPath}`); throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
} }
@@ -111170,9 +111170,9 @@ function countResultsInSarif(sarif) {
} }
return numResults; return numResults;
} }
function readSarifFile(sarifFilePath) { function readSarifFile2(sarifFilePath) {
try { try {
return JSON.parse(fs12.readFileSync(sarifFilePath, "utf8")); return readSarifFile(sarifFilePath);
} catch (e) { } catch (e) {
throw new InvalidSarifUploadError( throw new InvalidSarifUploadError(
`Invalid SARIF. JSON syntax error: ${getErrorMessage(e)}` `Invalid SARIF. JSON syntax error: ${getErrorMessage(e)}`
@@ -111241,7 +111241,7 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
payloadObj.base_sha = mergeBaseCommitOid; payloadObj.base_sha = mergeBaseCommitOid;
} else if (process.env.GITHUB_EVENT_PATH) { } else if (process.env.GITHUB_EVENT_PATH) {
const githubEvent = JSON.parse( const githubEvent = JSON.parse(
fs12.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8") fs13.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8")
); );
payloadObj.base_ref = `refs/heads/${githubEvent.pull_request.base.ref}`; payloadObj.base_ref = `refs/heads/${githubEvent.pull_request.base.ref}`;
payloadObj.base_sha = githubEvent.pull_request.base.sha; payloadObj.base_sha = githubEvent.pull_request.base.sha;
@@ -111256,7 +111256,7 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths,
category = analysis.fixCategory(logger, category); category = analysis.fixCategory(logger, category);
if (sarifPaths.length > 1) { if (sarifPaths.length > 1) {
for (const sarifPath of sarifPaths) { for (const sarifPath of sarifPaths) {
const parsedSarif = readSarifFile(sarifPath); const parsedSarif = readSarifFile2(sarifPath);
validateSarifFileSchema(parsedSarif, sarifPath, logger); validateSarifFileSchema(parsedSarif, sarifPath, logger);
} }
sarif = await combineSarifFilesUsingCLI( sarif = await combineSarifFilesUsingCLI(
@@ -111267,7 +111267,7 @@ async function postProcessSarifFiles(logger, features, checkoutPath, sarifPaths,
); );
} else { } else {
const sarifPath = sarifPaths[0]; const sarifPath = sarifPaths[0];
sarif = readSarifFile(sarifPath); sarif = readSarifFile2(sarifPath);
validateSarifFileSchema(sarif, sarifPath, logger); validateSarifFileSchema(sarif, sarifPath, logger);
await throwIfCombineSarifFilesDisabled([sarif], gitHubVersion); await throwIfCombineSarifFilesDisabled([sarif], gitHubVersion);
} }
@@ -111345,9 +111345,9 @@ async function uploadPostProcessedFiles(logger, checkoutPath, uploadTarget, post
}; };
} }
function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) { function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) {
if (!fs12.existsSync(outputDir)) { if (!fs13.existsSync(outputDir)) {
fs12.mkdirSync(outputDir, { recursive: true }); fs13.mkdirSync(outputDir, { recursive: true });
} else if (!fs12.lstatSync(outputDir).isDirectory()) { } else if (!fs13.lstatSync(outputDir).isDirectory()) {
throw new ConfigurationError( throw new ConfigurationError(
`The path that processed SARIF files should be written to exists, but is not a directory: ${outputDir}` `The path that processed SARIF files should be written to exists, but is not a directory: ${outputDir}`
); );
@@ -111357,7 +111357,7 @@ function dumpSarifFile(sarifPayload, outputDir, logger, uploadTarget) {
`upload${uploadTarget.sarifExtension}` `upload${uploadTarget.sarifExtension}`
); );
logger.info(`Writing processed SARIF file to ${outputFile}`); logger.info(`Writing processed SARIF file to ${outputFile}`);
fs12.writeFileSync(outputFile, sarifPayload); fs13.writeFileSync(outputFile, sarifPayload);
} }
var STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1e3; var STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1e3;
var STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1e3; var STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1e3;

View File

@@ -1,3 +1,5 @@
import * as fs from "fs";
import { Logger } from "../logging"; import { Logger } from "../logging";
export interface SarifLocation { export interface SarifLocation {
@@ -166,3 +168,7 @@ export function fixInvalidNotifications(
} }
return newSarif; return newSarif;
} }
export function readSarifFile(sarifFilePath: string): SarifFile {
return JSON.parse(fs.readFileSync(sarifFilePath, "utf8")) as SarifFile;
}

View File

@@ -21,6 +21,7 @@ import * as gitUtils from "./git-utils";
import { initCodeQL } from "./init"; import { initCodeQL } from "./init";
import { Logger } from "./logging"; import { Logger } from "./logging";
import { getRepositoryNwo, RepositoryNwo } from "./repository"; import { getRepositoryNwo, RepositoryNwo } from "./repository";
import type { SarifFile, SarifRun } from "./sarif";
import { BasePayload, UploadPayload } from "./upload-lib/types"; import { BasePayload, UploadPayload } from "./upload-lib/types";
import * as util from "./util"; import * as util from "./util";
import { import {
@@ -30,8 +31,6 @@ import {
GitHubVariant, GitHubVariant,
GitHubVersion, GitHubVersion,
satisfiesGHESVersion, satisfiesGHESVersion,
SarifFile,
SarifRun,
} from "./util"; } from "./util";
const GENERIC_403_MSG = const GENERIC_403_MSG =
@@ -50,9 +49,7 @@ function combineSarifFiles(sarifFiles: string[], logger: Logger): SarifFile {
for (const sarifFile of sarifFiles) { for (const sarifFile of sarifFiles) {
logger.debug(`Loading SARIF file: ${sarifFile}`); logger.debug(`Loading SARIF file: ${sarifFile}`);
const sarifObject = JSON.parse( const sarifObject = util.readSarifFile(sarifFile);
fs.readFileSync(sarifFile, "utf8"),
) as SarifFile;
// Check SARIF version // Check SARIF version
if (combinedSarif.version === null) { if (combinedSarif.version === null) {
combinedSarif.version = sarifObject.version; combinedSarif.version = sarifObject.version;
@@ -195,9 +192,7 @@ async function combineSarifFilesUsingCLI(
): Promise<SarifFile> { ): Promise<SarifFile> {
logger.info("Combining SARIF files using the CodeQL CLI"); logger.info("Combining SARIF files using the CodeQL CLI");
const sarifObjects = sarifFiles.map((sarifFile): SarifFile => { const sarifObjects = sarifFiles.map(util.readSarifFile);
return JSON.parse(fs.readFileSync(sarifFile, "utf8")) as SarifFile;
});
const deprecationWarningMessage = const deprecationWarningMessage =
gitHubVersion.type === GitHubVariant.GHES gitHubVersion.type === GitHubVariant.GHES
@@ -279,7 +274,7 @@ async function combineSarifFilesUsingCLI(
mergeRunsFromEqualCategory: true, mergeRunsFromEqualCategory: true,
}); });
return JSON.parse(fs.readFileSync(outputFile, "utf8")) as SarifFile; return util.readSarifFile(outputFile);
} }
// Populates the run.automationDetails.id field using the analysis_key and environment // Populates the run.automationDetails.id field using the analysis_key and environment
@@ -531,7 +526,7 @@ function countResultsInSarif(sarif: string): number {
export function readSarifFile(sarifFilePath: string): SarifFile { export function readSarifFile(sarifFilePath: string): SarifFile {
try { try {
return JSON.parse(fs.readFileSync(sarifFilePath, "utf8")) as SarifFile; return util.readSarifFile(sarifFilePath);
} catch (e) { } catch (e) {
throw new InvalidSarifUploadError( throw new InvalidSarifUploadError(
`Invalid SARIF. JSON syntax error: ${getErrorMessage(e)}`, `Invalid SARIF. JSON syntax error: ${getErrorMessage(e)}`,