mirror of
https://github.com/github/codeql-action.git
synced 2025-12-08 00:38:30 +08:00
Compare commits
555 Commits
v1.0.21
...
codeql-bun
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6e327771b | ||
|
|
b9577df761 | ||
|
|
808c29257b | ||
|
|
8b2f5d7158 | ||
|
|
0ba58d8497 | ||
|
|
3962f1bd85 | ||
|
|
c5c5bdabb9 | ||
|
|
e7869d541b | ||
|
|
7a12645d7e | ||
|
|
9f20addbf2 | ||
|
|
780f4ee1bf | ||
|
|
baf90d17d2 | ||
|
|
6f174084dd | ||
|
|
b0c570ef83 | ||
|
|
2d80fe85fc | ||
|
|
0c80741707 | ||
|
|
792bbfea04 | ||
|
|
1ed1437484 | ||
|
|
3ed22c8145 | ||
|
|
739937f14e | ||
|
|
0ecdac49ad | ||
|
|
426a3951ee | ||
|
|
a0b596246a | ||
|
|
5d3e1a701c | ||
|
|
b9bb8dd18d | ||
|
|
11673755ab | ||
|
|
d0ca51f5e9 | ||
|
|
0182a2c78c | ||
|
|
488f78249e | ||
|
|
9cab82f202 | ||
|
|
43d066495c | ||
|
|
f090899ed0 | ||
|
|
8a00ed086d | ||
|
|
935969c6f7 | ||
|
|
e26813cf98 | ||
|
|
2c03704a6c | ||
|
|
dd6b592e3e | ||
|
|
a90d8bf711 | ||
|
|
dc0338e493 | ||
|
|
57096fe795 | ||
|
|
b0ddf36abe | ||
|
|
1ea2f2d7f1 | ||
|
|
9dcc141f12 | ||
|
|
ea751a9fae | ||
|
|
a2949f47b3 | ||
|
|
7871f0d5e1 | ||
|
|
e6f3e049b4 | ||
|
|
e83a1d469e | ||
|
|
894faced79 | ||
|
|
a9095cefc9 | ||
|
|
4d339ae3ec | ||
|
|
381ea36211 | ||
|
|
e769c2dd6e | ||
|
|
bae3a3acab | ||
|
|
bcd5c027de | ||
|
|
9885f86fab | ||
|
|
ee3341a9d8 | ||
|
|
28eead2408 | ||
|
|
a4da970395 | ||
|
|
34a1681e50 | ||
|
|
8833977736 | ||
|
|
bfe9e81020 | ||
|
|
1d58cc1f27 | ||
|
|
d8576e34bf | ||
|
|
f1060fbba0 | ||
|
|
af34c6da92 | ||
|
|
282b607642 | ||
|
|
f0e2f3c053 | ||
|
|
73ba7ffb48 | ||
|
|
2f4dd4bb41 | ||
|
|
8237e85158 | ||
|
|
eea7cf19ff | ||
|
|
fdc2a903c1 | ||
|
|
c22162c09d | ||
|
|
01c72238c1 | ||
|
|
63b2636c23 | ||
|
|
0ed0799824 | ||
|
|
9e403590f4 | ||
|
|
45b96c3de6 | ||
|
|
9a709c116e | ||
|
|
43c9f26143 | ||
|
|
b949e494e4 | ||
|
|
3d23aade46 | ||
|
|
d625a00cee | ||
|
|
077ec096bb | ||
|
|
4d6e9c02ac | ||
|
|
839aa81918 | ||
|
|
6d1f0a0357 | ||
|
|
88db5e75ec | ||
|
|
d068f5372a | ||
|
|
044f112dc1 | ||
|
|
f7846479e6 | ||
|
|
d0bd80897c | ||
|
|
bed132dae4 | ||
|
|
9d26fe0cb3 | ||
|
|
6e57bbac6c | ||
|
|
85cfdb24f4 | ||
|
|
df164705ad | ||
|
|
da7944b165 | ||
|
|
33599909af | ||
|
|
f143182488 | ||
|
|
0b037b4fcb | ||
|
|
1668e0a2bf | ||
|
|
bd4757cd6b | ||
|
|
5fb01dd153 | ||
|
|
124e7d96a6 | ||
|
|
b8f3a377bf | ||
|
|
4b465cb3ce | ||
|
|
d76b18254a | ||
|
|
33f749f1c9 | ||
|
|
ccda44cac5 | ||
|
|
81827d3fc6 | ||
|
|
b386fd4443 | ||
|
|
2a7a517ea5 | ||
|
|
ca5ed24270 | ||
|
|
fb22523acc | ||
|
|
b887a2ce1e | ||
|
|
686c3a37f0 | ||
|
|
c9973ef56b | ||
|
|
c3010cb18a | ||
|
|
81bfc289f5 | ||
|
|
5d72058994 | ||
|
|
6de8537e54 | ||
|
|
1d81ec489b | ||
|
|
c592f89989 | ||
|
|
f71aeef4dc | ||
|
|
0a713019c3 | ||
|
|
243ebf6e35 | ||
|
|
3886398541 | ||
|
|
f60bb5cc38 | ||
|
|
d0ee2b4276 | ||
|
|
34905f691e | ||
|
|
ac7bd44c3b | ||
|
|
1457c164a9 | ||
|
|
8834766498 | ||
|
|
69a58ad266 | ||
|
|
5b59d8784d | ||
|
|
ea5898d606 | ||
|
|
39aa619399 | ||
|
|
2190825ac9 | ||
|
|
e61a4b9c7c | ||
|
|
b74506c7c2 | ||
|
|
e27fa67f0f | ||
|
|
eb507cfac6 | ||
|
|
c33cdd74b3 | ||
|
|
aeefdce612 | ||
|
|
761da7eb50 | ||
|
|
76c3e91b1f | ||
|
|
560edbc33e | ||
|
|
e64a215b41 | ||
|
|
e437ea1d38 | ||
|
|
8ecc1fcbc4 | ||
|
|
0b3acf68ab | ||
|
|
480ef7689f | ||
|
|
4e2634f2fd | ||
|
|
04d521d705 | ||
|
|
cdf3c9d01e | ||
|
|
628afae9d3 | ||
|
|
111428ce06 | ||
|
|
d2fd19b7d7 | ||
|
|
c825c24663 | ||
|
|
0e0e934038 | ||
|
|
d430deb927 | ||
|
|
f5d822707e | ||
|
|
1f44993f56 | ||
|
|
701b6a5569 | ||
|
|
e75fa83dde | ||
|
|
a33ae09fb8 | ||
|
|
44198be781 | ||
|
|
308528ba13 | ||
|
|
939659ccd0 | ||
|
|
401a76f245 | ||
|
|
5e27f57127 | ||
|
|
4154eaf0e9 | ||
|
|
75e4d9f140 | ||
|
|
870dbaaebe | ||
|
|
3615d8ac45 | ||
|
|
47dd636fbc | ||
|
|
e4766c87d5 | ||
|
|
5c2600e559 | ||
|
|
a92e8775d8 | ||
|
|
527d5153ad | ||
|
|
07990f07e5 | ||
|
|
fa19286989 | ||
|
|
b1c781d398 | ||
|
|
938e0a0743 | ||
|
|
d63f798314 | ||
|
|
86940df49f | ||
|
|
25313901b7 | ||
|
|
8ec6a84629 | ||
|
|
162ecaff35 | ||
|
|
117a67b074 | ||
|
|
0da815296a | ||
|
|
4e02f8e87a | ||
|
|
438f654919 | ||
|
|
42af7232c3 | ||
|
|
360221eece | ||
|
|
9169d2461f | ||
|
|
949eeb2dcf | ||
|
|
507795f5c4 | ||
|
|
75f07e7ab2 | ||
|
|
42c72a10c8 | ||
|
|
fa57ef0579 | ||
|
|
4b66d317a4 | ||
|
|
d7ad71d803 | ||
|
|
afbddca263 | ||
|
|
c592525a67 | ||
|
|
f14beebc58 | ||
|
|
3d93bb2ac9 | ||
|
|
040feefecf | ||
|
|
4d875a922c | ||
|
|
cbc9c75e8f | ||
|
|
65174f238c | ||
|
|
d39d5d5c97 | ||
|
|
da54d7bd9f | ||
|
|
fe6fb6f21b | ||
|
|
72f407c72c | ||
|
|
cefec5bcb7 | ||
|
|
070bf9ae1c | ||
|
|
74dd782377 | ||
|
|
78e09bd811 | ||
|
|
72b5ce4f22 | ||
|
|
21c48e7a01 | ||
|
|
326e5118c5 | ||
|
|
b83cccd8a6 | ||
|
|
9b2dafda62 | ||
|
|
770ee8972e | ||
|
|
ec300a3159 | ||
|
|
c9f98d45c1 | ||
|
|
6a961c08f2 | ||
|
|
db24c88f31 | ||
|
|
c4e058a6a3 | ||
|
|
0d87b8c615 | ||
|
|
49c1e2f719 | ||
|
|
13c841aa39 | ||
|
|
ef024e702c | ||
|
|
1ed61a37b6 | ||
|
|
abba98ef38 | ||
|
|
9d794b2b2e | ||
|
|
7e1ca4f093 | ||
|
|
621c8c7115 | ||
|
|
feb711fe0b | ||
|
|
609ca1e4cf | ||
|
|
4c266bab6d | ||
|
|
ec47ce3982 | ||
|
|
e72dfad837 | ||
|
|
bcdaad245b | ||
|
|
8aa32bd9c9 | ||
|
|
d8ee3b9d09 | ||
|
|
2c6b76bc5a | ||
|
|
19debd424c | ||
|
|
3fdc5a23fa | ||
|
|
68365ec944 | ||
|
|
474bbf07f9 | ||
|
|
58f66fa60a | ||
|
|
3d2ad0b9c8 | ||
|
|
7e15b9612a | ||
|
|
7f9dca2982 | ||
|
|
87bfa0ea7a | ||
|
|
a6d606becc | ||
|
|
f2027c51f7 | ||
|
|
70e63f4b08 | ||
|
|
88073a5f6e | ||
|
|
eb172af46d | ||
|
|
a777a982cb | ||
|
|
8f27994474 | ||
|
|
8e2954c3fa | ||
|
|
8768b0f5a3 | ||
|
|
c72c200f52 | ||
|
|
34c777f8d0 | ||
|
|
8dd2b9ac2f | ||
|
|
b8047e5610 | ||
|
|
edd03fbd2c | ||
|
|
f9607205db | ||
|
|
b870f13d6d | ||
|
|
2890d306c3 | ||
|
|
2b46439dd5 | ||
|
|
6d8390b7cb | ||
|
|
4eb03fb6f3 | ||
|
|
03c64ef07d | ||
|
|
cc622a02a9 | ||
|
|
c95a3d854c | ||
|
|
f888be73ce | ||
|
|
16d4068732 | ||
|
|
aab545260e | ||
|
|
501fe7ff12 | ||
|
|
ad40e4a8f8 | ||
|
|
537b2f873a | ||
|
|
9f32fc9b9d | ||
|
|
904d0acf90 | ||
|
|
9b14aa7c84 | ||
|
|
1cddec9558 | ||
|
|
a005206838 | ||
|
|
ff33f031e8 | ||
|
|
6a6a3203dd | ||
|
|
942b34d547 | ||
|
|
3469c69bba | ||
|
|
d57c2761c9 | ||
|
|
6081b90eae | ||
|
|
78eb2c9c00 | ||
|
|
b2af0740e4 | ||
|
|
77194581b7 | ||
|
|
1a5b604256 | ||
|
|
9bfa05fb03 | ||
|
|
e9aa623c5d | ||
|
|
ce89f1b611 | ||
|
|
57f34a1569 | ||
|
|
941e382c65 | ||
|
|
6c6b8c33c4 | ||
|
|
13f97c81fe | ||
|
|
36419a79c1 | ||
|
|
9a40cc5274 | ||
|
|
ec0b3ae7ff | ||
|
|
e836f97769 | ||
|
|
11639426e6 | ||
|
|
a9da9fc959 | ||
|
|
ae8741006b | ||
|
|
72f9a88bc5 | ||
|
|
9f36b75178 | ||
|
|
dfe2bc4e49 | ||
|
|
63d0c7856c | ||
|
|
3cc87990f0 | ||
|
|
260b4d5dc4 | ||
|
|
1bfa9ace60 | ||
|
|
1eaaf07b91 | ||
|
|
5916f9896d | ||
|
|
0dd4dbf9d9 | ||
|
|
980fd4ed38 | ||
|
|
e9aa2c6f62 | ||
|
|
e9d52340a3 | ||
|
|
392931027a | ||
|
|
ba2b46d53e | ||
|
|
a602dbedb7 | ||
|
|
66777347f6 | ||
|
|
ce6e94b1b8 | ||
|
|
30790fe430 | ||
|
|
1a927e9307 | ||
|
|
ea2ef8554d | ||
|
|
bbb9c53c65 | ||
|
|
9664bae55e | ||
|
|
3a741b6cf5 | ||
|
|
1498bce660 | ||
|
|
c260382f36 | ||
|
|
6410c0691e | ||
|
|
8e07ec6ce2 | ||
|
|
c337e5f2f3 | ||
|
|
9673b562d9 | ||
|
|
253bc84963 | ||
|
|
bc4366e948 | ||
|
|
3b831aafd9 | ||
|
|
14b1fecf33 | ||
|
|
5e23536180 | ||
|
|
5f30e2466f | ||
|
|
05981c5829 | ||
|
|
486633d442 | ||
|
|
d6360c9075 | ||
|
|
d3a0787934 | ||
|
|
e13c8bbfb7 | ||
|
|
1c9a1f5d01 | ||
|
|
1f7dab4ba2 | ||
|
|
8a36468d11 | ||
|
|
f8c38c1af3 | ||
|
|
10249d1591 | ||
|
|
e6bcd71529 | ||
|
|
806fc12eb2 | ||
|
|
ba352d365b | ||
|
|
751af2a9e3 | ||
|
|
1a686e7d76 | ||
|
|
0479586f61 | ||
|
|
708446c6e4 | ||
|
|
392316b555 | ||
|
|
5604c0a3ad | ||
|
|
7d8ca8fa93 | ||
|
|
8b37404d56 | ||
|
|
c180f23bb1 | ||
|
|
a7adbce22c | ||
|
|
3b4e4d44dc | ||
|
|
f18151cc59 | ||
|
|
e175dea369 | ||
|
|
752ae5743f | ||
|
|
0dabead789 | ||
|
|
5e69ce82f8 | ||
|
|
fdb92bbffe | ||
|
|
14b4839253 | ||
|
|
d76304cd8e | ||
|
|
57c4e974c2 | ||
|
|
c2fb041dc1 | ||
|
|
ac9d34fbc6 | ||
|
|
384cfc42b2 | ||
|
|
5a1e31dc6a | ||
|
|
67c0353a8c | ||
|
|
7ec25e02e3 | ||
|
|
713eacdf6c | ||
|
|
c8290d07f0 | ||
|
|
51126e5cd1 | ||
|
|
c0b507e521 | ||
|
|
d563b098d7 | ||
|
|
fca047627b | ||
|
|
28fe8e7028 | ||
|
|
8a4b243fbf | ||
|
|
19970ae6b5 | ||
|
|
ec1b16574e | ||
|
|
b31df3ff95 | ||
|
|
776db51d2e | ||
|
|
b886234637 | ||
|
|
9913c9bfa5 | ||
|
|
8de62beb50 | ||
|
|
b6fbccaba1 | ||
|
|
df0c306daf | ||
|
|
ab1f709732 | ||
|
|
8454e21c9c | ||
|
|
d85c3e58ec | ||
|
|
cbabe47a0b | ||
|
|
f8a48f464d | ||
|
|
f6f23f8671 | ||
|
|
c2a7379048 | ||
|
|
cd783c8a29 | ||
|
|
300c8b6dcb | ||
|
|
faa9ba7363 | ||
|
|
d2a0fc83dc | ||
|
|
71112ab35d | ||
|
|
e677af3fd0 | ||
|
|
848e5140d4 | ||
|
|
e7fe6da378 | ||
|
|
2159631658 | ||
|
|
9de1702400 | ||
|
|
efded22908 | ||
|
|
5602bd50bf | ||
|
|
2f4be8e34b | ||
|
|
9763bdd6ec | ||
|
|
00d4d60204 | ||
|
|
e5d84de18b | ||
|
|
ea1acc573a | ||
|
|
79ea6d6a7c | ||
|
|
3e50d096f8 | ||
|
|
cca1cfdacf | ||
|
|
cdea582765 | ||
|
|
3e59dee9e2 | ||
|
|
249c7ffce1 | ||
|
|
254816c2d2 | ||
|
|
6d62c245ec | ||
|
|
5e87034b3b | ||
|
|
621e0794ac | ||
|
|
d6499fad61 | ||
|
|
04671efa1d | ||
|
|
e1f05902cd | ||
|
|
f9e96fa857 | ||
|
|
14a5537e13 | ||
|
|
d3eb4974a3 | ||
|
|
39216d10d3 | ||
|
|
265a7db16a | ||
|
|
f623d4cec3 | ||
|
|
eacec3646a | ||
|
|
e0e2abc1a5 | ||
|
|
716b5980cd | ||
|
|
1d83f2a0bc | ||
|
|
ce77f88627 | ||
|
|
a777b51ef7 | ||
|
|
88fbabe21d | ||
|
|
eeb215b041 | ||
|
|
5f53256358 | ||
|
|
25a5103778 | ||
|
|
0782554948 | ||
|
|
705f634a1d | ||
|
|
b7b7607959 | ||
|
|
7bcc6564d4 | ||
|
|
b661ef1697 | ||
|
|
6ad00fd084 | ||
|
|
fccdee04ba | ||
|
|
e694ca6192 | ||
|
|
67d11b5928 | ||
|
|
924a64d2e0 | ||
|
|
45dc27d3c1 | ||
|
|
cbed0358c6 | ||
|
|
a8cf6f42c2 | ||
|
|
eebe7c46f1 | ||
|
|
dc32d5448f | ||
|
|
fac22de4f9 | ||
|
|
0a1efd7f45 | ||
|
|
043e3deaeb | ||
|
|
0dbcb55617 | ||
|
|
00c59b98ce | ||
|
|
7069ada3ed | ||
|
|
dd1f9a96d8 | ||
|
|
546b30f35a | ||
|
|
d1dde03d7a | ||
|
|
f44219c94b | ||
|
|
bdaac951f7 | ||
|
|
a82f53a364 | ||
|
|
f721f011bf | ||
|
|
c82e09aa41 | ||
|
|
460d053698 | ||
|
|
3bf14e85d8 | ||
|
|
13a9d6c442 | ||
|
|
dd65833ab6 | ||
|
|
c2d9e4b48f | ||
|
|
e095058bfa | ||
|
|
2c99f99c4a | ||
|
|
bcd7e6896f | ||
|
|
0b242db78f | ||
|
|
c897659213 | ||
|
|
8b902e1723 | ||
|
|
26567f6a49 | ||
|
|
dbf7ac4b37 | ||
|
|
077f7b2532 | ||
|
|
a392055010 | ||
|
|
0aea878963 | ||
|
|
bca71988d3 | ||
|
|
02e1cdcd36 | ||
|
|
4860ed1ad4 | ||
|
|
3e36cddb07 | ||
|
|
b9bd459b70 | ||
|
|
215c4f5ff5 | ||
|
|
4eef7ef32c | ||
|
|
e0b9b9a248 | ||
|
|
823bb21bbb | ||
|
|
49fc4c9b40 | ||
|
|
21a786fda0 | ||
|
|
316ad9d919 | ||
|
|
a627e9fa50 | ||
|
|
160021fe53 | ||
|
|
3f2269bf58 | ||
|
|
2ecc17d74f | ||
|
|
9b506fed7c | ||
|
|
2803f4a792 | ||
|
|
720bf9d157 | ||
|
|
bbf0a22e84 | ||
|
|
d7b5c618a4 | ||
|
|
37a4db94ad | ||
|
|
6a98a4b500 | ||
|
|
ea8a175a94 | ||
|
|
f360da772a | ||
|
|
ea169430d2 | ||
|
|
375c14729e | ||
|
|
0442e71a2a | ||
|
|
3832953584 | ||
|
|
3ce10aec2e | ||
|
|
c4b0d49ea3 | ||
|
|
5581e08a65 | ||
|
|
df5cf240b0 | ||
|
|
ae2843216b | ||
|
|
5156a89668 | ||
|
|
8f0825e9c0 | ||
|
|
9a44540e25 | ||
|
|
ff3272d4e1 | ||
|
|
56c7489b94 | ||
|
|
3ba4184b13 | ||
|
|
bc31f604d3 | ||
|
|
4293754ed2 | ||
|
|
70b730eb7d | ||
|
|
2905689d8a | ||
|
|
1d123b770b | ||
|
|
9661171991 | ||
|
|
e04751618e | ||
|
|
531c6ba7c8 |
@@ -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)?$"],
|
||||||
|
|||||||
1
.github/prepare-test/action.yml
vendored
1
.github/prepare-test/action.yml
vendored
@@ -28,7 +28,6 @@ runs:
|
|||||||
echo "::set-output name=tools-url::https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/codeql-bundle-$VERSION-manual/codeql-bundle.tar.gz"
|
echo "::set-output name=tools-url::https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/codeql-bundle-$VERSION-manual/codeql-bundle.tar.gz"
|
||||||
elif [[ ${{ inputs.version }} == *"stable"* ]]; then
|
elif [[ ${{ inputs.version }} == *"stable"* ]]; then
|
||||||
export VERSION=`echo ${{ inputs.version }} | sed -e 's/^.*\-//'`
|
export VERSION=`echo ${{ inputs.version }} | sed -e 's/^.*\-//'`
|
||||||
echo "Hello $VERSION"
|
|
||||||
echo "::set-output name=tools-url::https://github.com/github/codeql-action/releases/download/codeql-bundle-$VERSION/codeql-bundle.tar.gz"
|
echo "::set-output name=tools-url::https://github.com/github/codeql-action/releases/download/codeql-bundle-$VERSION/codeql-bundle.tar.gz"
|
||||||
elif [[ ${{ inputs.version }} == "latest" ]]; then
|
elif [[ ${{ inputs.version }} == "latest" ]]; then
|
||||||
echo "::set-output name=tools-url::latest"
|
echo "::set-output name=tools-url::latest"
|
||||||
|
|||||||
201
.github/update-release-branch.py
vendored
201
.github/update-release-branch.py
vendored
@@ -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,12 +13,12 @@ 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'
|
|
||||||
# Name of the remote
|
# Name of the remote
|
||||||
ORIGIN = 'origin'
|
ORIGIN = 'origin'
|
||||||
|
|
||||||
@@ -38,8 +35,8 @@ 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):
|
||||||
# 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 +58,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 +76,40 @@ 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:')
|
||||||
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 +129,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 +172,69 @@ 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 main as the source branch and v2 as the target branch. " +
|
||||||
|
f"'{V1_MODE}' uses v2 as the source branch and v1 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()
|
||||||
|
|
||||||
|
if args.mode == V2_MODE:
|
||||||
|
source_branch = 'main'
|
||||||
|
target_branch = 'v2'
|
||||||
|
elif args.mode == V1_MODE:
|
||||||
|
source_branch = 'v2'
|
||||||
|
target_branch = 'v1'
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Unexpected value for release 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 +245,79 @@ 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')
|
if args.mode == V1_MODE:
|
||||||
update_changelog(version)
|
# If we're performing a backport, start from the v1 branch
|
||||||
|
print(f'Creating {new_branch_name} from the {ORIGIN}/v1 branch')
|
||||||
|
run_git('checkout', '-b', new_branch_name, f'{ORIGIN}/v1')
|
||||||
|
|
||||||
# Create a commit that updates the CHANGELOG
|
# Revert the commit that we made as part of the last release that updated the version number and
|
||||||
run_git('add', 'CHANGELOG.md')
|
# changelog to refer to 1.x.x variants. This avoids merge conflicts in the changelog and
|
||||||
run_git('commit', '-m', version)
|
# 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')
|
||||||
|
run_git('merge', f'{ORIGIN}/{source_branch}', '--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 [],
|
||||||
|
)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
95
.github/workflows/__analyze-ref-input.yml
generated
vendored
Normal file
95
.github/workflows/__analyze-ref-input.yml
generated
vendored
Normal 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
|
||||||
|
- v1
|
||||||
|
- 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
|
||||||
96
.github/workflows/__debug-artifacts.yml
generated
vendored
Normal file
96
.github/workflows/__debug-artifacts.yml
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
# 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 - Debug artifact upload
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
- v2
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
debug-artifacts:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-20210308
|
||||||
|
- os: macos-latest
|
||||||
|
version: stable-20210308
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-20210319
|
||||||
|
- 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
|
||||||
|
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 }}
|
||||||
|
debug: true
|
||||||
|
debug-artifact-name: my-debug-artifacts
|
||||||
|
debug-database-name: my-db
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
id: analysis
|
||||||
|
- uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: my-debug-artifacts-${{ matrix.os }}-${{ matrix.version }}
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
LANGUAGES="cpp csharp go java javascript python"
|
||||||
|
for language in $LANGUAGES; do
|
||||||
|
echo "Checking $language"
|
||||||
|
if [[ ! -f "$language.sarif" ]] ; then
|
||||||
|
echo "Missing a SARIF file for $language"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -f "my-db-$language.zip" ]] ; then
|
||||||
|
echo "Missing a database bundle for $language"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -d "$language/log" ]] ; then
|
||||||
|
echo "Missing logs for $language"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
66
.github/workflows/__extractor-ram-threads.yml
generated
vendored
Normal file
66
.github/workflows/__extractor-ram-threads.yml
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
# 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 - Extractor ram and threads options test
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
- v2
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
extractor-ram-threads:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: latest
|
||||||
|
name: Extractor ram and threads options test
|
||||||
|
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: java
|
||||||
|
ram: 230
|
||||||
|
threads: 1
|
||||||
|
- name: Assert Results
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "${CODEQL_RAM}" != "230" ]; then
|
||||||
|
echo "CODEQL_RAM is '${CODEQL_RAM}' instead of 230"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "${CODEQL_EXTRACTOR_JAVA_RAM}" != "230" ]; then
|
||||||
|
echo "CODEQL_EXTRACTOR_JAVA_RAM is '${CODEQL_EXTRACTOR_JAVA_RAM}' instead of 230"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "${CODEQL_THREADS}" != "1" ]; then
|
||||||
|
echo "CODEQL_THREADS is '${CODEQL_THREADS}' instead of 1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "${CODEQL_EXTRACTOR_JAVA_THREADS}" != "1" ]; then
|
||||||
|
echo "CODEQL_EXTRACTOR_JAVA_THREADS is '${CODEQL_EXTRACTOR_JAVA_THREADS}' instead of 1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
58
.github/workflows/__go-custom-queries.yml
generated
vendored
58
.github/workflows/__go-custom-queries.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
39
.github/workflows/__go-custom-tracing-autobuild.yml
generated
vendored
39
.github/workflows/__go-custom-tracing-autobuild.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
58
.github/workflows/__go-custom-tracing.yml
generated
vendored
58
.github/workflows/__go-custom-tracing.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
13
.github/workflows/__javascript-source-root.yml
generated
vendored
13
.github/workflows/__javascript-source-root.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
119
.github/workflows/__ml-powered-queries.yml
generated
vendored
Normal file
119
.github/workflows/__ml-powered-queries.yml
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
# 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
|
||||||
|
- v1
|
||||||
|
- 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
|
||||||
|
env:
|
||||||
|
IS_WINDOWS: ${{ matrix.os == 'windows-latest' }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
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" && "${IS_WINDOWS}" != "true" ]]; then
|
||||||
|
echo "Expected SARIF output to contain rule '${rule}', but found no such rule."
|
||||||
|
exit 1
|
||||||
|
elif [[ "${found_rule}" == "true" && "${IS_WINDOWS}" == "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 && "${IS_WINDOWS}" != "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 && "${IS_WINDOWS}" == "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
|
||||||
37
.github/workflows/__multi-language-autodetect.yml
generated
vendored
37
.github/workflows/__multi-language-autodetect.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
11
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
11
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@@ -23,13 +24,17 @@ 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: nightly-20210831
|
||||||
|
- os: macos-latest
|
||||||
|
version: nightly-20210831
|
||||||
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
|
||||||
|
|||||||
11
.github/workflows/__packaging-config-js.yml
generated
vendored
11
.github/workflows/__packaging-config-js.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@@ -23,13 +24,17 @@ 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: nightly-20210831
|
||||||
|
- os: macos-latest
|
||||||
|
version: nightly-20210831
|
||||||
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
|
||||||
|
|||||||
11
.github/workflows/__packaging-inputs-js.yml
generated
vendored
11
.github/workflows/__packaging-inputs-js.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@@ -23,13 +24,17 @@ 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: nightly-20210831
|
||||||
|
- os: macos-latest
|
||||||
|
version: nightly-20210831
|
||||||
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
|
||||||
|
|||||||
58
.github/workflows/__remote-config.yml
generated
vendored
58
.github/workflows/__remote-config.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
25
.github/workflows/__rubocop-multi-language.yml
generated
vendored
25
.github/workflows/__rubocop-multi-language.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
11
.github/workflows/__split-workflow.yml
generated
vendored
11
.github/workflows/__split-workflow.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- v2
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@@ -23,13 +24,17 @@ 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: nightly-20210831
|
||||||
|
- os: macos-latest
|
||||||
|
version: nightly-20210831
|
||||||
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
|
||||||
|
|||||||
67
.github/workflows/__test-autobuild-working-dir.yml
generated
vendored
Normal file
67
.github/workflows/__test-autobuild-working-dir.yml
generated
vendored
Normal 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
|
||||||
|
- v1
|
||||||
|
- 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
|
||||||
9
.github/workflows/__test-local-codeql.yml
generated
vendored
9
.github/workflows/__test-local-codeql.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
9
.github/workflows/__test-proxy.yml
generated
vendored
9
.github/workflows/__test-proxy.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
19
.github/workflows/__test-ruby.yml
generated
vendored
19
.github/workflows/__test-ruby.yml
generated
vendored
@@ -12,6 +12,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- v1
|
- v1
|
||||||
|
- 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
|
||||||
|
|||||||
95
.github/workflows/__unset-environment.yml
generated
vendored
Normal file
95
.github/workflows/__unset-environment.yml
generated
vendored
Normal 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 - Test unsetting environment variables
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
- v2
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
unset-environment:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-20210308
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-20210319
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-20210809
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: cached
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: latest
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: nightly-latest
|
||||||
|
name: Test unsetting environment variables
|
||||||
|
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:
|
||||||
|
db-location: ${{ runner.temp }}/customDbLocation
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: env -i PATH="$PATH" HOME="$HOME" ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
id: analysis
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
CPP_DB=${{ fromJson(steps.analysis.outputs.db-locations).cpp }}
|
||||||
|
if [[ ! -d $CPP_DB ]] || [[ ! $CPP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
||||||
|
echo "Did not create a database for CPP, or created it in the wrong location."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
CSHARP_DB=${{ fromJson(steps.analysis.outputs.db-locations).csharp }}
|
||||||
|
if [[ ! -d $CSHARP_DB ]] || [[ ! $CSHARP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
||||||
|
echo "Did not create a database for C Sharp, or created it in the wrong location."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
GO_DB=${{ fromJson(steps.analysis.outputs.db-locations).go }}
|
||||||
|
if [[ ! -d $GO_DB ]] || [[ ! $GO_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
||||||
|
echo "Did not create a database for Go, or created it in the wrong location."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
JAVA_DB=${{ fromJson(steps.analysis.outputs.db-locations).java }}
|
||||||
|
if [[ ! -d $JAVA_DB ]] || [[ ! $JAVA_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
||||||
|
echo "Did not create a database for Java, or created it in the wrong location."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
JAVASCRIPT_DB=${{ fromJson(steps.analysis.outputs.db-locations).javascript }}
|
||||||
|
if [[ ! -d $JAVASCRIPT_DB ]] || [[ ! $JAVASCRIPT_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
||||||
|
echo "Did not create a database for Javascript, or created it in the wrong location."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
PYTHON_DB=${{ fromJson(steps.analysis.outputs.db-locations).python }}
|
||||||
|
if [[ ! -d $PYTHON_DB ]] || [[ ! $PYTHON_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
||||||
|
echo "Did not create a database for Python, or created it in the wrong location."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
102
.github/workflows/__upload-ref-sha-input.yml
generated
vendored
Normal file
102
.github/workflows/__upload-ref-sha-input.yml
generated
vendored
Normal 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
|
||||||
|
- v1
|
||||||
|
- 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
146
.github/workflows/__with-checkout-path.yml
generated
vendored
Normal 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
|
||||||
|
- v1
|
||||||
|
- 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
|
||||||
@@ -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
|
||||||
|
|||||||
8
.github/workflows/codeql.yml
vendored
8
.github/workflows/codeql.yml
vendored
@@ -2,9 +2,9 @@ name: "CodeQL action"
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, v1]
|
branches: [main, v1, v2]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, v1]
|
branches: [main, v1, 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:
|
||||||
|
|||||||
22
.github/workflows/post-release-mergeback.yml
vendored
22
.github/workflows/post-release-mergeback.yml
vendored
@@ -15,6 +15,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- v1
|
- v1
|
||||||
|
- v2
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
merge-back:
|
merge-back:
|
||||||
@@ -25,13 +26,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: |
|
||||||
@@ -90,7 +94,7 @@ jobs:
|
|||||||
git push origin --follow-tags "$VERSION"
|
git push origin --follow-tags "$VERSION"
|
||||||
|
|
||||||
- name: Create mergeback branch
|
- name: Create mergeback branch
|
||||||
if: steps.check.outputs.exists != 'true'
|
if: steps.check.outputs.exists != 'true' && contains(github.ref, '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 }}"
|
||||||
@@ -100,11 +104,13 @@ jobs:
|
|||||||
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"
|
||||||
|
|
||||||
|
|||||||
127
.github/workflows/pr-checks.yml
vendored
127
.github/workflows/pr-checks.yml
vendored
@@ -2,7 +2,7 @@ name: PR Checks (Basic Checks and Runner)
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, v1]
|
branches: [main, v1, 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
|
||||||
@@ -60,19 +92,21 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-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 run-script test
|
||||||
run: npm run-script test
|
run: npm run-script 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 +131,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 +156,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 +181,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 +219,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 +253,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 +266,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 +305,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 +341,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 +384,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 +422,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: |
|
||||||
@@ -393,3 +440,43 @@ jobs:
|
|||||||
# Deliberately don't use TEST_MODE here. This is specifically testing
|
# Deliberately don't use TEST_MODE here. This is specifically testing
|
||||||
# the compatibility with the API.
|
# the compatibility with the API.
|
||||||
runner/dist/codeql-runner-linux upload --sarif-file src/testdata/empty-sarif.sarif --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
runner/dist/codeql-runner-linux upload --sarif-file src/testdata/empty-sarif.sarif --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
runner-extractor-ram-threads-options:
|
||||||
|
name: Runner ubuntu extractor RAM and threads options
|
||||||
|
needs: [check-js, check-node-modules]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 45
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Build runner
|
||||||
|
run: |
|
||||||
|
cd runner
|
||||||
|
npm install
|
||||||
|
npm run build-runner
|
||||||
|
|
||||||
|
- name: Run init
|
||||||
|
run: |
|
||||||
|
runner/dist/codeql-runner-linux init --ram=230 --threads=1 --repository $GITHUB_REPOSITORY --languages java --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Assert Results
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
. ./codeql-runner/codeql-env.sh
|
||||||
|
if [ "${CODEQL_RAM}" != "230" ]; then
|
||||||
|
echo "CODEQL_RAM is '${CODEQL_RAM}' instead of 230"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "${CODEQL_EXTRACTOR_JAVA_RAM}" != "230" ]; then
|
||||||
|
echo "CODEQL_EXTRACTOR_JAVA_RAM is '${CODEQL_EXTRACTOR_JAVA_RAM}' instead of 230"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "${CODEQL_THREADS}" != "1" ]; then
|
||||||
|
echo "CODEQL_THREADS is '${CODEQL_THREADS}' instead of 1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "${CODEQL_EXTRACTOR_JAVA_THREADS}" != "1" ]; then
|
||||||
|
echo "CODEQL_EXTRACTOR_JAVA_THREADS is '${CODEQL_EXTRACTOR_JAVA_THREADS}' instead of 1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
13
.github/workflows/python-deps.yml
vendored
13
.github/workflows/python-deps.yml
vendored
@@ -2,7 +2,7 @@ name: Test Python Package Installation on Linux and Mac
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, v1]
|
branches: [main, v1, 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
|
||||||
@@ -24,7 +25,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 +71,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
|
||||||
@@ -121,11 +122,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
|
||||||
|
|||||||
54
.github/workflows/release-runner.yml
vendored
54
.github/workflows/release-runner.yml
vendored
@@ -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
|
|
||||||
73
.github/workflows/split.yml
vendored
73
.github/workflows/split.yml
vendored
@@ -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
|
|
||||||
3
.github/workflows/update-dependencies.yml
vendored
3
.github/workflows/update-dependencies.yml
vendored
@@ -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:
|
||||||
|
|||||||
48
.github/workflows/update-release-branch.yml
vendored
48
.github/workflows/update-release-branch.yml
vendored
@@ -1,26 +1,35 @@
|
|||||||
name: Update release branch
|
name: Update release branch
|
||||||
on:
|
on:
|
||||||
schedule:
|
# You can trigger this workflow via workflow dispatch to start a release.
|
||||||
- cron: 0 9 * * 1
|
# This will open a PR to update the v2 release branch.
|
||||||
repository_dispatch:
|
|
||||||
# Example of how to trigger this:
|
|
||||||
# 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:
|
||||||
|
- 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
|
||||||
|
|
||||||
@@ -34,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}
|
||||||
|
|||||||
@@ -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
2
.gitignore
vendored
@@ -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
|
||||||
|
|||||||
104
CHANGELOG.md
104
CHANGELOG.md
@@ -1,4 +1,106 @@
|
|||||||
# CodeQL Action and CodeQL Runner Changelog
|
# CodeQL Action Changelog
|
||||||
|
|
||||||
|
## [UNRELEASED]
|
||||||
|
|
||||||
|
- 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)
|
||||||
|
|
||||||
|
## 2.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)
|
||||||
|
|
||||||
|
## 2.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)
|
||||||
|
|
||||||
|
## 2.1.6 - 30 Mar 2022
|
||||||
|
|
||||||
|
- [v2+ only] The CodeQL Action now runs on Node.js v16. [#1000](https://github.com/github/codeql-action/pull/1000)
|
||||||
|
- 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.1–3.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
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.7.3. [#842](https://github.com/github/codeql-action/pull/842)
|
||||||
|
|
||||||
|
## 1.0.25 - 06 Dec 2021
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 1.0.24 - 23 Nov 2021
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.7.2. [#827](https://github.com/github/codeql-action/pull/827)
|
||||||
|
|
||||||
|
## 1.0.23 - 16 Nov 2021
|
||||||
|
|
||||||
|
- The `upload-sarif` action now allows multiple uploads in a single job, as long as they have different categories. [#801](https://github.com/github/codeql-action/pull/801)
|
||||||
|
- Update default CodeQL bundle version to 2.7.1. [#816](https://github.com/github/codeql-action/pull/816)
|
||||||
|
|
||||||
|
## 1.0.22 - 04 Nov 2021
|
||||||
|
|
||||||
|
- The `init` step of the Action now supports `ram` and `threads` inputs to limit resource use of CodeQL extractors. These inputs also serve as defaults to the subsequent `analyze` step, which finalizes the database and executes queries. [#738](https://github.com/github/codeql-action/pull/738)
|
||||||
|
- When used with CodeQL 2.7.1 or above, the Action now includes custom query help in the analysis results uploaded to GitHub code scanning, if available. To add help text for a custom query, create a Markdown file next to the `.ql` file containing the query, using the same base name but the file extension `.md`. [#804](https://github.com/github/codeql-action/pull/804)
|
||||||
|
|
||||||
## 1.0.21 - 28 Oct 2021
|
## 1.0.21 - 28 Oct 2021
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
**/* @github/codeql-action-reviewers
|
**/* @github/codeql-action-reviewers
|
||||||
|
|
||||||
|
/python-setup/ @github/codeql-python @github/codeql-action-reviewers
|
||||||
|
|||||||
@@ -61,16 +61,41 @@ 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 `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 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 v2" pull request is merged into the `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 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 v2" pull request is merged into the `v2` branch, the "Update release branch" workflow will create a "Merge v2 into v1" pull request to merge the changes since the last release into the `v1` release branch.
|
||||||
|
This ensures we keep both the `v1` and `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 v2 into v1" PR has been merged to `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. Managing these PR checks manually is time consuming and complex. Here is a semi-automated approach.
|
||||||
|
|
||||||
|
To regenerate the PR jobs for the action:
|
||||||
|
|
||||||
|
1. From a terminal, run the following commands (replace `SHA` with the sha of the commit whose checks you want to use, typically this should be the latest from `main`):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
SHA= ####
|
||||||
|
CHECKS="$(gh api repos/github/codeql-action/commits/${SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or . == "Update dependencies" or . == "Update Supported Enterprise Server Versions" | not)]')"
|
||||||
|
echo "{\"contexts\": ${CHECKS}}" > checks.json
|
||||||
|
gh api -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
|
||||||
|
gh api -X "PATCH" repos/github/codeql-action/branches/v2/protection/required_status_checks --input checks.json
|
||||||
|
gh api -X "PATCH" repos/github/codeql-action/branches/v1/protection/required_status_checks --input checks.json
|
||||||
|
````
|
||||||
|
|
||||||
|
2. Go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules have been updated.
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
|
|||||||
22
README.md
22
README.md
@@ -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,7 +64,7 @@ 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
|
# 📚 https://git.io/JvXDl
|
||||||
@@ -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>
|
||||||
```
|
```
|
||||||
@@ -145,4 +145,4 @@ The very first time code scanning is run and if it is on a pull request, you wil
|
|||||||
|
|
||||||
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.
|
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)
|
For more information and other causes of this message, see [Reasons for the "Analysis not found" message](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/setting-up-code-scanning-for-a-repository#reasons-for-the-analysis-not-found-message)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: 'CodeQL: Finish'
|
name: "CodeQL: Finish"
|
||||||
description: 'Finalize CodeQL database'
|
description: "Finalize CodeQL database"
|
||||||
author: 'GitHub'
|
author: "GitHub"
|
||||||
inputs:
|
inputs:
|
||||||
check_name:
|
check_name:
|
||||||
description: The name of the check run to add text to.
|
description: The name of the check run to add text to.
|
||||||
@@ -8,9 +8,9 @@ inputs:
|
|||||||
output:
|
output:
|
||||||
description: The path of the directory in which to save the SARIF results
|
description: The path of the directory in which to save the SARIF results
|
||||||
required: false
|
required: false
|
||||||
default: '../results'
|
default: "../results"
|
||||||
upload:
|
upload:
|
||||||
description: Upload the SARIF file
|
description: Upload the SARIF file to Code Scanning
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
cleanup-level:
|
cleanup-level:
|
||||||
@@ -18,7 +18,12 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: "brutal"
|
default: "brutal"
|
||||||
ram:
|
ram:
|
||||||
description: Override the amount of memory in MB to be used by CodeQL. By default, almost all the memory of the machine is used.
|
description: >-
|
||||||
|
The amount of memory in MB that can be used by CodeQL for database finalization and query execution.
|
||||||
|
By default, this action will use the same amount of memory as previously set in the "init" action.
|
||||||
|
If the "init" action also does not have an explicit "ram" input, this action will use most of the
|
||||||
|
memory available in the system (which for GitHub-hosted runners is 6GB for Linux, 5.5GB for Windows,
|
||||||
|
and 13GB for macOS).
|
||||||
required: false
|
required: false
|
||||||
add-snippets:
|
add-snippets:
|
||||||
description: Specify whether or not to add code snippets to the output sarif file.
|
description: Specify whether or not to add code snippets to the output sarif file.
|
||||||
@@ -29,12 +34,23 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
threads:
|
threads:
|
||||||
description: The number of threads to be used by CodeQL.
|
description: >-
|
||||||
|
The number of threads that can be used by CodeQL for database finalization and query execution.
|
||||||
|
By default, this action will use the same number of threads as previously set in the "init" action.
|
||||||
|
If the "init" action also does not have an explicit "threads" input, this action will use all the
|
||||||
|
hardware threads available in the system (which for GitHub-hosted runners is 2 for Linux and Windows
|
||||||
|
and 3 for macOS).
|
||||||
required: false
|
required: false
|
||||||
checkout_path:
|
checkout_path:
|
||||||
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
|
||||||
@@ -42,6 +58,10 @@ inputs:
|
|||||||
description: Whether to upload the resulting CodeQL database
|
description: Whether to upload the resulting CodeQL database
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
|
wait-for-processing:
|
||||||
|
description: If true, the Action will wait for the uploaded SARIF to be processed before completing.
|
||||||
|
required: true
|
||||||
|
default: "true"
|
||||||
token:
|
token:
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
matrix:
|
matrix:
|
||||||
@@ -49,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: "node16"
|
||||||
main: '../lib/analyze-action.js'
|
main: "../lib/analyze-action.js"
|
||||||
|
|||||||
@@ -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: 'node16'
|
||||||
main: '../lib/autobuild-action.js'
|
main: '../lib/autobuild-action.js'
|
||||||
|
|||||||
@@ -41,9 +41,37 @@ inputs:
|
|||||||
source-root:
|
source-root:
|
||||||
description: Path of the root source code directory, relative to $GITHUB_WORKSPACE.
|
description: Path of the root source code directory, relative to $GITHUB_WORKSPACE.
|
||||||
required: false
|
required: false
|
||||||
|
ram:
|
||||||
|
description: >-
|
||||||
|
The amount of memory in MB that can be used by CodeQL extractors.
|
||||||
|
By default, CodeQL extractors will use most of the memory available in the system
|
||||||
|
(which for GitHub-hosted runners is 6GB for Linux, 5.5GB for Windows, and 13GB for macOS).
|
||||||
|
This input also sets the amount of memory that can later be used by the "analyze" action.
|
||||||
|
required: false
|
||||||
|
threads:
|
||||||
|
description: >-
|
||||||
|
The number of threads that can be used by CodeQL extractors.
|
||||||
|
By default, CodeQL extractors will use all the hardware threads available in the system
|
||||||
|
(which for GitHub-hosted runners is 2 for Linux and Windows and 3 for macOS).
|
||||||
|
This input also sets the number of threads that can later be used by the "analyze" action.
|
||||||
|
required: false
|
||||||
|
debug:
|
||||||
|
description: Enable debugging mode. This will result in more output being produced which may be useful when debugging certain issues.
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
debug-artifact-name:
|
||||||
|
description: >-
|
||||||
|
The name of the artifact to store debugging information in.
|
||||||
|
This is only used when debug mode is enabled.
|
||||||
|
required: false
|
||||||
|
debug-database-name:
|
||||||
|
description: >-
|
||||||
|
The name of the database uploaded to the debugging artifact.
|
||||||
|
This is only used when debug mode is enabled.
|
||||||
|
required: false
|
||||||
outputs:
|
outputs:
|
||||||
codeql-path:
|
codeql-path:
|
||||||
description: The path of the CodeQL binary used for analysis
|
description: The path of the CodeQL binary used for analysis
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node16'
|
||||||
main: '../lib/init-action.js'
|
main: '../lib/init-action.js'
|
||||||
|
|||||||
149
lib/actions-util.js
generated
149
lib/actions-util.js
generated
@@ -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.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.getToolCacheDirectory = 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"];
|
||||||
@@ -73,7 +76,7 @@ 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,15 +96,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}`);
|
||||||
return (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
core.info(e.stack || "NO STACK");
|
||||||
|
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";
|
||||||
}
|
}
|
||||||
@@ -301,7 +357,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,
|
||||||
@@ -372,8 +428,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
|
||||||
@@ -382,15 +454,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}.`);
|
||||||
@@ -401,6 +472,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.
|
||||||
*
|
*
|
||||||
@@ -411,7 +491,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;
|
||||||
@@ -426,6 +506,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()
|
||||||
@@ -444,6 +526,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) {
|
||||||
@@ -452,18 +536,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.";
|
||||||
/**
|
/**
|
||||||
@@ -476,8 +574,21 @@ 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
|
||||||
|
const testMode = process.env["TEST_MODE"] === "true" || false;
|
||||||
|
if (testMode) {
|
||||||
|
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();
|
||||||
@@ -567,11 +678,15 @@ 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;
|
||||||
return currentRef === defaultBranch;
|
return currentRef === defaultBranch;
|
||||||
}
|
}
|
||||||
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
|
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
|
||||||
|
function sanitizeArifactName(name) {
|
||||||
|
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
||||||
|
}
|
||||||
|
exports.sanitizeArifactName = sanitizeArifactName;
|
||||||
//# sourceMappingURL=actions-util.js.map
|
//# sourceMappingURL=actions-util.js.map
|
||||||
File diff suppressed because one or more lines are too long
117
lib/actions-util.test.js
generated
117
lib/actions-util.test.js
generated
@@ -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: {
|
||||||
@@ -440,4 +497,10 @@ on: ["push"]
|
|||||||
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
|
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
(0, ava_1.default)("sanitizeArifactName", (t) => {
|
||||||
|
t.deepEqual(actionsutil.sanitizeArifactName("hello-world_"), "hello-world_");
|
||||||
|
t.deepEqual(actionsutil.sanitizeArifactName("hello`world`"), "helloworld");
|
||||||
|
t.deepEqual(actionsutil.sanitizeArifactName("hello===123"), "hello123");
|
||||||
|
t.deepEqual(actionsutil.sanitizeArifactName("*m)a&n^y%i££n+v!a:l[i]d"), "manyinvalid");
|
||||||
|
});
|
||||||
//# sourceMappingURL=actions-util.test.js.map
|
//# sourceMappingURL=actions-util.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
4
lib/analysis-paths.js
generated
4
lib/analysis-paths.js
generated
@@ -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;
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analysis-paths.js","sourceRoot":"","sources":["../src/analysis-paths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAK7B,SAAS,qBAAqB,CAAC,QAAQ;IACrC,OAAO,CACL,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,CAC1E,CAAC;AACJ,CAAC;AAED,6FAA6F;AAChF,QAAA,+BAA+B,GAAG,cAAc,CAAC;AAE9D,uFAAuF;AACvF,SAAS,yBAAyB,CAAC,KAAe;IAChD,iCAAiC;IACjC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnD,uDAAuD;IACvD,IAAI,OAAO,CAAC,Q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b,MAAM,CAAC,YAAY,CACpB,CAAC;IACF,IAAI,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACrC,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC3C,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;KACzD;IACD,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC5C,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC;KAC1D;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;KAC5E;IAED,yEAAyE;IACzE,6EAA6E;IAC7E,wDAAwD;IACxD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACxD;AACH,CAAC;AArCD,wEAqCC"}
|
||||||
12
lib/analysis-paths.test.js
generated
12
lib/analysis-paths.test.js
generated
@@ -42,6 +42,10 @@ const util = __importStar(require("./util"));
|
|||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_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);
|
||||||
@@ -63,6 +67,10 @@ const util = __importStar(require("./util"));
|
|||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_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");
|
||||||
@@ -85,6 +93,10 @@ const util = __importStar(require("./util"));
|
|||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_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);
|
||||||
|
|||||||
@@ -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;SACV,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,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AAE,EAAE;YACb,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAwB;YACxE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,kBAAkB,CAAC;YACrD,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,KAAK;YAChB,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;YACnD,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;YACnD,iBAAiB,EAAE,KAAK;SACzB,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,oBAAoB,CAAC,CAAC;QAC9D,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
78
lib/analyze-action-env.test.js
generated
Normal file
78
lib/analyze-action-env.test.js
generated
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const ava_1 = __importDefault(require("ava"));
|
||||||
|
const sinon = __importStar(require("sinon"));
|
||||||
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
|
const analyze = __importStar(require("./analyze"));
|
||||||
|
const configUtils = __importStar(require("./config-utils"));
|
||||||
|
const testing_utils_1 = require("./testing-utils");
|
||||||
|
const util = __importStar(require("./util"));
|
||||||
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
|
// This test needs to be in its own file so that ava would run it in its own
|
||||||
|
// nodejs process. The code being tested is in analyze-action.ts, which runs
|
||||||
|
// immediately on load. So the file needs to be loaded during part of the test,
|
||||||
|
// and that can happen only once per nodejs process. If multiple such tests are
|
||||||
|
// in the same test file, ava would run them in the same nodejs process, and all
|
||||||
|
// but the first test would fail.
|
||||||
|
(0, ava_1.default)("analyze action with RAM & threads from environment variables", async (t) => {
|
||||||
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
|
process.env["GITHUB_SERVER_URL"] = "fake-server-url";
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "fake/repository";
|
||||||
|
sinon
|
||||||
|
.stub(actionsUtil, "createStatusReportBase")
|
||||||
|
.resolves({});
|
||||||
|
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
||||||
|
sinon.stub(configUtils, "getConfig").resolves({
|
||||||
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
|
languages: [],
|
||||||
|
packs: [],
|
||||||
|
});
|
||||||
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
|
requiredInputStub.withArgs("token").returns("fake-token");
|
||||||
|
requiredInputStub.withArgs("upload-database").returns("false");
|
||||||
|
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
||||||
|
optionalInputStub.withArgs("cleanup-level").returns("none");
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
||||||
|
// When there are no action inputs for RAM and threads, the action uses
|
||||||
|
// environment variables (passed down from the init action) to set RAM and
|
||||||
|
// threads usage.
|
||||||
|
process.env["CODEQL_THREADS"] = "-1";
|
||||||
|
process.env["CODEQL_RAM"] = "4992";
|
||||||
|
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
|
||||||
|
const runQueriesStub = sinon.stub(analyze, "runQueries");
|
||||||
|
const analyzeAction = require("./analyze-action");
|
||||||
|
// When analyze-action.ts loads, it runs an async function from the top
|
||||||
|
// level but does not wait for it to finish. To ensure that calls to
|
||||||
|
// runFinalize and runQueries are correctly captured by spies, we explicitly
|
||||||
|
// wait for the action promise to complete before starting verification.
|
||||||
|
await analyzeAction.runPromise;
|
||||||
|
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
|
||||||
|
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=4992");
|
||||||
|
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
|
||||||
|
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=4992");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=analyze-action-env.test.js.map
|
||||||
1
lib/analyze-action-env.test.js.map
Normal file
1
lib/analyze-action-env.test.js.map
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"analyze-action-env.test.js","sourceRoot":"","sources":["../src/analyze-action-env.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8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|
|||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const ava_1 = __importDefault(require("ava"));
|
||||||
|
const sinon = __importStar(require("sinon"));
|
||||||
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
|
const analyze = __importStar(require("./analyze"));
|
||||||
|
const configUtils = __importStar(require("./config-utils"));
|
||||||
|
const testing_utils_1 = require("./testing-utils");
|
||||||
|
const util = __importStar(require("./util"));
|
||||||
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
|
// This test needs to be in its own file so that ava would run it in its own
|
||||||
|
// nodejs process. The code being tested is in analyze-action.ts, which runs
|
||||||
|
// immediately on load. So the file needs to be loaded during part of the test,
|
||||||
|
// and that can happen only once per nodejs process. If multiple such tests are
|
||||||
|
// in the same test file, ava would run them in the same nodejs process, and all
|
||||||
|
// but the first test would fail.
|
||||||
|
(0, ava_1.default)("analyze action with RAM & threads from action inputs", async (t) => {
|
||||||
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
|
process.env["GITHUB_SERVER_URL"] = "fake-server-url";
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "fake/repository";
|
||||||
|
sinon
|
||||||
|
.stub(actionsUtil, "createStatusReportBase")
|
||||||
|
.resolves({});
|
||||||
|
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
||||||
|
sinon.stub(configUtils, "getConfig").resolves({
|
||||||
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
|
languages: [],
|
||||||
|
packs: [],
|
||||||
|
});
|
||||||
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
|
requiredInputStub.withArgs("token").returns("fake-token");
|
||||||
|
requiredInputStub.withArgs("upload-database").returns("false");
|
||||||
|
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
||||||
|
optionalInputStub.withArgs("cleanup-level").returns("none");
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
||||||
|
process.env["CODEQL_THREADS"] = "1";
|
||||||
|
process.env["CODEQL_RAM"] = "4992";
|
||||||
|
// Action inputs have precedence over environment variables.
|
||||||
|
optionalInputStub.withArgs("threads").returns("-1");
|
||||||
|
optionalInputStub.withArgs("ram").returns("3012");
|
||||||
|
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
|
||||||
|
const runQueriesStub = sinon.stub(analyze, "runQueries");
|
||||||
|
const analyzeAction = require("./analyze-action");
|
||||||
|
// When analyze-action.ts loads, it runs an async function from the top
|
||||||
|
// level but does not wait for it to finish. To ensure that calls to
|
||||||
|
// runFinalize and runQueries are correctly captured by spies, we explicitly
|
||||||
|
// wait for the action promise to complete before starting verification.
|
||||||
|
await analyzeAction.runPromise;
|
||||||
|
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
|
||||||
|
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=3012");
|
||||||
|
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
|
||||||
|
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=3012");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=analyze-action-input.test.js.map
|
||||||
1
lib/analyze-action-input.test.js.map
Normal file
1
lib/analyze-action-input.test.js.map
Normal file
@@ -0,0 +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;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,sDAAsD,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACvE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,KAAK;aACF,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC;aAC3C,QAAQ,CAAC,EAAkC,CAAC,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC;YAC5C,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EAAwE;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"}
|
||||||
105
lib/analyze-action.js
generated
105
lib/analyze-action.js
generated
@@ -19,8 +19,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.runPromise = exports.sendStatusReport = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
|
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");
|
||||||
@@ -31,22 +33,27 @@ const logging_1 = require("./logging");
|
|||||||
const repository_1 = require("./repository");
|
const repository_1 = require("./repository");
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(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);
|
||||||
}
|
}
|
||||||
|
exports.sendStatusReport = sendStatusReport;
|
||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
let uploadStats = undefined;
|
let uploadResult = undefined;
|
||||||
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);
|
||||||
@@ -65,11 +72,33 @@ async function run() {
|
|||||||
url: util.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
url: util.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
const outputDir = actionsUtil.getRequiredInput("output");
|
const outputDir = actionsUtil.getRequiredInput("output");
|
||||||
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads"), logger);
|
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger);
|
||||||
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram"));
|
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
||||||
|
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
||||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
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) {
|
||||||
|
// Upload the SARIF files as an Actions artifact for debugging
|
||||||
|
await uploadDebugArtifacts(config.languages.map((lang) => path.resolve(outputDir, `${lang}.sarif`)), outputDir, config.debugArtifactName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
|
if (config.debugMode) {
|
||||||
|
// Upload the logs as an Actions artifact for debugging
|
||||||
|
const toUpload = [];
|
||||||
|
for (const language of config.languages) {
|
||||||
|
toUpload.push(...listFolder(path.resolve(util.getCodeQLDatabasePath(config, language), "log")));
|
||||||
|
}
|
||||||
|
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
|
||||||
|
toUpload.push(...listFolder(path.resolve(config.dbLocation, "log")));
|
||||||
|
}
|
||||||
|
await uploadDebugArtifacts(toUpload, config.dbLocation, config.debugArtifactName);
|
||||||
|
if (!(await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING))) {
|
||||||
|
// Before multi-language tracing, we wrote a compound-build-tracer.log in the temp dir
|
||||||
|
await uploadDebugArtifacts([path.resolve(config.tempDir, "compound-build-tracer.log")], config.tempDir, config.debugArtifactName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
|
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
|
||||||
await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
||||||
@@ -80,13 +109,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") {
|
||||||
uploadStats = 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");
|
||||||
}
|
}
|
||||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
// Possibly upload the database bundles for remote queries
|
||||||
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger);
|
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger);
|
||||||
|
if (uploadResult !== undefined &&
|
||||||
|
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)());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (origError) {
|
catch (origError) {
|
||||||
const error = origError instanceof Error ? origError : new Error(String(origError));
|
const error = origError instanceof Error ? origError : new Error(String(origError));
|
||||||
@@ -94,14 +128,27 @@ 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) {
|
||||||
|
try {
|
||||||
|
// Upload the database bundles as an Actions artifact for debugging
|
||||||
|
const toUpload = [];
|
||||||
|
for (const language of config.languages) {
|
||||||
|
toUpload.push(await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd), `${config.debugDatabaseName}-${language}`));
|
||||||
|
}
|
||||||
|
await uploadDebugArtifacts(toUpload, config.dbLocation, config.debugArtifactName);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log(`Failed to upload database debug bundles: ${error}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (core.isDebug() && config !== undefined) {
|
if (core.isDebug() && config !== undefined) {
|
||||||
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) {
|
||||||
@@ -124,19 +171,45 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (runStats && uploadStats) {
|
if (runStats && uploadResult) {
|
||||||
await sendStatusReport(startedAt, { ...runStats, ...uploadStats });
|
await sendStatusReport(startedAt, config, {
|
||||||
|
...runStats,
|
||||||
|
...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) {
|
||||||
|
let suffix = "";
|
||||||
|
const matrix = actionsUtil.getRequiredInput("matrix");
|
||||||
|
if (matrix !== undefined && matrix !== "null") {
|
||||||
|
for (const entry of Object.entries(JSON.parse(matrix)).sort())
|
||||||
|
suffix += `-${entry[1]}`;
|
||||||
|
}
|
||||||
|
await artifact.create().uploadArtifact(actionsUtil.sanitizeArifactName(`${artifactName}${suffix}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir));
|
||||||
|
}
|
||||||
|
function listFolder(dir) {
|
||||||
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
|
const files = [];
|
||||||
|
for (const entry of entries) {
|
||||||
|
if (entry.isFile()) {
|
||||||
|
files.push(path.resolve(dir, entry.name));
|
||||||
|
}
|
||||||
|
else if (entry.isDirectory()) {
|
||||||
|
files.push(...listFolder(path.resolve(dir, entry.name)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
exports.runPromise = run();
|
||||||
async function runWrapper() {
|
async function runWrapper() {
|
||||||
try {
|
try {
|
||||||
await run();
|
await exports.runPromise;
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(`analyze action failed: ${error}`);
|
core.setFailed(`analyze action failed: ${error}`);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
34
lib/analyze.js
generated
34
lib/analyze.js
generated
@@ -29,6 +29,7 @@ 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) {
|
||||||
@@ -130,14 +131,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"}`)
|
||||||
@@ -235,9 +233,29 @@ function packWithVersionToQuerySuiteEntry(pack) {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
||||||
// Delete the tracer config env var to avoid tracing ourselves
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
||||||
fs.mkdirSync(outputDir, { recursive: true });
|
// 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];
|
||||||
|
}
|
||||||
|
// After switching to Node16, this entire block can be replaced with `await fs.promises.rm(outputDir, { recursive: true, force: true });`.
|
||||||
|
try {
|
||||||
|
await fs.promises.rmdir(outputDir, {
|
||||||
|
recursive: true,
|
||||||
|
maxRetries: 5,
|
||||||
|
retryDelay: 2000,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if ((error === null || error === void 0 ? void 0 : error.code) !== "ENOENT") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await fs.promises.mkdir(outputDir, { recursive: true });
|
||||||
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger);
|
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger);
|
||||||
}
|
}
|
||||||
exports.runFinalize = runFinalize;
|
exports.runFinalize = runFinalize;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
4
lib/analyze.test.js
generated
4
lib/analyze.test.js
generated
@@ -125,6 +125,10 @@ const util = __importStar(require("./util"));
|
|||||||
},
|
},
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs,
|
packs,
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_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,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
34
lib/api-client.js
generated
34
lib/api-client.js
generated
@@ -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
|
||||||
@@ -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;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEvC,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,+FAAc,CAAA;IACd,+FAAc,CAAA;AAChB,CAAC,EAHW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAGrC;AAeM,MAAM,YAAY,GAAG,UAC1B,UAAoC,EACpC,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,EAAE;IAE9B,MAAM,IAAI,GACR,CAAC,aAAa,IAAI,UAAU,CAAC,gBAAgB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC;IACpE,MAAM,eAAe,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,IAAI,eAAe,CACxB,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE;QAClC,OAAO,EAAE,SAAS,CAAC,UAA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AO,CAAC;QAC/B,GAAG,EAAE,IAAA,0BAAmB,EAAC,mBAAmB,CAAC;KAC9C,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,qFAAqF;AACrF,+CAA+C;AAC/C,SAAgB,mBAAmB;IACjC,OAAO,IAAA,oBAAY,EAAC,aAAa,EAAE,CAAC,CAAC;AACvC,CAAC;AAFD,kDAEC;AAED,IAAI,mBAAmB,GAA8B,SAAS,CAAC;AAE/D;;;;;;;GAOG;AACI,KAAK,UAAU,2BAA2B;IAC/C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KAC1E;IACD,IAAI,mBAAmB,KAAK,SAAS,EAAE;QACrC,mBAAmB,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,CAAC,CAAC;KACpE;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AARD,kEAQC"}
|
||||||
@@ -1 +1 @@
|
|||||||
{ "maximumVersion": "3.3", "minimumVersion": "3.0" }
|
{ "maximumVersion": "3.5", "minimumVersion": "3.1" }
|
||||||
|
|||||||
9
lib/autobuild-action.js
generated
9
lib/autobuild-action.js
generated
@@ -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,
|
||||||
@@ -54,6 +52,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,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AC9C;KACF;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CACZ,mIACE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;QACF,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,yBAAyB,CAC7B,SAAS,EACT,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,EAC1B,QAAQ,EACR,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAC1D,CAAC;QACF,OAAO;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"}
|
||||||
108
lib/codeql.js
generated
108
lib/codeql.js
generated
@@ -22,7 +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.getExtraOptions = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.convertToSemVer = exports.getCodeQLURLVersion = exports.setupCodeQL = exports.getCodeQLActionRepository = exports.CODEQL_VERSION_NEW_TRACING = 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_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"));
|
||||||
@@ -37,6 +37,7 @@ const languages_1 = require("./languages");
|
|||||||
const toolcache = __importStar(require("./toolcache"));
|
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");
|
||||||
class CommandInvocationError extends Error {
|
class CommandInvocationError extends Error {
|
||||||
constructor(cmd, args, exitCode, error) {
|
constructor(cmd, args, exitCode, error) {
|
||||||
super(`Failure invoking ${cmd} with arguments ${args}.\n
|
super(`Failure invoking ${cmd} with arguments ${args}.\n
|
||||||
@@ -58,9 +59,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
|
||||||
@@ -72,22 +74,18 @@ const CODEQL_VERSION_METRICS = "2.5.5";
|
|||||||
const CODEQL_VERSION_GROUP_RULES = "2.5.5";
|
const CODEQL_VERSION_GROUP_RULES = "2.5.5";
|
||||||
const CODEQL_VERSION_SARIF_GROUP = "2.5.3";
|
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";
|
||||||
|
exports.CODEQL_VERSION_ML_POWERED_QUERIES = "2.7.5";
|
||||||
/**
|
/**
|
||||||
* Version above which we use the CLI's indirect build tracing and
|
* This variable controls using the new style of tracing from the CodeQL
|
||||||
* multi-language tracing features.
|
* CLI. In particular, with versions above this we will use both indirect
|
||||||
|
* tracing, and multi-language tracing together with database clusters.
|
||||||
*
|
*
|
||||||
* There are currently three blockers on the CLI's side to enabling this:
|
* Note that there were bugs in both of these features that were fixed in
|
||||||
* (1) The logs directory should be created for a DB cluster, as some
|
* release 2.7.0 of the CodeQL CLI, therefore this flag is only enabled for
|
||||||
* autobuilders expect it to be present.
|
* versions above that.
|
||||||
* (2) The SEMMLE_PRELOAD_libtrace{32,64}? env variables need to be set.
|
|
||||||
* (3) The .environment and .win32env files need to be created next to
|
|
||||||
* the DB spec.
|
|
||||||
*
|
|
||||||
* Once _all_ of these are fixed, we can enable this by setting the
|
|
||||||
* version flag below to the earliest version of the CLI that resolved
|
|
||||||
* the above issues.
|
|
||||||
*/
|
*/
|
||||||
exports.CODEQL_VERSION_NEW_TRACING = "99.99.99";
|
exports.CODEQL_VERSION_NEW_TRACING = "2.7.0";
|
||||||
function getCodeQLBundleName() {
|
function getCodeQLBundleName() {
|
||||||
let platform;
|
let platform;
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@@ -196,6 +194,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}`;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Set up CodeQL CLI access.
|
||||||
|
*
|
||||||
|
* @param codeqlURL
|
||||||
|
* @param apiDetails
|
||||||
|
* @param tempDir
|
||||||
|
* @param toolCacheDir
|
||||||
|
* @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, toolCacheDir, variant, logger, checkVersion) {
|
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, 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
|
||||||
@@ -220,7 +231,7 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
|||||||
// 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", toolCacheDir, logger);
|
||||||
if (codeqlVersions.length === 1) {
|
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], toolCacheDir, logger);
|
||||||
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}`);
|
||||||
@@ -358,16 +369,35 @@ function getCachedCodeQL() {
|
|||||||
return cachedCodeQL;
|
return cachedCodeQL;
|
||||||
}
|
}
|
||||||
exports.getCachedCodeQL = getCachedCodeQL;
|
exports.getCachedCodeQL = getCachedCodeQL;
|
||||||
|
/**
|
||||||
|
* Get a real, newly created CodeQL instance for testing. The instance refers to
|
||||||
|
* a non-existent placeholder codeql command, so tests that use this function
|
||||||
|
* should also stub the toolrunner.ToolRunner constructor.
|
||||||
|
*/
|
||||||
|
async function getCodeQLForTesting() {
|
||||||
|
return getCodeQLForCmd("codeql-for-testing", false);
|
||||||
|
}
|
||||||
|
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"]);
|
||||||
|
util.cacheCodeQlVersion(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
},
|
},
|
||||||
async printVersion() {
|
async printVersion() {
|
||||||
await runTool(cmd, ["version", "--format=json"]);
|
await runTool(cmd, ["version", "--format=json"]);
|
||||||
@@ -422,14 +452,17 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
...getExtraOptionsFromEnv(["database", "init"]),
|
...getExtraOptionsFromEnv(["database", "init"]),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
async databaseInitCluster(databasePath, languages, sourceRoot, processName, processLevel) {
|
async databaseInitCluster(config, sourceRoot, processName, processLevel) {
|
||||||
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}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -437,7 +470,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
"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"]),
|
||||||
@@ -506,7 +539,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);
|
||||||
@@ -568,11 +606,14 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
codeqlArgs.push("--print-metrics-summary");
|
codeqlArgs.push("--print-metrics-summary");
|
||||||
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_GROUP_RULES))
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_GROUP_RULES))
|
||||||
codeqlArgs.push("--sarif-group-rules-by-pack");
|
codeqlArgs.push("--sarif-group-rules-by-pack");
|
||||||
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_CUSTOM_QUERY_HELP))
|
||||||
|
codeqlArgs.push("--sarif-add-query-help");
|
||||||
if (automationDetailsId !== undefined &&
|
if (automationDetailsId !== undefined &&
|
||||||
(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);
|
||||||
},
|
},
|
||||||
@@ -627,19 +668,30 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
"cleanup",
|
"cleanup",
|
||||||
databasePath,
|
databasePath,
|
||||||
`--mode=${cleanupLevel}`,
|
`--mode=${cleanupLevel}`,
|
||||||
|
...getExtraOptionsFromEnv(["database", "cleanup"]),
|
||||||
];
|
];
|
||||||
await runTool(cmd, codeqlArgs);
|
await runTool(cmd, codeqlArgs);
|
||||||
},
|
},
|
||||||
async databaseBundle(databasePath, outputFilePath) {
|
async databaseBundle(databasePath, outputFilePath, databaseName) {
|
||||||
const args = [
|
const args = [
|
||||||
"database",
|
"database",
|
||||||
"bundle",
|
"bundle",
|
||||||
databasePath,
|
databasePath,
|
||||||
`--output=${outputFilePath}`,
|
`--output=${outputFilePath}`,
|
||||||
|
`--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()}`);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
23
lib/codeql.test.js
generated
23
lib/codeql.test.js
generated
@@ -23,9 +23,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const nock_1 = __importDefault(require("nock"));
|
const nock_1 = __importDefault(require("nock"));
|
||||||
|
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 logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
@@ -217,4 +219,25 @@ ava_1.default.beforeEach(() => {
|
|||||||
const repoEnv = codeql.getCodeQLActionRepository(logger);
|
const repoEnv = codeql.getCodeQLActionRepository(logger);
|
||||||
t.deepEqual(repoEnv, "xxx/yyy");
|
t.deepEqual(repoEnv, "xxx/yyy");
|
||||||
});
|
});
|
||||||
|
(0, ava_1.default)("databaseInterpretResults() does not set --sarif-add-query-help for 2.7.0", async (t) => {
|
||||||
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
||||||
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "");
|
||||||
|
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) => {
|
||||||
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
||||||
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "");
|
||||||
|
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent");
|
||||||
|
});
|
||||||
|
function stubToolRunnerConstructor() {
|
||||||
|
const runnerObjectStub = sinon.createStubInstance(toolrunner.ToolRunner);
|
||||||
|
runnerObjectStub.exec.resolves(0);
|
||||||
|
const runnerConstructorStub = sinon.stub(toolrunner, "ToolRunner");
|
||||||
|
runnerConstructorStub.returns(runnerObjectStub);
|
||||||
|
return runnerConstructorStub;
|
||||||
|
}
|
||||||
//# sourceMappingURL=codeql.test.js.map
|
//# sourceMappingURL=codeql.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
80
lib/config-utils.js
generated
80
lib/config-utils.js
generated
@@ -25,8 +25,11 @@ const path = __importStar(require("path"));
|
|||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
|
const codeql_1 = require("./codeql");
|
||||||
const externalQueries = __importStar(require("./external-queries"));
|
const externalQueries = __importStar(require("./external-queries"));
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
|
const util_1 = require("./util");
|
||||||
// Property names from the user-supplied config file.
|
// Property names from the user-supplied config file.
|
||||||
const NAME_PROPERTY = "name";
|
const NAME_PROPERTY = "name";
|
||||||
const DISABLE_DEFAULT_QUERIES_PROPERTY = "disable-default-queries";
|
const DISABLE_DEFAULT_QUERIES_PROPERTY = "disable-default-queries";
|
||||||
@@ -115,14 +118,35 @@ 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, suiteName, 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), the repo is
|
||||||
|
// opted into the ML-powered queries beta, and a user hasn't already added the ML-powered query
|
||||||
|
// pack, then add the ML-powered query pack so that we run ML-powered queries.
|
||||||
|
if (
|
||||||
|
// Disable ML-powered queries on Windows
|
||||||
|
process.platform !== "win32" &&
|
||||||
|
languages.includes("javascript") &&
|
||||||
|
(found === "security-extended" || found === "security-and-quality") &&
|
||||||
|
!((_a = packs.javascript) === null || _a === void 0 ? void 0 : _a.some((pack) => pack.packName === util_1.ML_POWERED_JS_QUERIES_PACK_NAME)) &&
|
||||||
|
(await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled)) &&
|
||||||
|
(await (0, util_1.codeQlVersionAbove)(codeQL, codeql_1.CODEQL_VERSION_ML_POWERED_QUERIES))) {
|
||||||
|
if (!packs.javascript) {
|
||||||
|
packs.javascript = [];
|
||||||
|
}
|
||||||
|
packs.javascript.push(await (0, util_1.getMlPoweredJsQueriesPack)(codeQL));
|
||||||
|
injectedMlQueries = true;
|
||||||
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
||||||
@@ -179,8 +203,13 @@ 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, queryUses, tempDir, workspacePath, apiDetails, logger, configFile) {
|
async function parseQueryUses(languages, codeQL, resultMap, packs, queryUses, tempDir, workspacePath, apiDetails, featureFlags, logger, configFile) {
|
||||||
queryUses = queryUses.trim();
|
queryUses = queryUses.trim();
|
||||||
if (queryUses === "") {
|
if (queryUses === "") {
|
||||||
throw new Error(getQueryUsesInvalid(configFile));
|
throw new Error(getQueryUsesInvalid(configFile));
|
||||||
@@ -188,15 +217,15 @@ async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir,
|
|||||||
// 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, queryUses, 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
|
||||||
@@ -404,13 +433,16 @@ async function getLanguages(codeQL, languagesInput, repository, apiDetails, logg
|
|||||||
}
|
}
|
||||||
return parsedLanguages;
|
return parsedLanguages;
|
||||||
}
|
}
|
||||||
async function addQueriesFromWorkflow(codeQL, queriesInput, languages, resultMap, tempDir, workspacePath, apiDetails, 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, query, tempDir, workspacePath, apiDetails, 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,
|
||||||
@@ -418,14 +450,14 @@ async function addQueriesFromWorkflow(codeQL, queriesInput, languages, resultMap
|
|||||||
// 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, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, 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 = {};
|
||||||
@@ -436,10 +468,11 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
await addDefaultQueries(codeQL, languages, queries);
|
await addDefaultQueries(codeQL, languages, queries);
|
||||||
if (queriesInput) {
|
|
||||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, workspacePath, apiDetails, logger);
|
|
||||||
}
|
|
||||||
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) {
|
||||||
|
injectedMlQueries = await addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureFlags, logger);
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
@@ -452,13 +485,17 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
|
|||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
|
debugMode,
|
||||||
|
debugArtifactName,
|
||||||
|
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, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||||
var _a;
|
var _a;
|
||||||
let parsedYAML;
|
let parsedYAML;
|
||||||
if (isLocal(configFile)) {
|
if (isLocal(configFile)) {
|
||||||
@@ -499,12 +536,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);
|
||||||
// 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 addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, workspacePath, apiDetails, 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) {
|
||||||
@@ -517,7 +556,7 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
typeof query[QUERIES_USES_PROPERTY] !== "string") {
|
typeof query[QUERIES_USES_PROPERTY] !== "string") {
|
||||||
throw new Error(getQueryUsesInvalid(configFile));
|
throw new Error(getQueryUsesInvalid(configFile));
|
||||||
}
|
}
|
||||||
await parseQueryUses(languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir, workspacePath, apiDetails, logger, configFile);
|
await parseQueryUses(languages, codeQL, queries, packs, query[QUERIES_USES_PROPERTY], tempDir, workspacePath, apiDetails, featureFlags, logger, configFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
||||||
@@ -542,7 +581,6 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
paths.push(validateAndSanitisePath(includePath, PATHS_PROPERTY, configFile, logger));
|
paths.push(validateAndSanitisePath(includePath, PATHS_PROPERTY, configFile, logger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY]) !== null && _a !== void 0 ? _a : {}, packsInput, languages, configFile);
|
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
@@ -555,6 +593,10 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
|
debugMode,
|
||||||
|
debugArtifactName,
|
||||||
|
debugDatabaseName,
|
||||||
|
injectedMlQueries,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -680,16 +722,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, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, 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, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, 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
139
lib/config-utils.test.js
generated
139
lib/config-utils.test.js
generated
@@ -31,6 +31,7 @@ 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");
|
||||||
const configUtils = __importStar(require("./config-utils"));
|
const configUtils = __importStar(require("./config-utils"));
|
||||||
|
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");
|
||||||
@@ -88,8 +89,8 @@ function mockListLanguages(languages) {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
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);
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("loading config saves config", async (t) => {
|
(0, ava_1.default)("loading config saves config", async (t) => {
|
||||||
@@ -111,18 +112,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, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
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);
|
||||||
// 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, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -135,7 +139,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, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -149,7 +153,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, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -214,10 +218,14 @@ function mockListLanguages(languages) {
|
|||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: "my-artifact",
|
||||||
|
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, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (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, 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);
|
||||||
});
|
});
|
||||||
@@ -253,7 +261,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, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
// 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, [
|
||||||
@@ -296,7 +304,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
// 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.
|
||||||
@@ -329,7 +337,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
// 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.
|
||||||
@@ -361,7 +369,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
// 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
|
||||||
@@ -387,7 +395,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
// 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
|
||||||
@@ -426,7 +434,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
// 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,
|
||||||
@@ -465,7 +473,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
t.fail("initConfig did not throw error");
|
t.fail("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -508,7 +516,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, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -518,7 +526,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, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -534,7 +542,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, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -551,7 +559,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -563,7 +571,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, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -591,7 +599,7 @@ 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, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: [
|
||||||
{
|
{
|
||||||
@@ -630,7 +638,7 @@ 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, { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: [
|
||||||
{
|
{
|
||||||
@@ -683,7 +691,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, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
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));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -756,28 +764,26 @@ 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"), 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]: [
|
||||||
@@ -866,6 +872,59 @@ parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and
|
|||||||
(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/);
|
||||||
// errors
|
const mlPoweredQueriesMacro = ava_1.default.macro({
|
||||||
// input w invalid pack name
|
exec: async (t, codeQLVersion, isMlPoweredQueriesFlagEnabled, packsInput, queriesInput, expectedVersionString) => {
|
||||||
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
|
async getVersion() {
|
||||||
|
return codeQLVersion;
|
||||||
|
},
|
||||||
|
async resolveQueries() {
|
||||||
|
return {
|
||||||
|
byLanguage: {
|
||||||
|
javascript: { "fake-query.ql": {} },
|
||||||
|
},
|
||||||
|
noDeclaredLanguage: {},
|
||||||
|
multipleDeclaredLanguages: {},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const { packs } = await configUtils.initConfig("javascript", queriesInput, packsInput, 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 (expectedVersionString !== undefined) {
|
||||||
|
t.deepEqual(packs, {
|
||||||
|
[languages_1.Language.javascript]: [
|
||||||
|
{
|
||||||
|
packName: "codeql/javascript-experimental-atm-queries",
|
||||||
|
version: expectedVersionString,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
t.deepEqual(packs, {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
title: (_providedTitle, codeQLVersion, isMlPoweredQueriesFlagEnabled, packsInput, queriesInput, expectedVersionString) => `ML-powered queries ${expectedVersionString !== undefined
|
||||||
|
? `${expectedVersionString} are`
|
||||||
|
: "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 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`.
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, "security-extended", process.platform === "win32" ? undefined : "~0.1.0");
|
||||||
|
// Test that ML-powered queries are run on non-Windows platforms running `security-and-quality`.
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, "security-and-quality", process.platform === "win32" ? undefined : "~0.1.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.7.5", true, "codeql/javascript-experimental-atm-queries@0.0.1", "security-and-quality", process.platform === "win32" ? undefined : "0.0.1");
|
||||||
|
// Test that the ~0.2.0 version of ML-powered queries is run on v2.8.4 of the CLI.
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.8.4", true, undefined, "security-extended", process.platform === "win32" ? undefined : "~0.2.0");
|
||||||
//# sourceMappingURL=config-utils.test.js.map
|
//# sourceMappingURL=config-utils.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
35
lib/database-upload.js
generated
35
lib/database-upload.js
generated
@@ -25,6 +25,7 @@ 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 util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
|
const util_1 = require("./util");
|
||||||
async function uploadDatabases(repositoryNwo, config, 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.");
|
||||||
@@ -41,36 +42,24 @@ async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const client = (0, api_client_1.getApiClient)(apiDetails);
|
const client = (0, api_client_1.getApiClient)(apiDetails);
|
||||||
try {
|
|
||||||
await client.request("GET /repos/:owner/:repo/code-scanning/codeql/databases", {
|
|
||||||
owner: repositoryNwo.owner,
|
|
||||||
repo: repositoryNwo.repo,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
if (util.isHTTPError(e) && e.status === 404) {
|
|
||||||
logger.debug("Repository is not opted in to database uploads. Skipping upload.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(e);
|
|
||||||
logger.info(`Skipping database upload due to unknown error: ${e}`);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
// Bundle the database up into a single zip file
|
// Upload the database bundle.
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
// Although we are uploading arbitrary file contents to the API, it's worth
|
||||||
const databaseBundlePath = `${databasePath}.zip`;
|
// noting that it's the API's job to validate that the contents is acceptable.
|
||||||
await codeql.databaseBundle(databasePath, databaseBundlePath);
|
// This API method is available to anyone with write access to the repo.
|
||||||
// Upload the database bundle
|
const payload = fs.readFileSync(await (0, util_1.bundleDb)(config, language, codeql, language));
|
||||||
const payload = fs.readFileSync(databaseBundlePath);
|
|
||||||
try {
|
try {
|
||||||
await client.request(`PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language`, {
|
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`,
|
||||||
data: payload,
|
data: payload,
|
||||||
|
headers: {
|
||||||
|
authorization: `token ${apiDetails.auth}`,
|
||||||
|
"Content-Type": "application/zip",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
logger.debug(`Successfully uploaded database for ${language}`);
|
logger.debug(`Successfully uploaded database for ${language}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"database-upload.js","sourceRoot":"","sources":["../src/database-upload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,4DAA8C;AAC9C,6CAA8D;AAC9D,qCAAqC;AAIrC,6CAA+B;AAExB,KAAK,UAAU,eAAe,CACnC,aAA4B,EAC5B,MAAc,EACd,UAA4B,EAC5B,MAAc;IAEd,IAAI,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,KAAK,MAAM,EAAE;QAC9D,MAAM,CAAC,KAAK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AAC,CAAC;QAC/D,OAAO;KACR;IAED,MAAM,MAAM,GAAG,IAAA,yBAAY,EAAC,UAAU,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAEjD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE;QACvC,8BAA8B;QAC9B,2EAA2E;QAC3E,8EAA8E;QAC9E,wEAAwE;QACxE,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAC7B,MAAM,IAAA,eAAQ,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CACnD,CAAC;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"}
|
||||||
127
lib/database-upload.test.js
generated
127
lib/database-upload.test.js
generated
@@ -55,50 +55,23 @@ function getTestConfig(tmpDir) {
|
|||||||
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
|
||||||
dbLocation: tmpDir,
|
dbLocation: tmpDir,
|
||||||
packs: {},
|
packs: {},
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: util_1.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||||
|
debugDatabaseName: util_1.DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
|
injectedMlQueries: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function getRecordingLogger(messages) {
|
async function mockHttpRequests(databaseUploadStatusCode) {
|
||||||
return {
|
|
||||||
debug: (message) => {
|
|
||||||
messages.push({ type: "debug", message });
|
|
||||||
console.debug(message);
|
|
||||||
},
|
|
||||||
info: (message) => {
|
|
||||||
messages.push({ type: "info", message });
|
|
||||||
console.info(message);
|
|
||||||
},
|
|
||||||
warning: (message) => {
|
|
||||||
messages.push({ type: "warning", message });
|
|
||||||
console.warn(message);
|
|
||||||
},
|
|
||||||
error: (message) => {
|
|
||||||
messages.push({ type: "error", message });
|
|
||||||
console.error(message);
|
|
||||||
},
|
|
||||||
isDebug: () => true,
|
|
||||||
startGroup: () => undefined,
|
|
||||||
endGroup: () => undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function mockHttpRequests(optInStatusCode, 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 optInSpy = requestSpy.withArgs("GET /repos/:owner/:repo/code-scanning/codeql/databases");
|
const url = "POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name";
|
||||||
if (optInStatusCode < 300) {
|
const databaseUploadSpy = requestSpy.withArgs(url);
|
||||||
optInSpy.resolves(undefined);
|
if (databaseUploadStatusCode < 300) {
|
||||||
|
databaseUploadSpy.resolves(undefined);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
optInSpy.throws(new util_1.HTTPError("some error message", optInStatusCode));
|
databaseUploadSpy.throws(new util_1.HTTPError("some error message", databaseUploadStatusCode));
|
||||||
}
|
|
||||||
if (databaseUploadStatusCode !== undefined) {
|
|
||||||
const databaseUploadSpy = requestSpy.withArgs("PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language");
|
|
||||||
if (databaseUploadStatusCode < 300) {
|
|
||||||
databaseUploadSpy.resolves(undefined);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
databaseUploadSpy.throws(new util_1.HTTPError("some error message", databaseUploadStatusCode));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sinon.stub(apiClient, "getApiClient").value(() => client);
|
sinon.stub(apiClient, "getApiClient").value(() => client);
|
||||||
}
|
}
|
||||||
@@ -111,7 +84,7 @@ function mockHttpRequests(optInStatusCode, 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), testApiDetails, 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);
|
||||||
});
|
});
|
||||||
@@ -127,7 +100,7 @@ function mockHttpRequests(optInStatusCode, 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, testApiDetails, 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);
|
||||||
});
|
});
|
||||||
@@ -143,7 +116,7 @@ function mockHttpRequests(optInStatusCode, 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, testApiDetails, 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);
|
||||||
});
|
});
|
||||||
@@ -157,53 +130,11 @@ function mockHttpRequests(optInStatusCode, 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), testApiDetails, 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 opt-in request returns 404", 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);
|
|
||||||
mockHttpRequests(404);
|
|
||||||
(0, codeql_1.setCodeQL)({
|
|
||||||
async databaseBundle() {
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const loggedMessages = [];
|
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, 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)("Abort database upload if opt-in request fails with something other than 404", 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);
|
|
||||||
mockHttpRequests(500);
|
|
||||||
(0, codeql_1.setCodeQL)({
|
|
||||||
async databaseBundle() {
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const loggedMessages = [];
|
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "info" &&
|
|
||||||
v.message ===
|
|
||||||
"Skipping database upload due to unknown error: Error: some error message") !== 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);
|
||||||
@@ -212,20 +143,20 @@ function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
mockHttpRequests(204, 500);
|
await mockHttpRequests(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), testApiDetails, 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Successfully uploading a database", async (t) => {
|
(0, ava_1.default)("Successfully uploading a database to api.github.com", 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);
|
||||||
sinon
|
sinon
|
||||||
@@ -233,14 +164,34 @@ function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
mockHttpRequests(204, 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), testApiDetails, 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" &&
|
||||||
|
v.message === "Successfully uploaded database for javascript") !== undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("Successfully uploading a database to uploads.github.com", 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);
|
||||||
|
await mockHttpRequests(201);
|
||||||
|
(0, codeql_1.setCodeQL)({
|
||||||
|
async databaseBundle(_, outputFilePath) {
|
||||||
|
fs.writeFileSync(outputFilePath, "");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const 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
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20211025"
|
"bundleVersion": "codeql-bundle-20220401"
|
||||||
}
|
}
|
||||||
|
|||||||
94
lib/feature-flags.js
generated
Normal file
94
lib/feature-flags.js
generated
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
"use strict";
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.createFeatureFlags = exports.GitHubFeatureFlags = exports.FeatureFlag = void 0;
|
||||||
|
const api_client_1 = require("./api-client");
|
||||||
|
const util = __importStar(require("./util"));
|
||||||
|
var FeatureFlag;
|
||||||
|
(function (FeatureFlag) {
|
||||||
|
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
||||||
|
})(FeatureFlag = exports.FeatureFlag || (exports.FeatureFlag = {}));
|
||||||
|
class GitHubFeatureFlags {
|
||||||
|
constructor(gitHubVersion, apiDetails, repositoryNwo, logger) {
|
||||||
|
this.gitHubVersion = gitHubVersion;
|
||||||
|
this.apiDetails = apiDetails;
|
||||||
|
this.repositoryNwo = repositoryNwo;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
async getValue(flag) {
|
||||||
|
const response = (await this.getApiResponse())[flag];
|
||||||
|
if (response === undefined) {
|
||||||
|
this.logger.debug(`Feature flag '${flag}' undefined in API response, considering it disabled.`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
async getApiResponse() {
|
||||||
|
const loadApiResponse = async () => {
|
||||||
|
// Do nothing when not running against github.com
|
||||||
|
if (this.gitHubVersion.type !== util.GitHubVariant.DOTCOM) {
|
||||||
|
this.logger.debug("Not running against github.com. Disabling all feature flags.");
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const client = (0, api_client_1.getApiClient)(this.apiDetails);
|
||||||
|
try {
|
||||||
|
const response = await client.request("GET /repos/:owner/:repo/code-scanning/codeql-action/features", {
|
||||||
|
owner: this.repositoryNwo.owner,
|
||||||
|
repo: this.repositoryNwo.repo,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (util.isHTTPError(e) && e.status === 403) {
|
||||||
|
this.logger.warning("This run of the CodeQL Action does not have permission to access Code Scanning API endpoints. " +
|
||||||
|
"As a result, it will not be opted into any experimental features. " +
|
||||||
|
"This could be because the Action is running on a pull request from a fork. If not, " +
|
||||||
|
`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());
|
||||||
|
this.cachedApiResponse = apiResponse;
|
||||||
|
return apiResponse;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.GitHubFeatureFlags = GitHubFeatureFlags;
|
||||||
|
/**
|
||||||
|
* Create a feature flags instance with the specified set of enabled flags.
|
||||||
|
*
|
||||||
|
* This should be only used within tests.
|
||||||
|
*/
|
||||||
|
function createFeatureFlags(enabledFlags) {
|
||||||
|
return {
|
||||||
|
getValue: async (flag) => {
|
||||||
|
return enabledFlags.includes(flag);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.createFeatureFlags = createFeatureFlags;
|
||||||
|
//# sourceMappingURL=feature-flags.js.map
|
||||||
1
lib/feature-flags.js.map
Normal file
1
lib/feature-flags.js.map
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../src/feature-flags.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8D;AAG9D,6CAA+B;AAM/B,IAAY,WAEX;AAFD,WAAY,WAAW;IACrB,qEAAsD,CAAA;AACxD,CAAC,EAFW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAEtB;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;IAEO,KAAK,CAAC,cAAc;QAC1B,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE;YACjC,iDAAiD;YACjD,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;gBACzD,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,8DAA8D,CAC/D,CAAC;gBACF,OAAO,EAAE,CAAC;aACX;YACD,MAAM,MAAM,GAAG,IAAA,yBAAY,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7C,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,OAAO,CACnC,8DAA8D,EAC9D;oBACE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK;oBAC/B,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI;iBAC9B,CACF,CAAC;gBACF,OAAO,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"}
|
||||||
88
lib/feature-flags.test.js
generated
Normal file
88
lib/feature-flags.test.js
generated
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const ava_1 = __importDefault(require("ava"));
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
|
const logging_1 = require("./logging");
|
||||||
|
const repository_1 = require("./repository");
|
||||||
|
const testing_utils_1 = require("./testing-utils");
|
||||||
|
const util_1 = require("./util");
|
||||||
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
|
ava_1.default.beforeEach(() => {
|
||||||
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
||||||
|
});
|
||||||
|
const testApiDetails = {
|
||||||
|
auth: "1234",
|
||||||
|
url: "https://github.com",
|
||||||
|
};
|
||||||
|
const testRepositoryNwo = (0, repository_1.parseRepositoryNwo)("github/example");
|
||||||
|
const ALL_FEATURE_FLAGS_DISABLED_VARIANTS = [
|
||||||
|
{
|
||||||
|
description: "GHES",
|
||||||
|
gitHubVersion: { type: util_1.GitHubVariant.GHES, version: "3.0.0" },
|
||||||
|
},
|
||||||
|
{ description: "GHAE", gitHubVersion: { type: util_1.GitHubVariant.GHAE } },
|
||||||
|
];
|
||||||
|
for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
|
||||||
|
(0, ava_1.default)(`All feature flags are disabled if running against ${variant.description}`, async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
const loggedMessages = [];
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags(variant.gitHubVersion, testApiDetails, testRepositoryNwo, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
|
for (const flag of Object.values(feature_flags_1.FeatureFlag)) {
|
||||||
|
t.assert((await featureFlags.getValue(flag)) === false);
|
||||||
|
}
|
||||||
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
|
v.message ===
|
||||||
|
"Not running against github.com. Disabling all feature flags.") !== undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
(0, ava_1.default)("Feature flags are disabled if they're not returned in API response", async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
const loggedMessages = [];
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
||||||
|
for (const flag of Object.values(feature_flags_1.FeatureFlag)) {
|
||||||
|
t.assert((await featureFlags.getValue(flag)) === false);
|
||||||
|
}
|
||||||
|
for (const featureFlag of ["ml_powered_queries_enabled"]) {
|
||||||
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
|
v.message ===
|
||||||
|
`Feature flag '${featureFlag}' undefined in API response, considering it disabled.`) !== undefined);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("Feature flags exception is propagated if the API request errors", async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (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));
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(500, {});
|
||||||
|
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",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const FEATURE_FLAGS = ["ml_powered_queries_enabled"];
|
||||||
|
for (const featureFlag of FEATURE_FLAGS) {
|
||||||
|
(0, ava_1.default)(`Feature flag '${featureFlag}' is enabled if enabled in the API response`, async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (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 expectedFeatureFlags = {};
|
||||||
|
for (const f of FEATURE_FLAGS) {
|
||||||
|
expectedFeatureFlags[f] = false;
|
||||||
|
}
|
||||||
|
expectedFeatureFlags[featureFlag] = true;
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags);
|
||||||
|
const actualFeatureFlags = {
|
||||||
|
ml_powered_queries_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled),
|
||||||
|
};
|
||||||
|
t.deepEqual(actualFeatureFlags, expectedFeatureFlags);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=feature-flags.test.js.map
|
||||||
1
lib/feature-flags.test.js.map
Normal file
1
lib/feature-flags.test.js.map
Normal file
@@ -0,0 +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,IAA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ingerprints.js
generated
@@ -226,9 +226,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 +265,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
22
lib/fingerprints.test.js
generated
22
lib/fingerprints.test.js
generated
@@ -169,30 +169,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
28
lib/init-action.js
generated
28
lib/init-action.js
generated
@@ -22,7 +22,9 @@ 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 init_1 = require("./init");
|
const init_1 = require("./init");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
@@ -47,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);
|
||||||
}
|
}
|
||||||
@@ -76,8 +79,10 @@ 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 featureFlags = new feature_flags_1.GitHubFeatureFlags(gitHubVersion, apiDetails, repositoryNwo, logger);
|
||||||
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)))) {
|
||||||
@@ -87,7 +92,7 @@ async function run() {
|
|||||||
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, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), (0, actions_util_1.getTemporaryDirectory)(), (0, util_1.getRequiredEnvParam)("RUNNER_TOOL_CACHE"), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, 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"), (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);
|
||||||
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 {
|
||||||
@@ -113,9 +118,14 @@ async function run() {
|
|||||||
core.exportVariable("GOFLAGS", goFlags);
|
core.exportVariable("GOFLAGS", goFlags);
|
||||||
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
|
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
|
||||||
}
|
}
|
||||||
// Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935)
|
// Limit RAM and threads for extractors. When running extractors, the CodeQL CLI obeys the
|
||||||
const codeqlRam = process.env["CODEQL_RAM"] || "6500";
|
// CODEQL_RAM and CODEQL_THREADS environment variables to decide how much RAM and how many
|
||||||
core.exportVariable("CODEQL_RAM", codeqlRam);
|
// threads it would ask extractors to use. See help text for the "--ram" and "--threads"
|
||||||
|
// options at https://codeql.github.com/docs/codeql-cli/manual/database-trace-command/
|
||||||
|
// for details.
|
||||||
|
core.exportVariable("CODEQL_RAM", process.env["CODEQL_RAM"] ||
|
||||||
|
(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());
|
||||||
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);
|
||||||
if (tracerConfig !== undefined) {
|
if (tracerConfig !== undefined) {
|
||||||
@@ -132,7 +142,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
37
lib/init.js
generated
37
lib/init.js
generated
@@ -38,24 +38,43 @@ async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant,
|
|||||||
return { codeql, toolsVersion };
|
return { codeql, toolsVersion };
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, 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, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, 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) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
|||||||
@@ -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;AAG9C,mDAAwE;AACxE,6CAA+B;AAC/B,iCAA4C;AAErC,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf,YAAoB,EACpB,OAA2B,EAC3B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,oBAAW,EAChD,SAAS,EACT,UAAU,EACV,OAAO,EACP,YAAY,EACZ,OAAO,EACP,MAAM,EACN,IAAI,CACL,CAAC;IACF,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC;AArBD,gCAqBC;AAEM,KAAK,UAAU,UAAU,CAC9B,cAAkC,EAClC,YAAgC,EAChC,UAA8B,EAC9B,UAA8B,EAC9B,UAA8B,EAC9B,UAAyB,EACzB,OAAe,EACf,YAAoB,EACpB,MAAc,EACd,aAAqB,EACrB,aAAiC,EACjC,UAAoC,EACpC,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,CACzC,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,YAAY,E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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 });
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
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 analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const autobuild_1 = require("./autobuild");
|
const autobuild_1 = require("./autobuild");
|
||||||
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 feature_flags_1 = require("./feature-flags");
|
||||||
const init_1 = require("./init");
|
const init_1 = require("./init");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
@@ -54,11 +59,14 @@ function getToolsDir(userInput) {
|
|||||||
return toolsDir;
|
return toolsDir;
|
||||||
}
|
}
|
||||||
const codeqlEnvJsonFilename = "codeql-env.json";
|
const codeqlEnvJsonFilename = "codeql-env.json";
|
||||||
|
function loadTracerEnvironment(config) {
|
||||||
|
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
|
||||||
|
return JSON.parse(fs.readFileSync(jsonEnvFile).toString("utf-8"));
|
||||||
|
}
|
||||||
// Imports the environment from codeqlEnvJsonFilename if not already present
|
// Imports the environment from codeqlEnvJsonFilename if not already present
|
||||||
function importTracerEnvironment(config) {
|
function importTracerEnvironment(config) {
|
||||||
if (!("ODASA_TRACER_CONFIGURATION" in process.env)) {
|
if (!("ODASA_TRACER_CONFIGURATION" in process.env)) {
|
||||||
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
|
const env = loadTracerEnvironment(config);
|
||||||
const env = JSON.parse(fs.readFileSync(jsonEnvFile).toString("utf-8"));
|
|
||||||
for (const key of Object.keys(env)) {
|
for (const key of Object.keys(env)) {
|
||||||
process.env[key] = env[key];
|
process.env[key] = env[key];
|
||||||
}
|
}
|
||||||
@@ -116,6 +124,12 @@ program
|
|||||||
.option("--debug", "Print more verbose output", false)
|
.option("--debug", "Print more verbose output", false)
|
||||||
.option("--trace-process-name <string>", "(Advanced, windows-only) Inject a windows tracer of this process into a process with the given process name.")
|
.option("--trace-process-name <string>", "(Advanced, windows-only) Inject a windows tracer of this process into a process with the given process name.")
|
||||||
.option("--trace-process-level <number>", "(Advanced, windows-only) Inject a windows tracer of this process into a parent process <number> levels up.")
|
.option("--trace-process-level <number>", "(Advanced, windows-only) Inject a windows tracer of this process into a parent process <number> levels up.")
|
||||||
|
.option("--ram <number>", "The amount of memory in MB that can be used by CodeQL extractors. " +
|
||||||
|
"By default, CodeQL extractors will use most of the memory available in the system. " +
|
||||||
|
'This input also sets the amount of memory that can later be used by the "analyze" command.')
|
||||||
|
.option("--threads <number>", "The number of threads that can be used by CodeQL extractors. " +
|
||||||
|
"By default, CodeQL extractors will use all the hardware threads available in the system. " +
|
||||||
|
'This input also sets the number of threads that can later be used by the "analyze" command.')
|
||||||
.action(async (cmd) => {
|
.action(async (cmd) => {
|
||||||
const logger = (0, logging_1.getRunnerLogger)(cmd.debug);
|
const logger = (0, logging_1.getRunnerLogger)(cmd.debug);
|
||||||
try {
|
try {
|
||||||
@@ -124,7 +138,7 @@ program
|
|||||||
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}`);
|
||||||
fs.rmSync(tempDir, { recursive: true, force: true });
|
await (0, del_1.default)(tempDir, { force: true });
|
||||||
fs.mkdirSync(tempDir, { recursive: true });
|
fs.mkdirSync(tempDir, { recursive: true });
|
||||||
const auth = await (0, util_1.getGitHubAuth)(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
const auth = await (0, util_1.getGitHubAuth)(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
@@ -134,6 +148,13 @@ program
|
|||||||
};
|
};
|
||||||
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
||||||
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.runner);
|
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.runner);
|
||||||
|
// Limit RAM and threads for extractors. When running extractors, the CodeQL CLI obeys the
|
||||||
|
// CODEQL_RAM and CODEQL_THREADS environment variables to decide how much RAM and how many
|
||||||
|
// threads it would ask extractors to use. See help text for the "--ram" and "--threads"
|
||||||
|
// options at https://codeql.github.com/docs/codeql-cli/manual/database-trace-command/
|
||||||
|
// for details.
|
||||||
|
process.env["CODEQL_RAM"] = (0, util_1.getMemoryFlagValue)(cmd.ram).toString();
|
||||||
|
process.env["CODEQL_THREADS"] = (0, util_1.getThreadsFlagValue)(cmd.threads, logger).toString();
|
||||||
let codeql;
|
let codeql;
|
||||||
if (cmd.codeqlPath !== undefined) {
|
if (cmd.codeqlPath !== undefined) {
|
||||||
codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath);
|
codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath);
|
||||||
@@ -143,7 +164,7 @@ program
|
|||||||
}
|
}
|
||||||
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, (0, repository_1.parseRepositoryNwo)(cmd.repository), tempDir, toolsDir, codeql, workspacePath, gitHubVersion, apiDetails, 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, toolsDir, 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());
|
||||||
if (tracerConfig === undefined) {
|
if (tracerConfig === undefined) {
|
||||||
@@ -240,10 +261,15 @@ program
|
|||||||
.option("--checkout-path <path>", "Checkout path. Default is the current working directory.")
|
.option("--checkout-path <path>", "Checkout path. Default is the current working directory.")
|
||||||
.option("--no-upload", "Do not upload results after analysis.")
|
.option("--no-upload", "Do not upload results after analysis.")
|
||||||
.option("--output-dir <dir>", "Directory to output SARIF files to. Default is in the temp directory.")
|
.option("--output-dir <dir>", "Directory to output SARIF files to. Default is in the temp directory.")
|
||||||
.option("--ram <ram>", "Amount of memory to use when running queries. Default is to use all available memory.")
|
.option("--ram <ram>", "The amount of memory in MB that can be used by CodeQL for database finalization and query execution. " +
|
||||||
|
'By default, this command will use the same amount of memory as previously set in the "init" command. ' +
|
||||||
|
'If the "init" command also does not have an explicit "ram" flag, this command will use most of the ' +
|
||||||
|
"memory available in the system.")
|
||||||
.option("--no-add-snippets", "Specify whether to include code snippets in the sarif output.")
|
.option("--no-add-snippets", "Specify whether to include code snippets in the sarif output.")
|
||||||
.option("--threads <threads>", "Number of threads to use when running queries. " +
|
.option("--threads <threads>", "The number of threads that can be used by CodeQL for database finalization and query execution. " +
|
||||||
"Default is to use all available cores.")
|
'By default, this command will use the same number of threads as previously set in the "init" command. ' +
|
||||||
|
'If the "init" command also does not have an explicit "threads" flag, this command will use all the ' +
|
||||||
|
"hardware threads available in the system.")
|
||||||
.option("--temp-dir <dir>", 'Directory to use for temporary files. Default is "./codeql-runner".')
|
.option("--temp-dir <dir>", 'Directory to use for temporary files. Default is "./codeql-runner".')
|
||||||
.option("--category <category>", "String used by Code Scanning for matching the analyses.")
|
.option("--category <category>", "String used by Code Scanning for matching the analyses.")
|
||||||
.option("--debug", "Print more verbose output", false)
|
.option("--debug", "Print more verbose output", false)
|
||||||
@@ -262,8 +288,15 @@ program
|
|||||||
url: (0, util_1.parseGitHubUrl)(cmd.githubUrl),
|
url: (0, util_1.parseGitHubUrl)(cmd.githubUrl),
|
||||||
};
|
};
|
||||||
const outputDir = cmd.outputDir || path.join(config.tempDir, "codeql-sarif");
|
const outputDir = cmd.outputDir || path.join(config.tempDir, "codeql-sarif");
|
||||||
const threads = (0, util_1.getThreadsFlag)(cmd.threads, logger);
|
let initEnv = {};
|
||||||
const memory = (0, util_1.getMemoryFlag)(cmd.ram);
|
try {
|
||||||
|
initEnv = loadTracerEnvironment(config);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
// The init command did not generate a tracer environment file
|
||||||
|
}
|
||||||
|
const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger);
|
||||||
|
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);
|
||||||
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) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
50
lib/testing-utils.js
generated
50
lib/testing-utils.js
generated
@@ -19,9 +19,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.setupActionsVars = exports.setupTests = void 0;
|
exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = void 0;
|
||||||
|
const github = __importStar(require("@actions/github"));
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
|
const apiClient = __importStar(require("./api-client"));
|
||||||
const CodeQL = __importStar(require("./codeql"));
|
const CodeQL = __importStar(require("./codeql"));
|
||||||
|
const util_1 = require("./util");
|
||||||
function wrapOutput(context) {
|
function wrapOutput(context) {
|
||||||
// Function signature taken from Socket.write.
|
// Function signature taken from Socket.write.
|
||||||
// Note there are two overloads:
|
// Note there are two overloads:
|
||||||
@@ -87,6 +90,51 @@ exports.setupTests = setupTests;
|
|||||||
function setupActionsVars(tempDir, toolsDir) {
|
function setupActionsVars(tempDir, toolsDir) {
|
||||||
process.env["RUNNER_TEMP"] = tempDir;
|
process.env["RUNNER_TEMP"] = tempDir;
|
||||||
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
|
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
|
||||||
|
process.env["GITHUB_WORKSPACE"] = tempDir;
|
||||||
}
|
}
|
||||||
exports.setupActionsVars = setupActionsVars;
|
exports.setupActionsVars = setupActionsVars;
|
||||||
|
function getRecordingLogger(messages) {
|
||||||
|
return {
|
||||||
|
debug: (message) => {
|
||||||
|
messages.push({ type: "debug", message });
|
||||||
|
console.debug(message);
|
||||||
|
},
|
||||||
|
info: (message) => {
|
||||||
|
messages.push({ type: "info", message });
|
||||||
|
console.info(message);
|
||||||
|
},
|
||||||
|
warning: (message) => {
|
||||||
|
messages.push({ type: "warning", message });
|
||||||
|
console.warn(message);
|
||||||
|
},
|
||||||
|
error: (message) => {
|
||||||
|
messages.push({ type: "error", message });
|
||||||
|
console.error(message);
|
||||||
|
},
|
||||||
|
isDebug: () => true,
|
||||||
|
startGroup: () => undefined,
|
||||||
|
endGroup: () => undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
exports.getRecordingLogger = getRecordingLogger;
|
||||||
|
/** Mock the HTTP request to the feature flags enablement API endpoint. */
|
||||||
|
function mockFeatureFlagApiEndpoint(responseStatusCode, response) {
|
||||||
|
// Passing an auth token is required, so we just use a dummy value
|
||||||
|
const client = github.getOctokit("123");
|
||||||
|
const requestSpy = sinon.stub(client, "request");
|
||||||
|
const optInSpy = requestSpy.withArgs("GET /repos/:owner/:repo/code-scanning/codeql-action/features");
|
||||||
|
if (responseStatusCode < 300) {
|
||||||
|
optInSpy.resolves({
|
||||||
|
status: responseStatusCode,
|
||||||
|
data: response,
|
||||||
|
headers: {},
|
||||||
|
url: "GET /repos/:owner/:repo/code-scanning/codeql-action/features",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
optInSpy.throws(new util_1.HTTPError("some error message", responseStatusCode));
|
||||||
|
}
|
||||||
|
sinon.stub(apiClient, "getApiClient").value(() => client);
|
||||||
|
}
|
||||||
|
exports.mockFeatureFlagApiEndpoint = mockFeatureFlagApiEndpoint;
|
||||||
//# sourceMappingURL=testing-utils.js.map
|
//# sourceMappingURL=testing-utils.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../src/testing-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,6CAA+B;AAE/B,iDAAmC;AASnC,SAAS,UAAU,CAAC,OAAoB;I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0BAA0B,CACxC,kBAA0B,EAC1B,QAAyC;IAEzC,kEAAkE;IAClE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAExC,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEjD,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAClC,8DAA8D,CAC/D,CAAC;IACF,IAAI,kBAAkB,GAAG,GAAG,EAAE;QAC5B,QAAQ,CAAC,QAAQ,CAAC;YAChB,MAAM,EAAE,kBAAkB;YAC1B,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE;YACX,GAAG,EAAE,8DAA8D;SACpE,CAAC,CAAC;KACJ;SAAM;QACL,QAAQ,CAAC,MAAM,CAAC,IAAI,gBAAS,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,CAAC;KAC1E;IAED,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC;AAxBD,gEAwBC"}
|
||||||
12
lib/toolcache.js
generated
12
lib/toolcache.js
generated
@@ -18,6 +18,9 @@ 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.downloadTool = exports.findAllVersions = exports.find = exports.cacheDir = exports.extractTar = void 0;
|
exports.downloadTool = exports.findAllVersions = exports.find = exports.cacheDir = exports.extractTar = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
@@ -27,6 +30,7 @@ const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
|||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
||||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
||||||
|
const del_1 = __importDefault(require("del"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const uuid_1 = require("uuid");
|
const uuid_1 = require("uuid");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
@@ -123,7 +127,7 @@ async function cacheDir(sourceDir, tool, version, toolCacheDir, logger) {
|
|||||||
throw new Error("sourceDir is not a directory");
|
throw new Error("sourceDir is not a directory");
|
||||||
}
|
}
|
||||||
// Create the tool dir
|
// Create the tool dir
|
||||||
const destPath = createToolPath(tool, version, arch, toolCacheDir, logger);
|
const destPath = await createToolPath(tool, version, arch, toolCacheDir, logger);
|
||||||
// copy each child item. do not move. move can fail on Windows
|
// copy each child item. do not move. move can fail on Windows
|
||||||
// due to anti-virus software having an open handle on a file.
|
// due to anti-virus software having an open handle on a file.
|
||||||
for (const itemName of fs.readdirSync(sourceDir)) {
|
for (const itemName of fs.readdirSync(sourceDir)) {
|
||||||
@@ -232,12 +236,12 @@ function createExtractFolder(tempDir) {
|
|||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
function createToolPath(tool, version, arch, toolCacheDir, logger) {
|
async function createToolPath(tool, version, arch, toolCacheDir, logger) {
|
||||||
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
||||||
logger.debug(`destination ${folderPath}`);
|
logger.debug(`destination ${folderPath}`);
|
||||||
const markerPath = `${folderPath}.complete`;
|
const markerPath = `${folderPath}.complete`;
|
||||||
fs.rmSync(folderPath, { recursive: true, force: true });
|
await (0, del_1.default)(folderPath, { force: true });
|
||||||
fs.rmSync(markerPath, { recursive: true, force: true });
|
await (0, del_1.default)(markerPath, { force: true });
|
||||||
fs.mkdirSync(folderPath, { recursive: true });
|
fs.mkdirSync(folderPath, { recursive: true });
|
||||||
return folderPath;
|
return folderPath;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
8
lib/toolrunner-error-catcher.js
generated
8
lib/toolrunner-error-catcher.js
generated
@@ -44,10 +44,6 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout) !== undefined) {
|
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout) !== undefined) {
|
||||||
options.listeners.stdout(data);
|
options.listeners.stdout(data);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// if no stdout listener was originally defined then we match default behavior of Toolrunner
|
|
||||||
process.stdout.write(data);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
stderr: (data) => {
|
stderr: (data) => {
|
||||||
var _a;
|
var _a;
|
||||||
@@ -55,10 +51,6 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stderr) !== undefined) {
|
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stderr) !== undefined) {
|
||||||
options.listeners.stderr(data);
|
options.listeners.stderr(data);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// if no stderr listener was originally defined then we match default behavior of Toolrunner
|
|
||||||
process.stderr.write(data);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// we capture the original return code or error so that if no match is found we can duplicate the behavior
|
// we capture the original return code or error so that if no match is found we can duplicate the behavior
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"toolrunner-error-catcher.js","sourceRoot":"","sources":["../src/toolrunner-error-catcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,yEAA2D;AAC3D,kEAAoD;AAIpD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,IAAe,EACf,QAAyB,EACzB,OAAwB;;IAExB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,MAAM,SAAS,GAAG;QAChB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACL,4FAA4F;gBAC5F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC5B;QACH,CAAC;QACD,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACL,4FAA4F;gBAC5F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC5B;QACH,CAAC;KACF,CAAC;IAEF,0GAA0G;IAC1G,IAAI,WAA2B,CAAC;IAChC,IAAI;QACF,WAAW,GAAG,MAAM,IAAI,UAAU,CAAC,UAAU,CAC3C,MAAM,SAA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AAO,IAAI,QAAQ,EAAE;YAC9B,IACE,OAAO,CAAC,QAAQ,KAAK,WAAW;iBAChC,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,CAAC,CAAA;iBACjC,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,CAAC,CAAA,EACjC;gBACA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAClC;SACF;KACF;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,qFAAqF;QACrF,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,EAAE;YAC7B,OAAO,WAAW,CAAC;SACpB;aAAM;YACL,MAAM,IAAI,KAAK,CACb,gBAAgB,WAAW,2BAA2B,WAAW,EAAE,CACpE,CAAC;SACH;KACF;SAAM;QACL,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AAnED,wDAmEC"}
|
||||||
44
lib/tracer-config.js
generated
44
lib/tracer-config.js
generated
@@ -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.getCombinedTracerConfig = exports.concatTracerConfigs = exports.getTracerConfigForLanguage = exports.getTracerConfigForCluster = void 0;
|
exports.getCombinedTracerConfig = exports.concatTracerConfigs = exports.getTracerConfigForLanguage = exports.getTracerConfigForCluster = exports.endTracingForCluster = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -33,6 +33,30 @@ const CRITICAL_TRACER_VARS = new Set([
|
|||||||
"SEMMLE_DEPTRACE_SOCKET",
|
"SEMMLE_DEPTRACE_SOCKET",
|
||||||
"SEMMLE_JAVA_TOOL_OPTIONS",
|
"SEMMLE_JAVA_TOOL_OPTIONS",
|
||||||
]);
|
]);
|
||||||
|
async function endTracingForCluster(config) {
|
||||||
|
// If there are no traced languages, we don't need to do anything.
|
||||||
|
if (!config.languages.some(languages_1.isTracedLanguage))
|
||||||
|
return;
|
||||||
|
const envVariablesFile = path.resolve(config.dbLocation, "temp/tracingEnvironment/end-tracing.json");
|
||||||
|
if (!fs.existsSync(envVariablesFile)) {
|
||||||
|
throw new Error(`Environment file for ending tracing not found: ${envVariablesFile}`);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const endTracingEnvVariables = JSON.parse(fs.readFileSync(envVariablesFile, "utf8"));
|
||||||
|
for (const [key, value] of Object.entries(endTracingEnvVariables)) {
|
||||||
|
if (value !== null) {
|
||||||
|
process.env[key] = value;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
delete process.env[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw new Error(`Failed to parse file containing end tracing environment variables: ${e}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.endTracingForCluster = endTracingForCluster;
|
||||||
async function getTracerConfigForCluster(config) {
|
async function getTracerConfigForCluster(config) {
|
||||||
const tracingEnvVariables = JSON.parse(fs.readFileSync(path.resolve(config.dbLocation, "temp/tracingEnvironment/start-tracing.json"), "utf8"));
|
const tracingEnvVariables = JSON.parse(fs.readFileSync(path.resolve(config.dbLocation, "temp/tracingEnvironment/start-tracing.json"), "utf8"));
|
||||||
return {
|
return {
|
||||||
@@ -182,15 +206,15 @@ async function getCombinedTracerConfig(config, codeql) {
|
|||||||
tracedLanguageConfigs[language] = await getTracerConfigForLanguage(codeql, config, language);
|
tracedLanguageConfigs[language] = await getTracerConfigForLanguage(codeql, config, language);
|
||||||
}
|
}
|
||||||
mainTracerConfig = concatTracerConfigs(tracedLanguageConfigs, config);
|
mainTracerConfig = concatTracerConfigs(tracedLanguageConfigs, config);
|
||||||
}
|
// Add a couple more variables
|
||||||
// Add a couple more variables
|
mainTracerConfig.env["ODASA_TRACER_CONFIGURATION"] = mainTracerConfig.spec;
|
||||||
mainTracerConfig.env["ODASA_TRACER_CONFIGURATION"] = mainTracerConfig.spec;
|
const codeQLDir = path.dirname(codeql.getPath());
|
||||||
const codeQLDir = path.dirname(codeql.getPath());
|
if (process.platform === "darwin") {
|
||||||
if (process.platform === "darwin") {
|
mainTracerConfig.env["DYLD_INSERT_LIBRARIES"] = path.join(codeQLDir, "tools", "osx64", "libtrace.dylib");
|
||||||
mainTracerConfig.env["DYLD_INSERT_LIBRARIES"] = path.join(codeQLDir, "tools", "osx64", "libtrace.dylib");
|
}
|
||||||
}
|
else if (process.platform !== "win32") {
|
||||||
else if (process.platform !== "win32") {
|
mainTracerConfig.env["LD_PRELOAD"] = path.join(codeQLDir, "tools", "linux64", "${LIB}trace.so");
|
||||||
mainTracerConfig.env["LD_PRELOAD"] = path.join(codeQLDir, "tools", "linux64", "${LIB}trace.so");
|
}
|
||||||
}
|
}
|
||||||
// On macos it's necessary to prefix the build command with the runner executable
|
// On macos it's necessary to prefix the build command with the runner executable
|
||||||
// on order to trace when System Integrity Protection is enabled.
|
// on order to trace when System Integrity Protection is enabled.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user