mirror of
https://github.com/github/codeql-action.git
synced 2026-08-05 21:06:13 -05:00
Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d1418f9e47 | |||
| 21066c2326 | |||
| eda5730a8b | |||
| e263f3a83a | |||
| ddef289289 | |||
| 99576d59b9 | |||
| 72b0f9fed4 | |||
| 9fc351a8ac | |||
| 72f4abcfcc | |||
| 0630e39f3f | |||
| 2b0250fe46 | |||
| 446948f50b | |||
| d24f3022a8 | |||
| 8aad20d150 | |||
| f521b08cd8 | |||
| 8aeff0ffb7 | |||
| dcb947ce15 | |||
| c251bcefa1 | |||
| 62953c18b3 | |||
| 423b570baf | |||
| acb38f7265 | |||
| dd9e36c0d3 | |||
| 8c6a2b4d4b | |||
| 57b3666b1d | |||
| 1251f87758 | |||
| 6963dfbbc5 | |||
| d426d33115 | |||
| f22e7a29ce | |||
| d8e5e3dbab | |||
| 9b49e27edb | |||
| aeb3e20ace | |||
| d622e410d6 | |||
| fb605661cd | |||
| 063bb8b614 | |||
| 3d8236de69 | |||
| b1eeb13c4c | |||
| 964d328667 | |||
| f9b6569832 | |||
| 3782e65e9f | |||
| dafa67e1d3 | |||
| 0d5f0f55c2 | |||
| 7c7926f8df | |||
| 838486a3c3 | |||
| 09a0f62a7a | |||
| 652e91defb |
@@ -69,7 +69,7 @@ jobs:
|
||||
run: npm run lint-ci
|
||||
|
||||
- name: Upload sarif
|
||||
uses: github/codeql-action/upload-sarif@v4
|
||||
uses: ./upload-sarif
|
||||
if: matrix.os == 'ubuntu-latest' && matrix.node-version == 24
|
||||
with:
|
||||
sarif_file: eslint.sarif
|
||||
|
||||
+7
-1
@@ -4,7 +4,13 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
|
||||
|
||||
## [UNRELEASED]
|
||||
|
||||
No user facing changes.
|
||||
- Organizations can create a custom repository property named `github-codeql-tools` to set a default CodeQL CLI tools value. You can optionally set `github-codeql-tools-mode` to control scope: use `enforce` (default) to apply to all workflows, or `dynamic` to apply only to dynamic workflows. If a workflow provides an explicit `tools:` input, that input takes precedence. For more information, see [Managing custom properties for repositories in your organization](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization), [Repository properties for Code Scanning](https://docs.github.com/en/code-security/concepts/code-scanning/repository-properties) and [Customizing your advanced setup for code scanning](https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning).
|
||||
|
||||
## 4.36.2 - 04 Jun 2026
|
||||
|
||||
- Cache CodeQL CLI version information across Actions steps. [#3943](https://github.com/github/codeql-action/pull/3943)
|
||||
- Reduce requests while waiting for analysis processing by using exponential backoff when polling SARIF processing status. [#3937](https://github.com/github/codeql-action/pull/3937)
|
||||
- Update default CodeQL bundle version to [2.25.6](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.6). [#3948](https://github.com/github/codeql-action/pull/3948)
|
||||
|
||||
## 4.36.1 - 02 Jun 2026
|
||||
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-v2.25.5",
|
||||
"cliVersion": "2.25.5",
|
||||
"priorBundleVersion": "codeql-bundle-v2.25.4",
|
||||
"priorCliVersion": "2.25.4"
|
||||
"bundleVersion": "codeql-bundle-v2.25.6",
|
||||
"cliVersion": "2.25.6",
|
||||
"priorBundleVersion": "codeql-bundle-v2.25.5",
|
||||
"priorCliVersion": "2.25.5"
|
||||
}
|
||||
|
||||
Generated
+152
-65
@@ -26853,6 +26853,7 @@ var require_range = __commonJS({
|
||||
return this.range;
|
||||
}
|
||||
parseRange(range) {
|
||||
range = range.replace(BUILDSTRIPRE, "");
|
||||
const memoOpts = (this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE);
|
||||
const memoKey = memoOpts + ":" + range;
|
||||
const cached = cache.get(memoKey);
|
||||
@@ -26935,12 +26936,14 @@ var require_range = __commonJS({
|
||||
var SemVer = require_semver();
|
||||
var {
|
||||
safeRe: re,
|
||||
src,
|
||||
t,
|
||||
comparatorTrimReplace,
|
||||
tildeTrimReplace,
|
||||
caretTrimReplace
|
||||
} = require_re();
|
||||
var { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants6();
|
||||
var BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
|
||||
var isNullSet = (c) => c.value === "<0.0.0-0";
|
||||
var isAny = (c) => c.value === "";
|
||||
var isSatisfiable = (comparators, options) => {
|
||||
@@ -27696,7 +27699,7 @@ var require_subset = __commonJS({
|
||||
if (higher === c && higher !== gt) {
|
||||
return false;
|
||||
}
|
||||
} else if (gt.operator === ">=" && !satisfies2(gt.semver, String(c), options)) {
|
||||
} else if (gt.operator === ">=" && !c.test(gt.semver)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -27711,7 +27714,7 @@ var require_subset = __commonJS({
|
||||
if (lower === c && lower !== lt2) {
|
||||
return false;
|
||||
}
|
||||
} else if (lt2.operator === "<=" && !satisfies2(lt2.semver, String(c), options)) {
|
||||
} else if (lt2.operator === "<=" && !c.test(lt2.semver)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -148395,7 +148398,7 @@ function getDiffRangesJsonFilePath() {
|
||||
return path2.join(getTemporaryDirectory(), PR_DIFF_RANGE_JSON_FILENAME);
|
||||
}
|
||||
function getActionVersion() {
|
||||
return "4.36.2";
|
||||
return "4.36.3";
|
||||
}
|
||||
function getWorkflowEventName() {
|
||||
return getRequiredEnvParam("GITHUB_EVENT_NAME");
|
||||
@@ -148959,8 +148962,8 @@ function wrapApiConfigurationError(e) {
|
||||
}
|
||||
|
||||
// src/defaults.json
|
||||
var bundleVersion = "codeql-bundle-v2.25.5";
|
||||
var cliVersion = "2.25.5";
|
||||
var bundleVersion = "codeql-bundle-v2.25.6";
|
||||
var cliVersion = "2.25.6";
|
||||
|
||||
// src/overlay/index.ts
|
||||
var fs4 = __toESM(require("fs"));
|
||||
@@ -150444,11 +150447,14 @@ function getUnknownLanguagesError(languages) {
|
||||
}
|
||||
|
||||
// src/feature-flags/properties.ts
|
||||
var github2 = __toESM(require_github());
|
||||
var GITHUB_CODEQL_PROPERTY_PREFIX = "github-codeql-";
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
RepositoryPropertyName2["DISABLE_OVERLAY"] = "github-codeql-disable-overlay";
|
||||
RepositoryPropertyName2["EXTRA_QUERIES"] = "github-codeql-extra-queries";
|
||||
RepositoryPropertyName2["FILE_COVERAGE_ON_PRS"] = "github-codeql-file-coverage-on-prs";
|
||||
RepositoryPropertyName2["TOOLS"] = "github-codeql-tools";
|
||||
RepositoryPropertyName2["TOOLS_MODE"] = "github-codeql-tools-mode";
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
function isString2(value) {
|
||||
@@ -150466,7 +150472,12 @@ var booleanProperty = {
|
||||
var repositoryPropertyParsers = {
|
||||
["github-codeql-disable-overlay" /* DISABLE_OVERLAY */]: booleanProperty,
|
||||
["github-codeql-extra-queries" /* EXTRA_QUERIES */]: stringProperty,
|
||||
["github-codeql-file-coverage-on-prs" /* FILE_COVERAGE_ON_PRS */]: booleanProperty
|
||||
["github-codeql-file-coverage-on-prs" /* FILE_COVERAGE_ON_PRS */]: booleanProperty,
|
||||
["github-codeql-tools" /* TOOLS */]: stringProperty,
|
||||
["github-codeql-tools-mode" /* TOOLS_MODE */]: {
|
||||
validate: isString2,
|
||||
parse: parseToolsModeRepositoryProperty
|
||||
}
|
||||
};
|
||||
async function loadPropertiesFromApi(logger, repositoryNwo) {
|
||||
try {
|
||||
@@ -150519,6 +150530,26 @@ async function loadPropertiesFromApi(logger, repositoryNwo) {
|
||||
);
|
||||
}
|
||||
}
|
||||
async function loadRepositoryProperties(repositoryNwo, logger) {
|
||||
const repositoryOwnerType = github2.context.payload.repository?.owner.type;
|
||||
logger.debug(
|
||||
`Repository owner type is '${repositoryOwnerType ?? "unknown"}'.`
|
||||
);
|
||||
if (repositoryOwnerType === "User") {
|
||||
logger.debug(
|
||||
"Skipping loading repository properties because the repository is owned by a user and therefore cannot have repository properties."
|
||||
);
|
||||
return new Success({});
|
||||
}
|
||||
try {
|
||||
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
||||
} catch (error3) {
|
||||
logger.info(
|
||||
`Failed to load repository properties: ${getErrorMessage(error3)}`
|
||||
);
|
||||
return new Failure(error3);
|
||||
}
|
||||
}
|
||||
function setProperty2(properties, name, value, logger) {
|
||||
const propertyOptions = repositoryPropertyParsers[name];
|
||||
if (propertyOptions.validate(value)) {
|
||||
@@ -150540,6 +150571,15 @@ function parseBooleanRepositoryProperty(name, value, logger) {
|
||||
function parseStringRepositoryProperty(_name, value) {
|
||||
return value;
|
||||
}
|
||||
function parseToolsModeRepositoryProperty(name, value, logger) {
|
||||
if (value !== "dynamic" /* Dynamic */ && value !== "enforce" /* Enforce */) {
|
||||
logger.warning(
|
||||
`Repository property '${name}' has unexpected value '${value}'. Expected 'dynamic' or 'enforce'. Defaulting to 'enforce'.`
|
||||
);
|
||||
return "enforce" /* Enforce */;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
var KNOWN_REPOSITORY_PROPERTY_NAMES = new Set(
|
||||
Object.values(RepositoryPropertyName)
|
||||
);
|
||||
@@ -150959,16 +150999,14 @@ async function prepareDiffInformedAnalysis(codeql, features, logger) {
|
||||
if (!branches) {
|
||||
return false;
|
||||
}
|
||||
return await withGroupAsync("Computing PR diff ranges", async () => {
|
||||
try {
|
||||
return await computeAndPersistDiffRanges(branches, logger);
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to compute diff-informed analysis ranges: ${getErrorMessage(e)}`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return await computeAndPersistDiffRanges(branches, logger);
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to compute diff-informed analysis ranges: ${getErrorMessage(e)}`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function writeDiffRangesJsonFile(logger, ranges) {
|
||||
const jsonContents = JSON.stringify(ranges, null, 2);
|
||||
@@ -151021,6 +151059,7 @@ async function getPullRequestEditedDiffRanges(branches, logger) {
|
||||
return results;
|
||||
}
|
||||
async function computeAndPersistDiffRanges(branches, logger) {
|
||||
logger.info("Computing PR diff ranges...");
|
||||
const ranges = await getPullRequestEditedDiffRanges(branches, logger);
|
||||
if (ranges === void 0) {
|
||||
return false;
|
||||
@@ -151524,7 +151563,7 @@ async function getTrapCachesForLanguage(allCaches, language, logger) {
|
||||
}
|
||||
async function getLanguagesSupportingCaching(codeql, languages, logger) {
|
||||
const result = [];
|
||||
const resolveResult = await codeql.betterResolveLanguages();
|
||||
const resolveResult = await codeql.resolveLanguages();
|
||||
outer: for (const lang of languages) {
|
||||
const extractorsForLanguage = resolveResult.extractors[lang];
|
||||
if (extractorsForLanguage === void 0) {
|
||||
@@ -151577,7 +151616,7 @@ async function getSupportedLanguageMap(codeql, logger) {
|
||||
const resolveSupportedLanguagesUsingCli = await codeql.supportsFeature(
|
||||
"builtinExtractorsSpecifyDefaultQueries" /* BuiltinExtractorsSpecifyDefaultQueries */
|
||||
);
|
||||
const resolveResult = await codeql.betterResolveLanguages({
|
||||
const resolveResult = await codeql.resolveLanguages({
|
||||
filterToLanguagesWithQueries: resolveSupportedLanguagesUsingCli
|
||||
});
|
||||
if (resolveSupportedLanguagesUsingCli) {
|
||||
@@ -153419,7 +153458,7 @@ async function getCodeQLSource(toolsInput, defaultCliVersion, rawLanguages, useO
|
||||
);
|
||||
} else {
|
||||
if (allowToolcacheValueFF) {
|
||||
logger.warning(
|
||||
logger.info(
|
||||
`Ignoring 'tools: ${toolsInput}' because the workflow was not triggered dynamically.`
|
||||
);
|
||||
} else {
|
||||
@@ -154075,23 +154114,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
];
|
||||
await runCli(cmd, args);
|
||||
},
|
||||
async resolveLanguages() {
|
||||
const codeqlArgs = [
|
||||
"resolve",
|
||||
"languages",
|
||||
"--format=json",
|
||||
...getExtraOptionsFromEnv(["resolve", "languages"])
|
||||
];
|
||||
const output = await runCli(cmd, codeqlArgs);
|
||||
try {
|
||||
return JSON.parse(output);
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Unexpected output from codeql resolve languages: ${e}`
|
||||
);
|
||||
}
|
||||
},
|
||||
async betterResolveLanguages({
|
||||
async resolveLanguages({
|
||||
filterToLanguagesWithQueries
|
||||
} = { filterToLanguagesWithQueries: false }) {
|
||||
const codeqlArgs = [
|
||||
@@ -156760,7 +156783,7 @@ var fs19 = __toESM(require("fs"));
|
||||
var path17 = __toESM(require("path"));
|
||||
var core14 = __toESM(require_core());
|
||||
var toolrunner4 = __toESM(require_toolrunner());
|
||||
var github2 = __toESM(require_github());
|
||||
var github3 = __toESM(require_github());
|
||||
var io6 = __toESM(require_io());
|
||||
async function initCodeQL(toolsInput, apiDetails, tempDir, variant, defaultCliVersion, rawLanguages, useOverlayAwareDefaultCliVersion, features, logger) {
|
||||
logger.startGroup("Setup CodeQL tools");
|
||||
@@ -156964,7 +156987,7 @@ function logFileCoverageOnPrsDeprecationWarning(logger) {
|
||||
if (process.env["CODEQL_ACTION_DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION" /* DID_LOG_FILE_COVERAGE_ON_PRS_DEPRECATION */]) {
|
||||
return;
|
||||
}
|
||||
const repositoryOwnerType = github2.context.payload.repository?.owner.type;
|
||||
const repositoryOwnerType = github3.context.payload.repository?.owner.type;
|
||||
let message = "Starting April 2026, the CodeQL Action will skip computing file coverage information on pull requests to improve analysis performance. File coverage information will still be computed on non-PR analyses.";
|
||||
const envVarOptOut = "set the `CODEQL_ACTION_FILE_COVERAGE_ON_PRS` environment variable to `true`.";
|
||||
const repoPropertyOptOut = 'create a custom repository property with the name `github-codeql-file-coverage-on-prs` and the type "True/false", then set this property to `true` in the repository\'s settings.';
|
||||
@@ -158752,10 +158775,50 @@ async function runWrapper3() {
|
||||
var fs27 = __toESM(require("fs"));
|
||||
var path23 = __toESM(require("path"));
|
||||
var core21 = __toESM(require_core());
|
||||
var github3 = __toESM(require_github());
|
||||
var io7 = __toESM(require_io());
|
||||
var semver10 = __toESM(require_semver2());
|
||||
|
||||
// src/config/resolve-tools-input.ts
|
||||
function resolveToolsInputWithMetadata(toolsWorkflowInput, isDynamicWorkflow2, repositoryProperties, logger) {
|
||||
if (toolsWorkflowInput) {
|
||||
logger.info(
|
||||
`Setting tools: ${toolsWorkflowInput} based on workflow input.`
|
||||
);
|
||||
return {
|
||||
effectiveToolsInput: toolsWorkflowInput,
|
||||
effectiveToolsInputSource: "workflow-input" /* WorkflowInput */,
|
||||
toolsRepoPropertyMode: void 0
|
||||
};
|
||||
}
|
||||
const toolsPropertyValue = repositoryProperties["github-codeql-tools" /* TOOLS */];
|
||||
const toolsMode = repositoryProperties["github-codeql-tools-mode" /* TOOLS_MODE */] ?? "enforce" /* Enforce */;
|
||||
if (toolsPropertyValue && toolsMode === "dynamic" /* Dynamic */ && !isDynamicWorkflow2) {
|
||||
logger.info(
|
||||
`Ignoring '${"github-codeql-tools" /* TOOLS */}' repository property because '${"github-codeql-tools-mode" /* TOOLS_MODE */}' is set to '${toolsMode}' and this is not a dynamic workflow.`
|
||||
);
|
||||
return {
|
||||
effectiveToolsInput: void 0,
|
||||
effectiveToolsInputSource: "none" /* None */,
|
||||
toolsRepoPropertyMode: toolsMode
|
||||
};
|
||||
}
|
||||
if (toolsPropertyValue) {
|
||||
logger.info(
|
||||
`Setting tools: ${toolsPropertyValue} based on the '${"github-codeql-tools" /* TOOLS */}' repository property (mode: '${toolsMode}').`
|
||||
);
|
||||
return {
|
||||
effectiveToolsInput: toolsPropertyValue,
|
||||
effectiveToolsInputSource: "repository-property" /* RepositoryProperty */,
|
||||
toolsRepoPropertyMode: toolsMode
|
||||
};
|
||||
}
|
||||
return {
|
||||
effectiveToolsInput: void 0,
|
||||
effectiveToolsInputSource: "none" /* None */,
|
||||
toolsRepoPropertyMode: void 0
|
||||
};
|
||||
}
|
||||
|
||||
// src/workflow.ts
|
||||
var fs26 = __toESM(require("fs"));
|
||||
var path22 = __toESM(require("path"));
|
||||
@@ -158776,7 +158839,7 @@ var WorkflowErrors = toCodedErrors({
|
||||
InconsistentActionVersion: `Not all workflow steps that use \`github/codeql-action\` actions use the same version. Please ensure that all such steps use the same version to avoid compatibility issues.`
|
||||
});
|
||||
async function groupLanguagesByExtractor(languages, codeql) {
|
||||
const resolveResult = await codeql.betterResolveLanguages();
|
||||
const resolveResult = await codeql.resolveLanguages();
|
||||
if (!resolveResult.aliases) {
|
||||
return void 0;
|
||||
}
|
||||
@@ -159046,7 +159109,7 @@ async function sendStartingStatusReport(startedAt, config, logger) {
|
||||
await sendStatusReport(statusReportBase);
|
||||
}
|
||||
}
|
||||
async function sendCompletedStatusReport2(startedAt, config, configFile, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, overlayBaseDatabaseStats, dependencyCachingResults, logger, error3) {
|
||||
async function sendCompletedStatusReport2(startedAt, config, configFile, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, effectiveToolsInput, effectiveToolsInputSource, toolsRepoPropertyMode, overlayBaseDatabaseStats, dependencyCachingResults, logger, error3) {
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"init" /* Init */,
|
||||
getActionsStatus(error3),
|
||||
@@ -159064,6 +159127,9 @@ async function sendCompletedStatusReport2(startedAt, config, configFile, toolsDo
|
||||
const initStatusReport = {
|
||||
...statusReportBase,
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
effective_tools_input: effectiveToolsInput || "",
|
||||
effective_tools_input_source: effectiveToolsInputSource,
|
||||
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || "UNKNOWN" /* Unknown */,
|
||||
workflow_languages: workflowLanguages || ""
|
||||
@@ -159107,6 +159173,9 @@ async function run3(startedAt) {
|
||||
let toolsSource;
|
||||
let toolsVersion;
|
||||
let zstdAvailability;
|
||||
let effectiveToolsInput;
|
||||
let effectiveToolsInputSource;
|
||||
let toolsRepoPropertyMode;
|
||||
try {
|
||||
initializeEnvironment(getActionVersion());
|
||||
persistInputs();
|
||||
@@ -159130,6 +159199,7 @@ async function run3(startedAt) {
|
||||
repositoryNwo,
|
||||
logger
|
||||
);
|
||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||
const jobRunUuid = v4_default();
|
||||
logger.info(`Job run UUID is ${jobRunUuid}.`);
|
||||
core21.exportVariable("JOB_RUN_UUID" /* JOB_RUN_UUID */, jobRunUuid);
|
||||
@@ -159155,12 +159225,21 @@ async function run3(startedAt) {
|
||||
}
|
||||
const codeQLDefaultVersionInfo = await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||
getOptionalInput("tools"),
|
||||
isDynamicWorkflow(),
|
||||
repositoryProperties,
|
||||
logger
|
||||
);
|
||||
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||
getOptionalInput("languages")
|
||||
);
|
||||
const useOverlayAwareDefaultCliVersion = analysisKinds?.length === 1 && analysisKinds[0] === "code-scanning" /* CodeScanning */;
|
||||
const initCodeQLResult = await initCodeQL(
|
||||
getOptionalInput("tools"),
|
||||
effectiveToolsInput,
|
||||
apiDetails,
|
||||
getTemporaryDirectory(),
|
||||
gitHubVersion.type,
|
||||
@@ -159196,7 +159275,6 @@ async function run3(startedAt) {
|
||||
}
|
||||
analysisKinds = await getAnalysisKinds(logger, features);
|
||||
const debugMode = getOptionalInput("debug") === "true" || core21.isDebug();
|
||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||
const fileCoverageResult = await getFileCoverageInformationEnabled(
|
||||
debugMode,
|
||||
codeql,
|
||||
@@ -159497,6 +159575,9 @@ exec ${goBinaryPath} "$@"`
|
||||
toolsFeatureFlagsValid,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingStatus,
|
||||
logger,
|
||||
@@ -159514,31 +159595,14 @@ exec ${goBinaryPath} "$@"`
|
||||
toolsFeatureFlagsValid,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingStatus,
|
||||
logger
|
||||
);
|
||||
}
|
||||
async function loadRepositoryProperties(repositoryNwo, logger) {
|
||||
const repositoryOwnerType = github3.context.payload.repository?.owner.type;
|
||||
logger.debug(
|
||||
`Repository owner type is '${repositoryOwnerType ?? "unknown"}'.`
|
||||
);
|
||||
if (repositoryOwnerType === "User") {
|
||||
logger.debug(
|
||||
"Skipping loading repository properties because the repository is owned by a user and therefore cannot have repository properties."
|
||||
);
|
||||
return new Success({});
|
||||
}
|
||||
try {
|
||||
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
||||
} catch (error3) {
|
||||
logger.warning(
|
||||
`Failed to load repository properties: ${getErrorMessage(error3)}`
|
||||
);
|
||||
return new Failure(error3);
|
||||
}
|
||||
}
|
||||
async function recordZstdAvailability(config, zstdAvailability) {
|
||||
addNoLanguageDiagnostic(
|
||||
config,
|
||||
@@ -160107,7 +160171,7 @@ async function runWrapper6() {
|
||||
|
||||
// src/setup-codeql-action.ts
|
||||
var core24 = __toESM(require_core());
|
||||
async function sendCompletedStatusReport3(startedAt, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, logger, error3) {
|
||||
async function sendCompletedStatusReport3(startedAt, toolsDownloadStatusReport, toolsFeatureFlagsValid, toolsSource, toolsVersion, effectiveToolsInput, effectiveToolsInputSource, toolsRepoPropertyMode, logger, error3) {
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
"setup-codeql" /* SetupCodeQL */,
|
||||
getActionsStatus(error3),
|
||||
@@ -160124,6 +160188,9 @@ async function sendCompletedStatusReport3(startedAt, toolsDownloadStatusReport,
|
||||
const initStatusReport = {
|
||||
...statusReportBase,
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
effective_tools_input: effectiveToolsInput || "",
|
||||
effective_tools_input_source: effectiveToolsInputSource,
|
||||
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || "UNKNOWN" /* Unknown */,
|
||||
workflow_languages: ""
|
||||
@@ -160144,6 +160211,9 @@ async function run6(startedAt) {
|
||||
let toolsFeatureFlagsValid;
|
||||
let toolsSource;
|
||||
let toolsVersion;
|
||||
let effectiveToolsInput;
|
||||
let effectiveToolsInputSource;
|
||||
let toolsRepoPropertyMode;
|
||||
try {
|
||||
initializeEnvironment(getActionVersion());
|
||||
const apiDetails = {
|
||||
@@ -160178,12 +160248,26 @@ async function run6(startedAt) {
|
||||
}
|
||||
const codeQLDefaultVersionInfo = await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||
const repositoryPropertiesResult = await loadRepositoryProperties(
|
||||
repositoryNwo,
|
||||
logger
|
||||
);
|
||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||
getOptionalInput("tools"),
|
||||
isDynamicWorkflow(),
|
||||
repositoryProperties,
|
||||
logger
|
||||
);
|
||||
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||
getOptionalInput("languages")
|
||||
);
|
||||
const analysisKinds = await getAnalysisKinds(logger, features);
|
||||
const initCodeQLResult = await initCodeQL(
|
||||
getOptionalInput("tools"),
|
||||
effectiveToolsInput,
|
||||
apiDetails,
|
||||
getTemporaryDirectory(),
|
||||
gitHubVersion.type,
|
||||
@@ -160224,6 +160308,9 @@ async function run6(startedAt) {
|
||||
toolsFeatureFlagsValid,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
logger
|
||||
);
|
||||
}
|
||||
|
||||
Generated
+68
-68
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "4.36.2",
|
||||
"version": "4.36.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "codeql",
|
||||
"version": "4.36.2",
|
||||
"version": "4.36.3",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"pr-checks"
|
||||
@@ -32,7 +32,7 @@
|
||||
"jsonschema": "1.5.0",
|
||||
"long": "^5.3.2",
|
||||
"node-forge": "^1.4.0",
|
||||
"semver": "^7.8.0",
|
||||
"semver": "^7.8.1",
|
||||
"uuid": "^14.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -61,7 +61,7 @@
|
||||
"nock": "^14.0.15",
|
||||
"sinon": "^22.0.0",
|
||||
"typescript": "^6.0.3",
|
||||
"typescript-eslint": "^8.59.4"
|
||||
"typescript-eslint": "^8.60.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@aashutoshrathi/word-wrap": {
|
||||
@@ -2528,17 +2528,17 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.59.4.tgz",
|
||||
"integrity": "sha512-PegsU+XfyJJNjd4+u/k6f9yTyp0lEXXiPopUNobZcIAUJFGICFLN+sP0Rb3JehVmiij1Ph0dFGYqODoRo/2+6A==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.60.0.tgz",
|
||||
"integrity": "sha512-QYb/sa74/s7OKMbACMjrYnGspj9Hs5YI5aaffSL65UfeBUzVzBJfVo3oWSpbzPurvm7yaCCo2Lk7lVj610HqKw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.12.2",
|
||||
"@typescript-eslint/scope-manager": "8.59.4",
|
||||
"@typescript-eslint/type-utils": "8.59.4",
|
||||
"@typescript-eslint/utils": "8.59.4",
|
||||
"@typescript-eslint/visitor-keys": "8.59.4",
|
||||
"@typescript-eslint/scope-manager": "8.60.0",
|
||||
"@typescript-eslint/type-utils": "8.60.0",
|
||||
"@typescript-eslint/utils": "8.60.0",
|
||||
"@typescript-eslint/visitor-keys": "8.60.0",
|
||||
"ignore": "^7.0.5",
|
||||
"natural-compare": "^1.4.0",
|
||||
"ts-api-utils": "^2.5.0"
|
||||
@@ -2551,7 +2551,7 @@
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@typescript-eslint/parser": "^8.59.4",
|
||||
"@typescript-eslint/parser": "^8.60.0",
|
||||
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
||||
"typescript": ">=4.8.4 <6.1.0"
|
||||
}
|
||||
@@ -2567,16 +2567,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/parser": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.59.4.tgz",
|
||||
"integrity": "sha512-zORHqO/tuhxY1zWuTvMUqddRxpiFJ72xVfcNoWpqdLjs6lfPbuQBJuW4pk+49/uBMy7Ssr4bzgjiKmmDB1UbZQ==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.60.0.tgz",
|
||||
"integrity": "sha512-fcqpj/MyK4sxDPcbe7STNPbpQL4RLZOPWuaTmwZYuc+hJKzRf58yRxfhqGpc6PIq9ZyfSBpfHgmUHmHs0KwHwg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/scope-manager": "8.59.4",
|
||||
"@typescript-eslint/types": "8.59.4",
|
||||
"@typescript-eslint/typescript-estree": "8.59.4",
|
||||
"@typescript-eslint/visitor-keys": "8.59.4",
|
||||
"@typescript-eslint/scope-manager": "8.60.0",
|
||||
"@typescript-eslint/types": "8.60.0",
|
||||
"@typescript-eslint/typescript-estree": "8.60.0",
|
||||
"@typescript-eslint/visitor-keys": "8.60.0",
|
||||
"debug": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
@@ -2610,14 +2610,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/project-service": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.59.4.tgz",
|
||||
"integrity": "sha512-Ly00Vu4oAacfDeHp2Zg85ioNG6l8HG+tN1D7J+xTHSxu9y0awYKJ2zH1rFBn8ZSfuGK+7FxK3Cgl3uAz0aZZLg==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.60.0.tgz",
|
||||
"integrity": "sha512-aZu74NNKJeUWqCjDddzdiKaS82dgYgV/vmf+Ui3ZdZejmgfXR/q+pRumgobnQ2cCJTgGTWp4ypiwsuofFubavg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/tsconfig-utils": "^8.59.4",
|
||||
"@typescript-eslint/types": "^8.59.4",
|
||||
"@typescript-eslint/tsconfig-utils": "^8.60.0",
|
||||
"@typescript-eslint/types": "^8.60.0",
|
||||
"debug": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
@@ -2650,14 +2650,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.59.4.tgz",
|
||||
"integrity": "sha512-mUeR/3H1WrTAddJrwut8OoPjfauaztMQmRwV5fQTUyNVJCLiUXXe4lGEyYIL2oFDpP7UtgbGJXCt72wT0z2S3Q==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.60.0.tgz",
|
||||
"integrity": "sha512-pFzqhllJMs+jghLQWzV00ds39xLzuyqPSev5pd8f4Ir0rtKR3ZLUB4/4dhjOFighWb9larvtfJvqL+4yKDI3Xw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.59.4",
|
||||
"@typescript-eslint/visitor-keys": "8.59.4"
|
||||
"@typescript-eslint/types": "8.60.0",
|
||||
"@typescript-eslint/visitor-keys": "8.60.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -2668,9 +2668,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/tsconfig-utils": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.59.4.tgz",
|
||||
"integrity": "sha512-DLCpnKgD4alVxTBSKulK+gU1KCqOgUXfDRDXh2mZgzokQKa/70ax93I2uVO3m/LLvIAtWZIFoiifudmIqAxpMA==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.60.0.tgz",
|
||||
"integrity": "sha512-BZPR3RGYlAXnly6ymAxfkVn5rCbZzQNou0rxv3GfWZ8cTQp+hhVd73khbGLAd8k1TlAPLISH337M+tAgAnaJDQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -2685,15 +2685,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.59.4.tgz",
|
||||
"integrity": "sha512-uonTuPAAKr9XaBGqJ3LjYTh72zy5DyGesljO9gtmk/eFW0W1fRHjnwVYKB35Lm8d5Q5CluEW3gPHjTvZTmgrfA==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.60.0.tgz",
|
||||
"integrity": "sha512-SX46wEUtitCpq7AN38HkUU/+zvUpdKf7ephtWAFgckH8O7PQIyL5gvrhQgBLuEYgLfuKWOVvWVskMbuFHAz5xg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.59.4",
|
||||
"@typescript-eslint/typescript-estree": "8.59.4",
|
||||
"@typescript-eslint/utils": "8.59.4",
|
||||
"@typescript-eslint/types": "8.60.0",
|
||||
"@typescript-eslint/typescript-estree": "8.60.0",
|
||||
"@typescript-eslint/utils": "8.60.0",
|
||||
"debug": "^4.4.3",
|
||||
"ts-api-utils": "^2.5.0"
|
||||
},
|
||||
@@ -2728,9 +2728,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/types": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.59.4.tgz",
|
||||
"integrity": "sha512-F1o7WJcCq+bc8dwcO/YsSEOudAH8RDtaOhM6wcAQhcUsFhnWQl81JKy48q1hoxAU0qrzM89+31GYh1515Zde3Q==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.60.0.tgz",
|
||||
"integrity": "sha512-AsE7x2XaAK+CVbeih0Fvbn+r1qHxtpLDJ3XUuFcIinT318T90yHMJC+Zgv+jUuDjQQd06HKwxnDu6sz1IcTilA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -2742,16 +2742,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.59.4.tgz",
|
||||
"integrity": "sha512-F+RuOmcDXo4+TPdfd/TCLS3m2nw8gE9XXyZLrA3JBfaA5tz9TtdkyD3YJFmPxulyc2cKbEok/CvFE3MgSLWnag==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.60.0.tgz",
|
||||
"integrity": "sha512-3AcZNBGMClm6CXDyo8kYvVGT/sx29sS0oBsIb9oZI2gunA4Vm2M3YHzRLPvsUBBsl+yB5FPtltq7gGH0iTlp9g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/project-service": "8.59.4",
|
||||
"@typescript-eslint/tsconfig-utils": "8.59.4",
|
||||
"@typescript-eslint/types": "8.59.4",
|
||||
"@typescript-eslint/visitor-keys": "8.59.4",
|
||||
"@typescript-eslint/project-service": "8.60.0",
|
||||
"@typescript-eslint/tsconfig-utils": "8.60.0",
|
||||
"@typescript-eslint/types": "8.60.0",
|
||||
"@typescript-eslint/visitor-keys": "8.60.0",
|
||||
"debug": "^4.4.3",
|
||||
"minimatch": "^10.2.2",
|
||||
"semver": "^7.7.3",
|
||||
@@ -2827,16 +2827,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.59.4.tgz",
|
||||
"integrity": "sha512-cYXeNAUsG4lJo5dbc1FcKm+JwIWrj1/UpTORsC6tGMjEZ81DYcvIr9/ueikhMa/Y/gDQYGp+YX9/xQrXje5BJw==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.60.0.tgz",
|
||||
"integrity": "sha512-HtXuPfrHTyBDkameWpl+vJb1Uevu2tznAyahM1Oc4AENidCLTPiZDWIo4GfcxNdC/RcfGcadzzkqbRG87dUrQA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.9.1",
|
||||
"@typescript-eslint/scope-manager": "8.59.4",
|
||||
"@typescript-eslint/types": "8.59.4",
|
||||
"@typescript-eslint/typescript-estree": "8.59.4"
|
||||
"@typescript-eslint/scope-manager": "8.60.0",
|
||||
"@typescript-eslint/types": "8.60.0",
|
||||
"@typescript-eslint/typescript-estree": "8.60.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
@@ -2851,13 +2851,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.59.4.tgz",
|
||||
"integrity": "sha512-U3gxVaDVnuZKhSspW/MzMxE1kq7zOdc072FcSNoqA1I9p8HyKbBFfEHoWckBAMgNMph4MamwS5iTVzFmrnt8TQ==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.60.0.tgz",
|
||||
"integrity": "sha512-9WI52t8ZGLVGrPMBet25yAftqY/n95+zmoUUtJBBQTKDSKUu7OsPTroT2op7U9JatkoRccL0YkWDNMFfC4Sjxg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "8.59.4",
|
||||
"@typescript-eslint/types": "8.60.0",
|
||||
"eslint-visitor-keys": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
@@ -8311,9 +8311,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "7.8.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.0.tgz",
|
||||
"integrity": "sha512-AcM7dV/5ul4EekoQ29Agm5vri8JNqRyj39o0qpX6vDF2GZrtutZl5RwgD1XnZjiTAfncsJhMI48QQH3sN87YNA==",
|
||||
"version": "7.8.1",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.8.1.tgz",
|
||||
"integrity": "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
@@ -9292,16 +9292,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript-eslint": {
|
||||
"version": "8.59.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.59.4.tgz",
|
||||
"integrity": "sha512-Rw6+44QNFaXtgHSjPy+Kw8hrJniMYzR85E9yLmOLcfZ91/rz+JXQbDTCmc6ccxMPY6K6PgAq26f0JCBfR7LIPQ==",
|
||||
"version": "8.60.0",
|
||||
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.60.0.tgz",
|
||||
"integrity": "sha512-9f65qWLZdAW9m1JaxBDUHcqRUfL8bkxxXL7XxEfI+F09q56PkBvIfCjLF3yInsDM/BBmwkqmCQdCZe/RYlIWEw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "8.59.4",
|
||||
"@typescript-eslint/parser": "8.59.4",
|
||||
"@typescript-eslint/typescript-estree": "8.59.4",
|
||||
"@typescript-eslint/utils": "8.59.4"
|
||||
"@typescript-eslint/eslint-plugin": "8.60.0",
|
||||
"@typescript-eslint/parser": "8.60.0",
|
||||
"@typescript-eslint/typescript-estree": "8.60.0",
|
||||
"@typescript-eslint/utils": "8.60.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "4.36.2",
|
||||
"version": "4.36.3",
|
||||
"private": true,
|
||||
"description": "CodeQL action",
|
||||
"scripts": {
|
||||
@@ -40,7 +40,7 @@
|
||||
"jsonschema": "1.5.0",
|
||||
"long": "^5.3.2",
|
||||
"node-forge": "^1.4.0",
|
||||
"semver": "^7.8.0",
|
||||
"semver": "^7.8.1",
|
||||
"uuid": "^14.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -69,7 +69,7 @@
|
||||
"nock": "^14.0.15",
|
||||
"sinon": "^22.0.0",
|
||||
"typescript": "^6.0.3",
|
||||
"typescript-eslint": "^8.59.4"
|
||||
"typescript-eslint": "^8.60.0"
|
||||
},
|
||||
"overrides": {
|
||||
"@actions/tool-cache": {
|
||||
|
||||
@@ -30,7 +30,7 @@ import {
|
||||
} from "./dependency-caching";
|
||||
import { EnvVar } from "./environment";
|
||||
import { initFeatures } from "./feature-flags";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { cleanupAndUploadOverlayBaseDatabaseToCache } from "./overlay/caching";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import {
|
||||
} from "./analyze";
|
||||
import { createStubCodeQL } from "./codeql";
|
||||
import { Feature } from "./feature-flags";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import {
|
||||
setupTests,
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import {
|
||||
} from "./diff-informed-analysis-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { FeatureEnablement, Feature } from "./feature-flags";
|
||||
import { BuiltInLanguage, Language } from "./languages";
|
||||
import { BuiltInLanguage, Language } from "./languages/index";
|
||||
import { Logger, withGroupAsync } from "./logging";
|
||||
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
||||
import type * as sarif from "./sarif";
|
||||
|
||||
@@ -10,7 +10,7 @@ import { determineAutobuildLanguages, runAutobuild } from "./autobuild";
|
||||
import { getCodeQL } from "./codeql";
|
||||
import { Config, getConfig } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Language } from "./languages";
|
||||
import { Language } from "./languages/index";
|
||||
import { Logger, getActionsLogger } from "./logging";
|
||||
import {
|
||||
StatusReportBase,
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import * as configUtils from "./config-utils";
|
||||
import { DocUrl } from "./doc-url";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Feature, featureConfig, initFeatures } from "./feature-flags";
|
||||
import { BuiltInLanguage, Language } from "./languages";
|
||||
import { BuiltInLanguage, Language } from "./languages/index";
|
||||
import { Logger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
import { asyncFilter, BuildMode } from "./util";
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import {
|
||||
import type { Config } from "./config-utils";
|
||||
import * as defaults from "./defaults.json";
|
||||
import { DocUrl } from "./doc-url";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { ToolsSource } from "./setup-codeql";
|
||||
import {
|
||||
|
||||
+11
-39
@@ -22,7 +22,7 @@ import {
|
||||
FeatureEnablement,
|
||||
} from "./feature-flags";
|
||||
import { isAnalyzingDefaultBranch } from "./git-utils";
|
||||
import { Language } from "./languages";
|
||||
import { Language } from "./languages/index";
|
||||
import { Logger } from "./logging";
|
||||
import { writeBaseDatabaseOidsFile, writeOverlayChangesFile } from "./overlay";
|
||||
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
||||
@@ -117,16 +117,12 @@ export interface CodeQL {
|
||||
memoryFlag: string,
|
||||
enableDebugLogging: boolean,
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Run 'codeql resolve languages'.
|
||||
*/
|
||||
resolveLanguages(): Promise<ResolveLanguagesOutput>;
|
||||
/**
|
||||
* Run 'codeql resolve languages' with '--format=betterjson'.
|
||||
*/
|
||||
betterResolveLanguages(options?: {
|
||||
resolveLanguages(options?: {
|
||||
filterToLanguagesWithQueries: boolean;
|
||||
}): Promise<BetterResolveLanguagesOutput>;
|
||||
}): Promise<ResolveLanguagesOutput>;
|
||||
/**
|
||||
* Run 'codeql resolve build-environment'
|
||||
*/
|
||||
@@ -239,20 +235,14 @@ export interface ResolveDatabaseOutput {
|
||||
}
|
||||
|
||||
export interface ResolveLanguagesOutput {
|
||||
[language: string]: [string];
|
||||
}
|
||||
|
||||
export interface BetterResolveLanguagesOutput {
|
||||
aliases?: {
|
||||
[alias: string]: string;
|
||||
};
|
||||
extractors: {
|
||||
[language: string]: [
|
||||
{
|
||||
extractor_root: string;
|
||||
extractor_options?: any;
|
||||
},
|
||||
];
|
||||
[language: string]: Array<{
|
||||
extractor_root: string;
|
||||
extractor_options?: any;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -460,10 +450,9 @@ export function createStubCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
|
||||
"extractUsingBuildMode",
|
||||
),
|
||||
finalizeDatabase: resolveFunction(partialCodeql, "finalizeDatabase"),
|
||||
resolveLanguages: resolveFunction(partialCodeql, "resolveLanguages"),
|
||||
betterResolveLanguages: resolveFunction(
|
||||
resolveLanguages: resolveFunction(
|
||||
partialCodeql,
|
||||
"betterResolveLanguages",
|
||||
"resolveLanguages",
|
||||
async () => ({ aliases: {}, extractors: {} }),
|
||||
),
|
||||
resolveBuildEnvironment: resolveFunction(
|
||||
@@ -735,24 +724,7 @@ async function getCodeQLForCmd(
|
||||
];
|
||||
await runCli(cmd, args);
|
||||
},
|
||||
async resolveLanguages() {
|
||||
const codeqlArgs = [
|
||||
"resolve",
|
||||
"languages",
|
||||
"--format=json",
|
||||
...getExtraOptionsFromEnv(["resolve", "languages"]),
|
||||
];
|
||||
const output = await runCli(cmd, codeqlArgs);
|
||||
|
||||
try {
|
||||
return JSON.parse(output) as ResolveLanguagesOutput;
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Unexpected output from codeql resolve languages: ${e}`,
|
||||
);
|
||||
}
|
||||
},
|
||||
async betterResolveLanguages(
|
||||
async resolveLanguages(
|
||||
{
|
||||
filterToLanguagesWithQueries,
|
||||
}: {
|
||||
@@ -773,7 +745,7 @@ async function getCodeQLForCmd(
|
||||
const output = await runCli(cmd, codeqlArgs);
|
||||
|
||||
try {
|
||||
return JSON.parse(output) as BetterResolveLanguagesOutput;
|
||||
return JSON.parse(output) as ResolveLanguagesOutput;
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Unexpected output from codeql resolve languages with --format=betterjson: ${e}`,
|
||||
|
||||
+12
-12
@@ -18,7 +18,7 @@ import { Feature } from "./feature-flags";
|
||||
import { RepositoryProperties } from "./feature-flags/properties";
|
||||
import * as gitUtils from "./git-utils";
|
||||
import { GitVersionInfo } from "./git-utils";
|
||||
import { BuiltInLanguage, Language } from "./languages";
|
||||
import { BuiltInLanguage, Language } from "./languages/index";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay";
|
||||
import * as overlayDiagnostics from "./overlay/diagnostics";
|
||||
@@ -75,7 +75,7 @@ function createTestInitConfigInputs(
|
||||
repository: { owner: "github", repo: "example" },
|
||||
tempDir: "",
|
||||
codeql: createStubCodeQL({
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
html: [{ extractor_root: "" }],
|
||||
@@ -150,7 +150,7 @@ test.serial("load empty config", async (t) => {
|
||||
setupActionsVars(tempDir, tempDir);
|
||||
|
||||
const codeql = createStubCodeQL({
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
javascript: [{ extractor_root: "" }],
|
||||
@@ -193,7 +193,7 @@ test.serial("load code quality config", async (t) => {
|
||||
setupActionsVars(tempDir, tempDir);
|
||||
|
||||
const codeql = createStubCodeQL({
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
actions: [{ extractor_root: "" }],
|
||||
@@ -247,7 +247,7 @@ test.serial(
|
||||
setupActionsVars(tempDir, tempDir);
|
||||
|
||||
const codeql = createStubCodeQL({
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
javascript: [{ extractor_root: "" }],
|
||||
@@ -305,7 +305,7 @@ test.serial("loading a saved config produces the same config", async (t) => {
|
||||
const logger = getRunnerLogger(true);
|
||||
|
||||
const codeql = createStubCodeQL({
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
javascript: [{ extractor_root: "" }],
|
||||
@@ -352,7 +352,7 @@ test.serial("loading config with version mismatch throws", async (t) => {
|
||||
const logger = getRunnerLogger(true);
|
||||
|
||||
const codeql = createStubCodeQL({
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
javascript: [{ extractor_root: "" }],
|
||||
@@ -487,7 +487,7 @@ test.serial("load non-empty input", async (t) => {
|
||||
setupActionsVars(tempDir, tempDir);
|
||||
|
||||
const codeql = createStubCodeQL({
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
javascript: [{ extractor_root: "" }],
|
||||
@@ -582,7 +582,7 @@ test.serial(
|
||||
fs.mkdirSync(path.join(tempDir, "foo"));
|
||||
|
||||
const codeql = createStubCodeQL({
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
javascript: [{ extractor_root: "" }],
|
||||
@@ -615,7 +615,7 @@ test.serial(
|
||||
test.serial("API client used when reading remote config", async (t) => {
|
||||
return await withTmpDir(async (tempDir) => {
|
||||
const codeql = createStubCodeQL({
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
javascript: [{ extractor_root: "" }],
|
||||
@@ -725,7 +725,7 @@ test.serial("No detected languages", async (t) => {
|
||||
mockListLanguages([]);
|
||||
const codeql = createStubCodeQL({
|
||||
async resolveLanguages() {
|
||||
return {};
|
||||
return { extractors: {} };
|
||||
},
|
||||
});
|
||||
|
||||
@@ -891,7 +891,7 @@ const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
extractor_root: "",
|
||||
};
|
||||
const codeQL = createStubCodeQL({
|
||||
betterResolveLanguages: (options) =>
|
||||
resolveLanguages: (options) =>
|
||||
Promise.resolve({
|
||||
aliases: {
|
||||
"c#": BuiltInLanguage.csharp,
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ import {
|
||||
hasSubmodules,
|
||||
isAnalyzingDefaultBranch,
|
||||
} from "./git-utils";
|
||||
import { BuiltInLanguage, Language } from "./languages";
|
||||
import { BuiltInLanguage, Language } from "./languages/index";
|
||||
import { Logger } from "./logging";
|
||||
import { CODEQL_OVERLAY_MINIMUM_VERSION } from "./overlay";
|
||||
import {
|
||||
@@ -266,7 +266,7 @@ async function getSupportedLanguageMap(
|
||||
const resolveSupportedLanguagesUsingCli = await codeql.supportsFeature(
|
||||
ToolsFeature.BuiltinExtractorsSpecifyDefaultQueries,
|
||||
);
|
||||
const resolveResult = await codeql.betterResolveLanguages({
|
||||
const resolveResult = await codeql.resolveLanguages({
|
||||
filterToLanguagesWithQueries: resolveSupportedLanguagesUsingCli,
|
||||
});
|
||||
if (resolveSupportedLanguagesUsingCli) {
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
import test from "ava";
|
||||
|
||||
import {
|
||||
EffectiveToolsInputSource,
|
||||
resolveToolsInput,
|
||||
resolveToolsInputWithMetadata,
|
||||
} from "../config/resolve-tools-input";
|
||||
import {
|
||||
RepositoryPropertyName,
|
||||
ToolsModeRepositoryPropertyValue,
|
||||
} from "../feature-flags/properties";
|
||||
import type { RepositoryProperties } from "../feature-flags/properties";
|
||||
import {
|
||||
getRecordingLogger,
|
||||
LoggedMessage,
|
||||
setupTests,
|
||||
} from "../testing-utils";
|
||||
|
||||
setupTests(test);
|
||||
|
||||
test("resolveToolsInput returns undefined when no tools input or repository property is set", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const result = resolveToolsInput(undefined, false, {}, logger);
|
||||
|
||||
t.is(result, undefined);
|
||||
t.is(loggedMessages.length, 0);
|
||||
});
|
||||
|
||||
test("resolveToolsInput returns workflow input when only workflow input is provided", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const result = resolveToolsInput("latest", false, {}, logger);
|
||||
|
||||
t.is(result, "latest");
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: latest based on workflow input.",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveToolsInput returns repository property when only repository property is provided", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const repositoryProperties: RepositoryProperties = {
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
};
|
||||
const result = resolveToolsInput(
|
||||
undefined,
|
||||
false,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result, "toolcache");
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveToolsInput prioritizes workflow input over repository property", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const repositoryProperties: RepositoryProperties = {
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
};
|
||||
const result = resolveToolsInput(
|
||||
"nightly",
|
||||
false,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result, "nightly");
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: nightly based on workflow input.",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveToolsInput treats empty string workflow input as not set", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const repositoryProperties: RepositoryProperties = {
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
};
|
||||
const result = resolveToolsInput("", false, repositoryProperties, logger);
|
||||
|
||||
t.is(result, "toolcache");
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveToolsInput returns undefined when repository property is undefined", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const repositoryProperties: RepositoryProperties = {
|
||||
[RepositoryPropertyName.TOOLS]: undefined,
|
||||
};
|
||||
const result = resolveToolsInput(
|
||||
undefined,
|
||||
false,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result, undefined);
|
||||
t.is(loggedMessages.length, 0);
|
||||
});
|
||||
|
||||
test("resolveToolsInput returns repository property when workflow input is not set", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const repositoryProperties: RepositoryProperties = {
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
};
|
||||
const result = resolveToolsInput(
|
||||
undefined,
|
||||
false,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result, "toolcache");
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveToolsInput does not log when workflow input and repository property are not set", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const result = resolveToolsInput(undefined, false, {}, logger);
|
||||
|
||||
t.is(result, undefined);
|
||||
t.is(loggedMessages.length, 0);
|
||||
});
|
||||
|
||||
test("resolveToolsInput applies tools property in enforce mode for static workflows", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const repositoryProperties: RepositoryProperties = {
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
[RepositoryPropertyName.TOOLS_MODE]:
|
||||
ToolsModeRepositoryPropertyValue.Enforce,
|
||||
};
|
||||
const result = resolveToolsInput(
|
||||
undefined,
|
||||
false,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result, "toolcache");
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'enforce').",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveToolsInput applies tools property in dynamic mode for dynamic workflows", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const repositoryProperties: RepositoryProperties = {
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
[RepositoryPropertyName.TOOLS_MODE]:
|
||||
ToolsModeRepositoryPropertyValue.Dynamic,
|
||||
};
|
||||
const result = resolveToolsInput(
|
||||
undefined,
|
||||
true,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result, "toolcache");
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Setting tools: toolcache based on the 'github-codeql-tools' repository property (mode: 'dynamic').",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveToolsInput ignores tools property in dynamic mode for static workflows", (t) => {
|
||||
const loggedMessages: LoggedMessage[] = [];
|
||||
const logger = getRecordingLogger(loggedMessages);
|
||||
|
||||
const repositoryProperties: RepositoryProperties = {
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
[RepositoryPropertyName.TOOLS_MODE]:
|
||||
ToolsModeRepositoryPropertyValue.Dynamic,
|
||||
};
|
||||
const result = resolveToolsInput(
|
||||
undefined,
|
||||
false,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result, undefined);
|
||||
t.is(loggedMessages.length, 1);
|
||||
t.is(
|
||||
loggedMessages[0].message,
|
||||
"Ignoring 'github-codeql-tools' repository property because 'github-codeql-tools-mode' is set to 'dynamic' and this is not a dynamic workflow.",
|
||||
);
|
||||
});
|
||||
|
||||
test("resolveToolsInputWithMetadata reports workflow input source", (t) => {
|
||||
const logger = getRecordingLogger([]);
|
||||
|
||||
const result = resolveToolsInputWithMetadata("latest", false, {}, logger);
|
||||
|
||||
t.is(result.effectiveToolsInput, "latest");
|
||||
t.is(
|
||||
result.effectiveToolsInputSource,
|
||||
EffectiveToolsInputSource.WorkflowInput,
|
||||
);
|
||||
t.is(result.toolsRepoPropertyMode, undefined);
|
||||
});
|
||||
|
||||
test("resolveToolsInputWithMetadata reports repository property source and mode", (t) => {
|
||||
const logger = getRecordingLogger([]);
|
||||
|
||||
const result = resolveToolsInputWithMetadata(
|
||||
undefined,
|
||||
false,
|
||||
{
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
[RepositoryPropertyName.TOOLS_MODE]:
|
||||
ToolsModeRepositoryPropertyValue.Enforce,
|
||||
},
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result.effectiveToolsInput, "toolcache");
|
||||
t.is(
|
||||
result.effectiveToolsInputSource,
|
||||
EffectiveToolsInputSource.RepositoryProperty,
|
||||
);
|
||||
t.is(result.toolsRepoPropertyMode, ToolsModeRepositoryPropertyValue.Enforce);
|
||||
});
|
||||
|
||||
test("resolveToolsInputWithMetadata reports dynamic-mode skip on static workflows", (t) => {
|
||||
const logger = getRecordingLogger([]);
|
||||
|
||||
const result = resolveToolsInputWithMetadata(
|
||||
undefined,
|
||||
false,
|
||||
{
|
||||
[RepositoryPropertyName.TOOLS]: "toolcache",
|
||||
[RepositoryPropertyName.TOOLS_MODE]:
|
||||
ToolsModeRepositoryPropertyValue.Dynamic,
|
||||
},
|
||||
logger,
|
||||
);
|
||||
|
||||
t.is(result.effectiveToolsInput, undefined);
|
||||
t.is(result.effectiveToolsInputSource, EffectiveToolsInputSource.None);
|
||||
t.is(result.toolsRepoPropertyMode, ToolsModeRepositoryPropertyValue.Dynamic);
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
import {
|
||||
RepositoryProperties,
|
||||
RepositoryPropertyName,
|
||||
ToolsModeRepositoryPropertyValue,
|
||||
} from "../feature-flags/properties";
|
||||
import { Logger } from "../logging";
|
||||
|
||||
export enum EffectiveToolsInputSource {
|
||||
WorkflowInput = "workflow-input",
|
||||
RepositoryProperty = "repository-property",
|
||||
None = "none",
|
||||
}
|
||||
|
||||
export type ResolvedToolsInput = {
|
||||
effectiveToolsInput: string | undefined;
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource;
|
||||
toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves the effective tools input by combining the workflow input and repository properties.
|
||||
* The explicit `tools` workflow input takes precedence. If none is provided,
|
||||
* falls back to the repository property (if set). The optional
|
||||
* `github-codeql-tools-mode` repository property controls whether this fallback
|
||||
* applies to all workflows (`enforce`) or only dynamic workflows (`dynamic`).
|
||||
*
|
||||
* @param toolsWorkflowInput - The value of the `tools` workflow input, if provided.
|
||||
* @param isDynamicWorkflow - Whether the current workflow is dynamic.
|
||||
* @param repositoryProperties - The parsed repository properties.
|
||||
* @param logger - Logger for outputting resolution messages.
|
||||
* @returns The effective tools input value.
|
||||
*/
|
||||
export function resolveToolsInput(
|
||||
toolsWorkflowInput: string | undefined,
|
||||
isDynamicWorkflow: boolean,
|
||||
repositoryProperties: RepositoryProperties,
|
||||
logger: Logger,
|
||||
): string | undefined {
|
||||
return resolveToolsInputWithMetadata(
|
||||
toolsWorkflowInput,
|
||||
isDynamicWorkflow,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
).effectiveToolsInput;
|
||||
}
|
||||
|
||||
export function resolveToolsInputWithMetadata(
|
||||
toolsWorkflowInput: string | undefined,
|
||||
isDynamicWorkflow: boolean,
|
||||
repositoryProperties: RepositoryProperties,
|
||||
logger: Logger,
|
||||
): ResolvedToolsInput {
|
||||
if (toolsWorkflowInput) {
|
||||
logger.info(
|
||||
`Setting tools: ${toolsWorkflowInput} based on workflow input.`,
|
||||
);
|
||||
return {
|
||||
effectiveToolsInput: toolsWorkflowInput,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource.WorkflowInput,
|
||||
toolsRepoPropertyMode: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
const toolsPropertyValue = repositoryProperties[RepositoryPropertyName.TOOLS];
|
||||
const toolsMode =
|
||||
repositoryProperties[RepositoryPropertyName.TOOLS_MODE] ??
|
||||
ToolsModeRepositoryPropertyValue.Enforce;
|
||||
|
||||
if (
|
||||
toolsPropertyValue &&
|
||||
toolsMode === ToolsModeRepositoryPropertyValue.Dynamic &&
|
||||
!isDynamicWorkflow
|
||||
) {
|
||||
logger.info(
|
||||
`Ignoring '${RepositoryPropertyName.TOOLS}' repository property because '${RepositoryPropertyName.TOOLS_MODE}' is set to '${toolsMode}' and this is not a dynamic workflow.`,
|
||||
);
|
||||
return {
|
||||
effectiveToolsInput: undefined,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource.None,
|
||||
toolsRepoPropertyMode: toolsMode,
|
||||
};
|
||||
}
|
||||
|
||||
if (toolsPropertyValue) {
|
||||
logger.info(
|
||||
`Setting tools: ${toolsPropertyValue} based on the '${RepositoryPropertyName.TOOLS}' repository property (mode: '${toolsMode}').`,
|
||||
);
|
||||
return {
|
||||
effectiveToolsInput: toolsPropertyValue,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource.RepositoryProperty,
|
||||
toolsRepoPropertyMode: toolsMode,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
effectiveToolsInput: undefined,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource.None,
|
||||
toolsRepoPropertyMode: undefined,
|
||||
};
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import { createStubCodeQL } from "./codeql";
|
||||
import { Config } from "./config-utils";
|
||||
import { cleanupAndUploadDatabases } from "./database-upload";
|
||||
import * as gitUtils from "./git-utils";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import { RepositoryNwo } from "./repository";
|
||||
import {
|
||||
checkExpectedLogMessages,
|
||||
|
||||
@@ -13,7 +13,7 @@ import { type CodeQL } from "./codeql";
|
||||
import { Config } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import * as json from "./json";
|
||||
import { Language } from "./languages";
|
||||
import { Language } from "./languages/index";
|
||||
import { Logger, withGroup } from "./logging";
|
||||
import {
|
||||
isSafeArtifactUpload,
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-v2.25.5",
|
||||
"cliVersion": "2.25.5",
|
||||
"priorBundleVersion": "codeql-bundle-v2.25.4",
|
||||
"priorCliVersion": "2.25.4"
|
||||
"bundleVersion": "codeql-bundle-v2.25.6",
|
||||
"cliVersion": "2.25.6",
|
||||
"priorBundleVersion": "codeql-bundle-v2.25.5",
|
||||
"priorCliVersion": "2.25.5"
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import {
|
||||
CacheStoreResult,
|
||||
} from "./dependency-caching";
|
||||
import { Feature } from "./feature-flags";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import {
|
||||
setupTests,
|
||||
createFeatures,
|
||||
|
||||
@@ -11,7 +11,7 @@ import { CodeQL } from "./codeql";
|
||||
import { Config } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { BuiltInLanguage, Language } from "./languages";
|
||||
import { BuiltInLanguage, Language } from "./languages/index";
|
||||
import { Logger } from "./logging";
|
||||
import { getErrorMessage, getRequiredEnvParam } from "./util";
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { existsSync, mkdirSync, writeFileSync } from "fs";
|
||||
import path from "path";
|
||||
|
||||
import type { Config } from "./config-utils";
|
||||
import { Language } from "./languages";
|
||||
import { Language } from "./languages/index";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { getCodeQLDatabasePath } from "./util";
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { PullRequestBranches } from "./actions-util";
|
||||
import { getApiClient, getGitHubVersion } from "./api-client";
|
||||
import type { CodeQL } from "./codeql";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { Logger, withGroupAsync } from "./logging";
|
||||
import { Logger } from "./logging";
|
||||
import { getRepositoryNwoFromEnv } from "./repository";
|
||||
import { getErrorMessage, GitHubVariant, satisfiesGHESVersion } from "./util";
|
||||
|
||||
@@ -83,16 +83,14 @@ export async function prepareDiffInformedAnalysis(
|
||||
return false;
|
||||
}
|
||||
|
||||
return await withGroupAsync("Computing PR diff ranges", async () => {
|
||||
try {
|
||||
return await computeAndPersistDiffRanges(branches, logger);
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to compute diff-informed analysis ranges: ${getErrorMessage(e)}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return await computeAndPersistDiffRanges(branches, logger);
|
||||
} catch (e) {
|
||||
logger.warning(
|
||||
`Failed to compute diff-informed analysis ranges: ${getErrorMessage(e)}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export interface DiffThunkRange {
|
||||
@@ -192,6 +190,7 @@ export async function computeAndPersistDiffRanges(
|
||||
branches: PullRequestBranches,
|
||||
logger: Logger,
|
||||
): Promise<boolean> {
|
||||
logger.info("Computing PR diff ranges...");
|
||||
const ranges = await getPullRequestEditedDiffRanges(branches, logger);
|
||||
if (ranges === undefined) {
|
||||
return false;
|
||||
|
||||
@@ -78,6 +78,8 @@ test.serial("loadPropertiesFromApi loads known properties", async (t) => {
|
||||
url: "",
|
||||
data: [
|
||||
{ property_name: "github-codeql-extra-queries", value: "+queries" },
|
||||
{ property_name: "github-codeql-tools", value: "toolcache" },
|
||||
{ property_name: "github-codeql-tools-mode", value: "dynamic" },
|
||||
{ property_name: "unknown-property", value: "something" },
|
||||
] satisfies properties.GitHubPropertiesResponse,
|
||||
});
|
||||
@@ -87,9 +89,45 @@ test.serial("loadPropertiesFromApi loads known properties", async (t) => {
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
);
|
||||
t.deepEqual(response, { "github-codeql-extra-queries": "+queries" });
|
||||
t.deepEqual(response, {
|
||||
"github-codeql-extra-queries": "+queries",
|
||||
"github-codeql-tools": "toolcache",
|
||||
"github-codeql-tools-mode": "dynamic",
|
||||
});
|
||||
});
|
||||
|
||||
test.serial(
|
||||
"loadPropertiesFromApi warns if tools mode property has unexpected value",
|
||||
async (t) => {
|
||||
sinon.stub(api, "getRepositoryProperties").resolves({
|
||||
headers: {},
|
||||
status: 200,
|
||||
url: "",
|
||||
data: [
|
||||
{
|
||||
property_name: "github-codeql-tools-mode",
|
||||
value: "all",
|
||||
},
|
||||
] satisfies properties.GitHubPropertiesResponse,
|
||||
});
|
||||
const logger = getRunnerLogger(true);
|
||||
const warningSpy = sinon.spy(logger, "warning");
|
||||
const mockRepositoryNwo = parseRepositoryNwo("owner/repo");
|
||||
const response = await properties.loadPropertiesFromApi(
|
||||
logger,
|
||||
mockRepositoryNwo,
|
||||
);
|
||||
t.deepEqual(response, {
|
||||
"github-codeql-tools-mode": "enforce",
|
||||
});
|
||||
t.true(warningSpy.calledOnce);
|
||||
t.is(
|
||||
warningSpy.firstCall.args[0],
|
||||
"Repository property 'github-codeql-tools-mode' has unexpected value 'all'. Expected 'dynamic' or 'enforce'. Defaulting to 'enforce'.",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
test.serial("loadPropertiesFromApi parses true boolean property", async (t) => {
|
||||
sinon.stub(api, "getRepositoryProperties").resolves({
|
||||
headers: {},
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import * as github from "@actions/github";
|
||||
|
||||
import { isDynamicWorkflow } from "../actions-util";
|
||||
import { getRepositoryProperties } from "../api-client";
|
||||
import { Logger } from "../logging";
|
||||
import { RepositoryNwo } from "../repository";
|
||||
import { getErrorMessage, Result, Success, Failure } from "../util";
|
||||
|
||||
/** The common prefix that we expect all of our repository properties to have. */
|
||||
export const GITHUB_CODEQL_PROPERTY_PREFIX = "github-codeql-";
|
||||
@@ -13,6 +16,13 @@ export enum RepositoryPropertyName {
|
||||
DISABLE_OVERLAY = "github-codeql-disable-overlay",
|
||||
EXTRA_QUERIES = "github-codeql-extra-queries",
|
||||
FILE_COVERAGE_ON_PRS = "github-codeql-file-coverage-on-prs",
|
||||
TOOLS = "github-codeql-tools",
|
||||
TOOLS_MODE = "github-codeql-tools-mode",
|
||||
}
|
||||
|
||||
export enum ToolsModeRepositoryPropertyValue {
|
||||
Dynamic = "dynamic",
|
||||
Enforce = "enforce",
|
||||
}
|
||||
|
||||
/** Parsed types of the known repository properties. */
|
||||
@@ -20,6 +30,8 @@ export type AllRepositoryProperties = {
|
||||
[RepositoryPropertyName.DISABLE_OVERLAY]: boolean;
|
||||
[RepositoryPropertyName.EXTRA_QUERIES]: string;
|
||||
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: boolean;
|
||||
[RepositoryPropertyName.TOOLS]: string;
|
||||
[RepositoryPropertyName.TOOLS_MODE]: ToolsModeRepositoryPropertyValue;
|
||||
};
|
||||
|
||||
/** Parsed repository properties. */
|
||||
@@ -30,6 +42,8 @@ export type RepositoryPropertyApiType = {
|
||||
[RepositoryPropertyName.DISABLE_OVERLAY]: string;
|
||||
[RepositoryPropertyName.EXTRA_QUERIES]: string;
|
||||
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: string;
|
||||
[RepositoryPropertyName.TOOLS]: string;
|
||||
[RepositoryPropertyName.TOOLS_MODE]: string;
|
||||
};
|
||||
|
||||
/** The type of functions which take the `value` from the API and try to convert it to the type we want. */
|
||||
@@ -77,6 +91,11 @@ const repositoryPropertyParsers: {
|
||||
[RepositoryPropertyName.DISABLE_OVERLAY]: booleanProperty,
|
||||
[RepositoryPropertyName.EXTRA_QUERIES]: stringProperty,
|
||||
[RepositoryPropertyName.FILE_COVERAGE_ON_PRS]: booleanProperty,
|
||||
[RepositoryPropertyName.TOOLS]: stringProperty,
|
||||
[RepositoryPropertyName.TOOLS_MODE]: {
|
||||
validate: isString,
|
||||
parse: parseToolsModeRepositoryProperty,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -172,6 +191,38 @@ export async function loadPropertiesFromApi(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads [repository properties](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization) if applicable.
|
||||
*/
|
||||
export async function loadRepositoryProperties(
|
||||
repositoryNwo: RepositoryNwo,
|
||||
logger: Logger,
|
||||
): Promise<Result<RepositoryProperties, unknown>> {
|
||||
// See if we can skip loading repository properties early. In particular,
|
||||
// repositories owned by users cannot have repository properties, so we can
|
||||
// skip the API call entirely in that case.
|
||||
const repositoryOwnerType = github.context.payload.repository?.owner.type;
|
||||
logger.debug(
|
||||
`Repository owner type is '${repositoryOwnerType ?? "unknown"}'.`,
|
||||
);
|
||||
if (repositoryOwnerType === "User") {
|
||||
logger.debug(
|
||||
"Skipping loading repository properties because the repository is owned by a user and " +
|
||||
"therefore cannot have repository properties.",
|
||||
);
|
||||
return new Success({});
|
||||
}
|
||||
|
||||
try {
|
||||
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
||||
} catch (error) {
|
||||
logger.info(
|
||||
`Failed to load repository properties: ${getErrorMessage(error)}`,
|
||||
);
|
||||
return new Failure(error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that `value` has the correct type for `K` and, if so, update the partial set of repository
|
||||
* properties with the parsed value of the specified property.
|
||||
@@ -217,6 +268,25 @@ function parseStringRepositoryProperty(_name: string, value: string): string {
|
||||
return value;
|
||||
}
|
||||
|
||||
/** Parse the tools mode repository property. */
|
||||
function parseToolsModeRepositoryProperty(
|
||||
name: string,
|
||||
value: string,
|
||||
logger: Logger,
|
||||
): ToolsModeRepositoryPropertyValue {
|
||||
if (
|
||||
value !== ToolsModeRepositoryPropertyValue.Dynamic &&
|
||||
value !== ToolsModeRepositoryPropertyValue.Enforce
|
||||
) {
|
||||
logger.warning(
|
||||
`Repository property '${name}' has unexpected value '${value}'. Expected 'dynamic' or 'enforce'. Defaulting to 'enforce'.`,
|
||||
);
|
||||
return ToolsModeRepositoryPropertyValue.Enforce;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/** Set of known repository property names, for fast lookups. */
|
||||
const KNOWN_REPOSITORY_PROPERTY_NAMES = new Set<string>(
|
||||
Object.values(RepositoryPropertyName),
|
||||
|
||||
+41
-42
@@ -2,12 +2,12 @@ import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import * as core from "@actions/core";
|
||||
import * as github from "@actions/github";
|
||||
import * as io from "@actions/io";
|
||||
import * as semver from "semver";
|
||||
import { v4 as uuidV4 } from "uuid";
|
||||
|
||||
import {
|
||||
isDynamicWorkflow,
|
||||
FileCmdNotFoundError,
|
||||
getActionVersion,
|
||||
getFileType,
|
||||
@@ -24,6 +24,10 @@ import {
|
||||
shouldRestoreCache,
|
||||
} from "./caching-utils";
|
||||
import { CodeQL } from "./codeql";
|
||||
import {
|
||||
EffectiveToolsInputSource,
|
||||
resolveToolsInputWithMetadata,
|
||||
} from "./config/resolve-tools-input";
|
||||
import * as configUtils from "./config-utils";
|
||||
import {
|
||||
DependencyCacheRestoreStatusReport,
|
||||
@@ -40,8 +44,8 @@ import {
|
||||
import { EnvVar } from "./environment";
|
||||
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||
import {
|
||||
loadPropertiesFromApi,
|
||||
RepositoryProperties,
|
||||
loadRepositoryProperties,
|
||||
ToolsModeRepositoryPropertyValue,
|
||||
} from "./feature-flags/properties";
|
||||
import {
|
||||
checkInstallPython311,
|
||||
@@ -53,14 +57,14 @@ import {
|
||||
initConfig,
|
||||
runDatabaseInitCluster,
|
||||
} from "./init";
|
||||
import { JavaEnvVars, BuiltInLanguage } from "./languages";
|
||||
import { JavaEnvVars, BuiltInLanguage } from "./languages/index";
|
||||
import { getActionsLogger, Logger, withGroupAsync } from "./logging";
|
||||
import {
|
||||
downloadOverlayBaseDatabaseFromCache,
|
||||
OverlayBaseDatabaseDownloadStats,
|
||||
} from "./overlay/caching";
|
||||
import { OverlayDatabaseMode } from "./overlay/overlay-database-mode";
|
||||
import { getRepositoryNwo, RepositoryNwo } from "./repository";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
import { ToolsSource } from "./setup-codeql";
|
||||
import {
|
||||
ActionName,
|
||||
@@ -93,10 +97,7 @@ import {
|
||||
checkActionVersion,
|
||||
getErrorMessage,
|
||||
BuildMode,
|
||||
Result,
|
||||
getOptionalEnvVar,
|
||||
Success,
|
||||
Failure,
|
||||
} from "./util";
|
||||
import { checkWorkflow } from "./workflow";
|
||||
|
||||
@@ -140,6 +141,9 @@ async function sendCompletedStatusReport(
|
||||
toolsFeatureFlagsValid: boolean | undefined,
|
||||
toolsSource: ToolsSource,
|
||||
toolsVersion: string,
|
||||
effectiveToolsInput: string | undefined,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource,
|
||||
toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined,
|
||||
overlayBaseDatabaseStats: OverlayBaseDatabaseDownloadStats | undefined,
|
||||
dependencyCachingResults: DependencyCacheRestoreStatusReport | undefined,
|
||||
logger: Logger,
|
||||
@@ -165,6 +169,9 @@ async function sendCompletedStatusReport(
|
||||
const initStatusReport: InitStatusReport = {
|
||||
...statusReportBase,
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
effective_tools_input: effectiveToolsInput || "",
|
||||
effective_tools_input_source: effectiveToolsInputSource,
|
||||
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || ToolsSource.Unknown,
|
||||
workflow_languages: workflowLanguages || "",
|
||||
@@ -219,6 +226,9 @@ async function run(startedAt: Date) {
|
||||
let toolsSource: ToolsSource;
|
||||
let toolsVersion: string;
|
||||
let zstdAvailability: ZstdAvailability | undefined;
|
||||
let effectiveToolsInput: string | undefined;
|
||||
let effectiveToolsInputSource: EffectiveToolsInputSource;
|
||||
let toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined;
|
||||
|
||||
try {
|
||||
initializeEnvironment(getActionVersion());
|
||||
@@ -251,6 +261,7 @@ async function run(startedAt: Date) {
|
||||
repositoryNwo,
|
||||
logger,
|
||||
);
|
||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||
|
||||
// Create a unique identifier for this run.
|
||||
const jobRunUuid = uuidV4();
|
||||
@@ -296,6 +307,21 @@ async function run(startedAt: Date) {
|
||||
const codeQLDefaultVersionInfo =
|
||||
await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||
|
||||
// Determine the effective tools input.
|
||||
// The explicit `tools` workflow input takes precedence. If none is provided,
|
||||
// fall back to the 'github-codeql-tools' repository property (if set).
|
||||
// If 'github-codeql-tools-mode' is set to 'dynamic', this fallback applies
|
||||
// only to dynamic workflows. Otherwise, it applies to all workflows.
|
||||
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||
getOptionalInput("tools"),
|
||||
isDynamicWorkflow(),
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||
const rawLanguages = configUtils.getRawLanguagesNoAutodetect(
|
||||
getOptionalInput("languages"),
|
||||
);
|
||||
@@ -303,7 +329,7 @@ async function run(startedAt: Date) {
|
||||
analysisKinds?.length === 1 &&
|
||||
analysisKinds[0] === AnalysisKind.CodeScanning;
|
||||
const initCodeQLResult = await initCodeQL(
|
||||
getOptionalInput("tools"),
|
||||
effectiveToolsInput,
|
||||
apiDetails,
|
||||
getTemporaryDirectory(),
|
||||
gitHubVersion.type,
|
||||
@@ -350,7 +376,6 @@ async function run(startedAt: Date) {
|
||||
|
||||
analysisKinds = await getAnalysisKinds(logger, features);
|
||||
const debugMode = getOptionalInput("debug") === "true" || core.isDebug();
|
||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||
const fileCoverageResult = await getFileCoverageInformationEnabled(
|
||||
debugMode,
|
||||
codeql,
|
||||
@@ -774,6 +799,9 @@ async function run(startedAt: Date) {
|
||||
toolsFeatureFlagsValid,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingStatus,
|
||||
logger,
|
||||
@@ -791,44 +819,15 @@ async function run(startedAt: Date) {
|
||||
toolsFeatureFlagsValid,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
overlayBaseDatabaseStats,
|
||||
dependencyCachingStatus,
|
||||
logger,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads [repository properties](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization) if applicable.
|
||||
*/
|
||||
async function loadRepositoryProperties(
|
||||
repositoryNwo: RepositoryNwo,
|
||||
logger: Logger,
|
||||
): Promise<Result<RepositoryProperties, unknown>> {
|
||||
// See if we can skip loading repository properties early. In particular,
|
||||
// repositories owned by users cannot have repository properties, so we can
|
||||
// skip the API call entirely in that case.
|
||||
const repositoryOwnerType = github.context.payload.repository?.owner.type;
|
||||
logger.debug(
|
||||
`Repository owner type is '${repositoryOwnerType ?? "unknown"}'.`,
|
||||
);
|
||||
if (repositoryOwnerType === "User") {
|
||||
logger.debug(
|
||||
"Skipping loading repository properties because the repository is owned by a user and " +
|
||||
"therefore cannot have repository properties.",
|
||||
);
|
||||
return new Success({});
|
||||
}
|
||||
|
||||
try {
|
||||
return new Success(await loadPropertiesFromApi(logger, repositoryNwo));
|
||||
} catch (error) {
|
||||
logger.warning(
|
||||
`Failed to load repository properties: ${getErrorMessage(error)}`,
|
||||
);
|
||||
return new Failure(error);
|
||||
}
|
||||
}
|
||||
|
||||
async function recordZstdAvailability(
|
||||
config: configUtils.Config,
|
||||
zstdAvailability: ZstdAvailability,
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import {
|
||||
getFileCoverageInformationEnabled,
|
||||
logFileCoverageOnPrsDeprecationWarning,
|
||||
} from "./init";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import {
|
||||
createFeatures,
|
||||
LoggedMessage,
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ import {
|
||||
RepositoryProperties,
|
||||
RepositoryPropertyName,
|
||||
} from "./feature-flags/properties";
|
||||
import { BuiltInLanguage, Language } from "./languages";
|
||||
import { BuiltInLanguage, Language } from "./languages/index";
|
||||
import { Logger, withGroupAsync } from "./logging";
|
||||
import { ToolsSource } from "./setup-codeql";
|
||||
import { ZstdAvailability } from "./tar";
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as core from "@actions/core";
|
||||
import { v4 as uuidV4 } from "uuid";
|
||||
|
||||
import {
|
||||
isDynamicWorkflow,
|
||||
getActionVersion,
|
||||
getOptionalInput,
|
||||
getRequiredInput,
|
||||
@@ -10,9 +11,17 @@ import {
|
||||
import { AnalysisKind, getAnalysisKinds } from "./analyses";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { CodeQL } from "./codeql";
|
||||
import {
|
||||
EffectiveToolsInputSource,
|
||||
resolveToolsInputWithMetadata,
|
||||
} from "./config/resolve-tools-input";
|
||||
import { getRawLanguagesNoAutodetect } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { initFeatures } from "./feature-flags";
|
||||
import {
|
||||
loadRepositoryProperties,
|
||||
ToolsModeRepositoryPropertyValue,
|
||||
} from "./feature-flags/properties";
|
||||
import { initCodeQL } from "./init";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
@@ -48,6 +57,9 @@ async function sendCompletedStatusReport(
|
||||
toolsFeatureFlagsValid: boolean | undefined,
|
||||
toolsSource: ToolsSource,
|
||||
toolsVersion: string,
|
||||
effectiveToolsInput: string | undefined,
|
||||
effectiveToolsInputSource: EffectiveToolsInputSource,
|
||||
toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined,
|
||||
logger: Logger,
|
||||
error?: Error,
|
||||
): Promise<void> {
|
||||
@@ -69,6 +81,9 @@ async function sendCompletedStatusReport(
|
||||
const initStatusReport: InitStatusReport = {
|
||||
...statusReportBase,
|
||||
tools_input: getOptionalInput("tools") || "",
|
||||
effective_tools_input: effectiveToolsInput || "",
|
||||
effective_tools_input_source: effectiveToolsInputSource,
|
||||
tools_repo_property_mode: toolsRepoPropertyMode || "",
|
||||
tools_resolved_version: toolsVersion,
|
||||
tools_source: toolsSource || ToolsSource.Unknown,
|
||||
workflow_languages: "",
|
||||
@@ -99,6 +114,9 @@ async function run(startedAt: Date): Promise<void> {
|
||||
let toolsFeatureFlagsValid: boolean | undefined;
|
||||
let toolsSource: ToolsSource;
|
||||
let toolsVersion: string;
|
||||
let effectiveToolsInput: string | undefined;
|
||||
let effectiveToolsInputSource: EffectiveToolsInputSource;
|
||||
let toolsRepoPropertyMode: ToolsModeRepositoryPropertyValue | undefined;
|
||||
|
||||
try {
|
||||
initializeEnvironment(getActionVersion());
|
||||
@@ -141,12 +159,35 @@ async function run(startedAt: Date): Promise<void> {
|
||||
const codeQLDefaultVersionInfo =
|
||||
await features.getEnabledDefaultCliVersions(gitHubVersion.type);
|
||||
toolsFeatureFlagsValid = codeQLDefaultVersionInfo.toolsFeatureFlagsValid;
|
||||
|
||||
// Fetch the values of known repository properties that affect us.
|
||||
const repositoryPropertiesResult = await loadRepositoryProperties(
|
||||
repositoryNwo,
|
||||
logger,
|
||||
);
|
||||
const repositoryProperties = repositoryPropertiesResult.orElse({});
|
||||
|
||||
// Determine the effective tools input.
|
||||
// The explicit `tools` workflow input takes precedence. If none is provided,
|
||||
// fall back to the 'github-codeql-tools' repository property (if set).
|
||||
// If 'github-codeql-tools-mode' is set to 'dynamic', this fallback applies
|
||||
// only to dynamic workflows. Otherwise, it applies to all workflows.
|
||||
const resolvedToolsInput = resolveToolsInputWithMetadata(
|
||||
getOptionalInput("tools"),
|
||||
isDynamicWorkflow(),
|
||||
repositoryProperties,
|
||||
logger,
|
||||
);
|
||||
effectiveToolsInput = resolvedToolsInput.effectiveToolsInput;
|
||||
effectiveToolsInputSource = resolvedToolsInput.effectiveToolsInputSource;
|
||||
toolsRepoPropertyMode = resolvedToolsInput.toolsRepoPropertyMode;
|
||||
const rawLanguages = getRawLanguagesNoAutodetect(
|
||||
getOptionalInput("languages"),
|
||||
);
|
||||
const analysisKinds = await getAnalysisKinds(logger, features);
|
||||
|
||||
const initCodeQLResult = await initCodeQL(
|
||||
getOptionalInput("tools"),
|
||||
effectiveToolsInput,
|
||||
apiDetails,
|
||||
getTemporaryDirectory(),
|
||||
gitHubVersion.type,
|
||||
@@ -191,6 +232,9 @@ async function run(startedAt: Date): Promise<void> {
|
||||
toolsFeatureFlagsValid,
|
||||
toolsSource,
|
||||
toolsVersion,
|
||||
effectiveToolsInput,
|
||||
effectiveToolsInputSource,
|
||||
toolsRepoPropertyMode,
|
||||
logger,
|
||||
);
|
||||
}
|
||||
|
||||
+1
-1
@@ -559,7 +559,7 @@ export async function getCodeQLSource(
|
||||
);
|
||||
} else {
|
||||
if (allowToolcacheValueFF) {
|
||||
logger.warning(
|
||||
logger.info(
|
||||
`Ignoring 'tools: ${toolsInput}' because the workflow was not triggered dynamically.`,
|
||||
);
|
||||
} else {
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as core from "@actions/core";
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { getGitHubVersion } from "./api-client";
|
||||
import { Feature, FeatureEnablement, initFeatures } from "./feature-flags";
|
||||
import { BuiltInLanguage, parseBuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage, parseBuiltInLanguage } from "./languages/index";
|
||||
import { getActionsLogger, Logger } from "./logging";
|
||||
import { getRepositoryNwo } from "./repository";
|
||||
import {
|
||||
|
||||
@@ -10,7 +10,7 @@ import * as defaults from "./defaults.json";
|
||||
import { setUpFeatureFlagTests } from "./feature-flags/testing-util";
|
||||
import { UnvalidatedObject, validateSchema } from "./json";
|
||||
import { makeFromSchema } from "./json/testing-util";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import { getRunnerLogger, Logger } from "./logging";
|
||||
import * as startProxyExports from "./start-proxy";
|
||||
import * as statusReport from "./status-report";
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ import {
|
||||
FeatureEnablement,
|
||||
} from "./feature-flags";
|
||||
import * as json from "./json";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import { Logger } from "./logging";
|
||||
import {
|
||||
Address,
|
||||
|
||||
@@ -2,9 +2,10 @@ import test from "ava";
|
||||
import * as sinon from "sinon";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { EffectiveToolsInputSource } from "./config/resolve-tools-input";
|
||||
import { Config } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { ToolsSource } from "./setup-codeql";
|
||||
import {
|
||||
@@ -316,6 +317,9 @@ const testCreateInitWithConfigStatusReport = makeMacro({
|
||||
const initStatusReport: InitStatusReport = {
|
||||
...statusReportBase,
|
||||
tools_input: "",
|
||||
effective_tools_input: "",
|
||||
effective_tools_input_source: EffectiveToolsInputSource.None,
|
||||
tools_repo_property_mode: "",
|
||||
tools_resolved_version: "foo",
|
||||
tools_source: ToolsSource.Unknown,
|
||||
workflow_languages: "actions",
|
||||
@@ -347,6 +351,8 @@ testCreateInitWithConfigStatusReport.serial(
|
||||
languages: [BuiltInLanguage.java, BuiltInLanguage.swift],
|
||||
}),
|
||||
{
|
||||
effective_tools_input_source: EffectiveToolsInputSource.None,
|
||||
tools_repo_property_mode: "",
|
||||
trap_cache_download_size_bytes: 1024,
|
||||
registries: "[]",
|
||||
query_filters: "[]",
|
||||
@@ -354,6 +360,63 @@ testCreateInitWithConfigStatusReport.serial(
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"createInitWithConfigStatusReport preserves tools telemetry fields",
|
||||
async (t) => {
|
||||
await withTmpDir(async (tmpDir: string) => {
|
||||
setupEnvironmentAndStub(tmpDir);
|
||||
|
||||
const config = createTestConfig({
|
||||
buildMode: BuildMode.None,
|
||||
languages: [BuiltInLanguage.java],
|
||||
});
|
||||
|
||||
const statusReportBase = await createStatusReportBase(
|
||||
ActionName.Init,
|
||||
"failure",
|
||||
new Date("May 19, 2023 05:19:00"),
|
||||
config,
|
||||
{ numAvailableBytes: 100, numTotalBytes: 500 },
|
||||
getRunnerLogger(false),
|
||||
"failure cause",
|
||||
"exception stack trace",
|
||||
);
|
||||
|
||||
if (t.truthy(statusReportBase)) {
|
||||
const initStatusReport: InitStatusReport = {
|
||||
...statusReportBase,
|
||||
tools_input: "",
|
||||
effective_tools_input: "toolcache",
|
||||
effective_tools_input_source:
|
||||
EffectiveToolsInputSource.RepositoryProperty,
|
||||
tools_repo_property_mode: "dynamic",
|
||||
tools_resolved_version: "foo",
|
||||
tools_source: ToolsSource.Unknown,
|
||||
workflow_languages: "actions",
|
||||
};
|
||||
|
||||
const initWithConfigStatusReport =
|
||||
await createInitWithConfigStatusReport(
|
||||
config,
|
||||
initStatusReport,
|
||||
undefined,
|
||||
1024,
|
||||
undefined,
|
||||
undefined,
|
||||
);
|
||||
|
||||
if (t.truthy(initWithConfigStatusReport)) {
|
||||
t.is(
|
||||
initWithConfigStatusReport.effective_tools_input_source,
|
||||
EffectiveToolsInputSource.RepositoryProperty,
|
||||
);
|
||||
t.is(initWithConfigStatusReport.tools_repo_property_mode, "dynamic");
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testCreateInitWithConfigStatusReport.serial(
|
||||
"includes packs for a single language",
|
||||
createTestConfig({
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
isSelfHostedRunner,
|
||||
} from "./actions-util";
|
||||
import { getAnalysisKey, getApiClient } from "./api-client";
|
||||
import { EffectiveToolsInputSource } from "./config/resolve-tools-input";
|
||||
import { parseRegistriesWithoutCredentials, type Config } from "./config-utils";
|
||||
import { DependencyCacheRestoreStatusReport } from "./dependency-caching";
|
||||
import { DocUrl } from "./doc-url";
|
||||
@@ -482,6 +483,12 @@ export async function sendStatusReport<S extends StatusReportBase>(
|
||||
export interface InitStatusReport extends StatusReportBase {
|
||||
/** Value given by the user as the "tools" input. */
|
||||
tools_input: string;
|
||||
/** The effective tools input that was used, after applying defaults and repository properties. */
|
||||
effective_tools_input: string;
|
||||
/** Indicates where the effective tools input was resolved from. */
|
||||
effective_tools_input_source: EffectiveToolsInputSource;
|
||||
/** The value of the tools repository property mode, if relevant. */
|
||||
tools_repo_property_mode: string;
|
||||
/** Version of the bundle used. */
|
||||
tools_resolved_version: string;
|
||||
/** Where the bundle originated from. */
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as sinon from "sinon";
|
||||
|
||||
import { CodeQL, getCodeQLForTesting } from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import { createTestConfig, makeVersionInfo, setupTests } from "./testing-utils";
|
||||
import { ToolsFeature } from "./tools-features";
|
||||
import { getCombinedTracerConfig } from "./tracer-config";
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
import * as configUtils from "./config-utils";
|
||||
import { Feature } from "./feature-flags";
|
||||
import * as gitUtils from "./git-utils";
|
||||
import { BuiltInLanguage } from "./languages";
|
||||
import { BuiltInLanguage } from "./languages/index";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import {
|
||||
createFeatures,
|
||||
@@ -38,7 +38,7 @@ const stubCodeql = createStubCodeQL({
|
||||
async getVersion() {
|
||||
return makeVersionInfo("2.10.3");
|
||||
},
|
||||
async betterResolveLanguages() {
|
||||
async resolveLanguages() {
|
||||
return {
|
||||
extractors: {
|
||||
[BuiltInLanguage.javascript]: [
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ import { type Config } from "./config-utils";
|
||||
import { DocUrl } from "./doc-url";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import * as gitUtils from "./git-utils";
|
||||
import { Language } from "./languages";
|
||||
import { Language } from "./languages/index";
|
||||
import { Logger } from "./logging";
|
||||
import {
|
||||
asHTTPError,
|
||||
@@ -280,7 +280,7 @@ export async function getLanguagesSupportingCaching(
|
||||
logger: Logger,
|
||||
): Promise<Language[]> {
|
||||
const result: Language[] = [];
|
||||
const resolveResult = await codeql.betterResolveLanguages();
|
||||
const resolveResult = await codeql.resolveLanguages();
|
||||
outer: for (const lang of languages) {
|
||||
const extractorsForLanguage = resolveResult.extractors[lang];
|
||||
if (extractorsForLanguage === undefined) {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ import type { Pack } from "./config/db-config";
|
||||
import type { Config } from "./config-utils";
|
||||
import { EnvVar } from "./environment";
|
||||
import * as json from "./json";
|
||||
import { Language } from "./languages";
|
||||
import { Language } from "./languages/index";
|
||||
import { Logger } from "./logging";
|
||||
|
||||
/**
|
||||
|
||||
@@ -383,7 +383,7 @@ async function testLanguageAliases(
|
||||
process.env.GITHUB_JOB = "test";
|
||||
|
||||
const codeql = await getCodeQLForTesting();
|
||||
sinon.stub(codeql, "betterResolveLanguages").resolves({
|
||||
sinon.stub(codeql, "resolveLanguages").resolves({
|
||||
aliases:
|
||||
aliases !== undefined
|
||||
? // Remap from languageName -> aliases to alias -> languageName
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ async function groupLanguagesByExtractor(
|
||||
languages: string[],
|
||||
codeql: CodeQL,
|
||||
): Promise<{ [extractorName: string]: string[] } | undefined> {
|
||||
const resolveResult = await codeql.betterResolveLanguages();
|
||||
const resolveResult = await codeql.resolveLanguages();
|
||||
if (!resolveResult.aliases) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user