Compare commits

...

720 Commits

Author SHA1 Message Date
Cornelius Riemenschneider
f7b6c0021b Merge pull request #1142 from github/update-v1.1.16-3e7e3b32
Merge releases/v2 into releases/v1
2022-07-13 14:43:54 +02:00
github-actions[bot]
ea16f0f943 Update checked-in dependencies 2022-07-13 11:48:41 +00:00
github-actions[bot]
0b90ea88eb Update version and changelog for v1.1.16 2022-07-13 11:27:42 +00:00
github-actions[bot]
f695c53a17 Merge remote-tracking branch 'origin/releases/v2' into update-v1.1.16-3e7e3b32 2022-07-13 11:27:41 +00:00
github-actions[bot]
2d5f20d706 Revert "Update checked-in dependencies"
This reverts commit eb9619301e.
2022-07-13 11:27:41 +00:00
github-actions[bot]
e617b8972d Revert "Update version and changelog for v1.1.15"
This reverts commit 785cbf1898.
2022-07-13 11:27:40 +00:00
Cornelius Riemenschneider
3e7e3b32d0 Merge pull request #1140 from github/update-v2.1.16-548f07e3
Merge main into releases/v2
2022-07-13 12:55:19 +02:00
github-actions[bot]
330d552535 Update changelog for v2.1.16 2022-07-13 10:05:10 +00:00
Andrew Eisenberg
548f07e307 Merge pull request #1139 from github/aeisenberg/concat-not-push
Use concat instead of push around `listFolders`
2022-07-13 02:39:34 -07:00
Henry Mercer
a844fefc86 Merge branch 'main' into aeisenberg/concat-not-push 2022-07-13 10:09:16 +01:00
Andrew Eisenberg
7ce9ef9137 Use concat instead of push around listFolders
This avoids stack overflows when using the spread operator on
directories that have many, many children.
2022-07-12 13:23:01 -07:00
Henry Mercer
d750c6d79d Merge pull request #1138 from github/henrymercer/drop-token-check
Update required checks: Allow authenticating via the GitHub CLI
2022-07-12 19:57:01 +01:00
Henry Mercer
4cb248b0ec Merge branch 'main' into henrymercer/drop-token-check 2022-07-12 18:21:09 +01:00
Henry Mercer
1e7f770864 Merge pull request #1132 from github/henrymercer/one-click-debug
Enable one-click debugging via the "Enable debug logging" option when re-running Actions jobs
2022-07-12 18:10:16 +01:00
Henry Mercer
816b3e91bc Update failure message
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
2022-07-12 17:52:15 +01:00
Henry Mercer
fbbd1dcd52 Fix extra double quote
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
2022-07-12 17:44:51 +01:00
Henry Mercer
0a5dad3c83 Allow authenticating via the GitHub CLI
We no longer run this script within Actions for security reasons, and
when running locally we can authenticate with the GitHub CLI instead
of a PAT.
2022-07-12 17:33:24 +01:00
Henry Mercer
d61e3fdf02 Fix shellcheck errors
Avoid trying to evaluate `github/codeql-action`.
2022-07-12 17:31:31 +01:00
Henry Mercer
dca60ba711 Merge remote-tracking branch 'origin/main' into henrymercer/one-click-debug 2022-07-12 16:54:30 +01:00
Cornelius Riemenschneider
e1ec69721f Merge pull request #1137 from github/criemen/fix-end-tracing
Unset tracing variables after finalizing databases.
2022-07-12 17:49:59 +02:00
Henry Mercer
b45ac1f8f8 Cleanup: Use optional chaining in a couple of places 2022-07-12 16:30:21 +01:00
Henry Mercer
b316baae94 Merge remote-tracking branch 'origin/main' into henrymercer/one-click-debug 2022-07-12 16:22:05 +01:00
Henry Mercer
e655fb331c Use core.isDebug() instead of accessing env var 2022-07-12 16:19:13 +01:00
Henry Mercer
b3801753d4 Merge pull request #1133 from github/henrymercer/log-diagnostics-when-debug-enabled
Print diagnostic messages when debugging mode is enabled
2022-07-12 15:49:16 +01:00
Cornelius Riemenschneider
3dcdbc9add Unset tracing variables after finalizing databases.
The tracer is very good at preserving itself, so unsetting the tracing-specific
variables from within a process will not end tracing for children of
that process.
The way the actions process model works means that we're running inside
a process for the entire build step that was launched with the tracer
variables set, so we'll have the tracer injected into the entire build
step and its children.
If we unset the variables in end-tracing, we will get into an intermediate
state: Not all variables in there are preserved by the tracer,
but the tracer is still active.
Usually, that wouldn't be a problem, but the autobuilders called from
the finalize step will suddenly run under a half-configured tracer.

Particularly, this half-configured tracer is unable to execute the dotnet
CLI without hangs, as the environment variable that prevents hangs for
dotnet on MacOS has been unset, but the tracer is still active.

This is an issue for the the go autobuilder, that invokes
user-provided build scripts in the hope of installing dependencies.
If that build script then invokes dotnet, it will hang.

This is only of concern for the Lua tracer that now implements proper
multi-language tracing: Previously, when encountering the go autobuilder,
the tracer disabled itself entirely, thus side-stepping any hangs.
In the new, multi-language tracing world, the tracer will stay active
as long as there is at least one other language that's been set up
for tracing.
Thus, we also get hangs when invoking the dotnet CLI through the go
autobuilder.
2022-07-12 11:33:44 +00:00
Henry Mercer
688508d8cb Merge pull request #1099 from github/henrymercer/run-unit-tests-on-windows
Run unit tests on Windows too
2022-07-12 11:06:41 +01:00
Henry Mercer
fc926423a5 Merge remote-tracking branch 'origin/main' into henrymercer/run-unit-tests-on-windows 2022-07-11 17:57:19 +01:00
Henry Mercer
ea8fb214de Merge pull request #1104 from github/henrymercer/remove-toolcache-decorator
Remove toolcache decorator
2022-07-11 17:54:54 +01:00
Henry Mercer
3a5fa35535 Add changelog note 2022-07-01 19:14:38 +01:00
Henry Mercer
7e94a6cbca Print diagnostic messages when debug logging enabled
This commit prints diagnostic messages to the Actions log when debug
logging is enabled by passing `debug: true` to `codeql-action/init` or
enabling Actions step debug logging.
2022-07-01 18:56:12 +01:00
Henry Mercer
b7da732b32 Add changelog note 2022-07-01 18:47:41 +01:00
Henry Mercer
0c729c81f2 Mention that debug mode is automatically enabled when step debugging on 2022-07-01 17:59:10 +01:00
Henry Mercer
53850d88bb Enable one-click debugging via the "Enable debug logging" rerun option 2022-07-01 17:56:57 +01:00
Henry Mercer
b1742f8919 Add instructions to remove deleted JS / source map files in PR check 2022-06-30 09:16:11 +01:00
Henry Mercer
c736697abf Remove toolcache decorator
This decorator enabled us to use the functionality of the Actions
toolcache within the runner too.
Now that we've deleted the runner we no longer need it.
2022-06-30 09:16:10 +01:00
Arthur Baars
ca8a203b51 Merge pull request #1126 from github/aibaars/python-setup-no-pycache
Python-Setup: run auto_install_packages.py with -B flag
2022-06-30 10:08:46 +02:00
Arthur Baars
53bc5e6c78 Merge remote-tracking branch 'origin/main' into aibaars/python-setup-no-pycache 2022-06-30 09:10:41 +02:00
Henry Mercer
130a51dbc6 Handle Windows absolute paths in resolveUriToFile 2022-06-29 18:59:33 +01:00
Henry Mercer
c2fd5d10f6 Don't make temporary directories symlinks
`toolcache.extractTar` currently falls over when `ACTIONS_TEMP` contains
a symlink, and the runner no longer exists, so it's unlikely our
customers would be running with temporary directories that contain
symlinks.
2022-06-29 18:59:33 +01:00
Henry Mercer
30681e79db Separate paths with / in resolveUriToFile 2022-06-29 18:59:32 +01:00
Henry Mercer
c15604920a Workaround PATH casing issues on Windows 2022-06-29 18:59:32 +01:00
Henry Mercer
4792297702 Fix test failures on Windows related to path separators 2022-06-29 18:59:32 +01:00
Henry Mercer
79ec03f3e5 Run npm scripts on using bash so Windows can find commands 2022-06-29 18:58:38 +01:00
Henry Mercer
7ebbfcbbdd Run unit tests on Windows too 2022-06-29 10:07:31 +01:00
Chuan-kai Lin
e41f8baf4a Merge pull request #1131 from github/update-v1.1.15-3f62b754
Merge releases/v2 into releases/v1
2022-06-28 14:13:46 -07:00
Chuan-kai Lin
3ea10cc7b5 Merge pull request #1130 from github/mergeback/v2.1.15-to-main-3f62b754
Mergeback v2.1.15 refs/heads/releases/v2 into main
2022-06-28 14:11:56 -07:00
github-actions[bot]
eb9619301e Update checked-in dependencies 2022-06-28 19:39:17 +00:00
github-actions[bot]
4a887ca920 Update checked-in dependencies 2022-06-28 19:26:38 +00:00
github-actions[bot]
785cbf1898 Update version and changelog for v1.1.15 2022-06-28 19:04:23 +00:00
github-actions[bot]
b7cbc0f8be Merge remote-tracking branch 'origin/releases/v2' into update-v1.1.15-3f62b754 2022-06-28 19:04:22 +00:00
github-actions[bot]
1fd3a8d1c7 Revert "Update checked-in dependencies"
This reverts commit 98b2df478b.
2022-06-28 19:04:22 +00:00
github-actions[bot]
269aa1746e Revert "Update version and changelog for v1.1.14"
This reverts commit f4fb1cfb88.
2022-06-28 19:04:22 +00:00
github-actions[bot]
7c1b9e6b1a Update changelog and version after v2.1.15 2022-06-28 19:04:16 +00:00
Chuan-kai Lin
3f62b754e2 Merge pull request #1129 from github/update-v2.1.15-e8c48cc8
Merge main into releases/v2
2022-06-28 12:02:35 -07:00
github-actions[bot]
26a69806cf Update changelog for v2.1.15 2022-06-28 18:00:58 +00:00
Henry Mercer
9953936347 Add instructions to remove deleted JS / source map files in PR check 2022-06-28 18:24:18 +01:00
Henry Mercer
41d6ac4d2a Remove toolcache decorator
This decorator enabled us to use the functionality of the Actions
toolcache within the runner too.
Now that we've deleted the runner we no longer need it.
2022-06-28 18:22:09 +01:00
Cornelius Riemenschneider
e8c48cc8cf Merge pull request #1128 from github/criemen/lua-tracer-ff-2
Simplify tests for the Lua tracer FF in analyze-action.
2022-06-28 12:52:24 +02:00
Cornelius Riemenschneider
1616e0ef98 Simplify tests for the Lua tracer FF in analyze-action. 2022-06-28 10:29:00 +00:00
Cornelius Riemenschneider
b40cd0390c Merge pull request #1120 from github/criemen/lua-tracer-ff-2
Honor the Lua tracer FF for `database trace-command` invocations for scanned languages.
2022-06-28 11:19:44 +02:00
Cornelius Riemenschneider
821fe9b476 Merge branch 'main' into criemen/lua-tracer-ff-2 2022-06-28 10:43:04 +02:00
Chuan-kai Lin
37d8b5142f Merge pull request #1123 from github/cklin/codeql-cli-2.10.0
Update default CodeQL version to 2.10.0
2022-06-27 10:20:30 -07:00
Cornelius Riemenschneider
ab7316e0c5 Implement unit tests for reading the Lua tracer FF in analyze-action. 2022-06-27 16:04:29 +00:00
Cornelius Riemenschneider
f422a50448 Honor the Lua tracer FF for database trace-command invocations for scanned languages.
In theory, a scanned language will not setup the build tracer, and so
shouldn't care about lua versus legacy tracing. However, `go` is a
special case where the autobuilder runs under the build tracer, that
then gets disabled immediately again, unless a special environment
variable is used.
Therefore, we need to thread through the feature flag to this
`database trace-command` invocation. For other scanned languages,
this should be a no-op, as no tracing is ever set up.
2022-06-27 16:04:29 +00:00
Chuan-kai Lin
ed40e306f5 Update default CodeQL version to 2.10.0 2022-06-27 09:01:12 -07:00
Arthur Baars
cae9a1f462 Run npm build 2022-06-27 16:40:40 +02:00
Arthur Baars
11a46b8856 Python-Setup: run auto_install_packages.py with -B flag
This avoids creating a __pycache__ folder in the _actions folder, which
may cause file ownership problems on self-hosted runners
when run in a docker container.
2022-06-27 16:39:19 +02:00
Arthur Baars
95673cf9a2 Revert "Python-Setup: set PYTHONDONTWRITEBYTECODE=1"
This reverts commit 3ff1fd9192.
2022-06-27 16:34:35 +02:00
Arthur Baars
3ff1fd9192 Python-Setup: set PYTHONDONTWRITEBYTECODE=1 2022-06-27 16:34:25 +02:00
Andrew Eisenberg
47bcabd3e8 Merge pull request #1116 from github/aeisenberg/multi-lang-packs
Allow scans with packs for languages not being scanned
2022-06-24 16:47:56 -07:00
Andrew Eisenberg
b9deefbe0a Merge branch 'main' into aeisenberg/multi-lang-packs 2022-06-24 15:12:24 -07:00
Andrew Eisenberg
7c4d0e0f6e Merge pull request #1124 from github/aeisenberg/poetry-python2
Disable python2 + poetry
2022-06-24 13:50:46 -07:00
Andrew Eisenberg
b38dc80666 Merge branch 'main' into aeisenberg/multi-lang-packs 2022-06-24 11:20:12 -07:00
Andrew Eisenberg
e0411511a5 Update CHANGELOG.md
Co-authored-by: Aditya Sharad <6874315+adityasharad@users.noreply.github.com>
2022-06-24 11:20:06 -07:00
Andrew Eisenberg
c08ab55e3d Merge branch 'main' into aeisenberg/poetry-python2 2022-06-24 10:44:08 -07:00
Andrew Eisenberg
934c0340a7 Update CHANGELOG.md 2022-06-24 10:21:24 -07:00
Andrew Eisenberg
c18b1d6732 Update changelog 2022-06-24 10:16:08 -07:00
Andrew Eisenberg
8bfe3c6be5 Disable python2 + poetry 2022-06-24 10:09:46 -07:00
Andrew Eisenberg
4efa7d6115 Merge pull request #1119 from github/aeisenberg/runner-dependabot-fix
Fix dependabot warnings in runner
2022-06-24 09:09:13 -07:00
Andrew Eisenberg
c699821722 Update runner dependencies 2022-06-23 11:46:42 -07:00
Andrew Eisenberg
7fa4dc3512 Fix dependabot warnings in runner
Note that this changes the lock file format
from 1 to 2, so there are many changes here.
2022-06-23 10:33:54 -07:00
Andrew Eisenberg
a965b69658 Merge pull request #1118 from github/mergeback/v2.1.14-to-main-41a4ada3
Mergeback v2.1.14 refs/heads/releases/v2 into main
2022-06-22 21:28:54 -07:00
Andrew Eisenberg
714ec5a57d Merge pull request #1117 from github/update-v1.1.14-41a4ada3
Merge releases/v2 into releases/v1
2022-06-22 19:15:29 -07:00
github-actions[bot]
98b2df478b Update checked-in dependencies 2022-06-23 00:26:15 +00:00
github-actions[bot]
3b151b1bde Update checked-in dependencies 2022-06-23 00:11:35 +00:00
github-actions[bot]
f9fd90ed60 Update changelog and version after v2.1.14 2022-06-22 23:54:13 +00:00
github-actions[bot]
f4fb1cfb88 Update version and changelog for v1.1.14 2022-06-22 23:53:49 +00:00
github-actions[bot]
876c187c13 Merge remote-tracking branch 'origin/releases/v2' into update-v1.1.14-41a4ada3 2022-06-22 23:53:49 +00:00
github-actions[bot]
fef25133ac Revert "Update checked-in dependencies"
This reverts commit c053e94e7d.
2022-06-22 23:53:49 +00:00
github-actions[bot]
a8d485f901 Revert "Update version and changelog for v1.1.13"
This reverts commit e47f040350.
2022-06-22 23:53:48 +00:00
Andrew Eisenberg
41a4ada31b Merge pull request #1114 from github/update-v2.1.14-2e0c6caf
Merge main into releases/v2
2022-06-22 16:52:17 -07:00
Andrew Eisenberg
e524cd64db Update branch names for check-for-conflicts.yml job 2022-06-22 16:07:46 -07:00
Andrew Eisenberg
1653a84fbc Allow scans with packs for languages not being scanned
Previously, we were being too strict about checking that a pack's
language was being scanned. It was a failure if a pack language
was specified for a language not being scanned.
2022-06-22 14:37:31 -07:00
github-actions[bot]
08f9ac4674 Update changelog for v2.1.14 2022-06-22 14:37:09 +00:00
Andrew Eisenberg
2e0c6caf16 Merge pull request #1111 from github/aeisenberg/revert-1098
Revert "Add capability to filter queries #1098"
2022-06-21 14:25:59 -07:00
Andrew Eisenberg
99d4397d88 Revert "Add capability to filter queries #1098"
https://github.com/github/codeql-action/pull/1098
This reverts commit 777b778409.
This reverts commit 59ca9b59cb.
This reverts commit eec34d5f05.
This reverts commit 40b280032c.
2022-06-21 13:49:33 -07:00
Edoardo Pirovano
47dc295f08 Merge pull request #1110 from github/edoardo/case-insensitive-update
Fix issue with required checks sync script
2022-06-21 15:10:59 +01:00
Edoardo Pirovano
5a6f006e4d Fix issue with required checks sync script 2022-06-21 13:20:45 +01:00
Edoardo Pirovano
614d63af76 Merge pull request #1109 from github/update-v1.1.13-d00e8c09
Merge releases/v2 into releases/v1
2022-06-21 12:58:19 +01:00
Edoardo Pirovano
ceacebd3ff Merge pull request #1108 from github/mergeback/v2.1.13-to-main-d00e8c09
Mergeback v2.1.13 refs/heads/releases/v2 into main
2022-06-21 12:56:32 +01:00
github-actions[bot]
c053e94e7d Update checked-in dependencies 2022-06-21 10:38:03 +00:00
Edoardo Pirovano
d069ed5c71 Merge branch 'main' into mergeback/v2.1.13-to-main-d00e8c09 2022-06-21 11:26:28 +01:00
github-actions[bot]
0e17d37ac3 Update checked-in dependencies 2022-06-21 10:23:20 +00:00
Cornelius Riemenschneider
2318cf79e9 Merge pull request #1106 from github/criemen/bump-lua-tracer-version
Bump lua tracer version requirement.
2022-06-21 11:44:40 +02:00
github-actions[bot]
e47f040350 Update version and changelog for v1.1.13 2022-06-21 09:43:36 +00:00
github-actions[bot]
4d013d7594 Merge remote-tracking branch 'origin/releases/v2' into update-v1.1.13-d00e8c09 2022-06-21 09:43:35 +00:00
github-actions[bot]
3b2cf8914c Revert "Update checked-in dependencies"
This reverts commit 6efabfeaef.
2022-06-21 09:43:35 +00:00
github-actions[bot]
9d650fdc1f Revert "Update version and changelog for v1.1.12"
This reverts commit 24d91cb4e9.
2022-06-21 09:43:35 +00:00
github-actions[bot]
b2786f5323 Update changelog and version after v2.1.13 2022-06-21 09:43:31 +00:00
Edoardo Pirovano
d00e8c09a3 Merge pull request #1107 from github/update-v2.1.13-31367d4e
Merge main into releases/v2
2022-06-21 10:41:43 +01:00
github-actions[bot]
8bd4419d1e Update changelog for v2.1.13 2022-06-21 08:59:28 +00:00
Cornelius Riemenschneider
99acb8dda6 Bump lua tracer version requirement.
The old version had a bug related to go autobuilding, so we only want to
respect the feature flag for the version that has the fix.
2022-06-20 14:05:26 +00:00
Edoardo Pirovano
31367d4e57 Merge pull request #1100 from github/edoardo/2.9.4-bump
Update default CodeQL version to 2.9.4
2022-06-20 14:46:48 +01:00
Edoardo Pirovano
ccf5d70ab3 Update default CodeQL version to 2.9.4 2022-06-20 09:39:11 +01:00
Andrew Eisenberg
30fe0a56d2 Merge pull request #1103 from github/aeisenberg/fix-required-checks-script
Ensure there are no duplicates when sending up required checks
2022-06-17 15:48:46 +02:00
Andrew Eisenberg
7adb33da1d Ensure there are no duplicates when sending up required checks
This breaks the API. Also, fix the checks that had duplicate names.
2022-06-16 20:31:29 -07:00
Andrew Eisenberg
2e111b27f7 Merge pull request #1102 from github/aeisenberg/fix-query-filters-test
Fix input to action
2022-06-17 03:56:40 +02:00
Andrew Eisenberg
c7785f6b91 Fix input to action 2022-06-16 18:34:04 -07:00
Andrew Eisenberg
2e80c74b1b Merge pull request #1096 from github/aeisenberg/check-sarif-action
Add the check-sarif action
2022-06-16 03:39:00 +02:00
Andrew Eisenberg
80ecdcdf69 Merge pull request #1098 from github/aeisenberg/remove-queries
Add capability to filter queries
2022-06-15 17:52:46 -07:00
Andrew Eisenberg
7c412c67ba Merge branch 'aeisenberg/check-sarif-action' into aeisenberg/remove-queries 2022-06-16 02:42:30 +02:00
Andrew Eisenberg
ee4575b213 Merge branch 'main' into aeisenberg/check-sarif-action 2022-06-16 02:39:30 +02:00
Henry Mercer
d2ab7a2abb Merge pull request #1086 from github/update-supported-enterprise-server-versions
Update supported GitHub Enterprise Server versions.
2022-06-16 01:37:12 +01:00
Andrew Eisenberg
d7459f0368 Merge branch 'aeisenberg/check-sarif-action' into aeisenberg/remove-queries 2022-06-16 02:22:34 +02:00
Andrew Eisenberg
6db77eec0d Merge remote-tracking branch 'upstream/main' into aeisenberg/remove-queries 2022-06-15 17:21:05 -07:00
Andrew Eisenberg
777b778409 Spelling, capitalization, and better descriptions 2022-06-15 17:18:35 -07:00
GitHub
97f9db4fb9 Update supported GitHub Enterprise Server versions. 2022-06-16 00:11:36 +00:00
Andrew Eisenberg
59ca9b59cb Extract query-filters test into a composite action
Removes duplicated yaml.

Also add some better typings.
2022-06-15 16:32:33 -07:00
Andrew Eisenberg
6834383903 Apply suggestions from code review
Co-authored-by: Henry Mercer <henrymercer@github.com>
2022-06-15 16:27:01 -07:00
Andrew Eisenberg
4918636a75 Clarify variable names in new action
Also simplify some computations.
2022-06-15 16:06:16 -07:00
Andrew Eisenberg
428caf0cf5 Update changelog 2022-06-15 14:11:03 -07:00
Tom Bolton
df05122fc6 Merge pull request #1087 from github/tombolton/update-ml-pack
Run ML-powered query pack `~0.3.0` on v2.9.3+ of the CLI
2022-06-15 15:55:43 +01:00
tombolton
a27dc4fee4 update security extended test for all platforms 2022-06-15 11:42:22 +01:00
tombolton
a568674c69 add tests for ML powered queries 0.3.0 and CLI 2.9.3 2022-06-15 11:42:22 +01:00
tombolton
f8f4c0b33e compile the modified TypeScript to Javascript 2022-06-15 11:42:22 +01:00
tombolton
79d8e4a43d fix lint errors 2022-06-15 11:42:22 +01:00
tombolton
0ece1d1000 add ml query pack 0.3.0 2022-06-15 11:42:22 +01:00
Andrew Eisenberg
81b419c908 Merge pull request #1097 from github/aeisenberg/js-yaml-typings 2022-06-15 05:56:07 +02:00
Andrew Eisenberg
eec34d5f05 Add integration tests for query filters 2022-06-14 14:10:08 -07:00
Andrew Eisenberg
06e27d3e3d Merge branch 'aeisenberg/js-yaml-typings' into aeisenberg/remove-queries 2022-06-14 12:08:16 -07:00
Andrew Eisenberg
40b280032c Add capability to filter queries
This change adds a `query-filters` property to the codeql-config file.

This property is an array of `exclude`/`include` entries for a query
suite. These filters are appended to the generated query suite files
and used to filter queries after they are selected.

A related change is that now, all pack references are run in a single
query suite, which has the query filters appended to them.
2022-06-14 12:07:49 -07:00
Andrew Eisenberg
bcb7fad5b3 Add the check-sarif action
Allows us to analyze and then check that certain queries were included
in the analysis and others were not.
2022-06-14 11:55:10 -07:00
Andrew Eisenberg
0efcf74ce0 Add typings for js-yaml 2022-06-14 07:50:47 -07:00
Andrew Eisenberg
29a2159db1 Merge pull request #1095 from github/aeisenberg/use-del
Avoid use of rmdir
2022-06-14 02:55:00 +02:00
Andrew Eisenberg
f7c46e5cbc Avoid use of rmdir
This is a deprecated method on node v16.
2022-06-13 22:40:09 +00:00
Andrew Eisenberg
ccf479d336 Merge pull request #1085 from github/swift-support
Add Swift as a possible traced language
2022-06-02 17:43:40 -07:00
Mathias Vorreiter Pedersen
1b5ea4afdc Merge branch 'main' into swift-support 2022-06-03 01:13:47 +01:00
Andrew Eisenberg
69e09909dc Merge pull request #1089 from github/mergeback/v2.1.12-to-main-27ea8f8f
Mergeback v2.1.12 refs/heads/releases/v2 into main
2022-06-01 13:39:46 -07:00
Chuan-kai Lin
a6611b8691 Merge pull request #1090 from github/update-v1.1.12-27ea8f8f
Merge releases/v2 into releases/v1
2022-06-01 12:47:07 -07:00
github-actions[bot]
632cc8efb3 Update checked-in dependencies 2022-06-01 18:35:33 +00:00
github-actions[bot]
6efabfeaef Update checked-in dependencies 2022-06-01 18:30:51 +00:00
github-actions[bot]
24d91cb4e9 Update version and changelog for v1.1.12 2022-06-01 17:58:43 +00:00
github-actions[bot]
b6b48ceae3 Merge remote-tracking branch 'origin/releases/v2' into update-v1.1.12-27ea8f8f 2022-06-01 17:58:28 +00:00
github-actions[bot]
af390c0075 Revert "Update checked-in dependencies"
This reverts commit 459cf02690.
2022-06-01 17:58:28 +00:00
github-actions[bot]
4c3af19a40 Revert "Update version and changelog for v1.1.11"
This reverts commit acc7a4bc97.
2022-06-01 17:58:28 +00:00
github-actions[bot]
57096f1d43 Update changelog and version after v2.1.12 2022-06-01 17:58:23 +00:00
Chuan-kai Lin
27ea8f8fe5 Merge pull request #1088 from github/update-v2.1.12-dbe6f211
Merge main into releases/v2
2022-06-01 10:56:48 -07:00
github-actions[bot]
3f00a1265f Update changelog for v2.1.12 2022-06-01 16:43:15 +00:00
Chuan-kai Lin
dbe6f211e6 Merge pull request #1084 from github/cklin/codeql-bundle-2.9.3
Update default CodeQL to 2.9.3
2022-05-31 09:20:46 -07:00
Mathias Vorreiter Pedersen
16c620dea4 Make the linter happy. 2022-05-31 13:55:23 +01:00
Chuan-kai Lin
b36688d5b7 Update default CodeQL to 2.9.3 2022-05-27 09:16:45 -07:00
Mathias Vorreiter Pedersen
bfe9d7da56 Add Swift as a supported language. 2022-05-27 16:29:13 +01:00
Cornelius Riemenschneider
822fe5ef9a Merge pull request #1057 from github/criemen/lua-tracing-ff
Introduce a feature-flag to enable/disable lua-based tracing.
2022-05-25 12:33:41 +02:00
Cornelius Riemenschneider
255ffd480f Merge branch 'main' into criemen/lua-tracing-ff 2022-05-25 11:53:06 +02:00
Cornelius Riemenschneider
4b775686a0 Choose the correct version to enable the Lua tracer for. 2022-05-25 07:39:11 +00:00
Marco Gario
f0705a6d6f Merge pull request #1081 from github/clarify_missing_base
Remove outdated guidance on missing analysis
2022-05-19 08:32:10 +02:00
Marco Gario
2faa3e16f3 Remove outdated guidance on missing analysis
As of December 2021, we do not return missing base analysis anymore.
2022-05-17 12:04:13 +02:00
Edoardo Pirovano
aaff818427 Merge pull request #1079 from github/mergeback/v2.1.11-to-main-a3a6c128
Mergeback v2.1.11 refs/heads/releases/v2 into main
2022-05-17 10:59:43 +01:00
Edoardo Pirovano
0e9acb6e5c Merge pull request #1080 from github/update-v1.1.11-a3a6c128
Merge releases/v2 into releases/v1
2022-05-17 10:58:00 +01:00
github-actions[bot]
459cf02690 Update checked-in dependencies 2022-05-17 09:02:42 +00:00
github-actions[bot]
6f285ad15b Update checked-in dependencies 2022-05-17 08:42:16 +00:00
github-actions[bot]
c88cf91b1f Update changelog and version after v2.1.11 2022-05-17 08:23:51 +00:00
github-actions[bot]
acc7a4bc97 Update version and changelog for v1.1.11 2022-05-17 08:23:48 +00:00
github-actions[bot]
d25b8aca1b Merge remote-tracking branch 'origin/releases/v2' into update-v1.1.11-a3a6c128 2022-05-17 08:23:47 +00:00
github-actions[bot]
c6fc792e04 Revert "Update checked-in dependencies"
This reverts commit ec7fba1280.
2022-05-17 08:23:47 +00:00
github-actions[bot]
d28ac7880b Revert "Update version and changelog for v1.1.10"
This reverts commit 46d6a93dcc.
2022-05-17 08:23:47 +00:00
Edoardo Pirovano
a3a6c128d7 Merge pull request #1078 from github/update-v2.1.11-657c2f3f
Merge main into releases/v2
2022-05-17 09:22:11 +01:00
github-actions[bot]
657581e7a8 Update changelog for v2.1.11 2022-05-17 07:54:00 +00:00
Edoardo Pirovano
657c2f3ff0 Merge pull request #1074 from github/edoardo/2.9.2-update
Update default CodeQL to 2.9.2
2022-05-16 14:22:11 +01:00
Cornelius Riemenschneider
970e0879d9 Fix linter errors. 2022-05-16 09:40:10 +00:00
Cornelius Riemenschneider
db50adab01 Add tests for the Lua feature flag. 2022-05-16 09:16:41 +00:00
Cornelius Riemenschneider
9e9a8428c3 Introduce a feature-flag to enable/disable lua-based tracing.
This allows us to gradually roll out (or even roll back)
Lua-based tracing in case problems occur.
2022-05-16 09:16:38 +00:00
Edoardo Pirovano
1725087693 Update default CodeQL to 2.9.2 2022-05-16 09:40:19 +01:00
Henry Mercer
e655565390 Merge pull request #1076 from github/henrymercer/fix-changelog-typo
Fix a typo in the CHANGELOG
2022-05-13 17:30:42 +01:00
Henry Mercer
c38e41c45a Fix a typo in the CHANGELOG
`2.9.5 -> 2.9.1` — I missed this during review.
2022-05-13 16:55:08 +01:00
Henry Mercer
0658e4b2d6 Merge pull request #1075 from github/henrymercer/update-actions-tool-cache
Bump @actions/tool-cache to 2.0.0
2022-05-13 14:45:57 +01:00
Henry Mercer
54b4854fda Bump @actions/tool-cache to 2.0.0
This allows us to drop our direct dependency on `@actions/http-client`.
2022-05-13 11:54:40 +01:00
Henry Mercer
1fae5bf71b Merge pull request #1051 from github/henrymercer/run-atm-on-windows
Run ML-powered queries on Windows with CodeQL CLI 2.9.0+
2022-05-11 20:03:26 +01:00
Henry Mercer
533ce91971 Merge remote-tracking branch 'origin/main' into henrymercer/run-atm-on-windows 2022-05-11 19:32:14 +01:00
Henry Mercer
ace076b980 Merge pull request #1070 from github/mergeback/v2.1.10-to-main-2f58583a
Mergeback v2.1.10 refs/heads/releases/v2 into main
2022-05-11 18:36:28 +01:00
Henry Mercer
5e59d8eec4 Merge pull request #1071 from github/update-v1.1.10-2f58583a
Merge releases/v2 into releases/v1
2022-05-11 18:34:38 +01:00
github-actions[bot]
ec7fba1280 Update checked-in dependencies 2022-05-11 16:07:10 +00:00
Henry Mercer
97847a4dde Merge branch 'main' into mergeback/v2.1.10-to-main-2f58583a 2022-05-11 16:59:06 +01:00
github-actions[bot]
46d6a93dcc Update version and changelog for v1.1.10 2022-05-11 15:52:27 +00:00
github-actions[bot]
ab69202a0b Merge remote-tracking branch 'origin/releases/v2' into update-v1.1.10-2f58583a 2022-05-11 15:52:26 +00:00
github-actions[bot]
93c20939ac Revert "Update checked-in dependencies"
This reverts commit e3983ef751.
2022-05-11 15:52:26 +00:00
github-actions[bot]
c1672e532f Revert "Update version and changelog for v1.1.9"
This reverts commit e34f3ea243.
2022-05-11 15:52:26 +00:00
github-actions[bot]
f8c88ab2dc Update changelog and version after v2.1.10 2022-05-11 15:51:54 +00:00
Henry Mercer
2f58583a1b Merge pull request #1069 from github/henrymercer/fix-integration-tests-on-v1
Fix integration tests on v1
2022-05-11 16:48:31 +01:00
Henry Mercer
4e0668d05e Fix integration tests on v1
The GitHub API client coerces `fake-server-url` to the Dotcom API URL,
which means commands like `util.getGitHubVersion` will call the Dotcom
API with the `fake-token`, resulting in 401s.

We therefore use the Dotcom URL instead and additionally stub
`util.getGitHubVersion` as a good practice (it's no longer necessary).
2022-05-11 15:53:57 +01:00
Henry Mercer
c4fdf5fe69 Merge pull request #1067 from github/mergeback/v2.1.10-to-main-03e2e3c4
Mergeback v2.1.10 refs/heads/releases/v2 into main
2022-05-11 13:14:15 +01:00
Henry Mercer
4f87830a1f Merge branch 'main' into mergeback/v2.1.10-to-main-03e2e3c4 2022-05-11 12:00:48 +01:00
github-actions[bot]
daf6560612 Update changelog and version after v2.1.10 2022-05-11 10:57:56 +00:00
Henry Mercer
03e2e3c45f Merge pull request #1065 from github/henrymercer/remove-extraneous-commit
Remove an extraneous commit during the release process
2022-05-11 11:39:31 +01:00
Henry Mercer
3bb6c41212 Remove an extraneous commit during the release process
We only need to run `git commit` after the `git merge` call if there were conflicts.
2022-05-11 10:50:13 +01:00
Alexander Eyers-Taylor
38fc5ebb37 Merge pull request #1064 from github/mergeback/v2.1.10-to-main-75b4f1c4
Mergeback v2.1.10 refs/heads/releases/v2 into main
2022-05-10 20:12:54 +01:00
Henry Mercer
a82d691646 Merge branch 'main' into mergeback/v2.1.10-to-main-75b4f1c4 2022-05-10 19:32:12 +01:00
github-actions[bot]
ca6773e404 Update checked-in dependencies 2022-05-10 17:39:06 +00:00
Andrew Eisenberg
8dbd96566a Merge pull request #1063 from github/aeisenberg/contrib
Update contributing.md
2022-05-10 10:25:04 -07:00
github-actions[bot]
ef73e3bee8 Update changelog and version after v2.1.10 2022-05-10 17:05:35 +00:00
Alexander Eyers-Taylor
75b4f1c466 Merge pull request #1062 from github/update-v2.1.10-7cf0ed5e
Merge main into releases/v2
2022-05-10 18:03:52 +01:00
Andrew Eisenberg
d468c94a69 Update contributing.md
Change the text for keeping the checks up to date.
2022-05-10 09:55:27 -07:00
Rasmus Wriedt Larsen
7c55012151 Merge pull request #1039 from github/rasmuswl/pip-python2-fix
python-setup: Check if `pip` is already installed for Python2
2022-05-10 14:17:06 +02:00
github-actions[bot]
f8eea91a7b Update changelog for v2.1.10 2022-05-10 11:33:39 +00:00
Henry Mercer
878b64e0ef Merge branch 'main' into rasmuswl/pip-python2-fix 2022-05-10 10:52:20 +01:00
Andrew Eisenberg
7cf0ed5e3f Merge pull request #1060 from github/aeisenberg/required-checks-script
Create update-required-checks script
2022-05-10 02:50:12 -07:00
Rasmus Wriedt Larsen
b651a677d2 Merge branch 'main' into rasmuswl/pip-python2-fix 2022-05-10 10:51:39 +02:00
Andrew Eisenberg
827fd55c21 Create update-required-checks script
This also removes the .github/workflows/update-required-checks.yml
workflow. This script needs to be run locally by someone who has
admin privileges on the repo.
2022-05-09 14:59:16 -07:00
Alexander Eyers-Taylor
dd56e95b46 Merge pull request #1056 from github/alexet/update-2.9.1
Update codeql to 2.9.1
2022-05-05 16:52:48 +01:00
alexet
3c6dd303a8 Update codeql to 2.9.1 2022-05-03 15:58:57 +01:00
Chris Gavin
96bc9c36c6 Merge pull request #1055 from github/fix-status-error-being-caught
Fix processing errors being caught and logged as a warning rather than failing the workflow run.
2022-05-03 13:21:10 +01:00
Chris Gavin
366e88c2c1 Fix processing errors being caught and logged as a warning rather than failing the workflow run. 2022-05-03 10:06:19 +01:00
Andrew Eisenberg
7b66e72cb7 Merge pull request #1054 from github/aeisenberg/update-checks
Add permissions to workflow
2022-05-02 12:46:59 -07:00
Andrew Eisenberg
06d4e82bd2 Add permissions block to workflow 2022-05-02 12:01:19 -07:00
Andrew Eisenberg
0fb78380f8 Merge pull request #1053 from github/aeisenberg/update-checks
Add workflow to regenerate required checks
2022-05-02 10:44:05 -07:00
Andrew Eisenberg
b71f20d70f Add workflow to regenerate required checks
Update contributing guide.
Ensure this workflow runs once a week.
2022-05-02 10:15:40 -07:00
Andrew Eisenberg
8f845425a2 Merge pull request #1052 from github/aeisenberg/required-checks
Update CONTRIBUTING.md
2022-05-02 09:25:35 -07:00
Andrew Eisenberg
c9882bef2d Update CONTRIBUTING.md 2022-05-02 08:58:10 -07:00
Andrew Eisenberg
9a6bf18ec4 Update CONTRIBUTING.md
Clarify instructions for updating required checks
2022-05-02 08:29:30 -07:00
Andrew Eisenberg
0235de0279 Merge pull request #1049 from github/aeisenberg/packs-with-paths
Allow running packs with paths
2022-05-02 08:24:46 -07:00
Andrew Eisenberg
a73e506617 Fix syntax error in workflow 2022-04-29 17:33:21 -07:00
Andrew Eisenberg
b11fe85402 Merge branch 'main' into aeisenberg/packs-with-paths 2022-04-29 11:10:16 -07:00
Andrew Eisenberg
922dc2b976 Use the --resolve-query-specs parameter of pack download
This will allow the command to resolve packs with paths.

Also, use a more concise version of `tr`.
2022-04-29 10:54:01 -07:00
Henry Mercer
395afb1dd9 Fix unit test assertion on Windows 2022-04-29 18:18:19 +01:00
Henry Mercer
ceeddf2638 Merge pull request #1050 from github/henrymercer/dont-wait-for-processing-in-test-mode
Don't wait for processing in test mode
2022-04-29 10:26:03 +01:00
Andrew Eisenberg
06b15c22b1 Allow pack specifiers to include paths
Also, this cleans up our pack-related integration tests.
We are now testing with the most recent CLIs.
2022-04-28 17:14:30 -07:00
Henry Mercer
ed0abc6cac Log the expected outcome of the tests for clarity 2022-04-28 19:21:56 +01:00
Henry Mercer
193cfa588d Update PR checks for Windows and CodeQL CLI 2.9.0+ 2022-04-28 19:18:15 +01:00
Henry Mercer
d9e30cb001 Run ML-powered queries on Windows with CodeQL CLI 2.9.0+ 2022-04-28 19:18:15 +01:00
Henry Mercer
ea676e3184 Don't wait for processing in test mode
In test mode, we don't upload results, so there's no point waiting for
processing.
2022-04-28 19:14:14 +01:00
Henry Mercer
7c2be06006 Factor out test mode determination code 2022-04-28 19:13:22 +01:00
Henry Mercer
0c3c093eba Merge pull request #1045 from github/henrymercer/prompt-v1-to-v2-upgrades
Prompt customers to upgrade from v1 to v2
2022-04-28 18:50:10 +01:00
Henry Mercer
2bf00f719d Merge branch 'main' into henrymercer/prompt-v1-to-v2-upgrades 2022-04-28 14:17:36 +01:00
Henry Mercer
02083c307e Add a comment to explain why we show the upgrade message on GHES 3.4 2022-04-28 14:16:32 +01:00
Henry Mercer
35ef6a2db3 Move formatGitHubVersion into util.test.ts 2022-04-28 14:16:32 +01:00
Henry Mercer
5227afabbe Tweak wording of message 2022-04-28 14:16:32 +01:00
Edoardo Pirovano
6ed7f70798 Merge pull request #1047 from github/mergeback/v2.1.9-to-main-7502d6e9
Mergeback v2.1.9 refs/heads/releases/v2 into main
2022-04-28 09:39:17 +01:00
github-actions[bot]
04f504ca7f Update checked-in dependencies 2022-04-27 20:55:44 +00:00
Henning Makholm
6c3ae45f3a Merge pull request #1048 from github/update-v1.1.9-7502d6e9
Merge releases/v2 into releases/v1
2022-04-27 22:39:57 +02:00
Henning Makholm
8371fda073 manually resolve conflict in favor of node12 for v1 2022-04-27 22:08:55 +02:00
github-actions[bot]
e3983ef751 Update checked-in dependencies 2022-04-27 18:36:25 +00:00
github-actions[bot]
e34f3ea243 Update version and changelog for v1.1.9 2022-04-27 18:21:56 +00:00
github-actions[bot]
d9937ad6ad Merge remote-tracking branch 'origin/releases/v2' into update-v1.1.9-7502d6e9
# Conflicts:
#	autobuild/action.yml
2022-04-27 18:21:55 +00:00
github-actions[bot]
f703d1ca07 Revert "Update checked-in dependencies"
This reverts commit c7b049b347.
2022-04-27 18:21:55 +00:00
github-actions[bot]
acf17f7547 Revert "Update version and changelog for v1.1.8"
This reverts commit f679ec9aa9.
2022-04-27 18:21:55 +00:00
github-actions[bot]
016ec75b7c Update changelog and version after v2.1.9 2022-04-27 18:21:50 +00:00
Henning Makholm
7502d6e991 Merge pull request #1046 from github/update-v2.1.9-72861144
Merge main into releases/v2
2022-04-27 20:20:29 +02:00
github-actions[bot]
cbce00d08d Update changelog for v2.1.9 2022-04-27 16:41:08 +00:00
Henry Mercer
0256599547 Prompt customers to upgrade from v1 to v2 2022-04-27 16:11:24 +01:00
Chuan-kai Lin
72861144fd Merge pull request #1042 from cklin/windows-status-report-error
Fix status reporting error on Windows
2022-04-26 08:46:38 -07:00
Chuan-kai Lin
6dd9baf8be Fix status reporting error on Windows 2022-04-26 08:06:57 -07:00
Henry Mercer
ff8b365e79 Merge pull request #1044 from github/adityasharad/readme/replace-git-io
README: Replace git.io shortlink with full link
2022-04-26 12:30:02 +01:00
Henry Mercer
eed184a534 Merge branch 'main' into adityasharad/readme/replace-git-io 2022-04-26 10:44:55 +01:00
Henry Mercer
c76f0b5b07 Merge pull request #1032 from github/henrymercer/handle-merge-conflicts-in-releases
Commit any conflicts during v1 backport to simplify release process
2022-04-26 10:43:55 +01:00
Aditya Sharad
bf4ba6945d README: Replace git.io shortlink with full link
git.io is deprecated, so use the full link to docs.github.com instead.
2022-04-26 02:14:44 -07:00
Henry Mercer
d2d14adf3e Merge branch 'main' into henrymercer/handle-merge-conflicts-in-releases 2022-04-26 10:03:00 +01:00
Henning Makholm
95b49c3e6b Merge pull request #1038 from github/hmakholm/pr/2.9.0
Bump default CodeQL version to 2.9.0
2022-04-26 03:03:24 +02:00
Henning Makholm
80771fd2d0 Merge branch 'main' into hmakholm/pr/2.9.0 2022-04-26 02:33:49 +02:00
Henry Mercer
2b8fdb3f2e Merge branch 'main' into henrymercer/handle-merge-conflicts-in-releases 2022-04-25 17:02:03 +01:00
Henry Mercer
074853a9a2 Suggest resolving conflicts by adding new commits vs amending the merge commit
This gives us slightly messier git history, but more importantly makes
reviewing substantially easier.
2022-04-25 16:37:32 +01:00
Henry Mercer
ce63ab5d00 Merge pull request #1033 from github/henrymercer/use-tags-for-releases
Specify releases of the CodeQL Action using tags instead of branches
2022-04-25 13:22:12 +01:00
Henry Mercer
e87e2d8201 Merge branch 'main' into henrymercer/use-tags-for-releases 2022-04-25 09:56:42 +01:00
Rasmus Wriedt Larsen
8a646279fc python-setup: Check if pip is already installed for Python2 2022-04-22 10:32:29 +02:00
Henning Makholm
23b7196b6b Bump default CodeQL version to 2.9.0 2022-04-21 23:12:38 +02:00
Andrew Eisenberg
e6e327771b Merge pull request #1026 from kojiromike/patch-1 2022-04-18 09:18:46 -07:00
Rasmus Wriedt Larsen
b9577df761 python-setup: refactor Pipenv without lockfile 2022-04-18 11:14:14 -04:00
Michael A. Smith
808c29257b Support Pipfile without Pipfile.lock
As previously written, if codeql finds a `Pipfile`, but no `Pipfile.lock`, it will run `pipenv install` with args that require `Pipfile.lock` to exist. Pipfile will fail with this message:

```
  Usage: python -m pipenv install [OPTIONS] [PACKAGES]...
  
  ERROR:: Pipfile.lock must exist to use --keep-outdated!
  package installation with pipenv failed, see error above
```

This changeset enables auto_install to work with Pipfile when there is no lock. (Bonus: `--skip-lock` is generally a bit faster.)
2022-04-18 11:14:14 -04:00
Henry Mercer
5b5ed44ab7 Add a PR check to check for conflict markers
This check is primarily intended to validate that any merge conflicts in
the v2 -> v1 backport PR are fixed before the PR is merged.
2022-04-14 20:05:42 +01:00
Henry Mercer
faf9d4b499 Merge branch 'main' into henrymercer/use-tags-for-releases 2022-04-14 19:40:48 +01:00
Henry Mercer
8b2f5d7158 Merge pull request #1034 from github/dependabot/npm_and_yarn/glob-8.0.1
Bump glob from 7.1.7 to 8.0.1
2022-04-14 19:39:48 +01:00
github-actions[bot]
0ba58d8497 Update checked-in dependencies 2022-04-14 17:56:23 +00:00
dependabot[bot]
3962f1bd85 Bump glob from 7.1.7 to 8.0.1
Bumps [glob](https://github.com/isaacs/node-glob) from 7.1.7 to 8.0.1.
- [Release notes](https://github.com/isaacs/node-glob/releases)
- [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
- [Commits](https://github.com/isaacs/node-glob/compare/v7.1.7...v8.0.1)

---
updated-dependencies:
- dependency-name: glob
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-14 17:00:42 +00:00
Henry Mercer
9daf1de73c Update references to release branches
Prepare for renaming `v1` -> `releases/v1` and `v2` -> `releases/v2`.
2022-04-14 17:48:46 +01:00
Henry Mercer
bce749b10f Improve consistency of variable references in Bash 2022-04-14 17:48:46 +01:00
Henry Mercer
fce4a01cd7 Update the major version tag within the release process 2022-04-14 17:48:46 +01:00
Henry Mercer
bac9320f4f Update description of "Tag release and merge back" workflow 2022-04-14 17:48:46 +01:00
Henry Mercer
b3bf557359 Merge branch 'main' into henrymercer/handle-merge-conflicts-in-releases 2022-04-14 17:41:31 +01:00
Henry Mercer
f6312f1322 Commit any conflicts during v1 backport to simplify release process
The process of creating the v1 release can run into merge conflicts. We
commit the unresolved conflicts so a maintainer can easily resolve them
(vs erroring and requiring maintainers to reconstruct the release
manually).
2022-04-14 16:08:38 +01:00
Chris Gavin
c5c5bdabb9 Merge pull request #1007 from github/wait-for-processing-2
Re-enable waiting for processing by default, using the new API semantics.
2022-04-14 09:29:10 +01:00
Chris Gavin
e7869d541b Merge main into wait-for-processing-2. 2022-04-14 08:49:44 +01:00
Henry Mercer
7a12645d7e Merge pull request #1030 from github/RasmusWL/pyton-setup-codeowners
Add codeql-python as CODEOWNERS
2022-04-12 16:01:41 +01:00
Rasmus Wriedt Larsen
9f20addbf2 Update CODEOWNERS
Co-authored-by: Henry Mercer <henrymercer@github.com>
2022-04-12 16:34:35 +02:00
Rasmus Wriedt Larsen
780f4ee1bf Add codeql-python as CODEOWNERS 2022-04-12 11:40:51 +02:00
Chuan-kai Lin
baf90d17d2 Merge pull request #1024 from cklin/autobuild-working-dir
autobuild: add working-directory input
2022-04-08 16:20:01 -07:00
Chuan-kai Lin
6f174084dd Add autobuild workind-directory test 2022-04-08 15:18:11 -07:00
Chuan-kai Lin
b0c570ef83 autobuild: add working-directory input 2022-04-08 13:37:42 -07:00
Edoardo Pirovano
2d80fe85fc Merge pull request #1029 from github/mergeback/v2.1.8-to-main-1ed14374
Mergeback v2.1.8 refs/heads/v2 into main
2022-04-08 10:58:37 +01:00
Edoardo Pirovano
e2cc7cc006 Merge pull request #1028 from github/update-v1.1.8-1ed14374
Merge v2 into v1
2022-04-08 10:55:32 +01:00
github-actions[bot]
0c80741707 Update checked-in dependencies 2022-04-08 09:02:30 +00:00
github-actions[bot]
c7b049b347 Update checked-in dependencies 2022-04-08 08:58:43 +00:00
github-actions[bot]
792bbfea04 Update changelog and version after v2.1.8 2022-04-08 08:46:10 +00:00
github-actions[bot]
f679ec9aa9 Update version and changelog for v1.1.8 2022-04-08 08:46:06 +00:00
github-actions[bot]
d9f89b3dfd Merge remote-tracking branch 'origin/v2' into update-v1.1.8-1ed14374 2022-04-08 08:46:06 +00:00
github-actions[bot]
0ab00f44cb Revert "Update checked-in dependencies"
This reverts commit 7eac76fcb4.
2022-04-08 08:46:06 +00:00
github-actions[bot]
026ff35db0 Revert "Update version and changelog for v1.1.7"
This reverts commit 3d10ffe493.
2022-04-08 08:46:05 +00:00
Edoardo Pirovano
1ed1437484 Merge pull request #1027 from github/update-v2.1.8-739937f1
Merge main into v2
2022-04-08 09:44:43 +01:00
github-actions[bot]
3ed22c8145 Update changelog for v2.1.8 2022-04-08 08:16:27 +00:00
Andrew Eisenberg
739937f14e Merge pull request #1025 from github/aeisenberg/get-runs-api
Exclude pull requests from actions/runs request
2022-04-07 16:12:02 -07:00
Andrew Eisenberg
0ecdac49ad Update changelog 2022-04-07 14:02:50 -07:00
Andrew Eisenberg
426a3951ee Exclude pull requests from actions/runs request
This will save time when fetcing the current run and we
don't use the pull requests for anything anyway. It is
ok to leave out.
2022-04-07 14:02:44 -07:00
Edoardo Pirovano
a0b596246a Merge pull request #1014 from github/edoardo/2.8.5-bump
Update default CodeQL version to 2.8.5
2022-04-07 16:12:41 +01:00
Edoardo Pirovano
5d3e1a701c Update default CodeQL version to 2.8.5 2022-04-07 13:41:02 +01:00
Edoardo Pirovano
b9bb8dd18d Merge pull request #1020 from github/mergeback/v2.1.7-to-main-0182a2c7
Mergeback v2.1.7 refs/heads/v2 into main
2022-04-05 10:50:50 -07:00
Edoardo Pirovano
1fc1008278 Merge pull request #1021 from github/update-v1.1.7-0182a2c7
Merge v2 into v1
2022-04-05 10:38:59 -07:00
github-actions[bot]
11673755ab Update checked-in dependencies 2022-04-05 17:17:35 +00:00
github-actions[bot]
7eac76fcb4 Update checked-in dependencies 2022-04-05 16:35:27 +00:00
github-actions[bot]
3d10ffe493 Update version and changelog for v1.1.7 2022-04-05 16:21:40 +00:00
github-actions[bot]
f5e5590fc8 Merge remote-tracking branch 'origin/v2' into update-v1.1.7-0182a2c7 2022-04-05 16:21:39 +00:00
github-actions[bot]
380041ed00 Revert "Update checked-in dependencies"
This reverts commit 75743c96fc.
2022-04-05 16:21:39 +00:00
github-actions[bot]
8165d30832 Revert "Update version and changelog for v1.1.6"
This reverts commit 03a275bc11.
2022-04-05 16:21:39 +00:00
github-actions[bot]
d0ca51f5e9 Update changelog and version after v2.1.7 2022-04-05 16:21:20 +00:00
Edoardo Pirovano
0182a2c78c Merge pull request #1019 from github/update-v2.1.7-9cab82f2
Merge main into v2
2022-04-05 09:19:51 -07:00
github-actions[bot]
488f78249e Update changelog for v2.1.7 2022-04-05 14:52:53 +00:00
Edoardo Pirovano
9cab82f202 Merge pull request #1018 from github/edoardo/revert-codescanning-config
Revert usage of `--codescanning-config` flag
2022-04-05 07:50:07 -07:00
Edoardo Pirovano
43d066495c Revert usage of --codescanning-config flag 2022-04-05 09:41:07 +01:00
Edoardo Pirovano
f090899ed0 Merge pull request #1015 from github/edoardo/dependency-update
Fix issue with dependencies
2022-04-01 10:08:50 -07:00
Edoardo Pirovano
8a00ed086d Fix issue with dependencies 2022-04-01 17:36:08 +01:00
Henry Mercer
935969c6f7 Merge pull request #1013 from github/henrymercer/ml-powered-query-pack-v0.2.0
Run version `~0.2.0` of the ML-powered query pack on v2.8.4+ of the CLI
2022-03-31 16:25:07 +01:00
Henry Mercer
e26813cf98 Run version ~0.2.0 of the ML-powered query pack for v2.8.4+ of the CLI 2022-03-31 14:58:41 +01:00
Henry Mercer
2c03704a6c Allow the version of the ML-powered pack to depend on the CLI version 2022-03-31 14:58:29 +01:00
Henry Mercer
dd6b592e3e Simplify ML-powered query status report definition
We now limit the cardinality of the ML-powered JS queries status report
field server-side. With no need for a limit on the cardinality of the
status report client-side, we can simplify how we produce it.
2022-03-31 14:55:32 +01:00
Henry Mercer
a90d8bf711 Merge pull request #1011 from github/henrymercer/ml-powered-queries-pr-check
Add a PR check to validate that ML-powered queries are run correctly
2022-03-31 11:13:26 +01:00
Henry Mercer
dc0338e493 Use latest major version of actions/upload-artifact 2022-03-31 10:11:33 +01:00
Henry Mercer
57096fe795 Add a PR check to validate that ML-powered queries are run correctly 2022-03-31 10:11:30 +01:00
Henry Mercer
b0ddf36abe Merge pull request #1012 from github/henrymercer/update-actions-major-versions
Update major versions of Actions in README and workflows
2022-03-30 21:06:16 +01:00
Henry Mercer
1ea2f2d7f1 Merge branch 'main' into henrymercer/update-actions-major-versions 2022-03-30 20:00:06 +01:00
Henry Mercer
9dcc141f12 Merge pull request #1010 from github/henrymercer/stop-running-ml-powered-queries-on-windows
Stop running ML-powered queries on Windows
2022-03-30 19:57:03 +01:00
Henry Mercer
ea751a9fae Update other Actions from v2 to v3 2022-03-30 19:46:09 +01:00
Henry Mercer
a2949f47b3 Update actions/checkout from v2 to v3 2022-03-30 19:46:09 +01:00
Henry Mercer
7871f0d5e1 Update CodeQL Action from v1 to v2 in README 2022-03-30 19:46:09 +01:00
Henry Mercer
e6f3e049b4 Add descriptions to each test 2022-03-30 18:17:06 +01:00
Henry Mercer
e83a1d469e Stop running ML-powered queries on Windows 2022-03-30 18:05:12 +01:00
Edoardo Pirovano
894faced79 Merge pull request #1008 from github/edoardo/no-fail-12.12
Avoid failure if `@types/node` is already 12.12
2022-03-30 17:52:20 +01:00
Edoardo Pirovano
a9095cefc9 Avoid failure if @types/node is already 12.12 2022-03-30 16:58:25 +01:00
Henry Mercer
4d339ae3ec Merge pull request #1009 from github/henrymercer/run-pr-checks-on-v2-branch
Run all PR checks on the `v2` branch
2022-03-30 16:53:09 +01:00
Henry Mercer
381ea36211 Delete unused workflows 2022-03-30 16:00:52 +01:00
Henry Mercer
e769c2dd6e Run all PR checks on v2 branch 2022-03-30 15:59:09 +01:00
Edoardo Pirovano
4c1021c504 Merge pull request #1006 from github/update-v1.1.6-28eead24
Merge v2 into v1
2022-03-30 15:28:29 +01:00
Edoardo Pirovano
bae3a3acab Merge pull request #1005 from github/mergeback/v2.1.6-to-main-28eead24
Mergeback v2.1.6 refs/heads/v2 into main
2022-03-30 14:27:22 +01:00
Edoardo Pirovano
9da34a6ec6 Avoid failure if @types/node is already 12.12 2022-03-30 14:00:43 +01:00
Edoardo Pirovano
f83be76fd8 Revert "Upgrade Node type definitions"
This reverts commit b949e494e4.
2022-03-30 13:49:37 +01:00
Edoardo Pirovano
b45efc9e42 Revert "Use Node.js v16 in all Actions"
This reverts commit 3d23aade46.
2022-03-30 13:49:29 +01:00
github-actions[bot]
75743c96fc Update checked-in dependencies 2022-03-30 12:20:06 +00:00
github-actions[bot]
bcd5c027de Update checked-in dependencies 2022-03-30 11:55:38 +00:00
Chris Gavin
9885f86fab Re-enable waiting for processing by default, using the new API semantics. 2022-03-30 12:24:59 +01:00
github-actions[bot]
03a275bc11 Update version and changelog for v1.1.6 2022-03-30 11:13:40 +00:00
github-actions[bot]
ee3341a9d8 Update changelog and version after v2.1.6 2022-03-30 11:13:37 +00:00
Edoardo Pirovano
28eead2408 Merge pull request #1004 from github/update-v2.1.6-bfe9e810
Merge main into v2
2022-03-30 12:12:52 +01:00
Edoardo Pirovano
a4da970395 Run workflow also on v2 branch 2022-03-30 11:47:41 +01:00
Edoardo Pirovano
34a1681e50 Fix location of changelog entry 2022-03-30 11:11:17 +01:00
github-actions[bot]
8833977736 Update changelog for v2.1.6 2022-03-30 09:58:37 +00:00
Edoardo Pirovano
bfe9e81020 Merge pull request #1003 from github/edoardo/fix-workflow
Fix typos in release workflow
2022-03-30 10:56:28 +01:00
Edoardo Pirovano
1d58cc1f27 Fix typos in release workflow 2022-03-30 10:28:34 +01:00
Edoardo Pirovano
d8576e34bf Merge pull request #990 from github/edoardo/2.8.4-bump
Bump default CodeQL version to 2.8.4
2022-03-29 17:34:59 +01:00
Edoardo Pirovano
f1060fbba0 Bump default CodeQL version to 2.8.4 2022-03-29 16:55:25 +01:00
Henry Mercer
af34c6da92 Merge pull request #1002 from github/henrymercer/update-changelog-rewriting
Update changelog rewriting step to match v2+ only changelog notes
2022-03-29 16:50:35 +01:00
Henry Mercer
282b607642 Update changelog rewriting step to match v2+ only release notes 2022-03-29 16:10:02 +01:00
Henry Mercer
f0e2f3c053 Merge pull request #1001 from github/henrymercer/pr-check-validate-node-12-build
Add PR check to validate compatibility with Node 12
2022-03-29 14:27:01 +01:00
Henry Mercer
73ba7ffb48 Merge branch 'main' into henrymercer/pr-check-validate-node-12-build 2022-03-29 13:27:16 +01:00
Henry Mercer
2f4dd4bb41 Use git add --all . 2022-03-29 13:27:03 +01:00
Henry Mercer
8237e85158 Merge pull request #1000 from github/henrymercer/bump-node-js-to-v16
Run Actions on Node 16
2022-03-29 13:07:18 +01:00
Henry Mercer
eea7cf19ff Merge branch 'main' into henrymercer/bump-node-js-to-v16 2022-03-29 12:41:55 +01:00
Edoardo Pirovano
fdc2a903c1 Merge pull request #997 from cdivitotawela/python2-fix
Fix python_setup/install_tool.sh when `python2` not present
2022-03-29 12:15:26 +01:00
Henry Mercer
c22162c09d Merge branch 'main' into henrymercer/bump-node-js-to-v16 2022-03-29 11:59:06 +01:00
Henry Mercer
01c72238c1 Add v2 only prefix to changelog note 2022-03-29 11:58:14 +01:00
Rasmus Wriedt Larsen
63b2636c23 Merge branch 'main' into python2-fix 2022-03-29 10:56:20 +02:00
Edoardo Pirovano
0ed0799824 Merge pull request #999 from github/edoardo/reenable-atm
Start running ATM queries again
2022-03-28 17:06:53 -04:00
Henry Mercer
9e403590f4 Improve code comments 2022-03-28 18:02:19 +01:00
Henry Mercer
45b96c3de6 Add PR check to validate compatibility with Node 12 2022-03-28 16:40:01 +01:00
Henry Mercer
9a709c116e Add changelog note 2022-03-28 16:39:46 +01:00
Henry Mercer
43c9f26143 Bump version to 2.1.6 2022-03-28 14:39:00 +01:00
Henry Mercer
b949e494e4 Upgrade Node type definitions 2022-03-28 14:39:00 +01:00
Henry Mercer
3d23aade46 Use Node.js v16 in all Actions 2022-03-28 14:39:00 +01:00
Edoardo Pirovano
d625a00cee Start running ATM queries again 2022-03-28 09:06:45 +01:00
Chaminda Divitotawela
077ec096bb #996: Fix python_setup/install_tool.sh
When the script  executed on a runner which does not have python2, script incorrectly execute the code inside the if condition. This script runs using /bin/sh in Ubuntu and cause the problem. Fix for this issue to use different syntax in output redirection.

Issue is reproduced using running the job on ubunutu container. Fix also verified in the action https://github.com/cdivitotawela/codeql-issue/actions/runs/2038007502
2022-03-28 07:23:31 +10:00
Henry Mercer
4d6e9c02ac Merge pull request #995 from github/henrymercer/update-release-process
Update release process to maintain both v2 and v1 releases
2022-03-25 19:33:43 +00:00
Henry Mercer
839aa81918 Merge branch 'main' into henrymercer/update-release-process 2022-03-25 19:11:59 +00:00
Andrew Eisenberg
6d1f0a0357 Merge pull request #956 from github/aeisenberg/checkout-path-commitoid
Use the `checkout_path` for getting the commit oid
2022-03-25 11:02:54 -07:00
Andrew Eisenberg
88db5e75ec Merge branch 'main' into aeisenberg/checkout-path-commitoid 2022-03-25 10:31:47 -07:00
Andrew Eisenberg
d068f5372a Fix failing tests 2022-03-25 10:00:47 -07:00
Henry Mercer
044f112dc1 Update branch protection instructions 2022-03-25 15:24:54 +00:00
Henry Mercer
f7846479e6 Merge branch 'main' into henrymercer/update-release-process 2022-03-25 15:18:11 +00:00
Henry Mercer
d0bd80897c Expose a more restrictive interface to the release script
Give the release script modes rather
than source and target branches
2022-03-25 15:17:17 +00:00
Henry Mercer
bed132dae4 Use a more restrictive sed pattern 2022-03-25 13:40:41 +00:00
Henry Mercer
9d26fe0cb3 Use source branch and target branch names consistently 2022-03-25 12:55:00 +00:00
Edoardo Pirovano
6e57bbac6c Merge pull request #998 from github/edoardo/no-download-pack
Don't download packs when it isn't needed
2022-03-25 08:36:15 -04:00
Edoardo Pirovano
85cfdb24f4 Don't download packs when it isn't needed 2022-03-25 11:26:13 +00:00
Henry Mercer
df164705ad Merge pull request #993 from github/dependabot/npm_and_yarn/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6
2022-03-24 18:50:32 +00:00
Henry Mercer
da7944b165 Update release process doc 2022-03-24 18:18:45 +00:00
Henry Mercer
33599909af Avoid conflicts by reverting 1.x version num commit from last v1 release 2022-03-24 18:18:45 +00:00
Henry Mercer
f143182488 Add "Update dependencies" label to v1 release PR 2022-03-24 18:18:45 +00:00
Henry Mercer
0b037b4fcb Add merging the v1 release PR to the checklist 2022-03-24 18:18:45 +00:00
Henry Mercer
1668e0a2bf Only mention merging the mergeback PR in the checklist when relevant 2022-03-24 18:18:45 +00:00
Henry Mercer
bd4757cd6b Update the changelog and version number in a single commit 2022-03-24 18:18:45 +00:00
Henry Mercer
5fb01dd153 Avoid commits with duplicate names during v2 to v1 backport 2022-03-24 18:18:45 +00:00
Henry Mercer
124e7d96a6 Stop versioning the runner
We no longer release the runner.
2022-03-24 18:18:45 +00:00
Henry Mercer
b8f3a377bf Fix exception when there are no commits to merge 2022-03-24 18:18:45 +00:00
Henry Mercer
4b465cb3ce Dump environment and GitHub context 2022-03-24 18:18:45 +00:00
Henry Mercer
d76b18254a Add functionality for v2 -> v1 backports 2022-03-24 18:18:45 +00:00
Henry Mercer
33f749f1c9 Set up main -> v2, v2 -> v1, and v2 -> main merges 2022-03-24 18:18:45 +00:00
Henry Mercer
ccda44cac5 Handle missing author information when generating changelog 2022-03-24 18:18:45 +00:00
Henry Mercer
81827d3fc6 Use the person triggering the release workflow as the conductor 2022-03-24 18:18:45 +00:00
Henry Mercer
b386fd4443 Parameterize release branch workflow over source and target branches 2022-03-24 18:18:45 +00:00
Henry Mercer
2a7a517ea5 Remove unused repository_dispatch trigger 2022-03-24 18:18:45 +00:00
github-actions[bot]
ca5ed24270 Update checked-in dependencies 2022-03-24 16:36:41 +00:00
dependabot[bot]
fb22523acc Bump minimist from 1.2.5 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-24 15:54:01 +00:00
Andrew Eisenberg
b887a2ce1e Merge pull request #976 from aeisenberg/aeisenberg/timeout-45-min
Bump timeout to 45 minutes
2022-03-24 08:33:12 -07:00
Andrew Eisenberg
686c3a37f0 Merge branch 'main' into aeisenberg/timeout-45-min 2022-03-24 08:07:42 -07:00
Chuan-kai Lin
c9973ef56b Merge pull request #992 from cklin/fix-codeql-version-field
Status reporting: fix codeql_version field name
2022-03-23 13:11:09 -07:00
Chuan-kai Lin
c3010cb18a Status reporting: fix codeql_version field name 2022-03-23 11:32:03 -07:00
Henry Mercer
81bfc289f5 Merge pull request #989 from github/henrymercer/update-readme
Update README now build tracing is compatible with Windows 2022
2022-03-21 16:03:34 +00:00
Henry Mercer
5d72058994 Merge branch 'main' into aeisenberg/timeout-45-min 2022-03-21 15:37:09 +00:00
Henry Mercer
6de8537e54 Update README now build tracing is compatible with Windows 2022 2022-03-21 15:31:51 +00:00
Henry Mercer
1d81ec489b Merge pull request #984 from github/update-supported-enterprise-server-versions
Update supported GitHub Enterprise Server versions.
2022-03-21 13:43:13 +00:00
Henry Mercer
c592f89989 Merge branch 'main' into update-supported-enterprise-server-versions 2022-03-21 13:12:12 +00:00
Henry Mercer
f71aeef4dc Merge pull request #988 from CommanderRoot/refactor/rm-deprecated-substr
refactor: replace deprecated String.prototype.substr()
2022-03-21 10:52:17 +00:00
Tobias Speicher
0a713019c3 refactor: replace deprecated String.prototype.substr()
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
2022-03-20 17:08:43 +01:00
GitHub
243ebf6e35 Update supported GitHub Enterprise Server versions. 2022-03-18 00:09:57 +00:00
Chuan-kai Lin
3886398541 Merge pull request #987 from cklin/report-versions
Include CodeQL CLI and action versions in status reports
2022-03-17 10:46:34 -07:00
Chuan-kai Lin
f60bb5cc38 Include CodeQL CLI and action versions in status reports 2022-03-17 10:07:29 -07:00
Chuan-kai Lin
d0ee2b4276 Merge pull request #983 from github/mergeback/v1.1.5-to-main-88347664
Mergeback v1.1.5 refs/heads/v1 into main
2022-03-15 14:51:17 -07:00
github-actions[bot]
34905f691e Update checked-in dependencies 2022-03-15 19:57:13 +00:00
github-actions[bot]
ac7bd44c3b 1.1.6 2022-03-15 19:39:33 +00:00
github-actions[bot]
1457c164a9 Update changelog and version after v1.1.5 2022-03-15 19:39:31 +00:00
Chuan-kai Lin
8834766498 Merge pull request #982 from github/update-v1.1.5-5b59d878
Merge main into v1
2022-03-15 12:38:22 -07:00
github-actions[bot]
69a58ad266 1.1.5 2022-03-15 18:16:05 +00:00
Chuan-kai Lin
5b59d8784d Merge pull request #978 from cklin/restore-ghes-compatibility
Restore compatibility with GHES 3.1
2022-03-15 09:29:23 -07:00
Chuan-kai Lin
ea5898d606 Restore compatibility with GHES 3.1: address code review comments 2022-03-14 15:44:16 -07:00
Chuan-kai Lin
39aa619399 Merge branch 'main' into restore-ghes-compatibility 2022-03-14 14:59:00 -07:00
Chuan-kai Lin
2190825ac9 Merge pull request #980 from github/edoardo/release-expected
Remove runner from expected release files
2022-03-14 14:40:57 -07:00
Edoardo Pirovano
e61a4b9c7c Merge branch 'main' into edoardo/release-expected 2022-03-14 18:57:18 +00:00
Chuan-kai Lin
b74506c7c2 Merge pull request #974 from github/cklin/pr/2.8.3
Update default CodeQL bundle version to 2.8.3
2022-03-14 11:53:01 -07:00
Edoardo Pirovano
e27fa67f0f Add changenote mentioning deprecation 2022-03-14 18:35:22 +00:00
Edoardo Pirovano
eb507cfac6 Remove runner from expected release files 2022-03-14 17:56:05 +00:00
Chuan-kai Lin
c33cdd74b3 Merge branch 'main' into cklin/pr/2.8.3 2022-03-14 09:19:25 -07:00
Chuan-kai Lin
aeefdce612 Restore compatibility with GHES 3.1 2022-03-14 08:20:27 -07:00
Andrew Eisenberg
761da7eb50 Merge pull request #968 from github/aeisenberg/required-checks
Add some instructions on how to regenerate required checks
2022-03-11 12:11:17 -08:00
Andrew Eisenberg
76c3e91b1f Bump timeout to 45 minutes
With a 30 minute timeout, we were getting some cancelled runs.
This should fix it.
2022-03-11 11:45:45 -08:00
Henry Mercer
560edbc33e Merge branch 'main' into aeisenberg/required-checks 2022-03-11 18:35:59 +00:00
Andrew Eisenberg
e64a215b41 Add name to workflow 2022-03-11 10:16:34 -08:00
Henry Mercer
e437ea1d38 Merge pull request #975 from github/henrymercer/bump-ml-powered-queries-to-0.1.0
Bump ML-powered queries to v0.1.0
2022-03-11 17:47:33 +00:00
Andrew Eisenberg
8ecc1fcbc4 Ignore "Update Supported Enterprise Server Versions" 2022-03-11 09:38:08 -08:00
Henry Mercer
0b3acf68ab Bump ML-powered queries to v0.1.0 2022-03-11 15:04:07 +00:00
Arthur Baars
480ef7689f Update default CodeQL bundle version to 2.8.3 2022-03-11 12:07:37 +01:00
Andrew Eisenberg
4e2634f2fd Merge branch 'main' into aeisenberg/required-checks 2022-03-10 09:20:14 -08:00
Andrew Eisenberg
04d521d705 Avoid using sed, use --slurp instead 2022-03-09 11:07:16 -08:00
Andrew Eisenberg
cdf3c9d01e Merge pull request #971 from github/aeisenberg/timeouts
Add a timeout of 30 min
2022-03-08 20:37:45 -08:00
Andrew Eisenberg
628afae9d3 Add a timeout of 30 min
For all CI jobs. Based on some eye-balling 30 minutes should be
enough time for all jobs to complete.
2022-03-08 14:57:35 -08:00
Andrew Eisenberg
111428ce06 Add some instructions on how to regenerate required checks 2022-03-08 10:19:32 -08:00
Andrew Eisenberg
d2fd19b7d7 Merge pull request #966 from github/mergeback/v1.1.4-to-main-f5d82270
Mergeback v1.1.4 refs/heads/v1 into main
2022-03-07 17:27:08 -08:00
github-actions[bot]
c825c24663 Update checked-in dependencies 2022-03-07 22:12:02 +00:00
github-actions[bot]
0e0e934038 1.1.5 2022-03-07 21:02:20 +00:00
github-actions[bot]
d430deb927 Update changelog and version after v1.1.4 2022-03-07 21:02:19 +00:00
Henning Makholm
f5d822707e Merge pull request #965 from github/update-v1.1.4-308528ba
Merge main into v1
2022-03-07 22:01:06 +01:00
Henning Makholm
1f44993f56 Update CHANGELOG.md 2022-03-07 20:24:16 +01:00
Henning Makholm
701b6a5569 Update CHANGELOG.md
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
2022-03-07 18:15:18 +01:00
Henning Makholm
e75fa83dde Update CHANGELOG.md 2022-03-07 17:49:53 +01:00
Henning Makholm
a33ae09fb8 Update CHANGELOG.md
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
2022-03-07 17:44:04 +01:00
github-actions[bot]
44198be781 1.1.4 2022-03-07 16:22:37 +00:00
Andrew Eisenberg
308528ba13 Merge pull request #958 from daniel-beck/fix-link
Fix link to docs
2022-03-04 10:48:08 -08:00
Chuan-kai Lin
939659ccd0 Merge pull request #959 from cklin/report-runner-os-arch
Add runner OS and arch to status report
2022-03-03 14:59:41 -08:00
Chuan-kai Lin
401a76f245 Add runner OS release to status report 2022-03-03 13:06:02 -08:00
Andrew Eisenberg
5e27f57127 Merge pull request #961 from github/dependabot/npm_and_yarn/actions/artifact-1.0.0
Bump @actions/artifact from 0.5.2 to 1.0.0
2022-03-03 11:23:57 -08:00
github-actions[bot]
4154eaf0e9 Update checked-in dependencies 2022-03-03 17:18:51 +00:00
dependabot[bot]
75e4d9f140 Bump @actions/artifact from 0.5.2 to 1.0.0
Bumps [@actions/artifact](https://github.com/actions/toolkit/tree/HEAD/packages/artifact) from 0.5.2 to 1.0.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/artifact/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/@actions/io@1.0.0/packages/artifact)

---
updated-dependencies:
- dependency-name: "@actions/artifact"
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-03 17:01:31 +00:00
Chuan-kai Lin
870dbaaebe Use getRequiredEnvParam()
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
2022-03-02 16:23:13 -08:00
Chuan-kai Lin
3615d8ac45 Add runner OS and arch to status report 2022-03-02 10:57:12 -08:00
Daniel Beck
47dd636fbc Fix link to docs 2022-03-02 15:30:11 +01:00
Edoardo Pirovano
e4766c87d5 Merge pull request #957 from github/edoardo/reuse-codescanning-config
Second attempt to use `--codescanning-config` flag of CLI
2022-03-02 00:27:29 +00:00
Andrew Eisenberg
5c2600e559 Merge branch 'main' into aeisenberg/checkout-path-commitoid 2022-03-01 13:15:40 -08:00
Andrew Eisenberg
a92e8775d8 Use the checkout_path for getting the commit oid
This commit also adds a new integration check to verify this.

When running in test mode, payloads will not be uploaded. Instead, they
will be saved to disk so that they can be inspected later.
2022-03-01 12:40:52 -08:00
Edoardo Pirovano
527d5153ad Bump version flag for using --codescanning-config flag 2022-03-01 14:34:53 +00:00
Edoardo Pirovano
07990f07e5 Revert "Revert "Use --codescanning-config flag of CLI""
This reverts commit 326e5118c5.
2022-03-01 14:33:00 +00:00
Edoardo Pirovano
fa19286989 Merge pull request #954 from github/edoardo/expand-tests
Expand PR checks to cover `windows-2022`
2022-03-01 09:24:51 +00:00
Chris Gavin
b1c781d398 Merge pull request #955 from github/delete-results-directory
Delete the results directory in between runs.
2022-02-28 20:26:51 +00:00
Chris Gavin
938e0a0743 Add retryDelay and a type cast to make it work. 2022-02-28 19:42:58 +00:00
Chris Gavin
d63f798314 Retry directory deletion to avoid Windows file locking issues.
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
2022-02-28 18:55:45 +00:00
Chris Gavin
86940df49f Delete the results directory in between runs. 2022-02-28 18:55:45 +00:00
Henning Makholm
25313901b7 Merge pull request #950 from github/hmakholm/pr/2.8.2
Update default CodeQL bundle version to 2.8.2
2022-02-28 19:11:10 +01:00
Edoardo Pirovano
8ec6a84629 Expand PR checks to cover windows-2022 2022-02-28 15:39:34 +00:00
Henning Makholm
162ecaff35 Update default CodeQL bundle version to 2.8.2 2022-02-25 14:09:56 +01:00
Henry Mercer
117a67b074 Merge pull request #949 from github/dependabot/npm_and_yarn/removeNPMAbsolutePaths-3.0.0
Bump removeNPMAbsolutePaths from 2.0.0 to 3.0.0
2022-02-24 18:49:56 +00:00
github-actions[bot]
0da815296a Update checked-in dependencies 2022-02-24 17:03:29 +00:00
dependabot[bot]
4e02f8e87a Bump removeNPMAbsolutePaths from 2.0.0 to 3.0.0
Bumps [removeNPMAbsolutePaths](https://github.com/juanjoDiaz/removeNPMAbsolutePaths) from 2.0.0 to 3.0.0.
- [Release notes](https://github.com/juanjoDiaz/removeNPMAbsolutePaths/releases)
- [Commits](https://github.com/juanjoDiaz/removeNPMAbsolutePaths/compare/v2.0.0...v3.0.0)

---
updated-dependencies:
- dependency-name: removeNPMAbsolutePaths
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-24 17:01:55 +00:00
Edoardo Pirovano
438f654919 Merge pull request #948 from github/edoardo/revert-windows-11
Revert "Merge pull request #869 from github/edoardo/windows-11-error"
2022-02-24 14:36:46 +00:00
Edoardo Pirovano
42af7232c3 Revert "Merge pull request #869 from github/edoardo/windows-11-error"
This reverts commit faa9ba7363, reversing
changes made to 71112ab35d.
2022-02-24 11:29:26 +00:00
Andrew Eisenberg
360221eece Merge pull request #947 from github/mergeback/v1.1.3-to-main-75f07e7a
Mergeback v1.1.3 refs/heads/v1 into main
2022-02-23 14:09:47 -08:00
github-actions[bot]
9169d2461f Update checked-in dependencies 2022-02-23 19:50:02 +00:00
github-actions[bot]
949eeb2dcf 1.1.4 2022-02-23 19:33:33 +00:00
github-actions[bot]
507795f5c4 Update changelog and version after v1.1.3 2022-02-23 19:33:31 +00:00
Andrew Eisenberg
75f07e7ab2 Merge pull request #946 from github/update-v1.1.3-d7ad71d8
Merge main into v1
2022-02-23 11:32:12 -08:00
Andrew Eisenberg
42c72a10c8 Update runner version
For some reason, the runner was still on 1.0.x.
2022-02-23 11:02:14 -08:00
Andrew Eisenberg
fa57ef0579 Update changelog 2022-02-23 09:29:10 -08:00
github-actions[bot]
4b66d317a4 1.1.3 2022-02-23 17:13:38 +00:00
Edoardo Pirovano
d7ad71d803 Merge pull request #938 from github/respect-end-tracing
Respect `end-tracing` script instead of deleting one variable
2022-02-23 17:08:20 +00:00
Edoardo Pirovano
afbddca263 Improve error handling for ending tracing 2022-02-23 16:43:38 +00:00
Edoardo Pirovano
c592525a67 Respect end-tracing script instead of deleting one variable 2022-02-23 16:21:35 +00:00
Edoardo Pirovano
f14beebc58 Merge pull request #942 from github/aeisenberg/user-error
Add `UserError`
2022-02-23 11:21:14 +00:00
Andrew Eisenberg
3d93bb2ac9 Add UserError
This commit adds a `UserError` class that should be thrown when the
cause of an error is fundamentally from user configuration.

When sending status reports, avoid sending a `failure` for `UserError`s.
This will prevent our diagnostics from pinging us for errors outside of
our control.
2022-02-17 11:47:31 -08:00
Henry Mercer
040feefecf Merge pull request #941 from github/mergeback/v1.1.2-to-main-d39d5d5c
Mergeback v1.1.2 refs/heads/v1 into main
2022-02-17 19:36:22 +00:00
github-actions[bot]
4d875a922c Update checked-in dependencies 2022-02-17 18:13:39 +00:00
github-actions[bot]
cbc9c75e8f 1.1.3 2022-02-17 17:57:14 +00:00
github-actions[bot]
65174f238c Update changelog and version after v1.1.2 2022-02-17 17:57:09 +00:00
Henry Mercer
d39d5d5c97 Merge pull request #939 from github/update-v1.1.2-fe6fb6f2
Merge main into v1
2022-02-17 17:55:54 +00:00
github-actions[bot]
da54d7bd9f 1.1.2 2022-02-17 16:35:22 +00:00
Henry Mercer
fe6fb6f21b Merge pull request #937 from github/henrymercer/revert-node-16-upgrade
Revert Node.js v16 upgrade
2022-02-17 16:33:46 +00:00
Henry Mercer
72f407c72c Merge branch 'main' into henrymercer/revert-node-16-upgrade 2022-02-17 15:30:43 +00:00
Henry Mercer
cefec5bcb7 Merge pull request #935 from github/mergeback/v1.1.1-to-main-ec300a31
Mergeback v1.1.1 refs/heads/v1 into main
2022-02-17 15:21:01 +00:00
Henry Mercer
070bf9ae1c Add changelog note 2022-02-17 13:56:09 +00:00
Henry Mercer
74dd782377 Merge branch 'main' into mergeback/v1.1.1-to-main-ec300a31 2022-02-17 13:55:34 +00:00
Henry Mercer
78e09bd811 Merge pull request #936 from edoardopirovano/revert-codescanning-config
Revert "Use `--codescanning-config` flag of CLI"
2022-02-17 13:55:06 +00:00
Henry Mercer
72b5ce4f22 Revert "Upgrade Node type definitions"
This reverts commit c72c200f52.
2022-02-17 13:52:07 +00:00
Henry Mercer
21c48e7a01 Revert "Use Node.js v16 in all Actions"
This reverts commit 34c777f8d0.
2022-02-17 13:51:03 +00:00
Edoardo Pirovano
326e5118c5 Revert "Use --codescanning-config flag of CLI"
This reverts commit 0d87b8c615.
2022-02-17 13:05:55 +00:00
github-actions[bot]
b83cccd8a6 Update checked-in dependencies 2022-02-17 12:50:43 +00:00
github-actions[bot]
9b2dafda62 1.1.2 2022-02-17 12:29:38 +00:00
github-actions[bot]
770ee8972e Update changelog and version after v1.1.1 2022-02-17 12:29:36 +00:00
Henry Mercer
ec300a3159 Merge pull request #934 from github/update-v1.1.1-6a961c08
Merge main into v1
2022-02-17 12:28:17 +00:00
github-actions[bot]
c9f98d45c1 1.1.1 2022-02-17 12:00:54 +00:00
Henry Mercer
6a961c08f2 Merge pull request #931 from github/henrymercer/fix-flaky-tests
Bump minimum supported CodeQL version to 2.4.5 to address flaky tests
2022-02-17 11:49:54 +00:00
Henry Mercer
db24c88f31 Merge branch 'main' into henrymercer/fix-flaky-tests 2022-02-17 10:50:19 +00:00
Edoardo Pirovano
c4e058a6a3 Merge pull request #830 from edoardopirovano/cli-config-files
Use `--codescanning-config` flag of CLI
2022-02-16 17:05:16 +00:00
Edoardo Pirovano
0d87b8c615 Use --codescanning-config flag of CLI 2022-02-16 13:34:47 +00:00
Henry Mercer
49c1e2f719 Add changelog note 2022-02-16 13:32:12 +00:00
Henry Mercer
13c841aa39 Bump minimum supported CodeQL version to 2.4.5
This is the earliest CodeQL version supported by GHES.
Bumping to this version resolves some flaky tests caused by the "We
still have not reached idleness" deadlock, as this deadlock is fixed in
2.4.5.
2022-02-16 12:46:47 +00:00
Henry Mercer
ef024e702c Merge pull request #930 from github/henrymercer/open-update-supported-enterprise-versions-as-draft
Open "Update supported enterprise versions" PR as draft
2022-02-16 12:42:23 +00:00
Henry Mercer
1ed61a37b6 Merge branch 'main' into henrymercer/open-update-supported-enterprise-versions-as-draft 2022-02-16 11:55:10 +00:00
Henry Mercer
abba98ef38 Merge pull request #929 from github/update-supported-enterprise-server-versions
Update supported GitHub Enterprise Server versions.
2022-02-16 11:54:53 +00:00
Henry Mercer
9d794b2b2e Open "Update supported enterprise versions" PR as draft
Actions will not run checks on PRs opened by Actions, so opening the PR as draft allows us to trigger PR checks by marking the PR as ready for review.
2022-02-16 10:42:01 +00:00
GitHub
7e1ca4f093 Update supported GitHub Enterprise Server versions. 2022-02-16 00:07:46 +00:00
Henry Mercer
621c8c7115 Merge pull request #928 from github/henrymercer/add-ml-powered-query-enablement-to-analyze-status-report
Add ML-powered query enablement info to analyze finish status report
2022-02-15 19:11:12 +00:00
Henry Mercer
feb711fe0b Merge branch 'main' into henrymercer/add-ml-powered-query-enablement-to-analyze-status-report 2022-02-15 17:31:07 +00:00
Robert
609ca1e4cf Merge pull request #927 from github/robertbrignull/remote_database_upload_flag
Remove check of database uploads feature flag
2022-02-15 17:24:50 +00:00
Robert
4c266bab6d Merge branch 'main' into robertbrignull/remote_database_upload_flag 2022-02-15 15:13:33 +00:00
Henry Mercer
ec47ce3982 Merge branch 'main' into henrymercer/add-ml-powered-query-enablement-to-analyze-status-report 2022-02-15 15:09:02 +00:00
Alexander Eyers-Taylor
e72dfad837 Merge pull request #925 from github/alexet/update-2.8.1
Update bundle version to 2.8.1
2022-02-15 15:07:58 +00:00
Henry Mercer
bcdaad245b Add ML-powered query enablement info to analyze finish status report 2022-02-15 15:04:23 +00:00
Robert
8aa32bd9c9 Remove check of database uploads feature flag 2022-02-15 14:10:33 +00:00
alexet
d8ee3b9d09 Update bundle version to 2.8.1 2022-02-14 19:10:33 +00:00
Henry Mercer
2c6b76bc5a Merge pull request #923 from github/mergeback/v1.1.0-to-main-474bbf07
Mergeback v1.1.0 refs/heads/v1 into main
2022-02-11 12:33:18 +00:00
github-actions[bot]
19debd424c Update checked-in dependencies 2022-02-11 12:12:30 +00:00
github-actions[bot]
3fdc5a23fa 1.1.1 2022-02-11 11:58:00 +00:00
github-actions[bot]
68365ec944 Update changelog and version after v1.1.0 2022-02-11 11:57:58 +00:00
Henry Mercer
474bbf07f9 Merge pull request #922 from github/update-v1.1.0-3d2ad0b9
Merge main into v1
2022-02-11 11:56:36 +00:00
github-actions[bot]
58f66fa60a 1.1.0 2022-02-11 11:24:14 +00:00
Henry Mercer
3d2ad0b9c8 Merge pull request #919 from github/henrymercer/rename-status-report-field
Rename ML powered JS queries status report field
2022-02-10 10:44:15 +00:00
Henry Mercer
7e15b9612a Merge branch 'main' into henrymercer/rename-status-report-field 2022-02-09 13:32:57 +00:00
Henry Mercer
7f9dca2982 Merge pull request #918 from github/henrymercer/windows-2022-tracing-notices
Update changelog and README with build tracing compatibility info
2022-02-09 13:32:18 +00:00
Henry Mercer
87bfa0ea7a Rename ML powered JS queries status report field
The new name `ml_powered_javascript_queries` is more consistent with
status report fields for analysis and interpretation duration metrics.
This isn't a breaking change since the old name never made it into the
GitHub API.
2022-02-09 12:56:31 +00:00
Henry Mercer
a6d606becc Update changelog and README with build tracing compatibility info 2022-02-09 12:47:13 +00:00
Henry Mercer
f2027c51f7 Merge pull request #916 from github/dependabot/npm_and_yarn/runner/simple-get-3.1.1
Bump simple-get from 3.1.0 to 3.1.1 in /runner
2022-02-08 20:59:28 +00:00
dependabot[bot]
70e63f4b08 Bump simple-get from 3.1.0 to 3.1.1 in /runner
Bumps [simple-get](https://github.com/feross/simple-get) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/feross/simple-get/releases)
- [Commits](https://github.com/feross/simple-get/compare/v3.1.0...v3.1.1)

---
updated-dependencies:
- dependency-name: simple-get
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-08 18:33:09 +00:00
Henry Mercer
88073a5f6e Merge pull request #909 from github/henrymercer/bump-node-js-to-v16
Use Node.js v16 in all Actions
2022-02-08 18:32:24 +00:00
Henry Mercer
eb172af46d Merge branch 'main' into henrymercer/bump-node-js-to-v16 2022-02-08 17:06:42 +00:00
Henry Mercer
a777a982cb Merge pull request #917 from github/henrymercer/fix-windows-latest-ci-jobs
Fix CI jobs that broke as a result of `windows-latest` being upgraded to Windows Server 2022
2022-02-08 17:05:36 +00:00
Henry Mercer
8f27994474 Add changelog note 2022-02-08 16:19:47 +00:00
Henry Mercer
8e2954c3fa Bump to v1.1.0
The upgrade to Node.js v16 warrants a minor version bump.
2022-02-08 13:55:23 +00:00
Henry Mercer
8768b0f5a3 Remove stub type definitions 2022-02-08 13:55:23 +00:00
Henry Mercer
c72c200f52 Upgrade Node type definitions 2022-02-08 13:55:23 +00:00
Henry Mercer
34c777f8d0 Use Node.js v16 in all Actions
This is now in active LTS status.
2022-02-08 13:55:23 +00:00
Henry Mercer
8dd2b9ac2f Fix typo in Python package installation CI job 2022-02-08 13:50:46 +00:00
Henry Mercer
b8047e5610 Use windows-2019 for CI jobs involving build tracing
Build tracing currently does not support Windows 2022, so use
`windows-2019` instead of`windows-latest`.
2022-02-08 13:29:20 +00:00
Chuan-kai Lin
edd03fbd2c Merge pull request #914 from github/mergeback/v1.0.32-to-main-2b46439d
Mergeback v1.0.32 refs/heads/v1 into main
2022-02-07 11:23:20 -08:00
github-actions[bot]
f9607205db Update checked-in dependencies 2022-02-07 18:45:41 +00:00
github-actions[bot]
b870f13d6d 1.0.33 2022-02-07 18:22:30 +00:00
github-actions[bot]
2890d306c3 Update changelog and version after v1.0.32 2022-02-07 18:22:28 +00:00
Chuan-kai Lin
2b46439dd5 Merge pull request #913 from github/update-v1.0.32-4eb03fb6
Merge main into v1
2022-02-07 10:21:10 -08:00
github-actions[bot]
6d8390b7cb 1.0.32 2022-02-07 17:21:16 +00:00
Henry Mercer
4eb03fb6f3 Merge pull request #907 from github/henrymercer/report-ml-powered-query-enablement
Report ML-powered query enablement in the `init` status report
2022-02-07 17:16:25 +00:00
Henry Mercer
03c64ef07d Add more documentation for ML-powered JS queries status report
Also be more explicit about which version strings are reportable in
the code.
2022-02-07 16:46:53 +00:00
Henry Mercer
cc622a02a9 Merge branch 'main' into henrymercer/report-ml-powered-query-enablement 2022-02-07 14:39:20 +00:00
Henry Mercer
c95a3d854c Limit cardinality of ML-powered JS queries status report
Some platforms that ingest this status report charge based on the
cardinality of the fields, so here we restrict the version strings we
support to a fixed set.
2022-02-07 14:36:40 +00:00
Henry Mercer
f888be73ce Nit: Simplify code with optional chaining 2022-02-07 14:24:40 +00:00
Chuan-kai Lin
16d4068732 Merge pull request #911 from github/cklin/codeql-cli-2.8.0
Update default CodeQL version to 2.8.0
2022-02-04 13:03:16 -08:00
Chuan-kai Lin
aab545260e Update default CodeQL version to 2.8.0 2022-02-04 11:24:40 -08:00
Henry Mercer
501fe7ff12 Update getMlPoweredJsQueriesStatus doc 2022-02-04 17:16:25 +00:00
Henry Mercer
ad40e4a8f8 Merge branch 'main' into henrymercer/report-ml-powered-query-enablement 2022-02-04 16:38:18 +00:00
Henry Mercer
537b2f873a Add "multiple" report for ML-powered JS query enablement
When multiple ML-powered JS packs are in scope (an unsupported
scenario), the status report is "multiple".
2022-02-04 16:37:26 +00:00
Henry Mercer
9f32fc9b9d Only add ML-powered queries pack if the user didn't manually request it 2022-02-04 16:34:17 +00:00
Thomas Horstmeyer
904d0acf90 Merge pull request #858 from github/use-better-base-sha
Declare the merge base as base for code scanning comparisons
2022-02-04 12:37:55 +00:00
Thomas Horstmeyer
9b14aa7c84 Merge branch 'main' into use-better-base-sha 2022-02-04 12:04:41 +00:00
Henry Mercer
1cddec9558 Add ML-powered queries enablement to init status report
We report this information in the `init` status report rather than the
`analyze` status report so we can gather data about timeouts.
2022-02-03 16:29:28 +00:00
Henry Mercer
a005206838 Convert status report comments to documentation 2022-02-03 11:52:49 +00:00
Henry Mercer
ff33f031e8 Merge pull request #822 from github/dependabot/npm_and_yarn/ava/typescript-3.0.1
Upgrade AVA to v4
2022-02-02 18:01:27 +00:00
Henry Mercer
6a6a3203dd Merge branch 'main' into dependabot/npm_and_yarn/ava/typescript-3.0.1 2022-02-02 17:24:20 +00:00
Henry Mercer
942b34d547 Merge pull request #906 from github/aibaars/fix-typo
Fix typo in error message
2022-02-02 16:25:19 +00:00
Thomas Horstmeyer
3469c69bba Merge branch 'main' into use-better-base-sha 2022-02-02 13:52:13 +00:00
Arthur Baars
d57c2761c9 Fix typo in error message 2022-02-02 13:51:48 +01:00
Henry Mercer
6081b90eae Merge pull request #905 from github/henrymercer/fix-changelog
Fix changelog
2022-02-02 12:02:44 +00:00
Henry Mercer
78eb2c9c00 Fix changelog
Move a couple of entries for #889 that should have been in the
unreleased section but were inadvertently moved into the 1.0.31
release.
2022-02-02 11:13:24 +00:00
Andrew Eisenberg
b2af0740e4 Remove security-events: write from tests
This is not necessary.
2022-02-01 19:17:15 -08:00
Andrew Eisenberg
77194581b7 Merge pull request #904 from cw-acroteau/add-ref-input
Add ref input
2022-02-01 19:15:33 -08:00
cw-acroteau
1a5b604256 Merge branch 'main' into add-ref-input 2022-02-01 20:28:42 -05:00
cw-acroteau
9bfa05fb03 Merge pull request #3 from aeisenberg/aeisenberg/add-ref-input
Update the description of new inputs
2022-02-01 17:19:33 -05:00
Henry Mercer
e9aa623c5d Merge branch 'main' into dependabot/npm_and_yarn/ava/typescript-3.0.1 2022-02-01 18:57:02 +00:00
Henry Mercer
ce89f1b611 Upgrade Ava to v4 2022-02-01 18:56:42 +00:00
Andrew Eisenberg
57f34a1569 Merge pull request #902 from github/aeisenberg/permissions
Add a permissions block for generated workflows
2022-02-01 10:54:05 -08:00
Andrew Eisenberg
941e382c65 Merge branch 'main' into aeisenberg/permissions 2022-02-01 10:37:13 -08:00
Andrew Eisenberg
6c6b8c33c4 Update the description of new inputs
These new inputs will not work on pull requests from forks.
2022-02-01 10:34:45 -08:00
Andrew Eisenberg
13f97c81fe Merge branch 'aeisenberg/permissions' into add-ref-input 2022-02-01 10:31:14 -08:00
Andrew Eisenberg
36419a79c1 Avoid sending status reports in test mode 2022-02-01 10:12:35 -08:00
github-actions[bot]
9a40cc5274 Update checked-in dependencies 2022-02-01 17:46:08 +00:00
Thomas Horstmeyer
ec0b3ae7ff remove some debug info 2022-02-01 15:39:11 +00:00
Thomas Horstmeyer
e836f97769 Detect merge base as base_sha for upload 2022-02-01 15:38:43 +00:00
dependabot[bot]
11639426e6 Bump @ava/typescript from 2.0.0 to 3.0.1
Bumps [@ava/typescript](https://github.com/avajs/typescript) from 2.0.0 to 3.0.1.
- [Release notes](https://github.com/avajs/typescript/releases)
- [Commits](https://github.com/avajs/typescript/compare/v2.0.0...v3.0.1)

---
updated-dependencies:
- dependency-name: "@ava/typescript"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-01 13:33:29 +00:00
Henry Mercer
a9da9fc959 Merge pull request #901 from github/dependabot/npm_and_yarn/long-5.2.0
Bump long from 4.0.0 to 5.2.0
2022-02-01 13:31:41 +00:00
Henry Mercer
ae8741006b Merge branch 'main' into dependabot/npm_and_yarn/long-5.2.0 2022-02-01 11:11:25 +00:00
Alex Croteau
72f9a88bc5 Regenerates test workflows 2022-01-31 20:07:55 -05:00
Alex Croteau
9f36b75178 Splits integration tests 2022-01-31 20:06:18 -05:00
Alex Croteau
dfe2bc4e49 Changes to commit hash in main branch 2022-01-31 20:06:18 -05:00
Alex Croteau
63d0c7856c Fixes integration tests referred repo 2022-01-31 20:06:18 -05:00
Alex Croteau
3cc87990f0 Updates javascript files 2022-01-31 20:06:18 -05:00
Alex Croteau
260b4d5dc4 Fixes integration test 2022-01-31 20:06:18 -05:00
Alex Croteau
1bfa9ace60 Adds integration test and fixes linting 2022-01-31 20:06:18 -05:00
Alex Croteau
1eaaf07b91 Adds check on inputs and compiled files 2022-01-31 20:06:17 -05:00
Alex Croteau
5916f9896d Applies recomendation in upload-sarif/action.yml 2022-01-31 20:06:17 -05:00
cw-acroteau
0dd4dbf9d9 Apply documentation suggestions from code review
Co-authored-by: Andrew Eisenberg <aeisenberg@github.com>
2022-01-31 20:06:17 -05:00
Alex Croteau
980fd4ed38 Adds ref and SHA as inputs, and sarif-id as output 2022-01-31 20:06:17 -05:00
Andrew Eisenberg
e9aa2c6f62 Add a permissions block for generated workflows
Ensure that all workflows are able to write security events.
2022-01-31 16:11:00 -08:00
Andrew Eisenberg
e9d52340a3 Merge pull request #900 from github/mergeback/v1.0.31-to-main-1a927e93
Mergeback v1.0.31 refs/heads/v1 into main
2022-01-31 13:36:54 -08:00
github-actions[bot]
392931027a Update checked-in dependencies 2022-01-31 18:36:27 +00:00
dependabot[bot]
ba2b46d53e Bump long from 4.0.0 to 5.2.0
Bumps [long](https://github.com/dcodeIO/long.js) from 4.0.0 to 5.2.0.
- [Release notes](https://github.com/dcodeIO/long.js/releases)
- [Commits](https://github.com/dcodeIO/long.js/compare/4.0.0...v5.2.0)

---
updated-dependencies:
- dependency-name: long
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-31 18:32:15 +00:00
github-actions[bot]
a602dbedb7 Update checked-in dependencies 2022-01-31 17:42:59 +00:00
Andrew Eisenberg
66777347f6 Merge branch 'main' into mergeback/v1.0.31-to-main-1a927e93 2022-01-31 08:42:20 -08:00
github-actions[bot]
ce6e94b1b8 1.0.32 2022-01-31 16:41:57 +00:00
github-actions[bot]
30790fe430 Update changelog and version after v1.0.31 2022-01-31 16:41:55 +00:00
Andrew Eisenberg
1a927e9307 Merge pull request #899 from github/update-v1.0.31-3a741b6c
Merge main into v1
2022-01-31 08:40:43 -08:00
Henry Mercer
ea2ef8554d Merge pull request #893 from github/dependabot/npm_and_yarn/trim-off-newlines-1.0.3
Bump trim-off-newlines from 1.0.2 to 1.0.3
2022-01-31 16:26:49 +00:00
github-actions[bot]
bbb9c53c65 1.0.31 2022-01-31 16:08:02 +00:00
Henry Mercer
9664bae55e Merge branch 'main' into dependabot/npm_and_yarn/trim-off-newlines-1.0.3 2022-01-31 15:59:28 +00:00
Henry Mercer
3a741b6cf5 Merge pull request #892 from github/dependabot/npm_and_yarn/node-fetch-2.6.7
Bump node-fetch from 2.6.1 to 2.6.7
2022-01-31 15:48:18 +00:00
Henry Mercer
1498bce660 Merge branch 'main' into dependabot/npm_and_yarn/node-fetch-2.6.7 2022-01-31 14:51:48 +00:00
Henry Mercer
c260382f36 Merge pull request #894 from github/dependabot/npm_and_yarn/sinon-13.0.0
Bump sinon from 11.1.2 to 13.0.0
2022-01-31 14:51:33 +00:00
github-actions[bot]
6410c0691e Update checked-in dependencies 2022-01-29 01:49:46 +00:00
github-actions[bot]
8e07ec6ce2 Update checked-in dependencies 2022-01-29 01:33:45 +00:00
github-actions[bot]
c337e5f2f3 Update checked-in dependencies 2022-01-29 01:21:58 +00:00
dependabot[bot]
9673b562d9 Bump sinon from 11.1.2 to 13.0.0
Bumps [sinon](https://github.com/sinonjs/sinon) from 11.1.2 to 13.0.0.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/master/docs/changelog.md)
- [Commits](https://github.com/sinonjs/sinon/compare/v11.1.2...v13.0.0)

---
updated-dependencies:
- dependency-name: sinon
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-29 01:16:14 +00:00
dependabot[bot]
253bc84963 Bump trim-off-newlines from 1.0.2 to 1.0.3
Bumps [trim-off-newlines](https://github.com/stevemao/trim-off-newlines) from 1.0.2 to 1.0.3.
- [Release notes](https://github.com/stevemao/trim-off-newlines/releases)
- [Commits](https://github.com/stevemao/trim-off-newlines/compare/v1.0.2...v1.0.3)

---
updated-dependencies:
- dependency-name: trim-off-newlines
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-29 01:15:48 +00:00
dependabot[bot]
bc4366e948 Bump node-fetch from 2.6.1 to 2.6.7
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-29 01:15:47 +00:00
Andrew Eisenberg
3b831aafd9 Merge pull request #885 from github/dependabot/npm_and_yarn/runner/node-fetch-2.6.7
Bump node-fetch from 2.6.1 to 2.6.7 in /runner
2022-01-28 17:15:15 -08:00
Andrew Eisenberg
14b1fecf33 Merge branch 'main' into dependabot/npm_and_yarn/runner/node-fetch-2.6.7 2022-01-28 15:42:46 -08:00
Robin Neatherway
5e23536180 Merge pull request #887 from github/rneatherway/content-type
Set contentType for database uploads
2022-01-25 18:40:57 +00:00
Robin Neatherway
5f30e2466f Merge branch 'rneatherway/content-type' of github.com:github/codeql-action into rneatherway/content-type 2022-01-25 17:17:21 +00:00
Andrew Eisenberg
05981c5829 Merge branch 'main' into dependabot/npm_and_yarn/runner/node-fetch-2.6.7 2022-01-25 08:57:02 -08:00
Robin Neatherway
486633d442 Try string literal key 2022-01-25 16:33:09 +00:00
Robin Neatherway
d6360c9075 Merge branch 'main' into rneatherway/content-type 2022-01-25 15:21:13 +00:00
Robin Neatherway
d3a0787934 Merge pull request #886 from github/rneatherway/remove-old-upload-path
Remove old upload path
2022-01-25 14:08:16 +00:00
Robin Neatherway
e13c8bbfb7 Merge branch 'main' into rneatherway/remove-old-upload-path 2022-01-25 12:36:23 +00:00
Andrew Eisenberg
1c9a1f5d01 Merge pull request #888 from github/aeisenberg/remove-experiemental-message
Remove `experimental` warning message for custom packs
2022-01-24 17:03:09 -08:00
Andrew Eisenberg
1f7dab4ba2 Merge branch 'main' into aeisenberg/remove-experiemental-message 2022-01-24 13:30:45 -08:00
Andrew Eisenberg
8a36468d11 Merge pull request #882 from github/aeisenberg/better-error
Ensure loadApiError is caught
2022-01-24 12:05:09 -08:00
Andrew Eisenberg
f8c38c1af3 Update changelog 2022-01-24 09:54:17 -08:00
Robin Neatherway
10249d1591 Update tests to remove feature flag 2022-01-24 17:53:09 +00:00
Andrew Eisenberg
e6bcd71529 Remove experimental warning message for custom packs 2022-01-24 09:40:46 -08:00
Andrew Eisenberg
806fc12eb2 Reword changelog entry and add back test 2022-01-24 09:25:52 -08:00
Andrew Eisenberg
ba352d365b Merge branch 'main' into aeisenberg/better-error 2022-01-24 08:56:14 -08:00
Robin Neatherway
751af2a9e3 Set contentType for database uploads 2022-01-24 15:54:46 +00:00
Robin Neatherway
1a686e7d76 Remove old upload path
The `useUploadDomain` approach is now fully enabled
2022-01-24 15:47:08 +00:00
dependabot[bot]
0479586f61 Bump node-fetch from 2.6.1 to 2.6.7 in /runner
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-24 13:34:40 +00:00
Edoardo Pirovano
708446c6e4 Merge pull request #884 from github/mergeback/v1.0.30-to-main-8b37404d
Mergeback v1.0.30 refs/heads/v1 into main
2022-01-24 13:33:55 +00:00
github-actions[bot]
392316b555 Update checked-in dependencies 2022-01-24 13:16:43 +00:00
github-actions[bot]
5604c0a3ad 1.0.31 2022-01-24 13:01:42 +00:00
github-actions[bot]
7d8ca8fa93 Update changelog and version after v1.0.30 2022-01-24 13:01:40 +00:00
Edoardo Pirovano
8b37404d56 Merge pull request #883 from github/update-v1.0.30-a7adbce2
Merge main into v1
2022-01-24 13:00:42 +00:00
github-actions[bot]
c180f23bb1 1.0.30 2022-01-24 11:30:41 +00:00
Edoardo Pirovano
a7adbce22c Merge pull request #877 from github/codeql-cli-2.7.6
Update default CodeQL version to 2.7.6
2022-01-24 11:18:52 +00:00
Edoardo Pirovano
3b4e4d44dc Update default CodeQL version to 2.7.6 2022-01-24 09:45:48 +00:00
Andrew Eisenberg
f18151cc59 Update error message and remove feature flag preloading
Discussion here https://github.com/github/codeql-action/pull/882#discussion_r789924177
shows that properly handling preloading feature flag errors is complex
and the benefit we get from it does not offset the complexity.
2022-01-21 11:20:48 -08:00
Andrew Eisenberg
e175dea369 Update changelog 2022-01-21 10:05:52 -08:00
Andrew Eisenberg
752ae5743f Ensure loadApiError is caught
And add a better error message.

By using `void` instead of `await`, any error thrown is not caught
by surrounding try-catch blocks.

I could continue to use `void` and explicitly handle any thrown errors
by using `.catch`, but most likely the time savings is minimal and
this makes the code more complex.
2022-01-21 10:04:08 -08:00
Andrew Eisenberg
0dabead789 Merge pull request #876 from github/aeisenberg/multi-init
Include better error message
2022-01-21 08:42:06 -08:00
Andrew Eisenberg
5e69ce82f8 Merge branch 'main' into aeisenberg/multi-init 2022-01-21 08:04:13 -08:00
Edoardo Pirovano
fdb92bbffe Merge pull request #881 from github/edoardo/respect-env
Respect extra options in a few `codeql` calls
2022-01-21 14:02:21 +00:00
Edoardo Pirovano
14b4839253 Respect extra options in a few codeql calls 2022-01-21 13:44:52 +00:00
Edoardo Pirovano
d76304cd8e Merge pull request #880 from github/mergeback/v1.0.29-to-main-384cfc42
Mergeback v1.0.29 refs/heads/v1 into main
2022-01-21 11:53:08 +00:00
github-actions[bot]
57c4e974c2 Update checked-in dependencies 2022-01-21 11:23:59 +00:00
github-actions[bot]
c2fb041dc1 1.0.30 2022-01-21 11:12:16 +00:00
github-actions[bot]
ac9d34fbc6 Update changelog and version after v1.0.29 2022-01-21 11:12:14 +00:00
Edoardo Pirovano
384cfc42b2 Merge pull request #879 from github/update-v1.0.29-67c0353a
Merge main into v1
2022-01-21 11:11:07 +00:00
github-actions[bot]
5a1e31dc6a 1.0.29 2022-01-21 10:47:33 +00:00
Edoardo Pirovano
67c0353a8c Merge pull request #878 from github/revert-wait-for-processing
Revert "Start waiting for processing by default."
2022-01-21 10:45:30 +00:00
Chris Gavin
7ec25e02e3 Add a changelog note. 2022-01-21 10:26:18 +00:00
Chris Gavin
713eacdf6c Revert "Start waiting for processing by default."
This reverts commit b661ef1697.
2022-01-21 10:25:57 +00:00
Andrew Eisenberg
c8290d07f0 Update changelog
Add a line item for using a better error message.

Also, add a link for an entry that didn't have one before.
2022-01-20 10:31:43 -08:00
Andrew Eisenberg
51126e5cd1 Include better error message
When users call init multiple times.
2022-01-20 10:28:11 -08:00
Edoardo Pirovano
c0b507e521 Merge pull request #875 from github/mergeback/v1.0.28-to-main-8a4b243f
Mergeback v1.0.28 refs/heads/v1 into main
2022-01-18 22:21:27 +00:00
github-actions[bot]
d563b098d7 Update checked-in dependencies 2022-01-18 21:54:31 +00:00
github-actions[bot]
fca047627b 1.0.29 2022-01-18 21:35:32 +00:00
github-actions[bot]
28fe8e7028 Update changelog and version after v1.0.28 2022-01-18 21:35:30 +00:00
Andrew Eisenberg
8a4b243fbf Merge pull request #874 from github/update-v1.0.28-b31df3ff
Merge main into v1
2022-01-18 13:33:47 -08:00
Andrew Eisenberg
19970ae6b5 Update changelog
Add an entry and move an entry.
2022-01-18 12:44:43 -08:00
github-actions[bot]
ec1b16574e 1.0.28 2022-01-18 19:13:38 +00:00
Henning Makholm
b31df3ff95 Merge pull request #866 from github/hmakholm/pr/2.7.5
Bump CodeQL version to 2.7.5
2022-01-17 19:45:58 +01:00
Henning Makholm
776db51d2e Merge remote-tracking branch 'origin/main' into hmakholm/pr/2.7.5 2022-01-17 18:27:39 +01:00
Andrew Eisenberg
b886234637 Merge pull request #872 from github/aeisenberg/category-with-tool
Change category uniqueness test
2022-01-17 09:19:39 -08:00
Henning Makholm
9913c9bfa5 Merge remote-tracking branch 'origin/main' into hmakholm/pr/2.7.5 2022-01-17 18:06:10 +01:00
Andrew Eisenberg
8de62beb50 Merge branch 'main' into aeisenberg/category-with-tool 2022-01-17 09:00:14 -08:00
Andrew Eisenberg
b6fbccaba1 Merge pull request #873 from github/nickrolfe/ruby
Update warning about interpreted languages to mention Ruby
2022-01-14 09:05:50 -08:00
Nick Rolfe
df0c306daf Update warning about interpreted languages to mention Ruby 2022-01-14 11:57:29 +00:00
Andrew Eisenberg
ab1f709732 Allow duplicate categories in the same validation step
A single SARIF file should be allowed to have duplicated
categories.
2022-01-13 10:35:03 -08:00
Andrew Eisenberg
8454e21c9c Change category uniqueness test
Turboscan only allows a single combination of tool name and automation
details id for testing category uniqueness.

Previously, the check in the action was not entirely correct since it
only looked at the _category_ and not the combination of the category
and the tool name.

It's even more precise now since it is looking at the actual, computed
value of the automation details id, rather than an inputted value of
the category.

This change also includes a refactoring where the action is now avoiding
multiple parsing/stringifying of the sarif files. Instead, sarif is
parsed once at the start of the process and stringified once, after
sarif processing is completely finished.
2022-01-12 15:26:34 -08:00
Henning Makholm
d85c3e58ec Bump CodeQL version to 2.7.5 2022-01-12 19:36:20 +01:00
Edoardo Pirovano
cbabe47a0b Merge pull request #871 from github/mergeback/v1.0.27-to-main-cd783c8a
Mergeback v1.0.27 refs/heads/v1 into main
2022-01-11 22:22:02 +00:00
github-actions[bot]
f8a48f464d Update checked-in dependencies 2022-01-11 21:57:25 +00:00
github-actions[bot]
f6f23f8671 1.0.28 2022-01-11 21:43:35 +00:00
github-actions[bot]
c2a7379048 Update changelog and version after v1.0.27 2022-01-11 21:43:33 +00:00
Edoardo Pirovano
cd783c8a29 Merge pull request #870 from github/update-v1.0.27-faa9ba73
Merge main into v1
2022-01-11 21:42:44 +00:00
github-actions[bot]
300c8b6dcb 1.0.27 2022-01-11 20:35:30 +00:00
Edoardo Pirovano
faa9ba7363 Merge pull request #869 from github/edoardo/windows-11-error
Refuse to run on Windows 11
2022-01-11 20:34:11 +00:00
Edoardo Pirovano
d2a0fc83dc Refuse to run on Windows 11 2022-01-11 18:34:33 +00:00
2129 changed files with 62222 additions and 141114 deletions

View File

@@ -10,7 +10,8 @@
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking", "plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:github/recommended", "plugin:github/recommended",
"plugin:github/typescript" "plugin:github/typescript",
"plugin:import/typescript"
], ],
"rules": { "rules": {
"filenames/match-regex": ["error", "^[a-z0-9-]+(\\.test)?$"], "filenames/match-regex": ["error", "^[a-z0-9-]+(\\.test)?$"],

20
.github/check-sarif/action.yml vendored Normal file
View File

@@ -0,0 +1,20 @@
name: Check SARIF
description: Checks a SARIF file to see if certain queries were run and others were not run.
inputs:
sarif-file:
required: true
description: The SARIF file to check
queries-run:
required: true
description: |
Comma separated list of query ids that should be included in this SARIF file.
queries-not-run:
required: true
description: |
Comma separated list of query ids that should NOT be included in this SARIF file.
runs:
using: node12
main: index.js

43
.github/check-sarif/index.js vendored Normal file
View File

@@ -0,0 +1,43 @@
'use strict'
const core = require('@actions/core')
const fs = require('fs')
const sarif = JSON.parse(fs.readFileSync(core.getInput('sarif-file'), 'utf8'))
const rules = sarif.runs[0].tool.extensions.flatMap(ext => ext.rules || [])
const ruleIds = rules.map(rule => rule.id)
// Check that all the expected queries ran
const expectedQueriesRun = getQueryIdsInput('queries-run')
const queriesThatShouldHaveRunButDidNot = expectedQueriesRun.filter(queryId => !ruleIds.includes(queryId))
if (queriesThatShouldHaveRunButDidNot.length > 0) {
core.setFailed(`The following queries were expected to run but did not: ${queriesThatShouldHaveRunButDidNot.join(', ')}`)
}
// Check that all the unexpected queries did not run
const expectedQueriesNotRun = getQueryIdsInput('queries-not-run')
const queriesThatShouldNotHaveRunButDid = expectedQueriesNotRun.filter(queryId => ruleIds.includes(queryId))
if (queriesThatShouldNotHaveRunButDid.length > 0) {
core.setFailed(`The following queries were NOT expected to have run but did: ${queriesThatShouldNotHaveRunButDid.join(', ')}`)
}
core.startGroup('All queries run')
rules.forEach(rule => {
core.info(`${rule.id}: ${(rule.properties && rule.properties.name) || rule.name}`)
})
core.endGroup()
core.startGroup('Full SARIF')
core.info(JSON.stringify(sarif, null, 2))
core.endGroup()
function getQueryIdsInput(name) {
return core.getInput(name)
.split(',')
.map(q => q.trim())
.filter(q => q.length > 0)
}

52
.github/query-filter-test/action.yml vendored Normal file
View File

@@ -0,0 +1,52 @@
name: Query Filter Test
description: Runs a test of query filters using the check sarif action
inputs:
sarif-file:
required: true
description: The SARIF file to check
queries-run:
required: true
description: |
Comma separated list of query ids that should be included in this SARIF file.
queries-not-run:
required: true
description: |
Comma separated list of query ids that should NOT be included in this SARIF file.
config-file:
required: true
description: |
The location of the codeql configuration file to use.
tools:
required: true
description: |
The url of codeql to use.
runs:
using: composite
steps:
- uses: ./../action/init
with:
languages: javascript
config-file: ${{ inputs.config-file }}
tools: ${{ inputs.tools }}
db-location: ${{ runner.temp }}/query-filter-test
- uses: ./../action/analyze
with:
output: ${{ runner.temp }}/results
upload-database: false
upload: false
env:
TEST_MODE: "true"
- name: Check SARIF
uses: ./../action/.github/check-sarif
with:
sarif-file: ${{ inputs.sarif-file }}
queries-run: ${{ inputs.queries-run}}
queries-not-run: ${{ inputs.queries-not-run}}
- name: Cleanup after test
shell: bash
run: rm -rf "$RUNNER_TEMP/results" "$RUNNER_TEMP//query-filter-test"

View File

@@ -1,12 +1,9 @@
import argparse
import datetime import datetime
from github import Github from github import Github
import random
import requests
import subprocess
import sys
import json import json
import datetime
import os import os
import subprocess
EMPTY_CHANGELOG = """# CodeQL Action and CodeQL Runner Changelog EMPTY_CHANGELOG = """# CodeQL Action and CodeQL Runner Changelog
@@ -16,21 +13,25 @@ No user facing changes.
""" """
# The branch being merged from. # Value of the mode flag for a v1 release
# This is the one that contains day-to-day development work. V1_MODE = 'v1-release'
MAIN_BRANCH = 'main'
# The branch being merged into. # Value of the mode flag for a v2 release
# This is the release branch that users reference. V2_MODE = 'v2-release'
LATEST_RELEASE_BRANCH = 'v1'
SOURCE_BRANCH_FOR_MODE = { V1_MODE: 'releases/v2', V2_MODE: 'main' }
TARGET_BRANCH_FOR_MODE = { V1_MODE: 'releases/v1', V2_MODE: 'releases/v2' }
# Name of the remote # Name of the remote
ORIGIN = 'origin' ORIGIN = 'origin'
# Runs git with the given args and returns the stdout. # Runs git with the given args and returns the stdout.
# Raises an error if git does not exit successfully. # Raises an error if git does not exit successfully (unless passed
def run_git(*args): # allow_non_zero_exit_code=True).
def run_git(*args, allow_non_zero_exit_code=False):
cmd = ['git', *args] cmd = ['git', *args]
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if (p.returncode != 0): if not allow_non_zero_exit_code and p.returncode != 0:
raise Exception('Call to ' + ' '.join(cmd) + ' exited with code ' + str(p.returncode) + ' stderr:' + p.stderr.decode('ascii')) raise Exception('Call to ' + ' '.join(cmd) + ' exited with code ' + str(p.returncode) + ' stderr:' + p.stderr.decode('ascii'))
return p.stdout.decode('ascii') return p.stdout.decode('ascii')
@@ -38,8 +39,10 @@ def run_git(*args):
def branch_exists_on_remote(branch_name): def branch_exists_on_remote(branch_name):
return run_git('ls-remote', '--heads', ORIGIN, branch_name).strip() != '' return run_git('ls-remote', '--heads', ORIGIN, branch_name).strip() != ''
# Opens a PR from the given branch to the release branch # Opens a PR from the given branch to the target branch
def open_pr(repo, all_commits, short_main_sha, branch_name): def open_pr(
repo, all_commits, source_branch_short_sha, new_branch_name, source_branch, target_branch,
conductor, is_v2_release, labels, conflicted_files):
# Sort the commits into the pull requests that introduced them, # Sort the commits into the pull requests that introduced them,
# and any commits that don't have a pull request # and any commits that don't have a pull request
pull_requests = [] pull_requests = []
@@ -61,9 +64,8 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
# Start constructing the body text # Start constructing the body text
body = [] body = []
body.append('Merging ' + short_main_sha + ' into ' + LATEST_RELEASE_BRANCH) body.append('Merging ' + source_branch_short_sha + ' into ' + target_branch)
conductor = get_conductor(repo, pull_requests, commits_without_pull_requests)
body.append('') body.append('')
body.append('Conductor for this PR is @' + conductor) body.append('Conductor for this PR is @' + conductor)
@@ -80,43 +82,46 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
body.append('') body.append('')
body.append('Contains the following commits not from a pull request:') body.append('Contains the following commits not from a pull request:')
for commit in commits_without_pull_requests: for commit in commits_without_pull_requests:
body.append('- ' + commit.sha + ' - ' + get_truncated_commit_message(commit) + ' (@' + commit.author.login + ')') author_description = ' (@' + commit.author.login + ')' if commit.author is not None else ''
body.append('- ' + commit.sha + ' - ' + get_truncated_commit_message(commit) + author_description)
body.append('') body.append('')
body.append('Please review the following:') body.append('Please review the following:')
if len(conflicted_files) > 0:
body.append(' - [ ] You have added commits to this branch that resolve the merge conflicts ' +
'in the following files:')
body.extend([f' - [ ] `{file}`' for file in conflicted_files])
body.append(' - [ ] Another maintainer has reviewed the additional commits you added to this ' +
'branch to resolve the merge conflicts.')
body.append(' - [ ] The CHANGELOG displays the correct version and date.') body.append(' - [ ] The CHANGELOG displays the correct version and date.')
body.append(' - [ ] The CHANGELOG includes all relevant, user-facing changes since the last release.') body.append(' - [ ] The CHANGELOG includes all relevant, user-facing changes since the last release.')
body.append(' - [ ] There are no unexpected commits being merged into the ' + LATEST_RELEASE_BRANCH + ' branch.') body.append(' - [ ] There are no unexpected commits being merged into the ' + target_branch + ' branch.')
body.append(' - [ ] The docs team is aware of any documentation changes that need to be released.') body.append(' - [ ] The docs team is aware of any documentation changes that need to be released.')
body.append(' - [ ] The mergeback PR is merged back into ' + MAIN_BRANCH + ' after this PR is merged.') if is_v2_release:
body.append(' - [ ] The mergeback PR is merged back into ' + source_branch + ' after this PR is merged.')
body.append(' - [ ] The v1 release PR is merged after this PR is merged.')
title = 'Merge ' + MAIN_BRANCH + ' into ' + LATEST_RELEASE_BRANCH title = 'Merge ' + source_branch + ' into ' + target_branch
# Create the pull request # Create the pull request
# PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft so that # PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft so that
# a maintainer can take the PR out of draft, thereby triggering the PR checks. # a maintainer can take the PR out of draft, thereby triggering the PR checks.
pr = repo.create_pull(title=title, body='\n'.join(body), head=branch_name, base=LATEST_RELEASE_BRANCH, draft=True) pr = repo.create_pull(title=title, body='\n'.join(body), head=new_branch_name, base=target_branch, draft=True)
pr.add_to_labels(*labels)
print('Created PR #' + str(pr.number)) print('Created PR #' + str(pr.number))
# Assign the conductor # Assign the conductor
pr.add_to_assignees(conductor) pr.add_to_assignees(conductor)
print('Assigned PR to ' + conductor) print('Assigned PR to ' + conductor)
# Gets the person who should be in charge of the mergeback PR # Gets a list of the SHAs of all commits that have happened on the source branch
def get_conductor(repo, pull_requests, other_commits): # since the last release to the target branch.
# If there are any PRs then use whoever merged the last one # This will not include any commits that exist on the target branch
if len(pull_requests) > 0: # that aren't on the source branch.
return get_merger_of_pr(repo, pull_requests[-1]) def get_commit_difference(repo, source_branch, target_branch):
# Passing split nothing means that the empty string splits to nothing: compare `''.split() == []`
# Otherwise take the author of the latest commit # to `''.split('\n') == ['']`.
return other_commits[-1].author.login commits = run_git('log', '--pretty=format:%H', ORIGIN + '/' + target_branch + '..' + ORIGIN + '/' + source_branch).strip().split()
# Gets a list of the SHAs of all commits that have happened on main
# since the release branched off.
# This will not include any commits that exist on the release branch
# that aren't on main.
def get_commit_difference(repo):
commits = run_git('log', '--pretty=format:%H', ORIGIN + '/' + LATEST_RELEASE_BRANCH + '..' + ORIGIN + '/' + MAIN_BRANCH).strip().split('\n')
# Convert to full-fledged commit objects # Convert to full-fledged commit objects
commits = [repo.get_commit(c) for c in commits] commits = [repo.get_commit(c) for c in commits]
@@ -136,7 +141,7 @@ def get_truncated_commit_message(commit):
else: else:
return message return message
# Converts a commit into the PR that introduced it to the main branch. # Converts a commit into the PR that introduced it to the source branch.
# Returns the PR object, or None if no PR could be found. # Returns the PR object, or None if no PR could be found.
def get_pr_for_commit(repo, commit): def get_pr_for_commit(repo, commit):
prs = commit.get_pulls() prs = commit.get_pulls()
@@ -179,29 +184,65 @@ def update_changelog(version):
def main(): def main():
if len(sys.argv) != 3: parser = argparse.ArgumentParser('update-release-branch.py')
raise Exception('Usage: update-release.branch.py <github token> <repository nwo>')
github_token = sys.argv[1]
repository_nwo = sys.argv[2]
repo = Github(github_token).get_repo(repository_nwo) parser.add_argument(
'--github-token',
type=str,
required=True,
help='GitHub token, typically from GitHub Actions.'
)
parser.add_argument(
'--repository-nwo',
type=str,
required=True,
help='The nwo of the repository, for example github/codeql-action.'
)
parser.add_argument(
'--mode',
type=str,
required=True,
choices=[V2_MODE, V1_MODE],
help=f"Which release to perform. '{V2_MODE}' uses {SOURCE_BRANCH_FOR_MODE[V2_MODE]} as the source " +
f"branch and {TARGET_BRANCH_FOR_MODE[V2_MODE]} as the target branch. " +
f"'{V1_MODE}' uses {SOURCE_BRANCH_FOR_MODE[V1_MODE]} as the source branch and " +
f"{TARGET_BRANCH_FOR_MODE[V1_MODE]} as the target branch."
)
parser.add_argument(
'--conductor',
type=str,
required=True,
help='The GitHub handle of the person who is conducting the release process.'
)
args = parser.parse_args()
source_branch = SOURCE_BRANCH_FOR_MODE[args.mode]
target_branch = TARGET_BRANCH_FOR_MODE[args.mode]
repo = Github(args.github_token).get_repo(args.repository_nwo)
version = get_current_version() version = get_current_version()
if args.mode == V1_MODE:
# Change the version number to a v1 equivalent
version = get_current_version()
version = f'1{version[1:]}'
# Print what we intend to go # Print what we intend to go
print('Considering difference between ' + MAIN_BRANCH + ' and ' + LATEST_RELEASE_BRANCH) print('Considering difference between ' + source_branch + ' and ' + target_branch)
short_main_sha = run_git('rev-parse', '--short', ORIGIN + '/' + MAIN_BRANCH).strip() source_branch_short_sha = run_git('rev-parse', '--short', ORIGIN + '/' + source_branch).strip()
print('Current head of ' + MAIN_BRANCH + ' is ' + short_main_sha) print('Current head of ' + source_branch + ' is ' + source_branch_short_sha)
# See if there are any commits to merge in # See if there are any commits to merge in
commits = get_commit_difference(repo) commits = get_commit_difference(repo=repo, source_branch=source_branch, target_branch=target_branch)
if len(commits) == 0: if len(commits) == 0:
print('No commits to merge from ' + MAIN_BRANCH + ' to ' + LATEST_RELEASE_BRANCH) print('No commits to merge from ' + source_branch + ' to ' + target_branch)
return return
# The branch name is based off of the name of branch being merged into # The branch name is based off of the name of branch being merged into
# and the SHA of the branch being merged from. Thus if the branch already # and the SHA of the branch being merged from. Thus if the branch already
# exists we can assume we don't need to recreate it. # exists we can assume we don't need to recreate it.
new_branch_name = 'update-v' + version + '-' + short_main_sha new_branch_name = 'update-v' + version + '-' + source_branch_short_sha
print('Branch name is ' + new_branch_name) print('Branch name is ' + new_branch_name)
# Check if the branch already exists. If so we can abort as this script # Check if the branch already exists. If so we can abort as this script
@@ -212,19 +253,90 @@ def main():
# Create the new branch and push it to the remote # Create the new branch and push it to the remote
print('Creating branch ' + new_branch_name) print('Creating branch ' + new_branch_name)
run_git('checkout', '-b', new_branch_name, ORIGIN + '/' + MAIN_BRANCH)
print('Updating changelog') # The process of creating the v1 release can run into merge conflicts. We commit the unresolved
update_changelog(version) # conflicts so a maintainer can easily resolve them (vs erroring and requiring maintainers to
# reconstruct the release manually)
conflicted_files = []
# Create a commit that updates the CHANGELOG if args.mode == V1_MODE:
run_git('add', 'CHANGELOG.md') # If we're performing a backport, start from the target branch
run_git('commit', '-m', version) print(f'Creating {new_branch_name} from the {ORIGIN}/{target_branch} branch')
run_git('checkout', '-b', new_branch_name, f'{ORIGIN}/{target_branch}')
# Revert the commit that we made as part of the last release that updated the version number and
# changelog to refer to 1.x.x variants. This avoids merge conflicts in the changelog and
# package.json files when we merge in the v2 branch.
# This commit will not exist the first time we release the v1 branch from the v2 branch, so we
# use `git log --grep` to conditionally revert the commit.
print('Reverting the 1.x.x version number and changelog updates from the last release to avoid conflicts')
v1_update_commits = run_git('log', '--grep', '^Update version and changelog for v', '--format=%H').split()
if len(v1_update_commits) > 0:
print(f' Reverting {v1_update_commits[0]}')
# Only revert the newest commit as older ones will already have been reverted in previous
# releases.
run_git('revert', v1_update_commits[0], '--no-edit')
# Also revert the "Update checked-in dependencies" commit created by Actions.
update_dependencies_commit = run_git('log', '--grep', '^Update checked-in dependencies', '--format=%H').split()[0]
print(f' Reverting {update_dependencies_commit}')
run_git('revert', update_dependencies_commit, '--no-edit')
else:
print(' Nothing to revert.')
print(f'Merging {ORIGIN}/{source_branch} into the release prep branch')
# Commit any conflicts (see the comment for `conflicted_files`)
run_git('merge', f'{ORIGIN}/{source_branch}', allow_non_zero_exit_code=True)
conflicted_files = run_git('diff', '--name-only', '--diff-filter', 'U').splitlines()
if len(conflicted_files) > 0:
run_git('add', '.')
run_git('commit', '--no-edit')
# Migrate the package version number from a v2 version number to a v1 version number
print(f'Setting version number to {version}')
subprocess.run(['npm', 'version', version, '--no-git-tag-version'])
run_git('add', 'package.json', 'package-lock.json')
# Migrate the changelog notes from v2 version numbers to v1 version numbers
print('Migrating changelog notes from v2 to v1')
subprocess.run(['sed', '-i', 's/^## 2\./## 1./g', 'CHANGELOG.md'])
# Remove changelog notes from v2 that don't apply to v1
subprocess.run(['sed', '-i', '/^- \[v2+ only\]/d', 'CHANGELOG.md'])
# Amend the commit generated by `npm version` to update the CHANGELOG
run_git('add', 'CHANGELOG.md')
run_git('commit', '-m', f'Update version and changelog for v{version}')
else:
# If we're performing a standard release, there won't be any new commits on the target branch,
# as these will have already been merged back into the source branch. Therefore we can just
# start from the source branch.
run_git('checkout', '-b', new_branch_name, f'{ORIGIN}/{source_branch}')
print('Updating changelog')
update_changelog(version)
# Create a commit that updates the CHANGELOG
run_git('add', 'CHANGELOG.md')
run_git('commit', '-m', f'Update changelog for v{version}')
run_git('push', ORIGIN, new_branch_name) run_git('push', ORIGIN, new_branch_name)
# Open a PR to update the branch # Open a PR to update the branch
open_pr(repo, commits, short_main_sha, new_branch_name) open_pr(
repo,
commits,
source_branch_short_sha,
new_branch_name,
source_branch=source_branch,
target_branch=target_branch,
conductor=args.conductor,
is_v2_release=args.mode == V2_MODE,
labels=['Update dependencies'] if args.mode == V1_MODE else [],
conflicted_files=conflicted_files
)
if __name__ == '__main__': if __name__ == '__main__':
main() main()

95
.github/workflows/__analyze-ref-input.yml generated vendored Normal file
View File

@@ -0,0 +1,95 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# to regenerate this file.
name: "PR Check - Analyze: 'ref' and 'sha' from inputs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO111MODULE: auto
on:
push:
branches:
- main
- releases/v1
- releases/v2
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch: {}
jobs:
analyze-ref-input:
strategy:
matrix:
include:
- os: ubuntu-latest
version: stable-20210308
- os: macos-latest
version: stable-20210308
- os: windows-2019
version: stable-20210308
- os: ubuntu-latest
version: stable-20210319
- os: macos-latest
version: stable-20210319
- os: windows-2019
version: stable-20210319
- os: ubuntu-latest
version: stable-20210809
- os: macos-latest
version: stable-20210809
- os: windows-2019
version: stable-20210809
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-2019
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-2019
version: latest
- os: windows-2022
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-2019
version: nightly-latest
- os: windows-2022
version: nightly-latest
name: "Analyze: 'ref' and 'sha' from inputs"
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Prepare test
id: prepare-test
uses: ./.github/prepare-test
with:
version: ${{ matrix.version }}
- uses: ./../action/init
with:
tools: ${{ steps.prepare-test.outputs.tools-url }}
languages: cpp,csharp,java,javascript,python
config-file: ${{ github.repository }}/tests/multi-language-repo/.github/codeql/custom-queries.yml@${{
github.sha }}
- name: Build code
shell: bash
run: ./build.sh
- uses: ./../action/analyze
with:
ref: refs/heads/main
sha: 5e235361806c361d4d3f8859e3c897658025a9a2
env:
TEST_MODE: true
env:
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,19 +24,37 @@ jobs:
debug-artifacts: debug-artifacts:
strategy: strategy:
matrix: matrix:
version: include:
- stable-20201028 - os: ubuntu-latest
- stable-20210319 version: stable-20210308
- stable-20210809 - os: macos-latest
- cached version: stable-20210308
- latest - os: ubuntu-latest
- nightly-latest version: stable-20210319
os: [ubuntu-latest, macos-latest] - os: macos-latest
version: stable-20210319
- os: ubuntu-latest
version: stable-20210809
- os: macos-latest
version: stable-20210809
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
name: Debug artifact upload name: Debug artifact upload
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test
@@ -52,7 +71,7 @@ jobs:
run: ./build.sh run: ./build.sh
- uses: ./../action/analyze - uses: ./../action/analyze
id: analysis id: analysis
- uses: actions/download-artifact@v2 - uses: actions/download-artifact@v3
with: with:
name: my-debug-artifacts-${{ matrix.os }}-${{ matrix.version }} name: my-debug-artifacts-${{ matrix.os }}-${{ matrix.version }}
- shell: bash - shell: bash

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,13 +24,15 @@ jobs:
extractor-ram-threads: extractor-ram-threads:
strategy: strategy:
matrix: matrix:
version: [latest] include:
os: [ubuntu-latest] - os: ubuntu-latest
version: latest
name: Extractor ram and threads options test name: Extractor ram and threads options test
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,28 +24,59 @@ jobs:
go-custom-queries: go-custom-queries:
strategy: strategy:
matrix: matrix:
version: include:
- stable-20201028 - os: ubuntu-latest
- stable-20210319 version: stable-20210308
- stable-20210809 - os: macos-latest
- cached version: stable-20210308
- latest - os: windows-2019
- nightly-latest version: stable-20210308
os: - os: ubuntu-latest
- ubuntu-latest version: stable-20210319
- macos-latest - os: macos-latest
- windows-latest version: stable-20210319
- os: windows-2019
version: stable-20210319
- os: ubuntu-latest
version: stable-20210809
- os: macos-latest
version: stable-20210809
- os: windows-2019
version: stable-20210809
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-2019
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-2019
version: latest
- os: windows-2022
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-2019
version: nightly-latest
- os: windows-2022
version: nightly-latest
name: 'Go: Custom queries' name: 'Go: Custom queries'
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test
with: with:
version: ${{ matrix.version }} version: ${{ matrix.version }}
- uses: actions/setup-go@v2 - uses: actions/setup-go@v3
with: with:
go-version: ^1.13.1 go-version: ^1.13.1
- uses: ./../action/init - uses: ./../action/init

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,25 +24,43 @@ jobs:
go-custom-tracing-autobuild: go-custom-tracing-autobuild:
strategy: strategy:
matrix: matrix:
version: include:
- stable-20201028 - os: ubuntu-latest
- stable-20210319 version: stable-20210308
- stable-20210809 - os: macos-latest
- cached version: stable-20210308
- latest - os: ubuntu-latest
- nightly-latest version: stable-20210319
os: [ubuntu-latest, macos-latest] - os: macos-latest
version: stable-20210319
- os: ubuntu-latest
version: stable-20210809
- os: macos-latest
version: stable-20210809
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
name: 'Go: Autobuild custom tracing' name: 'Go: Autobuild custom tracing'
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test
with: with:
version: ${{ matrix.version }} version: ${{ matrix.version }}
- uses: actions/setup-go@v2 - uses: actions/setup-go@v3
with: with:
go-version: ^1.13.1 go-version: ^1.13.1
- uses: ./../action/init - uses: ./../action/init

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,28 +24,59 @@ jobs:
go-custom-tracing: go-custom-tracing:
strategy: strategy:
matrix: matrix:
version: include:
- stable-20201028 - os: ubuntu-latest
- stable-20210319 version: stable-20210308
- stable-20210809 - os: macos-latest
- cached version: stable-20210308
- latest - os: windows-2019
- nightly-latest version: stable-20210308
os: - os: ubuntu-latest
- ubuntu-latest version: stable-20210319
- macos-latest - os: macos-latest
- windows-latest version: stable-20210319
- os: windows-2019
version: stable-20210319
- os: ubuntu-latest
version: stable-20210809
- os: macos-latest
version: stable-20210809
- os: windows-2019
version: stable-20210809
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-2019
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-2019
version: latest
- os: windows-2022
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-2019
version: nightly-latest
- os: windows-2022
version: nightly-latest
name: 'Go: Custom tracing' name: 'Go: Custom tracing'
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test
with: with:
version: ${{ matrix.version }} version: ${{ matrix.version }}
- uses: actions/setup-go@v2 - uses: actions/setup-go@v3
with: with:
go-version: ^1.13.1 go-version: ^1.13.1
- uses: ./../action/init - uses: ./../action/init

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,13 +24,19 @@ jobs:
javascript-source-root: javascript-source-root:
strategy: strategy:
matrix: matrix:
version: [latest, cached, nightly-latest] # This feature is not compatible with old CLIs include:
os: [ubuntu-latest] - os: ubuntu-latest
version: latest
- os: ubuntu-latest
version: cached
- os: ubuntu-latest
version: nightly-latest
name: Custom source root name: Custom source root
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test

129
.github/workflows/__ml-powered-queries.yml generated vendored Normal file
View File

@@ -0,0 +1,129 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# to regenerate this file.
name: PR Check - ML-powered queries
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO111MODULE: auto
on:
push:
branches:
- main
- releases/v1
- releases/v2
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch: {}
jobs:
ml-powered-queries:
strategy:
matrix:
include:
- os: ubuntu-latest
version: stable-20220120
- os: macos-latest
version: stable-20220120
- os: windows-latest
version: stable-20220120
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-latest
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-latest
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-latest
version: nightly-latest
name: ML-powered queries
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Prepare test
id: prepare-test
uses: ./.github/prepare-test
with:
version: ${{ matrix.version }}
- uses: ./../action/init
with:
languages: javascript
queries: security-extended
source-root: ./../action/tests/ml-powered-queries-repo
tools: ${{ steps.prepare-test.outputs.tools-url }}
- uses: ./../action/analyze
with:
output: ${{ runner.temp }}/results
upload-database: false
env:
TEST_MODE: true
- name: Upload SARIF
uses: actions/upload-artifact@v3
with:
name: ml-powered-queries-${{ matrix.os }}-${{ matrix.version }}.sarif.json
path: ${{ runner.temp }}/results/javascript.sarif
retention-days: 7
- name: Check results
# Running ML-powered queries on Windows requires CodeQL CLI 2.9.0+. We don't run these checks
# against Windows and `cached` while CodeQL CLI 2.9.0 makes its way into `cached` to avoid the
# test starting to fail when the cached CodeQL Bundle gets updated. Once the CodeQL Bundle
# containing CodeQL CLI 2.9.0 has been fully released, we can drop this line and start running
# these checks on Windows and `cached`.
if: matrix.os != 'windows-latest' || matrix.version != 'cached'
env:
# Running on Windows requires CodeQL CLI 2.9.0+, which has so far only made it to 'latest'.
SHOULD_RUN_ML_POWERED_QUERIES: ${{ matrix.os != 'windows-latest' || matrix.version
== 'latest' || matrix.version == 'nightly-latest' }}
shell: bash
run: |
echo "Expecting ML-powered queries to be run: ${SHOULD_RUN_ML_POWERED_QUERIES}"
cd "$RUNNER_TEMP/results"
# We should run at least the ML-powered queries in `expected_rules`.
expected_rules="js/ml-powered/nosql-injection js/ml-powered/path-injection js/ml-powered/sql-injection js/ml-powered/xss"
for rule in ${expected_rules}; do
found_rule=$(jq --arg rule "${rule}" '[.runs[0].tool.extensions[].rules | select(. != null) |
flatten | .[].id] | any(. == $rule)' javascript.sarif)
echo "Did find rule '${rule}': ${found_rule}"
if [[ "${found_rule}" != "true" && "${SHOULD_RUN_ML_POWERED_QUERIES}" == "true" ]]; then
echo "Expected SARIF output to contain rule '${rule}', but found no such rule."
exit 1
elif [[ "${found_rule}" == "true" && "${SHOULD_RUN_ML_POWERED_QUERIES}" != "true" ]]; then
echo "Found rule '${rule}' in the SARIF output which shouldn't have been part of the analysis."
exit 1
fi
done
# We should have at least one alert from an ML-powered query.
num_alerts=$(jq '[.runs[0].results[] |
select(.properties.score != null and (.rule.id | startswith("js/ml-powered/")))] | length' \
javascript.sarif)
echo "Found ${num_alerts} alerts from ML-powered queries.";
if [[ "${num_alerts}" -eq 0 && "${SHOULD_RUN_ML_POWERED_QUERIES}" == "true" ]]; then
echo "Expected to find at least one alert from an ML-powered query but found ${num_alerts}."
exit 1
elif [[ "${num_alerts}" -ne 0 && "${SHOULD_RUN_ML_POWERED_QUERIES}" != "true" ]]; then
echo "Expected not to find any alerts from an ML-powered query but found ${num_alerts}."
exit 1
fi
env:
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,19 +24,37 @@ jobs:
multi-language-autodetect: multi-language-autodetect:
strategy: strategy:
matrix: matrix:
version: include:
- stable-20201028 - os: ubuntu-latest
- stable-20210319 version: stable-20210308
- stable-20210809 - os: macos-latest
- cached version: stable-20210308
- latest - os: ubuntu-latest
- nightly-latest version: stable-20210319
os: [ubuntu-latest, macos-latest] - os: macos-latest
version: stable-20210319
- os: ubuntu-latest
version: stable-20210809
- os: macos-latest
version: stable-20210809
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
name: Multi-language repository name: Multi-language repository
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,13 +24,35 @@ jobs:
packaging-config-inputs-js: packaging-config-inputs-js:
strategy: strategy:
matrix: matrix:
version: [nightly-20210831] # This CLI version is known to work with package used in this test include:
os: [ubuntu-latest, macos-latest] - os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-2019
version: latest
- os: windows-2022
version: latest
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-2019
version: cached
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-2019
version: nightly-latest
- os: windows-2022
version: nightly-latest
name: 'Packaging: Config and input' name: 'Packaging: Config and input'
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test
@@ -38,7 +61,7 @@ jobs:
- uses: ./../action/init - uses: ./../action/init
with: with:
config-file: .github/codeql/codeql-config-packaging3.yml config-file: .github/codeql/codeql-config-packaging3.yml
packs: +dsp-testing/codeql-pack1@0.1.0 packs: +dsp-testing/codeql-pack1@1.0.0
languages: javascript languages: javascript
tools: ${{ steps.prepare-test.outputs.tools-url }} tools: ${{ steps.prepare-test.outputs.tools-url }}
- name: Build code - name: Build code
@@ -53,11 +76,11 @@ jobs:
shell: bash shell: bash
run: | run: |
cd "$RUNNER_TEMP/results" cd "$RUNNER_TEMP/results"
# We should have 3 hits from these rules # We should have 4 hits from these rules
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block" EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace # use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)" RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
echo "Found matching rules '$RULES'" echo "Found matching rules '$RULES'"
if [ "$RULES" != "$EXPECTED_RULES" ]; then if [ "$RULES" != "$EXPECTED_RULES" ]; then
echo "Did not match expected rules '$EXPECTED_RULES'." echo "Did not match expected rules '$EXPECTED_RULES'."

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,13 +24,35 @@ jobs:
packaging-config-js: packaging-config-js:
strategy: strategy:
matrix: matrix:
version: [nightly-20210831] # This CLI version is known to work with package used in this test include:
os: [ubuntu-latest, macos-latest] - os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-2019
version: latest
- os: windows-2022
version: latest
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-2019
version: cached
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-2019
version: nightly-latest
- os: windows-2022
version: nightly-latest
name: 'Packaging: Config file' name: 'Packaging: Config file'
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test
@@ -52,11 +75,11 @@ jobs:
shell: bash shell: bash
run: | run: |
cd "$RUNNER_TEMP/results" cd "$RUNNER_TEMP/results"
# We should have 3 hits from these rules # We should have 4 hits from these rules
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block" EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace # use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)" RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
echo "Found matching rules '$RULES'" echo "Found matching rules '$RULES'"
if [ "$RULES" != "$EXPECTED_RULES" ]; then if [ "$RULES" != "$EXPECTED_RULES" ]; then
echo "Did not match expected rules '$EXPECTED_RULES'." echo "Did not match expected rules '$EXPECTED_RULES'."

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,13 +24,35 @@ jobs:
packaging-inputs-js: packaging-inputs-js:
strategy: strategy:
matrix: matrix:
version: [nightly-20210831] # This CLI version is known to work with package used in this test include:
os: [ubuntu-latest, macos-latest] - os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-2019
version: latest
- os: windows-2022
version: latest
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-2019
version: cached
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-2019
version: nightly-latest
- os: windows-2022
version: nightly-latest
name: 'Packaging: Action input' name: 'Packaging: Action input'
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test
@@ -39,7 +62,7 @@ jobs:
with: with:
config-file: .github/codeql/codeql-config-packaging2.yml config-file: .github/codeql/codeql-config-packaging2.yml
languages: javascript languages: javascript
packs: dsp-testing/codeql-pack1@0.1.0, dsp-testing/codeql-pack2 packs: dsp-testing/codeql-pack1@1.0.0, dsp-testing/codeql-pack2, dsp-testing/codeql-pack3:other-query.ql
tools: ${{ steps.prepare-test.outputs.tools-url }} tools: ${{ steps.prepare-test.outputs.tools-url }}
- name: Build code - name: Build code
shell: bash shell: bash
@@ -53,11 +76,11 @@ jobs:
shell: bash shell: bash
run: | run: |
cd "$RUNNER_TEMP/results" cd "$RUNNER_TEMP/results"
# We should have 3 hits from these rules # We should have 4 hits from these rules
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block" EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace # use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)" RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
echo "Found matching rules '$RULES'" echo "Found matching rules '$RULES'"
if [ "$RULES" != "$EXPECTED_RULES" ]; then if [ "$RULES" != "$EXPECTED_RULES" ]; then
echo "Did not match expected rules '$EXPECTED_RULES'." echo "Did not match expected rules '$EXPECTED_RULES'."

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,22 +24,53 @@ jobs:
remote-config: remote-config:
strategy: strategy:
matrix: matrix:
version: include:
- stable-20201028 - os: ubuntu-latest
- stable-20210319 version: stable-20210308
- stable-20210809 - os: macos-latest
- cached version: stable-20210308
- latest - os: windows-2019
- nightly-latest version: stable-20210308
os: - os: ubuntu-latest
- ubuntu-latest version: stable-20210319
- macos-latest - os: macos-latest
- windows-latest version: stable-20210319
- os: windows-2019
version: stable-20210319
- os: ubuntu-latest
version: stable-20210809
- os: macos-latest
version: stable-20210809
- os: windows-2019
version: stable-20210809
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-2019
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-2019
version: latest
- os: windows-2022
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-2019
version: nightly-latest
- os: windows-2022
version: nightly-latest
name: Remote config file name: Remote config file
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test
@@ -48,7 +80,7 @@ jobs:
with: with:
tools: ${{ steps.prepare-test.outputs.tools-url }} tools: ${{ steps.prepare-test.outputs.tools-url }}
languages: cpp,csharp,java,javascript,python languages: cpp,csharp,java,javascript,python
config-file: github/codeql-action/tests/multi-language-repo/.github/codeql/custom-queries.yml@${{ config-file: ${{ github.repository }}/tests/multi-language-repo/.github/codeql/custom-queries.yml@${{
github.sha }} github.sha }}
- name: Build code - name: Build code
shell: bash shell: bash

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,19 +24,25 @@ jobs:
rubocop-multi-language: rubocop-multi-language:
strategy: strategy:
matrix: matrix:
version: include:
- stable-20201028 - os: ubuntu-latest
- stable-20210319 version: stable-20210308
- stable-20210809 - os: ubuntu-latest
- cached version: stable-20210319
- latest - os: ubuntu-latest
- nightly-latest version: stable-20210809
os: [ubuntu-latest] - os: ubuntu-latest
version: cached
- os: ubuntu-latest
version: latest
- os: ubuntu-latest
version: nightly-latest
name: RuboCop multi-language name: RuboCop multi-language
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,13 +24,25 @@ jobs:
split-workflow: split-workflow:
strategy: strategy:
matrix: matrix:
version: [nightly-20210831] # This CLI version is known to work with package used in this test include:
os: [ubuntu-latest, macos-latest] - os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
name: Split workflow name: Split workflow
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test
@@ -38,7 +51,7 @@ jobs:
- uses: ./../action/init - uses: ./../action/init
with: with:
config-file: .github/codeql/codeql-config-packaging3.yml config-file: .github/codeql/codeql-config-packaging3.yml
packs: +dsp-testing/codeql-pack1@0.1.0 packs: +dsp-testing/codeql-pack1@1.0.0
languages: javascript languages: javascript
tools: ${{ steps.prepare-test.outputs.tools-url }} tools: ${{ steps.prepare-test.outputs.tools-url }}
- name: Build code - name: Build code
@@ -67,11 +80,11 @@ jobs:
shell: bash shell: bash
run: | run: |
cd "$RUNNER_TEMP/results" cd "$RUNNER_TEMP/results"
# We should have 3 hits from these rules # We should have 4 hits from these rules
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block" EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace # use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)" RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
echo "Found matching rules '$RULES'" echo "Found matching rules '$RULES'"
if [ "$RULES" != "$EXPECTED_RULES" ]; then if [ "$RULES" != "$EXPECTED_RULES" ]; then
echo "Did not match expected rules '$EXPECTED_RULES'." echo "Did not match expected rules '$EXPECTED_RULES'."

67
.github/workflows/__test-autobuild-working-dir.yml generated vendored Normal file
View File

@@ -0,0 +1,67 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# to regenerate this file.
name: PR Check - Autobuild working directory
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO111MODULE: auto
on:
push:
branches:
- main
- releases/v1
- releases/v2
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch: {}
jobs:
test-autobuild-working-dir:
strategy:
matrix:
include:
- os: ubuntu-latest
version: latest
name: Autobuild working directory
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Prepare test
id: prepare-test
uses: ./.github/prepare-test
with:
version: ${{ matrix.version }}
- name: Test setup
shell: bash
run: |
# Make sure that Gradle build succeeds in autobuild-dir ...
cp -a ../action/tests/java-repo autobuild-dir
# ... and fails if attempted in the current directory
echo > build.gradle
- uses: ./../action/init
with:
languages: java
tools: ${{ steps.prepare-test.outputs.tools-url }}
- uses: ./../action/autobuild
with:
working-directory: autobuild-dir
- uses: ./../action/analyze
env:
TEST_MODE: true
- name: Check database
shell: bash
run: |
cd "$RUNNER_TEMP/codeql_databases"
if [[ ! -d java ]]; then
echo "Did not find a Java database"
exit 1
fi
env:
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,13 +24,15 @@ jobs:
test-local-codeql: test-local-codeql:
strategy: strategy:
matrix: matrix:
version: [nightly-latest] include:
os: [ubuntu-latest] - os: ubuntu-latest
version: nightly-latest
name: Local CodeQL bundle name: Local CodeQL bundle
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test

11
.github/workflows/__test-proxy.yml generated vendored
View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,13 +24,15 @@ jobs:
test-proxy: test-proxy:
strategy: strategy:
matrix: matrix:
version: [latest] include:
os: [ubuntu-latest] - os: ubuntu-latest
version: latest
name: Proxy test name: Proxy test
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test

21
.github/workflows/__test-ruby.yml generated vendored
View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,13 +24,25 @@ jobs:
test-ruby: test-ruby:
strategy: strategy:
matrix: matrix:
version: [latest, cached, nightly-latest] include:
os: [ubuntu-latest, macos-latest] - os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
name: Ruby analysis name: Ruby analysis
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test

View File

@@ -11,7 +11,8 @@ on:
push: push:
branches: branches:
- main - main
- v1 - releases/v1
- releases/v2
pull_request: pull_request:
types: types:
- opened - opened
@@ -23,19 +24,25 @@ jobs:
unset-environment: unset-environment:
strategy: strategy:
matrix: matrix:
version: include:
- stable-20201028 - os: ubuntu-latest
- stable-20210319 version: stable-20210308
- stable-20210809 - os: ubuntu-latest
- cached version: stable-20210319
- latest - os: ubuntu-latest
- nightly-latest version: stable-20210809
os: [ubuntu-latest] - os: ubuntu-latest
version: cached
- os: ubuntu-latest
version: latest
- os: ubuntu-latest
version: nightly-latest
name: Test unsetting environment variables name: Test unsetting environment variables
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Prepare test - name: Prepare test
id: prepare-test id: prepare-test
uses: ./.github/prepare-test uses: ./.github/prepare-test

102
.github/workflows/__upload-ref-sha-input.yml generated vendored Normal file
View File

@@ -0,0 +1,102 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# to regenerate this file.
name: "PR Check - Upload-sarif: 'ref' and 'sha' from inputs"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO111MODULE: auto
on:
push:
branches:
- main
- releases/v1
- releases/v2
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch: {}
jobs:
upload-ref-sha-input:
strategy:
matrix:
include:
- os: ubuntu-latest
version: stable-20210308
- os: macos-latest
version: stable-20210308
- os: windows-2019
version: stable-20210308
- os: ubuntu-latest
version: stable-20210319
- os: macos-latest
version: stable-20210319
- os: windows-2019
version: stable-20210319
- os: ubuntu-latest
version: stable-20210809
- os: macos-latest
version: stable-20210809
- os: windows-2019
version: stable-20210809
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-2019
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-2019
version: latest
- os: windows-2022
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-2019
version: nightly-latest
- os: windows-2022
version: nightly-latest
name: "Upload-sarif: 'ref' and 'sha' from inputs"
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Prepare test
id: prepare-test
uses: ./.github/prepare-test
with:
version: ${{ matrix.version }}
- uses: ./../action/init
with:
tools: ${{ steps.prepare-test.outputs.tools-url }}
languages: cpp,csharp,java,javascript,python
config-file: ${{ github.repository }}/tests/multi-language-repo/.github/codeql/custom-queries.yml@${{
github.sha }}
- name: Build code
shell: bash
run: ./build.sh
- uses: ./../action/analyze
with:
ref: refs/heads/main
sha: 5e235361806c361d4d3f8859e3c897658025a9a2
upload: false
env:
TEST_MODE: true
- uses: ./../action/upload-sarif
with:
ref: refs/heads/main
sha: 5e235361806c361d4d3f8859e3c897658025a9a2
env:
TEST_MODE: true
env:
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true

146
.github/workflows/__with-checkout-path.yml generated vendored Normal file
View File

@@ -0,0 +1,146 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# to regenerate this file.
name: PR Check - Use a custom `checkout_path`
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GO111MODULE: auto
on:
push:
branches:
- main
- releases/v1
- releases/v2
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch: {}
jobs:
with-checkout-path:
strategy:
matrix:
include:
- os: ubuntu-latest
version: stable-20210308
- os: macos-latest
version: stable-20210308
- os: windows-2019
version: stable-20210308
- os: ubuntu-latest
version: stable-20210319
- os: macos-latest
version: stable-20210319
- os: windows-2019
version: stable-20210319
- os: ubuntu-latest
version: stable-20210809
- os: macos-latest
version: stable-20210809
- os: windows-2019
version: stable-20210809
- os: ubuntu-latest
version: cached
- os: macos-latest
version: cached
- os: windows-2019
version: cached
- os: ubuntu-latest
version: latest
- os: macos-latest
version: latest
- os: windows-2019
version: latest
- os: windows-2022
version: latest
- os: ubuntu-latest
version: nightly-latest
- os: macos-latest
version: nightly-latest
- os: windows-2019
version: nightly-latest
- os: windows-2022
version: nightly-latest
name: Use a custom `checkout_path`
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Prepare test
id: prepare-test
uses: ./.github/prepare-test
with:
version: ${{ matrix.version }}
- uses: actions/checkout@v3
with:
ref: 474bbf07f9247ffe1856c6a0f94aeeb10e7afee6
path: x/y/z/some-path
- uses: ./../action/init
with:
tools: ${{ steps.prepare-test.outputs.tools-url }}
# it's enough to test one compiled language and one interpreted language
languages: csharp,javascript
source-path: x/y/z/some-path/tests/multi-language-repo
debug: true
- name: Build code (non-windows)
shell: bash
if: ${{ runner.os != 'Windows' }}
run: |
$CODEQL_RUNNER x/y/z/some-path/tests/multi-language-repo/build.sh
- name: Build code (windows)
shell: bash
if: ${{ runner.os == 'Windows' }}
run: |
x/y/z/some-path/tests/multi-language-repo/build.sh
- uses: ./../action/analyze
with:
checkout_path: x/y/z/some-path/tests/multi-language-repo
ref: v1.1.0
sha: 474bbf07f9247ffe1856c6a0f94aeeb10e7afee6
upload: false
env:
TEST_MODE: true
- uses: ./../action/upload-sarif
with:
ref: v1.1.0
sha: 474bbf07f9247ffe1856c6a0f94aeeb10e7afee6
checkout_path: x/y/z/some-path/tests/multi-language-repo
env:
TEST_MODE: true
- name: Verify SARIF after upload
shell: bash
run: |
EXPECTED_COMMIT_OID="474bbf07f9247ffe1856c6a0f94aeeb10e7afee6"
EXPECTED_REF="v1.1.0"
EXPECTED_CHECKOUT_URI_SUFFIX="/x/y/z/some-path/tests/multi-language-repo"
ACTUAL_COMMIT_OID="$(cat "$RUNNER_TEMP/payload.json" | jq -r .commit_oid)"
ACTUAL_REF="$(cat "$RUNNER_TEMP/payload.json" | jq -r .ref)"
ACTUAL_CHECKOUT_URI="$(cat "$RUNNER_TEMP/payload.json" | jq -r .checkout_uri)"
if [[ "$EXPECTED_COMMIT_OID" != "$ACTUAL_COMMIT_OID" ]]; then
echo "::error Invalid commit oid. Expected: $EXPECTED_COMMIT_OID Actual: $ACTUAL_COMMIT_OID"
echo "$RUNNER_TEMP/payload.json"
exit 1
fi
if [[ "$EXPECTED_REF" != "$ACTUAL_REF" ]]; then
echo "::error Invalid ref. Expected: '$EXPECTED_REF' Actual: '$ACTUAL_REF'"
echo "$RUNNER_TEMP/payload.json"
exit 1
fi
if [[ "$ACTUAL_CHECKOUT_URI" != *$EXPECTED_CHECKOUT_URI_SUFFIX ]]; then
echo "::error Invalid checkout URI suffix. Expected suffix: $EXPECTED_CHECKOUT_URI_SUFFIX Actual uri: $ACTUAL_CHECKOUT_URI"
echo "$RUNNER_TEMP/payload.json"
exit 1
fi
env:
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true

View File

@@ -15,11 +15,11 @@ jobs:
steps: steps:
- name: Checkout CodeQL Action - name: Checkout CodeQL Action
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Check Expected Release Files - name: Check Expected Release Files
run: | run: |
bundle_version="$(cat "./src/defaults.json" | jq -r ".bundleVersion")" bundle_version="$(cat "./src/defaults.json" | jq -r ".bundleVersion")"
set -x set -x
for expected_file in "codeql-bundle.tar.gz" "codeql-bundle-linux64.tar.gz" "codeql-bundle-osx64.tar.gz" "codeql-bundle-win64.tar.gz" "codeql-runner-linux" "codeql-runner-macos" "codeql-runner-win.exe"; do for expected_file in "codeql-bundle.tar.gz" "codeql-bundle-linux64.tar.gz" "codeql-bundle-osx64.tar.gz" "codeql-bundle-win64.tar.gz"; do
curl --location --fail --head --request GET "https://github.com/github/codeql-action/releases/download/$bundle_version/$expected_file" > /dev/null curl --location --fail --head --request GET "https://github.com/github/codeql-action/releases/download/$bundle_version/$expected_file" > /dev/null
done done

View File

@@ -0,0 +1,31 @@
# Checks for any conflict markers created by git. This check is primarily intended to validate that
# any merge conflicts in the v2 -> v1 backport PR are fixed before the PR is merged.
name: Check for conflicts
on:
pull_request:
branches: [main, releases/v1, releases/v2]
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
# by other workflows.
types: [opened, synchronize, reopened, ready_for_review]
jobs:
check-for-conflicts:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check for conflicts
run: |
# Use `|| true` since grep returns exit code 1 if there are no matches, and we don't want
# this to fail the workflow.
FILES_WITH_CONFLICTS=$(grep --extended-regexp --ignore-case --line-number --recursive \
'^(<<<<<<<|>>>>>>>)' . || true)
if [[ "${FILES_WITH_CONFLICTS}" ]]; then
echo "Fail: Found merge conflict markers in the following files:"
echo ""
echo "${FILES_WITH_CONFLICTS}"
exit 1
else
echo "Success: Found no merge conflict markers."
fi

View File

@@ -2,9 +2,9 @@ name: "CodeQL action"
on: on:
push: push:
branches: [main, v1] branches: [main, releases/v1, releases/v2]
pull_request: pull_request:
branches: [main, v1] branches: [main, releases/v1, releases/v2]
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened # Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
# by other workflows. # by other workflows.
types: [opened, synchronize, reopened, ready_for_review] types: [opened, synchronize, reopened, ready_for_review]
@@ -20,7 +20,7 @@ jobs:
security-events: write security-events: write
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Init with default CodeQL bundle from the VM image - name: Init with default CodeQL bundle from the VM image
id: init-default id: init-default
uses: ./init uses: ./init
@@ -75,7 +75,7 @@ jobs:
security-events: write security-events: write
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: ./init - uses: ./init
id: init id: init
with: with:

View File

@@ -0,0 +1,49 @@
name: Expected queries runs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
on:
push:
branches:
- main
- releases/v1
- releases/v2
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
workflow_dispatch: {}
jobs:
expected-queries:
name: Expected Queries Tests
timeout-minutes: 45
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Prepare test
id: prepare-test
uses: ./.github/prepare-test
with:
version: latest
- uses: ./../action/init
with:
languages: javascript
tools: ${{ steps.prepare-test.outputs.tools-url }}
- uses: ./../action/analyze
with:
output: ${{ runner.temp }}/results
upload-database: false
upload: false
env:
TEST_MODE: true
- name: Check Sarif
uses: ./../action/.github/check-sarif
with:
sarif-file: ${{ runner.temp }}/results/javascript.sarif
queries-run: js/incomplete-hostname-regexp,js/path-injection
queries-not-run: foo,bar

View File

@@ -1,7 +1,8 @@
# This workflow runs after a release of the action. # This workflow runs after a release of the action. For v2 releases, it merges any changes from the
# It merges any changes from the release back into the # release back into the main branch. Typically, this is just a single commit that updates the
# main branch. Typically, this is just a single commit # changelog. For v2 and v1 releases, it then (a) tags the merge commit on the release branch that
# that updates the changelog. # represents the new release with an `vx.y.z` tag and (b) updates the `vx` tag to refer to this
# commit.
name: Tag release and merge back name: Tag release and merge back
on: on:
@@ -14,7 +15,8 @@ on:
push: push:
branches: branches:
- v1 - releases/v1
- releases/v2
jobs: jobs:
merge-back: merge-back:
@@ -25,13 +27,16 @@ jobs:
HEAD_BRANCH: "${{ github.head_ref || github.ref }}" HEAD_BRANCH: "${{ github.head_ref || github.ref }}"
steps: steps:
- name: Dump GitHub Event context - name: Dump environment
env: run: env
GITHUB_EVENT_CONTEXT: "${{ toJson(github.event) }}"
run: echo "$GITHUB_EVENT_CONTEXT"
- uses: actions/checkout@v2 - name: Dump GitHub context
- uses: actions/setup-node@v2 env:
GITHUB_CONTEXT: '${{ toJson(github) }}'
run: echo "${GITHUB_CONTEXT}"
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Update git config - name: Update git config
run: | run: |
@@ -42,25 +47,25 @@ jobs:
id: getVersion id: getVersion
run: | run: |
VERSION="v$(jq '.version' -r 'package.json')" VERSION="v$(jq '.version' -r 'package.json')"
SHORT_SHA="${GITHUB_SHA:0:8}" echo "::set-output name=version::${VERSION}"
echo "::set-output name=version::$VERSION" short_sha="${GITHUB_SHA:0:8}"
NEW_BRANCH="mergeback/${VERSION}-to-${BASE_BRANCH}-${SHORT_SHA}" NEW_BRANCH="mergeback/${VERSION}-to-${BASE_BRANCH}-${short_sha}"
echo "::set-output name=newBranch::$NEW_BRANCH" echo "::set-output name=newBranch::${NEW_BRANCH}"
- name: Dump branches - name: Dump branches
env: env:
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}" NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
run: | run: |
echo "BASE_BRANCH $BASE_BRANCH" echo "BASE_BRANCH ${BASE_BRANCH}"
echo "HEAD_BRANCH $HEAD_BRANCH" echo "HEAD_BRANCH ${HEAD_BRANCH}"
echo "NEW_BRANCH $NEW_BRANCH" echo "NEW_BRANCH ${NEW_BRANCH}"
- name: Create mergeback branch - name: Create mergeback branch
env: env:
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}" NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
run: | run: |
git checkout -b "$NEW_BRANCH" git checkout -b "${NEW_BRANCH}"
- name: Check for tag - name: Check for tag
id: check id: check
@@ -68,13 +73,13 @@ jobs:
VERSION: "${{ steps.getVersion.outputs.version }}" VERSION: "${{ steps.getVersion.outputs.version }}"
run: | run: |
set +e # don't fail on an errored command set +e # don't fail on an errored command
git ls-remote --tags origin | grep "$VERSION" git ls-remote --tags origin | grep "${VERSION}"
EXISTS="$?" exists="$?"
if [ "$EXISTS" -eq 0 ]; then if [ "${exists}" -eq 0 ]; then
echo "Tag $TAG exists. Not going to re-release." echo "Tag ${VERSION} exists. Not going to re-release."
echo "::set-output name=exists::true" echo "::set-output name=exists::true"
else else
echo "Tag $TAG does not exist yet." echo "Tag ${VERSION} does not exist yet."
fi fi
# we didn't tag the release during the update-release-branch workflow because the # we didn't tag the release during the update-release-branch workflow because the
@@ -85,35 +90,48 @@ jobs:
env: env:
VERSION: ${{ steps.getVersion.outputs.version }} VERSION: ${{ steps.getVersion.outputs.version }}
run: | run: |
git tag -a "$VERSION" -m "$VERSION" # Unshallow the repo in order to allow pushes
git fetch --unshallow # unshallow the repo in order to allow pushes git fetch --unshallow
git push origin --follow-tags "$VERSION" # Create the `vx.y.z` tag
git tag --annotate "${VERSION}" --message "${VERSION}"
# Update the `vx` tag
major_version_tag=$(cut -d '.' -f1 <<< "${VERSION}")
# Use `--force` to overwrite the major version tag
git tag --annotate "${major_version_tag}" --message "${major_version_tag}" --force
# Push the tags, using:
# - `--atomic` to make sure we either update both tags or neither (an intermediate state,
# e.g. where we update the v2.x.y tag on the remote but not the v2 tag, could result in
# unwanted Dependabot updates, e.g. from v2 to v2.x.y)
# - `--force` since we're overwriting the `vx` tag
git push origin --atomic --force refs/tags/"${VERSION}" refs/tags/"${major_version_tag}"
- name: Create mergeback branch - name: Create mergeback branch
if: steps.check.outputs.exists != 'true' if: steps.check.outputs.exists != 'true' && contains(github.ref, 'releases/v2')
env: env:
VERSION: "${{ steps.getVersion.outputs.version }}" VERSION: "${{ steps.getVersion.outputs.version }}"
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}" NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: | run: |
set -exu set -exu
PR_TITLE="Mergeback $VERSION $HEAD_BRANCH into $BASE_BRANCH" pr_title="Mergeback ${VERSION} ${HEAD_BRANCH} into ${BASE_BRANCH}"
PR_BODY="Updates version and changelog." pr_body="Updates version and changelog."
# Update the version number ready for the next release
npm version patch --no-git-tag-version
# Update the changelog # Update the changelog
perl -i -pe 's/^/## \[UNRELEASED\]\n\nNo user facing changes.\n\n/ if($.==3)' CHANGELOG.md perl -i -pe 's/^/## \[UNRELEASED\]\n\nNo user facing changes.\n\n/ if($.==3)' CHANGELOG.md
git add . git add .
git commit -m "Update changelog and version after $VERSION" git commit -m "Update changelog and version after ${VERSION}"
npm version patch
git push origin "$NEW_BRANCH" git push origin "${NEW_BRANCH}"
# PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft # PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft
# so that a maintainer can take the PR out of draft, thereby triggering the PR checks. # so that a maintainer can take the PR out of draft, thereby triggering the PR checks.
gh pr create \ gh pr create \
--head "$NEW_BRANCH" \ --head "${NEW_BRANCH}" \
--base "$BASE_BRANCH" \ --base "${BASE_BRANCH}" \
--title "$PR_TITLE" \ --title "${pr_title}" \
--label "Update dependencies" \ --label "Update dependencies" \
--body "$PR_BODY" \ --body "${pr_body}" \
--draft --draft

View File

@@ -2,7 +2,7 @@ name: PR Checks (Basic Checks and Runner)
on: on:
push: push:
branches: [main, v1] branches: [main, releases/v1, releases/v2]
pull_request: pull_request:
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened # Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
# by other workflows. # by other workflows.
@@ -13,37 +13,69 @@ jobs:
lint-js: lint-js:
name: Lint name: Lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 45
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Run Lint - name: Run Lint
run: npm run-script lint run: npm run-script lint
check-js: check-js:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: true
matrix:
node-types-version: [12.12, current]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Update version of @types/node
if: matrix.node-types-version != 'current'
env:
NODE_TYPES_VERSION: ${{ matrix.node-types-version }}
run: |
# Export `NODE_TYPES_VERSION` so it's available to jq
export NODE_TYPES_VERSION="${NODE_TYPES_VERSION}"
contents=$(jq '.devDependencies."@types/node" = env.NODE_TYPES_VERSION' package.json)
echo "${contents}" > package.json
# Usually we run `npm install` on macOS to ensure that we pick up macOS-only dependencies.
# However we're not checking in the updated lockfile here, so it's fine to run
# `npm install` on Linux.
npm install
if [ ! -z "$(git status --porcelain)" ]; then
git config --global user.email "github-actions@github.com"
git config --global user.name "github-actions[bot]"
# The period in `git add --all .` ensures that we stage deleted files too.
git add --all .
git commit -m "Use @types/node=${NODE_TYPES_VERSION}"
fi
- name: Check generated JS - name: Check generated JS
run: .github/workflows/script/check-js.sh run: .github/workflows/script/check-js.sh
check-node-modules: check-node-modules:
name: Check modules up to date name: Check modules up to date
runs-on: macos-latest runs-on: macos-latest
timeout-minutes: 45
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Check node modules up to date - name: Check node modules up to date
run: .github/workflows/script/check-node-modules.sh run: .github/workflows/script/check-node-modules.sh
verify-pr-checks: verify-pr-checks:
name: Verify PR checks up to date name: Verify PR checks up to date
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 45
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v3
with: with:
python-version: 3.8 python-version: 3.8
- name: Install dependencies - name: Install dependencies
@@ -58,21 +90,27 @@ jobs:
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
timeout-minutes: 45
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: npm run-script test - name: npm test
run: npm run-script test run: |
# Run any commands referenced in package.json using Bash, otherwise
# we won't be able to find them on Windows.
npm config set script-shell bash
npm test
runner-analyze-javascript-ubuntu: runner-analyze-javascript-ubuntu:
name: Runner ubuntu JS analyze name: Runner ubuntu JS analyze
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
timeout-minutes: 45
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Build runner - name: Build runner
run: | run: |
@@ -97,10 +135,11 @@ jobs:
runner-analyze-javascript-windows: runner-analyze-javascript-windows:
name: Runner windows JS analyze name: Runner windows JS analyze
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
timeout-minutes: 45
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Build runner - name: Build runner
run: | run: |
@@ -121,10 +160,11 @@ jobs:
runner-analyze-javascript-macos: runner-analyze-javascript-macos:
name: Runner macos JS analyze name: Runner macos JS analyze
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
timeout-minutes: 45
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Build runner - name: Build runner
run: | run: |
@@ -145,10 +185,11 @@ jobs:
runner-analyze-csharp-ubuntu: runner-analyze-csharp-ubuntu:
name: Runner ubuntu C# analyze name: Runner ubuntu C# analyze
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
timeout-minutes: 45
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Move codeql-action - name: Move codeql-action
shell: bash shell: bash
@@ -182,10 +223,13 @@ jobs:
runner-analyze-csharp-windows: runner-analyze-csharp-windows:
name: Runner windows C# analyze name: Runner windows C# analyze
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
runs-on: windows-latest # Build tracing currently does not support Windows 2022, so use `windows-2019` instead of
# `windows-latest`.
timeout-minutes: 45
runs-on: windows-2019
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Move codeql-action - name: Move codeql-action
shell: bash shell: bash
@@ -213,7 +257,7 @@ jobs:
& $Env:CODEQL_RUNNER dotnet build /p:UseSharedCompilation=false & $Env:CODEQL_RUNNER dotnet build /p:UseSharedCompilation=false
- name: Upload tracer logs - name: Upload tracer logs
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: tracer-logs name: tracer-logs
path: ./codeql-runner/compound-build-tracer.log path: ./codeql-runner/compound-build-tracer.log
@@ -226,11 +270,12 @@ jobs:
runner-analyze-csharp-macos: runner-analyze-csharp-macos:
name: Runner macos C# analyze name: Runner macos C# analyze
timeout-minutes: 45
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Move codeql-action - name: Move codeql-action
shell: bash shell: bash
@@ -264,11 +309,12 @@ jobs:
runner-analyze-csharp-autobuild-ubuntu: runner-analyze-csharp-autobuild-ubuntu:
name: Runner ubuntu autobuild C# analyze name: Runner ubuntu autobuild C# analyze
timeout-minutes: 45
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Move codeql-action - name: Move codeql-action
shell: bash shell: bash
@@ -299,12 +345,15 @@ jobs:
TEST_MODE: true TEST_MODE: true
runner-analyze-csharp-autobuild-windows: runner-analyze-csharp-autobuild-windows:
timeout-minutes: 45
name: Runner windows autobuild C# analyze name: Runner windows autobuild C# analyze
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
runs-on: windows-latest # Build tracing currently does not support Windows 2022, so use `windows-2019` instead of
# `windows-latest`.
runs-on: windows-2019
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Move codeql-action - name: Move codeql-action
shell: bash shell: bash
@@ -339,9 +388,10 @@ jobs:
name: Runner macos autobuild C# analyze name: Runner macos autobuild C# analyze
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
runs-on: macos-latest runs-on: macos-latest
timeout-minutes: 45
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Move codeql-action - name: Move codeql-action
shell: bash shell: bash
@@ -376,11 +426,12 @@ jobs:
name: Runner upload sarif name: Runner upload sarif
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 45
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id }} if: ${{ github.event_name != 'pull_request' || github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id }}
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Build runner - name: Build runner
run: | run: |
@@ -398,9 +449,10 @@ jobs:
name: Runner ubuntu extractor RAM and threads options name: Runner ubuntu extractor RAM and threads options
needs: [check-js, check-node-modules] needs: [check-js, check-node-modules]
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 45
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Build runner - name: Build runner
run: | run: |

View File

@@ -2,7 +2,7 @@ name: Test Python Package Installation on Linux and Mac
on: on:
push: push:
branches: [main, v1] branches: [main, releases/v1, releases/v2]
pull_request: pull_request:
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened # Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
# by other workflows. # by other workflows.
@@ -10,6 +10,7 @@ on:
jobs: jobs:
test-setup-python-scripts: test-setup-python-scripts:
timeout-minutes: 45
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
fail-fast: false fail-fast: false
@@ -17,6 +18,11 @@ jobs:
os: [ubuntu-latest, macos-latest] os: [ubuntu-latest, macos-latest]
python_deps_type: [pipenv, poetry, requirements, setup_py] python_deps_type: [pipenv, poetry, requirements, setup_py]
python_version: [2, 3] python_version: [2, 3]
exclude:
# Python2 and poetry are not supported. See https://github.com/actions/setup-python/issues/374
- python_version: 2
python_deps_type: poetry
env: env:
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }} PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
@@ -24,7 +30,7 @@ jobs:
steps: steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Initialize CodeQL - name: Initialize CodeQL
uses: ./init uses: ./init
@@ -70,7 +76,7 @@ jobs:
steps: steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Initialize CodeQL - name: Initialize CodeQL
uses: ./init uses: ./init
@@ -114,6 +120,10 @@ jobs:
matrix: matrix:
python_deps_type: [pipenv, poetry, requirements, setup_py] python_deps_type: [pipenv, poetry, requirements, setup_py]
python_version: [2, 3] python_version: [2, 3]
exclude:
# Python2 and poetry are not supported. See https://github.com/actions/setup-python/issues/374
- python_version: 2
python_deps_type: poetry
env: env:
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }} PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
@@ -121,11 +131,11 @@ jobs:
steps: steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- uses: actions/setup-python@v2 - uses: actions/setup-python@v3
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python_version }}
- name: Initialize CodeQL - name: Initialize CodeQL
uses: ./init uses: ./init

View File

@@ -1,54 +0,0 @@
name: Release runner
on:
workflow_dispatch:
inputs:
bundle-tag:
description: 'Tag of the bundle release (e.g., "codeql-bundle-20200826")'
required: false
jobs:
release-runner:
runs-on: ubuntu-latest
env:
RELEASE_TAG: "${{ github.event.inputs.bundle-tag }}"
strategy:
matrix:
extension: ["linux", "macos", "win.exe"]
steps:
- uses: actions/checkout@v2
- name: Build runner
run: |
cd runner
npm install
npm run build-runner
- uses: actions/upload-artifact@v2
with:
name: codeql-runner-${{matrix.extension}}
path: runner/dist/codeql-runner-${{matrix.extension}}
- name: Resolve Upload URL for the release
if: ${{ github.event.inputs.bundle-tag != null }}
id: save_url
run: |
UPLOAD_URL=$(curl -sS \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_TAG}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq .upload_url | sed s/\"//g)
echo ${UPLOAD_URL}
echo "::set-output name=upload_url::${UPLOAD_URL}"
- name: Upload Platform Package
if: ${{ github.event.inputs.bundle-tag != null }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.save_url.outputs.upload_url }}
asset_path: runner/dist/codeql-runner-${{matrix.extension}}
asset_name: codeql-runner-${{matrix.extension}}
asset_content_type: application/octet-stream

View File

@@ -14,8 +14,8 @@ npm run-script build
# Check that repo is still clean # Check that repo is still clean
if [ ! -z "$(git status --porcelain)" ]; then if [ ! -z "$(git status --porcelain)" ]; then
# If we get a fail here then the PR needs attention # If we get a fail here then the PR needs attention
>&2 echo "Failed: JavaScript files are not up to date. Run 'npm run-script build' to update" >&2 echo "Failed: JavaScript files are not up to date. Run 'rm -rf lib && npm run-script build' to update"
git status git status
exit 1 exit 1
fi fi
echo "Success: JavaScript files are up to date" echo "Success: JavaScript files are up to date"

View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Update the required checks based on the current branch.
# Typically, this will be main.
if ! gh auth status 2>/dev/null; then
gh auth status
echo "Failed: Not authorized. This script requires admin access to github/codeql-action through the gh CLI."
exit 1
fi
if [ "$#" -eq 1 ]; then
# If we were passed an argument, use that as the SHA
GITHUB_SHA="$0"
elif [ "$#" -gt 1 ]; then
echo "Usage: $0 [SHA]"
echo "Update the required checks based on the SHA, or main."
exit 1
elif [ -z "$GITHUB_SHA" ]; then
# If we don't have a SHA, use main
GITHUB_SHA="$(git rev-parse main)"
fi
echo "Getting checks for $GITHUB_SHA"
# Ignore any checks with "https://", CodeQL, LGTM, and Update checks.
CHECKS="$(gh api repos/github/codeql-action/commits/"${GITHUB_SHA}"/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") or contains("update") | not)] | unique | sort')"
echo "$CHECKS" | jq
echo "{\"contexts\": ${CHECKS}}" > checks.json
for BRANCH in main releases/v2 releases/v1; do
echo "Updating $BRANCH"
gh api --silent -X "PATCH" "repos/github/codeql-action/branches/$BRANCH/protection/required_status_checks" --input checks.json
done
rm checks.json

View File

@@ -1,73 +0,0 @@
#
# Split the CodeQL Bundle into platform bundles
#
# Instructions:
# 1. Upload the new codeql-bundle (codeql-bundle.tar.gz) as an asset of the
# release (codeql-bundle-20200826)
# 2. Take note of the CLI Release used by the bundle (e.g., v2.2.5)
# 3. Manually launch this workflow file (via the Actions UI) specifying
# - The CLI Release (e.g., v2.2.5)
# - The release tag (e.g., codeql-bundle-20200826)
# 4. If everything succeeds you should see 3 new assets.
#
name: Split Bundle
on:
workflow_dispatch:
inputs:
cli-release:
description: 'CodeQL CLI Release (e.g., "v2.2.5")'
required: true
bundle-tag:
description: 'Tag of the bundle release (e.g., "codeql-bundle-20200826")'
required: true
jobs:
build:
runs-on: ubuntu-latest
env:
CLI_RELEASE: "${{ github.event.inputs.cli-release }}"
RELEASE_TAG: "${{ github.event.inputs.bundle-tag }}"
strategy:
fail-fast: false
matrix:
platform: ["linux64", "osx64", "win64"]
steps:
- name: Resolve Upload URL for the release
id: save_url
run: |
UPLOAD_URL=$(curl -sS \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_TAG}" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq .upload_url | sed s/\"//g)
echo ${UPLOAD_URL}
echo "::set-output name=upload_url::${UPLOAD_URL}"
- name: Download CodeQL CLI and Bundle
run: |
wget --no-verbose "https://github.com/${GITHUB_REPOSITORY}/releases/download/${RELEASE_TAG}/codeql-bundle.tar.gz"
wget --no-verbose "https://github.com/github/codeql-cli-binaries/releases/download/${CLI_RELEASE}/codeql-${{matrix.platform}}.zip"
- name: Create Platform Package
# Replace the codeql-binaries with the platform specific ones
run: |
gunzip codeql-bundle.tar.gz
tar -f codeql-bundle.tar --delete codeql
unzip -q codeql-${{matrix.platform}}.zip
tar -f codeql-bundle.tar --append codeql
gzip codeql-bundle.tar
mv codeql-bundle.tar.gz codeql-bundle-${{matrix.platform}}.tar.gz
du -sh codeql-bundle-${{matrix.platform}}.tar.gz
- name: Upload Platform Package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.save_url.outputs.upload_url }}
asset_path: ./codeql-bundle-${{matrix.platform}}.tar.gz
asset_name: codeql-bundle-${{matrix.platform}}.tar.gz
asset_content_type: application/tar+gzip

View File

@@ -6,11 +6,12 @@ on:
jobs: jobs:
update: update:
name: Update dependencies name: Update dependencies
timeout-minutes: 45
runs-on: macos-latest runs-on: macos-latest
if: contains(github.event.pull_request.labels.*.name, 'Update dependencies') && (github.event.pull_request.head.repo.full_name == 'github/codeql-action') if: contains(github.event.pull_request.labels.*.name, 'Update dependencies') && (github.event.pull_request.head.repo.full_name == 'github/codeql-action')
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Remove PR label - name: Remove PR label
env: env:

View File

@@ -1,24 +1,35 @@
name: Update release branch name: Update release branch
on: on:
repository_dispatch: # You can trigger this workflow via workflow dispatch to start a release.
# Example of how to trigger this: # This will open a PR to update the v2 release branch.
# curl -H "Authorization: Bearer <token>" -X POST https://api.github.com/repos/github/codeql-action/dispatches -d '{"event_type":"update-release-branch"}'
# Replace <token> with a personal access token from this page: https://github.com/settings/tokens
types: [update-release-branch]
workflow_dispatch: workflow_dispatch:
# When the v2 release is complete, this workflow will open a PR to update the v1 release branch.
push:
branches:
- releases/v2
jobs: jobs:
update: update:
timeout-minutes: 45
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.repository == 'github/codeql-action' }} if: github.repository == 'github/codeql-action'
steps: steps:
- uses: actions/checkout@v2 - name: Dump environment
run: env
- name: Dump GitHub context
env:
GITHUB_CONTEXT: '${{ toJson(github) }}'
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v3
with: with:
# Need full history so we calculate diffs # Need full history so we calculate diffs
fetch-depth: 0 fetch-depth: 0
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v3
with: with:
python-version: 3.8 python-version: 3.8
@@ -32,5 +43,20 @@ jobs:
git config --global user.email "github-actions@github.com" git config --global user.email "github-actions@github.com"
git config --global user.name "github-actions[bot]" git config --global user.name "github-actions[bot]"
- name: Update release branch - name: Update v2 release branch
run: python .github/update-release-branch.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} if: github.event_name == 'workflow_dispatch'
run: |
python .github/update-release-branch.py \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--repository-nwo ${{ github.repository }} \
--mode v2-release \
--conductor ${GITHUB_ACTOR}
- name: Update v1 release branch
if: github.event_name == 'push'
run: |
python .github/update-release-branch.py \
--github-token ${{ secrets.GITHUB_TOKEN }} \
--repository-nwo ${{ github.repository }} \
--mode v1-release \
--conductor ${GITHUB_ACTOR}

View File

@@ -6,18 +6,20 @@ on:
jobs: jobs:
update-supported-enterprise-server-versions: update-supported-enterprise-server-versions:
name: Update Supported Enterprise Server Versions
timeout-minutes: 45
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.repository == 'github/codeql-action' }} if: ${{ github.repository == 'github/codeql-action' }}
steps: steps:
- name: Setup Python - name: Setup Python
uses: actions/setup-python@v2 uses: actions/setup-python@v3
with: with:
python-version: "3.7" python-version: "3.7"
- name: Checkout CodeQL Action - name: Checkout CodeQL Action
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Checkout Enterprise Releases - name: Checkout Enterprise Releases
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
repository: github/enterprise-releases repository: github/enterprise-releases
ssh-key: ${{ secrets.ENTERPRISE_RELEASES_SSH_KEY }} ssh-key: ${{ secrets.ENTERPRISE_RELEASES_SSH_KEY }}
@@ -40,5 +42,6 @@ jobs:
body: "" body: ""
author: GitHub <noreply@github.com> author: GitHub <noreply@github.com>
branch: update-supported-enterprise-server-versions branch: update-supported-enterprise-server-versions
draft: true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
/runner/dist/ /runner/dist/
/runner/node_modules/ /runner/node_modules/
# Ignore for example failing-tests.json from AVA
node_modules/.cache

View File

@@ -1,9 +1,117 @@
# CodeQL Action and CodeQL Runner Changelog # CodeQL Action Changelog
## [UNRELEASED] ## 1.1.16 - 13 Jul 2022
- The `analyze` and `upload-sarif` actions will now wait up to 2 minutes for processing to complete after they have uploaded the results so they can report any processing errors that occurred. This behavior can be disabled by setting the `wait-for-processing` action input to `"false"`. - You can now quickly debug a job that uses the CodeQL Action by re-running the job from the GitHub UI and selecting the "Enable debug logging" option. [#1132](https://github.com/github/codeql-action/pull/1132)
- You can now see diagnostic messages produced by the analysis in the logs of the `analyze` Action by enabling debug mode. To enable debug mode, pass `debug: true` to the `init` Action, or [enable step debug logging](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging). This feature is available for CodeQL CLI version 2.10.0 and later. [#1133](https://github.com/github/codeql-action/pull/1133)
## 1.1.15 - 28 Jun 2022
- CodeQL query packs listed in the `packs` configuration field will be skipped if their target language is not being analyzed in the current Actions job. Previously, this would throw an error. [#1116](https://github.com/github/codeql-action/pull/1116)
- The combination of python2 and poetry is no longer supported. See https://github.com/actions/setup-python/issues/374 for more details. [#1124](https://github.com/github/codeql-action/pull/1124)
- Update default CodeQL bundle version to 2.10.0. [#1123](https://github.com/github/codeql-action/pull/1123)
## 1.1.14 - 22 Jun 2022
No user facing changes.
## 1.1.13 - 21 Jun 2022
- Update default CodeQL bundle version to 2.9.4. [#1100](https://github.com/github/codeql-action/pull/1100)
## 1.1.12 - 01 Jun 2022
- Update default CodeQL bundle version to 2.9.3. [#1084](https://github.com/github/codeql-action/pull/1084)
## 1.1.11 - 17 May 2022
- Update default CodeQL bundle version to 2.9.2. [#1074](https://github.com/github/codeql-action/pull/1074)
## 1.1.10 - 10 May 2022
- Update default CodeQL bundle version to 2.9.1. [#1056](https://github.com/github/codeql-action/pull/1056)
- When `wait-for-processing` is enabled, the workflow will now fail if there were any errors that occurred during processing of the analysis results.
## 1.1.9 - 27 Apr 2022
- Add `working-directory` input to the `autobuild` action. [#1024](https://github.com/github/codeql-action/pull/1024)
- The `analyze` and `upload-sarif` actions will now wait up to 2 minutes for processing to complete after they have uploaded the results so they can report any processing errors that occurred. This behavior can be disabled by setting the `wait-for-processing` action input to `"false"`. [#1007](https://github.com/github/codeql-action/pull/1007)
- Update default CodeQL bundle version to 2.9.0.
- Fix a bug where [status reporting fails on Windows](https://github.com/github/codeql-action/issues/1041). [#1042](https://github.com/github/codeql-action/pull/1042)
## 1.1.8 - 08 Apr 2022
- Update default CodeQL bundle version to 2.8.5. [#1014](https://github.com/github/codeql-action/pull/1014)
- Fix error where the init action would fail due to a GitHub API request that was taking too long to complete [#1025](https://github.com/github/codeql-action/pull/1025)
## 1.1.7 - 05 Apr 2022
- A bug where additional queries specified in the workflow file would sometimes not be respected has been fixed. [#1018](https://github.com/github/codeql-action/pull/1018)
## 1.1.6 - 30 Mar 2022
- Update default CodeQL bundle version to 2.8.4. [#990](https://github.com/github/codeql-action/pull/990)
- Fix a bug where an invalid `commit_oid` was being sent to code scanning when a custom checkout path was being used. [#956](https://github.com/github/codeql-action/pull/956)
## 1.1.5 - 15 Mar 2022
- Update default CodeQL bundle version to 2.8.3.
- The CodeQL runner is now deprecated and no longer being released. For more information, see [CodeQL runner deprecation](https://github.blog/changelog/2021-09-21-codeql-runner-deprecation/).
- Fix two bugs that cause action failures with GHES 3.3 or earlier. [#978](https://github.com/github/codeql-action/pull/978)
- Fix `not a permitted key` invalid requests with GHES 3.1 or earlier
- Fix `RUNNER_ARCH environment variable must be set` errors with GHES 3.3 or earlier
## 1.1.4 - 07 Mar 2022
- Update default CodeQL bundle version to 2.8.2. [#950](https://github.com/github/codeql-action/pull/950)
- Fix a bug where old results can be uploaded if the languages in a repository change when using a non-ephemeral self-hosted runner. [#955](https://github.com/github/codeql-action/pull/955)
## 1.1.3 - 23 Feb 2022
- Fix a bug where the CLR traces can continue tracing even after tracing should be stopped. [#938](https://github.com/github/codeql-action/pull/938)
## 1.1.2 - 17 Feb 2022
- Due to potential issues for GHES 3.13.3 customers who are using recent versions of the CodeQL Action via GHES Connect, the CodeQL Action now uses Node.js v12 rather than Node.js v16. [#937](https://github.com/github/codeql-action/pull/937)
## 1.1.1 - 17 Feb 2022
- The CodeQL CLI versions up to and including version 2.4.4 are not compatible with the CodeQL Action 1.1.1 and later. The Action will emit an error if it detects that it is being used by an incompatible version of the CLI. [#931](https://github.com/github/codeql-action/pull/931)
- Update default CodeQL bundle version to 2.8.1. [#925](https://github.com/github/codeql-action/pull/925)
## 1.1.0 - 11 Feb 2022
- The CodeQL Action now uses Node.js v16. [#909](https://github.com/github/codeql-action/pull/909)
- Beware that the CodeQL build tracer in this release (and in all earlier releases) is incompatible with Windows 11 and Windows Server 2022. This incompatibility affects database extraction for compiled languages: cpp, csharp, go, and java. As a result, analyzing these languages with the `windows-latest` or `windows-2022` Actions virtual environments is currently unsupported. If you use any of these languages, please use the `windows-2019` Actions virtual environment or otherwise avoid these specific Windows versions until a new release fixes this incompatibility.
## 1.0.32 - 07 Feb 2022
- Add `sarif-id` as an output for the `upload-sarif` and `analyze` actions. [#889](https://github.com/github/codeql-action/pull/889)
- Add `ref` and `sha` inputs to the `analyze` action, which override the defaults provided by the GitHub Action context. [#889](https://github.com/github/codeql-action/pull/889)
- Update default CodeQL bundle version to 2.8.0. [#911](https://github.com/github/codeql-action/pull/911)
## 1.0.31 - 31 Jan 2022
- Remove `experimental` message when using custom CodeQL packages. [#888](https://github.com/github/codeql-action/pull/888)
- Add a better warning message stating that experimental features will be disabled if the workflow has been triggered by a pull request from a fork or the `security-events: write` permission is not present. [#882](https://github.com/github/codeql-action/pull/882)
## 1.0.30 - 24 Jan 2022
- Display a better error message when encountering a workflow that runs the `codeql-action/init` action multiple times. [#876](https://github.com/github/codeql-action/pull/876)
- Update default CodeQL bundle version to 2.7.6. [#877](https://github.com/github/codeql-action/pull/877)
## 1.0.29 - 21 Jan 2022
- The feature to wait for SARIF processing to complete after upload has been disabled by default due to a bug in its interaction with pull requests from forks.
## 1.0.28 - 18 Jan 2022
- Update default CodeQL bundle version to 2.7.5. [#866](https://github.com/github/codeql-action/pull/866)
- Fix a bug where SARIF files were failing upload due to an invalid test for unique categories. [#872](https://github.com/github/codeql-action/pull/872)
## 1.0.27 - 11 Jan 2022
- The `analyze` and `upload-sarif` actions will now wait up to 2 minutes for processing to complete after they have uploaded the results so they can report any processing errors that occurred. This behavior can be disabled by setting the `wait-for-processing` action input to `"false"`. [#855](https://github.com/github/codeql-action/pull/855)
## 1.0.26 - 10 Dec 2021 ## 1.0.26 - 10 Dec 2021

View File

@@ -1 +1,3 @@
**/* @github/codeql-action-reviewers **/* @github/codeql-action-reviewers
/python-setup/ @github/codeql-python @github/codeql-action-reviewers

View File

@@ -61,16 +61,30 @@ Here are a few things you can do that will increase the likelihood of your pull
## Releasing (write access required) ## Releasing (write access required)
1. The first step of releasing a new version of the `codeql-action` is running the "Update release branch" workflow. 1. The first step of releasing a new version of the `codeql-action` is running the "Update release branch" workflow.
This workflow goes through the pull requests that have been merged to `main` since the last release, creates a changelog, then opens a pull request to merge the changes since the last release into the `v1` release branch. This workflow goes through the pull requests that have been merged to `main` since the last release, creates a changelog, then opens a pull request to merge the changes since the last release into the `releases/v2` release branch.
A release is automatically started every Monday via a scheduled run of this workflow, however you can start a release manually by triggering a run via [workflow dispatch](https://github.com/github/codeql-action/actions/workflows/update-release-branch.yml). You can start a release by triggering this workflow via [workflow dispatch](https://github.com/github/codeql-action/actions/workflows/update-release-branch.yml).
1. The workflow run will open a pull request titled "Merge main into v1". Mark the pull request as [ready for review](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review) to trigger the PR checks. 1. The workflow run will open a pull request titled "Merge main into releases/v2". Mark the pull request as [ready for review](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review) to trigger the PR checks.
1. Review the checklist items in the pull request description. 1. Review the checklist items in the pull request description.
Once you've checked off all but the last of these, approve the PR and automerge it. Once you've checked off all but the last two of these, approve the PR and automerge it.
1. When the "Merge main into v1" pull request is merged into the `v1` branch, the "Tag release and merge back" workflow will create a mergeback PR. 1. When the "Merge main into releases/v2" pull request is merged into the `releases/v2` branch, the "Tag release and merge back" workflow will create a mergeback PR.
This mergeback incorporates the changelog updates into `main`, tags the release using the merge commit of the "Merge main into v1" pull request, and bumps the patch version of the CodeQL Action. This mergeback incorporates the changelog updates into `main`, tags the release using the merge commit of the "Merge main into releases/v2" pull request, and bumps the patch version of the CodeQL Action.
Approve the mergeback PR and automerge it. Once the mergeback has been merged into main, the release is complete. Approve the mergeback PR and automerge it.
1. When the "Merge main into releases/v2" pull request is merged into the `releases/v2` branch, the "Update release branch" workflow will create a "Merge releases/v2 into releases/v1" pull request to merge the changes since the last release into the `releases/v1` release branch.
This ensures we keep both the `releases/v1` and `releases/v2` release branches up to date and fully supported.
Review the checklist items in the pull request description.
Once you've checked off all the items, approve the PR and automerge it.
1. Once the mergeback has been merged to `main` and the "Merge releases/v2 into releases/v1" PR has been merged to `releases/v1`, the release is complete.
## Keeping the PR checks up to date (admin access required)
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. You can regenerate the checks automatically by running the [update-required-checks.sh](.github/workflows/script/update-required-checks.sh) script:
1. By default, this script retrieves the checks from the latest SHA on `main`, so make sure that your `main` branch is up to date.
2. Run the script. If there's a reason to, you can pass in a different SHA as a CLI argument.
3. After running, go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules for `main`, `v1`, and `v2` have been updated.
## Resources ## Resources

View File

@@ -52,11 +52,11 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v3
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages # Override language selection by uncommenting this and choosing your languages
# with: # with:
# languages: go, javascript, csharp, python, cpp, java # languages: go, javascript, csharp, python, cpp, java
@@ -64,10 +64,10 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below). # If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild - name: Autobuild
uses: github/codeql-action/autobuild@v1 uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell. # Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# ✏️ If the Autobuild fails above, remove it and uncomment the following # ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your # three lines and modify them (or add more) to build your code if your
@@ -78,14 +78,14 @@ jobs:
# make release # make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v2
``` ```
If you prefer to integrate this within an existing CI workflow, it should end up looking something like this: If you prefer to integrate this within an existing CI workflow, it should end up looking something like this:
```yaml ```yaml
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v2
with: with:
languages: go, javascript languages: go, javascript
@@ -95,7 +95,7 @@ If you prefer to integrate this within an existing CI workflow, it should end up
make release make release
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1 uses: github/codeql-action/analyze@v2
``` ```
### Configuration file ### Configuration file
@@ -103,7 +103,7 @@ If you prefer to integrate this within an existing CI workflow, it should end up
Use the `config-file` parameter of the `init` action to enable the configuration file. The value of `config-file` is the path to the configuration file you want to use. This example loads the configuration file `./.github/codeql/codeql-config.yml`. Use the `config-file` parameter of the `init` action to enable the configuration file. The value of `config-file` is the path to the configuration file you want to use. This example loads the configuration file `./.github/codeql/codeql-config.yml`.
```yaml ```yaml
- uses: github/codeql-action/init@v1 - uses: github/codeql-action/init@v2
with: with:
config-file: ./.github/codeql/codeql-config.yml config-file: ./.github/codeql/codeql-config.yml
``` ```
@@ -111,7 +111,7 @@ Use the `config-file` parameter of the `init` action to enable the configuration
The configuration file can be located in a different repository. This is useful if you want to share the same configuration across multiple repositories. If the configuration file is in a private repository you can also specify an `external-repository-token` option. This should be a personal access token that has read access to any repositories containing referenced config files and queries. The configuration file can be located in a different repository. This is useful if you want to share the same configuration across multiple repositories. If the configuration file is in a private repository you can also specify an `external-repository-token` option. This should be a personal access token that has read access to any repositories containing referenced config files and queries.
```yaml ```yaml
- uses: github/codeql-action/init@v1 - uses: github/codeql-action/init@v2
with: with:
config-file: owner/repo/codeql-config.yml@branch config-file: owner/repo/codeql-config.yml@branch
external-repository-token: ${{ secrets.EXTERNAL_REPOSITORY_TOKEN }} external-repository-token: ${{ secrets.EXTERNAL_REPOSITORY_TOKEN }}
@@ -122,7 +122,7 @@ For information on how to write a configuration file, see "[Using a custom confi
If you only want to customise the queries used, you can specify them in your workflow instead of creating a config file, using the `queries` property of the `init` action: If you only want to customise the queries used, you can specify them in your workflow instead of creating a config file, using the `queries` property of the `init` action:
```yaml ```yaml
- uses: github/codeql-action/init@v1 - uses: github/codeql-action/init@v2
with: with:
queries: <local-or-remote-query>,<another-query> queries: <local-or-remote-query>,<another-query>
``` ```
@@ -130,7 +130,7 @@ If you only want to customise the queries used, you can specify them in your wor
By default, this will override any queries specified in a config file. If you wish to use both sets of queries, prefix the list of queries in the workflow with `+`: By default, this will override any queries specified in a config file. If you wish to use both sets of queries, prefix the list of queries in the workflow with `+`:
```yaml ```yaml
- uses: github/codeql-action/init@v1 - uses: github/codeql-action/init@v2
with: with:
queries: +<local-or-remote-query>,<another-query> queries: +<local-or-remote-query>,<another-query>
``` ```
@@ -139,10 +139,3 @@ By default, this will override any queries specified in a config file. If you wi
Read about [troubleshooting code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning). Read about [troubleshooting code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning).
### Note on "missing analysis" message
The very first time code scanning is run and if it is on a pull request, you will probably get a message mentioning a "missing analysis". This is expected.
After code scanning has analyzed the code in a pull request, it needs to compare the analysis of the topic branch (the merge commit of the branch you used to create the pull request) with the analysis of the base branch (the branch into which you want to merge the pull request). This allows code scanning to compute which alerts are newly introduced by the pull request, which alerts were already present in the base branch, and whether any existing alerts are fixed by the changes in the pull request. Initially, if you use a pull request to add code scanning to a repository, the base branch has not yet been analyzed, so it's not possible to compute these details. In this case, when you click through from the results check on the pull request you will see the "Missing analysis for base commit SHA-HASH" message.
For more information and other causes of this message, see [Reasons for the "missing analysis" message](https://docs.github.com/en/code-security/secure-coding/automatically-scanning-your-code-for-vulnerabilities-and-errors/setting-up-code-scanning-for-a-repository#reasons-for-the-missing-analysis-message)

View File

@@ -45,6 +45,12 @@ inputs:
description: "The path at which the analyzed repository was checked out. Used to relativize any absolute paths in the uploaded SARIF file." description: "The path at which the analyzed repository was checked out. Used to relativize any absolute paths in the uploaded SARIF file."
required: false required: false
default: ${{ github.workspace }} default: ${{ github.workspace }}
ref:
description: "The ref where results will be uploaded. If not provided, the Action will use the GITHUB_REF environment variable. If provided, the sha input must be provided as well. This input is not available in pull requests from forks."
required: false
sha:
description: "The sha of the HEAD of the ref where results will be uploaded. If not provided, the Action will use the GITHUB_SHA environment variable. If provided, the ref input must be provided as well. This input is not available in pull requests from forks."
required: false
category: category:
description: String used by Code Scanning for matching the analyses description: String used by Code Scanning for matching the analyses
required: false required: false
@@ -63,6 +69,8 @@ inputs:
outputs: outputs:
db-locations: db-locations:
description: A map from language to absolute path for each database created by CodeQL. description: A map from language to absolute path for each database created by CodeQL.
sarif-id:
description: The ID of the uploaded SARIF file.
runs: runs:
using: "node12" using: "node12"
main: "../lib/analyze-action.js" main: "../lib/analyze-action.js"

View File

@@ -6,6 +6,12 @@ inputs:
default: ${{ github.token }} default: ${{ github.token }}
matrix: matrix:
default: ${{ toJson(matrix) }} default: ${{ toJson(matrix) }}
working-directory:
description: >-
Run the autobuilder using this path (relative to $GITHUB_WORKSPACE) as
working directory. If this input is not set, the autobuilder runs with
$GITHUB_WORKSPACE as its working directory.
required: false
runs: runs:
using: 'node12' using: 'node12'
main: '../lib/autobuild-action.js' main: '../lib/autobuild-action.js'

View File

@@ -56,7 +56,10 @@ inputs:
This input also sets the number of threads that can later be used by the "analyze" action. This input also sets the number of threads that can later be used by the "analyze" action.
required: false required: false
debug: debug:
description: Enable debugging mode. This will result in more output being produced which may be useful when debugging certain issues. description: >-
Enable debugging mode.
This will result in more output being produced which may be useful when debugging certain issues.
Debugging mode is enabled automatically when step debug logging is turned on.
required: false required: false
default: 'false' default: 'false'
debug-artifact-name: debug-artifact-name:

150
lib/actions-util.js generated
View File

@@ -19,8 +19,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.sanitizeArifactName = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.getCommitOid = exports.getToolCacheDirectory = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0; exports.sanitizeArifactName = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getActionsStatus = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.determineMergeBaseCommitOid = exports.getCommitOid = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner")); const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
@@ -29,6 +30,8 @@ const yaml = __importStar(require("js-yaml"));
const api = __importStar(require("./api-client")); const api = __importStar(require("./api-client"));
const sharedEnv = __importStar(require("./shared-environment")); const sharedEnv = __importStar(require("./shared-environment"));
const util_1 = require("./util"); const util_1 = require("./util");
// eslint-disable-next-line import/no-commonjs
const pkg = require("../package.json");
/** /**
* The utils in this module are meant to be run inside of the action only. * The utils in this module are meant to be run inside of the action only.
* Code paths from the runner should not enter this module. * Code paths from the runner should not enter this module.
@@ -51,10 +54,10 @@ exports.getRequiredInput = getRequiredInput;
* This allows us to get stronger type checking of required/optional inputs * This allows us to get stronger type checking of required/optional inputs
* and make behaviour more consistent between actions and the runner. * and make behaviour more consistent between actions and the runner.
*/ */
function getOptionalInput(name) { const getOptionalInput = function (name) {
const value = core.getInput(name); const value = core.getInput(name);
return value.length > 0 ? value : undefined; return value.length > 0 ? value : undefined;
} };
exports.getOptionalInput = getOptionalInput; exports.getOptionalInput = getOptionalInput;
function getTemporaryDirectory() { function getTemporaryDirectory() {
const value = process.env["CODEQL_ACTION_TEMP"]; const value = process.env["CODEQL_ACTION_TEMP"];
@@ -63,17 +66,10 @@ function getTemporaryDirectory() {
: (0, util_1.getRequiredEnvParam)("RUNNER_TEMP"); : (0, util_1.getRequiredEnvParam)("RUNNER_TEMP");
} }
exports.getTemporaryDirectory = getTemporaryDirectory; exports.getTemporaryDirectory = getTemporaryDirectory;
function getToolCacheDirectory() {
const value = process.env["CODEQL_ACTION_TOOL_CACHE"];
return value !== undefined && value !== ""
? value
: (0, util_1.getRequiredEnvParam)("RUNNER_TOOL_CACHE");
}
exports.getToolCacheDirectory = getToolCacheDirectory;
/** /**
* Gets the SHA of the commit that is currently checked out. * Gets the SHA of the commit that is currently checked out.
*/ */
const getCommitOid = async function (ref = "HEAD") { const getCommitOid = async function (checkoutPath, ref = "HEAD") {
// Try to use git to get the current commit SHA. If that fails then // Try to use git to get the current commit SHA. If that fails then
// log but otherwise silently fall back to using the SHA from the environment. // log but otherwise silently fall back to using the SHA from the environment.
// The only time these two values will differ is during analysis of a PR when // The only time these two values will differ is during analysis of a PR when
@@ -93,16 +89,68 @@ const getCommitOid = async function (ref = "HEAD") {
process.stderr.write(data); process.stderr.write(data);
}, },
}, },
cwd: checkoutPath,
}).exec(); }).exec();
return commitOid.trim(); return commitOid.trim();
} }
catch (e) { catch (e) {
core.info(`Failed to call git to get current commit. Continuing with data from environment: ${e}`); core.info(`Failed to call git to get current commit. Continuing with data from environment or input: ${e}`);
core.info(e.stack || "NO STACK"); core.info(e.stack || "NO STACK");
return (0, util_1.getRequiredEnvParam)("GITHUB_SHA"); return (0, exports.getOptionalInput)("sha") || (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
} }
}; };
exports.getCommitOid = getCommitOid; exports.getCommitOid = getCommitOid;
/**
* If the action was triggered by a pull request, determine the commit sha of the merge base.
* Returns undefined if run by other triggers or the merge base cannot be determined.
*/
const determineMergeBaseCommitOid = async function () {
if (process.env.GITHUB_EVENT_NAME !== "pull_request") {
return undefined;
}
const mergeSha = (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
const checkoutPath = (0, exports.getOptionalInput)("checkout_path");
try {
let commitOid = "";
let baseOid = "";
let headOid = "";
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), ["show", "-s", "--format=raw", mergeSha], {
silent: true,
listeners: {
stdline: (data) => {
if (data.startsWith("commit ") && commitOid === "") {
commitOid = data.substring(7);
}
else if (data.startsWith("parent ")) {
if (baseOid === "") {
baseOid = data.substring(7);
}
else if (headOid === "") {
headOid = data.substring(7);
}
}
},
stderr: (data) => {
process.stderr.write(data);
},
},
cwd: checkoutPath,
}).exec();
// Let's confirm our assumptions: We had a merge commit and the parsed parent data looks correct
if (commitOid === mergeSha &&
headOid.length === 40 &&
baseOid.length === 40) {
return baseOid;
}
return undefined;
}
catch (e) {
core.info(`Failed to call git to determine merge base. Continuing with data from environment: ${e}`);
core.info(e.stack || "NO STACK");
return undefined;
}
};
exports.determineMergeBaseCommitOid = determineMergeBaseCommitOid;
function isObject(o) { function isObject(o) {
return o !== null && typeof o === "object"; return o !== null && typeof o === "object";
} }
@@ -302,7 +350,7 @@ async function getWorkflowPath() {
const repo = repo_nwo[1]; const repo = repo_nwo[1];
const run_id = Number((0, util_1.getRequiredEnvParam)("GITHUB_RUN_ID")); const run_id = Number((0, util_1.getRequiredEnvParam)("GITHUB_RUN_ID"));
const apiClient = api.getActionsApiClient(); const apiClient = api.getActionsApiClient();
const runsResponse = await apiClient.request("GET /repos/:owner/:repo/actions/runs/:run_id", { const runsResponse = await apiClient.request("GET /repos/:owner/:repo/actions/runs/:run_id?exclude_pull_requests=true", {
owner, owner,
repo, repo,
run_id, run_id,
@@ -373,8 +421,24 @@ exports.computeAutomationID = computeAutomationID;
async function getRef() { async function getRef() {
// Will be in the form "refs/heads/master" on a push event // Will be in the form "refs/heads/master" on a push event
// or in the form "refs/pull/N/merge" on a pull_request event // or in the form "refs/pull/N/merge" on a pull_request event
const ref = (0, util_1.getRequiredEnvParam)("GITHUB_REF"); const refInput = (0, exports.getOptionalInput)("ref");
const sha = (0, util_1.getRequiredEnvParam)("GITHUB_SHA"); const shaInput = (0, exports.getOptionalInput)("sha");
const checkoutPath = (0, exports.getOptionalInput)("checkout_path") ||
(0, exports.getOptionalInput)("source-root") ||
(0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE");
const hasRefInput = !!refInput;
const hasShaInput = !!shaInput;
// If one of 'ref' or 'sha' are provided, both are required
if ((hasRefInput || hasShaInput) && !(hasRefInput && hasShaInput)) {
throw new Error("Both 'ref' and 'sha' are required if one of them is provided.");
}
const ref = refInput || (0, util_1.getRequiredEnvParam)("GITHUB_REF");
const sha = shaInput || (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
// If the ref is a user-provided input, we have to skip logic
// and assume that it is really where they want to upload the results.
if (refInput) {
return refInput;
}
// For pull request refs we want to detect whether the workflow // For pull request refs we want to detect whether the workflow
// has run `git checkout HEAD^2` to analyze the 'head' ref rather // has run `git checkout HEAD^2` to analyze the 'head' ref rather
// than the 'merge' ref. If so, we want to convert the ref that // than the 'merge' ref. If so, we want to convert the ref that
@@ -383,15 +447,14 @@ async function getRef() {
if (!pull_ref_regex.test(ref)) { if (!pull_ref_regex.test(ref)) {
return ref; return ref;
} }
const head = await (0, exports.getCommitOid)("HEAD"); const head = await (0, exports.getCommitOid)(checkoutPath, "HEAD");
// in actions/checkout@v2 we can check if git rev-parse HEAD == GITHUB_SHA // in actions/checkout@v2+ we can check if git rev-parse HEAD == GITHUB_SHA
// in actions/checkout@v1 this may not be true as it checks out the repository // in actions/checkout@v1 this may not be true as it checks out the repository
// using GITHUB_REF. There is a subtle race condition where // using GITHUB_REF. There is a subtle race condition where
// git rev-parse GITHUB_REF != GITHUB_SHA, so we must check // git rev-parse GITHUB_REF != GITHUB_SHA, so we must check
// git git-parse GITHUB_REF == git rev-parse HEAD instead. // git git-parse GITHUB_REF == git rev-parse HEAD instead.
const hasChangedRef = sha !== head && const hasChangedRef = sha !== head &&
(await (0, exports.getCommitOid)(ref.replace(/^refs\/pull\//, "refs/remotes/pull/"))) !== (await (0, exports.getCommitOid)(checkoutPath, ref.replace(/^refs\/pull\//, "refs/remotes/pull/"))) !== head;
head;
if (hasChangedRef) { if (hasChangedRef) {
const newRef = ref.replace(pull_ref_regex, "refs/pull/$1/head"); const newRef = ref.replace(pull_ref_regex, "refs/pull/$1/head");
core.debug(`No longer on merge commit, rewriting ref from ${ref} to ${newRef}.`); core.debug(`No longer on merge commit, rewriting ref from ${ref} to ${newRef}.`);
@@ -402,6 +465,15 @@ async function getRef() {
} }
} }
exports.getRef = getRef; exports.getRef = getRef;
function getActionsStatus(error, otherFailureCause) {
if (error || otherFailureCause) {
return error instanceof util_1.UserError ? "user-error" : "failure";
}
else {
return "success";
}
}
exports.getActionsStatus = getActionsStatus;
/** /**
* Compose a StatusReport. * Compose a StatusReport.
* *
@@ -412,7 +484,7 @@ exports.getRef = getRef;
* @param exception Exception (only supply if status is 'failure') * @param exception Exception (only supply if status is 'failure')
*/ */
async function createStatusReportBase(actionName, status, actionStartedAt, cause, exception) { async function createStatusReportBase(actionName, status, actionStartedAt, cause, exception) {
const commitOid = process.env["GITHUB_SHA"] || ""; const commitOid = (0, exports.getOptionalInput)("sha") || process.env["GITHUB_SHA"] || "";
const ref = await getRef(); const ref = await getRef();
const workflowRunIDStr = process.env["GITHUB_RUN_ID"]; const workflowRunIDStr = process.env["GITHUB_RUN_ID"];
let workflowRunID = -1; let workflowRunID = -1;
@@ -427,6 +499,8 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
workflowStartedAt = actionStartedAt.toISOString(); workflowStartedAt = actionStartedAt.toISOString();
core.exportVariable(sharedEnv.CODEQL_WORKFLOW_STARTED_AT, workflowStartedAt); core.exportVariable(sharedEnv.CODEQL_WORKFLOW_STARTED_AT, workflowStartedAt);
} }
const runnerOs = (0, util_1.getRequiredEnvParam)("RUNNER_OS");
const codeQlCliVersion = (0, util_1.getCachedCodeQlVersion)();
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action // If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
// See https://github.com/actions/runner/issues/803 // See https://github.com/actions/runner/issues/803
const actionRef = isRunningLocalAction() const actionRef = isRunningLocalAction()
@@ -445,6 +519,8 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
started_at: workflowStartedAt, started_at: workflowStartedAt,
action_started_at: actionStartedAt.toISOString(), action_started_at: actionStartedAt.toISOString(),
status, status,
runner_os: runnerOs,
action_version: pkg.version,
}; };
// Add optional parameters // Add optional parameters
if (cause) { if (cause) {
@@ -453,18 +529,32 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
if (exception) { if (exception) {
statusReport.exception = exception; statusReport.exception = exception;
} }
if (status === "success" || status === "failure" || status === "aborted") { if (status === "success" ||
status === "failure" ||
status === "aborted" ||
status === "user-error") {
statusReport.completed_at = new Date().toISOString(); statusReport.completed_at = new Date().toISOString();
} }
const matrix = getRequiredInput("matrix"); const matrix = getRequiredInput("matrix");
if (matrix) { if (matrix) {
statusReport.matrix_vars = matrix; statusReport.matrix_vars = matrix;
} }
if ("RUNNER_ARCH" in process.env) {
// RUNNER_ARCH is available only in GHES 3.4 and later
// Values other than X86, X64, ARM, or ARM64 are discarded server side
statusReport.runner_arch = process.env["RUNNER_ARCH"];
}
if (runnerOs === "Windows" || runnerOs === "macOS") {
statusReport.runner_os_release = os.release();
}
if (codeQlCliVersion !== undefined) {
statusReport.codeql_version = codeQlCliVersion;
}
return statusReport; return statusReport;
} }
exports.createStatusReportBase = createStatusReportBase; exports.createStatusReportBase = createStatusReportBase;
const GENERIC_403_MSG = "The repo on which this action is running is not opted-in to CodeQL code scanning."; const GENERIC_403_MSG = "The repo on which this action is running is not opted-in to CodeQL code scanning.";
const GENERIC_404_MSG = "Not authorized to used the CodeQL code scanning feature on this repo."; const GENERIC_404_MSG = "Not authorized to use the CodeQL code scanning feature on this repo.";
const OUT_OF_DATE_MSG = "CodeQL Action is out-of-date. Please upgrade to the latest version of codeql-action."; const OUT_OF_DATE_MSG = "CodeQL Action is out-of-date. Please upgrade to the latest version of codeql-action.";
const INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the code scanning endpoint. Please update to a compatible version of codeql-action."; const INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the code scanning endpoint. Please update to a compatible version of codeql-action.";
/** /**
@@ -477,8 +567,20 @@ const INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the code sc
* Returns whether sending the status report was successful of not. * Returns whether sending the status report was successful of not.
*/ */
async function sendStatusReport(statusReport) { async function sendStatusReport(statusReport) {
const gitHubVersion = await api.getGitHubVersionActionsOnly();
if ((0, util_1.isGitHubGhesVersionBelow)(gitHubVersion, "3.2.0")) {
// GHES 3.1 and earlier versions reject unexpected properties, which means
// that they will reject status reports with newly added properties.
// Inhibiting status reporting for GHES < 3.2 avoids such failures.
return true;
}
const statusReportJSON = JSON.stringify(statusReport); const statusReportJSON = JSON.stringify(statusReport);
core.debug(`Sending status report: ${statusReportJSON}`); core.debug(`Sending status report: ${statusReportJSON}`);
// If in test mode we don't want to upload the results
if ((0, util_1.isInTestMode)()) {
core.debug("In test mode. Status reports are not uploaded.");
return true;
}
const nwo = (0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"); const nwo = (0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY");
const [owner, repo] = nwo.split("/"); const [owner, repo] = nwo.split("/");
const client = api.getActionsApiClient(); const client = api.getActionsApiClient();
@@ -568,7 +670,7 @@ async function isAnalyzingDefaultBranch() {
// Get the current ref and trim and refs/heads/ prefix // Get the current ref and trim and refs/heads/ prefix
let currentRef = await getRef(); let currentRef = await getRef();
currentRef = currentRef.startsWith("refs/heads/") currentRef = currentRef.startsWith("refs/heads/")
? currentRef.substr("refs/heads/".length) ? currentRef.slice("refs/heads/".length)
: currentRef; : currentRef;
const event = getWorkflowEvent(); const event = getWorkflowEvent();
const defaultBranch = (_a = event === null || event === void 0 ? void 0 : event.repository) === null || _a === void 0 ? void 0 : _a.default_branch; const defaultBranch = (_a = event === null || event === void 0 ? void 0 : event.repository) === null || _a === void 0 ? void 0 : _a.default_branch;

File diff suppressed because one or more lines are too long

111
lib/actions-util.test.js generated
View File

@@ -39,37 +39,93 @@ function errorCodes(actual, expected) {
await t.throwsAsync(actionsutil.getRef); await t.throwsAsync(actionsutil.getRef);
}); });
(0, ava_1.default)("getRef() returns merge PR ref if GITHUB_SHA still checked out", async (t) => { (0, ava_1.default)("getRef() returns merge PR ref if GITHUB_SHA still checked out", async (t) => {
const expectedRef = "refs/pull/1/merge"; await (0, util_1.withTmpDir)(async (tmpDir) => {
const currentSha = "a".repeat(40); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
process.env["GITHUB_REF"] = expectedRef; const expectedRef = "refs/pull/1/merge";
process.env["GITHUB_SHA"] = currentSha; const currentSha = "a".repeat(40);
const callback = sinon.stub(actionsutil, "getCommitOid"); process.env["GITHUB_REF"] = expectedRef;
callback.withArgs("HEAD").resolves(currentSha); process.env["GITHUB_SHA"] = currentSha;
const actualRef = await actionsutil.getRef(); const callback = sinon.stub(actionsutil, "getCommitOid");
t.deepEqual(actualRef, expectedRef); callback.withArgs("HEAD").resolves(currentSha);
callback.restore(); const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, expectedRef);
callback.restore();
});
}); });
(0, ava_1.default)("getRef() returns merge PR ref if GITHUB_REF still checked out but sha has changed (actions checkout@v1)", async (t) => { (0, ava_1.default)("getRef() returns merge PR ref if GITHUB_REF still checked out but sha has changed (actions checkout@v1)", async (t) => {
const expectedRef = "refs/pull/1/merge"; await (0, util_1.withTmpDir)(async (tmpDir) => {
process.env["GITHUB_REF"] = expectedRef; (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
process.env["GITHUB_SHA"] = "b".repeat(40); const expectedRef = "refs/pull/1/merge";
const sha = "a".repeat(40); process.env["GITHUB_REF"] = expectedRef;
const callback = sinon.stub(actionsutil, "getCommitOid"); process.env["GITHUB_SHA"] = "b".repeat(40);
callback.withArgs("refs/remotes/pull/1/merge").resolves(sha); const sha = "a".repeat(40);
callback.withArgs("HEAD").resolves(sha); const callback = sinon.stub(actionsutil, "getCommitOid");
const actualRef = await actionsutil.getRef(); callback.withArgs("refs/remotes/pull/1/merge").resolves(sha);
t.deepEqual(actualRef, expectedRef); callback.withArgs("HEAD").resolves(sha);
callback.restore(); const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, expectedRef);
callback.restore();
});
}); });
(0, ava_1.default)("getRef() returns head PR ref if GITHUB_REF no longer checked out", async (t) => { (0, ava_1.default)("getRef() returns head PR ref if GITHUB_REF no longer checked out", async (t) => {
process.env["GITHUB_REF"] = "refs/pull/1/merge"; await (0, util_1.withTmpDir)(async (tmpDir) => {
process.env["GITHUB_SHA"] = "a".repeat(40); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
const callback = sinon.stub(actionsutil, "getCommitOid"); process.env["GITHUB_REF"] = "refs/pull/1/merge";
callback.withArgs("refs/pull/1/merge").resolves("a".repeat(40)); process.env["GITHUB_SHA"] = "a".repeat(40);
callback.withArgs("HEAD").resolves("b".repeat(40)); const callback = sinon.stub(actionsutil, "getCommitOid");
const actualRef = await actionsutil.getRef(); callback.withArgs(tmpDir, "refs/pull/1/merge").resolves("a".repeat(40));
t.deepEqual(actualRef, "refs/pull/1/head"); callback.withArgs(tmpDir, "HEAD").resolves("b".repeat(40));
callback.restore(); const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, "refs/pull/1/head");
callback.restore();
});
});
(0, ava_1.default)("getRef() returns ref provided as an input and ignores current HEAD", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
const getAdditionalInputStub = sinon.stub(actionsutil, "getOptionalInput");
getAdditionalInputStub.withArgs("ref").resolves("refs/pull/2/merge");
getAdditionalInputStub.withArgs("sha").resolves("b".repeat(40));
// These values are be ignored
process.env["GITHUB_REF"] = "refs/pull/1/merge";
process.env["GITHUB_SHA"] = "a".repeat(40);
const callback = sinon.stub(actionsutil, "getCommitOid");
callback.withArgs("refs/pull/1/merge").resolves("b".repeat(40));
callback.withArgs("HEAD").resolves("b".repeat(40));
const actualRef = await actionsutil.getRef();
t.deepEqual(actualRef, "refs/pull/2/merge");
callback.restore();
getAdditionalInputStub.restore();
});
});
(0, ava_1.default)("getRef() throws an error if only `ref` is provided as an input", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
const getAdditionalInputStub = sinon.stub(actionsutil, "getOptionalInput");
getAdditionalInputStub.withArgs("ref").resolves("refs/pull/1/merge");
await t.throwsAsync(async () => {
await actionsutil.getRef();
}, {
instanceOf: Error,
message: "Both 'ref' and 'sha' are required if one of them is provided.",
});
getAdditionalInputStub.restore();
});
});
(0, ava_1.default)("getRef() throws an error if only `sha` is provided as an input", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
process.env["GITHUB_WORKSPACE"] = "/tmp";
const getAdditionalInputStub = sinon.stub(actionsutil, "getOptionalInput");
getAdditionalInputStub.withArgs("sha").resolves("a".repeat(40));
await t.throwsAsync(async () => {
await actionsutil.getRef();
}, {
instanceOf: Error,
message: "Both 'ref' and 'sha' are required if one of them is provided.",
});
getAdditionalInputStub.restore();
});
}); });
(0, ava_1.default)("computeAutomationID()", async (t) => { (0, ava_1.default)("computeAutomationID()", async (t) => {
let actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", '{"language": "javascript", "os": "linux"}'); let actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", '{"language": "javascript", "os": "linux"}');
@@ -424,6 +480,7 @@ on: ["push"]
}); });
(0, ava_1.default)("isAnalyzingDefaultBranch()", async (t) => { (0, ava_1.default)("isAnalyzingDefaultBranch()", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
const envFile = path.join(tmpDir, "event.json"); const envFile = path.join(tmpDir, "event.json");
fs.writeFileSync(envFile, JSON.stringify({ fs.writeFileSync(envFile, JSON.stringify({
repository: { repository: {

File diff suppressed because one or more lines are too long

11
lib/analysis-paths.js generated
View File

@@ -37,11 +37,11 @@ function buildIncludeExcludeEnvVar(paths) {
return paths.join("\n"); return paths.join("\n");
} }
function printPathFiltersWarning(config, logger) { function printPathFiltersWarning(config, logger) {
// Index include/exclude/filters only work in javascript and python. // Index include/exclude/filters only work in javascript/python/ruby.
// If any other languages are detected/configured then show a warning. // If any other languages are detected/configured then show a warning.
if ((config.paths.length !== 0 || config.pathsIgnore.length !== 0) && if ((config.paths.length !== 0 || config.pathsIgnore.length !== 0) &&
!config.languages.every(isInterpretedLanguage)) { !config.languages.every(isInterpretedLanguage)) {
logger.warning('The "paths"/"paths-ignore" fields of the config only have effect for JavaScript and Python'); logger.warning('The "paths"/"paths-ignore" fields of the config only have effect for JavaScript, Python, and Ruby');
} }
} }
exports.printPathFiltersWarning = printPathFiltersWarning; exports.printPathFiltersWarning = printPathFiltersWarning;
@@ -58,14 +58,11 @@ function includeAndExcludeAnalysisPaths(config) {
} }
// If the temporary or tools directory is in the working directory ignore that too. // If the temporary or tools directory is in the working directory ignore that too.
const tempRelativeToWorking = path.relative(process.cwd(), config.tempDir); const tempRelativeToWorking = path.relative(process.cwd(), config.tempDir);
const toolsRelativeToWorking = path.relative(process.cwd(), config.toolCacheDir);
let pathsIgnore = config.pathsIgnore; let pathsIgnore = config.pathsIgnore;
if (!tempRelativeToWorking.startsWith("..")) { if (!tempRelativeToWorking.startsWith("..") &&
!path.isAbsolute(tempRelativeToWorking)) {
pathsIgnore = pathsIgnore.concat(tempRelativeToWorking); pathsIgnore = pathsIgnore.concat(tempRelativeToWorking);
} }
if (!toolsRelativeToWorking.startsWith("..")) {
pathsIgnore = pathsIgnore.concat(toolsRelativeToWorking);
}
if (pathsIgnore.length !== 0) { if (pathsIgnore.length !== 0) {
process.env["LGTM_INDEX_EXCLUDE"] = buildIncludeExcludeEnvVar(pathsIgnore); process.env["LGTM_INDEX_EXCLUDE"] = buildIncludeExcludeEnvVar(pathsIgnore);
} }

View File

@@ -1 +1 @@
{"version":3,"file":"anal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OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACxD;AACH,CAAC;AAjCD,wEAiCC"}

View File

@@ -37,7 +37,6 @@ const util = __importStar(require("./util"));
paths: [], paths: [],
originalUserInput: {}, originalUserInput: {},
tempDir: tmpDir, tempDir: tmpDir,
toolCacheDir: tmpDir,
codeQLCmd: "", codeQLCmd: "",
gitHubVersion: { type: util.GitHubVariant.DOTCOM }, gitHubVersion: { type: util.GitHubVariant.DOTCOM },
dbLocation: path.resolve(tmpDir, "codeql_databases"), dbLocation: path.resolve(tmpDir, "codeql_databases"),
@@ -45,6 +44,7 @@ const util = __importStar(require("./util"));
debugMode: false, debugMode: false,
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME, debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME, debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
injectedMlQueries: false,
}; };
analysisPaths.includeAndExcludeAnalysisPaths(config); analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined); t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
@@ -61,7 +61,6 @@ const util = __importStar(require("./util"));
pathsIgnore: ["path4", "path5", "path6/**"], pathsIgnore: ["path4", "path5", "path6/**"],
originalUserInput: {}, originalUserInput: {},
tempDir: tmpDir, tempDir: tmpDir,
toolCacheDir: tmpDir,
codeQLCmd: "", codeQLCmd: "",
gitHubVersion: { type: util.GitHubVariant.DOTCOM }, gitHubVersion: { type: util.GitHubVariant.DOTCOM },
dbLocation: path.resolve(tmpDir, "codeql_databases"), dbLocation: path.resolve(tmpDir, "codeql_databases"),
@@ -69,6 +68,7 @@ const util = __importStar(require("./util"));
debugMode: false, debugMode: false,
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME, debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME, debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
injectedMlQueries: false,
}; };
analysisPaths.includeAndExcludeAnalysisPaths(config); analysisPaths.includeAndExcludeAnalysisPaths(config);
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2"); t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
@@ -77,28 +77,26 @@ const util = __importStar(require("./util"));
}); });
}); });
(0, ava_1.default)("exclude temp dir", async (t) => { (0, ava_1.default)("exclude temp dir", async (t) => {
return await util.withTmpDir(async (toolCacheDir) => { const tempDir = path.join(process.cwd(), "codeql-runner-temp");
const tempDir = path.join(process.cwd(), "codeql-runner-temp"); const config = {
const config = { languages: [],
languages: [], queries: {},
queries: {}, pathsIgnore: [],
pathsIgnore: [], paths: [],
paths: [], originalUserInput: {},
originalUserInput: {}, tempDir,
tempDir, codeQLCmd: "",
toolCacheDir, gitHubVersion: { type: util.GitHubVariant.DOTCOM },
codeQLCmd: "", dbLocation: path.resolve(tempDir, "codeql_databases"),
gitHubVersion: { type: util.GitHubVariant.DOTCOM }, packs: {},
dbLocation: path.resolve(tempDir, "codeql_databases"), debugMode: false,
packs: {}, debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
debugMode: false, debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME, injectedMlQueries: false,
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME, };
}; analysisPaths.includeAndExcludeAnalysisPaths(config);
analysisPaths.includeAndExcludeAnalysisPaths(config); t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined); t.is(process.env["LGTM_INDEX_EXCLUDE"], "codeql-runner-temp");
t.is(process.env["LGTM_INDEX_EXCLUDE"], "codeql-runner-temp"); t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
});
}); });
//# sourceMappingURL=analysis-paths.test.js.map //# sourceMappingURL=analysis-paths.test.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"analysis-paths.test.js","sourceRoot":"","sources":["../src/analysis-paths.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,8CAAuB;AAEvB,gEAAkD;AAClD,mDAA6C;AAC7C,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,IAAA,aAAI,EAAC,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC7B,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,EAAE;YACT,iBAAiB,EAAE,EAAE;YACrB,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,MAAM;YACpB,SAAS,EAAE,EAAE;YACb,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAwB;YACxE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,kBAAkB,CAAC;YACpD,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,KAAK;YAChB,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;YACnD,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;SACpD,CAAC;QACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;QACnD,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,EAAE;QACrB,OAAO;QACP,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAwB;QACxE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,kBAAkB,CAAC;QACrD,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,KAAK;QAChB,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;QACnD,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;QACnD,iBAAiB,EAAE,KAAK;KACzB,CAAC;IACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,CAAC;IAC9D,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}

View File

@@ -38,21 +38,26 @@ const util = __importStar(require("./util"));
// but the first test would fail. // but the first test would fail.
(0, ava_1.default)("analyze action with RAM & threads from environment variables", async (t) => { (0, ava_1.default)("analyze action with RAM & threads from environment variables", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
process.env["GITHUB_SERVER_URL"] = "fake-server-url"; process.env["GITHUB_SERVER_URL"] = util.GITHUB_DOTCOM_URL;
process.env["GITHUB_REPOSITORY"] = "fake/repository"; process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
sinon sinon
.stub(actionsUtil, "createStatusReportBase") .stub(actionsUtil, "createStatusReportBase")
.resolves({}); .resolves({});
sinon.stub(actionsUtil, "sendStatusReport").resolves(true); sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
const gitHubVersion = {
type: util.GitHubVariant.DOTCOM,
};
sinon.stub(configUtils, "getConfig").resolves({ sinon.stub(configUtils, "getConfig").resolves({
gitHubVersion: { type: util.GitHubVariant.DOTCOM }, gitHubVersion,
languages: [], languages: [],
packs: [],
}); });
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput"); const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
requiredInputStub.withArgs("token").returns("fake-token"); requiredInputStub.withArgs("token").returns("fake-token");
requiredInputStub.withArgs("upload-database").returns("false"); requiredInputStub.withArgs("upload-database").returns("false");
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput"); const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
optionalInputStub.withArgs("cleanup-level").returns("none"); optionalInputStub.withArgs("cleanup-level").returns("none");
sinon.stub(util, "getGitHubVersion").resolves(gitHubVersion);
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {}); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
// When there are no action inputs for RAM and threads, the action uses // When there are no action inputs for RAM and threads, the action uses

View File

@@ -1 +1 @@
{"version":3,"file":"analyze-action-env.test.js","sourceRoot":"","sources":["../src/analyze-action-env.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,8DAA8D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC/E,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;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iBAAiB;QACjB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;QAEnC,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

View File

@@ -38,21 +38,26 @@ const util = __importStar(require("./util"));
// but the first test would fail. // but the first test would fail.
(0, ava_1.default)("analyze action with RAM & threads from action inputs", async (t) => { (0, ava_1.default)("analyze action with RAM & threads from action inputs", async (t) => {
await util.withTmpDir(async (tmpDir) => { await util.withTmpDir(async (tmpDir) => {
process.env["GITHUB_SERVER_URL"] = "fake-server-url"; process.env["GITHUB_SERVER_URL"] = util.GITHUB_DOTCOM_URL;
process.env["GITHUB_REPOSITORY"] = "fake/repository"; process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
sinon sinon
.stub(actionsUtil, "createStatusReportBase") .stub(actionsUtil, "createStatusReportBase")
.resolves({}); .resolves({});
sinon.stub(actionsUtil, "sendStatusReport").resolves(true); sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
const gitHubVersion = {
type: util.GitHubVariant.DOTCOM,
};
sinon.stub(configUtils, "getConfig").resolves({ sinon.stub(configUtils, "getConfig").resolves({
gitHubVersion: { type: util.GitHubVariant.DOTCOM }, gitHubVersion,
languages: [], languages: [],
packs: [],
}); });
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput"); const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
requiredInputStub.withArgs("token").returns("fake-token"); requiredInputStub.withArgs("token").returns("fake-token");
requiredInputStub.withArgs("upload-database").returns("false"); requiredInputStub.withArgs("upload-database").returns("false");
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput"); const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
optionalInputStub.withArgs("cleanup-level").returns("none"); optionalInputStub.withArgs("cleanup-level").returns("none");
sinon.stub(util, "getGitHubVersion").resolves(gitHubVersion);
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {}); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
process.env["CODEQL_THREADS"] = "1"; process.env["CODEQL_THREADS"] = "1";

View File

@@ -1 +1 @@
{"version":3,"file":"analyze-action-input.test.js","sourceRoot":"","sources":["../src/analyze-action-input.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;A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AC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

56
lib/analyze-action.js generated
View File

@@ -26,6 +26,7 @@ const artifact = __importStar(require("@actions/artifact"));
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const actionsUtil = __importStar(require("./actions-util")); const actionsUtil = __importStar(require("./actions-util"));
const analyze_1 = require("./analyze"); const analyze_1 = require("./analyze");
const api_client_1 = require("./api-client");
const codeql_1 = require("./codeql"); const codeql_1 = require("./codeql");
const config_utils_1 = require("./config-utils"); const config_utils_1 = require("./config-utils");
const database_upload_1 = require("./database-upload"); const database_upload_1 = require("./database-upload");
@@ -37,13 +38,16 @@ const util = __importStar(require("./util"));
const util_1 = require("./util"); const util_1 = require("./util");
// eslint-disable-next-line import/no-commonjs // eslint-disable-next-line import/no-commonjs
const pkg = require("../package.json"); const pkg = require("../package.json");
async function sendStatusReport(startedAt, stats, error) { async function sendStatusReport(startedAt, config, stats, error) {
const status = (stats === null || stats === void 0 ? void 0 : stats.analyze_failure_language) !== undefined || error !== undefined const status = actionsUtil.getActionsStatus(error, stats === null || stats === void 0 ? void 0 : stats.analyze_failure_language);
? "failure"
: "success";
const statusReportBase = await actionsUtil.createStatusReportBase("finish", status, startedAt, error === null || error === void 0 ? void 0 : error.message, error === null || error === void 0 ? void 0 : error.stack); const statusReportBase = await actionsUtil.createStatusReportBase("finish", status, startedAt, error === null || error === void 0 ? void 0 : error.message, error === null || error === void 0 ? void 0 : error.stack);
const statusReport = { const statusReport = {
...statusReportBase, ...statusReportBase,
...(config
? {
ml_powered_javascript_queries: util.getMlPoweredJsQueriesStatus(config),
}
: {}),
...(stats || {}), ...(stats || {}),
}; };
await actionsUtil.sendStatusReport(statusReport); await actionsUtil.sendStatusReport(statusReport);
@@ -55,6 +59,7 @@ async function run() {
let runStats = undefined; let runStats = undefined;
let config = undefined; let config = undefined;
util.initializeEnvironment(util.Mode.actions, pkg.version); util.initializeEnvironment(util.Mode.actions, pkg.version);
await util.checkActionVersion(pkg.version);
try { try {
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) { if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
return; return;
@@ -73,13 +78,9 @@ async function run() {
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger); const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger);
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]); const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")); const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
const featureFlags = new feature_flags_1.GitHubFeatureFlags(config.gitHubVersion, apiDetails, repositoryNwo, logger); const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
// We currently perform an API request in both the `init` and `analyze` Actions to determine const featureFlags = new feature_flags_1.GitHubFeatureFlags(gitHubVersion, apiDetails, repositoryNwo, logger);
// what feature flags are enabled. At the time of writing, this redundant API call is acceptable await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, featureFlags);
// to us, but if we wanted to avoid it, we could do so by serializing the feature flags as part
// of the config file.
void featureFlags.preloadFeatureFlags();
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
if (actionsUtil.getRequiredInput("skip-queries") !== "true") { if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger); runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger);
if (config.debugMode) { if (config.debugMode) {
@@ -90,13 +91,13 @@ async function run() {
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd); const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
if (config.debugMode) { if (config.debugMode) {
// Upload the logs as an Actions artifact for debugging // Upload the logs as an Actions artifact for debugging
const toUpload = []; let toUpload = [];
for (const language of config.languages) { for (const language of config.languages) {
toUpload.push(...listFolder(path.resolve(util.getCodeQLDatabasePath(config, language), "log"))); toUpload = toUpload.concat(listFolder(path.resolve(util.getCodeQLDatabasePath(config, language), "log")));
} }
if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) { if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
// Multilanguage tracing: there are additional logs in the root of the cluster // Multilanguage tracing: there are additional logs in the root of the cluster
toUpload.push(...listFolder(path.resolve(config.dbLocation, "log"))); toUpload = toUpload.concat(listFolder(path.resolve(config.dbLocation, "log")));
} }
await uploadDebugArtifacts(toUpload, config.dbLocation, config.debugArtifactName); await uploadDebugArtifacts(toUpload, config.dbLocation, config.debugArtifactName);
if (!(await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING))) { if (!(await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING))) {
@@ -114,13 +115,18 @@ async function run() {
core.setOutput("db-locations", dbLocations); core.setOutput("db-locations", dbLocations);
if (runStats && actionsUtil.getRequiredInput("upload") === "true") { if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
uploadResult = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger); uploadResult = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger);
core.setOutput("sarif-id", uploadResult.sarifID);
} }
else { else {
logger.info("Not uploading results"); logger.info("Not uploading results");
} }
// Possibly upload the database bundles for remote queries // Possibly upload the database bundles for remote queries
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, featureFlags, apiDetails, logger); await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger);
if (uploadResult !== undefined && // We don't upload results in test mode, so don't wait for processing
if (util.isInTestMode()) {
core.debug("In test mode. Waiting for processing is disabled.");
}
else if (uploadResult !== undefined &&
actionsUtil.getRequiredInput("wait-for-processing") === "true") { actionsUtil.getRequiredInput("wait-for-processing") === "true") {
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)()); await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
} }
@@ -131,15 +137,15 @@ async function run() {
console.log(error); console.log(error);
if (error instanceof analyze_1.CodeQLAnalysisError) { if (error instanceof analyze_1.CodeQLAnalysisError) {
const stats = { ...error.queriesStatusReport }; const stats = { ...error.queriesStatusReport };
await sendStatusReport(startedAt, stats, error); await sendStatusReport(startedAt, config, stats, error);
} }
else { else {
await sendStatusReport(startedAt, undefined, error); await sendStatusReport(startedAt, config, undefined, error);
} }
return; return;
} }
finally { finally {
if (config !== undefined && config.debugMode) { if (config === null || config === void 0 ? void 0 : config.debugMode) {
try { try {
// Upload the database bundles as an Actions artifact for debugging // Upload the database bundles as an Actions artifact for debugging
const toUpload = []; const toUpload = [];
@@ -152,7 +158,7 @@ async function run() {
console.log(`Failed to upload database debug bundles: ${error}`); console.log(`Failed to upload database debug bundles: ${error}`);
} }
} }
if (core.isDebug() && config !== undefined) { if (config === null || config === void 0 ? void 0 : config.debugMode) {
core.info("Debug mode is on. Printing CodeQL debug logs..."); core.info("Debug mode is on. Printing CodeQL debug logs...");
for (const language of config.languages) { for (const language of config.languages) {
const databaseDirectory = util.getCodeQLDatabasePath(config, language); const databaseDirectory = util.getCodeQLDatabasePath(config, language);
@@ -175,16 +181,16 @@ async function run() {
} }
} }
if (runStats && uploadResult) { if (runStats && uploadResult) {
await sendStatusReport(startedAt, { await sendStatusReport(startedAt, config, {
...runStats, ...runStats,
...uploadResult.statusReport, ...uploadResult.statusReport,
}); });
} }
else if (runStats) { else if (runStats) {
await sendStatusReport(startedAt, { ...runStats }); await sendStatusReport(startedAt, config, { ...runStats });
} }
else { else {
await sendStatusReport(startedAt, undefined); await sendStatusReport(startedAt, config, undefined);
} }
} }
async function uploadDebugArtifacts(toUpload, rootDir, artifactName) { async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
@@ -198,13 +204,13 @@ async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
} }
function listFolder(dir) { function listFolder(dir) {
const entries = fs.readdirSync(dir, { withFileTypes: true }); const entries = fs.readdirSync(dir, { withFileTypes: true });
const files = []; let files = [];
for (const entry of entries) { for (const entry of entries) {
if (entry.isFile()) { if (entry.isFile()) {
files.push(path.resolve(dir, entry.name)); files.push(path.resolve(dir, entry.name));
} }
else if (entry.isDirectory()) { else if (entry.isDirectory()) {
files.push(...listFolder(path.resolve(dir, entry.name))); files = files.concat(listFolder(path.resolve(dir, entry.name)));
} }
} }
return files; return files;

File diff suppressed because one or more lines are too long

90
lib/analyze.js generated
View File

@@ -18,17 +18,22 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod); __setModuleDefault(result, mod);
return result; return result;
}; };
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.runCleanup = exports.runFinalize = exports.runQueries = exports.CodeQLAnalysisError = void 0; exports.runCleanup = exports.runFinalize = exports.runQueries = exports.createdDBForScannedLanguages = exports.CodeQLAnalysisError = void 0;
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner")); const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
const del_1 = __importDefault(require("del"));
const yaml = __importStar(require("js-yaml")); const yaml = __importStar(require("js-yaml"));
const analysisPaths = __importStar(require("./analysis-paths")); const analysisPaths = __importStar(require("./analysis-paths"));
const codeql_1 = require("./codeql"); const codeql_1 = require("./codeql");
const count_loc_1 = require("./count-loc"); const count_loc_1 = require("./count-loc");
const languages_1 = require("./languages"); const languages_1 = require("./languages");
const sharedEnv = __importStar(require("./shared-environment")); const sharedEnv = __importStar(require("./shared-environment"));
const tracer_config_1 = require("./tracer-config");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
class CodeQLAnalysisError extends Error { class CodeQLAnalysisError extends Error {
constructor(queriesStatusReport, message) { constructor(queriesStatusReport, message) {
@@ -63,11 +68,10 @@ async function setupPythonExtractor(logger) {
logger.info(`Setting LGTM_PYTHON_SETUP_VERSION=${output}`); logger.info(`Setting LGTM_PYTHON_SETUP_VERSION=${output}`);
process.env["LGTM_PYTHON_SETUP_VERSION"] = output; process.env["LGTM_PYTHON_SETUP_VERSION"] = output;
} }
async function createdDBForScannedLanguages(config, logger) { async function createdDBForScannedLanguages(codeql, config, logger, featureFlags) {
// Insert the LGTM_INDEX_X env vars at this point so they are set when // Insert the LGTM_INDEX_X env vars at this point so they are set when
// we extract any scanned languages. // we extract any scanned languages.
analysisPaths.includeAndExcludeAnalysisPaths(config); analysisPaths.includeAndExcludeAnalysisPaths(config);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
for (const language of config.languages) { for (const language of config.languages) {
if ((0, languages_1.isScannedLanguage)(language) && if ((0, languages_1.isScannedLanguage)(language) &&
!dbIsFinalized(config, language, logger)) { !dbIsFinalized(config, language, logger)) {
@@ -75,11 +79,12 @@ async function createdDBForScannedLanguages(config, logger) {
if (language === languages_1.Language.python) { if (language === languages_1.Language.python) {
await setupPythonExtractor(logger); await setupPythonExtractor(logger);
} }
await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config, language), language); await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config, language), language, featureFlags);
logger.endGroup(); logger.endGroup();
} }
} }
} }
exports.createdDBForScannedLanguages = createdDBForScannedLanguages;
function dbIsFinalized(config, language, logger) { function dbIsFinalized(config, language, logger) {
const dbPath = util.getCodeQLDatabasePath(config, language); const dbPath = util.getCodeQLDatabasePath(config, language);
try { try {
@@ -91,9 +96,9 @@ function dbIsFinalized(config, language, logger) {
return false; return false;
} }
} }
async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger) { async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureFlags) {
await createdDBForScannedLanguages(config, logger);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd); const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
await createdDBForScannedLanguages(codeql, config, logger, featureFlags);
for (const language of config.languages) { for (const language of config.languages) {
if (dbIsFinalized(config, language, logger)) { if (dbIsFinalized(config, language, logger)) {
logger.info(`There is already a finalized database for ${language} at the location where the CodeQL Action places databases, so we did not create one.`); logger.info(`There is already a finalized database for ${language} at the location where the CodeQL Action places databases, so we did not create one.`);
@@ -110,10 +115,8 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
const statusReport = {}; const statusReport = {};
let locPromise = Promise.resolve({}); let locPromise = Promise.resolve({});
const cliCanCountBaseline = await cliCanCountLoC(); const cliCanCountBaseline = await cliCanCountLoC();
const debugMode = process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] || const countLocDebugMode = process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] || config.debugMode;
process.env["ACTIONS_RUNNER_DEBUG"] || if (!cliCanCountBaseline || countLocDebugMode) {
process.env["ACTIONS_STEP_DEBUG"];
if (!cliCanCountBaseline || debugMode) {
// count the number of lines in the background // count the number of lines in the background
locPromise = (0, count_loc_1.countLoc)(path.resolve(), locPromise = (0, count_loc_1.countLoc)(path.resolve(),
// config.paths specifies external directories. the current // config.paths specifies external directories. the current
@@ -130,14 +133,11 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
if (!hasBuiltinQueries && !hasCustomQueries && !hasPackWithCustomQueries) { if (!hasBuiltinQueries && !hasCustomQueries && !hasPackWithCustomQueries) {
throw new Error(`Unable to analyse ${language} as no queries were selected for this language`); throw new Error(`Unable to analyse ${language} as no queries were selected for this language`);
} }
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
try { try {
if (hasPackWithCustomQueries) { if (hasPackWithCustomQueries) {
logger.info("*************"); logger.info("Performing analysis with custom CodeQL Packs.");
logger.info("Performing analysis with custom QL Packs. QL Packs are an experimental feature.");
logger.info("And should not be used in production yet.");
logger.info("*************");
logger.startGroup(`Downloading custom packs for ${language}`); logger.startGroup(`Downloading custom packs for ${language}`);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
const results = await codeql.packDownload(packsWithVersion); const results = await codeql.packDownload(packsWithVersion);
logger.info(`Downloaded packs: ${results.packs logger.info(`Downloaded packs: ${results.packs
.map((r) => `${r.name}@${r.version || "latest"}`) .map((r) => `${r.name}@${r.version || "latest"}`)
@@ -161,7 +161,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
} }
} }
if (packsWithVersion.length > 0) { if (packsWithVersion.length > 0) {
querySuitePaths.push(await runQueryGroup(language, "packs", createPackSuiteContents(packsWithVersion), undefined)); querySuitePaths.push(...(await runQueryPacks(language, "packs", packsWithVersion, undefined)));
ranCustom = true; ranCustom = true;
} }
if (ranCustom) { if (ranCustom) {
@@ -172,14 +172,14 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
logger.startGroup(`Interpreting results for ${language}`); logger.startGroup(`Interpreting results for ${language}`);
const startTimeInterpretResults = new Date().getTime(); const startTimeInterpretResults = new Date().getTime();
const sarifFile = path.join(sarifFolder, `${language}.sarif`); const sarifFile = path.join(sarifFolder, `${language}.sarif`);
const analysisSummary = await runInterpretResults(language, querySuitePaths, sarifFile); const analysisSummary = await runInterpretResults(language, querySuitePaths, sarifFile, config.debugMode);
if (!cliCanCountBaseline) if (!cliCanCountBaseline)
await injectLinesOfCode(sarifFile, language, locPromise); await injectLinesOfCode(sarifFile, language, locPromise);
statusReport[`interpret_results_${language}_duration_ms`] = statusReport[`interpret_results_${language}_duration_ms`] =
new Date().getTime() - startTimeInterpretResults; new Date().getTime() - startTimeInterpretResults;
logger.endGroup(); logger.endGroup();
logger.info(analysisSummary); logger.info(analysisSummary);
if (!cliCanCountBaseline || debugMode) if (!cliCanCountBaseline || countLocDebugMode)
printLinesOfCodeSummary(logger, language, await locPromise); printLinesOfCodeSummary(logger, language, await locPromise);
if (cliCanCountBaseline) if (cliCanCountBaseline)
logger.info(await runPrintLinesOfCode(language)); logger.info(await runPrintLinesOfCode(language));
@@ -194,10 +194,10 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
} }
} }
return statusReport; return statusReport;
async function runInterpretResults(language, queries, sarifFile) { async function runInterpretResults(language, queries, sarifFile, enableDebugLogging) {
const databasePath = util.getCodeQLDatabasePath(config, language); const databasePath = util.getCodeQLDatabasePath(config, language);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd); const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, automationDetailsId); return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, enableDebugLogging ? "-vv" : "-v", automationDetailsId);
} }
async function cliCanCountLoC() { async function cliCanCountLoC() {
return await util.codeQlVersionAbove(await (0, codeql_1.getCodeQL)(config.codeQLCmd), codeql_1.CODEQL_VERSION_COUNTS_LINES); return await util.codeQlVersionAbove(await (0, codeql_1.getCodeQL)(config.codeQLCmd), codeql_1.CODEQL_VERSION_COUNTS_LINES);
@@ -219,26 +219,48 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`); logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
return querySuitePath; return querySuitePath;
} }
async function runQueryPacks(language, type, packs, searchPath) {
const databasePath = util.getCodeQLDatabasePath(config, language);
// Run the queries individually instead of all at once to avoid command
// line length restrictions, particularly on windows.
for (const pack of packs) {
logger.debug(`Running query pack for ${language}-${type}: ${pack}`);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
await codeql.databaseRunQueries(databasePath, searchPath, pack, memoryFlag, threadsFlag);
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
}
return packs;
}
} }
exports.runQueries = runQueries; exports.runQueries = runQueries;
function createQuerySuiteContents(queries) { function createQuerySuiteContents(queries) {
return queries.map((q) => `- query: ${q}`).join("\n"); return queries.map((q) => `- query: ${q}`).join("\n");
} }
function createPackSuiteContents(packsWithVersion) { async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger, featureFlags) {
return packsWithVersion.map(packWithVersionToQuerySuiteEntry).join("\n"); try {
} await (0, del_1.default)(outputDir, { force: true });
function packWithVersionToQuerySuiteEntry(pack) { }
let text = `- qlpack: ${pack.packName}`; catch (error) {
if (pack.version) { if ((error === null || error === void 0 ? void 0 : error.code) !== "ENOENT") {
text += `\n version: ${pack.version}`; throw error;
}
}
await fs.promises.mkdir(outputDir, { recursive: true });
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureFlags);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
// WARNING: This does not _really_ end tracing, as the tracer will restore its
// critical environment variables and it'll still be active for all processes
// launched from this build step.
// However, it will stop tracing for all steps past the codeql-action/analyze
// step.
if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
// Delete variables as specified by the end-tracing script
await (0, tracer_config_1.endTracingForCluster)(config);
}
else {
// Delete the tracer config env var to avoid tracing ourselves
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
} }
return text;
}
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
// Delete the tracer config env var to avoid tracing ourselves
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
fs.mkdirSync(outputDir, { recursive: true });
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger);
} }
exports.runFinalize = runFinalize; exports.runFinalize = runFinalize;
async function runCleanup(config, cleanupLevel, logger) { async function runCleanup(config, cleanupLevel, logger) {

File diff suppressed because one or more lines are too long

108
lib/analyze.test.js generated
View File

@@ -26,11 +26,12 @@ const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const ava_1 = __importDefault(require("ava")); const ava_1 = __importDefault(require("ava"));
const yaml = __importStar(require("js-yaml")); const yaml = __importStar(require("js-yaml"));
const semver_1 = require("semver");
const sinon = __importStar(require("sinon")); const sinon = __importStar(require("sinon"));
const analyze_1 = require("./analyze"); const analyze_1 = require("./analyze");
const codeql_1 = require("./codeql"); const codeql_1 = require("./codeql");
const codeql_test_1 = require("./codeql.test");
const count = __importStar(require("./count-loc")); const count = __importStar(require("./count-loc"));
const feature_flags_1 = require("./feature-flags");
const languages_1 = require("./languages"); const languages_1 = require("./languages");
const logging_1 = require("./logging"); const logging_1 = require("./logging");
const testing_utils_1 = require("./testing-utils"); const testing_utils_1 = require("./testing-utils");
@@ -53,18 +54,8 @@ const util = __importStar(require("./util"));
const addSnippetsFlag = ""; const addSnippetsFlag = "";
const threadsFlag = ""; const threadsFlag = "";
const packs = { const packs = {
[languages_1.Language.cpp]: [ [languages_1.Language.cpp]: ["a/b@1.0.0"],
{ [languages_1.Language.java]: ["c/d@2.0.0"],
packName: "a/b",
version: (0, semver_1.clean)("1.0.0"),
},
],
[languages_1.Language.java]: [
{
packName: "c/d",
version: (0, semver_1.clean)("2.0.0"),
},
],
}; };
for (const language of Object.values(languages_1.Language)) { for (const language of Object.values(languages_1.Language)) {
(0, codeql_1.setCodeQL)({ (0, codeql_1.setCodeQL)({
@@ -118,7 +109,6 @@ const util = __importStar(require("./util"));
paths: [], paths: [],
originalUserInput: {}, originalUserInput: {},
tempDir: tmpDir, tempDir: tmpDir,
toolCacheDir: tmpDir,
codeQLCmd: "", codeQLCmd: "",
gitHubVersion: { gitHubVersion: {
type: util.GitHubVariant.DOTCOM, type: util.GitHubVariant.DOTCOM,
@@ -128,6 +118,7 @@ const util = __importStar(require("./util"));
debugMode: false, debugMode: false,
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME, debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME, debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
injectedMlQueries: false,
}; };
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), { fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
recursive: true, recursive: true,
@@ -208,32 +199,10 @@ const util = __importStar(require("./util"));
query: "bar.ql", query: "bar.ql",
}, },
]; ];
const qlsPackContentCpp = [
{
qlpack: "a/b",
version: "1.0.0",
},
];
const qlsPackContentJava = [
{
qlpack: "c/d",
version: "2.0.0",
},
];
for (const lang of Object.values(languages_1.Language)) { for (const lang of Object.values(languages_1.Language)) {
t.deepEqual(readContents(`${lang}-queries-builtin.qls`), qlsContent); t.deepEqual(readContents(`${lang}-queries-builtin.qls`), qlsContent);
t.deepEqual(readContents(`${lang}-queries-custom-0.qls`), qlsContent); t.deepEqual(readContents(`${lang}-queries-custom-0.qls`), qlsContent);
t.deepEqual(readContents(`${lang}-queries-custom-1.qls`), qlsContent2); t.deepEqual(readContents(`${lang}-queries-custom-1.qls`), qlsContent2);
const packSuiteName = `${lang}-queries-packs.qls`;
if (lang === languages_1.Language.cpp) {
t.deepEqual(readContents(packSuiteName), qlsPackContentCpp);
}
else if (lang === languages_1.Language.java) {
t.deepEqual(readContents(packSuiteName), qlsPackContentJava);
}
else {
t.false(fs.existsSync(path.join(tmpDir, "codeql_databases", packSuiteName)));
}
} }
function readContents(name) { function readContents(name) {
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8"); const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
@@ -242,4 +211,71 @@ const util = __importStar(require("./util"));
} }
} }
}); });
const stubConfig = {
languages: [languages_1.Language.cpp, languages_1.Language.go],
queries: {},
pathsIgnore: [],
paths: [],
originalUserInput: {},
tempDir: "",
codeQLCmd: "",
gitHubVersion: {
type: util.GitHubVariant.DOTCOM,
},
dbLocation: "",
packs: {},
debugMode: false,
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
injectedMlQueries: false,
};
for (const options of [
{
name: "Lua feature flag enabled, but old CLI",
version: "2.9.0",
featureFlags: [feature_flags_1.FeatureFlag.LuaTracerConfigEnabled],
yesFlagSet: false,
noFlagSet: false,
},
{
name: "Lua feature flag disabled, with old CLI",
version: "2.9.0",
featureFlags: [],
yesFlagSet: false,
noFlagSet: false,
},
{
name: "Lua feature flag enabled, with new CLI",
version: "2.10.0",
featureFlags: [feature_flags_1.FeatureFlag.LuaTracerConfigEnabled],
yesFlagSet: true,
noFlagSet: false,
},
{
name: "Lua feature flag disabled, with new CLI",
version: "2.10.0",
featureFlags: [],
yesFlagSet: false,
noFlagSet: true,
},
]) {
(0, ava_1.default)(`createdDBForScannedLanguages() ${options.name}`, async (t) => {
const runnerConstructorStub = (0, codeql_test_1.stubToolRunnerConstructor)();
const codeqlObject = await (0, codeql_1.getCodeQLForTesting)("codeql/for-testing");
sinon.stub(codeqlObject, "getVersion").resolves(options.version);
const promise = (0, analyze_1.createdDBForScannedLanguages)(codeqlObject, stubConfig, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)(options.featureFlags));
// call listener on `codeql resolve extractor`
const mockToolRunner = runnerConstructorStub.getCall(0);
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
await promise;
if (options.yesFlagSet)
t.true(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be present, but it is absent");
else
t.false(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
if (options.noFlagSet)
t.true(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be present, but it is absent");
else
t.false(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
});
}
//# sourceMappingURL=analyze.test.js.map //# sourceMappingURL=analyze.test.js.map

File diff suppressed because one or more lines are too long

34
lib/api-client.js generated
View File

@@ -22,12 +22,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.getActionsApiClient = exports.getApiClient = exports.DisallowedAPIVersionReason = void 0; exports.getGitHubVersionActionsOnly = exports.getActionsApiClient = exports.getApiClient = exports.DisallowedAPIVersionReason = void 0;
const path = __importStar(require("path")); const path = __importStar(require("path"));
const githubUtils = __importStar(require("@actions/github/lib/utils")); const githubUtils = __importStar(require("@actions/github/lib/utils"));
const retry = __importStar(require("@octokit/plugin-retry")); const retry = __importStar(require("@octokit/plugin-retry"));
const console_log_level_1 = __importDefault(require("console-log-level")); const console_log_level_1 = __importDefault(require("console-log-level"));
const actions_util_1 = require("./actions-util"); const actions_util_1 = require("./actions-util");
const util = __importStar(require("./util"));
const util_1 = require("./util"); const util_1 = require("./util");
// eslint-disable-next-line import/no-commonjs // eslint-disable-next-line import/no-commonjs
const pkg = require("../package.json"); const pkg = require("../package.json");
@@ -57,15 +58,36 @@ function getApiUrl(githubUrl) {
url.pathname = path.join(url.pathname, "api", "v3"); url.pathname = path.join(url.pathname, "api", "v3");
return url.toString(); return url.toString();
} }
function getApiDetails() {
return {
auth: (0, actions_util_1.getRequiredInput)("token"),
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
};
}
// Temporary function to aid in the transition to running on and off of github actions. // Temporary function to aid in the transition to running on and off of github actions.
// Once all code has been converted this function should be removed or made canonical // Once all code has been converted this function should be removed or made canonical
// and called only from the action entrypoints. // and called only from the action entrypoints.
function getActionsApiClient() { function getActionsApiClient() {
const apiDetails = { return (0, exports.getApiClient)(getApiDetails());
auth: (0, actions_util_1.getRequiredInput)("token"),
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
};
return (0, exports.getApiClient)(apiDetails);
} }
exports.getActionsApiClient = getActionsApiClient; exports.getActionsApiClient = getActionsApiClient;
let cachedGitHubVersion = undefined;
/**
* Report the GitHub server version. This is a wrapper around
* util.getGitHubVersion() that automatically supplies GitHub API details using
* GitHub Action inputs. If you need to get the GitHub server version from the
* Runner, please call util.getGitHubVersion() instead.
*
* @returns GitHub version
*/
async function getGitHubVersionActionsOnly() {
if (!util.isActions()) {
throw new Error("getGitHubVersionActionsOnly() works only in an action");
}
if (cachedGitHubVersion === undefined) {
cachedGitHubVersion = await util.getGitHubVersion(getApiDetails());
}
return cachedGitHubVersion;
}
exports.getGitHubVersionActionsOnly = getGitHubVersionActionsOnly;
//# sourceMappingURL=api-client.js.map //# sourceMappingURL=api-client.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,uEAAyD;AACzD,6DAA+C;AAC/C,0EAAgD;AAEhD,iDAAkD;AAClD,iCAAsD;AAEtD,8CAA8C;A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umVersion": "3.6", "minimumVersion": "3.2" }

View File

@@ -29,9 +29,7 @@ const util_1 = require("./util");
const pkg = require("../package.json"); const pkg = require("../package.json");
async function sendCompletedStatusReport(startedAt, allLanguages, failingLanguage, cause) { async function sendCompletedStatusReport(startedAt, allLanguages, failingLanguage, cause) {
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version); (0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
const status = failingLanguage !== undefined || cause !== undefined const status = (0, actions_util_1.getActionsStatus)(cause, failingLanguage);
? "failure"
: "success";
const statusReportBase = await (0, actions_util_1.createStatusReportBase)("autobuild", status, startedAt, cause === null || cause === void 0 ? void 0 : cause.message, cause === null || cause === void 0 ? void 0 : cause.stack); const statusReportBase = await (0, actions_util_1.createStatusReportBase)("autobuild", status, startedAt, cause === null || cause === void 0 ? void 0 : cause.message, cause === null || cause === void 0 ? void 0 : cause.stack);
const statusReport = { const statusReport = {
...statusReportBase, ...statusReportBase,
@@ -41,8 +39,9 @@ async function sendCompletedStatusReport(startedAt, allLanguages, failingLanguag
await (0, actions_util_1.sendStatusReport)(statusReport); await (0, actions_util_1.sendStatusReport)(statusReport);
} }
async function run() { async function run() {
const logger = (0, logging_1.getActionsLogger)();
const startedAt = new Date(); const startedAt = new Date();
const logger = (0, logging_1.getActionsLogger)();
await (0, util_1.checkActionVersion)(pkg.version);
let language = undefined; let language = undefined;
try { try {
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("autobuild", "starting", startedAt)))) { if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("autobuild", "starting", startedAt)))) {
@@ -54,6 +53,11 @@ async function run() {
} }
language = (0, autobuild_1.determineAutobuildLanguage)(config, logger); language = (0, autobuild_1.determineAutobuildLanguage)(config, logger);
if (language !== undefined) { if (language !== undefined) {
const workingDirectory = (0, actions_util_1.getOptionalInput)("working-directory");
if (workingDirectory) {
logger.info(`Changing autobuilder working directory to ${workingDirectory}`);
process.chdir(workingDirectory);
}
await (0, autobuild_1.runAutobuild)(language, config, logger); await (0, autobuild_1.runAutobuild)(language, config, logger);
} }
} }

View File

@@ -1 +1 @@
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,iDAKwB;AACxB,2CAAuE;AACvE,6DAA+C;AAE/C,uCAA6C;AAC7C,iCAAqD;AAErD,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AASvC,KAAK,UAAU,yBAAyB,CACtC,SAAe,EACf,YAAsB,EACtB,eAAwB,EACxB,KAAa;IAEb,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAEjD,MAAM,MAAM,GACV,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS;QAClD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,gBAAgB,GAAG,MAAM,IAAA,qCAAsB,EACnD,WAAW,EACX,MAAM,EACN,SAAS,EACT,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EACd,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CACb,CAAC;IACF,MAAM,YAAY,GAA0B;QAC1C,GAAG,gBAAgB;QACnB,mBAAmB,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAC3C,iBAAiB,EAAE,eAAe;KACnC,CAAC;IACF,MAAM,IAAA,+BAAgB,EAAC,YAAY,CAAC,CAAC;AACvC,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAClC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IAAI,QAAQ,GAAyB,SAAS,CAAC;IAC/C,IAAI;QACF,IACE,CAAC,C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AAO;KACR;IAED,MAAM,yBAAyB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}

135
lib/codeql.js generated
View File

@@ -22,19 +22,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.getExtraOptions = exports.getCodeQLForTesting = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.convertToSemVer = exports.getCodeQLURLVersion = exports.setupCodeQL = exports.getCodeQLActionRepository = exports.CODEQL_VERSION_NEW_TRACING = exports.CODEQL_VERSION_ML_POWERED_QUERIES = exports.CODEQL_VERSION_COUNTS_LINES = exports.CommandInvocationError = void 0; exports.getExtraOptions = exports.getCodeQLForTesting = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.convertToSemVer = exports.getCodeQLURLVersion = exports.setupCodeQL = exports.getCodeQLActionRepository = exports.CODEQL_VERSION_ML_POWERED_QUERIES_WINDOWS = exports.CODEQL_VERSION_NEW_TRACING = exports.CODEQL_VERSION_ML_POWERED_QUERIES = exports.CODEQL_VERSION_COUNTS_LINES = exports.CommandInvocationError = void 0;
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner")); const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
const toolcache = __importStar(require("@actions/tool-cache"));
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal")); const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
const query_string_1 = __importDefault(require("query-string")); const query_string_1 = __importDefault(require("query-string"));
const semver = __importStar(require("semver")); const semver = __importStar(require("semver"));
const uuid_1 = require("uuid");
const actions_util_1 = require("./actions-util"); const actions_util_1 = require("./actions-util");
const api = __importStar(require("./api-client")); const api = __importStar(require("./api-client"));
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool! const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
const error_matcher_1 = require("./error-matcher"); const error_matcher_1 = require("./error-matcher");
const feature_flags_1 = require("./feature-flags");
const languages_1 = require("./languages"); const languages_1 = require("./languages");
const toolcache = __importStar(require("./toolcache"));
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher"); const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
const util_1 = require("./util"); const util_1 = require("./util");
@@ -59,9 +61,10 @@ const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
* below can be used to conditionally enable certain features on versions newer * below can be used to conditionally enable certain features on versions newer
* than this. Please record the reason we cannot support an older version. * than this. Please record the reason we cannot support an older version.
* *
* Reason: Changes to how the tracing environment is set up. * Reason: First version containing fix for the "We still have not reached
* idleness" deadlock.
*/ */
const CODEQL_MINIMUM_VERSION = "2.3.1"; const CODEQL_MINIMUM_VERSION = "2.4.5";
/** /**
* Versions of CodeQL that version-flag certain functionality in the Action. * Versions of CodeQL that version-flag certain functionality in the Action.
* For convenience, please keep these in descending order. Once a version * For convenience, please keep these in descending order. Once a version
@@ -75,6 +78,7 @@ const CODEQL_VERSION_SARIF_GROUP = "2.5.3";
exports.CODEQL_VERSION_COUNTS_LINES = "2.6.2"; exports.CODEQL_VERSION_COUNTS_LINES = "2.6.2";
const CODEQL_VERSION_CUSTOM_QUERY_HELP = "2.7.1"; const CODEQL_VERSION_CUSTOM_QUERY_HELP = "2.7.1";
exports.CODEQL_VERSION_ML_POWERED_QUERIES = "2.7.5"; exports.CODEQL_VERSION_ML_POWERED_QUERIES = "2.7.5";
const CODEQL_VERSION_LUA_TRACER_CONFIG = "2.10.0";
/** /**
* This variable controls using the new style of tracing from the CodeQL * This variable controls using the new style of tracing from the CodeQL
* CLI. In particular, with versions above this we will use both indirect * CLI. In particular, with versions above this we will use both indirect
@@ -85,6 +89,12 @@ exports.CODEQL_VERSION_ML_POWERED_QUERIES = "2.7.5";
* versions above that. * versions above that.
*/ */
exports.CODEQL_VERSION_NEW_TRACING = "2.7.0"; exports.CODEQL_VERSION_NEW_TRACING = "2.7.0";
/**
* Versions 2.9.0+ of the CodeQL CLI run machine learning models from a temporary directory, which
* resolves an issue on Windows where TensorFlow models are not correctly loaded due to the path of
* some of their files being greater than MAX_PATH (260 characters).
*/
exports.CODEQL_VERSION_ML_POWERED_QUERIES_WINDOWS = "2.9.0";
function getCodeQLBundleName() { function getCodeQLBundleName() {
let platform; let platform;
if (process.platform === "win32") { if (process.platform === "win32") {
@@ -193,7 +203,19 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
} }
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`; return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
} }
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger, checkVersion) { /**
* Set up CodeQL CLI access.
*
* @param codeqlURL
* @param apiDetails
* @param tempDir
* @param variant
* @param logger
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
* version requirement. Must be set to true outside tests.
* @returns
*/
async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, logger, checkVersion) {
try { try {
// We use the special value of 'latest' to prioritize the version in the // We use the special value of 'latest' to prioritize the version in the
// defaults over any pinned cached version. // defaults over any pinned cached version.
@@ -204,21 +226,21 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
let codeqlFolder; let codeqlFolder;
let codeqlURLVersion; let codeqlURLVersion;
if (codeqlURL && !codeqlURL.startsWith("http")) { if (codeqlURL && !codeqlURL.startsWith("http")) {
codeqlFolder = await toolcache.extractTar(codeqlURL, tempDir, logger); codeqlFolder = await toolcache.extractTar(codeqlURL);
codeqlURLVersion = "local"; codeqlURLVersion = "local";
} }
else { else {
codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_BUNDLE_VERSION}/`); codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_BUNDLE_VERSION}/`);
const codeqlURLSemVer = convertToSemVer(codeqlURLVersion, logger); const codeqlURLSemVer = convertToSemVer(codeqlURLVersion, logger);
// If we find the specified version, we always use that. // If we find the specified version, we always use that.
codeqlFolder = toolcache.find("CodeQL", codeqlURLSemVer, toolCacheDir, logger); codeqlFolder = toolcache.find("CodeQL", codeqlURLSemVer);
// If we don't find the requested version, in some cases we may allow a // If we don't find the requested version, in some cases we may allow a
// different version to save download time if the version hasn't been // different version to save download time if the version hasn't been
// specified explicitly (in which case we always honor it). // specified explicitly (in which case we always honor it).
if (!codeqlFolder && !codeqlURL && !forceLatest) { if (!codeqlFolder && !codeqlURL && !forceLatest) {
const codeqlVersions = toolcache.findAllVersions("CodeQL", toolCacheDir, logger); const codeqlVersions = toolcache.findAllVersions("CodeQL");
if (codeqlVersions.length === 1 && (0, util_1.isGoodVersion)(codeqlVersions[0])) { if (codeqlVersions.length === 1 && (0, util_1.isGoodVersion)(codeqlVersions[0])) {
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0], toolCacheDir, logger); const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0]);
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) { if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`); logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
codeqlFolder = tmpCodeqlFolder; codeqlFolder = tmpCodeqlFolder;
@@ -234,7 +256,9 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
} }
const parsedCodeQLURL = new URL(codeqlURL); const parsedCodeQLURL = new URL(codeqlURL);
const parsedQueryString = query_string_1.default.parse(parsedCodeQLURL.search); const parsedQueryString = query_string_1.default.parse(parsedCodeQLURL.search);
const headers = { accept: "application/octet-stream" }; const headers = {
accept: "application/octet-stream",
};
// We only want to provide an authorization header if we are downloading // We only want to provide an authorization header if we are downloading
// from the same GitHub instance the Action is running on. // from the same GitHub instance the Action is running on.
// This avoids leaking Enterprise tokens to dotcom. // This avoids leaking Enterprise tokens to dotcom.
@@ -248,10 +272,12 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
logger.debug("Downloading CodeQL bundle without token."); logger.debug("Downloading CodeQL bundle without token.");
} }
logger.info(`Downloading CodeQL tools from ${codeqlURL}. This may take a while.`); logger.info(`Downloading CodeQL tools from ${codeqlURL}. This may take a while.`);
const codeqlPath = await toolcache.downloadTool(codeqlURL, tempDir, headers); const dest = path.join(tempDir, (0, uuid_1.v4)());
const finalHeaders = Object.assign({ "User-Agent": "CodeQL Action" }, headers);
const codeqlPath = await toolcache.downloadTool(codeqlURL, dest, undefined, finalHeaders);
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`); logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
const codeqlExtracted = await toolcache.extractTar(codeqlPath, tempDir, logger); const codeqlExtracted = await toolcache.extractTar(codeqlPath);
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLSemVer, toolCacheDir, logger); codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLSemVer);
} }
} }
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql"); let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
@@ -360,20 +386,30 @@ exports.getCachedCodeQL = getCachedCodeQL;
* a non-existent placeholder codeql command, so tests that use this function * a non-existent placeholder codeql command, so tests that use this function
* should also stub the toolrunner.ToolRunner constructor. * should also stub the toolrunner.ToolRunner constructor.
*/ */
async function getCodeQLForTesting() { async function getCodeQLForTesting(cmd = "codeql-for-testing") {
return getCodeQLForCmd("codeql-for-testing", false); return getCodeQLForCmd(cmd, false);
} }
exports.getCodeQLForTesting = getCodeQLForTesting; exports.getCodeQLForTesting = getCodeQLForTesting;
/**
* Return a CodeQL object for CodeQL CLI access.
*
* @param cmd Path to CodeQL CLI
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
* version requirement. Must be set to true outside tests.
* @returns A new CodeQL object
*/
async function getCodeQLForCmd(cmd, checkVersion) { async function getCodeQLForCmd(cmd, checkVersion) {
let cachedVersion = undefined;
const codeql = { const codeql = {
getPath() { getPath() {
return cmd; return cmd;
}, },
async getVersion() { async getVersion() {
if (cachedVersion === undefined) let result = util.getCachedCodeQlVersion();
cachedVersion = runTool(cmd, ["version", "--format=terse"]); if (result === undefined) {
return await cachedVersion; result = (await runTool(cmd, ["version", "--format=terse"])).trim();
util.cacheCodeQlVersion(result);
}
return result;
}, },
async printVersion() { async printVersion() {
await runTool(cmd, ["version", "--format=json"]); await runTool(cmd, ["version", "--format=json"]);
@@ -428,22 +464,33 @@ async function getCodeQLForCmd(cmd, checkVersion) {
...getExtraOptionsFromEnv(["database", "init"]), ...getExtraOptionsFromEnv(["database", "init"]),
]); ]);
}, },
async databaseInitCluster(databasePath, languages, sourceRoot, processName, processLevel) { async databaseInitCluster(config, sourceRoot, processName, processLevel, featureFlags) {
const extraArgs = languages.map((language) => `--language=${language}`); const extraArgs = config.languages.map((language) => `--language=${language}`);
if (languages.filter(languages_1.isTracedLanguage).length > 0) { if (config.languages.filter(languages_1.isTracedLanguage).length > 0) {
extraArgs.push("--begin-tracing"); extraArgs.push("--begin-tracing");
if (processName !== undefined) { if (processName !== undefined) {
extraArgs.push(`--trace-process-name=${processName}`); extraArgs.push(`--trace-process-name=${processName}`);
} }
else { else {
// We default to 3 if no other arguments are provided since this was the default
// behaviour of the Runner. Note this path never happens in the CodeQL Action
// because that always passes in a process name.
extraArgs.push(`--trace-process-level=${processLevel || 3}`); extraArgs.push(`--trace-process-level=${processLevel || 3}`);
} }
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_LUA_TRACER_CONFIG)) {
if (await featureFlags.getValue(feature_flags_1.FeatureFlag.LuaTracerConfigEnabled)) {
extraArgs.push("--internal-use-lua-tracing");
}
else {
extraArgs.push("--no-internal-use-lua-tracing");
}
}
} }
await runTool(cmd, [ await runTool(cmd, [
"database", "database",
"init", "init",
"--db-cluster", "--db-cluster",
databasePath, config.dbLocation,
`--source-root=${sourceRoot}`, `--source-root=${sourceRoot}`,
...extraArgs, ...extraArgs,
...getExtraOptionsFromEnv(["database", "init"]), ...getExtraOptionsFromEnv(["database", "init"]),
@@ -465,7 +512,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
].join(" "); ].join(" ");
await runTool(autobuildCmd); await runTool(autobuildCmd);
}, },
async extractScannedLanguage(databasePath, language) { async extractScannedLanguage(databasePath, language, featureFlags) {
// Get extractor location // Get extractor location
let extractorPath = ""; let extractorPath = "";
await new toolrunner.ToolRunner(cmd, [ await new toolrunner.ToolRunner(cmd, [
@@ -488,10 +535,20 @@ async function getCodeQLForCmd(cmd, checkVersion) {
// Set trace command // Set trace command
const ext = process.platform === "win32" ? ".cmd" : ".sh"; const ext = process.platform === "win32" ? ".cmd" : ".sh";
const traceCommand = path.resolve(JSON.parse(extractorPath), "tools", `autobuild${ext}`); const traceCommand = path.resolve(JSON.parse(extractorPath), "tools", `autobuild${ext}`);
const extraArgs = [];
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_LUA_TRACER_CONFIG)) {
if (await featureFlags.getValue(feature_flags_1.FeatureFlag.LuaTracerConfigEnabled)) {
extraArgs.push("--internal-use-lua-tracing");
}
else {
extraArgs.push("--no-internal-use-lua-tracing");
}
}
// Run trace command // Run trace command
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, [ await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, [
"database", "database",
"trace-command", "trace-command",
...extraArgs,
...getExtraOptionsFromEnv(["database", "trace-command"]), ...getExtraOptionsFromEnv(["database", "trace-command"]),
databasePath, databasePath,
"--", "--",
@@ -512,7 +569,12 @@ async function getCodeQLForCmd(cmd, checkVersion) {
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, args, error_matcher_1.errorMatchers); await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, args, error_matcher_1.errorMatchers);
}, },
async resolveLanguages() { async resolveLanguages() {
const codeqlArgs = ["resolve", "languages", "--format=json"]; const codeqlArgs = [
"resolve",
"languages",
"--format=json",
...getExtraOptionsFromEnv(["resolve", "languages"]),
];
const output = await runTool(cmd, codeqlArgs); const output = await runTool(cmd, codeqlArgs);
try { try {
return JSON.parse(output); return JSON.parse(output);
@@ -557,13 +619,13 @@ async function getCodeQLForCmd(cmd, checkVersion) {
codeqlArgs.push(querySuitePath); codeqlArgs.push(querySuitePath);
await runTool(cmd, codeqlArgs); await runTool(cmd, codeqlArgs);
}, },
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, automationDetailsId) { async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId) {
const codeqlArgs = [ const codeqlArgs = [
"database", "database",
"interpret-results", "interpret-results",
threadsFlag, threadsFlag,
"--format=sarif-latest", "--format=sarif-latest",
"-v", verbosityFlag,
`--output=${sarifFile}`, `--output=${sarifFile}`,
addSnippetsFlag, addSnippetsFlag,
...getExtraOptionsFromEnv(["database", "interpret-results"]), ...getExtraOptionsFromEnv(["database", "interpret-results"]),
@@ -580,7 +642,8 @@ async function getCodeQLForCmd(cmd, checkVersion) {
(await util.codeQlVersionAbove(this, CODEQL_VERSION_SARIF_GROUP))) { (await util.codeQlVersionAbove(this, CODEQL_VERSION_SARIF_GROUP))) {
codeqlArgs.push("--sarif-category", automationDetailsId); codeqlArgs.push("--sarif-category", automationDetailsId);
} }
codeqlArgs.push(databasePath, ...querySuitePaths); codeqlArgs.push(databasePath);
codeqlArgs.push(...querySuitePaths);
// capture stdout, which contains analysis summaries // capture stdout, which contains analysis summaries
return await runTool(cmd, codeqlArgs); return await runTool(cmd, codeqlArgs);
}, },
@@ -608,8 +671,9 @@ async function getCodeQLForCmd(cmd, checkVersion) {
"pack", "pack",
"download", "download",
"--format=json", "--format=json",
"--resolve-query-specs",
...getExtraOptionsFromEnv(["pack", "download"]), ...getExtraOptionsFromEnv(["pack", "download"]),
...packs.map(packWithVersionToString), ...packs,
]; ];
const output = await runTool(cmd, codeqlArgs); const output = await runTool(cmd, codeqlArgs);
try { try {
@@ -635,6 +699,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
"cleanup", "cleanup",
databasePath, databasePath,
`--mode=${cleanupLevel}`, `--mode=${cleanupLevel}`,
...getExtraOptionsFromEnv(["database", "cleanup"]),
]; ];
await runTool(cmd, codeqlArgs); await runTool(cmd, codeqlArgs);
}, },
@@ -645,19 +710,25 @@ async function getCodeQLForCmd(cmd, checkVersion) {
databasePath, databasePath,
`--output=${outputFilePath}`, `--output=${outputFilePath}`,
`--name=${databaseName}`, `--name=${databaseName}`,
...getExtraOptionsFromEnv(["database", "bundle"]),
]; ];
await new toolrunner.ToolRunner(cmd, args).exec(); await new toolrunner.ToolRunner(cmd, args).exec();
}, },
}; };
// To ensure that status reports include the CodeQL CLI version whereever
// possbile, we want to call getVersion(), which populates the version value
// used by status reporting, at the earliest opportunity. But invoking
// getVersion() directly here breaks tests that only pretend to create a
// CodeQL object. So instead we rely on the assumption that all non-test
// callers would set checkVersion to true, and util.codeQlVersionAbove()
// would call getVersion(), so the CLI version would be cached as soon as the
// CodeQL object is created.
if (checkVersion && if (checkVersion &&
!(await util.codeQlVersionAbove(codeql, CODEQL_MINIMUM_VERSION))) { !(await util.codeQlVersionAbove(codeql, CODEQL_MINIMUM_VERSION))) {
throw new Error(`Expected a CodeQL CLI with version at least ${CODEQL_MINIMUM_VERSION} but got version ${await codeql.getVersion()}`); throw new Error(`Expected a CodeQL CLI with version at least ${CODEQL_MINIMUM_VERSION} but got version ${await codeql.getVersion()}`);
} }
return codeql; return codeql;
} }
function packWithVersionToString(pack) {
return pack.version ? `${pack.packName}@${pack.version}` : pack.packName;
}
/** /**
* Gets the options for `path` of `options` as an array of extra option strings. * Gets the options for `path` of `options` as an array of extra option strings.
*/ */

File diff suppressed because one or more lines are too long

76
lib/codeql.test.js generated
View File

@@ -22,6 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.stubToolRunnerConstructor = void 0;
const path = __importStar(require("path")); const path = __importStar(require("path"));
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner")); const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
const toolcache = __importStar(require("@actions/tool-cache")); const toolcache = __importStar(require("@actions/tool-cache"));
@@ -30,6 +31,8 @@ const nock_1 = __importDefault(require("nock"));
const sinon = __importStar(require("sinon")); const sinon = __importStar(require("sinon"));
const codeql = __importStar(require("./codeql")); const codeql = __importStar(require("./codeql"));
const defaults = __importStar(require("./defaults.json")); const defaults = __importStar(require("./defaults.json"));
const feature_flags_1 = require("./feature-flags");
const languages_1 = require("./languages");
const logging_1 = require("./logging"); const logging_1 = require("./logging");
const testing_utils_1 = require("./testing-utils"); const testing_utils_1 = require("./testing-utils");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
@@ -55,7 +58,7 @@ ava_1.default.beforeEach(() => {
(0, nock_1.default)("https://example.com") (0, nock_1.default)("https://example.com")
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`)); t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
} }
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
@@ -68,12 +71,12 @@ ava_1.default.beforeEach(() => {
(0, nock_1.default)("https://example.com") (0, nock_1.default)("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
(0, nock_1.default)("https://example.com") (0, nock_1.default)("https://example.com")
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
t.assert(toolcache.find("CodeQL", "0.0.0-20200610")); t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
}); });
}); });
@@ -83,9 +86,9 @@ ava_1.default.beforeEach(() => {
(0, nock_1.default)("https://example.com") (0, nock_1.default)("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 1); t.is(cachedVersions.length, 1);
}); });
@@ -96,7 +99,7 @@ ava_1.default.beforeEach(() => {
(0, nock_1.default)("https://example.com") (0, nock_1.default)("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
const platform = process.platform === "win32" const platform = process.platform === "win32"
? "win64" ? "win64"
@@ -106,7 +109,7 @@ ava_1.default.beforeEach(() => {
(0, nock_1.default)("https://github.com") (0, nock_1.default)("https://github.com")
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`) .get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 2); t.is(cachedVersions.length, 2);
}); });
@@ -117,7 +120,7 @@ ava_1.default.beforeEach(() => {
(0, nock_1.default)("https://example.com") (0, nock_1.default)("https://example.com")
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`) .get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
t.assert(toolcache.find("CodeQL", "0.0.0-20200601")); t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
const platform = process.platform === "win32" const platform = process.platform === "win32"
? "win64" ? "win64"
@@ -127,7 +130,7 @@ ava_1.default.beforeEach(() => {
(0, nock_1.default)("https://github.com") (0, nock_1.default)("https://github.com")
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`) .get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 2); t.is(cachedVersions.length, 2);
}); });
@@ -155,7 +158,7 @@ ava_1.default.beforeEach(() => {
(0, nock_1.default)("https://example.githubenterprise.com") (0, nock_1.default)("https://example.githubenterprise.com")
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`) .get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`)); .replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, tmpDir, util.GitHubVariant.GHAE, (0, logging_1.getRunnerLogger)(true), false); await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, util.GitHubVariant.GHAE, (0, logging_1.getRunnerLogger)(true), false);
const cachedVersions = toolcache.findAllVersions("CodeQL"); const cachedVersions = toolcache.findAllVersions("CodeQL");
t.is(cachedVersions.length, 1); t.is(cachedVersions.length, 1);
}); });
@@ -223,16 +226,64 @@ ava_1.default.beforeEach(() => {
const runnerConstructorStub = stubToolRunnerConstructor(); const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting(); const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0"); sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
await codeqlObject.databaseInterpretResults("", [], "", "", "", ""); await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be absent, but it is present"); t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be absent, but it is present");
}); });
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => { (0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor(); const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting(); const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1"); sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
await codeqlObject.databaseInterpretResults("", [], "", "", "", ""); await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent"); t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent");
}); });
const stubConfig = {
languages: [languages_1.Language.cpp],
queries: {},
pathsIgnore: [],
paths: [],
originalUserInput: {},
tempDir: "",
codeQLCmd: "",
gitHubVersion: {
type: util.GitHubVariant.DOTCOM,
},
dbLocation: "",
packs: {},
debugMode: false,
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
injectedMlQueries: false,
};
(0, ava_1.default)("databaseInitCluster() Lua feature flag enabled, but old CLI", async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves("2.9.0");
await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.LuaTracerConfigEnabled]));
t.false(runnerConstructorStub.firstCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
t.false(runnerConstructorStub.firstCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
});
(0, ava_1.default)("databaseInitCluster() Lua feature flag disabled, with old CLI", async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves("2.9.0");
await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, feature_flags_1.createFeatureFlags)([]));
t.false(runnerConstructorStub.firstCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
t.false(runnerConstructorStub.firstCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
});
(0, ava_1.default)("databaseInitCluster() Lua feature flag enabled, compatible CLI", async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves("2.10.0");
await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.LuaTracerConfigEnabled]));
t.true(runnerConstructorStub.firstCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be present, but it is absent");
});
(0, ava_1.default)("databaseInitCluster() Lua feature flag disabled, compatible CLI", async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves("2.10.0");
await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, feature_flags_1.createFeatureFlags)([]));
t.true(runnerConstructorStub.firstCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be present, but it is absent");
});
function stubToolRunnerConstructor() { function stubToolRunnerConstructor() {
const runnerObjectStub = sinon.createStubInstance(toolrunner.ToolRunner); const runnerObjectStub = sinon.createStubInstance(toolrunner.ToolRunner);
runnerObjectStub.exec.resolves(0); runnerObjectStub.exec.resolves(0);
@@ -240,4 +291,5 @@ function stubToolRunnerConstructor() {
runnerConstructorStub.returns(runnerObjectStub); runnerConstructorStub.returns(runnerObjectStub);
return runnerConstructorStub; return runnerConstructorStub;
} }
exports.stubToolRunnerConstructor = stubToolRunnerConstructor;
//# sourceMappingURL=codeql.test.js.map //# sourceMappingURL=codeql.test.js.map

File diff suppressed because one or more lines are too long

165
lib/config-utils.js generated
View File

@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPacksRequireLanguage = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0; exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.validatePacksSpecification = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0;
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const yaml = __importStar(require("js-yaml")); const yaml = __importStar(require("js-yaml"));
@@ -118,29 +118,41 @@ const builtinSuites = ["security-extended", "security-and-quality"];
/** /**
* Determine the set of queries associated with suiteName's suites and add them to resultMap. * Determine the set of queries associated with suiteName's suites and add them to resultMap.
* Throws an error if suiteName is not a valid builtin suite. * Throws an error if suiteName is not a valid builtin suite.
* May inject ML queries, and the return value will declare if this was done.
*/ */
async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suiteName, featureFlags, configFile) { async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suiteName, featureFlags, configFile) {
var _a;
let injectedMlQueries = false;
const found = builtinSuites.find((suite) => suite === suiteName); const found = builtinSuites.find((suite) => suite === suiteName);
if (!found) { if (!found) {
throw new Error(getQueryUsesInvalid(configFile, suiteName)); throw new Error(getQueryUsesInvalid(configFile, suiteName));
} }
// If we're running the JavaScript security-extended analysis (or a superset of it) and the repo // If we're running the JavaScript security-extended analysis (or a superset of it), the repo is
// is opted into the ML-powered queries beta, then add the ML-powered query pack so that we run // opted into the ML-powered queries beta, and a user hasn't already added the ML-powered query
// the ML-powered queries. // pack, then add the ML-powered query pack so that we run ML-powered queries.
if (languages.includes("javascript") && if (
// Only run ML-powered queries on Windows if we have a CLI that supports it.
(process.platform !== "win32" ||
(await (0, util_1.codeQlVersionAbove)(codeQL, codeql_1.CODEQL_VERSION_ML_POWERED_QUERIES_WINDOWS))) &&
languages.includes("javascript") &&
(found === "security-extended" || found === "security-and-quality") && (found === "security-extended" || found === "security-and-quality") &&
!((_a = packs.javascript) === null || _a === void 0 ? void 0 : _a.some(isMlPoweredJsQueriesPack)) &&
(await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled)) && (await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled)) &&
(await (0, util_1.codeQlVersionAbove)(codeQL, codeql_1.CODEQL_VERSION_ML_POWERED_QUERIES))) { (await (0, util_1.codeQlVersionAbove)(codeQL, codeql_1.CODEQL_VERSION_ML_POWERED_QUERIES))) {
if (!packs.javascript) { if (!packs.javascript) {
packs.javascript = []; packs.javascript = [];
} }
packs.javascript.push({ packs.javascript.push(await (0, util_1.getMlPoweredJsQueriesPack)(codeQL));
packName: "codeql/javascript-experimental-atm-queries", injectedMlQueries = true;
version: "~0.0.2",
});
} }
const suites = languages.map((l) => `${l}-${suiteName}.qls`); const suites = languages.map((l) => `${l}-${suiteName}.qls`);
await runResolveQueries(codeQL, resultMap, suites, undefined); await runResolveQueries(codeQL, resultMap, suites, undefined);
return injectedMlQueries;
}
function isMlPoweredJsQueriesPack(pack) {
return (pack === util_1.ML_POWERED_JS_QUERIES_PACK_NAME ||
pack.startsWith(`${util_1.ML_POWERED_JS_QUERIES_PACK_NAME}@`) ||
pack.startsWith(`${util_1.ML_POWERED_JS_QUERIES_PACK_NAME}:`));
} }
/** /**
* Retrieve the set of queries at localQueryPath and add them to resultMap. * Retrieve the set of queries at localQueryPath and add them to resultMap.
@@ -197,6 +209,11 @@ async function addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetail
* parsing the 'uses' actions in the workflow file. So it can handle * parsing the 'uses' actions in the workflow file. So it can handle
* local paths starting with './', or references to remote repos, or * local paths starting with './', or references to remote repos, or
* a finite set of hardcoded terms for builtin suites. * a finite set of hardcoded terms for builtin suites.
*
* This may inject ML queries into the packs to use, and the return value will
* declare if this was done.
*
* @returns whether or not we injected ML queries into the packs
*/ */
async function parseQueryUses(languages, codeQL, resultMap, packs, queryUses, tempDir, workspacePath, apiDetails, featureFlags, logger, configFile) { async function parseQueryUses(languages, codeQL, resultMap, packs, queryUses, tempDir, workspacePath, apiDetails, featureFlags, logger, configFile) {
queryUses = queryUses.trim(); queryUses = queryUses.trim();
@@ -206,15 +223,15 @@ async function parseQueryUses(languages, codeQL, resultMap, packs, queryUses, te
// Check for the local path case before we start trying to parse the repository name // Check for the local path case before we start trying to parse the repository name
if (queryUses.startsWith("./")) { if (queryUses.startsWith("./")) {
await addLocalQueries(codeQL, resultMap, queryUses.slice(2), workspacePath, configFile); await addLocalQueries(codeQL, resultMap, queryUses.slice(2), workspacePath, configFile);
return; return false;
} }
// Check for one of the builtin suites // Check for one of the builtin suites
if (queryUses.indexOf("/") === -1 && queryUses.indexOf("@") === -1) { if (queryUses.indexOf("/") === -1 && queryUses.indexOf("@") === -1) {
await addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, queryUses, featureFlags, configFile); return await addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, queryUses, featureFlags, configFile);
return;
} }
// Otherwise, must be a reference to another repo // Otherwise, must be a reference to another repo
await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetails, logger, configFile); await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetails, logger, configFile);
return false;
} }
// Regex validating stars in paths or paths-ignore entries. // Regex validating stars in paths or paths-ignore entries.
// The intention is to only allow ** to appear when immediately // The intention is to only allow ** to appear when immediately
@@ -289,9 +306,8 @@ function getPathsInvalid(configFile) {
} }
exports.getPathsInvalid = getPathsInvalid; exports.getPathsInvalid = getPathsInvalid;
function getPacksRequireLanguage(lang, configFile) { function getPacksRequireLanguage(lang, configFile) {
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, `has "${lang}", but it is not one of the languages to analyze`); return getConfigFilePropertyError(configFile, PACKS_PROPERTY, `has "${lang}", but it is not a valid language.`);
} }
exports.getPacksRequireLanguage = getPacksRequireLanguage;
function getPacksInvalidSplit(configFile) { function getPacksInvalidSplit(configFile) {
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, "must split packages by language"); return getConfigFilePropertyError(configFile, PACKS_PROPERTY, "must split packages by language");
} }
@@ -423,12 +439,15 @@ async function getLanguages(codeQL, languagesInput, repository, apiDetails, logg
return parsedLanguages; return parsedLanguages;
} }
async function addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, resultMap, packs, tempDir, workspacePath, apiDetails, featureFlags, logger) { async function addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, resultMap, packs, tempDir, workspacePath, apiDetails, featureFlags, logger) {
let injectedMlQueries = false;
queriesInput = queriesInput.trim(); queriesInput = queriesInput.trim();
// "+" means "don't override config file" - see shouldAddConfigFileQueries // "+" means "don't override config file" - see shouldAddConfigFileQueries
queriesInput = queriesInput.replace(/^\+/, ""); queriesInput = queriesInput.replace(/^\+/, "");
for (const query of queriesInput.split(",")) { for (const query of queriesInput.split(",")) {
await parseQueryUses(languages, codeQL, resultMap, packs, query, tempDir, workspacePath, apiDetails, featureFlags, logger); const didInject = await parseQueryUses(languages, codeQL, resultMap, packs, query, tempDir, workspacePath, apiDetails, featureFlags, logger);
injectedMlQueries = injectedMlQueries || didInject;
} }
return injectedMlQueries;
} }
// Returns true if either no queries were provided in the workflow. // Returns true if either no queries were provided in the workflow.
// or if the queries in the workflow were provided in "additive" mode, // or if the queries in the workflow were provided in "additive" mode,
@@ -436,14 +455,14 @@ async function addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, r
// should instead be added in addition // should instead be added in addition
function shouldAddConfigFileQueries(queriesInput) { function shouldAddConfigFileQueries(queriesInput) {
if (queriesInput) { if (queriesInput) {
return queriesInput.trimStart().substr(0, 1) === "+"; return queriesInput.trimStart().slice(0, 1) === "+";
} }
return true; return true;
} }
/** /**
* Get the default config for when the user has not supplied one. * Get the default config for when the user has not supplied one.
*/ */
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) { async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
var _a; var _a;
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger); const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
const queries = {}; const queries = {};
@@ -455,8 +474,9 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
} }
await addDefaultQueries(codeQL, languages, queries); await addDefaultQueries(codeQL, languages, queries);
const packs = (_a = parsePacksFromInput(packsInput, languages)) !== null && _a !== void 0 ? _a : {}; const packs = (_a = parsePacksFromInput(packsInput, languages)) !== null && _a !== void 0 ? _a : {};
let injectedMlQueries = false;
if (queriesInput) { if (queriesInput) {
await addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureFlags, logger); injectedMlQueries = await addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureFlags, logger);
} }
return { return {
languages, languages,
@@ -466,20 +486,20 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
packs, packs,
originalUserInput: {}, originalUserInput: {},
tempDir, tempDir,
toolCacheDir,
codeQLCmd: codeQL.getPath(), codeQLCmd: codeQL.getPath(),
gitHubVersion, gitHubVersion,
dbLocation: dbLocationOrDefault(dbLocation, tempDir), dbLocation: dbLocationOrDefault(dbLocation, tempDir),
debugMode, debugMode,
debugArtifactName, debugArtifactName,
debugDatabaseName, debugDatabaseName,
injectedMlQueries,
}; };
} }
exports.getDefaultConfig = getDefaultConfig; exports.getDefaultConfig = getDefaultConfig;
/** /**
* Load the config from the given file. * Load the config from the given file.
*/ */
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) { async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
var _a; var _a;
let parsedYAML; let parsedYAML;
if (isLocal(configFile)) { if (isLocal(configFile)) {
@@ -520,13 +540,14 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
if (!disableDefaultQueries) { if (!disableDefaultQueries) {
await addDefaultQueries(codeQL, languages, queries); await addDefaultQueries(codeQL, languages, queries);
} }
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY]) !== null && _a !== void 0 ? _a : {}, packsInput, languages, configFile); const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY]) !== null && _a !== void 0 ? _a : {}, packsInput, languages, configFile, logger);
// If queries were provided using `with` in the action configuration, // If queries were provided using `with` in the action configuration,
// they should take precedence over the queries in the config file // they should take precedence over the queries in the config file
// unless they're prefixed with "+", in which case they supplement those // unless they're prefixed with "+", in which case they supplement those
// in the config file. // in the config file.
let injectedMlQueries = false;
if (queriesInput) { if (queriesInput) {
await addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureFlags, logger); injectedMlQueries = await addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureFlags, logger);
} }
if (shouldAddConfigFileQueries(queriesInput) && if (shouldAddConfigFileQueries(queriesInput) &&
QUERIES_PROPERTY in parsedYAML) { QUERIES_PROPERTY in parsedYAML) {
@@ -572,13 +593,13 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
packs, packs,
originalUserInput: parsedYAML, originalUserInput: parsedYAML,
tempDir, tempDir,
toolCacheDir,
codeQLCmd: codeQL.getPath(), codeQLCmd: codeQL.getPath(),
gitHubVersion, gitHubVersion,
dbLocation: dbLocationOrDefault(dbLocation, tempDir), dbLocation: dbLocationOrDefault(dbLocation, tempDir),
debugMode, debugMode,
debugArtifactName, debugArtifactName,
debugDatabaseName, debugDatabaseName,
injectedMlQueries,
}; };
} }
/** /**
@@ -592,7 +613,7 @@ const PACK_IDENTIFIER_PATTERN = (function () {
return new RegExp(`^${component}/${component}$`); return new RegExp(`^${component}/${component}$`);
})(); })();
// Exported for testing // Exported for testing
function parsePacksFromConfig(packsByLanguage, languages, configFile) { function parsePacksFromConfig(packsByLanguage, languages, configFile, logger) {
const packs = {}; const packs = {};
if (Array.isArray(packsByLanguage)) { if (Array.isArray(packsByLanguage)) {
if (languages.length === 1) { if (languages.length === 1) {
@@ -612,11 +633,19 @@ function parsePacksFromConfig(packsByLanguage, languages, configFile) {
throw new Error(getPacksInvalid(configFile)); throw new Error(getPacksInvalid(configFile));
} }
if (!languages.includes(lang)) { if (!languages.includes(lang)) {
throw new Error(getPacksRequireLanguage(lang, configFile)); // This particular language is not being analyzed in this run.
if (languages_1.Language[lang]) {
logger.info(`Ignoring packs for ${lang} since this language is not being analyzed in this run.`);
continue;
}
else {
// This language is invalid, probably a misspelling
throw new Error(getPacksRequireLanguage(configFile, lang));
}
} }
packs[lang] = []; packs[lang] = [];
for (const packStr of packsArr) { for (const packStr of packsArr) {
packs[lang].push(toPackWithVersion(packStr, configFile)); packs[lang].push(validatePacksSpecification(packStr, configFile));
} }
} }
return packs; return packs;
@@ -641,36 +670,84 @@ function parsePacksFromInput(packsInput, languages) {
} }
return { return {
[languages[0]]: packsInput.split(",").reduce((packs, pack) => { [languages[0]]: packsInput.split(",").reduce((packs, pack) => {
packs.push(toPackWithVersion(pack, "")); packs.push(validatePacksSpecification(pack, ""));
return packs; return packs;
}, []), }, []),
}; };
} }
function toPackWithVersion(packStr, configFile) { /**
* Validates that this package specification is syntactically correct.
* It may not point to any real package, but after this function returns
* without throwing, we are guaranteed that the package specification
* is roughly correct.
*
* The CLI itself will do a more thorough validation of the package
* specification.
*
* A package specification looks like this:
*
* `scope/name@version:path`
*
* Version and path are optional.
*
* @param packStr the package specification to verify.
* @param configFile Config file to use for error reporting
*/
function validatePacksSpecification(packStr, configFile) {
if (typeof packStr !== "string") { if (typeof packStr !== "string") {
throw new Error(getPacksStrInvalid(packStr, configFile)); throw new Error(getPacksStrInvalid(packStr, configFile));
} }
const nameWithVersion = packStr.trim().split("@"); packStr = packStr.trim();
let version; const atIndex = packStr.indexOf("@");
if (nameWithVersion.length > 2 || const colonIndex = packStr.indexOf(":", atIndex);
!PACK_IDENTIFIER_PATTERN.test(nameWithVersion[0])) { const packStart = 0;
const versionStart = atIndex + 1 || undefined;
const pathStart = colonIndex + 1 || undefined;
const packEnd = Math.min(atIndex > 0 ? atIndex : Infinity, colonIndex > 0 ? colonIndex : Infinity, packStr.length);
const versionEnd = versionStart
? Math.min(colonIndex > 0 ? colonIndex : Infinity, packStr.length)
: undefined;
const pathEnd = pathStart ? packStr.length : undefined;
const packName = packStr.slice(packStart, packEnd).trim();
const version = versionStart
? packStr.slice(versionStart, versionEnd).trim()
: undefined;
const packPath = pathStart
? packStr.slice(pathStart, pathEnd).trim()
: undefined;
if (!PACK_IDENTIFIER_PATTERN.test(packName)) {
throw new Error(getPacksStrInvalid(packStr, configFile)); throw new Error(getPacksStrInvalid(packStr, configFile));
} }
else if (nameWithVersion.length === 2) { if (version) {
version = semver.clean(nameWithVersion[1]) || undefined; try {
if (!version) { new semver.Range(version);
}
catch (e) {
// The range string is invalid. OK to ignore the caught error
throw new Error(getPacksStrInvalid(packStr, configFile)); throw new Error(getPacksStrInvalid(packStr, configFile));
} }
} }
return { if (packPath &&
packName: nameWithVersion[0].trim(), (path.isAbsolute(packPath) ||
version, // Permit using "/" instead of "\" on Windows
}; // Use `x.split(y).join(z)` as a polyfill for `x.replaceAll(y, z)` since
// if we used a regex we'd need to escape the path separator on Windows
// which seems more awkward.
path.normalize(packPath).split(path.sep).join("/") !==
packPath.split(path.sep).join("/"))) {
throw new Error(getPacksStrInvalid(packStr, configFile));
}
if (!packPath && pathStart) {
// 0 length path
throw new Error(getPacksStrInvalid(packStr, configFile));
}
return (packName + (version ? `@${version}` : "") + (packPath ? `:${packPath}` : ""));
} }
exports.validatePacksSpecification = validatePacksSpecification;
// exported for testing // exported for testing
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) { function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile, logger) {
const packsFromInput = parsePacksFromInput(rawPacksInput, languages); const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile); const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile, logger);
if (!packsFromInput) { if (!packsFromInput) {
return packsFomConfig; return packsFomConfig;
} }
@@ -704,16 +781,16 @@ function dbLocationOrDefault(dbLocation, tempDir) {
* This will parse the config from the user input if present, or generate * This will parse the config from the user input if present, or generate
* a default config. The parsed config is then stored to a known location. * a default config. The parsed config is then stored to a known location.
*/ */
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) { async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
var _a, _b, _c; var _a, _b, _c;
let config; let config;
// If no config file was provided create an empty one // If no config file was provided create an empty one
if (!configFile) { if (!configFile) {
logger.debug("No configuration file was provided"); logger.debug("No configuration file was provided");
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger); config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
} }
else { else {
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger); config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
} }
// The list of queries should not be empty for any language. If it is then // The list of queries should not be empty for any language. If it is then
// it is a user configuration error. // it is a user configuration error.

File diff suppressed because one or more lines are too long

352
lib/config-utils.test.js generated
View File

@@ -26,7 +26,6 @@ const fs = __importStar(require("fs"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const github = __importStar(require("@actions/github")); const github = __importStar(require("@actions/github"));
const ava_1 = __importDefault(require("ava")); const ava_1 = __importDefault(require("ava"));
const semver_1 = require("semver");
const sinon = __importStar(require("sinon")); const sinon = __importStar(require("sinon"));
const api = __importStar(require("./api-client")); const api = __importStar(require("./api-client"));
const codeql_1 = require("./codeql"); const codeql_1 = require("./codeql");
@@ -89,8 +88,8 @@ function mockListLanguages(languages) {
}; };
}, },
}); });
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger); const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger);
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger)); t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger));
}); });
}); });
(0, ava_1.default)("loading config saves config", async (t) => { (0, ava_1.default)("loading config saves config", async (t) => {
@@ -112,18 +111,21 @@ function mockListLanguages(languages) {
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir))); t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
// Sanity check that getConfig returns undefined before we have called initConfig // Sanity check that getConfig returns undefined before we have called initConfig
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined); t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger); const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger);
// The saved config file should now exist // The saved config file should now exist
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir))); t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
// And that same newly-initialised config should now be returned by getConfig // And that same newly-initialised config should now be returned by getConfig
const config2 = await configUtils.getConfig(tmpDir, logger); const config2 = await configUtils.getConfig(tmpDir, logger);
t.deepEqual(config1, config2); t.not(config2, undefined);
if (config2 !== undefined) {
t.deepEqual(config1, config2);
}
}); });
}); });
(0, ava_1.default)("load input outside of workspace", async (t) => { (0, ava_1.default)("load input outside of workspace", async (t) => {
return await util.withTmpDir(async (tmpDir) => { return await util.withTmpDir(async (tmpDir) => {
try { try {
await configUtils.initConfig(undefined, undefined, undefined, "../input", undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, "../input", undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@@ -136,7 +138,7 @@ function mockListLanguages(languages) {
// no filename given, just a repo // no filename given, just a repo
const configFile = "octo-org/codeql-config@main"; const configFile = "octo-org/codeql-config@main";
try { try {
await configUtils.initConfig(undefined, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@@ -150,7 +152,7 @@ function mockListLanguages(languages) {
const configFile = "input"; const configFile = "input";
t.false(fs.existsSync(path.join(tmpDir, configFile))); t.false(fs.existsSync(path.join(tmpDir, configFile)));
try { try {
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@@ -210,7 +212,6 @@ function mockListLanguages(languages) {
paths: ["c/d"], paths: ["c/d"],
}, },
tempDir: tmpDir, tempDir: tmpDir,
toolCacheDir: tmpDir,
codeQLCmd: codeQL.getPath(), codeQLCmd: codeQL.getPath(),
gitHubVersion, gitHubVersion,
dbLocation: path.resolve(tmpDir, "codeql_databases"), dbLocation: path.resolve(tmpDir, "codeql_databases"),
@@ -218,10 +219,11 @@ function mockListLanguages(languages) {
debugMode: false, debugMode: false,
debugArtifactName: "my-artifact", debugArtifactName: "my-artifact",
debugDatabaseName: "my-db", debugDatabaseName: "my-db",
injectedMlQueries: false,
}; };
const languages = "javascript"; const languages = "javascript";
const configFilePath = createConfigFile(inputFileContents, tmpDir); const configFilePath = createConfigFile(inputFileContents, tmpDir);
const actualConfig = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "my-artifact", "my-db", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const actualConfig = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "my-artifact", "my-db", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
// Should exactly equal the object we constructed earlier // Should exactly equal the object we constructed earlier
t.deepEqual(actualConfig, expectedConfig); t.deepEqual(actualConfig, expectedConfig);
}); });
@@ -257,7 +259,7 @@ function mockListLanguages(languages) {
fs.mkdirSync(path.join(tmpDir, "foo")); fs.mkdirSync(path.join(tmpDir, "foo"));
const languages = "javascript"; const languages = "javascript";
const configFilePath = createConfigFile(inputFileContents, tmpDir); const configFilePath = createConfigFile(inputFileContents, tmpDir);
await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolve queries was called correctly // Check resolve queries was called correctly
t.deepEqual(resolveQueriesArgs.length, 1); t.deepEqual(resolveQueriesArgs.length, 1);
t.deepEqual(resolveQueriesArgs[0].queries, [ t.deepEqual(resolveQueriesArgs[0].queries, [
@@ -300,18 +302,18 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly // Check resolveQueries was called correctly
// It'll be called once for the default queries // It'll be called once for the default queries
// and once for `./foo` from the config file. // and once for `./foo` from the config file.
t.deepEqual(resolveQueriesArgs.length, 2); t.deepEqual(resolveQueriesArgs.length, 2);
t.deepEqual(resolveQueriesArgs[1].queries.length, 1); t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
t.regex(resolveQueriesArgs[1].queries[0], /.*\/foo$/); t.true(resolveQueriesArgs[1].queries[0].endsWith(`${path.sep}foo`));
// Now check that the end result contains the default queries and the query from config // Now check that the end result contains the default queries and the query from config
t.deepEqual(config.queries["javascript"].builtin.length, 1); t.deepEqual(config.queries["javascript"].builtin.length, 1);
t.deepEqual(config.queries["javascript"].custom.length, 1); t.deepEqual(config.queries["javascript"].custom.length, 1);
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/); t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/foo$/); t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}foo`));
}); });
}); });
(0, ava_1.default)("Queries from config file can be overridden in workflow file", async (t) => { (0, ava_1.default)("Queries from config file can be overridden in workflow file", async (t) => {
@@ -333,18 +335,18 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly // Check resolveQueries was called correctly
// It'll be called once for the default queries and once for `./override`, // It'll be called once for the default queries and once for `./override`,
// but won't be called for './foo' from the config file. // but won't be called for './foo' from the config file.
t.deepEqual(resolveQueriesArgs.length, 2); t.deepEqual(resolveQueriesArgs.length, 2);
t.deepEqual(resolveQueriesArgs[1].queries.length, 1); t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
t.regex(resolveQueriesArgs[1].queries[0], /.*\/override$/); t.true(resolveQueriesArgs[1].queries[0].endsWith(`${path.sep}override`));
// Now check that the end result contains only the default queries and the override query // Now check that the end result contains only the default queries and the override query
t.deepEqual(config.queries["javascript"].builtin.length, 1); t.deepEqual(config.queries["javascript"].builtin.length, 1);
t.deepEqual(config.queries["javascript"].custom.length, 1); t.deepEqual(config.queries["javascript"].custom.length, 1);
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/); t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override$/); t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}override`));
}); });
}); });
(0, ava_1.default)("Queries in workflow file can be used in tandem with the 'disable default queries' option", async (t) => { (0, ava_1.default)("Queries in workflow file can be used in tandem with the 'disable default queries' option", async (t) => {
@@ -365,17 +367,17 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly // Check resolveQueries was called correctly
// It'll be called once for `./workflow-query`, // It'll be called once for `./workflow-query`,
// but won't be called for the default one since that was disabled // but won't be called for the default one since that was disabled
t.deepEqual(resolveQueriesArgs.length, 1); t.deepEqual(resolveQueriesArgs.length, 1);
t.deepEqual(resolveQueriesArgs[0].queries.length, 1); t.deepEqual(resolveQueriesArgs[0].queries.length, 1);
t.regex(resolveQueriesArgs[0].queries[0], /.*\/workflow-query$/); t.true(resolveQueriesArgs[0].queries[0].endsWith(`${path.sep}workflow-query`));
// Now check that the end result contains only the workflow query, and not the default one // Now check that the end result contains only the workflow query, and not the default one
t.deepEqual(config.queries["javascript"].builtin.length, 0); t.deepEqual(config.queries["javascript"].builtin.length, 0);
t.deepEqual(config.queries["javascript"].custom.length, 1); t.deepEqual(config.queries["javascript"].custom.length, 1);
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/workflow-query$/); t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}workflow-query`));
}); });
}); });
(0, ava_1.default)("Multiple queries can be specified in workflow file, no config file required", async (t) => { (0, ava_1.default)("Multiple queries can be specified in workflow file, no config file required", async (t) => {
@@ -391,21 +393,21 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly: // Check resolveQueries was called correctly:
// It'll be called once for the default queries, // It'll be called once for the default queries,
// and then once for each of the two queries from the workflow // and then once for each of the two queries from the workflow
t.deepEqual(resolveQueriesArgs.length, 3); t.deepEqual(resolveQueriesArgs.length, 3);
t.deepEqual(resolveQueriesArgs[1].queries.length, 1); t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
t.deepEqual(resolveQueriesArgs[2].queries.length, 1); t.deepEqual(resolveQueriesArgs[2].queries.length, 1);
t.regex(resolveQueriesArgs[1].queries[0], /.*\/override1$/); t.true(resolveQueriesArgs[1].queries[0].endsWith(`${path.sep}override1`));
t.regex(resolveQueriesArgs[2].queries[0], /.*\/override2$/); t.true(resolveQueriesArgs[2].queries[0].endsWith(`${path.sep}override2`));
// Now check that the end result contains both the queries from the workflow, as well as the defaults // Now check that the end result contains both the queries from the workflow, as well as the defaults
t.deepEqual(config.queries["javascript"].builtin.length, 1); t.deepEqual(config.queries["javascript"].builtin.length, 1);
t.deepEqual(config.queries["javascript"].custom.length, 2); t.deepEqual(config.queries["javascript"].custom.length, 2);
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/); t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override1$/); t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}override1`));
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/override2$/); t.true(config.queries["javascript"].custom[1].queries[0].endsWith(`${path.sep}override2`));
}); });
}); });
(0, ava_1.default)("Queries in workflow file can be added to the set of queries without overriding config file", async (t) => { (0, ava_1.default)("Queries in workflow file can be added to the set of queries without overriding config file", async (t) => {
@@ -430,25 +432,25 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
const languages = "javascript"; const languages = "javascript";
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
// Check resolveQueries was called correctly // Check resolveQueries was called correctly
// It'll be called once for the default queries, // It'll be called once for the default queries,
// once for each of additional1 and additional2, // once for each of additional1 and additional2,
// and once for './foo' from the config file // and once for './foo' from the config file
t.deepEqual(resolveQueriesArgs.length, 4); t.deepEqual(resolveQueriesArgs.length, 4);
t.deepEqual(resolveQueriesArgs[1].queries.length, 1); t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
t.regex(resolveQueriesArgs[1].queries[0], /.*\/additional1$/); t.true(resolveQueriesArgs[1].queries[0].endsWith(`${path.sep}additional1`));
t.deepEqual(resolveQueriesArgs[2].queries.length, 1); t.deepEqual(resolveQueriesArgs[2].queries.length, 1);
t.regex(resolveQueriesArgs[2].queries[0], /.*\/additional2$/); t.true(resolveQueriesArgs[2].queries[0].endsWith(`${path.sep}additional2`));
t.deepEqual(resolveQueriesArgs[3].queries.length, 1); t.deepEqual(resolveQueriesArgs[3].queries.length, 1);
t.regex(resolveQueriesArgs[3].queries[0], /.*\/foo$/); t.true(resolveQueriesArgs[3].queries[0].endsWith(`${path.sep}foo`));
// Now check that the end result contains all the queries // Now check that the end result contains all the queries
t.deepEqual(config.queries["javascript"].builtin.length, 1); t.deepEqual(config.queries["javascript"].builtin.length, 1);
t.deepEqual(config.queries["javascript"].custom.length, 3); t.deepEqual(config.queries["javascript"].custom.length, 3);
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/); t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/additional1$/); t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}additional1`));
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/additional2$/); t.true(config.queries["javascript"].custom[1].queries[0].endsWith(`${path.sep}additional2`));
t.regex(config.queries["javascript"].custom[2].queries[0], /.*\/foo$/); t.true(config.queries["javascript"].custom[2].queries[0].endsWith(`${path.sep}foo`));
}); });
}); });
(0, ava_1.default)("Invalid queries in workflow file handled correctly", async (t) => { (0, ava_1.default)("Invalid queries in workflow file handled correctly", async (t) => {
@@ -469,7 +471,7 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
try { try {
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, queries, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
t.fail("initConfig did not throw error"); t.fail("initConfig did not throw error");
} }
catch (err) { catch (err) {
@@ -512,7 +514,7 @@ function queriesToResolvedQueryForm(queries) {
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true }); fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
const configFile = "octo-org/codeql-config/config.yaml@main"; const configFile = "octo-org/codeql-config/config.yaml@main";
const languages = "javascript"; const languages = "javascript";
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
t.assert(spyGetContents.called); t.assert(spyGetContents.called);
}); });
}); });
@@ -522,7 +524,7 @@ function queriesToResolvedQueryForm(queries) {
mockGetContents(dummyResponse); mockGetContents(dummyResponse);
const repoReference = "octo-org/codeql-config/config.yaml@main"; const repoReference = "octo-org/codeql-config/config.yaml@main";
try { try {
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@@ -538,7 +540,7 @@ function queriesToResolvedQueryForm(queries) {
mockGetContents(dummyResponse); mockGetContents(dummyResponse);
const repoReference = "octo-org/codeql-config/config.yaml@main"; const repoReference = "octo-org/codeql-config/config.yaml@main";
try { try {
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@@ -555,7 +557,7 @@ function queriesToResolvedQueryForm(queries) {
}, },
}); });
try { try {
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@@ -567,7 +569,7 @@ function queriesToResolvedQueryForm(queries) {
return await util.withTmpDir(async (tmpDir) => { return await util.withTmpDir(async (tmpDir) => {
const languages = "rubbish,english"; const languages = "rubbish,english";
try { try {
await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@@ -595,14 +597,9 @@ function queriesToResolvedQueryForm(queries) {
const configFile = path.join(tmpDir, "codeql-config.yaml"); const configFile = path.join(tmpDir, "codeql-config.yaml");
fs.writeFileSync(configFile, inputFileContents); fs.writeFileSync(configFile, inputFileContents);
const languages = "javascript"; const languages = "javascript";
const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
t.deepEqual(packs, { t.deepEqual(packs, {
[languages_1.Language.javascript]: [ [languages_1.Language.javascript]: ["a/b@1.2.3"],
{
packName: "a/b",
version: (0, semver_1.clean)("1.2.3"),
},
],
}); });
}); });
}); });
@@ -634,20 +631,10 @@ function queriesToResolvedQueryForm(queries) {
fs.writeFileSync(configFile, inputFileContents); fs.writeFileSync(configFile, inputFileContents);
fs.mkdirSync(path.join(tmpDir, "foo")); fs.mkdirSync(path.join(tmpDir, "foo"));
const languages = "javascript,python,cpp"; const languages = "javascript,python,cpp";
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
t.deepEqual(packs, { t.deepEqual(packs, {
[languages_1.Language.javascript]: [ [languages_1.Language.javascript]: ["a/b@1.2.3"],
{ [languages_1.Language.python]: ["c/d@1.2.3"],
packName: "a/b",
version: (0, semver_1.clean)("1.2.3"),
},
],
[languages_1.Language.python]: [
{
packName: "c/d",
version: (0, semver_1.clean)("1.2.3"),
},
],
}); });
t.deepEqual(queries, { t.deepEqual(queries, {
cpp: { cpp: {
@@ -687,7 +674,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
const inputFile = path.join(tmpDir, configFile); const inputFile = path.join(tmpDir, configFile);
fs.writeFileSync(inputFile, inputFileContents, "utf8"); fs.writeFileSync(inputFile, inputFileContents, "utf8");
try { try {
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true)); await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
throw new Error("initConfig did not throw error"); throw new Error("initConfig did not throw error");
} }
catch (err) { catch (err) {
@@ -760,160 +747,197 @@ const invalidPaths = ["a/***/b", "a/**b", "a/b**", "**"];
/** /**
* Test macro for ensuring the packs block is valid * Test macro for ensuring the packs block is valid
*/ */
function parsePacksMacro(t, packsByLanguage, languages, expected) { const parsePacksMacro = ava_1.default.macro({
t.deepEqual(configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"), expected); exec: (t, packsByLanguage, languages, expected) => t.deepEqual(configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b", mockLogger), expected),
} title: (providedTitle = "") => `Parse Packs: ${providedTitle}`,
parsePacksMacro.title = (providedTitle) => `Parse Packs: ${providedTitle}`; });
/** /**
* Test macro for testing when the packs block is invalid * Test macro for testing when the packs block is invalid
*/ */
function parsePacksErrorMacro(t, packsByLanguage, languages, expected) { const parsePacksErrorMacro = ava_1.default.macro({
t.throws(() => { exec: (t, packsByLanguage, languages, expected) => t.throws(() => configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b", {}), {
configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b");
}, {
message: expected, message: expected,
}); }),
} title: (providedTitle = "") => `Parse Packs Error: ${providedTitle}`,
parsePacksErrorMacro.title = (providedTitle) => `Parse Packs Error: ${providedTitle}`; });
/** /**
* Test macro for testing when the packs block is invalid * Test macro for testing when the packs block is invalid
*/ */
function invalidPackNameMacro(t, name) { const invalidPackNameMacro = ava_1.default.macro({
parsePacksErrorMacro(t, { [languages_1.Language.cpp]: [name] }, [languages_1.Language.cpp], new RegExp(`The configuration file "/a/b" is invalid: property "packs" "${name}" is not a valid pack`)); exec: (t, name) => parsePacksErrorMacro.exec(t, { [languages_1.Language.cpp]: [name] }, [languages_1.Language.cpp], new RegExp(`The configuration file "/a/b" is invalid: property "packs" "${name}" is not a valid pack`)),
} title: (_providedTitle, arg) => `Invalid pack string: ${arg}`,
invalidPackNameMacro.title = (_, arg) => `Invalid pack string: ${arg}`; });
(0, ava_1.default)("no packs", parsePacksMacro, {}, [], {}); (0, ava_1.default)("no packs", parsePacksMacro, {}, [], {});
(0, ava_1.default)("two packs", parsePacksMacro, ["a/b", "c/d@1.2.3"], [languages_1.Language.cpp], { (0, ava_1.default)("two packs", parsePacksMacro, ["a/b", "c/d@1.2.3"], [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [ [languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
{ packName: "a/b", version: undefined },
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
],
}); });
(0, ava_1.default)("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], { (0, ava_1.default)("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [ [languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
{ packName: "a/b", version: undefined },
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
],
}); });
(0, ava_1.default)("two packs with language", parsePacksMacro, { (0, ava_1.default)("two packs with language", parsePacksMacro, {
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"], [languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"], [languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
}, [languages_1.Language.cpp, languages_1.Language.java, languages_1.Language.csharp], { }, [languages_1.Language.cpp, languages_1.Language.java, languages_1.Language.csharp], {
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
});
(0, ava_1.default)("two packs with unused language in config", parsePacksMacro, {
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
}, [languages_1.Language.cpp, languages_1.Language.csharp], {
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
});
(0, ava_1.default)("packs with other valid names", parsePacksMacro, [
// ranges are ok
"c/d@1.0",
"c/d@~1.0.0",
"c/d@~1.0.0:a/b",
"c/d@~1.0.0+abc:a/b",
"c/d@~1.0.0-abc:a/b",
"c/d:a/b",
// whitespace is removed
" c/d @ ~1.0.0 : b.qls ",
// and it is retained within a path
" c/d @ ~1.0.0 : b/a path with/spaces.qls ",
// this is valid. the path is '@'. It will probably fail when passed to the CLI
"c/d@1.2.3:@",
// this is valid, too. It will fail if it doesn't match a path
// (globbing is not done)
"c/d@1.2.3:+*)_(",
], [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [ [languages_1.Language.cpp]: [
{ packName: "a/b", version: undefined }, "c/d@1.0",
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") }, "c/d@~1.0.0",
], "c/d@~1.0.0:a/b",
[languages_1.Language.java]: [ "c/d@~1.0.0+abc:a/b",
{ packName: "d/e", version: undefined }, "c/d@~1.0.0-abc:a/b",
{ packName: "f/g", version: (0, semver_1.clean)("1.2.3") }, "c/d:a/b",
"c/d@~1.0.0:b.qls",
"c/d@~1.0.0:b/a path with/spaces.qls",
"c/d@1.2.3:@",
"c/d@1.2.3:+*)_(",
], ],
}); });
(0, ava_1.default)("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/); (0, ava_1.default)("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
(0, ava_1.default)("invalid language", parsePacksErrorMacro, { [languages_1.Language.java]: ["c/d"] }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" has "java", but it is not one of the languages to analyze/);
(0, ava_1.default)("not an array", parsePacksErrorMacro, { [languages_1.Language.cpp]: "c/d" }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/); (0, ava_1.default)("not an array", parsePacksErrorMacro, { [languages_1.Language.cpp]: "c/d" }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/);
(0, ava_1.default)(invalidPackNameMacro, "c"); // all packs require at least a scope and a name (0, ava_1.default)(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
(0, ava_1.default)(invalidPackNameMacro, "c-/d"); (0, ava_1.default)(invalidPackNameMacro, "c-/d");
(0, ava_1.default)(invalidPackNameMacro, "-c/d"); (0, ava_1.default)(invalidPackNameMacro, "-c/d");
(0, ava_1.default)(invalidPackNameMacro, "c/d_d"); (0, ava_1.default)(invalidPackNameMacro, "c/d_d");
(0, ava_1.default)(invalidPackNameMacro, "c/d@x"); (0, ava_1.default)(invalidPackNameMacro, "c/d@@");
(0, ava_1.default)(invalidPackNameMacro, "c/d@1.0.0:");
(0, ava_1.default)(invalidPackNameMacro, "c/d:");
(0, ava_1.default)(invalidPackNameMacro, "c/d:/a");
(0, ava_1.default)(invalidPackNameMacro, "@1.0.0:a");
(0, ava_1.default)(invalidPackNameMacro, "c/d@../a");
(0, ava_1.default)(invalidPackNameMacro, "c/d@b/../a");
(0, ava_1.default)(invalidPackNameMacro, "c/d:z@1");
/** /**
* Test macro for testing the packs block and the packs input * Test macro for testing the packs block and the packs input
*/ */
function parseInputAndConfigMacro(t, packsFromConfig, packsFromInput, languages, expected) { function parseInputAndConfigMacro(t, packsFromConfig, packsFromInput, languages, expected) {
t.deepEqual(configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b"), expected); t.deepEqual(configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b", mockLogger), expected);
} }
parseInputAndConfigMacro.title = (providedTitle) => `Parse Packs input and config: ${providedTitle}`; parseInputAndConfigMacro.title = (providedTitle) => `Parse Packs input and config: ${providedTitle}`;
const mockLogger = {
info: (message) => {
console.log(message);
},
};
function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, languages, expected) { function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, languages, expected) {
t.throws(() => { t.throws(() => {
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b"); configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b", mockLogger);
}, { }, {
message: expected, message: expected,
}); });
} }
parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`; parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`;
(0, ava_1.default)("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], { (0, ava_1.default)("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [{ packName: "c/d", version: undefined }], [languages_1.Language.cpp]: ["c/d"],
}); });
(0, ava_1.default)("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], { (0, ava_1.default)("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [ [languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
{ packName: "a/b", version: undefined },
{ packName: "c/d", version: "1.2.3" },
],
}); });
(0, ava_1.default)("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], { (0, ava_1.default)("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [ [languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
{ packName: "a/b", version: undefined },
{ packName: "c/d", version: "1.2.3" },
],
}); });
(0, ava_1.default)("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], { (0, ava_1.default)("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [ [languages_1.Language.cpp]: ["a/b", "c/d"],
{ packName: "a/b", version: undefined },
{ packName: "c/d", version: undefined },
],
}); });
(0, ava_1.default)("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], { (0, ava_1.default)("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [ [languages_1.Language.cpp]: ["e/f", "g/h@1.2.3"],
{ packName: "e/f", version: undefined },
{ packName: "g/h", version: "1.2.3" },
],
}); });
(0, ava_1.default)("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], { (0, ava_1.default)("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [ [languages_1.Language.cpp]: ["e/f", "g/h@1.2.3", "a/b", "c/d"],
{ packName: "e/f", version: undefined },
{ packName: "g/h", version: "1.2.3" },
{ packName: "a/b", version: undefined },
{ packName: "c/d", version: undefined },
],
}); });
(0, ava_1.default)("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/); (0, ava_1.default)("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
(0, ava_1.default)("input with two languages", parseInputAndConfigErrorMacro, {}, "c/d", [languages_1.Language.cpp, languages_1.Language.csharp], /multi-language analysis/); (0, ava_1.default)("input with two languages", parseInputAndConfigErrorMacro, {}, "c/d", [languages_1.Language.cpp, languages_1.Language.csharp], /multi-language analysis/);
(0, ava_1.default)("input with + only", parseInputAndConfigErrorMacro, {}, " + ", [languages_1.Language.cpp], /remove the '\+'/); (0, ava_1.default)("input with + only", parseInputAndConfigErrorMacro, {}, " + ", [languages_1.Language.cpp], /remove the '\+'/);
(0, ava_1.default)("input with invalid pack name", parseInputAndConfigErrorMacro, {}, " xxx", [languages_1.Language.cpp], /"xxx" is not a valid pack/); (0, ava_1.default)("input with invalid pack name", parseInputAndConfigErrorMacro, {}, " xxx", [languages_1.Language.cpp], /"xxx" is not a valid pack/);
async function mlPoweredQueriesMacro(t, codeQLVersion, isMlPoweredQueriesFlagEnabled, queriesInput, shouldRunMlPoweredQueries) { const mlPoweredQueriesMacro = ava_1.default.macro({
return await util.withTmpDir(async (tmpDir) => { exec: async (t, codeQLVersion, isMlPoweredQueriesFlagEnabled, packsInput, queriesInput, expectedVersionString) => {
const codeQL = (0, codeql_1.setCodeQL)({ return await util.withTmpDir(async (tmpDir) => {
async getVersion() { const codeQL = (0, codeql_1.setCodeQL)({
return codeQLVersion; async getVersion() {
}, return codeQLVersion;
async resolveQueries() { },
return { async resolveQueries() {
byLanguage: { return {
javascript: { "fake-query.ql": {} }, byLanguage: {
}, javascript: { "fake-query.ql": {} },
noDeclaredLanguage: {}, },
multipleDeclaredLanguages: {}, noDeclaredLanguage: {},
}; multipleDeclaredLanguages: {},
}, };
}); },
const { packs } = await configUtils.initConfig("javascript", queriesInput, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)(isMlPoweredQueriesFlagEnabled
? [feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled]
: []), (0, logging_1.getRunnerLogger)(true));
if (shouldRunMlPoweredQueries) {
t.deepEqual(packs, {
[languages_1.Language.javascript]: [
{
packName: "codeql/javascript-experimental-atm-queries",
version: "~0.0.2",
},
],
}); });
} const { packs } = await configUtils.initConfig("javascript", queriesInput, packsInput, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)(isMlPoweredQueriesFlagEnabled
else { ? [feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled]
t.deepEqual(packs, {}); : []), (0, logging_1.getRunnerLogger)(true));
} if (expectedVersionString !== undefined) {
}); t.deepEqual(packs, {
} [languages_1.Language.javascript]: [
mlPoweredQueriesMacro.title = (_providedTitle, codeQLVersion, isMlPoweredQueriesFlagEnabled, queriesInput, shouldRunMlPoweredQueries) => { `codeql/javascript-experimental-atm-queries@${expectedVersionString}`,
const queriesInputDescription = queriesInput ],
? `'queries: ${queriesInput}'` });
: "default config"; }
return `ML-powered queries ${shouldRunMlPoweredQueries ? "are" : "aren't"} loaded for ${queriesInputDescription} using CLI v${codeQLVersion} when feature flag is ${isMlPoweredQueriesFlagEnabled ? "enabled" : "disabled"}`; else {
}; t.deepEqual(packs, {});
// macro, isMlPoweredQueriesFlagEnabled, queriesInput, shouldRunMlPoweredQueries }
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.4", true, "security-extended", false); });
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", false, "security-extended", false); },
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, false); title: (_providedTitle, codeQLVersion, isMlPoweredQueriesFlagEnabled, packsInput, queriesInput, expectedVersionString) => `ML-powered queries ${expectedVersionString !== undefined
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, "security-extended", true); ? `${expectedVersionString} are`
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, "security-and-quality", true); : "aren't"} loaded for packs: ${packsInput}, queries: ${queriesInput} using CLI v${codeQLVersion} when feature flag is ${isMlPoweredQueriesFlagEnabled ? "enabled" : "disabled"}`,
});
// macro, codeQLVersion, isMlPoweredQueriesFlagEnabled, packsInput, queriesInput, expectedVersionString
// Test that ML-powered queries aren't run on v2.7.4 of the CLI.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.4", true, undefined, "security-extended", undefined);
// Test that ML-powered queries aren't run when the feature flag is off.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", false, undefined, "security-extended", undefined);
// Test that the ~0.1.0 version of ML-powered queries is run on v2.8.3 of the CLI.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.8.3", true, undefined, "security-extended", process.platform === "win32" ? undefined : "~0.1.0");
// Test that ML-powered queries aren't run when the user hasn't specified that we should run the
// `security-extended` or `security-and-quality` query suite.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, undefined, undefined);
// Test that ML-powered queries are run on non-Windows platforms running `security-extended` on
// versions of the CodeQL CLI prior to 2.9.0.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.8.5", true, undefined, "security-extended", process.platform === "win32" ? undefined : "~0.2.0");
// Test that ML-powered queries are run on non-Windows platforms running `security-and-quality` on
// versions of the CodeQL CLI prior to 2.9.0.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.8.5", true, undefined, "security-and-quality", process.platform === "win32" ? undefined : "~0.2.0");
// Test that ML-powered queries are run on all platforms running `security-extended` on CodeQL CLI
// 2.9.0+.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.0", true, undefined, "security-extended", "~0.2.0");
// Test that ML-powered queries are run on all platforms running `security-and-quality` on CodeQL
// CLI 2.9.0+.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.0", true, undefined, "security-and-quality", "~0.2.0");
// Test that we don't inject an ML-powered query pack if the user has already specified one.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.0", true, "codeql/javascript-experimental-atm-queries@0.0.1", "security-and-quality", "0.0.1");
// Test that ML-powered queries are run on all platforms running `security-extended` on CodeQL
// CLI 2.9.3+.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.3", true, undefined, "security-extended", "~0.3.0");
// Test that ML-powered queries are run on all platforms running `security-and-quality` on CodeQL
// CLI 2.9.3+.
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.3", true, undefined, "security-and-quality", "~0.3.0");
//# sourceMappingURL=config-utils.test.js.map //# sourceMappingURL=config-utils.test.js.map

File diff suppressed because one or more lines are too long

39
lib/database-upload.js generated
View File

@@ -24,10 +24,9 @@ const fs = __importStar(require("fs"));
const actionsUtil = __importStar(require("./actions-util")); const actionsUtil = __importStar(require("./actions-util"));
const api_client_1 = require("./api-client"); const api_client_1 = require("./api-client");
const codeql_1 = require("./codeql"); const codeql_1 = require("./codeql");
const feature_flags_1 = require("./feature-flags");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
const util_1 = require("./util"); const util_1 = require("./util");
async function uploadDatabases(repositoryNwo, config, featureFlags, apiDetails, logger) { async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
if (actionsUtil.getRequiredInput("upload-database") !== "true") { if (actionsUtil.getRequiredInput("upload-database") !== "true") {
logger.debug("Database upload disabled in workflow. Skipping upload."); logger.debug("Database upload disabled in workflow. Skipping upload.");
return; return;
@@ -42,13 +41,8 @@ async function uploadDatabases(repositoryNwo, config, featureFlags, apiDetails,
logger.debug("Not analyzing default branch. Skipping upload."); logger.debug("Not analyzing default branch. Skipping upload.");
return; return;
} }
if (!(await featureFlags.getValue(feature_flags_1.FeatureFlag.DatabaseUploadsEnabled))) {
logger.debug("Repository is not opted in to database uploads. Skipping upload.");
return;
}
const client = (0, api_client_1.getApiClient)(apiDetails); const client = (0, api_client_1.getApiClient)(apiDetails);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd); const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
const useUploadDomain = await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled);
for (const language of config.languages) { for (const language of config.languages) {
// Upload the database bundle. // Upload the database bundle.
// Although we are uploading arbitrary file contents to the API, it's worth // Although we are uploading arbitrary file contents to the API, it's worth
@@ -56,26 +50,17 @@ async function uploadDatabases(repositoryNwo, config, featureFlags, apiDetails,
// This API method is available to anyone with write access to the repo. // This API method is available to anyone with write access to the repo.
const payload = fs.readFileSync(await (0, util_1.bundleDb)(config, language, codeql, language)); const payload = fs.readFileSync(await (0, util_1.bundleDb)(config, language, codeql, language));
try { try {
if (useUploadDomain) { await client.request(`POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name`, {
await client.request(`POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name`, { owner: repositoryNwo.owner,
owner: repositoryNwo.owner, repo: repositoryNwo.repo,
repo: repositoryNwo.repo, language,
language, name: `${language}-database`,
name: `${language}-database`, data: payload,
data: payload, headers: {
headers: { authorization: `token ${apiDetails.auth}`,
authorization: `token ${apiDetails.auth}`, "Content-Type": "application/zip",
}, },
}); });
}
else {
await client.request(`PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language`, {
owner: repositoryNwo.owner,
repo: repositoryNwo.repo,
language,
data: payload,
});
}
logger.debug(`Successfully uploaded database for ${language}`); logger.debug(`Successfully uploaded database for ${language}`);
} }
catch (e) { catch (e) {

View File

@@ -1 +1 @@
{"version":3,"file":"database-upload.js","sourceRoot":"","sources":["../src/database-upload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,4DAA8C;AAC9C,6CAA8D;AAC9D,qCAAqC;AAErC,mDAA4D;AAG5D,6CAA+B;AAC/B,iCAAkC;AAE3B,KAAK,UAAU,eAAe,CACnC,aAA4B,EAC5B,MAAc,EACd,YAA0B,EAC1B,UAA4B,EAC5B,MAAc;IAEd,IAAI,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,KAAK,MAAM,EAAE;QAC9D,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACvE,OAAO;KACR;IAED,iDAAiD;IACjD,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;QAC3D,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,OAAO;KACR;IAED,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,wBAAwB,EAAE,CAAC,EAAE;QACnD,4EAA4E;QAC5E,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO;KACR;IAED,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,QAAQ,CAAC,2BAAW,CAAC,sBAAsB,CAAC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C;QACF,IAAI;YACF,MAAM,MAAM,CAAC,OAAO,CAClB,wGAAwG,EACxG;gBACE,KAAK,EAAE,aAAa,CAAC,KAAK;gBAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;gBACxB,QAAQ;gBACR,IAAI,EAAE,GAAG,QAAQ,WAAW;gBAC5B,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE;oBACP,aAAa,EAAE,SAAS,UAAU,CAAC,IAAI,EAAE;oBACzC,cAAc,EAAE,iBAAiB;iBAClC;aACF,CACF,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,sCAAsC,QAAQ,EAAE,CAAC,CAAC;SAChE;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,4CAA4C;YAC5C,MAAM,CAAC,OAAO,CAAC,iCAAiC,QAAQ,KAAK,CAAC,EAAE,CAAC,CAAC;SACnE;KACF;AACH,CAAC;AAxDD,0CAwDC"}

View File

@@ -30,7 +30,6 @@ const actionsUtil = __importStar(require("./actions-util"));
const apiClient = __importStar(require("./api-client")); const apiClient = __importStar(require("./api-client"));
const codeql_1 = require("./codeql"); const codeql_1 = require("./codeql");
const database_upload_1 = require("./database-upload"); const database_upload_1 = require("./database-upload");
const feature_flags_1 = require("./feature-flags");
const languages_1 = require("./languages"); const languages_1 = require("./languages");
const testing_utils_1 = require("./testing-utils"); const testing_utils_1 = require("./testing-utils");
const util_1 = require("./util"); const util_1 = require("./util");
@@ -38,10 +37,6 @@ const util_1 = require("./util");
ava_1.default.beforeEach(() => { ava_1.default.beforeEach(() => {
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3"); (0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
}); });
const uploadToUploadsDomainFlags = (0, feature_flags_1.createFeatureFlags)([
feature_flags_1.FeatureFlag.DatabaseUploadsEnabled,
feature_flags_1.FeatureFlag.UploadsDomainEnabled,
]);
const testRepoName = { owner: "github", repo: "example" }; const testRepoName = { owner: "github", repo: "example" };
const testApiDetails = { const testApiDetails = {
auth: "1234", auth: "1234",
@@ -55,7 +50,6 @@ function getTestConfig(tmpDir) {
paths: [], paths: [],
originalUserInput: {}, originalUserInput: {},
tempDir: tmpDir, tempDir: tmpDir,
toolCacheDir: tmpDir,
codeQLCmd: "foo", codeQLCmd: "foo",
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM }, gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
dbLocation: tmpDir, dbLocation: tmpDir,
@@ -63,15 +57,14 @@ function getTestConfig(tmpDir) {
debugMode: false, debugMode: false,
debugArtifactName: util_1.DEFAULT_DEBUG_ARTIFACT_NAME, debugArtifactName: util_1.DEFAULT_DEBUG_ARTIFACT_NAME,
debugDatabaseName: util_1.DEFAULT_DEBUG_DATABASE_NAME, debugDatabaseName: util_1.DEFAULT_DEBUG_DATABASE_NAME,
injectedMlQueries: false,
}; };
} }
async function mockHttpRequests(featureFlags, databaseUploadStatusCode) { async function mockHttpRequests(databaseUploadStatusCode) {
// Passing an auth token is required, so we just use a dummy value // Passing an auth token is required, so we just use a dummy value
const client = github.getOctokit("123"); const client = github.getOctokit("123");
const requestSpy = sinon.stub(client, "request"); const requestSpy = sinon.stub(client, "request");
const url = (await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled)) const url = "POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name";
? "POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name"
: "PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language";
const databaseUploadSpy = requestSpy.withArgs(url); const databaseUploadSpy = requestSpy.withArgs(url);
if (databaseUploadStatusCode < 300) { if (databaseUploadStatusCode < 300) {
databaseUploadSpy.resolves(undefined); databaseUploadSpy.resolves(undefined);
@@ -90,7 +83,7 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
.returns("false"); .returns("false");
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true); sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
const loggedMessages = []; const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages)); await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" && t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === "Database upload disabled in workflow. Skipping upload.") !== undefined); v.message === "Database upload disabled in workflow. Skipping upload.") !== undefined);
}); });
@@ -106,7 +99,7 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
const config = getTestConfig(tmpDir); const config = getTestConfig(tmpDir);
config.gitHubVersion = { type: util_1.GitHubVariant.GHES, version: "3.0" }; config.gitHubVersion = { type: util_1.GitHubVariant.GHES, version: "3.0" };
const loggedMessages = []; const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, config, (0, feature_flags_1.createFeatureFlags)([]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages)); await (0, database_upload_1.uploadDatabases)(testRepoName, config, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" && t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === "Not running against github.com. Skipping upload.") !== undefined); v.message === "Not running against github.com. Skipping upload.") !== undefined);
}); });
@@ -122,7 +115,7 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
const config = getTestConfig(tmpDir); const config = getTestConfig(tmpDir);
config.gitHubVersion = { type: util_1.GitHubVariant.GHAE }; config.gitHubVersion = { type: util_1.GitHubVariant.GHAE };
const loggedMessages = []; const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, config, (0, feature_flags_1.createFeatureFlags)([]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages)); await (0, database_upload_1.uploadDatabases)(testRepoName, config, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" && t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === "Not running against github.com. Skipping upload.") !== undefined); v.message === "Not running against github.com. Skipping upload.") !== undefined);
}); });
@@ -136,31 +129,11 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
.returns("true"); .returns("true");
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false); sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
const loggedMessages = []; const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages)); await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" && t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === "Not analyzing default branch. Skipping upload.") !== undefined); v.message === "Not analyzing default branch. Skipping upload.") !== undefined);
}); });
}); });
(0, ava_1.default)("Abort database upload if feature flag is disabled", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
sinon
.stub(actionsUtil, "getRequiredInput")
.withArgs("upload-database")
.returns("true");
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
(0, codeql_1.setCodeQL)({
async databaseBundle() {
return;
},
});
const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.UploadsDomainEnabled]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message ===
"Repository is not opted in to database uploads. Skipping upload.") !== undefined);
});
});
(0, ava_1.default)("Don't crash if uploading a database fails", async (t) => { (0, ava_1.default)("Don't crash if uploading a database fails", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => { await (0, util_1.withTmpDir)(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
@@ -169,17 +142,14 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
.withArgs("upload-database") .withArgs("upload-database")
.returns("true"); .returns("true");
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true); sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
const featureFlags = (0, feature_flags_1.createFeatureFlags)([ await mockHttpRequests(500);
feature_flags_1.FeatureFlag.DatabaseUploadsEnabled,
]);
await mockHttpRequests(featureFlags, 500);
(0, codeql_1.setCodeQL)({ (0, codeql_1.setCodeQL)({
async databaseBundle(_, outputFilePath) { async databaseBundle(_, outputFilePath) {
fs.writeFileSync(outputFilePath, ""); fs.writeFileSync(outputFilePath, "");
}, },
}); });
const loggedMessages = []; const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), featureFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages)); await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "warning" && t.assert(loggedMessages.find((v) => v.type === "warning" &&
v.message === v.message ===
"Failed to upload database for javascript: Error: some error message") !== undefined); "Failed to upload database for javascript: Error: some error message") !== undefined);
@@ -193,14 +163,14 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
.withArgs("upload-database") .withArgs("upload-database")
.returns("true"); .returns("true");
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true); sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
await mockHttpRequests(uploadToUploadsDomainFlags, 201); await mockHttpRequests(201);
(0, codeql_1.setCodeQL)({ (0, codeql_1.setCodeQL)({
async databaseBundle(_, outputFilePath) { async databaseBundle(_, outputFilePath) {
fs.writeFileSync(outputFilePath, ""); fs.writeFileSync(outputFilePath, "");
}, },
}); });
const loggedMessages = []; const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages)); await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" && t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === "Successfully uploaded database for javascript") !== undefined); v.message === "Successfully uploaded database for javascript") !== undefined);
}); });
@@ -213,14 +183,14 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
.withArgs("upload-database") .withArgs("upload-database")
.returns("true"); .returns("true");
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true); sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
await mockHttpRequests(uploadToUploadsDomainFlags, 201); await mockHttpRequests(201);
(0, codeql_1.setCodeQL)({ (0, codeql_1.setCodeQL)({
async databaseBundle(_, outputFilePath) { async databaseBundle(_, outputFilePath) {
fs.writeFileSync(outputFilePath, ""); fs.writeFileSync(outputFilePath, "");
}, },
}); });
const loggedMessages = []; const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages)); await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" && t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === "Successfully uploaded database for javascript") !== undefined); v.message === "Successfully uploaded database for javascript") !== undefined);
}); });

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,3 @@
{ {
"bundleVersion": "codeql-bundle-20211208" "bundleVersion": "codeql-bundle-20220623"
} }

24
lib/feature-flags.js generated
View File

@@ -24,9 +24,8 @@ const api_client_1 = require("./api-client");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
var FeatureFlag; var FeatureFlag;
(function (FeatureFlag) { (function (FeatureFlag) {
FeatureFlag["DatabaseUploadsEnabled"] = "database_uploads_enabled";
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled"; FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
FeatureFlag["UploadsDomainEnabled"] = "uploads_domain_enabled"; FeatureFlag["LuaTracerConfigEnabled"] = "lua_tracer_config_enabled";
})(FeatureFlag = exports.FeatureFlag || (exports.FeatureFlag = {})); })(FeatureFlag = exports.FeatureFlag || (exports.FeatureFlag = {}));
class GitHubFeatureFlags { class GitHubFeatureFlags {
constructor(gitHubVersion, apiDetails, repositoryNwo, logger) { constructor(gitHubVersion, apiDetails, repositoryNwo, logger) {
@@ -43,9 +42,6 @@ class GitHubFeatureFlags {
} }
return response; return response;
} }
async preloadFeatureFlags() {
await this.getApiResponse();
}
async getApiResponse() { async getApiResponse() {
const loadApiResponse = async () => { const loadApiResponse = async () => {
// Do nothing when not running against github.com // Do nothing when not running against github.com
@@ -62,11 +58,19 @@ class GitHubFeatureFlags {
return response.data; return response.data;
} }
catch (e) { catch (e) {
// Some feature flags, such as `ml_powered_queries_enabled` affect the produced alerts. if (util.isHTTPError(e) && e.status === 403) {
// Considering these feature flags disabled in the event of a transient error could this.logger.warning("This run of the CodeQL Action does not have permission to access Code Scanning API endpoints. " +
// therefore lead to alert churn. As a result, we crash if we cannot determine the value of "As a result, it will not be opted into any experimental features. " +
// the feature flags. "This could be because the Action is running on a pull request from a fork. If not, " +
throw new Error(`Encountered an error while trying to load feature flags: ${e}`); `please ensure the Action has the 'security-events: write' permission. Details: ${e}`);
}
else {
// Some feature flags, such as `ml_powered_queries_enabled` affect the produced alerts.
// Considering these feature flags disabled in the event of a transient error could
// therefore lead to alert churn. As a result, we crash if we cannot determine the value of
// the feature flags.
throw new Error(`Encountered an error while trying to load feature flags: ${e}`);
}
} }
}; };
const apiResponse = this.cachedApiResponse || (await loadApiResponse()); const apiResponse = this.cachedApiResponse || (await loadApiResponse());

View File

@@ -1 +1 @@
{"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../src/feature-flags.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8D;AAG9D,6CAA+B;AAM/B,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kEAAmD,CAAA;IACnD,qEAAsD,CAAA;IACtD,8DAA+C,CAAA;AACjD,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAUD,MAAa,kBAAkB;IAG7B,YACU,aAAiC,EACjC,UAA4B,EAC5B,aAA4B,EAC5B,MAAc;QAHd,kBAAa,GAAb,aAAa,CAAoB;QACjC,eAAU,GAAV,UAAU,CAAkB;QAC5B,kBAAa,GAAb,aAAa,CAAe;QAC5B,WAAM,GAAN,MAAM,CAAQ;IACrB,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,IAAiB;QAC9B,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,iBAAiB,IAAI,uDAAuD,CAC7E,CAAC;YACF,OAAO,KAAK,CAAC;SACd;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,mBAAmB;QACvB,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;IAC9B,CAAC;IAEO,KAAK,CAAC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O,QAAQ,CAAC,IAAI,CAAC;aACtB;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE;oBAC3C,IAAI,CAAC,MAAM,CAAC,OAAO,CACjB,gGAAgG;wBAC9F,oEAAoE;wBACpE,qFAAqF;wBACrF,kFAAkF,CAAC,EAAE,CACxF,CAAC;iBACH;qBAAM;oBACL,uFAAuF;oBACvF,mFAAmF;oBACnF,2FAA2F;oBAC3F,qBAAqB;oBACrB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAAC,EAAE,CAChE,CAAC;iBACH;aACF;QACH,CAAC,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,IAAI,CAAC,MAAM,eAAe,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,iBAAiB,GAAG,WAAW,CAAC;QACrC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AAhED,gDAgEC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,YAA2B;IAC5D,OAAO;QACL,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACvB,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC;AAND,gDAMC"}

View File

@@ -49,11 +49,7 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
for (const flag of Object.values(feature_flags_1.FeatureFlag)) { for (const flag of Object.values(feature_flags_1.FeatureFlag)) {
t.assert((await featureFlags.getValue(flag)) === false); t.assert((await featureFlags.getValue(flag)) === false);
} }
for (const featureFlag of [ for (const featureFlag of ["ml_powered_queries_enabled"]) {
"database_uploads_enabled",
"ml_powered_queries_enabled",
"uploads_domain_enabled",
]) {
t.assert(loggedMessages.find((v) => v.type === "debug" && t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === v.message ===
`Feature flag '${featureFlag}' undefined in API response, considering it disabled.`) !== undefined); `Feature flag '${featureFlag}' undefined in API response, considering it disabled.`) !== undefined);
@@ -65,15 +61,14 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir); (0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, logging_1.getRunnerLogger)(true)); const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, logging_1.getRunnerLogger)(true));
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(500, {}); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(500, {});
await t.throwsAsync(async () => featureFlags.preloadFeatureFlags(), { await t.throwsAsync(async () => featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled), {
message: "Encountered an error while trying to load feature flags: Error: some error message", message: "Encountered an error while trying to load feature flags: Error: some error message",
}); });
}); });
}); });
const FEATURE_FLAGS = [ const FEATURE_FLAGS = [
"database_uploads_enabled",
"ml_powered_queries_enabled", "ml_powered_queries_enabled",
"uploads_domain_enabled", "lua_tracer_config_enabled",
]; ];
for (const featureFlag of FEATURE_FLAGS) { for (const featureFlag of FEATURE_FLAGS) {
(0, ava_1.default)(`Feature flag '${featureFlag}' is enabled if enabled in the API response`, async (t) => { (0, ava_1.default)(`Feature flag '${featureFlag}' is enabled if enabled in the API response`, async (t) => {
@@ -87,9 +82,8 @@ for (const featureFlag of FEATURE_FLAGS) {
expectedFeatureFlags[featureFlag] = true; expectedFeatureFlags[featureFlag] = true;
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags); (0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags);
const actualFeatureFlags = { const actualFeatureFlags = {
database_uploads_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.DatabaseUploadsEnabled),
ml_powered_queries_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled), ml_powered_queries_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled),
uploads_domain_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled), lua_tracer_config_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.LuaTracerConfigEnabled),
}; };
t.deepEqual(actualFeatureFlags, expectedFeatureFlags); t.deepEqual(actualFeatureFlags, expectedFeatureFlags);
}); });

View File

@@ -1 +1 @@
{"version":3,"file":"feature-flags.test.js","sourceRoot":"","sources":["../src/feature-flags.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAGvB,mDAAkE;AAClE,uCAA4C;AAC5C,6CAAkD;AAClD,mDAMyB;AAEzB,iCAAgF;AAEhF,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,UAAU,CAAC,GAAG,EAAE;IACnB,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEH,MAAM,cAAc,GAAqB;IACvC,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,oBAAoB;CAC1B,CAAC;AAEF,MAAM,iBAAiB,GAAG,IAAA,+BAAkB,EAAC,gBAAgB,CAAC,CAAC;AAE/D,MAAM,mCAAmC,GAGpC;IACH;QACE,WAAW,EAAE,MAAM;QACnB,aAAa,EAAE,EAAE,IAAI,EAAE,oBAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;KAC9D;IACD,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,oBAAa,CAAC,IAAI,EAAE,EAAE;CACrE,CAAC;AAEF,KAAK,MAAM,OAAO,IAAI,mCAAmC,EAAE;IACzD,IAAA,aAAI,EAAC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AC;YAEtD,MAAM,kBAAkB,GAAgC;gBACtD,0BAA0B,EAAE,MAAM,YAAY,CAAC,QAAQ,CACrD,2BAAW,CAAC,uBAAuB,CACpC;gBACD,yBAAyB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACpD,2BAAW,CAAC,sBAAsB,CACnC;aACF,CAAC;YAEF,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ"}

8
lib/fingerprints.js generated
View File

@@ -24,6 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.addFingerprints = exports.resolveUriToFile = exports.hash = void 0; exports.addFingerprints = exports.resolveUriToFile = exports.hash = void 0;
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const path_1 = __importDefault(require("path"));
const long_1 = __importDefault(require("long")); const long_1 = __importDefault(require("long"));
const tab = "\t".charCodeAt(0); const tab = "\t".charCodeAt(0);
const space = " ".charCodeAt(0); const space = " ".charCodeAt(0);
@@ -209,7 +210,7 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
// Just assume a relative path is relative to the src root. // Just assume a relative path is relative to the src root.
// This is not necessarily true but should be a good approximation // This is not necessarily true but should be a good approximation
// and here we likely want to err on the side of handling more cases. // and here we likely want to err on the side of handling more cases.
if (!uri.startsWith("/")) { if (!path_1.default.isAbsolute(uri)) {
uri = srcRootPrefix + uri; uri = srcRootPrefix + uri;
} }
// Check the file exists // Check the file exists
@@ -226,9 +227,8 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
exports.resolveUriToFile = resolveUriToFile; exports.resolveUriToFile = resolveUriToFile;
// Compute fingerprints for results in the given sarif file // Compute fingerprints for results in the given sarif file
// and return an updated sarif file contents. // and return an updated sarif file contents.
async function addFingerprints(sarifContents, sourceRoot, logger) { async function addFingerprints(sarif, sourceRoot, logger) {
var _a, _b, _c; var _a, _b, _c;
const sarif = JSON.parse(sarifContents);
// Gather together results for the same file and construct // Gather together results for the same file and construct
// callbacks to accept hashes for that file and update the location // callbacks to accept hashes for that file and update the location
const callbacksByFile = {}; const callbacksByFile = {};
@@ -266,7 +266,7 @@ async function addFingerprints(sarifContents, sourceRoot, logger) {
}; };
await hash(teeCallback, filepath); await hash(teeCallback, filepath);
} }
return JSON.stringify(sarif); return sarif;
} }
exports.addFingerprints = addFingerprints; exports.addFingerprints = addFingerprints;
//# sourceMappingURL=fingerprints.js.map //# sourceMappingURL=fingerprints.js.map

File diff suppressed because one or more lines are too long

View File

@@ -131,20 +131,22 @@ function testResolveUriToFile(uri, index, artifactsURIs) {
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), (0, logging_1.getRunnerLogger)(true)); return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), (0, logging_1.getRunnerLogger)(true));
} }
(0, ava_1.default)("resolveUriToFile", (t) => { (0, ava_1.default)("resolveUriToFile", (t) => {
var _a, _b;
// The resolveUriToFile method checks that the file exists and is in the right directory // The resolveUriToFile method checks that the file exists and is in the right directory
// so we need to give it real files to look at. We will use this file as an example. // so we need to give it real files to look at. We will use this file as an example.
// For this to work we require the current working directory to be a parent, but this // For this to work we require the current working directory to be a parent, but this
// should generally always be the case so this is fine. // should generally always be the case so this is fine.
const cwd = process.cwd(); const filepath = __filename.split(path.sep).join("/");
const filepath = __filename; const relativeFilepath = path
t.true(filepath.startsWith(`${cwd}/`)); .relative(process.cwd(), __filename)
const relativeFilepath = filepath.substring(cwd.length + 1); .split(path.sep)
.join("/");
// Absolute paths are unmodified // Absolute paths are unmodified
t.is(testResolveUriToFile(filepath, undefined, []), filepath); t.is(testResolveUriToFile(filepath, undefined, []), filepath);
t.is(testResolveUriToFile(`file://${filepath}`, undefined, []), filepath); t.is(testResolveUriToFile(`file://${filepath}`, undefined, []), filepath);
// Relative paths are made absolute // Relative paths are made absolute
t.is(testResolveUriToFile(relativeFilepath, undefined, []), filepath); t.is((_a = testResolveUriToFile(relativeFilepath, undefined, [])) === null || _a === void 0 ? void 0 : _a.split(path.sep).join("/"), filepath);
t.is(testResolveUriToFile(`file://${relativeFilepath}`, undefined, []), filepath); t.is((_b = testResolveUriToFile(`file://${relativeFilepath}`, undefined, [])) === null || _b === void 0 ? void 0 : _b.split(path.sep).join("/"), filepath);
// Absolute paths outside the src root are discarded // Absolute paths outside the src root are discarded
t.is(testResolveUriToFile("/src/foo/bar.js", undefined, []), undefined); t.is(testResolveUriToFile("/src/foo/bar.js", undefined, []), undefined);
t.is(testResolveUriToFile("file:///src/foo/bar.js", undefined, []), undefined); t.is(testResolveUriToFile("file:///src/foo/bar.js", undefined, []), undefined);
@@ -169,30 +171,24 @@ function testResolveUriToFile(uri, index, artifactsURIs) {
}); });
(0, ava_1.default)("addFingerprints", async (t) => { (0, ava_1.default)("addFingerprints", async (t) => {
// Run an end-to-end test on a test file // Run an end-to-end test on a test file
let input = fs const input = JSON.parse(fs
.readFileSync(`${__dirname}/../src/testdata/fingerprinting.input.sarif`) .readFileSync(`${__dirname}/../src/testdata/fingerprinting.input.sarif`)
.toString(); .toString());
let expected = fs const expected = JSON.parse(fs
.readFileSync(`${__dirname}/../src/testdata/fingerprinting.expected.sarif`) .readFileSync(`${__dirname}/../src/testdata/fingerprinting.expected.sarif`)
.toString(); .toString());
// The test files are stored prettified, but addFingerprints outputs condensed JSON
input = JSON.stringify(JSON.parse(input));
expected = JSON.stringify(JSON.parse(expected));
// The URIs in the SARIF files resolve to files in the testdata directory // The URIs in the SARIF files resolve to files in the testdata directory
const sourceRoot = path.normalize(`${__dirname}/../src/testdata`); const sourceRoot = path.normalize(`${__dirname}/../src/testdata`);
t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, (0, logging_1.getRunnerLogger)(true)), expected); t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, (0, logging_1.getRunnerLogger)(true)), expected);
}); });
(0, ava_1.default)("missingRegions", async (t) => { (0, ava_1.default)("missingRegions", async (t) => {
// Run an end-to-end test on a test file // Run an end-to-end test on a test file
let input = fs const input = JSON.parse(fs
.readFileSync(`${__dirname}/../src/testdata/fingerprinting2.input.sarif`) .readFileSync(`${__dirname}/../src/testdata/fingerprinting2.input.sarif`)
.toString(); .toString());
let expected = fs const expected = JSON.parse(fs
.readFileSync(`${__dirname}/../src/testdata/fingerprinting2.expected.sarif`) .readFileSync(`${__dirname}/../src/testdata/fingerprinting2.expected.sarif`)
.toString(); .toString());
// The test files are stored prettified, but addFingerprints outputs condensed JSON
input = JSON.stringify(JSON.parse(input));
expected = JSON.stringify(JSON.parse(expected));
// The URIs in the SARIF files resolve to files in the testdata directory // The URIs in the SARIF files resolve to files in the testdata directory
const sourceRoot = path.normalize(`${__dirname}/../src/testdata`); const sourceRoot = path.normalize(`${__dirname}/../src/testdata`);
t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, (0, logging_1.getRunnerLogger)(true)), expected); t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, (0, logging_1.getRunnerLogger)(true)), expected);

File diff suppressed because one or more lines are too long

25
lib/init-action.js generated
View File

@@ -22,6 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path")); const path = __importStar(require("path"));
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const actions_util_1 = require("./actions-util"); const actions_util_1 = require("./actions-util");
const api_client_1 = require("./api-client");
const codeql_1 = require("./codeql"); const codeql_1 = require("./codeql");
const feature_flags_1 = require("./feature-flags"); const feature_flags_1 = require("./feature-flags");
const init_1 = require("./init"); const init_1 = require("./init");
@@ -48,20 +49,21 @@ async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
} }
if (queriesInput !== undefined) { if (queriesInput !== undefined) {
queriesInput = queriesInput.startsWith("+") queriesInput = queriesInput.startsWith("+")
? queriesInput.substr(1) ? queriesInput.slice(1)
: queriesInput; : queriesInput;
queries.push(...queriesInput.split(",")); queries.push(...queriesInput.split(","));
} }
const statusReport = { const statusReport = {
...statusReportBase, ...statusReportBase,
disable_default_queries: disableDefaultQueries,
languages, languages,
workflow_languages: workflowLanguages || "", ml_powered_javascript_queries: (0, util_1.getMlPoweredJsQueriesStatus)(config),
paths, paths,
paths_ignore: pathsIgnore, paths_ignore: pathsIgnore,
disable_default_queries: disableDefaultQueries,
queries: queries.join(","), queries: queries.join(","),
tools_input: (0, actions_util_1.getOptionalInput)("tools") || "", tools_input: (0, actions_util_1.getOptionalInput)("tools") || "",
tools_resolved_version: toolsVersion, tools_resolved_version: toolsVersion,
workflow_languages: workflowLanguages || "",
}; };
await (0, actions_util_1.sendStatusReport)(statusReport); await (0, actions_util_1.sendStatusReport)(statusReport);
} }
@@ -69,6 +71,7 @@ async function run() {
const startedAt = new Date(); const startedAt = new Date();
const logger = (0, logging_1.getActionsLogger)(); const logger = (0, logging_1.getActionsLogger)();
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version); (0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
await (0, util_1.checkActionVersion)(pkg.version);
let config; let config;
let codeql; let codeql;
let toolsVersion; let toolsVersion;
@@ -77,21 +80,25 @@ async function run() {
externalRepoAuth: (0, actions_util_1.getOptionalInput)("external-repository-token"), externalRepoAuth: (0, actions_util_1.getOptionalInput)("external-repository-token"),
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"), url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
}; };
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails); const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.actions); (0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.actions);
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")); const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
const featureFlags = new feature_flags_1.GitHubFeatureFlags(gitHubVersion, apiDetails, repositoryNwo, logger); const featureFlags = new feature_flags_1.GitHubFeatureFlags(gitHubVersion, apiDetails, repositoryNwo, logger);
void featureFlags.preloadFeatureFlags();
try { try {
const workflowErrors = await (0, actions_util_1.validateWorkflow)(); const workflowErrors = await (0, actions_util_1.validateWorkflow)();
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "starting", startedAt, workflowErrors)))) { if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "starting", startedAt, workflowErrors)))) {
return; return;
} }
const initCodeQLResult = await (0, init_1.initCodeQL)((0, actions_util_1.getOptionalInput)("tools"), apiDetails, (0, actions_util_1.getTemporaryDirectory)(), (0, actions_util_1.getToolCacheDirectory)(), gitHubVersion.type, logger); const initCodeQLResult = await (0, init_1.initCodeQL)((0, actions_util_1.getOptionalInput)("tools"), apiDetails, (0, actions_util_1.getTemporaryDirectory)(), gitHubVersion.type, logger);
codeql = initCodeQLResult.codeql; codeql = initCodeQLResult.codeql;
toolsVersion = initCodeQLResult.toolsVersion; toolsVersion = initCodeQLResult.toolsVersion;
await (0, util_1.enrichEnvironment)(util_1.Mode.actions, codeql); await (0, util_1.enrichEnvironment)(util_1.Mode.actions, codeql);
config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"), (0, actions_util_1.getOptionalInput)("debug") === "true", (0, actions_util_1.getOptionalInput)("debug-artifact-name") || util_1.DEFAULT_DEBUG_ARTIFACT_NAME, (0, actions_util_1.getOptionalInput)("debug-database-name") || util_1.DEFAULT_DEBUG_DATABASE_NAME, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), (0, util_1.getRequiredEnvParam)("RUNNER_TOOL_CACHE"), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, featureFlags, logger); config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"),
// Debug mode is enabled if:
// - The `init` Action is passed `debug: true`.
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
// or by setting the `ACTIONS_STEP_DEBUG` secret to `true`).
(0, actions_util_1.getOptionalInput)("debug") === "true" || core.isDebug(), (0, actions_util_1.getOptionalInput)("debug-artifact-name") || util_1.DEFAULT_DEBUG_ARTIFACT_NAME, (0, actions_util_1.getOptionalInput)("debug-database-name") || util_1.DEFAULT_DEBUG_DATABASE_NAME, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, featureFlags, logger);
if (config.languages.includes(languages_1.Language.python) && if (config.languages.includes(languages_1.Language.python) &&
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") { (0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
try { try {
@@ -126,7 +133,7 @@ async function run() {
(0, util_1.getMemoryFlagValue)((0, actions_util_1.getOptionalInput)("ram")).toString()); (0, util_1.getMemoryFlagValue)((0, actions_util_1.getOptionalInput)("ram")).toString());
core.exportVariable("CODEQL_THREADS", (0, util_1.getThreadsFlagValue)((0, actions_util_1.getOptionalInput)("threads"), logger).toString()); core.exportVariable("CODEQL_THREADS", (0, util_1.getThreadsFlagValue)((0, actions_util_1.getOptionalInput)("threads"), logger).toString());
const sourceRoot = path.resolve((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), (0, actions_util_1.getOptionalInput)("source-root") || ""); const sourceRoot = path.resolve((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), (0, actions_util_1.getOptionalInput)("source-root") || "");
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", undefined); const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", undefined, featureFlags);
if (tracerConfig !== undefined) { if (tracerConfig !== undefined) {
for (const [key, value] of Object.entries(tracerConfig.env)) { for (const [key, value] of Object.entries(tracerConfig.env)) {
core.exportVariable(key, value); core.exportVariable(key, value);
@@ -141,7 +148,7 @@ async function run() {
catch (error) { catch (error) {
core.setFailed(String(error)); core.setFailed(String(error));
console.log(error); console.log(error);
await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "failure", startedAt, String(error), error instanceof Error ? error.stack : undefined)); await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", (0, actions_util_1.getActionsStatus)(error), startedAt, String(error), error instanceof Error ? error.stack : undefined));
return; return;
} }
await sendSuccessStatusReport(startedAt, config, toolsVersion); await sendSuccessStatusReport(startedAt, config, toolsVersion);

File diff suppressed because one or more lines are too long

48
lib/init.js generated
View File

@@ -30,32 +30,51 @@ const configUtils = __importStar(require("./config-utils"));
const tracer_config_1 = require("./tracer-config"); const tracer_config_1 = require("./tracer-config");
const util = __importStar(require("./util")); const util = __importStar(require("./util"));
const util_1 = require("./util"); const util_1 = require("./util");
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger) { async function initCodeQL(codeqlURL, apiDetails, tempDir, variant, logger) {
logger.startGroup("Setup CodeQL tools"); logger.startGroup("Setup CodeQL tools");
const { codeql, toolsVersion } = await (0, codeql_1.setupCodeQL)(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger, true); const { codeql, toolsVersion } = await (0, codeql_1.setupCodeQL)(codeqlURL, apiDetails, tempDir, variant, logger, true);
await codeql.printVersion(); await codeql.printVersion();
logger.endGroup(); logger.endGroup();
return { codeql, toolsVersion }; return { codeql, toolsVersion };
} }
exports.initCodeQL = initCodeQL; exports.initCodeQL = initCodeQL;
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) { async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
logger.startGroup("Load language configuration"); logger.startGroup("Load language configuration");
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger); const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
analysisPaths.printPathFiltersWarning(config, logger); analysisPaths.printPathFiltersWarning(config, logger);
logger.endGroup(); logger.endGroup();
return config; return config;
} }
exports.initConfig = initConfig; exports.initConfig = initConfig;
async function runInit(codeql, config, sourceRoot, processName, processLevel) { async function runInit(codeql, config, sourceRoot, processName, processLevel, featureFlags) {
var _a, _b;
fs.mkdirSync(config.dbLocation, { recursive: true }); fs.mkdirSync(config.dbLocation, { recursive: true });
if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) { try {
// Init a database cluster if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
await codeql.databaseInitCluster(config.dbLocation, config.languages, sourceRoot, processName, processLevel); // Init a database cluster
await codeql.databaseInitCluster(config, sourceRoot, processName, processLevel, featureFlags);
}
else {
for (const language of config.languages) {
// Init language database
await codeql.databaseInit(util.getCodeQLDatabasePath(config, language), language, sourceRoot);
}
}
} }
else { catch (e) {
for (const language of config.languages) { // Handle the situation where init is called twice
// Init language database // for the same database in the same job.
await codeql.databaseInit(util.getCodeQLDatabasePath(config, language), language, sourceRoot); if (e instanceof Error &&
((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("Refusing to create databases")) &&
e.message.includes("exists and is not an empty directory.")) {
throw new util.UserError(`Is the "init" action called twice in the same job? ${e.message}`);
}
else if (e instanceof Error &&
((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes("is not compatible with this CodeQL CLI"))) {
throw new util.UserError(e.message);
}
else {
throw e;
} }
} }
return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql); return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql);
@@ -160,12 +179,15 @@ async function installPythonDeps(codeql, logger) {
if (process.platform === "win32") { if (process.platform === "win32") {
await new toolrunner.ToolRunner(await safeWhich.safeWhich("py"), [ await new toolrunner.ToolRunner(await safeWhich.safeWhich("py"), [
"-3", "-3",
"-B",
path.join(scriptsFolder, script), path.join(scriptsFolder, script),
path.dirname(codeql.getPath()), path.dirname(codeql.getPath()),
]).exec(); ]).exec();
} }
else { else {
await new toolrunner.ToolRunner(path.join(scriptsFolder, script), [ await new toolrunner.ToolRunner(await safeWhich.safeWhich("python3"), [
"-B",
path.join(scriptsFolder, script),
path.dirname(codeql.getPath()), path.dirname(codeql.getPath()),
]).exec(); ]).exec();
} }

View File

@@ -1 +1 @@
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAElD,qCAA2E;AAC3E,4DAA8C;AAI9C,mDAAwE;AACxE,6CAA+B;AAC/B,iCAA4C;AAErC,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf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B,CAAC;QAC1C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YAChC,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBAC/D,IAAI;gBACJ,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;gBACpE,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAzCD,8CAyCC"}

3
lib/languages.js generated
View File

@@ -11,6 +11,7 @@ var Language;
Language["javascript"] = "javascript"; Language["javascript"] = "javascript";
Language["python"] = "python"; Language["python"] = "python";
Language["ruby"] = "ruby"; Language["ruby"] = "ruby";
Language["swift"] = "swift";
})(Language = exports.Language || (exports.Language = {})); })(Language = exports.Language || (exports.Language = {}));
// Additional names for languages // Additional names for languages
const LANGUAGE_ALIASES = { const LANGUAGE_ALIASES = {
@@ -35,7 +36,7 @@ function parseLanguage(language) {
} }
exports.parseLanguage = parseLanguage; exports.parseLanguage = parseLanguage;
function isTracedLanguage(language) { function isTracedLanguage(language) {
return (["cpp", "java", "csharp"].includes(language) || return (["cpp", "java", "csharp", "swift"].includes(language) ||
(process.env["CODEQL_EXTRACTOR_GO_BUILD_TRACING"] === "on" && (process.env["CODEQL_EXTRACTOR_GO_BUILD_TRACING"] === "on" &&
language === Language.go)); language === Language.go));
} }

View File

@@ -1 +1 @@
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AACxC,IAAY,QAQX;AARD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,yBAAa,CAAA;IACb,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;AACf,CAAC,EARW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAQnB;AAED,iCAAiC;AACjC,MAAM,gBAAgB,GAAiC;IACrD,CAAC,EAAE,QAAQ,CAAC,GAAG;IACf,KAAK,EAAE,QAAQ,CAAC,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC,MAAM;IACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;CAChC,CAAC;AAEF,gGAAgG;AAChG,SAAgB,aAAa,CAAC,QAAgB;IAC5C,0BAA0B;IAC1B,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAElC,6BAA6B;IAC7B,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,OAAO,QAAoB,CAAC;KAC7B;IAED,yBAAyB;IACzB,IAAI,QAAQ,IAAI,gBAAgB,EAAE;QAChC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KACnC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAfD,sCAeC;AAED,SAAgB,gBAAgB,CAAC,QAAkB;IACjD,OAAO,CACL,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAC5C,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAm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rD,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,KAAK,IAAI;YACxD,QAAQ,KAAK,QAAQ,CAAC,EAAE,CAAC,CAC5B,CAAC;AACJ,CAAC;AAND,4CAMC;AAED,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAFD,8CAEC"}

17
lib/runner.js generated
View File

@@ -23,7 +23,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const fs = __importStar(require("fs")); const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path")); const path = __importStar(require("path"));
const commander_1 = require("commander"); const commander_1 = require("commander");
const del_1 = __importDefault(require("del")); const del_1 = __importDefault(require("del"));
@@ -51,13 +50,6 @@ function getTempDir(userInput) {
} }
return tempDir; return tempDir;
} }
function getToolsDir(userInput) {
const toolsDir = userInput || path.join(os.homedir(), "codeql-runner-tools");
if (!fs.existsSync(toolsDir)) {
fs.mkdirSync(toolsDir, { recursive: true });
}
return toolsDir;
}
const codeqlEnvJsonFilename = "codeql-env.json"; const codeqlEnvJsonFilename = "codeql-env.json";
function loadTracerEnvironment(config) { function loadTracerEnvironment(config) {
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename); const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
@@ -134,7 +126,6 @@ program
const logger = (0, logging_1.getRunnerLogger)(cmd.debug); const logger = (0, logging_1.getRunnerLogger)(cmd.debug);
try { try {
const tempDir = getTempDir(cmd.tempDir); const tempDir = getTempDir(cmd.tempDir);
const toolsDir = getToolsDir(cmd.toolsDir);
const checkoutPath = cmd.checkoutPath || process.cwd(); const checkoutPath = cmd.checkoutPath || process.cwd();
// Wipe the temp dir // Wipe the temp dir
logger.info(`Cleaning temp directory ${tempDir}`); logger.info(`Cleaning temp directory ${tempDir}`);
@@ -160,13 +151,13 @@ program
codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath); codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath);
} }
else { else {
codeql = (await (0, init_1.initCodeQL)(undefined, apiDetails, tempDir, toolsDir, gitHubVersion.type, logger)).codeql; codeql = (await (0, init_1.initCodeQL)(undefined, apiDetails, tempDir, gitHubVersion.type, logger)).codeql;
} }
await (0, util_1.enrichEnvironment)(util_1.Mode.runner, codeql); await (0, util_1.enrichEnvironment)(util_1.Mode.runner, codeql);
const workspacePath = checkoutPath; const workspacePath = checkoutPath;
const config = await (0, init_1.initConfig)(cmd.languages, cmd.queries, cmd.packs, cmd.configFile, undefined, false, "", "", (0, repository_1.parseRepositoryNwo)(cmd.repository), tempDir, toolsDir, codeql, workspacePath, gitHubVersion, apiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger); const config = await (0, init_1.initConfig)(cmd.languages, cmd.queries, cmd.packs, cmd.configFile, undefined, false, "", "", (0, repository_1.parseRepositoryNwo)(cmd.repository), tempDir, codeql, workspacePath, gitHubVersion, apiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger);
const sourceRoot = checkoutPath; const sourceRoot = checkoutPath;
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, parseTraceProcessName(), parseTraceProcessLevel()); const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, parseTraceProcessName(), parseTraceProcessLevel(), (0, feature_flags_1.createFeatureFlags)([]));
if (tracerConfig === undefined) { if (tracerConfig === undefined) {
return; return;
} }
@@ -297,7 +288,7 @@ program
} }
const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger); const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger);
const memory = (0, util_1.getMemoryFlag)(cmd.ram || initEnv["CODEQL_RAM"]); const memory = (0, util_1.getMemoryFlag)(cmd.ram || initEnv["CODEQL_RAM"]);
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger); await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, (0, feature_flags_1.createFeatureFlags)([]));
await (0, analyze_1.runQueries)(outputDir, memory, (0, util_1.getAddSnippetsFlag)(cmd.addSnippets), threads, cmd.category, config, logger); await (0, analyze_1.runQueries)(outputDir, memory, (0, util_1.getAddSnippetsFlag)(cmd.addSnippets), threads, cmd.category, config, logger);
if (!cmd.upload) { if (!cmd.upload) {
logger.info("Not uploading results"); logger.info("Not uploading results");

Some files were not shown because too many files have changed in this diff Show More