Mark some upload-sarif errors as always configuration errors
This commit is contained in:
parent
a22989dcd4
commit
e006461bad
3 changed files with 13 additions and 7 deletions
9
lib/upload-lib.js
generated
9
lib/upload-lib.js
generated
|
|
@ -226,13 +226,15 @@ async function uploadFromActions(sarifPath, checkoutPath, category, logger) {
|
||||||
exports.uploadFromActions = uploadFromActions;
|
exports.uploadFromActions = uploadFromActions;
|
||||||
function getSarifFilePaths(sarifPath) {
|
function getSarifFilePaths(sarifPath) {
|
||||||
if (!fs.existsSync(sarifPath)) {
|
if (!fs.existsSync(sarifPath)) {
|
||||||
throw new InvalidSarifUploadError(`Path does not exist: ${sarifPath}`);
|
// This is always a configuration error, even for first-party runs.
|
||||||
|
throw new util_1.ConfigurationError(`Path does not exist: ${sarifPath}`);
|
||||||
}
|
}
|
||||||
let sarifFiles;
|
let sarifFiles;
|
||||||
if (fs.lstatSync(sarifPath).isDirectory()) {
|
if (fs.lstatSync(sarifPath).isDirectory()) {
|
||||||
sarifFiles = findSarifFilesInDir(sarifPath);
|
sarifFiles = findSarifFilesInDir(sarifPath);
|
||||||
if (sarifFiles.length === 0) {
|
if (sarifFiles.length === 0) {
|
||||||
throw new InvalidSarifUploadError(`No SARIF files found to upload in "${sarifPath}".`);
|
// This is always a configuration error, even for first-party runs.
|
||||||
|
throw new util_1.ConfigurationError(`No SARIF files found to upload in "${sarifPath}".`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -504,7 +506,8 @@ function validateUniqueCategory(sarif) {
|
||||||
for (const [category, { id, tool }] of Object.entries(categories)) {
|
for (const [category, { id, tool }] of Object.entries(categories)) {
|
||||||
const sentinelEnvVar = `CODEQL_UPLOAD_SARIF_${category}`;
|
const sentinelEnvVar = `CODEQL_UPLOAD_SARIF_${category}`;
|
||||||
if (process.env[sentinelEnvVar]) {
|
if (process.env[sentinelEnvVar]) {
|
||||||
throw new InvalidSarifUploadError("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per tool/category. " +
|
// This is always a configuration error, even for first-party runs.
|
||||||
|
throw new util_1.ConfigurationError("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per tool/category. " +
|
||||||
"The easiest fix is to specify a unique value for the `category` input. If .runs[].automationDetails.id is specified " +
|
"The easiest fix is to specify a unique value for the `category` input. If .runs[].automationDetails.id is specified " +
|
||||||
"in the sarif file, that will take precedence over your configured `category`. " +
|
"in the sarif file, that will take precedence over your configured `category`. " +
|
||||||
`Category: (${id ? id : "none"}) Tool: (${tool ? tool : "none"})`);
|
`Category: (${id ? id : "none"}) Tool: (${tool ? tool : "none"})`);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -320,14 +320,16 @@ export async function uploadFromActions(
|
||||||
|
|
||||||
function getSarifFilePaths(sarifPath: string) {
|
function getSarifFilePaths(sarifPath: string) {
|
||||||
if (!fs.existsSync(sarifPath)) {
|
if (!fs.existsSync(sarifPath)) {
|
||||||
throw new InvalidSarifUploadError(`Path does not exist: ${sarifPath}`);
|
// This is always a configuration error, even for first-party runs.
|
||||||
|
throw new ConfigurationError(`Path does not exist: ${sarifPath}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sarifFiles: string[];
|
let sarifFiles: string[];
|
||||||
if (fs.lstatSync(sarifPath).isDirectory()) {
|
if (fs.lstatSync(sarifPath).isDirectory()) {
|
||||||
sarifFiles = findSarifFilesInDir(sarifPath);
|
sarifFiles = findSarifFilesInDir(sarifPath);
|
||||||
if (sarifFiles.length === 0) {
|
if (sarifFiles.length === 0) {
|
||||||
throw new InvalidSarifUploadError(
|
// This is always a configuration error, even for first-party runs.
|
||||||
|
throw new ConfigurationError(
|
||||||
`No SARIF files found to upload in "${sarifPath}".`,
|
`No SARIF files found to upload in "${sarifPath}".`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -733,7 +735,8 @@ export function validateUniqueCategory(sarif: SarifFile): void {
|
||||||
for (const [category, { id, tool }] of Object.entries(categories)) {
|
for (const [category, { id, tool }] of Object.entries(categories)) {
|
||||||
const sentinelEnvVar = `CODEQL_UPLOAD_SARIF_${category}`;
|
const sentinelEnvVar = `CODEQL_UPLOAD_SARIF_${category}`;
|
||||||
if (process.env[sentinelEnvVar]) {
|
if (process.env[sentinelEnvVar]) {
|
||||||
throw new InvalidSarifUploadError(
|
// This is always a configuration error, even for first-party runs.
|
||||||
|
throw new ConfigurationError(
|
||||||
"Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per tool/category. " +
|
"Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per tool/category. " +
|
||||||
"The easiest fix is to specify a unique value for the `category` input. If .runs[].automationDetails.id is specified " +
|
"The easiest fix is to specify a unique value for the `category` input. If .runs[].automationDetails.id is specified " +
|
||||||
"in the sarif file, that will take precedence over your configured `category`. " +
|
"in the sarif file, that will take precedence over your configured `category`. " +
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue