Refactor all doc URLs into their own enum

This commit is contained in:
Angela P Wen 2024-07-23 14:13:16 +02:00
parent 7cb4b5a421
commit 7ad1090882
18 changed files with 67 additions and 25 deletions

16
lib/doc-url.js generated Normal file
View file

@ -0,0 +1,16 @@
"use strict";
/**
* URLs to code scanning docs linked to from CodeQL Action logs.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DocUrl = void 0;
var DocUrl;
(function (DocUrl) {
DocUrl["ASSIGNING_PERMISSIONS_TO_JOBS"] = "https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs";
DocUrl["AUTOMATIC_BUILD_FAILED"] = "https://docs.github.com/en/code-security/code-scanning/troubleshooting-code-scanning/automatic-build-failed";
DocUrl["DEFINE_ENV_VARIABLES"] = "https://docs.github.com/en/actions/learn-github-actions/variables#defining-environment-variables-for-a-single-workflow";
DocUrl["SCANNING_ON_PUSH"] = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning#scanning-on-push";
DocUrl["SPECIFY_BUILD_STEPS_MANUALLY"] = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#about-specifying-build-steps-manually";
DocUrl["TRACK_CODE_SCANNING_ALERTS_ACROSS_RUNS"] = "https://docs.github.com/en/enterprise-cloud@latest/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#providing-data-to-track-code-scanning-alerts-across-runs";
})(DocUrl || (exports.DocUrl = DocUrl = {}));
//# sourceMappingURL=doc-url.js.map

1
lib/doc-url.js.map Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"doc-url.js","sourceRoot":"","sources":["../src/doc-url.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,IAAY,MAaX;AAbD,WAAY,MAAM;IACd,uHACiF,CAAA;IACjF,gJACiH,CAAA;IACjH,yJAC4H,CAAA;IAC5H,qMAC4K,CAAA;IAC5K,gOAC2L,CAAA;IAC3L,2PAC4M,CAAA;AAChN,CAAC,EAbW,MAAM,sBAAN,MAAM,QAajB"}

5
lib/docs-urls.js generated Normal file
View file

@ -0,0 +1,5 @@
"use strict";
/**
* URLs to code scanning docs linked to from CodeQL Action logs.
*/
//# sourceMappingURL=docs-urls.js.map

1
lib/docs-urls.js.map Normal file
View file

@ -0,0 +1 @@
{"version":3,"file":"docs-urls.js","sourceRoot":"","sources":["../src/docs-urls.ts"],"names":[],"mappings":";AAAA;;GAEG"}

3
lib/fingerprints.js generated
View file

@ -32,6 +32,7 @@ exports.addFingerprints = addFingerprints;
const fs = __importStar(require("fs"));
const path_1 = __importDefault(require("path"));
const long_1 = __importDefault(require("long"));
const doc_url_1 = require("./doc-url");
const tab = "\t".charCodeAt(0);
const space = " ".charCodeAt(0);
const lf = "\n".charCodeAt(0);
@ -238,7 +239,7 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
// Compute fingerprints for results in the given sarif file
// and return an updated sarif file contents.
async function addFingerprints(sarif, sourceRoot, logger) {
logger.info("Adding fingerprints to SARIF file. For more information, see https://docs.github.com/en/enterprise-cloud@latest/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#providing-data-to-track-code-scanning-alerts-across-runs");
logger.info(`Adding fingerprints to SARIF file. For more information, see ${doc_url_1.DocUrl.TRACK_CODE_SCANNING_ALERTS_ACROSS_RUNS}`);
// Gather together results for the same file and construct
// callbacks to accept hashes for that file and update the location
const callbacksByFile = {};

File diff suppressed because one or more lines are too long

3
lib/status-report.js generated
View file

@ -33,6 +33,7 @@ const os = __importStar(require("os"));
const core = __importStar(require("@actions/core"));
const actions_util_1 = require("./actions-util");
const api_client_1 = require("./api-client");
const doc_url_1 = require("./doc-url");
const environment_1 = require("./environment");
const util_1 = require("./util");
var ActionName;
@ -253,7 +254,7 @@ async function sendStatusReport(statusReport) {
core.warning('Workflows triggered by Dependabot on the "push" event run with read-only access. ' +
"Uploading Code Scanning results requires write access. " +
'To use Code Scanning with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. ' +
"See https://docs.github.com/en/code-security/secure-coding/configuring-code-scanning#scanning-on-push for more information on how to configure these events.");
`See ${doc_url_1.DocUrl.SCANNING_ON_PUSH} for more information on how to configure these events."`);
}
else {
core.warning(e.message);

File diff suppressed because one or more lines are too long

3
lib/trap-caching.js generated
View file

@ -33,6 +33,7 @@ const path = __importStar(require("path"));
const actionsCache = __importStar(require("@actions/cache"));
const actionsUtil = __importStar(require("./actions-util"));
const apiClient = __importStar(require("./api-client"));
const doc_url_1 = require("./doc-url");
const feature_flags_1 = require("./feature-flags");
const util_1 = require("./util");
// This constant should be bumped if we make a breaking change
@ -177,7 +178,7 @@ async function cleanupTrapCaches(config, features, logger) {
if ((0, util_1.isHTTPError)(e) && e.status === 403) {
logger.warning("Could not cleanup TRAP caches as the token did not have the required permissions. " +
'To clean up TRAP caches, ensure the token has the "actions:write" permission. ' +
"For more information, see https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs");
`For more information, see " + ${doc_url_1.DocUrl.ASSIGNING_PERMISSIONS_TO_JOBS}`);
}
else {
logger.info(`Failed to cleanup TRAP caches, continuing. Details: ${e}`);

File diff suppressed because one or more lines are too long