mirror of
https://github.com/github/codeql-action.git
synced 2026-05-04 12:50:14 +00:00
Check that file doesn't belong to other analysis in getSarifFilePaths
This commit is contained in:
Generated
+11
-9
@@ -90177,6 +90177,12 @@ var CodeQuality = {
|
||||
sarifPredicate: (name) => name.endsWith(CodeQuality.sarifExtension),
|
||||
sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_"
|
||||
};
|
||||
var Analyses = [CodeScanning, CodeQuality];
|
||||
function isOtherAnalysisSarif(current, filepath) {
|
||||
return Analyses.some(
|
||||
(config) => config.kind !== current && config.sarifPredicate(filepath)
|
||||
);
|
||||
}
|
||||
|
||||
// src/analyze.ts
|
||||
var fs15 = __toESM(require("fs"));
|
||||
@@ -95568,11 +95574,11 @@ function findSarifFilesInDir(sarifPath, isSarif) {
|
||||
walkSarifFiles(sarifPath);
|
||||
return sarifFiles;
|
||||
}
|
||||
function getSarifFilePaths(sarifPath, isSarif, pathStats) {
|
||||
let sarifFiles;
|
||||
function getSarifFilePaths(sarifPath, analysis, pathStats) {
|
||||
let sarifFiles = [];
|
||||
if (pathStats.isDirectory()) {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
|
||||
} else {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, analysis.sarifPredicate);
|
||||
} else if (!isOtherAnalysisSarif(analysis.kind, sarifPath)) {
|
||||
sarifFiles = [sarifPath];
|
||||
}
|
||||
return sarifFiles;
|
||||
@@ -95677,11 +95683,7 @@ async function uploadFiles(inputSarifPath, checkoutPath, category, features, log
|
||||
if (pathStats === void 0) {
|
||||
throw new ConfigurationError(`Path does not exist: ${inputSarifPath}`);
|
||||
}
|
||||
const sarifPaths = getSarifFilePaths(
|
||||
inputSarifPath,
|
||||
uploadTarget.sarifPredicate,
|
||||
pathStats
|
||||
);
|
||||
const sarifPaths = getSarifFilePaths(inputSarifPath, uploadTarget, pathStats);
|
||||
if (sarifPaths.length === 0) {
|
||||
throw new ConfigurationError(
|
||||
`No SARIF files found to upload in "${inputSarifPath}".`
|
||||
|
||||
Generated
+11
-9
@@ -128817,6 +128817,12 @@ var CodeQuality = {
|
||||
sarifPredicate: (name) => name.endsWith(CodeQuality.sarifExtension),
|
||||
sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_"
|
||||
};
|
||||
var Analyses = [CodeScanning, CodeQuality];
|
||||
function isOtherAnalysisSarif(current, filepath) {
|
||||
return Analyses.some(
|
||||
(config) => config.kind !== current && config.sarifPredicate(filepath)
|
||||
);
|
||||
}
|
||||
|
||||
// src/caching-utils.ts
|
||||
var core6 = __toESM(require_core());
|
||||
@@ -133002,11 +133008,11 @@ function findSarifFilesInDir(sarifPath, isSarif) {
|
||||
walkSarifFiles(sarifPath);
|
||||
return sarifFiles;
|
||||
}
|
||||
function getSarifFilePaths(sarifPath, isSarif, pathStats) {
|
||||
let sarifFiles;
|
||||
function getSarifFilePaths(sarifPath, analysis, pathStats) {
|
||||
let sarifFiles = [];
|
||||
if (pathStats.isDirectory()) {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
|
||||
} else {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, analysis.sarifPredicate);
|
||||
} else if (!isOtherAnalysisSarif(analysis.kind, sarifPath)) {
|
||||
sarifFiles = [sarifPath];
|
||||
}
|
||||
return sarifFiles;
|
||||
@@ -133111,11 +133117,7 @@ async function uploadFiles(inputSarifPath, checkoutPath, category, features, log
|
||||
if (pathStats === void 0) {
|
||||
throw new ConfigurationError(`Path does not exist: ${inputSarifPath}`);
|
||||
}
|
||||
const sarifPaths = getSarifFilePaths(
|
||||
inputSarifPath,
|
||||
uploadTarget.sarifPredicate,
|
||||
pathStats
|
||||
);
|
||||
const sarifPaths = getSarifFilePaths(inputSarifPath, uploadTarget, pathStats);
|
||||
if (sarifPaths.length === 0) {
|
||||
throw new ConfigurationError(
|
||||
`No SARIF files found to upload in "${inputSarifPath}".`
|
||||
|
||||
Generated
+35
-17
@@ -88530,6 +88530,36 @@ async function runTool(cmd, args = [], opts = {}) {
|
||||
return stdout;
|
||||
}
|
||||
|
||||
// src/analyses.ts
|
||||
var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => {
|
||||
AnalysisKind2["CodeScanning"] = "code-scanning";
|
||||
AnalysisKind2["CodeQuality"] = "code-quality";
|
||||
return AnalysisKind2;
|
||||
})(AnalysisKind || {});
|
||||
var supportedAnalysisKinds = new Set(Object.values(AnalysisKind));
|
||||
var CodeScanning = {
|
||||
kind: "code-scanning" /* CodeScanning */,
|
||||
name: "code scanning",
|
||||
target: "PUT /repos/:owner/:repo/code-scanning/analysis" /* CODE_SCANNING */,
|
||||
sarifExtension: ".sarif",
|
||||
sarifPredicate: (name) => name.endsWith(CodeScanning.sarifExtension) && !CodeQuality.sarifPredicate(name),
|
||||
sentinelPrefix: "CODEQL_UPLOAD_SARIF_"
|
||||
};
|
||||
var CodeQuality = {
|
||||
kind: "code-quality" /* CodeQuality */,
|
||||
name: "code quality",
|
||||
target: "PUT /repos/:owner/:repo/code-quality/analysis" /* CODE_QUALITY */,
|
||||
sarifExtension: ".quality.sarif",
|
||||
sarifPredicate: (name) => name.endsWith(CodeQuality.sarifExtension),
|
||||
sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_"
|
||||
};
|
||||
var Analyses = [CodeScanning, CodeQuality];
|
||||
function isOtherAnalysisSarif(current, filepath) {
|
||||
return Analyses.some(
|
||||
(config) => config.kind !== current && config.sarifPredicate(filepath)
|
||||
);
|
||||
}
|
||||
|
||||
// src/api-client.ts
|
||||
var core5 = __toESM(require_core());
|
||||
var githubUtils = __toESM(require_utils4());
|
||||
@@ -88921,14 +88951,6 @@ function wrapCliConfigurationError(cliError) {
|
||||
var fs7 = __toESM(require("fs"));
|
||||
var path9 = __toESM(require("path"));
|
||||
|
||||
// src/analyses.ts
|
||||
var AnalysisKind = /* @__PURE__ */ ((AnalysisKind2) => {
|
||||
AnalysisKind2["CodeScanning"] = "code-scanning";
|
||||
AnalysisKind2["CodeQuality"] = "code-quality";
|
||||
return AnalysisKind2;
|
||||
})(AnalysisKind || {});
|
||||
var supportedAnalysisKinds = new Set(Object.values(AnalysisKind));
|
||||
|
||||
// src/caching-utils.ts
|
||||
var core6 = __toESM(require_core());
|
||||
|
||||
@@ -92374,11 +92396,11 @@ function findSarifFilesInDir(sarifPath, isSarif) {
|
||||
walkSarifFiles(sarifPath);
|
||||
return sarifFiles;
|
||||
}
|
||||
function getSarifFilePaths(sarifPath, isSarif, pathStats) {
|
||||
let sarifFiles;
|
||||
function getSarifFilePaths(sarifPath, analysis, pathStats) {
|
||||
let sarifFiles = [];
|
||||
if (pathStats.isDirectory()) {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
|
||||
} else {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, analysis.sarifPredicate);
|
||||
} else if (!isOtherAnalysisSarif(analysis.kind, sarifPath)) {
|
||||
sarifFiles = [sarifPath];
|
||||
}
|
||||
return sarifFiles;
|
||||
@@ -92483,11 +92505,7 @@ async function uploadFiles(inputSarifPath, checkoutPath, category, features, log
|
||||
if (pathStats === void 0) {
|
||||
throw new ConfigurationError(`Path does not exist: ${inputSarifPath}`);
|
||||
}
|
||||
const sarifPaths = getSarifFilePaths(
|
||||
inputSarifPath,
|
||||
uploadTarget.sarifPredicate,
|
||||
pathStats
|
||||
);
|
||||
const sarifPaths = getSarifFilePaths(inputSarifPath, uploadTarget, pathStats);
|
||||
if (sarifPaths.length === 0) {
|
||||
throw new ConfigurationError(
|
||||
`No SARIF files found to upload in "${inputSarifPath}".`
|
||||
|
||||
Generated
+11
-5
@@ -88781,6 +88781,12 @@ var CodeQuality = {
|
||||
sarifPredicate: (name) => name.endsWith(CodeQuality.sarifExtension),
|
||||
sentinelPrefix: "CODEQL_UPLOAD_QUALITY_SARIF_"
|
||||
};
|
||||
var Analyses = [CodeScanning, CodeQuality];
|
||||
function isOtherAnalysisSarif(current, filepath) {
|
||||
return Analyses.some(
|
||||
(config) => config.kind !== current && config.sarifPredicate(filepath)
|
||||
);
|
||||
}
|
||||
|
||||
// src/api-client.ts
|
||||
var core5 = __toESM(require_core());
|
||||
@@ -93075,11 +93081,11 @@ function findSarifFilesInDir(sarifPath, isSarif) {
|
||||
walkSarifFiles(sarifPath);
|
||||
return sarifFiles;
|
||||
}
|
||||
function getSarifFilePaths(sarifPath, isSarif, pathStats) {
|
||||
let sarifFiles;
|
||||
function getSarifFilePaths(sarifPath, analysis, pathStats) {
|
||||
let sarifFiles = [];
|
||||
if (pathStats.isDirectory()) {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
|
||||
} else {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, analysis.sarifPredicate);
|
||||
} else if (!isOtherAnalysisSarif(analysis.kind, sarifPath)) {
|
||||
sarifFiles = [sarifPath];
|
||||
}
|
||||
return sarifFiles;
|
||||
@@ -93430,7 +93436,7 @@ var core13 = __toESM(require_core());
|
||||
async function findAndUpload(logger, features, sarifPath, pathStats, checkoutPath, analysis, category) {
|
||||
const sarifFiles = getSarifFilePaths(
|
||||
sarifPath,
|
||||
analysis.sarifPredicate,
|
||||
analysis,
|
||||
pathStats
|
||||
);
|
||||
if (sarifFiles.length !== 0) {
|
||||
|
||||
+5
-9
@@ -437,13 +437,13 @@ export function findSarifFilesInDir(
|
||||
|
||||
export function getSarifFilePaths(
|
||||
sarifPath: string,
|
||||
isSarif: (name: string) => boolean,
|
||||
analysis: analyses.AnalysisConfig,
|
||||
pathStats: fs.Stats,
|
||||
) {
|
||||
let sarifFiles: string[];
|
||||
let sarifFiles: string[] = [];
|
||||
if (pathStats.isDirectory()) {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, isSarif);
|
||||
} else {
|
||||
sarifFiles = findSarifFilesInDir(sarifPath, analysis.sarifPredicate);
|
||||
} else if (!analyses.isOtherAnalysisSarif(analysis.kind, sarifPath)) {
|
||||
sarifFiles = [sarifPath];
|
||||
}
|
||||
return sarifFiles;
|
||||
@@ -620,11 +620,7 @@ export async function uploadFiles(
|
||||
throw new ConfigurationError(`Path does not exist: ${inputSarifPath}`);
|
||||
}
|
||||
|
||||
const sarifPaths = getSarifFilePaths(
|
||||
inputSarifPath,
|
||||
uploadTarget.sarifPredicate,
|
||||
pathStats,
|
||||
);
|
||||
const sarifPaths = getSarifFilePaths(inputSarifPath, uploadTarget, pathStats);
|
||||
|
||||
if (sarifPaths.length === 0) {
|
||||
// This is always a configuration error, even for first-party runs.
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ export async function findAndUpload(
|
||||
): Promise<upload_lib.UploadResult | undefined> {
|
||||
const sarifFiles: string[] | undefined = upload_lib.getSarifFilePaths(
|
||||
sarifPath,
|
||||
analysis.sarifPredicate,
|
||||
analysis,
|
||||
pathStats,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user