Skip to content

Commit 4a8f20f

Browse files
authored
Merge pull request #2150 from github/backport-v2.24.3-379614612
Merge releases/v3 into releases/v2
2 parents 8b6a45a + 460939e commit 4a8f20f

File tree

9 files changed

+165
-26
lines changed

9 files changed

+165
-26
lines changed

.github/workflows/__config-input.yml

+92
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
44

55
Note that the only difference between `v2` and `v3` of the CodeQL Action is the node version they support, with `v3` running on node 20 while we continue to release `v2` to support running on node 16. For example `3.22.11` was the first `v3` release and is functionally identical to `2.22.11`. This approach ensures an easy way to track exactly which features are included in different versions, indicated by the minor and patch version numbers.
66

7+
## 2.24.3 - 15 Feb 2024
8+
9+
- Fix an issue where the CodeQL Action would fail to load a configuration specified by the `config` input to the `init` Action. [#2147](https://github.com/github/codeql-action/pull/2147)
10+
711
## 2.24.2 - 15 Feb 2024
812

913
- Enable improved multi-threaded performance on larger runners for GitHub Enterprise Server users. This feature is already available to GitHub.com users. [#2141](https://github.com/github/codeql-action/pull/2141)

lib/config-utils.js

+14-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeql",
3-
"version": "2.24.2",
3+
"version": "2.24.3",
44
"private": true,
55
"description": "CodeQL action",
66
"scripts": {

pr-checks/checks/config-input.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Config input"
2+
description: "Tests specifying configuration using the config input"
3+
operatingSystems: ["ubuntu"]
4+
versions: ["latest"]
5+
steps:
6+
- name: Copy queries into workspace
7+
run: |
8+
cp -a ../action/queries .
9+
10+
- uses: ./../action/init
11+
with:
12+
tools: ${{ steps.prepare-test.outputs.tools-url }}
13+
languages: javascript
14+
build-mode: none
15+
config: |
16+
disable-default-queries: true
17+
queries:
18+
- name: Run custom query
19+
uses: ./queries/default-setup-environment-variables.ql
20+
paths-ignore:
21+
- tests
22+
- lib
23+
24+
- uses: ./../action/analyze
25+
with:
26+
output: ${{ runner.temp }}/results
27+
28+
- name: Check SARIF
29+
uses: ./../action/.github/actions/check-sarif
30+
with:
31+
sarif-file: ${{ runner.temp }}/results/javascript.sarif
32+
queries-run: javascript/codeql-action/default-setup-env-vars
33+
queries-not-run: javascript/codeql-action/default-setup-context-properties

src/config-utils.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,17 @@ async function loadConfig({
543543
let parsedYAML: UserConfig;
544544

545545
if (isLocal(configFile)) {
546-
// Treat the config file as relative to the workspace
547-
configFile = path.resolve(workspacePath, configFile);
548-
parsedYAML = getLocalConfig(configFile, workspacePath);
546+
if (configFile !== userConfigFromActionPath(tempDir)) {
547+
// If the config file is not generated by the Action, it should be relative to the workspace.
548+
configFile = path.resolve(workspacePath, configFile);
549+
// Error if the config file is now outside of the workspace
550+
if (!(configFile + path.sep).startsWith(workspacePath + path.sep)) {
551+
throw new ConfigurationError(
552+
getConfigFileOutsideWorkspaceErrorMessage(configFile),
553+
);
554+
}
555+
}
556+
parsedYAML = getLocalConfig(configFile);
549557
} else {
550558
parsedYAML = await getRemoteConfig(configFile, apiDetails);
551559
}
@@ -823,6 +831,10 @@ function dbLocationOrDefault(
823831
return dbLocation || path.resolve(tempDir, "codeql_databases");
824832
}
825833

834+
function userConfigFromActionPath(tempDir: string): string {
835+
return path.resolve(tempDir, "user-config-from-action.yml");
836+
}
837+
826838
/**
827839
* Load and return the config.
828840
*
@@ -841,7 +853,7 @@ export async function initConfig(inputs: InitConfigInputs): Promise<Config> {
841853
`Both a config file and config input were provided. Ignoring config file.`,
842854
);
843855
}
844-
inputs.configFile = path.resolve(tempDir, "user-config-from-action.yml");
856+
inputs.configFile = userConfigFromActionPath(tempDir);
845857
fs.writeFileSync(inputs.configFile, inputs.configInput);
846858
logger.debug(`Using config from action input: ${inputs.configFile}`);
847859
}
@@ -883,14 +895,7 @@ function isLocal(configPath: string): boolean {
883895
return configPath.indexOf("@") === -1;
884896
}
885897

886-
function getLocalConfig(configFile: string, workspacePath: string): UserConfig {
887-
// Error if the config file is now outside of the workspace
888-
if (!(configFile + path.sep).startsWith(workspacePath + path.sep)) {
889-
throw new ConfigurationError(
890-
getConfigFileOutsideWorkspaceErrorMessage(configFile),
891-
);
892-
}
893-
898+
function getLocalConfig(configFile: string): UserConfig {
894899
// Error if the file does not exist
895900
if (!fs.existsSync(configFile)) {
896901
throw new ConfigurationError(

0 commit comments

Comments
 (0)