mirror of
https://github.com/github/codeql-action.git
synced 2025-12-07 00:08:06 +08:00
Compare commits
548 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
384cfc42b2 | ||
|
|
5a1e31dc6a | ||
|
|
67c0353a8c | ||
|
|
7ec25e02e3 | ||
|
|
713eacdf6c | ||
|
|
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 | ||
|
|
e891551dd4 | ||
|
|
bd48dc5be5 | ||
|
|
a53b8d0ed1 | ||
|
|
22747bcb77 | ||
|
|
503f29874a | ||
|
|
c3b8b48b76 | ||
|
|
eae8bacaeb | ||
|
|
c226132b0b | ||
|
|
d3f5d485b3 | ||
|
|
4647e20bb5 | ||
|
|
1a3e71aa9a | ||
|
|
e86ea38e3f | ||
|
|
968c038839 | ||
|
|
531c6ba7c8 | ||
|
|
86fea52924 | ||
|
|
0499230710 | ||
|
|
c89d9bd8b0 | ||
|
|
63fd41bf33 | ||
|
|
a35be9cc60 | ||
|
|
0ebee75b04 | ||
|
|
70f007a73c | ||
|
|
1beeda3ba3 | ||
|
|
bee5aac8d7 | ||
|
|
04a87f068f | ||
|
|
ecffc3ce6b | ||
|
|
fc15a137e0 | ||
|
|
fd20d82b8d | ||
|
|
c49fe2506c | ||
|
|
1990ded3d2 | ||
|
|
f5e572fb4b | ||
|
|
a56f7259c1 | ||
|
|
5f37061461 | ||
|
|
286a237e20 | ||
|
|
43ea2ce0c9 | ||
|
|
3df217266d | ||
|
|
73f3a24896 | ||
|
|
e2f39a6d71 | ||
|
|
6ca99f72e9 | ||
|
|
1ebb0a0a35 | ||
|
|
f2159737dd | ||
|
|
5153cc4c8d | ||
|
|
faa3cfa2e9 | ||
|
|
fd3190bba5 | ||
|
|
4a45fbee96 | ||
|
|
0bbf22e3b7 | ||
|
|
d362b66e03 | ||
|
|
9e7b37f8e4 | ||
|
|
944ae88ffe | ||
|
|
ace3701b4a | ||
|
|
dbb326152c | ||
|
|
03e7dda1b9 | ||
|
|
ee9e32621e | ||
|
|
3bfe8ab742 | ||
|
|
515f16b728 | ||
|
|
8b12e8c5e1 | ||
|
|
10f284c032 | ||
|
|
19d3f6c536 | ||
|
|
7d56b0cd44 | ||
|
|
69ddeed7d5 | ||
|
|
2c73ad667d | ||
|
|
b5a522dfb8 | ||
|
|
1ddd8a5632 | ||
|
|
d96049eeaf | ||
|
|
168327a4aa | ||
|
|
ef3290ce11 | ||
|
|
f04acbbdc3 | ||
|
|
cd1b9df1e3 | ||
|
|
292203e8b6 | ||
|
|
f151a3cfe6 | ||
|
|
ee57c2ed58 | ||
|
|
d521b0e630 | ||
|
|
5aac657d98 | ||
|
|
ed36ec077c | ||
|
|
bb0850a826 | ||
|
|
f16cf435c3 | ||
|
|
167d7583fe | ||
|
|
1b37538d9c | ||
|
|
334262d6cf | ||
|
|
1f4460b9fb | ||
|
|
e40e887968 | ||
|
|
6e631b99c4 | ||
|
|
5a80cb1408 | ||
|
|
014d3ea60a | ||
|
|
8caa0808ee | ||
|
|
fd4659dfd4 | ||
|
|
7112cdaa06 | ||
|
|
58056a4b12 | ||
|
|
18cda24a3b | ||
|
|
c93e88dc4b | ||
|
|
a52e4c3e23 | ||
|
|
9db151d251 | ||
|
|
6e8752e4d5 | ||
|
|
adfea7610d | ||
|
|
40568daca8 | ||
|
|
5b28adb7ed | ||
|
|
008b2cc71c | ||
|
|
58d2adec4b | ||
|
|
b5a94e0978 | ||
|
|
31ae172f4b | ||
|
|
d0b95baf8b | ||
|
|
aa1baf5b84 | ||
|
|
bc190d2af9 | ||
|
|
c0971eed35 | ||
|
|
ac8bd3f417 | ||
|
|
4854dd23d5 | ||
|
|
c5468fcaea | ||
|
|
b0b34e58f9 | ||
|
|
83d5f38dee | ||
|
|
444316b6c6 | ||
|
|
7128833392 | ||
|
|
455ee1f217 | ||
|
|
54fc9c575e | ||
|
|
3525a164c3 | ||
|
|
aeeb3c3e88 | ||
|
|
88d30845f1 | ||
|
|
89d78ba457 | ||
|
|
e72d9f4a72 | ||
|
|
4455bf8cd9 | ||
|
|
f27dc32aeb | ||
|
|
bf6f871097 | ||
|
|
cda7fe109b | ||
|
|
12300ac88e | ||
|
|
11db623ba8 | ||
|
|
3f515d3140 | ||
|
|
a57642e1a0 | ||
|
|
bf85baea70 | ||
|
|
62ef9f5eb2 | ||
|
|
e22a6cd3c9 | ||
|
|
f9b0b9cb7b | ||
|
|
5fc16ebcf6 | ||
|
|
7e2215bc92 | ||
|
|
3a016ebea8 | ||
|
|
2ba7208ff2 | ||
|
|
72399ae69a | ||
|
|
c0a58782b6 | ||
|
|
d1ff4d6297 | ||
|
|
80a6b3a41e | ||
|
|
1c27c52804 | ||
|
|
e833d6e84c | ||
|
|
8a0c541e24 | ||
|
|
e2d592dc8f | ||
|
|
2e71e02553 | ||
|
|
b29bf7b05a | ||
|
|
1785bbb7d8 | ||
|
|
a44b61d961 | ||
|
|
a062fc9bf5 | ||
|
|
50de2e4d1e | ||
|
|
132e08a05f | ||
|
|
720884501a | ||
|
|
6dc5d80b98 | ||
|
|
542390c023 | ||
|
|
fd45eac830 | ||
|
|
e70ec1d70e | ||
|
|
70d2efc353 | ||
|
|
fb77829455 | ||
|
|
4ba53e33d7 | ||
|
|
f0a2954c12 | ||
|
|
bf91ac91d4 | ||
|
|
e3151ae8df | ||
|
|
a2f0227de2 | ||
|
|
2639547a69 | ||
|
|
e86cff2acb | ||
|
|
2eb8300e80 | ||
|
|
78cda05e38 | ||
|
|
b0e70410b4 | ||
|
|
3254fa5859 | ||
|
|
01d17eaf42 | ||
|
|
0c4306b672 | ||
|
|
acd9964b7a | ||
|
|
bc33041cc2 | ||
|
|
c7203c94d9 | ||
|
|
7f1659f0d8 | ||
|
|
962925a448 | ||
|
|
4e477f1b95 | ||
|
|
a068a286e6 | ||
|
|
b19f1f91f0 | ||
|
|
f1c75fc816 | ||
|
|
1e0763ca30 | ||
|
|
5fd8ca8122 | ||
|
|
873a76a1a7 | ||
|
|
4a0d3378b1 | ||
|
|
46043e8a9e | ||
|
|
75aad219f8 | ||
|
|
fe83f965e4 | ||
|
|
3ebf97724d | ||
|
|
0d884244be | ||
|
|
1263b9c651 | ||
|
|
93c9da2c2e | ||
|
|
060eb52d32 | ||
|
|
8c8a933d75 | ||
|
|
743d8dfb6e | ||
|
|
75d42bea8d | ||
|
|
46ddfc6186 | ||
|
|
07fa17da87 | ||
|
|
61fb5d7202 | ||
|
|
89e4b4fff3 | ||
|
|
9ad3f820af | ||
|
|
5ba154a3b4 | ||
|
|
bb0eba15f5 | ||
|
|
db7158f9ba | ||
|
|
94013c25cf | ||
|
|
20de0f01a3 | ||
|
|
21753283b1 | ||
|
|
44c8bd3e63 | ||
|
|
952b2690da | ||
|
|
d6a5bf5c1c | ||
|
|
068ade0b31 | ||
|
|
183487b717 | ||
|
|
38bb211981 | ||
|
|
a0ab4842b5 | ||
|
|
9e304b92ff | ||
|
|
5e1d24657c | ||
|
|
2b6d86c672 | ||
|
|
5bcf9d9972 | ||
|
|
8068352efa | ||
|
|
bef7eecb10 | ||
|
|
1df71f8baa | ||
|
|
8ddd620de3 | ||
|
|
53cfc95284 | ||
|
|
b22fb4674b | ||
|
|
64160b2268 | ||
|
|
ab6c0bce1b | ||
|
|
2a5fc0f6de | ||
|
|
d98d4f5fa8 | ||
|
|
2632b65a56 | ||
|
|
7eb261eac8 | ||
|
|
33927cc1c9 | ||
|
|
56b49fcd72 | ||
|
|
a673c950da | ||
|
|
0f516d90cf | ||
|
|
3057100963 | ||
|
|
e7f3012cc2 | ||
|
|
af7bc11dda | ||
|
|
a00769bdfb | ||
|
|
6e07237fd0 | ||
|
|
1b2479810e | ||
|
|
fa18c6064c | ||
|
|
adc7ff601c | ||
|
|
4f7bdf9d42 | ||
|
|
60484b2ccc | ||
|
|
9a562a33ac | ||
|
|
344d820984 | ||
|
|
2fcaf414fc | ||
|
|
a300034dbd | ||
|
|
ea8896ddf6 | ||
|
|
a73bba9f11 | ||
|
|
6e12f03311 | ||
|
|
33f3438c1d | ||
|
|
758835d67a | ||
|
|
9b3d4fd580 | ||
|
|
1c369971ff | ||
|
|
fb5a72155f | ||
|
|
2ea04f7e8a | ||
|
|
833be9c64e | ||
|
|
54e3e4405e | ||
|
|
1957254b4c | ||
|
|
e050205119 | ||
|
|
3b74ec2288 | ||
|
|
5b2b500646 | ||
|
|
aacf63d354 | ||
|
|
fe639a1033 | ||
|
|
fd833ba2c1 | ||
|
|
7e7162aa1e | ||
|
|
3baa223274 | ||
|
|
8fa56f3f78 | ||
|
|
c508d620dd | ||
|
|
ec2762e6fe | ||
|
|
a40becf6e4 | ||
|
|
5a67cbafe6 | ||
|
|
f3061d6dee | ||
|
|
a61bfd9ae4 | ||
|
|
5fee2f2ed7 | ||
|
|
46a225cb6f | ||
|
|
25fef55830 | ||
|
|
d523ba9baa | ||
|
|
ad37b812d5 | ||
|
|
e97797c21b | ||
|
|
cdcc3e81d5 | ||
|
|
e18dc0f8c5 | ||
|
|
6799d572f7 | ||
|
|
802eff9491 | ||
|
|
532d1b906d | ||
|
|
ecdbfd6594 | ||
|
|
351d080ced | ||
|
|
d0e23476a6 | ||
|
|
f0fd45b66f | ||
|
|
32c4995972 | ||
|
|
d1d4cc3106 | ||
|
|
c6b30dcdcb | ||
|
|
62be3f8b9d | ||
|
|
e1828d5291 | ||
|
|
ea5e62748e | ||
|
|
b1e69f9179 | ||
|
|
5fc3f3af30 | ||
|
|
30a243e57a | ||
|
|
659ec058e3 | ||
|
|
70bbe2df84 | ||
|
|
16fa9d48f8 | ||
|
|
67954db0cf | ||
|
|
1c4c64199f | ||
|
|
0cae9d939e | ||
|
|
5eb7f8c9a4 | ||
|
|
6abc4a8c32 | ||
|
|
3ba511a8f1 | ||
|
|
5f6ba88b4b | ||
|
|
50cb464f4a | ||
|
|
6e37ee3fe2 | ||
|
|
6ca0c46132 | ||
|
|
f649b7bd23 | ||
|
|
6520447123 | ||
|
|
5c80cfcc1e | ||
|
|
5643f45615 | ||
|
|
e45b14cfc3 | ||
|
|
05fc5a885c | ||
|
|
fb65207e91 | ||
|
|
fde64716e1 | ||
|
|
2a0289b1d8 | ||
|
|
04e8743013 | ||
|
|
e66384f36e | ||
|
|
34f86ea4ba | ||
|
|
c18ebba599 | ||
|
|
4df0bb9371 | ||
|
|
9c0cd50e9e | ||
|
|
6fdd5c2f4c | ||
|
|
8536203ad8 | ||
|
|
5a7f86f625 | ||
|
|
dbb1b44b8f | ||
|
|
07578cd9e7 | ||
|
|
cec3af8bb0 | ||
|
|
dae51797d0 | ||
|
|
a81500cbd6 | ||
|
|
ddd2696b4e | ||
|
|
de06f8a300 | ||
|
|
8c3255bc78 | ||
|
|
186161e61c | ||
|
|
cc561bc122 | ||
|
|
df6f81e49c | ||
|
|
b47da63f07 | ||
|
|
70f5789ed2 | ||
|
|
99afdfbfbd | ||
|
|
55e50b88db | ||
|
|
d9849b8ca1 | ||
|
|
60bee34764 | ||
|
|
c335145f4d | ||
|
|
17223bdff7 | ||
|
|
cc1adb825a | ||
|
|
80916e968c | ||
|
|
9ce2456348 | ||
|
|
3ab5d6d4d6 | ||
|
|
35f1961385 | ||
|
|
6b0d45a5c6 | ||
|
|
4867598089 | ||
|
|
2aa2bede67 | ||
|
|
69c3617042 | ||
|
|
181fce25fe | ||
|
|
05a53bbd2d | ||
|
|
d13dea1c37 | ||
|
|
fb19072237 | ||
|
|
c4e99325d0 | ||
|
|
ddb608be41 | ||
|
|
59e2f2d80d | ||
|
|
57a865e201 | ||
|
|
dd1c95359b | ||
|
|
fc12036b55 | ||
|
|
fb8602423d | ||
|
|
fa857eb53f | ||
|
|
ecc548b556 | ||
|
|
2f3ec1f9f1 | ||
|
|
554f1b3765 | ||
|
|
934fb86c58 | ||
|
|
e145aa414e | ||
|
|
36f860f369 | ||
|
|
63603427ef | ||
|
|
bf54da2db0 | ||
|
|
592af860c5 | ||
|
|
60211eb74c | ||
|
|
3428407b4d | ||
|
|
d6fc379360 | ||
|
|
11d56696ec | ||
|
|
47cfd760cf | ||
|
|
01b1510da2 | ||
|
|
0afedcafa7 | ||
|
|
2a20b15eca | ||
|
|
0d0f0ef80e |
@@ -14,11 +14,14 @@
|
|||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"filenames/match-regex": ["error", "^[a-z0-9-]+(\\.test)?$"],
|
"filenames/match-regex": ["error", "^[a-z0-9-]+(\\.test)?$"],
|
||||||
|
"i18n-text/no-en": "off",
|
||||||
"import/extensions": "error",
|
"import/extensions": "error",
|
||||||
"import/no-amd": "error",
|
"import/no-amd": "error",
|
||||||
"import/no-commonjs": "error",
|
"import/no-commonjs": "error",
|
||||||
"import/no-dynamic-require": "error",
|
"import/no-dynamic-require": "error",
|
||||||
"import/no-extraneous-dependencies": ["error"],
|
// Disable the rule that checks that devDependencies aren't imported since we use a single
|
||||||
|
// linting configuration file for both source and test code.
|
||||||
|
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}],
|
||||||
"import/no-namespace": "off",
|
"import/no-namespace": "off",
|
||||||
"import/no-unresolved": "error",
|
"import/no-unresolved": "error",
|
||||||
"import/no-webpack-loader-syntax": "error",
|
"import/no-webpack-loader-syntax": "error",
|
||||||
@@ -48,7 +51,8 @@
|
|||||||
"@typescript-eslint/prefer-regexp-exec": "off",
|
"@typescript-eslint/prefer-regexp-exec": "off",
|
||||||
"@typescript-eslint/require-await": "off",
|
"@typescript-eslint/require-await": "off",
|
||||||
"@typescript-eslint/restrict-template-expressions": "off",
|
"@typescript-eslint/restrict-template-expressions": "off",
|
||||||
"func-style": "off"
|
"func-style": "off",
|
||||||
|
"sort-imports": "off"
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,4 +1,5 @@
|
|||||||
lib/*.js linguist-generated=true
|
lib/*.js linguist-generated=true
|
||||||
|
.github/workflows/__* linguist-generated=true
|
||||||
|
|
||||||
# Reduce incidence of needless merge conflicts on CHANGELOG.md
|
# Reduce incidence of needless merge conflicts on CHANGELOG.md
|
||||||
# The man page at
|
# The man page at
|
||||||
|
|||||||
20
.github/dependabot.yml
vendored
Normal file
20
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "thursday" # Gives us a working day to merge this before our typical release
|
||||||
|
labels:
|
||||||
|
- "Update dependencies"
|
||||||
|
ignore:
|
||||||
|
- dependency-name: "*"
|
||||||
|
update-types: ["version-update:semver-minor", "version-update:semver-patch"]
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/runner"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "thursday" # Gives us a working day to merge this before our typical release
|
||||||
|
ignore:
|
||||||
|
- dependency-name: "*"
|
||||||
|
update-types: ["version-update:semver-minor", "version-update:semver-patch"]
|
||||||
38
.github/prepare-test/action.yml
vendored
Normal file
38
.github/prepare-test/action.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
name: "Prepare test"
|
||||||
|
description: Performs some preparation to run tests
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
required: true
|
||||||
|
outputs:
|
||||||
|
tools-url:
|
||||||
|
value: ${{ steps.get-url.outputs.tools-url }}
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
mv ../action/.github/workflows .github
|
||||||
|
- id: get-url
|
||||||
|
name: Determine URL
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [[ ${{ inputs.version }} == "nightly-latest" ]]; then
|
||||||
|
export LATEST=`gh release list --repo dsp-testing/codeql-cli-nightlies -L 1 | cut -f 3`
|
||||||
|
echo "::set-output name=tools-url::https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/$LATEST/codeql-bundle.tar.gz"
|
||||||
|
elif [[ ${{ inputs.version }} == *"nightly"* ]]; then
|
||||||
|
export VERSION=`echo ${{ inputs.version }} | sed -e 's/^.*\-//'`
|
||||||
|
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
|
||||||
|
export VERSION=`echo ${{ inputs.version }} | sed -e 's/^.*\-//'`
|
||||||
|
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
|
||||||
|
echo "::set-output name=tools-url::latest"
|
||||||
|
elif [[ ${{ inputs.version }} == "cached" ]]; then
|
||||||
|
echo "::set-output name=tools-url::"
|
||||||
|
else
|
||||||
|
echo "::error Unrecognized version specified!"
|
||||||
|
fi
|
||||||
4
.github/update-release-branch.py
vendored
4
.github/update-release-branch.py
vendored
@@ -93,7 +93,9 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
|
|||||||
title = 'Merge ' + MAIN_BRANCH + ' into ' + LATEST_RELEASE_BRANCH
|
title = 'Merge ' + MAIN_BRANCH + ' into ' + LATEST_RELEASE_BRANCH
|
||||||
|
|
||||||
# Create the pull request
|
# Create the pull request
|
||||||
pr = repo.create_pull(title=title, body='\n'.join(body), head=branch_name, base=LATEST_RELEASE_BRANCH)
|
# 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.
|
||||||
|
pr = repo.create_pull(title=title, body='\n'.join(body), head=branch_name, base=LATEST_RELEASE_BRANCH, draft=True)
|
||||||
print('Created PR #' + str(pr.number))
|
print('Created PR #' + str(pr.number))
|
||||||
|
|
||||||
# Assign the conductor
|
# Assign the conductor
|
||||||
|
|||||||
77
.github/workflows/__debug-artifacts.yml
generated
vendored
Normal file
77
.github/workflows/__debug-artifacts.yml
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# 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
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
debug-artifacts:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable-20201028
|
||||||
|
- stable-20210319
|
||||||
|
- stable-20210809
|
||||||
|
- cached
|
||||||
|
- latest
|
||||||
|
- nightly-latest
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
name: Debug artifact upload
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- 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@v2
|
||||||
|
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
|
||||||
63
.github/workflows/__extractor-ram-threads.yml
generated
vendored
Normal file
63
.github/workflows/__extractor-ram-threads.yml
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# 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
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
extractor-ram-threads:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [latest]
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
name: Extractor ram and threads options test
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- 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
|
||||||
62
.github/workflows/__go-custom-queries.yml
generated
vendored
Normal file
62
.github/workflows/__go-custom-queries.yml
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# 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 - Go: Custom queries'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
go-custom-queries:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable-20201028
|
||||||
|
- stable-20210319
|
||||||
|
- stable-20210809
|
||||||
|
- cached
|
||||||
|
- latest
|
||||||
|
- nightly-latest
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
- windows-latest
|
||||||
|
name: 'Go: Custom queries'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ^1.13.1
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: go
|
||||||
|
config-file: ./.github/codeql/custom-queries.yml
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
64
.github/workflows/__go-custom-tracing-autobuild.yml
generated
vendored
Normal file
64
.github/workflows/__go-custom-tracing-autobuild.yml
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
# 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 - Go: Autobuild custom tracing'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
go-custom-tracing-autobuild:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable-20201028
|
||||||
|
- stable-20210319
|
||||||
|
- stable-20210809
|
||||||
|
- cached
|
||||||
|
- latest
|
||||||
|
- nightly-latest
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
name: 'Go: Autobuild custom tracing'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ^1.13.1
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: go
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- uses: ./../action/autobuild
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
cd "$RUNNER_TEMP/codeql_databases"
|
||||||
|
if [[ ! -d go ]]; then
|
||||||
|
echo "Did not find a Go database"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
CODEQL_EXTRACTOR_GO_BUILD_TRACING: 'true'
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
62
.github/workflows/__go-custom-tracing.yml
generated
vendored
Normal file
62
.github/workflows/__go-custom-tracing.yml
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
# 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 - Go: Custom tracing'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
go-custom-tracing:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable-20201028
|
||||||
|
- stable-20210319
|
||||||
|
- stable-20210809
|
||||||
|
- cached
|
||||||
|
- latest
|
||||||
|
- nightly-latest
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
- windows-latest
|
||||||
|
name: 'Go: Custom tracing'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ^1.13.1
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: go
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: go build main.go
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
env:
|
||||||
|
CODEQL_EXTRACTOR_GO_BUILD_TRACING: 'true'
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
61
.github/workflows/__javascript-source-root.yml
generated
vendored
Normal file
61
.github/workflows/__javascript-source-root.yml
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# 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 - Custom source root
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
javascript-source-root:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [latest, cached, nightly-latest] # This feature is not compatible with old CLIs
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
name: Custom source root
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../new-source-root
|
||||||
|
mv * ../new-source-root
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: javascript
|
||||||
|
source-root: ../new-source-root
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
with:
|
||||||
|
skip-queries: true
|
||||||
|
upload: false
|
||||||
|
- name: Assert database exists
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd "$RUNNER_TEMP/codeql_databases"
|
||||||
|
if [[ ! -d javascript ]]; then
|
||||||
|
echo "Did not find a JavaScript database"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
88
.github/workflows/__multi-language-autodetect.yml
generated
vendored
Normal file
88
.github/workflows/__multi-language-autodetect.yml
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
# 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 - Multi-language repository
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
multi-language-autodetect:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable-20201028
|
||||||
|
- stable-20210319
|
||||||
|
- stable-20210809
|
||||||
|
- cached
|
||||||
|
- latest
|
||||||
|
- nightly-latest
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
name: Multi-language repository
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- 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: ./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
|
||||||
67
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
Normal file
67
.github/workflows/__packaging-config-inputs-js.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 - Packaging: Config and input'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
packaging-config-inputs-js:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [nightly-20210831] # This CLI version is known to work with package used in this test
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
name: 'Packaging: Config and input'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
config-file: .github/codeql/codeql-config-packaging3.yml
|
||||||
|
packs: +dsp-testing/codeql-pack1@0.1.0
|
||||||
|
languages: javascript
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
with:
|
||||||
|
output: ${{ runner.temp }}/results
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Assert Results
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd "$RUNNER_TEMP/results"
|
||||||
|
# We should have 3 hits from these rules
|
||||||
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
||||||
|
|
||||||
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
||||||
|
echo "Found matching rules '$RULES'"
|
||||||
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
66
.github/workflows/__packaging-config-js.yml
generated
vendored
Normal file
66
.github/workflows/__packaging-config-js.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 - Packaging: Config file'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
packaging-config-js:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [nightly-20210831] # This CLI version is known to work with package used in this test
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
name: 'Packaging: Config file'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
config-file: .github/codeql/codeql-config-packaging.yml
|
||||||
|
languages: javascript
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
with:
|
||||||
|
output: ${{ runner.temp }}/results
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Assert Results
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd "$RUNNER_TEMP/results"
|
||||||
|
# We should have 3 hits from these rules
|
||||||
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
||||||
|
|
||||||
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
||||||
|
echo "Found matching rules '$RULES'"
|
||||||
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
67
.github/workflows/__packaging-inputs-js.yml
generated
vendored
Normal file
67
.github/workflows/__packaging-inputs-js.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 - Packaging: Action input'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
packaging-inputs-js:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [nightly-20210831] # This CLI version is known to work with package used in this test
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
name: 'Packaging: Action input'
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
config-file: .github/codeql/codeql-config-packaging2.yml
|
||||||
|
languages: javascript
|
||||||
|
packs: dsp-testing/codeql-pack1@0.1.0, dsp-testing/codeql-pack2
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
with:
|
||||||
|
output: ${{ runner.temp }}/results
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Assert Results
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd "$RUNNER_TEMP/results"
|
||||||
|
# We should have 3 hits from these rules
|
||||||
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
||||||
|
|
||||||
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
||||||
|
echo "Found matching rules '$RULES'"
|
||||||
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
60
.github/workflows/__remote-config.yml
generated
vendored
Normal file
60
.github/workflows/__remote-config.yml
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# 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 - Remote config file
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
remote-config:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable-20201028
|
||||||
|
- stable-20210319
|
||||||
|
- stable-20210809
|
||||||
|
- cached
|
||||||
|
- latest
|
||||||
|
- nightly-latest
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
- macos-latest
|
||||||
|
- windows-latest
|
||||||
|
name: Remote config file
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- 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/codeql-action/tests/multi-language-repo/.github/codeql/custom-queries.yml@${{
|
||||||
|
github.sha }}
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
67
.github/workflows/__rubocop-multi-language.yml
generated
vendored
Normal file
67
.github/workflows/__rubocop-multi-language.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 - RuboCop multi-language
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
rubocop-multi-language:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable-20201028
|
||||||
|
- stable-20210319
|
||||||
|
- stable-20210809
|
||||||
|
- cached
|
||||||
|
- latest
|
||||||
|
- nightly-latest
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
name: RuboCop multi-language
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- name: Set up Ruby
|
||||||
|
uses: ruby/setup-ruby@v1
|
||||||
|
with:
|
||||||
|
ruby-version: 2.6
|
||||||
|
- name: Install Code Scanning integration
|
||||||
|
shell: bash
|
||||||
|
run: bundle add code-scanning-rubocop --version 0.3.0 --skip-install
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
run: bundle install
|
||||||
|
- name: RuboCop run
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
bash -c "
|
||||||
|
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
|
||||||
|
[[ $? -ne 2 ]]
|
||||||
|
"
|
||||||
|
- uses: ./../action/upload-sarif
|
||||||
|
with:
|
||||||
|
sarif_file: rubocop.sarif
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
81
.github/workflows/__split-workflow.yml
generated
vendored
Normal file
81
.github/workflows/__split-workflow.yml
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
# 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 - Split workflow
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
split-workflow:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [nightly-20210831] # This CLI version is known to work with package used in this test
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
name: Split workflow
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
config-file: .github/codeql/codeql-config-packaging3.yml
|
||||||
|
packs: +dsp-testing/codeql-pack1@0.1.0
|
||||||
|
languages: javascript
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
with:
|
||||||
|
skip-queries: true
|
||||||
|
output: ${{ runner.temp }}/results
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Assert No Results
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
if [ "$(ls -A $RUNNER_TEMP/results)" ]; then
|
||||||
|
echo "Expected results directory to be empty after skipping query execution!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
with:
|
||||||
|
output: ${{ runner.temp }}/results
|
||||||
|
upload-database: false
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Assert Results
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd "$RUNNER_TEMP/results"
|
||||||
|
# We should have 3 hits from these rules
|
||||||
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
||||||
|
|
||||||
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
||||||
|
echo "Found matching rules '$RULES'"
|
||||||
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
54
.github/workflows/__test-local-codeql.yml
generated
vendored
Normal file
54
.github/workflows/__test-local-codeql.yml
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
# 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 - Local CodeQL bundle
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
test-local-codeql:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [nightly-latest]
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
name: Local CodeQL bundle
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- name: Fetch a CodeQL bundle
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
CODEQL_URL: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
run: |
|
||||||
|
wget "$CODEQL_URL"
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
tools: ./codeql-bundle.tar.gz
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
55
.github/workflows/__test-proxy.yml
generated
vendored
Normal file
55
.github/workflows/__test-proxy.yml
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
# 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 - Proxy test
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
test-proxy:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [latest]
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
name: Proxy test
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: javascript
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
env:
|
||||||
|
https_proxy: http://squid-proxy:3128
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
|
container:
|
||||||
|
image: ubuntu:18.04
|
||||||
|
options: --dns 127.0.0.1
|
||||||
|
services:
|
||||||
|
squid-proxy:
|
||||||
|
image: datadog/squid:latest
|
||||||
|
ports:
|
||||||
|
- 3128:3128
|
||||||
56
.github/workflows/__test-ruby.yml
generated
vendored
Normal file
56
.github/workflows/__test-ruby.yml
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# 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 - Ruby analysis
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- v1
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
test-ruby:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version: [latest, cached, nightly-latest]
|
||||||
|
os: [ubuntu-latest, macos-latest]
|
||||||
|
name: Ruby analysis
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: ruby
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
id: analysis
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Check database
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
RUBY_DB="${{ fromJson(steps.analysis.outputs.db-locations).ruby }}"
|
||||||
|
if [[ ! -d "$RUBY_DB" ]]; then
|
||||||
|
echo "Did not create a database for Ruby."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
CODEQL_ENABLE_EXPERIMENTAL_FEATURES: 'true'
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
88
.github/workflows/__unset-environment.yml
generated
vendored
Normal file
88
.github/workflows/__unset-environment.yml
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
# 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
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
unset-environment:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable-20201028
|
||||||
|
- stable-20210319
|
||||||
|
- stable-20210809
|
||||||
|
- cached
|
||||||
|
- latest
|
||||||
|
- nightly-latest
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
name: Test unsetting environment variables
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- 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
|
||||||
@@ -5,6 +5,9 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- .github/workflows/check-expected-release-files.yml
|
- .github/workflows/check-expected-release-files.yml
|
||||||
- src/defaults.json
|
- src/defaults.json
|
||||||
|
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
||||||
|
# by other workflows.
|
||||||
|
types: [opened, synchronize, reopened, ready_for_review]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-expected-release-files:
|
check-expected-release-files:
|
||||||
|
|||||||
19
.github/workflows/codeql.yml
vendored
19
.github/workflows/codeql.yml
vendored
@@ -5,6 +5,9 @@ on:
|
|||||||
branches: [main, v1]
|
branches: [main, v1]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, v1]
|
branches: [main, v1]
|
||||||
|
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
||||||
|
# by other workflows.
|
||||||
|
types: [opened, synchronize, reopened, ready_for_review]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Identify the CodeQL tool versions to use in the analysis job.
|
# Identify the CodeQL tool versions to use in the analysis job.
|
||||||
@@ -14,8 +17,6 @@ jobs:
|
|||||||
versions: ${{ steps.compare.outputs.versions }}
|
versions: ${{ steps.compare.outputs.versions }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
security-events: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
@@ -45,13 +46,19 @@ jobs:
|
|||||||
CODEQL_VERSION_LATEST="$("$CODEQL_LATEST" version --format terse)"
|
CODEQL_VERSION_LATEST="$("$CODEQL_LATEST" version --format terse)"
|
||||||
echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT"
|
echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT"
|
||||||
echo "Latest CodeQL bundle version is $CODEQL_VERSION_LATEST"
|
echo "Latest CodeQL bundle version is $CODEQL_VERSION_LATEST"
|
||||||
if [[ "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LATEST" ]]; then
|
|
||||||
# Just use `tools: null` to avoid duplication in the analysis job.
|
# If we're running on a pull request, run with both bundles, even if `tools: latest` would
|
||||||
|
# be the same as `tools: null`. This allows us to make the job for each of the bundles a
|
||||||
|
# required status check.
|
||||||
|
#
|
||||||
|
# If we're running on push, then we can skip running with `tools: latest` when it would be
|
||||||
|
# the same as running with `tools: null`.
|
||||||
|
if [[ "$GITHUB_EVENT_NAME" != "pull_request" && "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LATEST" ]]; then
|
||||||
VERSIONS_JSON='[null]'
|
VERSIONS_JSON='[null]'
|
||||||
else
|
else
|
||||||
# Use both `tools: null` and `tools: latest` in the analysis job.
|
|
||||||
VERSIONS_JSON='[null, "latest"]'
|
VERSIONS_JSON='[null, "latest"]'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Output a JSON-encoded list with the distinct versions to test against.
|
# Output a JSON-encoded list with the distinct versions to test against.
|
||||||
echo "Suggested matrix config for analysis job: $VERSIONS_JSON"
|
echo "Suggested matrix config for analysis job: $VERSIONS_JSON"
|
||||||
echo "::set-output name=versions::${VERSIONS_JSON}"
|
echo "::set-output name=versions::${VERSIONS_JSON}"
|
||||||
@@ -65,8 +72,6 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
security-events: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
14
.github/workflows/post-release-mergeback.yml
vendored
14
.github/workflows/post-release-mergeback.yml
vendored
@@ -106,18 +106,14 @@ jobs:
|
|||||||
git commit -m "Update changelog and version after $VERSION"
|
git commit -m "Update changelog and version after $VERSION"
|
||||||
npm version patch
|
npm version patch
|
||||||
|
|
||||||
# when running this workflow on a PR, this is just a test.
|
|
||||||
# so put into draft mode.
|
|
||||||
if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
|
|
||||||
DRAFT="--draft"
|
|
||||||
else
|
|
||||||
DRAFT=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
git push origin "$NEW_BRANCH"
|
git push origin "$NEW_BRANCH"
|
||||||
|
|
||||||
|
# PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft
|
||||||
|
# so that a maintainer can take the PR out of draft, thereby triggering the PR checks.
|
||||||
gh pr create \
|
gh pr create \
|
||||||
--head "$NEW_BRANCH" \
|
--head "$NEW_BRANCH" \
|
||||||
--base "$BASE_BRANCH" \
|
--base "$BASE_BRANCH" \
|
||||||
--title "$PR_TITLE" \
|
--title "$PR_TITLE" \
|
||||||
|
--label "Update dependencies" \
|
||||||
--body "$PR_BODY" \
|
--body "$PR_BODY" \
|
||||||
${DRAFT:+"$DRAFT"} # no quotes around $DRAFT. gh will error out if there is an empty ""
|
--draft
|
||||||
|
|||||||
1076
.github/workflows/pr-checks.yml
vendored
1076
.github/workflows/pr-checks.yml
vendored
File diff suppressed because it is too large
Load Diff
11
.github/workflows/python-deps.yml
vendored
11
.github/workflows/python-deps.yml
vendored
@@ -4,6 +4,9 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main, v1]
|
branches: [main, v1]
|
||||||
pull_request:
|
pull_request:
|
||||||
|
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
||||||
|
# by other workflows.
|
||||||
|
types: [opened, synchronize, reopened, ready_for_review]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-setup-python-scripts:
|
test-setup-python-scripts:
|
||||||
@@ -55,7 +58,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Verify packages installed
|
- name: Verify packages installed
|
||||||
run: |
|
run: |
|
||||||
$GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh ${PYTHON_VERSION}
|
$GITHUB_WORKSPACE/python-setup/tests/check_requests_2_26_0.sh ${PYTHON_VERSION}
|
||||||
|
|
||||||
# This one shouldn't fail, but also won't install packages
|
# This one shouldn't fail, but also won't install packages
|
||||||
test-setup-python-scripts-non-standard-location:
|
test-setup-python-scripts-non-standard-location:
|
||||||
@@ -120,6 +123,10 @@ jobs:
|
|||||||
# 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@v2
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: ./init
|
uses: ./init
|
||||||
with:
|
with:
|
||||||
@@ -146,5 +153,5 @@ jobs:
|
|||||||
|
|
||||||
- name: Verify packages installed
|
- name: Verify packages installed
|
||||||
run: |
|
run: |
|
||||||
$cmd = $Env:GITHUB_WORKSPACE + "\\python-setup\\tests\\check_requests_123.ps1"
|
$cmd = $Env:GITHUB_WORKSPACE + "\\python-setup\\tests\\check_requests_2_26_0.ps1"
|
||||||
powershell -File $cmd $Env:PYTHON_VERSION
|
powershell -File $cmd $Env:PYTHON_VERSION
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ if [ ! -z "$(git status --porcelain)" ]; then
|
|||||||
>&2 echo "Failed: Repo should be clean before testing!"
|
>&2 echo "Failed: Repo should be clean before testing!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
sudo npm install --force -g npm@latest
|
||||||
# Reinstall modules and then clean to remove absolute paths
|
# Reinstall modules and then clean to remove absolute paths
|
||||||
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
|
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
|
||||||
npm ci
|
npm ci
|
||||||
|
|||||||
25
.github/workflows/script/verify-pr-checks.sh
vendored
Executable file
25
.github/workflows/script/verify-pr-checks.sh
vendored
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Sanity check that repo is clean to start with
|
||||||
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
|
# If we get a fail here then this workflow needs attention...
|
||||||
|
>&2 echo "Failed: Repo should be clean before testing!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wipe the generated PR checks in case there are extra unnecessary files in there
|
||||||
|
rm -rf .github/workflows/__*
|
||||||
|
|
||||||
|
# Generate the PR checks
|
||||||
|
cd pr-checks && python3 sync.py
|
||||||
|
|
||||||
|
# Check that repo is still clean
|
||||||
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
|
# If we get a fail here then the PR needs attention
|
||||||
|
git diff
|
||||||
|
git status
|
||||||
|
>&2 echo "Failed: PR checks are not up to date. Run 'cd pr-checks && python3 sync.py' to update"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Success: PR checks are up to date"
|
||||||
39
.github/workflows/update-dependencies.yml
vendored
Normal file
39
.github/workflows/update-dependencies.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: Update dependencies
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened, synchronize, reopened, ready_for_review, labeled]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update:
|
||||||
|
name: Update dependencies
|
||||||
|
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')
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Remove PR label
|
||||||
|
env:
|
||||||
|
REPOSITORY: '${{ github.repository }}'
|
||||||
|
PR_NUMBER: '${{ github.event.pull_request.number }}'
|
||||||
|
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
|
run: |
|
||||||
|
gh api "repos/$REPOSITORY/issues/$PR_NUMBER/labels/Update%20dependencies" -X DELETE
|
||||||
|
|
||||||
|
- name: Push updated dependencies
|
||||||
|
env:
|
||||||
|
BRANCH: '${{ github.head_ref }}'
|
||||||
|
run: |
|
||||||
|
git fetch origin "$BRANCH" --depth=1
|
||||||
|
git checkout "origin/$BRANCH"
|
||||||
|
sudo npm install --force -g npm@latest
|
||||||
|
npm install
|
||||||
|
npm ci
|
||||||
|
npm run removeNPMAbsolutePaths
|
||||||
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
|
git config --global user.email "github-actions@github.com"
|
||||||
|
git config --global user.name "github-actions[bot]"
|
||||||
|
git add node_modules
|
||||||
|
git commit -am "Update checked-in dependencies"
|
||||||
|
git push origin "HEAD:$BRANCH"
|
||||||
|
fi
|
||||||
4
.github/workflows/update-release-branch.yml
vendored
4
.github/workflows/update-release-branch.yml
vendored
@@ -1,7 +1,5 @@
|
|||||||
name: Update release branch
|
name: Update release branch
|
||||||
on:
|
on:
|
||||||
schedule:
|
|
||||||
- cron: 0 9 * * 1
|
|
||||||
repository_dispatch:
|
repository_dispatch:
|
||||||
# Example of how to trigger this:
|
# 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"}'
|
# curl -H "Authorization: Bearer <token>" -X POST https://api.github.com/repos/github/codeql-action/dispatches -d '{"event_type":"update-release-branch"}'
|
||||||
@@ -27,7 +25,7 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install PyGithub==1.51 requests
|
pip install PyGithub==1.55 requests
|
||||||
|
|
||||||
- name: Update git config
|
- name: Update git config
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
97
CHANGELOG.md
97
CHANGELOG.md
@@ -1,5 +1,102 @@
|
|||||||
# CodeQL Action and CodeQL Runner Changelog
|
# CodeQL Action and CodeQL Runner Changelog
|
||||||
|
|
||||||
|
## 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"`.
|
||||||
|
|
||||||
|
## 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
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.7.0. [#795](https://github.com/github/codeql-action/pull/795)
|
||||||
|
|
||||||
|
## 1.0.20 - 25 Oct 2021
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 1.0.19 - 18 Oct 2021
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 1.0.18 - 08 Oct 2021
|
||||||
|
|
||||||
|
- Fixed a bug where some builds were no longer being traced correctly. [#766](https://github.com/github/codeql-action/pull/766)
|
||||||
|
|
||||||
|
## 1.0.17 - 07 Oct 2021
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.6.3. [#761](https://github.com/github/codeql-action/pull/761)
|
||||||
|
|
||||||
|
## 1.0.16 - 05 Oct 2021
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 1.0.15 - 22 Sep 2021
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.6.2. [#746](https://github.com/github/codeql-action/pull/746)
|
||||||
|
|
||||||
|
## 1.0.14 - 09 Sep 2021
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.6.1. [#733](https://github.com/github/codeql-action/pull/733)
|
||||||
|
|
||||||
|
## 1.0.13 - 06 Sep 2021
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.6.0. [#712](https://github.com/github/codeql-action/pull/712)
|
||||||
|
- Update baseline lines of code counter for python. All multi-line strings are counted as code. [#714](https://github.com/github/codeql-action/pull/714)
|
||||||
|
- Remove old baseline LoC injection [#715](https://github.com/github/codeql-action/pull/715)
|
||||||
|
|
||||||
|
## 1.0.12 - 16 Aug 2021
|
||||||
|
|
||||||
|
- Update README to include a sample permissions block. [#689](https://github.com/github/codeql-action/pull/689)
|
||||||
|
|
||||||
|
## 1.0.11 - 09 Aug 2021
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.5.9. [#687](https://github.com/github/codeql-action/pull/687)
|
||||||
|
|
||||||
|
## 1.0.10 - 03 Aug 2021
|
||||||
|
|
||||||
|
- Fix an issue where a summary of diagnostics information from CodeQL was not output to the logs of the `analyze` step of the Action. [#672](https://github.com/github/codeql-action/pull/672)
|
||||||
|
|
||||||
|
## 1.0.9 - 02 Aug 2021
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 1.0.8 - 26 Jul 2021
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.5.8. [#631](https://github.com/github/codeql-action/pull/631)
|
||||||
|
|
||||||
|
## 1.0.7 - 21 Jul 2021
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
## 1.0.6 - 19 Jul 2021
|
## 1.0.6 - 19 Jul 2021
|
||||||
|
|
||||||
- The `init` step of the Action now supports a `source-root` input as a path to the root source-code directory. By default, the path is relative to `$GITHUB_WORKSPACE`. [#607](https://github.com/github/codeql-action/pull/607)
|
- The `init` step of the Action now supports a `source-root` input as a path to the root source-code directory. By default, the path is relative to `$GITHUB_WORKSPACE`. [#607](https://github.com/github/codeql-action/pull/607)
|
||||||
|
|||||||
@@ -58,6 +58,20 @@ Here are a few things you can do that will increase the likelihood of your pull
|
|||||||
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
|
- Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
|
||||||
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
- Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
|
||||||
|
|
||||||
|
## Releasing (write access required)
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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).
|
||||||
|
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. 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.
|
||||||
|
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.
|
||||||
|
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.
|
||||||
|
|
||||||
|
Approve the mergeback PR and automerge it. Once the mergeback has been merged into main, the release is complete.
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -22,7 +22,9 @@ name: "Code Scanning - Action"
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
schedule:
|
schedule:
|
||||||
# ┌───────────── minute (0 - 59)
|
# ┌───────────── minute (0 - 59)
|
||||||
# │ ┌───────────── hour (0 - 23)
|
# │ ┌───────────── hour (0 - 23)
|
||||||
@@ -40,6 +42,14 @@ jobs:
|
|||||||
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
|
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
# required for all workflows
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
# only required for workflows in private repositories
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@@ -64,8 +74,8 @@ jobs:
|
|||||||
# project uses a compiled language
|
# project uses a compiled language
|
||||||
|
|
||||||
#- run: |
|
#- run: |
|
||||||
# make bootstrap
|
# make bootstrap
|
||||||
# make release
|
# make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v1
|
||||||
@@ -81,8 +91,8 @@ If you prefer to integrate this within an existing CI workflow, it should end up
|
|||||||
|
|
||||||
# Here is where you build your code
|
# Here is where you build your code
|
||||||
- run: |
|
- run: |
|
||||||
make bootstrap
|
make bootstrap
|
||||||
make release
|
make release
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v1
|
uses: github/codeql-action/analyze@v1
|
||||||
|
|||||||
@@ -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,7 +34,12 @@ 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."
|
||||||
@@ -42,6 +52,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: "false"
|
||||||
token:
|
token:
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
matrix:
|
matrix:
|
||||||
@@ -50,5 +64,5 @@ 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.
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: "node12"
|
||||||
main: '../lib/analyze-action.js'
|
main: "../lib/analyze-action.js"
|
||||||
|
|||||||
@@ -41,6 +41,34 @@ 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
|
||||||
|
|||||||
87
lib/actions-util.js
generated
87
lib/actions-util.js
generated
@@ -1,12 +1,25 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.sanitizeArifactName = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.getCommitOid = exports.getToolCacheDirectory = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
@@ -47,20 +60,20 @@ function getTemporaryDirectory() {
|
|||||||
const value = process.env["CODEQL_ACTION_TEMP"];
|
const value = process.env["CODEQL_ACTION_TEMP"];
|
||||||
return value !== undefined && value !== ""
|
return value !== undefined && value !== ""
|
||||||
? value
|
? value
|
||||||
: util_1.getRequiredEnvParam("RUNNER_TEMP");
|
: (0, util_1.getRequiredEnvParam)("RUNNER_TEMP");
|
||||||
}
|
}
|
||||||
exports.getTemporaryDirectory = getTemporaryDirectory;
|
exports.getTemporaryDirectory = getTemporaryDirectory;
|
||||||
function getToolCacheDirectory() {
|
function getToolCacheDirectory() {
|
||||||
const value = process.env["CODEQL_ACTION_TOOL_CACHE"];
|
const value = process.env["CODEQL_ACTION_TOOL_CACHE"];
|
||||||
return value !== undefined && value !== ""
|
return value !== undefined && value !== ""
|
||||||
? value
|
? value
|
||||||
: util_1.getRequiredEnvParam("RUNNER_TOOL_CACHE");
|
: (0, util_1.getRequiredEnvParam)("RUNNER_TOOL_CACHE");
|
||||||
}
|
}
|
||||||
exports.getToolCacheDirectory = getToolCacheDirectory;
|
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.
|
||||||
*/
|
*/
|
||||||
exports.getCommitOid = async function (ref = "HEAD") {
|
const getCommitOid = async function (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
|
||||||
@@ -85,9 +98,11 @@ exports.getCommitOid = async function (ref = "HEAD") {
|
|||||||
}
|
}
|
||||||
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: ${e}`);
|
||||||
return util_1.getRequiredEnvParam("GITHUB_SHA");
|
core.info(e.stack || "NO STACK");
|
||||||
|
return (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
exports.getCommitOid = getCommitOid;
|
||||||
function isObject(o) {
|
function isObject(o) {
|
||||||
return o !== null && typeof o === "object";
|
return o !== null && typeof o === "object";
|
||||||
}
|
}
|
||||||
@@ -147,12 +162,12 @@ exports.WorkflowErrors = toCodedErrors({
|
|||||||
CheckoutWrongHead: `git checkout HEAD^2 is no longer necessary. Please remove this step as Code Scanning recommends analyzing the merge commit for best results.`,
|
CheckoutWrongHead: `git checkout HEAD^2 is no longer necessary. Please remove this step as Code Scanning recommends analyzing the merge commit for best results.`,
|
||||||
});
|
});
|
||||||
function getWorkflowErrors(doc) {
|
function getWorkflowErrors(doc) {
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h;
|
var _a, _b, _c, _d, _e;
|
||||||
const errors = [];
|
const errors = [];
|
||||||
const jobName = process.env.GITHUB_JOB;
|
const jobName = process.env.GITHUB_JOB;
|
||||||
if (jobName) {
|
if (jobName) {
|
||||||
const job = (_b = (_a = doc) === null || _a === void 0 ? void 0 : _a.jobs) === null || _b === void 0 ? void 0 : _b[jobName];
|
const job = (_a = doc === null || doc === void 0 ? void 0 : doc.jobs) === null || _a === void 0 ? void 0 : _a[jobName];
|
||||||
const steps = (_c = job) === null || _c === void 0 ? void 0 : _c.steps;
|
const steps = job === null || job === void 0 ? void 0 : job.steps;
|
||||||
if (Array.isArray(steps)) {
|
if (Array.isArray(steps)) {
|
||||||
for (const step of steps) {
|
for (const step of steps) {
|
||||||
// this was advice that we used to give in the README
|
// this was advice that we used to give in the README
|
||||||
@@ -160,7 +175,7 @@ function getWorkflowErrors(doc) {
|
|||||||
// to produce results that are more inline with expectations
|
// to produce results that are more inline with expectations
|
||||||
// (i.e: this is what will happen if you merge this PR)
|
// (i.e: this is what will happen if you merge this PR)
|
||||||
// and avoid some race conditions
|
// and avoid some race conditions
|
||||||
if (((_d = step) === null || _d === void 0 ? void 0 : _d.run) === "git checkout HEAD^2") {
|
if ((step === null || step === void 0 ? void 0 : step.run) === "git checkout HEAD^2") {
|
||||||
errors.push(exports.WorkflowErrors.CheckoutWrongHead);
|
errors.push(exports.WorkflowErrors.CheckoutWrongHead);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -190,14 +205,14 @@ function getWorkflowErrors(doc) {
|
|||||||
missingPush = true;
|
missingPush = true;
|
||||||
}
|
}
|
||||||
if (hasPush && hasPullRequest) {
|
if (hasPush && hasPullRequest) {
|
||||||
const paths = (_e = doc.on.push) === null || _e === void 0 ? void 0 : _e.paths;
|
const paths = (_b = doc.on.push) === null || _b === void 0 ? void 0 : _b.paths;
|
||||||
// if you specify paths or paths-ignore you can end up with commits that have no baseline
|
// if you specify paths or paths-ignore you can end up with commits that have no baseline
|
||||||
// if they didn't change any files
|
// if they didn't change any files
|
||||||
// currently we cannot go back through the history and find the most recent baseline
|
// currently we cannot go back through the history and find the most recent baseline
|
||||||
if (Array.isArray(paths) && paths.length > 0) {
|
if (Array.isArray(paths) && paths.length > 0) {
|
||||||
errors.push(exports.WorkflowErrors.PathsSpecified);
|
errors.push(exports.WorkflowErrors.PathsSpecified);
|
||||||
}
|
}
|
||||||
const pathsIgnore = (_f = doc.on.push) === null || _f === void 0 ? void 0 : _f["paths-ignore"];
|
const pathsIgnore = (_c = doc.on.push) === null || _c === void 0 ? void 0 : _c["paths-ignore"];
|
||||||
if (Array.isArray(pathsIgnore) && pathsIgnore.length > 0) {
|
if (Array.isArray(pathsIgnore) && pathsIgnore.length > 0) {
|
||||||
errors.push(exports.WorkflowErrors.PathsIgnoreSpecified);
|
errors.push(exports.WorkflowErrors.PathsIgnoreSpecified);
|
||||||
}
|
}
|
||||||
@@ -206,9 +221,9 @@ function getWorkflowErrors(doc) {
|
|||||||
// if doc.on.pull_request is undefined that means 'off'
|
// if doc.on.pull_request is undefined that means 'off'
|
||||||
// we only want to check for mismatched branches if pull_request is on.
|
// we only want to check for mismatched branches if pull_request is on.
|
||||||
if (doc.on.pull_request !== undefined) {
|
if (doc.on.pull_request !== undefined) {
|
||||||
const push = branchesToArray((_g = doc.on.push) === null || _g === void 0 ? void 0 : _g.branches);
|
const push = branchesToArray((_d = doc.on.push) === null || _d === void 0 ? void 0 : _d.branches);
|
||||||
if (push !== "**") {
|
if (push !== "**") {
|
||||||
const pull_request = branchesToArray((_h = doc.on.pull_request) === null || _h === void 0 ? void 0 : _h.branches);
|
const pull_request = branchesToArray((_e = doc.on.pull_request) === null || _e === void 0 ? void 0 : _e.branches);
|
||||||
if (pull_request !== "**") {
|
if (pull_request !== "**") {
|
||||||
const difference = pull_request.filter((value) => !push.some((o) => patternIsSuperset(o, value)));
|
const difference = pull_request.filter((value) => !push.some((o) => patternIsSuperset(o, value)));
|
||||||
if (difference.length > 0) {
|
if (difference.length > 0) {
|
||||||
@@ -237,14 +252,14 @@ async function validateWorkflow() {
|
|||||||
workflow = await getWorkflow();
|
workflow = await getWorkflow();
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return `error: getWorkflow() failed: ${e.toString()}`;
|
return `error: getWorkflow() failed: ${String(e)}`;
|
||||||
}
|
}
|
||||||
let workflowErrors;
|
let workflowErrors;
|
||||||
try {
|
try {
|
||||||
workflowErrors = getWorkflowErrors(workflow);
|
workflowErrors = getWorkflowErrors(workflow);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return `error: getWorkflowErrors() failed: ${e.toString()}`;
|
return `error: getWorkflowErrors() failed: ${String(e)}`;
|
||||||
}
|
}
|
||||||
if (workflowErrors.length > 0) {
|
if (workflowErrors.length > 0) {
|
||||||
let message;
|
let message;
|
||||||
@@ -252,7 +267,7 @@ async function validateWorkflow() {
|
|||||||
message = formatWorkflowErrors(workflowErrors);
|
message = formatWorkflowErrors(workflowErrors);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
return `error: formatWorkflowErrors() failed: ${e.toString()}`;
|
return `error: formatWorkflowErrors() failed: ${String(e)}`;
|
||||||
}
|
}
|
||||||
core.warning(message);
|
core.warning(message);
|
||||||
}
|
}
|
||||||
@@ -274,18 +289,18 @@ function formatWorkflowCause(errors) {
|
|||||||
exports.formatWorkflowCause = formatWorkflowCause;
|
exports.formatWorkflowCause = formatWorkflowCause;
|
||||||
async function getWorkflow() {
|
async function getWorkflow() {
|
||||||
const relativePath = await getWorkflowPath();
|
const relativePath = await getWorkflowPath();
|
||||||
const absolutePath = path.join(util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), relativePath);
|
const absolutePath = path.join((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), relativePath);
|
||||||
return yaml.safeLoad(fs.readFileSync(absolutePath, "utf-8"));
|
return yaml.load(fs.readFileSync(absolutePath, "utf-8"));
|
||||||
}
|
}
|
||||||
exports.getWorkflow = getWorkflow;
|
exports.getWorkflow = getWorkflow;
|
||||||
/**
|
/**
|
||||||
* Get the path of the currently executing workflow.
|
* Get the path of the currently executing workflow.
|
||||||
*/
|
*/
|
||||||
async function getWorkflowPath() {
|
async function getWorkflowPath() {
|
||||||
const repo_nwo = util_1.getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
|
const repo_nwo = (0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY").split("/");
|
||||||
const owner = repo_nwo[0];
|
const owner = repo_nwo[0];
|
||||||
const repo = repo_nwo[1];
|
const repo = repo_nwo[1];
|
||||||
const run_id = Number(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", {
|
||||||
owner,
|
owner,
|
||||||
@@ -300,7 +315,7 @@ async function getWorkflowPath() {
|
|||||||
* Get the workflow run ID.
|
* Get the workflow run ID.
|
||||||
*/
|
*/
|
||||||
function getWorkflowRunID() {
|
function getWorkflowRunID() {
|
||||||
const workflowRunID = parseInt(util_1.getRequiredEnvParam("GITHUB_RUN_ID"), 10);
|
const workflowRunID = parseInt((0, util_1.getRequiredEnvParam)("GITHUB_RUN_ID"), 10);
|
||||||
if (Number.isNaN(workflowRunID)) {
|
if (Number.isNaN(workflowRunID)) {
|
||||||
throw new Error("GITHUB_RUN_ID must define a non NaN workflow run ID");
|
throw new Error("GITHUB_RUN_ID must define a non NaN workflow run ID");
|
||||||
}
|
}
|
||||||
@@ -321,7 +336,7 @@ async function getAnalysisKey() {
|
|||||||
return analysisKey;
|
return analysisKey;
|
||||||
}
|
}
|
||||||
const workflowPath = await getWorkflowPath();
|
const workflowPath = await getWorkflowPath();
|
||||||
const jobName = util_1.getRequiredEnvParam("GITHUB_JOB");
|
const jobName = (0, util_1.getRequiredEnvParam)("GITHUB_JOB");
|
||||||
analysisKey = `${workflowPath}:${jobName}`;
|
analysisKey = `${workflowPath}:${jobName}`;
|
||||||
core.exportVariable(analysisKeyEnvVar, analysisKey);
|
core.exportVariable(analysisKeyEnvVar, analysisKey);
|
||||||
return analysisKey;
|
return analysisKey;
|
||||||
@@ -358,8 +373,8 @@ 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 = util_1.getRequiredEnvParam("GITHUB_REF");
|
const ref = (0, util_1.getRequiredEnvParam)("GITHUB_REF");
|
||||||
const sha = util_1.getRequiredEnvParam("GITHUB_SHA");
|
const sha = (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
||||||
// 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
|
||||||
@@ -368,14 +383,14 @@ async function getRef() {
|
|||||||
if (!pull_ref_regex.test(ref)) {
|
if (!pull_ref_regex.test(ref)) {
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
const head = await exports.getCommitOid("HEAD");
|
const head = await (0, exports.getCommitOid)("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 exports.getCommitOid(ref.replace(/^refs\/pull\//, "refs/remotes/pull/"))) !==
|
(await (0, exports.getCommitOid)(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");
|
||||||
@@ -464,7 +479,7 @@ const INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the code sc
|
|||||||
async function sendStatusReport(statusReport) {
|
async function sendStatusReport(statusReport) {
|
||||||
const statusReportJSON = JSON.stringify(statusReport);
|
const statusReportJSON = JSON.stringify(statusReport);
|
||||||
core.debug(`Sending status report: ${statusReportJSON}`);
|
core.debug(`Sending status report: ${statusReportJSON}`);
|
||||||
const nwo = 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();
|
||||||
try {
|
try {
|
||||||
@@ -477,7 +492,7 @@ async function sendStatusReport(statusReport) {
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
if (util_1.isHTTPError(e)) {
|
if ((0, util_1.isHTTPError)(e)) {
|
||||||
switch (e.status) {
|
switch (e.status) {
|
||||||
case 403:
|
case 403:
|
||||||
if (workflowIsTriggeredByPushEvent() && isDependabotActor()) {
|
if (workflowIsTriggeredByPushEvent() && isDependabotActor()) {
|
||||||
@@ -497,7 +512,7 @@ async function sendStatusReport(statusReport) {
|
|||||||
// schema incompatibility when reporting status
|
// schema incompatibility when reporting status
|
||||||
// this means that this action version is no longer compatible with the API
|
// this means that this action version is no longer compatible with the API
|
||||||
// we still want to continue as it is likely the analysis endpoint will work
|
// we still want to continue as it is likely the analysis endpoint will work
|
||||||
if (util_1.getRequiredEnvParam("GITHUB_SERVER_URL") !== util_1.GITHUB_DOTCOM_URL) {
|
if ((0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL") !== util_1.GITHUB_DOTCOM_URL) {
|
||||||
core.debug(INCOMPATIBLE_MSG);
|
core.debug(INCOMPATIBLE_MSG);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -531,14 +546,14 @@ exports.isRunningLocalAction = isRunningLocalAction;
|
|||||||
// Get the location where the action is running from.
|
// Get the location where the action is running from.
|
||||||
// This can be used to get the actions name or tell if we're running a local action.
|
// This can be used to get the actions name or tell if we're running a local action.
|
||||||
function getRelativeScriptPath() {
|
function getRelativeScriptPath() {
|
||||||
const runnerTemp = util_1.getRequiredEnvParam("RUNNER_TEMP");
|
const runnerTemp = (0, util_1.getRequiredEnvParam)("RUNNER_TEMP");
|
||||||
const actionsDirectory = path.join(path.dirname(runnerTemp), "_actions");
|
const actionsDirectory = path.join(path.dirname(runnerTemp), "_actions");
|
||||||
return path.relative(actionsDirectory, __filename);
|
return path.relative(actionsDirectory, __filename);
|
||||||
}
|
}
|
||||||
exports.getRelativeScriptPath = getRelativeScriptPath;
|
exports.getRelativeScriptPath = getRelativeScriptPath;
|
||||||
// Reads the contents of GITHUB_EVENT_PATH as a JSON object
|
// Reads the contents of GITHUB_EVENT_PATH as a JSON object
|
||||||
function getWorkflowEvent() {
|
function getWorkflowEvent() {
|
||||||
const eventJsonFile = util_1.getRequiredEnvParam("GITHUB_EVENT_PATH");
|
const eventJsonFile = (0, util_1.getRequiredEnvParam)("GITHUB_EVENT_PATH");
|
||||||
try {
|
try {
|
||||||
return JSON.parse(fs.readFileSync(eventJsonFile, "utf-8"));
|
return JSON.parse(fs.readFileSync(eventJsonFile, "utf-8"));
|
||||||
}
|
}
|
||||||
@@ -549,15 +564,19 @@ function getWorkflowEvent() {
|
|||||||
// Is the version of the repository we are currently analyzing from the default branch,
|
// Is the version of the repository we are currently analyzing from the default branch,
|
||||||
// or alternatively from another branch or a pull request.
|
// or alternatively from another branch or a pull request.
|
||||||
async function isAnalyzingDefaultBranch() {
|
async function isAnalyzingDefaultBranch() {
|
||||||
var _a, _b;
|
var _a;
|
||||||
// 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.substr("refs/heads/".length)
|
||||||
: currentRef;
|
: currentRef;
|
||||||
const event = getWorkflowEvent();
|
const event = getWorkflowEvent();
|
||||||
const defaultBranch = (_b = (_a = event) === null || _a === void 0 ? void 0 : _a.repository) === null || _b === void 0 ? void 0 : _b.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
140
lib/actions-util.test.js
generated
140
lib/actions-util.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -14,52 +26,52 @@ const fs = __importStar(require("fs"));
|
|||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const actionsutil = __importStar(require("./actions-util"));
|
const actionsutil = __importStar(require("./actions-util"));
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
function errorCodes(actual, expected) {
|
function errorCodes(actual, expected) {
|
||||||
return [actual.map(({ code }) => code), expected.map(({ code }) => code)];
|
return [actual.map(({ code }) => code), expected.map(({ code }) => code)];
|
||||||
}
|
}
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
ava_1.default("getRef() throws on the empty string", async (t) => {
|
(0, ava_1.default)("getRef() throws on the empty string", async (t) => {
|
||||||
process.env["GITHUB_REF"] = "";
|
process.env["GITHUB_REF"] = "";
|
||||||
await t.throwsAsync(actionsutil.getRef);
|
await t.throwsAsync(actionsutil.getRef);
|
||||||
});
|
});
|
||||||
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";
|
const expectedRef = "refs/pull/1/merge";
|
||||||
const currentSha = "a".repeat(40);
|
const currentSha = "a".repeat(40);
|
||||||
process.env["GITHUB_REF"] = expectedRef;
|
process.env["GITHUB_REF"] = expectedRef;
|
||||||
process.env["GITHUB_SHA"] = currentSha;
|
process.env["GITHUB_SHA"] = currentSha;
|
||||||
const callback = sinon_1.default.stub(actionsutil, "getCommitOid");
|
const callback = sinon.stub(actionsutil, "getCommitOid");
|
||||||
callback.withArgs("HEAD").resolves(currentSha);
|
callback.withArgs("HEAD").resolves(currentSha);
|
||||||
const actualRef = await actionsutil.getRef();
|
const actualRef = await actionsutil.getRef();
|
||||||
t.deepEqual(actualRef, expectedRef);
|
t.deepEqual(actualRef, expectedRef);
|
||||||
callback.restore();
|
callback.restore();
|
||||||
});
|
});
|
||||||
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";
|
const expectedRef = "refs/pull/1/merge";
|
||||||
process.env["GITHUB_REF"] = expectedRef;
|
process.env["GITHUB_REF"] = expectedRef;
|
||||||
process.env["GITHUB_SHA"] = "b".repeat(40);
|
process.env["GITHUB_SHA"] = "b".repeat(40);
|
||||||
const sha = "a".repeat(40);
|
const sha = "a".repeat(40);
|
||||||
const callback = sinon_1.default.stub(actionsutil, "getCommitOid");
|
const callback = sinon.stub(actionsutil, "getCommitOid");
|
||||||
callback.withArgs("refs/remotes/pull/1/merge").resolves(sha);
|
callback.withArgs("refs/remotes/pull/1/merge").resolves(sha);
|
||||||
callback.withArgs("HEAD").resolves(sha);
|
callback.withArgs("HEAD").resolves(sha);
|
||||||
const actualRef = await actionsutil.getRef();
|
const actualRef = await actionsutil.getRef();
|
||||||
t.deepEqual(actualRef, expectedRef);
|
t.deepEqual(actualRef, expectedRef);
|
||||||
callback.restore();
|
callback.restore();
|
||||||
});
|
});
|
||||||
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";
|
process.env["GITHUB_REF"] = "refs/pull/1/merge";
|
||||||
process.env["GITHUB_SHA"] = "a".repeat(40);
|
process.env["GITHUB_SHA"] = "a".repeat(40);
|
||||||
const callback = sinon_1.default.stub(actionsutil, "getCommitOid");
|
const callback = sinon.stub(actionsutil, "getCommitOid");
|
||||||
callback.withArgs("refs/pull/1/merge").resolves("a".repeat(40));
|
callback.withArgs("refs/pull/1/merge").resolves("a".repeat(40));
|
||||||
callback.withArgs("HEAD").resolves("b".repeat(40));
|
callback.withArgs("HEAD").resolves("b".repeat(40));
|
||||||
const actualRef = await actionsutil.getRef();
|
const actualRef = await actionsutil.getRef();
|
||||||
t.deepEqual(actualRef, "refs/pull/1/head");
|
t.deepEqual(actualRef, "refs/pull/1/head");
|
||||||
callback.restore();
|
callback.restore();
|
||||||
});
|
});
|
||||||
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"}');
|
||||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/language:javascript/os:linux/");
|
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/language:javascript/os:linux/");
|
||||||
// check the environment sorting
|
// check the environment sorting
|
||||||
@@ -75,31 +87,31 @@ ava_1.default("computeAutomationID()", async (t) => {
|
|||||||
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", undefined);
|
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", undefined);
|
||||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/");
|
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/");
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on is empty", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on is empty", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({ on: {} });
|
const errors = actionsutil.getWorkflowErrors({ on: {} });
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is an array missing pull_request", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push is an array missing pull_request", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({ on: ["push"] });
|
const errors = actionsutil.getWorkflowErrors({ on: ["push"] });
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is an array missing push", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push is an array missing push", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({ on: ["pull_request"] });
|
const errors = actionsutil.getWorkflowErrors({ on: ["pull_request"] });
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MissingPushHook]));
|
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MissingPushHook]));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is valid", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push is valid", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: ["push", "pull_request"],
|
on: ["push", "pull_request"],
|
||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is a valid superset", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push is a valid superset", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: ["push", "pull_request", "schedule"],
|
on: ["push", "pull_request", "schedule"],
|
||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push should not have a path", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push should not have a path", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: {
|
on: {
|
||||||
push: { branches: ["main"], paths: ["test/*"] },
|
push: { branches: ["main"], paths: ["test/*"] },
|
||||||
@@ -108,33 +120,33 @@ ava_1.default("getWorkflowErrors() when on.push should not have a path", (t) =>
|
|||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.PathsSpecified]));
|
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.PathsSpecified]));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is a correct object", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push is a correct object", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: { push: { branches: ["main"] }, pull_request: { branches: ["main"] } },
|
on: { push: { branches: ["main"] }, pull_request: { branches: ["main"] } },
|
||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_requests is a string", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.pull_requests is a string", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: { push: { branches: ["main"] }, pull_request: { branches: "*" } },
|
on: { push: { branches: ["main"] }, pull_request: { branches: "*" } },
|
||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_requests is a string and correct", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.pull_requests is a string and correct", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: { push: { branches: "*" }, pull_request: { branches: "*" } },
|
on: { push: { branches: "*" }, pull_request: { branches: "*" } },
|
||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is correct with empty objects", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push is correct with empty objects", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
pull_request:
|
pull_request:
|
||||||
`));
|
`));
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is mismatched", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push is mismatched", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: {
|
on: {
|
||||||
push: { branches: ["main"] },
|
push: { branches: ["main"] },
|
||||||
@@ -143,7 +155,7 @@ ava_1.default("getWorkflowErrors() when on.push is mismatched", (t) => {
|
|||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is not mismatched", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push is not mismatched", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: {
|
on: {
|
||||||
push: { branches: ["main", "feature"] },
|
push: { branches: ["main", "feature"] },
|
||||||
@@ -152,7 +164,7 @@ ava_1.default("getWorkflowErrors() when on.push is not mismatched", (t) => {
|
|||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is mismatched for pull_request", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push is mismatched for pull_request", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: {
|
on: {
|
||||||
push: { branches: ["main"] },
|
push: { branches: ["main"] },
|
||||||
@@ -161,7 +173,7 @@ ava_1.default("getWorkflowErrors() when on.push is mismatched for pull_request",
|
|||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
||||||
on: {
|
on: {
|
||||||
push: 1,
|
push: 1,
|
||||||
@@ -215,8 +227,8 @@ ava_1.default("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
|||||||
},
|
},
|
||||||
}), []));
|
}), []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_request for every branch but push specifies branches", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.pull_request for every branch but push specifies branches", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -225,7 +237,7 @@ on:
|
|||||||
`));
|
`));
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_request for wildcard branches", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.pull_request for wildcard branches", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: {
|
on: {
|
||||||
push: { branches: ["feature/*"] },
|
push: { branches: ["feature/*"] },
|
||||||
@@ -234,7 +246,7 @@ ava_1.default("getWorkflowErrors() when on.pull_request for wildcard branches",
|
|||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_request for mismatched wildcard branches", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.pull_request for mismatched wildcard branches", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: {
|
on: {
|
||||||
push: { branches: ["feature/moose"] },
|
push: { branches: ["feature/moose"] },
|
||||||
@@ -243,7 +255,7 @@ ava_1.default("getWorkflowErrors() when on.pull_request for mismatched wildcard
|
|||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when HEAD^2 is checked out", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when HEAD^2 is checked out", (t) => {
|
||||||
process.env.GITHUB_JOB = "test";
|
process.env.GITHUB_JOB = "test";
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
const errors = actionsutil.getWorkflowErrors({
|
||||||
on: ["push", "pull_request"],
|
on: ["push", "pull_request"],
|
||||||
@@ -251,24 +263,24 @@ ava_1.default("getWorkflowErrors() when HEAD^2 is checked out", (t) => {
|
|||||||
});
|
});
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]));
|
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]));
|
||||||
});
|
});
|
||||||
ava_1.default("formatWorkflowErrors() when there is one error", (t) => {
|
(0, ava_1.default)("formatWorkflowErrors() when there is one error", (t) => {
|
||||||
const message = actionsutil.formatWorkflowErrors([
|
const message = actionsutil.formatWorkflowErrors([
|
||||||
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
||||||
]);
|
]);
|
||||||
t.true(message.startsWith("1 issue was detected with this workflow:"));
|
t.true(message.startsWith("1 issue was detected with this workflow:"));
|
||||||
});
|
});
|
||||||
ava_1.default("formatWorkflowErrors() when there are multiple errors", (t) => {
|
(0, ava_1.default)("formatWorkflowErrors() when there are multiple errors", (t) => {
|
||||||
const message = actionsutil.formatWorkflowErrors([
|
const message = actionsutil.formatWorkflowErrors([
|
||||||
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
||||||
actionsutil.WorkflowErrors.PathsSpecified,
|
actionsutil.WorkflowErrors.PathsSpecified,
|
||||||
]);
|
]);
|
||||||
t.true(message.startsWith("2 issues were detected with this workflow:"));
|
t.true(message.startsWith("2 issues were detected with this workflow:"));
|
||||||
});
|
});
|
||||||
ava_1.default("formatWorkflowCause() with no errors", (t) => {
|
(0, ava_1.default)("formatWorkflowCause() with no errors", (t) => {
|
||||||
const message = actionsutil.formatWorkflowCause([]);
|
const message = actionsutil.formatWorkflowCause([]);
|
||||||
t.deepEqual(message, undefined);
|
t.deepEqual(message, undefined);
|
||||||
});
|
});
|
||||||
ava_1.default("formatWorkflowCause()", (t) => {
|
(0, ava_1.default)("formatWorkflowCause()", (t) => {
|
||||||
const message = actionsutil.formatWorkflowCause([
|
const message = actionsutil.formatWorkflowCause([
|
||||||
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
||||||
actionsutil.WorkflowErrors.PathsSpecified,
|
actionsutil.WorkflowErrors.PathsSpecified,
|
||||||
@@ -276,7 +288,7 @@ ava_1.default("formatWorkflowCause()", (t) => {
|
|||||||
t.deepEqual(message, "CheckoutWrongHead,PathsSpecified");
|
t.deepEqual(message, "CheckoutWrongHead,PathsSpecified");
|
||||||
t.deepEqual(actionsutil.formatWorkflowCause([]), undefined);
|
t.deepEqual(actionsutil.formatWorkflowCause([]), undefined);
|
||||||
});
|
});
|
||||||
ava_1.default("patternIsSuperset()", (t) => {
|
(0, ava_1.default)("patternIsSuperset()", (t) => {
|
||||||
t.false(actionsutil.patternIsSuperset("main-*", "main"));
|
t.false(actionsutil.patternIsSuperset("main-*", "main"));
|
||||||
t.true(actionsutil.patternIsSuperset("*", "*"));
|
t.true(actionsutil.patternIsSuperset("*", "*"));
|
||||||
t.true(actionsutil.patternIsSuperset("*", "main-*"));
|
t.true(actionsutil.patternIsSuperset("*", "main-*"));
|
||||||
@@ -298,8 +310,8 @@ ava_1.default("patternIsSuperset()", (t) => {
|
|||||||
t.true(actionsutil.patternIsSuperset("/robin/*/release/*", "/robin/moose/release/goose"));
|
t.true(actionsutil.patternIsSuperset("/robin/*/release/*", "/robin/moose/release/goose"));
|
||||||
t.false(actionsutil.patternIsSuperset("/robin/moose/release/goose", "/robin/*/release/*"));
|
t.false(actionsutil.patternIsSuperset("/robin/moose/release/goose", "/robin/*/release/*"));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when branches contain dots", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [4.1, master]
|
branches: [4.1, master]
|
||||||
@@ -309,8 +321,8 @@ ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
|||||||
`));
|
`));
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push has a trailing comma", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on.push has a trailing comma", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -321,9 +333,9 @@ on:
|
|||||||
`));
|
`));
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() should only report the current job's CheckoutWrongHead", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() should only report the current job's CheckoutWrongHead", (t) => {
|
||||||
process.env.GITHUB_JOB = "test";
|
process.env.GITHUB_JOB = "test";
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -345,9 +357,9 @@ jobs:
|
|||||||
`));
|
`));
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]));
|
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() should not report a different job's CheckoutWrongHead", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() should not report a different job's CheckoutWrongHead", (t) => {
|
||||||
process.env.GITHUB_JOB = "test3";
|
process.env.GITHUB_JOB = "test3";
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -369,49 +381,49 @@ jobs:
|
|||||||
`));
|
`));
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on is missing", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() when on is missing", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
`));
|
`));
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() with a different on setup", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() with a different on setup", (t) => {
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on: "workflow_dispatch"
|
on: "workflow_dispatch"
|
||||||
`)), []));
|
`)), []));
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on: [workflow_dispatch]
|
on: [workflow_dispatch]
|
||||||
`)), []));
|
`)), []));
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
`)), []));
|
`)), []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() should not report an error if PRs are totally unconfigured", (t) => {
|
(0, ava_1.default)("getWorkflowErrors() should not report an error if PRs are totally unconfigured", (t) => {
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
`)), []));
|
`)), []));
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on: ["push"]
|
on: ["push"]
|
||||||
`)), []));
|
`)), []));
|
||||||
});
|
});
|
||||||
ava_1.default("initializeEnvironment", (t) => {
|
(0, ava_1.default)("initializeEnvironment", (t) => {
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
||||||
t.deepEqual(util_1.getMode(), util_1.Mode.actions);
|
t.deepEqual((0, util_1.getMode)(), util_1.Mode.actions);
|
||||||
t.deepEqual(process.env.CODEQL_ACTION_VERSION, "1.2.3");
|
t.deepEqual(process.env.CODEQL_ACTION_VERSION, "1.2.3");
|
||||||
util_1.initializeEnvironment(util_1.Mode.runner, "4.5.6");
|
(0, util_1.initializeEnvironment)(util_1.Mode.runner, "4.5.6");
|
||||||
t.deepEqual(util_1.getMode(), util_1.Mode.runner);
|
t.deepEqual((0, util_1.getMode)(), util_1.Mode.runner);
|
||||||
t.deepEqual(process.env.CODEQL_ACTION_VERSION, "4.5.6");
|
t.deepEqual(process.env.CODEQL_ACTION_VERSION, "4.5.6");
|
||||||
});
|
});
|
||||||
ava_1.default("isAnalyzingDefaultBranch()", async (t) => {
|
(0, ava_1.default)("isAnalyzingDefaultBranch()", async (t) => {
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (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: {
|
||||||
@@ -428,4 +440,10 @@ ava_1.default("isAnalyzingDefaultBranch()", async (t) => {
|
|||||||
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
21
lib/analysis-paths.js
generated
21
lib/analysis-paths.js
generated
@@ -1,12 +1,25 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.includeAndExcludeAnalysisPaths = exports.printPathFiltersWarning = exports.legalWindowsPathCharactersRegex = void 0;
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
function isInterpretedLanguage(language) {
|
function isInterpretedLanguage(language) {
|
||||||
return (language === "javascript" || language === "python" || language === "ruby");
|
return (language === "javascript" || language === "python" || language === "ruby");
|
||||||
@@ -24,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,QAAQ,KAAK,OAAO,EAAE;QAChC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,uCAA+B,CAAC,CAAC,CAAC;KACvE;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAA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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"}
|
||||||
33
lib/analysis-paths.test.js
generated
33
lib/analysis-paths.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -15,8 +27,8 @@ const ava_1 = __importDefault(require("ava"));
|
|||||||
const analysisPaths = __importStar(require("./analysis-paths"));
|
const analysisPaths = __importStar(require("./analysis-paths"));
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
ava_1.default("emptyPaths", async (t) => {
|
(0, ava_1.default)("emptyPaths", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const config = {
|
const config = {
|
||||||
languages: [],
|
languages: [],
|
||||||
@@ -30,6 +42,9 @@ ava_1.default("emptyPaths", async (t) => {
|
|||||||
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,
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||||
@@ -37,7 +52,7 @@ ava_1.default("emptyPaths", async (t) => {
|
|||||||
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
|
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("nonEmptyPaths", async (t) => {
|
(0, ava_1.default)("nonEmptyPaths", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const config = {
|
const config = {
|
||||||
languages: [],
|
languages: [],
|
||||||
@@ -51,6 +66,9 @@ ava_1.default("nonEmptyPaths", async (t) => {
|
|||||||
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,
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
||||||
@@ -58,7 +76,7 @@ ava_1.default("nonEmptyPaths", async (t) => {
|
|||||||
t.is(process.env["LGTM_INDEX_FILTERS"], "include:path1\ninclude:path2\ninclude:**/path3\nexclude:path4\nexclude:path5\nexclude:path6/**");
|
t.is(process.env["LGTM_INDEX_FILTERS"], "include:path1\ninclude:path2\ninclude:**/path3\nexclude:path4\nexclude:path5\nexclude:path6/**");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("exclude temp dir", async (t) => {
|
(0, ava_1.default)("exclude temp dir", async (t) => {
|
||||||
return await util.withTmpDir(async (toolCacheDir) => {
|
return await util.withTmpDir(async (toolCacheDir) => {
|
||||||
const tempDir = path.join(process.cwd(), "codeql-runner-temp");
|
const tempDir = path.join(process.cwd(), "codeql-runner-temp");
|
||||||
const config = {
|
const config = {
|
||||||
@@ -73,6 +91,9 @@ ava_1.default("exclude temp dir", async (t) => {
|
|||||||
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,
|
||||||
};
|
};
|
||||||
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,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,YAAY,EAAE,KAAK,EAAE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AC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
77
lib/analyze-action-env.test.js
generated
Normal file
77
lib/analyze-action-env.test.js
generated
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
"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: [],
|
||||||
|
});
|
||||||
|
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,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,8DAA8D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC/E,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;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,QAA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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"}
|
||||||
77
lib/analyze-action-input.test.js
generated
Normal file
77
lib/analyze-action-input.test.js
generated
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
"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: [],
|
||||||
|
});
|
||||||
|
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,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QACpC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;QAEnC,4DAA4D;QAC5D,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpD,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
129
lib/analyze-action.js
generated
129
lib/analyze-action.js
generated
@@ -1,40 +1,57 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, 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");
|
||||||
|
const codeql_1 = require("./codeql");
|
||||||
const config_utils_1 = require("./config-utils");
|
const config_utils_1 = require("./config-utils");
|
||||||
const database_upload_1 = require("./database-upload");
|
const database_upload_1 = require("./database-upload");
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const logging_1 = require("./logging");
|
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, stats, error) {
|
||||||
var _a, _b, _c;
|
const status = (stats === null || stats === void 0 ? void 0 : stats.analyze_failure_language) !== undefined || error !== undefined
|
||||||
const status = ((_a = stats) === null || _a === void 0 ? void 0 : _a.analyze_failure_language) !== undefined || error !== undefined
|
|
||||||
? "failure"
|
? "failure"
|
||||||
: "success";
|
: "success";
|
||||||
const statusReportBase = await actionsUtil.createStatusReportBase("finish", status, startedAt, (_b = error) === null || _b === void 0 ? void 0 : _b.message, (_c = error) === null || _c === void 0 ? void 0 : _c.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,
|
||||||
...(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);
|
||||||
@@ -42,23 +59,53 @@ async function run() {
|
|||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const logger = logging_1.getActionsLogger();
|
const logger = (0, logging_1.getActionsLogger)();
|
||||||
config = await config_utils_1.getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
||||||
}
|
}
|
||||||
|
await util.enrichEnvironment(util.Mode.actions, await (0, codeql_1.getCodeQL)(config.codeQLCmd));
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
auth: actionsUtil.getRequiredInput("token"),
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
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);
|
||||||
await analyze_1.runFinalize(outputDir, threads, config, logger);
|
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
||||||
|
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags(config.gitHubVersion, apiDetails, repositoryNwo, logger);
|
||||||
|
// We currently perform an API request in both the `init` and `analyze` Actions to determine
|
||||||
|
// what feature flags are enabled. At the time of writing, this redundant API call is acceptable
|
||||||
|
// to us, but if we wanted to avoid it, we could do so by serializing the feature flags as part
|
||||||
|
// of the config file.
|
||||||
|
void featureFlags.preloadFeatureFlags();
|
||||||
|
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
||||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||||
runStats = await analyze_1.runQueries(outputDir, util.getMemoryFlag(actionsUtil.getOptionalInput("ram")), 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 analyze_1.runCleanup(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
||||||
}
|
}
|
||||||
const dbLocations = {};
|
const dbLocations = {};
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
@@ -66,15 +113,20 @@ 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);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
}
|
}
|
||||||
const repositoryNwo = repository_1.parseRepositoryNwo(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
// Possibly upload the database bundles for remote queries
|
||||||
await database_upload_1.uploadDatabases(repositoryNwo, config, apiDetails, logger);
|
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, featureFlags, 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 (error) {
|
catch (origError) {
|
||||||
|
const error = origError instanceof Error ? origError : new Error(String(origError));
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
console.log(error);
|
console.log(error);
|
||||||
if (error instanceof analyze_1.CodeQLAnalysisError) {
|
if (error instanceof analyze_1.CodeQLAnalysisError) {
|
||||||
@@ -87,6 +139,19 @@ async function run() {
|
|||||||
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) {
|
||||||
@@ -109,8 +174,11 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (runStats && uploadStats) {
|
if (runStats && uploadResult) {
|
||||||
await sendStatusReport(startedAt, { ...runStats, ...uploadStats });
|
await sendStatusReport(startedAt, {
|
||||||
|
...runStats,
|
||||||
|
...uploadResult.statusReport,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (runStats) {
|
else if (runStats) {
|
||||||
await sendStatusReport(startedAt, { ...runStats });
|
await sendStatusReport(startedAt, { ...runStats });
|
||||||
@@ -119,9 +187,32 @@ async function run() {
|
|||||||
await sendStatusReport(startedAt, undefined);
|
await sendStatusReport(startedAt, 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
102
lib/analyze.js
generated
102
lib/analyze.js
generated
@@ -1,12 +1,25 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.runCleanup = exports.runFinalize = exports.runQueries = exports.CodeQLAnalysisError = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
@@ -54,9 +67,9 @@ async function createdDBForScannedLanguages(config, logger) {
|
|||||||
// Insert the LGTM_INDEX_X env vars at this point so they are set when
|
// Insert the LGTM_INDEX_X env vars at this point so they are set when
|
||||||
// we extract any scanned languages.
|
// we extract any scanned languages.
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
const codeql = 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) {
|
||||||
if (languages_1.isScannedLanguage(language) &&
|
if ((0, languages_1.isScannedLanguage)(language) &&
|
||||||
!dbIsFinalized(config, language, logger)) {
|
!dbIsFinalized(config, language, logger)) {
|
||||||
logger.startGroup(`Extracting ${language}`);
|
logger.startGroup(`Extracting ${language}`);
|
||||||
if (language === languages_1.Language.python) {
|
if (language === languages_1.Language.python) {
|
||||||
@@ -78,35 +91,41 @@ function dbIsFinalized(config, language, logger) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function finalizeDatabaseCreation(config, threadsFlag, logger) {
|
async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger) {
|
||||||
await createdDBForScannedLanguages(config, logger);
|
await createdDBForScannedLanguages(config, logger);
|
||||||
const codeql = 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) {
|
||||||
if (dbIsFinalized(config, language, logger)) {
|
if (dbIsFinalized(config, language, logger)) {
|
||||||
logger.info(`There is already a finalized database for ${language} at the location where the CodeQL Action places databases, so we did not create one.`);
|
logger.info(`There is already a finalized database for ${language} at the location where the CodeQL Action places databases, so we did not create one.`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.startGroup(`Finalizing ${language}`);
|
logger.startGroup(`Finalizing ${language}`);
|
||||||
await codeql.finalizeDatabase(util.getCodeQLDatabasePath(config, language), threadsFlag);
|
await codeql.finalizeDatabase(util.getCodeQLDatabasePath(config, language), threadsFlag, memoryFlag);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Runs queries and creates sarif files in the given folder
|
// Runs queries and creates sarif files in the given folder
|
||||||
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger) {
|
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger) {
|
||||||
var _a, _b;
|
|
||||||
const statusReport = {};
|
const statusReport = {};
|
||||||
// count the number of lines in the background
|
let locPromise = Promise.resolve({});
|
||||||
const locPromise = count_loc_1.countLoc(path.resolve(),
|
const cliCanCountBaseline = await cliCanCountLoC();
|
||||||
// config.paths specifies external directories. the current
|
const debugMode = process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] ||
|
||||||
// directory is included in the analysis by default. Replicate
|
process.env["ACTIONS_RUNNER_DEBUG"] ||
|
||||||
// that here.
|
process.env["ACTIONS_STEP_DEBUG"];
|
||||||
config.paths, config.pathsIgnore, config.languages, logger);
|
if (!cliCanCountBaseline || debugMode) {
|
||||||
|
// count the number of lines in the background
|
||||||
|
locPromise = (0, count_loc_1.countLoc)(path.resolve(),
|
||||||
|
// config.paths specifies external directories. the current
|
||||||
|
// directory is included in the analysis by default. Replicate
|
||||||
|
// that here.
|
||||||
|
config.paths, config.pathsIgnore, config.languages, logger);
|
||||||
|
}
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
const queries = config.queries[language];
|
const queries = config.queries[language];
|
||||||
const packsWithVersion = config.packs[language] || [];
|
const packsWithVersion = config.packs[language] || [];
|
||||||
const hasBuiltinQueries = ((_a = queries) === null || _a === void 0 ? void 0 : _a.builtin.length) > 0;
|
const hasBuiltinQueries = (queries === null || queries === void 0 ? void 0 : queries.builtin.length) > 0;
|
||||||
const hasCustomQueries = ((_b = queries) === null || _b === void 0 ? void 0 : _b.custom.length) > 0;
|
const hasCustomQueries = (queries === null || queries === void 0 ? void 0 : queries.custom.length) > 0;
|
||||||
const hasPackWithCustomQueries = packsWithVersion.length > 0;
|
const hasPackWithCustomQueries = packsWithVersion.length > 0;
|
||||||
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`);
|
||||||
@@ -118,7 +137,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
logger.info("And should not be used in production yet.");
|
logger.info("And should not be used in production yet.");
|
||||||
logger.info("*************");
|
logger.info("*************");
|
||||||
logger.startGroup(`Downloading custom packs for ${language}`);
|
logger.startGroup(`Downloading custom packs for ${language}`);
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
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"}`)
|
||||||
@@ -154,16 +173,22 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
const startTimeInterpretResults = new Date().getTime();
|
const startTimeInterpretResults = new Date().getTime();
|
||||||
const sarifFile = path.join(sarifFolder, `${language}.sarif`);
|
const sarifFile = path.join(sarifFolder, `${language}.sarif`);
|
||||||
const analysisSummary = await runInterpretResults(language, querySuitePaths, sarifFile);
|
const analysisSummary = await runInterpretResults(language, querySuitePaths, sarifFile);
|
||||||
await injectLinesOfCode(sarifFile, language, locPromise);
|
if (!cliCanCountBaseline)
|
||||||
|
await injectLinesOfCode(sarifFile, language, locPromise);
|
||||||
statusReport[`interpret_results_${language}_duration_ms`] =
|
statusReport[`interpret_results_${language}_duration_ms`] =
|
||||||
new Date().getTime() - startTimeInterpretResults;
|
new Date().getTime() - startTimeInterpretResults;
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
logger.info(analysisSummary);
|
logger.info(analysisSummary);
|
||||||
printLinesOfCodeSummary(logger, language, await locPromise);
|
if (!cliCanCountBaseline || debugMode)
|
||||||
|
printLinesOfCodeSummary(logger, language, await locPromise);
|
||||||
|
if (cliCanCountBaseline)
|
||||||
|
logger.info(await runPrintLinesOfCode(language));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.info(e);
|
logger.info(String(e));
|
||||||
logger.info(e.stack);
|
if (e instanceof Error) {
|
||||||
|
logger.info(e.stack);
|
||||||
|
}
|
||||||
statusReport.analyze_failure_language = language;
|
statusReport.analyze_failure_language = language;
|
||||||
throw new CodeQLAnalysisError(statusReport, `Error running analysis for ${language}: ${e}`);
|
throw new CodeQLAnalysisError(statusReport, `Error running analysis for ${language}: ${e}`);
|
||||||
}
|
}
|
||||||
@@ -171,9 +196,17 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
return statusReport;
|
return statusReport;
|
||||||
async function runInterpretResults(language, queries, sarifFile) {
|
async function runInterpretResults(language, queries, sarifFile) {
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, automationDetailsId);
|
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, automationDetailsId);
|
||||||
}
|
}
|
||||||
|
async function cliCanCountLoC() {
|
||||||
|
return await util.codeQlVersionAbove(await (0, codeql_1.getCodeQL)(config.codeQLCmd), codeql_1.CODEQL_VERSION_COUNTS_LINES);
|
||||||
|
}
|
||||||
|
async function runPrintLinesOfCode(language) {
|
||||||
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
|
return await codeql.databasePrintBaseline(databasePath);
|
||||||
|
}
|
||||||
async function runQueryGroup(language, type, querySuiteContents, searchPath) {
|
async function runQueryGroup(language, type, querySuiteContents, searchPath) {
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
// Pass the queries to codeql using a file instead of using the command
|
// Pass the queries to codeql using a file instead of using the command
|
||||||
@@ -181,7 +214,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
const querySuitePath = `${databasePath}-queries-${type}.qls`;
|
const querySuitePath = `${databasePath}-queries-${type}.qls`;
|
||||||
fs.writeFileSync(querySuitePath, querySuiteContents);
|
fs.writeFileSync(querySuitePath, querySuiteContents);
|
||||||
logger.debug(`Query suite file for ${language}-${type}...\n${querySuiteContents}`);
|
logger.debug(`Query suite file for ${language}-${type}...\n${querySuiteContents}`);
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
await codeql.databaseRunQueries(databasePath, searchPath, querySuitePath, memoryFlag, threadsFlag);
|
await codeql.databaseRunQueries(databasePath, searchPath, querySuitePath, memoryFlag, threadsFlag);
|
||||||
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
|
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
|
||||||
return querySuitePath;
|
return querySuitePath;
|
||||||
@@ -201,17 +234,17 @@ function packWithVersionToQuerySuiteEntry(pack) {
|
|||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
async function runFinalize(outputDir, threadsFlag, config, logger) {
|
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
||||||
// Delete the tracer config env var to avoid tracing ourselves
|
// Delete the tracer config env var to avoid tracing ourselves
|
||||||
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
||||||
fs.mkdirSync(outputDir, { recursive: true });
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
await finalizeDatabaseCreation(config, threadsFlag, logger);
|
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger);
|
||||||
}
|
}
|
||||||
exports.runFinalize = runFinalize;
|
exports.runFinalize = runFinalize;
|
||||||
async function runCleanup(config, cleanupLevel, logger) {
|
async function runCleanup(config, cleanupLevel, logger) {
|
||||||
logger.startGroup("Cleaning up databases");
|
logger.startGroup("Cleaning up databases");
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
await codeql.databaseCleanup(databasePath, cleanupLevel);
|
await codeql.databaseCleanup(databasePath, cleanupLevel);
|
||||||
}
|
}
|
||||||
@@ -219,21 +252,22 @@ async function runCleanup(config, cleanupLevel, logger) {
|
|||||||
}
|
}
|
||||||
exports.runCleanup = runCleanup;
|
exports.runCleanup = runCleanup;
|
||||||
async function injectLinesOfCode(sarifFile, language, locPromise) {
|
async function injectLinesOfCode(sarifFile, language, locPromise) {
|
||||||
|
var _a;
|
||||||
const lineCounts = await locPromise;
|
const lineCounts = await locPromise;
|
||||||
const idPrefix = count_loc_1.getIdPrefix(language);
|
|
||||||
if (language in lineCounts) {
|
if (language in lineCounts) {
|
||||||
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
||||||
if (Array.isArray(sarif.runs)) {
|
if (Array.isArray(sarif.runs)) {
|
||||||
for (const run of sarif.runs) {
|
for (const run of sarif.runs) {
|
||||||
const ruleId = `${idPrefix}/summary/lines-of-code`;
|
|
||||||
run.properties = run.properties || {};
|
run.properties = run.properties || {};
|
||||||
run.properties.metricResults = run.properties.metricResults || [];
|
run.properties.metricResults = run.properties.metricResults || [];
|
||||||
const rule = run.properties.metricResults.find(
|
for (const metric of run.properties.metricResults) {
|
||||||
// the rule id can be in either of two places
|
// Baseline is inserted when matching rule has tag lines-of-code
|
||||||
(r) => { var _a; return r.ruleId === ruleId || ((_a = r.rule) === null || _a === void 0 ? void 0 : _a.id) === ruleId; });
|
if (metric.rule && metric.rule.toolComponent) {
|
||||||
// only add the baseline value if the rule already exists
|
const matchingRule = run.tool.extensions[metric.rule.toolComponent.index].rules[metric.rule.index];
|
||||||
if (rule) {
|
if ((_a = matchingRule.properties.tags) === null || _a === void 0 ? void 0 : _a.includes("lines-of-code")) {
|
||||||
rule.baseline = lineCounts[language];
|
metric.baseline = lineCounts[language];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
84
lib/analyze.test.js
generated
84
lib/analyze.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -15,29 +27,28 @@ const path = __importStar(require("path"));
|
|||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
const semver_1 = require("semver");
|
const semver_1 = require("semver");
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const count_loc_1 = require("./count-loc");
|
|
||||||
const count = __importStar(require("./count-loc"));
|
const count = __importStar(require("./count-loc"));
|
||||||
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");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
// Checks that the duration fields are populated for the correct language
|
// Checks that the duration fields are populated for the correct language
|
||||||
// and correct case of builtin or custom. Also checks the correct search
|
// and correct case of builtin or custom. Also checks the correct search
|
||||||
// paths are set in the database analyze invocation.
|
// paths are set in the database analyze invocation.
|
||||||
ava_1.default("status report fields and search path setting", async (t) => {
|
(0, ava_1.default)("status report fields and search path setting", async (t) => {
|
||||||
const mockLinesOfCode = Object.values(languages_1.Language).reduce((obj, lang, i) => {
|
const mockLinesOfCode = Object.values(languages_1.Language).reduce((obj, lang, i) => {
|
||||||
// use a different line count for each language
|
// use a different line count for each language
|
||||||
obj[lang] = i + 1;
|
obj[lang] = i + 1;
|
||||||
return obj;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
sinon_1.default.stub(count, "countLoc").resolves(mockLinesOfCode);
|
sinon.stub(count, "countLoc").resolves(mockLinesOfCode);
|
||||||
let searchPathsUsed = [];
|
let searchPathsUsed = [];
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
const memoryFlag = "";
|
const memoryFlag = "";
|
||||||
const addSnippetsFlag = "";
|
const addSnippetsFlag = "";
|
||||||
const threadsFlag = "";
|
const threadsFlag = "";
|
||||||
@@ -45,18 +56,18 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
{
|
{
|
||||||
packName: "a/b",
|
packName: "a/b",
|
||||||
version: semver_1.clean("1.0.0"),
|
version: (0, semver_1.clean)("1.0.0"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[languages_1.Language.java]: [
|
[languages_1.Language.java]: [
|
||||||
{
|
{
|
||||||
packName: "c/d",
|
packName: "c/d",
|
||||||
version: semver_1.clean("2.0.0"),
|
version: (0, semver_1.clean)("2.0.0"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
for (const language of Object.values(languages_1.Language)) {
|
for (const language of Object.values(languages_1.Language)) {
|
||||||
codeql_1.setCodeQL({
|
(0, codeql_1.setCodeQL)({
|
||||||
packDownload: async () => ({ packs: [] }),
|
packDownload: async () => ({ packs: [] }),
|
||||||
databaseRunQueries: async (_db, searchPath) => {
|
databaseRunQueries: async (_db, searchPath) => {
|
||||||
searchPathsUsed.push(searchPath);
|
searchPathsUsed.push(searchPath);
|
||||||
@@ -64,24 +75,29 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
databaseInterpretResults: async (_db, _queriesRun, sarifFile) => {
|
databaseInterpretResults: async (_db, _queriesRun, sarifFile) => {
|
||||||
fs.writeFileSync(sarifFile, JSON.stringify({
|
fs.writeFileSync(sarifFile, JSON.stringify({
|
||||||
runs: [
|
runs: [
|
||||||
// variant 1 uses ruleId
|
// references a rule with the lines-of-code tag, so baseline should be injected
|
||||||
{
|
{
|
||||||
properties: {
|
tool: {
|
||||||
metricResults: [
|
extensions: [
|
||||||
{
|
{
|
||||||
ruleId: `${count_loc_1.getIdPrefix(language)}/summary/lines-of-code`,
|
rules: [
|
||||||
value: 123,
|
{
|
||||||
|
properties: {
|
||||||
|
tags: ["lines-of-code"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
|
||||||
// variant 2 uses rule.id
|
|
||||||
{
|
|
||||||
properties: {
|
properties: {
|
||||||
metricResults: [
|
metricResults: [
|
||||||
{
|
{
|
||||||
rule: {
|
rule: {
|
||||||
id: `${count_loc_1.getIdPrefix(language)}/summary/lines-of-code`,
|
index: 0,
|
||||||
|
toolComponent: {
|
||||||
|
index: 0,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
value: 123,
|
value: 123,
|
||||||
},
|
},
|
||||||
@@ -109,6 +125,9 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
},
|
},
|
||||||
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,
|
||||||
};
|
};
|
||||||
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -117,7 +136,7 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
builtin: ["foo.ql"],
|
builtin: ["foo.ql"],
|
||||||
custom: [],
|
custom: [],
|
||||||
};
|
};
|
||||||
const builtinStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, logging_1.getRunnerLogger(true));
|
const builtinStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true));
|
||||||
const hasPacks = language in packs;
|
const hasPacks = language in packs;
|
||||||
const statusReportKeys = Object.keys(builtinStatusReport).sort();
|
const statusReportKeys = Object.keys(builtinStatusReport).sort();
|
||||||
if (hasPacks) {
|
if (hasPacks) {
|
||||||
@@ -143,7 +162,7 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
const customStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, logging_1.getRunnerLogger(true));
|
const customStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(Object.keys(customStatusReport).length, 2);
|
t.deepEqual(Object.keys(customStatusReport).length, 2);
|
||||||
t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport);
|
t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport);
|
||||||
const expectedSearchPathsUsed = hasPacks
|
const expectedSearchPathsUsed = hasPacks
|
||||||
@@ -158,30 +177,25 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
function verifyLineCounts(tmpDir) {
|
function verifyLineCounts(tmpDir) {
|
||||||
// eslint-disable-next-line github/array-foreach
|
// eslint-disable-next-line github/array-foreach
|
||||||
Object.keys(languages_1.Language).forEach((lang, i) => {
|
Object.keys(languages_1.Language).forEach((lang, i) => {
|
||||||
verifyLineCountForFile(lang, path.join(tmpDir, `${lang}.sarif`), i + 1);
|
verifyLineCountForFile(path.join(tmpDir, `${lang}.sarif`), i + 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function verifyLineCountForFile(lang, filePath, lineCount) {
|
function verifyLineCountForFile(filePath, lineCount) {
|
||||||
const idPrefix = count_loc_1.getIdPrefix(lang);
|
|
||||||
const sarif = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
const sarif = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||||
t.deepEqual(sarif.runs[0].properties.metricResults, [
|
t.deepEqual(sarif.runs[0].properties.metricResults, [
|
||||||
{
|
|
||||||
ruleId: `${idPrefix}/summary/lines-of-code`,
|
|
||||||
value: 123,
|
|
||||||
baseline: lineCount,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
t.deepEqual(sarif.runs[1].properties.metricResults, [
|
|
||||||
{
|
{
|
||||||
rule: {
|
rule: {
|
||||||
id: `${idPrefix}/summary/lines-of-code`,
|
index: 0,
|
||||||
|
toolComponent: {
|
||||||
|
index: 0,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
value: 123,
|
value: 123,
|
||||||
baseline: lineCount,
|
baseline: lineCount,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
// when the rule doesn't exist, it should not be added
|
// when the rule doesn't exist, it should not be added
|
||||||
t.deepEqual(sarif.runs[2].properties.metricResults, []);
|
t.deepEqual(sarif.runs[1].properties.metricResults, []);
|
||||||
}
|
}
|
||||||
function verifyQuerySuites(tmpDir) {
|
function verifyQuerySuites(tmpDir) {
|
||||||
const qlsContent = [
|
const qlsContent = [
|
||||||
@@ -224,7 +238,7 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
function readContents(name) {
|
function readContents(name) {
|
||||||
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
|
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
|
||||||
console.log(x);
|
console.log(x);
|
||||||
return yaml.safeLoad(fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8"));
|
return yaml.load(fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
30
lib/api-client.js
generated
30
lib/api-client.js
generated
@@ -1,15 +1,28 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
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;
|
||||||
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"));
|
||||||
@@ -23,15 +36,16 @@ var DisallowedAPIVersionReason;
|
|||||||
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_OLD"] = 0] = "ACTION_TOO_OLD";
|
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_OLD"] = 0] = "ACTION_TOO_OLD";
|
||||||
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_NEW"] = 1] = "ACTION_TOO_NEW";
|
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_NEW"] = 1] = "ACTION_TOO_NEW";
|
||||||
})(DisallowedAPIVersionReason = exports.DisallowedAPIVersionReason || (exports.DisallowedAPIVersionReason = {}));
|
})(DisallowedAPIVersionReason = exports.DisallowedAPIVersionReason || (exports.DisallowedAPIVersionReason = {}));
|
||||||
exports.getApiClient = function (apiDetails, { allowExternal = false } = {}) {
|
const getApiClient = function (apiDetails, { allowExternal = false } = {}) {
|
||||||
const auth = (allowExternal && apiDetails.externalRepoAuth) || apiDetails.auth;
|
const auth = (allowExternal && apiDetails.externalRepoAuth) || apiDetails.auth;
|
||||||
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
|
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
|
||||||
return new retryingOctokit(githubUtils.getOctokitOptions(auth, {
|
return new retryingOctokit(githubUtils.getOctokitOptions(auth, {
|
||||||
baseUrl: getApiUrl(apiDetails.url),
|
baseUrl: getApiUrl(apiDetails.url),
|
||||||
userAgent: `CodeQL-${util_1.getMode()}/${pkg.version}`,
|
userAgent: `CodeQL-${(0, util_1.getMode)()}/${pkg.version}`,
|
||||||
log: console_log_level_1.default({ level: "debug" }),
|
log: (0, console_log_level_1.default)({ level: "debug" }),
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
exports.getApiClient = getApiClient;
|
||||||
function getApiUrl(githubUrl) {
|
function getApiUrl(githubUrl) {
|
||||||
const url = new URL(githubUrl);
|
const url = new URL(githubUrl);
|
||||||
// If we detect this is trying to connect to github.com
|
// If we detect this is trying to connect to github.com
|
||||||
@@ -48,10 +62,10 @@ function getApiUrl(githubUrl) {
|
|||||||
// and called only from the action entrypoints.
|
// and called only from the action entrypoints.
|
||||||
function getActionsApiClient() {
|
function getActionsApiClient() {
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
auth: actions_util_1.getRequiredInput("token"),
|
auth: (0, actions_util_1.getRequiredInput)("token"),
|
||||||
url: util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
return exports.getApiClient(apiDetails);
|
return (0, exports.getApiClient)(apiDetails);
|
||||||
}
|
}
|
||||||
exports.getActionsApiClient = getActionsApiClient;
|
exports.getActionsApiClient = getActionsApiClient;
|
||||||
//# 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,+FAA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E/B,uDAAuD;IACvD,0CAA0C;IAC1C,IAAI,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,GAAG,CAAC,QAAQ,KAAK,gBAAgB,EAAE;QACtE,OAAO,wBAAwB,CAAC;KACjC;IAED,6BAA6B;IAC7B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACpD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,uFAAuF;AACvF,qFAAqF;AACrF,+CAA+C;AAC/C,SAAgB,mBAAmB;IACjC,MAAM,UAAU,GAAG;QACjB,IAAI,EAAE,IAAA,+BAAgB,EAAC,OAAO,CAAC;QAC/B,GAAG,EAAE,IAAA,0BAAmB,EAAC,mBAAmB,CAAC;KAC9C,CAAC;IAEF,OAAO,IAAA,oBAAY,EAAC,UAAU,CAAC,CAAC;AAClC,CAAC;AAPD,kDAOC"}
|
||||||
36
lib/api-client.test.js
generated
36
lib/api-client.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -12,22 +24,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const githubUtils = __importStar(require("@actions/github/lib/utils"));
|
const githubUtils = __importStar(require("@actions/github/lib/utils"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
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");
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
let pluginStub;
|
let pluginStub;
|
||||||
let githubStub;
|
let githubStub;
|
||||||
ava_1.default.beforeEach(() => {
|
ava_1.default.beforeEach(() => {
|
||||||
pluginStub = sinon_1.default.stub(githubUtils.GitHub, "plugin");
|
pluginStub = sinon.stub(githubUtils.GitHub, "plugin");
|
||||||
githubStub = sinon_1.default.stub();
|
githubStub = sinon.stub();
|
||||||
pluginStub.returns(githubStub);
|
pluginStub.returns(githubStub);
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, pkg.version);
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
||||||
});
|
});
|
||||||
ava_1.default("Get the client API", async (t) => {
|
(0, ava_1.default)("Get the client API", async (t) => {
|
||||||
doTest(t, {
|
doTest(t, {
|
||||||
auth: "xyz",
|
auth: "xyz",
|
||||||
externalRepoAuth: "abc",
|
externalRepoAuth: "abc",
|
||||||
@@ -38,7 +50,7 @@ ava_1.default("Get the client API", async (t) => {
|
|||||||
userAgent: `CodeQL-Action/${pkg.version}`,
|
userAgent: `CodeQL-Action/${pkg.version}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Get the client API external", async (t) => {
|
(0, ava_1.default)("Get the client API external", async (t) => {
|
||||||
doTest(t, {
|
doTest(t, {
|
||||||
auth: "xyz",
|
auth: "xyz",
|
||||||
externalRepoAuth: "abc",
|
externalRepoAuth: "abc",
|
||||||
@@ -49,7 +61,7 @@ ava_1.default("Get the client API external", async (t) => {
|
|||||||
userAgent: `CodeQL-Action/${pkg.version}`,
|
userAgent: `CodeQL-Action/${pkg.version}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Get the client API external not present", async (t) => {
|
(0, ava_1.default)("Get the client API external not present", async (t) => {
|
||||||
doTest(t, {
|
doTest(t, {
|
||||||
auth: "xyz",
|
auth: "xyz",
|
||||||
url: "http://hucairz",
|
url: "http://hucairz",
|
||||||
@@ -59,7 +71,7 @@ ava_1.default("Get the client API external not present", async (t) => {
|
|||||||
userAgent: `CodeQL-Action/${pkg.version}`,
|
userAgent: `CodeQL-Action/${pkg.version}`,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Get the client API with github url", async (t) => {
|
(0, ava_1.default)("Get the client API with github url", async (t) => {
|
||||||
doTest(t, {
|
doTest(t, {
|
||||||
auth: "xyz",
|
auth: "xyz",
|
||||||
url: "https://github.com/some/invalid/url",
|
url: "https://github.com/some/invalid/url",
|
||||||
@@ -70,7 +82,7 @@ ava_1.default("Get the client API with github url", async (t) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
function doTest(t, clientArgs, clientOptions, expected) {
|
function doTest(t, clientArgs, clientOptions, expected) {
|
||||||
api_client_1.getApiClient(clientArgs, clientOptions);
|
(0, api_client_1.getApiClient)(clientArgs, clientOptions);
|
||||||
const firstCallArgs = githubStub.args[0];
|
const firstCallArgs = githubStub.args[0];
|
||||||
// log is a function, so we don't need to test for equality of it
|
// log is a function, so we don't need to test for equality of it
|
||||||
delete firstCallArgs[0].log;
|
delete firstCallArgs[0].log;
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"api-client.test.js","sourceRoot":"","sources":["../src/api-client.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAAyD;AACzD,8CAA6C;AAC7C,kDAA0B;AAE1B,6CAA4C;AAC5C,mDAA6C;AAC7C,iCAAqD;AAErD,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEvC,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,IAAI,UAA2B,CAAC;AAChC,IAAI,UAA2B,CAAC;AAEhC,aAAI,CAAC,UAAU,CAAC,GAAG,EAAE;IACnB,UAAU,GAAG,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtD,UAAU,GAAG,eAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/B,4BAAqB,CAAC,WAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,oBAAoB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACrC,MAAM,CACJ,CAAC,EACD;QACE,IAAI,EAAE,KAAK;QACX,gBAAgB,EAAE,KAAK;QACvB,GAAG,EAAE,gBAAg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AC,CAAC,CAAC,CAAC;IACzC,iEAAiE;IACjE,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5B,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
||||||
@@ -1 +1 @@
|
|||||||
{ "maximumVersion": "3.2", "minimumVersion": "2.22" }
|
{ "maximumVersion": "3.4", "minimumVersion": "3.0" }
|
||||||
|
|||||||
37
lib/autobuild-action.js
generated
37
lib/autobuild-action.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
@@ -16,40 +28,39 @@ 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 sendCompletedStatusReport(startedAt, allLanguages, failingLanguage, cause) {
|
async function sendCompletedStatusReport(startedAt, allLanguages, failingLanguage, cause) {
|
||||||
var _a, _b;
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, pkg.version);
|
|
||||||
const status = failingLanguage !== undefined || cause !== undefined
|
const status = failingLanguage !== undefined || cause !== undefined
|
||||||
? "failure"
|
? "failure"
|
||||||
: "success";
|
: "success";
|
||||||
const statusReportBase = await actions_util_1.createStatusReportBase("autobuild", status, startedAt, (_a = cause) === null || _a === void 0 ? void 0 : _a.message, (_b = cause) === null || _b === void 0 ? void 0 : _b.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,
|
||||||
autobuild_languages: allLanguages.join(","),
|
autobuild_languages: allLanguages.join(","),
|
||||||
autobuild_failure: failingLanguage,
|
autobuild_failure: failingLanguage,
|
||||||
};
|
};
|
||||||
await actions_util_1.sendStatusReport(statusReport);
|
await (0, actions_util_1.sendStatusReport)(statusReport);
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const logger = logging_1.getActionsLogger();
|
const logger = (0, logging_1.getActionsLogger)();
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
let language = undefined;
|
let language = undefined;
|
||||||
try {
|
try {
|
||||||
if (!(await actions_util_1.sendStatusReport(await actions_util_1.createStatusReportBase("autobuild", "starting", startedAt)))) {
|
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("autobuild", "starting", startedAt)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const config = await config_utils.getConfig(actions_util_1.getTemporaryDirectory(), logger);
|
const config = await config_utils.getConfig((0, actions_util_1.getTemporaryDirectory)(), logger);
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
||||||
}
|
}
|
||||||
language = autobuild_1.determineAutobuildLanguage(config, logger);
|
language = (0, autobuild_1.determineAutobuildLanguage)(config, logger);
|
||||||
if (language !== undefined) {
|
if (language !== undefined) {
|
||||||
await autobuild_1.runAutobuild(language, config, logger);
|
await (0, autobuild_1.runAutobuild)(language, config, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(`We were unable to automatically build your code. Please replace the call to the autobuild action with your custom build steps. ${error.message}`);
|
core.setFailed(`We were unable to automatically build your code. Please replace the call to the autobuild action with your custom build steps. ${error instanceof Error ? error.message : String(error)}`);
|
||||||
console.log(error);
|
console.log(error);
|
||||||
await sendCompletedStatusReport(startedAt, language ? [language] : [], language, error);
|
await sendCompletedStatusReport(startedAt, language ? [language] : [], language, error instanceof Error ? error : new Error(String(error)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await sendCompletedStatusReport(startedAt, language ? [language] : []);
|
await sendCompletedStatusReport(startedAt, language ? [language] : []);
|
||||||
|
|||||||
@@ -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,YA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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"}
|
||||||
3
lib/autobuild.js
generated
3
lib/autobuild.js
generated
@@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.runAutobuild = exports.determineAutobuildLanguage = void 0;
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
function determineAutobuildLanguage(config, logger) {
|
function determineAutobuildLanguage(config, logger) {
|
||||||
@@ -24,7 +25,7 @@ function determineAutobuildLanguage(config, logger) {
|
|||||||
exports.determineAutobuildLanguage = determineAutobuildLanguage;
|
exports.determineAutobuildLanguage = determineAutobuildLanguage;
|
||||||
async function runAutobuild(language, config, logger) {
|
async function runAutobuild(language, config, logger) {
|
||||||
logger.startGroup(`Attempting to automatically build ${language} code`);
|
logger.startGroup(`Attempting to automatically build ${language} code`);
|
||||||
const codeQL = codeql_1.getCodeQL(config.codeQLCmd);
|
const codeQL = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
await codeQL.runAutobuild(language);
|
await codeQL.runAutobuild(language);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"autobuild.js","sourceRoot":"","sources":["../src/autobuild.ts"],"names":[],"mappings":";;AAAA,qCAAqC;AAErC,2CAAyD;AAGzD,SAAgB,0BAA0B,CACxC,MAA2B,EAC3B,MAAc;IAEd,0CAA0C;IAC1C,mFAAmF;IACnF,oFAAoF;IACpF,4EAA4E;IAC5E,MAAM,kBAAkB,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,4BAAgB,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAEvC,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,CAAC,IAAI,CACT,iEAAiE,CAClE,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,CAAC,KAAK,CAAC,sCAAsC,QAAQ,EAAE,CAAC,CAAC;IAE/D,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;QACjC,MAAM,CAAC,OAAO,CACZ,oCAAoC,QAAQ,8BAA8B,kBAAkB;aACzF,KAAK,CAAC,CAAC,CAAC;aACR,IAAI,CAAC,OAAO,CAAC,uDAAuD,CACxE,CAAC;KACH;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AA7BD,gEA6BC;AAEM,KAAK,UAAU,YAAY,CAChC,QAAkB,EAClB,MAA2B,EAC3B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,qCAAqC,QAAQ,OAAO,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,kBAAS,CAAC,MAAM,CAAC,SAAS,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
158
lib/codeql.js
generated
158
lib/codeql.js
generated
@@ -1,15 +1,28 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.getExtraOptions = exports.getCodeQLForTesting = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.convertToSemVer = exports.getCodeQLURLVersion = exports.setupCodeQL = exports.getCodeQLActionRepository = exports.CODEQL_VERSION_NEW_TRACING = exports.CODEQL_VERSION_ML_POWERED_QUERIES = exports.CODEQL_VERSION_COUNTS_LINES = exports.CommandInvocationError = void 0;
|
||||||
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"));
|
||||||
@@ -20,9 +33,11 @@ const actions_util_1 = require("./actions-util");
|
|||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
||||||
const error_matcher_1 = require("./error-matcher");
|
const error_matcher_1 = require("./error-matcher");
|
||||||
|
const 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
|
||||||
@@ -38,6 +53,38 @@ exports.CommandInvocationError = CommandInvocationError;
|
|||||||
let cachedCodeQL = undefined;
|
let cachedCodeQL = undefined;
|
||||||
const CODEQL_BUNDLE_VERSION = defaults.bundleVersion;
|
const CODEQL_BUNDLE_VERSION = defaults.bundleVersion;
|
||||||
const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
|
const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
|
||||||
|
/**
|
||||||
|
* The oldest version of CodeQL that the Action will run with. This should be
|
||||||
|
* at least three minor versions behind the current version. The version flags
|
||||||
|
* below can be used to conditionally enable certain features on versions newer
|
||||||
|
* than this. Please record the reason we cannot support an older version.
|
||||||
|
*
|
||||||
|
* Reason: Changes to how the tracing environment is set up.
|
||||||
|
*/
|
||||||
|
const CODEQL_MINIMUM_VERSION = "2.3.1";
|
||||||
|
/**
|
||||||
|
* Versions of CodeQL that version-flag certain functionality in the Action.
|
||||||
|
* For convenience, please keep these in descending order. Once a version
|
||||||
|
* flag is older than the oldest supported version above, it may be removed.
|
||||||
|
*/
|
||||||
|
const CODEQL_VERSION_RAM_FINALIZE = "2.5.8";
|
||||||
|
const CODEQL_VERSION_DIAGNOSTICS = "2.5.6";
|
||||||
|
const CODEQL_VERSION_METRICS = "2.5.5";
|
||||||
|
const CODEQL_VERSION_GROUP_RULES = "2.5.5";
|
||||||
|
const CODEQL_VERSION_SARIF_GROUP = "2.5.3";
|
||||||
|
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";
|
||||||
|
/**
|
||||||
|
* This variable controls using the new style of tracing from the CodeQL
|
||||||
|
* CLI. In particular, with versions above this we will use both indirect
|
||||||
|
* tracing, and multi-language tracing together with database clusters.
|
||||||
|
*
|
||||||
|
* Note that there were bugs in both of these features that were fixed in
|
||||||
|
* release 2.7.0 of the CodeQL CLI, therefore this flag is only enabled for
|
||||||
|
* versions above that.
|
||||||
|
*/
|
||||||
|
exports.CODEQL_VERSION_NEW_TRACING = "2.7.0";
|
||||||
function getCodeQLBundleName() {
|
function getCodeQLBundleName() {
|
||||||
let platform;
|
let platform;
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@@ -69,14 +116,14 @@ function getActionsCodeQLActionRepository(logger) {
|
|||||||
}
|
}
|
||||||
// The Actions Runner used with GitHub Enterprise Server 2.22 did not set the GITHUB_ACTION_REPOSITORY variable.
|
// The Actions Runner used with GitHub Enterprise Server 2.22 did not set the GITHUB_ACTION_REPOSITORY variable.
|
||||||
// This fallback logic can be removed after the end-of-support for 2.22 on 2021-09-23.
|
// This fallback logic can be removed after the end-of-support for 2.22 on 2021-09-23.
|
||||||
if (actions_util_1.isRunningLocalAction()) {
|
if ((0, actions_util_1.isRunningLocalAction)()) {
|
||||||
// This handles the case where the Action does not come from an Action repository,
|
// This handles the case where the Action does not come from an Action repository,
|
||||||
// e.g. our integration tests which use the Action code from the current checkout.
|
// e.g. our integration tests which use the Action code from the current checkout.
|
||||||
logger.info("The CodeQL Action is checked out locally. Using the default CodeQL Action repository.");
|
logger.info("The CodeQL Action is checked out locally. Using the default CodeQL Action repository.");
|
||||||
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
||||||
}
|
}
|
||||||
logger.info("GITHUB_ACTION_REPOSITORY environment variable was not set. Falling back to legacy method of finding the GitHub Action.");
|
logger.info("GITHUB_ACTION_REPOSITORY environment variable was not set. Falling back to legacy method of finding the GitHub Action.");
|
||||||
const relativeScriptPathParts = actions_util_1.getRelativeScriptPath().split(path.sep);
|
const relativeScriptPathParts = (0, actions_util_1.getRelativeScriptPath)().split(path.sep);
|
||||||
return `${relativeScriptPathParts[0]}/${relativeScriptPathParts[1]}`;
|
return `${relativeScriptPathParts[0]}/${relativeScriptPathParts[1]}`;
|
||||||
}
|
}
|
||||||
async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
||||||
@@ -92,7 +139,7 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
|||||||
// We now filter out any duplicates.
|
// We now filter out any duplicates.
|
||||||
// Duplicates will happen either because the GitHub instance is GitHub.com, or because the Action is not a fork.
|
// Duplicates will happen either because the GitHub instance is GitHub.com, or because the Action is not a fork.
|
||||||
const uniqueDownloadSources = potentialDownloadSources.filter((source, index, self) => {
|
const uniqueDownloadSources = potentialDownloadSources.filter((source, index, self) => {
|
||||||
return !self.slice(0, index).some((other) => fast_deep_equal_1.default(source, other));
|
return !self.slice(0, index).some((other) => (0, fast_deep_equal_1.default)(source, other));
|
||||||
});
|
});
|
||||||
const codeQLBundleName = getCodeQLBundleName();
|
const codeQLBundleName = getCodeQLBundleName();
|
||||||
if (variant === util.GitHubVariant.GHAE) {
|
if (variant === util.GitHubVariant.GHAE) {
|
||||||
@@ -146,7 +193,7 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
|||||||
}
|
}
|
||||||
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
|
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
|
||||||
}
|
}
|
||||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger) {
|
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
|
||||||
// defaults over any pinned cached version.
|
// defaults over any pinned cached version.
|
||||||
@@ -170,7 +217,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}`);
|
||||||
@@ -214,11 +261,11 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
|||||||
else if (process.platform !== "linux" && process.platform !== "darwin") {
|
else if (process.platform !== "linux" && process.platform !== "darwin") {
|
||||||
throw new Error(`Unsupported platform: ${process.platform}`);
|
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||||
}
|
}
|
||||||
cachedCodeQL = getCodeQLForCmd(codeqlCmd);
|
cachedCodeQL = await getCodeQLForCmd(codeqlCmd, checkVersion);
|
||||||
return { codeql: cachedCodeQL, toolsVersion: codeqlURLVersion };
|
return { codeql: cachedCodeQL, toolsVersion: codeqlURLVersion };
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error(e);
|
logger.error(e instanceof Error ? e : new Error(String(e)));
|
||||||
throw new Error("Unable to download and extract CodeQL CLI");
|
throw new Error("Unable to download and extract CodeQL CLI");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,9 +293,9 @@ exports.convertToSemVer = convertToSemVer;
|
|||||||
/**
|
/**
|
||||||
* Use the CodeQL executable located at the given path.
|
* Use the CodeQL executable located at the given path.
|
||||||
*/
|
*/
|
||||||
function getCodeQL(cmd) {
|
async function getCodeQL(cmd) {
|
||||||
if (cachedCodeQL === undefined) {
|
if (cachedCodeQL === undefined) {
|
||||||
cachedCodeQL = getCodeQLForCmd(cmd);
|
cachedCodeQL = await getCodeQLForCmd(cmd, true);
|
||||||
}
|
}
|
||||||
return cachedCodeQL;
|
return cachedCodeQL;
|
||||||
}
|
}
|
||||||
@@ -274,9 +321,11 @@ function resolveFunction(partialCodeql, methodName, defaultImplementation) {
|
|||||||
function setCodeQL(partialCodeql) {
|
function setCodeQL(partialCodeql) {
|
||||||
cachedCodeQL = {
|
cachedCodeQL = {
|
||||||
getPath: resolveFunction(partialCodeql, "getPath", () => "/tmp/dummy-path"),
|
getPath: resolveFunction(partialCodeql, "getPath", () => "/tmp/dummy-path"),
|
||||||
|
getVersion: resolveFunction(partialCodeql, "getVersion", () => new Promise((resolve) => resolve("1.0.0"))),
|
||||||
printVersion: resolveFunction(partialCodeql, "printVersion"),
|
printVersion: resolveFunction(partialCodeql, "printVersion"),
|
||||||
getTracerEnv: resolveFunction(partialCodeql, "getTracerEnv"),
|
getTracerEnv: resolveFunction(partialCodeql, "getTracerEnv"),
|
||||||
databaseInit: resolveFunction(partialCodeql, "databaseInit"),
|
databaseInit: resolveFunction(partialCodeql, "databaseInit"),
|
||||||
|
databaseInitCluster: resolveFunction(partialCodeql, "databaseInitCluster"),
|
||||||
runAutobuild: resolveFunction(partialCodeql, "runAutobuild"),
|
runAutobuild: resolveFunction(partialCodeql, "runAutobuild"),
|
||||||
extractScannedLanguage: resolveFunction(partialCodeql, "extractScannedLanguage"),
|
extractScannedLanguage: resolveFunction(partialCodeql, "extractScannedLanguage"),
|
||||||
finalizeDatabase: resolveFunction(partialCodeql, "finalizeDatabase"),
|
finalizeDatabase: resolveFunction(partialCodeql, "finalizeDatabase"),
|
||||||
@@ -287,6 +336,7 @@ function setCodeQL(partialCodeql) {
|
|||||||
databaseBundle: resolveFunction(partialCodeql, "databaseBundle"),
|
databaseBundle: resolveFunction(partialCodeql, "databaseBundle"),
|
||||||
databaseRunQueries: resolveFunction(partialCodeql, "databaseRunQueries"),
|
databaseRunQueries: resolveFunction(partialCodeql, "databaseRunQueries"),
|
||||||
databaseInterpretResults: resolveFunction(partialCodeql, "databaseInterpretResults"),
|
databaseInterpretResults: resolveFunction(partialCodeql, "databaseInterpretResults"),
|
||||||
|
databasePrintBaseline: resolveFunction(partialCodeql, "databasePrintBaseline"),
|
||||||
};
|
};
|
||||||
return cachedCodeQL;
|
return cachedCodeQL;
|
||||||
}
|
}
|
||||||
@@ -305,11 +355,26 @@ function getCachedCodeQL() {
|
|||||||
return cachedCodeQL;
|
return cachedCodeQL;
|
||||||
}
|
}
|
||||||
exports.getCachedCodeQL = getCachedCodeQL;
|
exports.getCachedCodeQL = getCachedCodeQL;
|
||||||
function getCodeQLForCmd(cmd) {
|
/**
|
||||||
return {
|
* 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;
|
||||||
|
async function getCodeQLForCmd(cmd, checkVersion) {
|
||||||
|
let cachedVersion = undefined;
|
||||||
|
const codeql = {
|
||||||
getPath() {
|
getPath() {
|
||||||
return cmd;
|
return cmd;
|
||||||
},
|
},
|
||||||
|
async getVersion() {
|
||||||
|
if (cachedVersion === undefined)
|
||||||
|
cachedVersion = runTool(cmd, ["version", "--format=terse"]);
|
||||||
|
return await cachedVersion;
|
||||||
|
},
|
||||||
async printVersion() {
|
async printVersion() {
|
||||||
await runTool(cmd, ["version", "--format=json"]);
|
await runTool(cmd, ["version", "--format=json"]);
|
||||||
},
|
},
|
||||||
@@ -363,6 +428,27 @@ function getCodeQLForCmd(cmd) {
|
|||||||
...getExtraOptionsFromEnv(["database", "init"]),
|
...getExtraOptionsFromEnv(["database", "init"]),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
async databaseInitCluster(databasePath, languages, sourceRoot, processName, processLevel) {
|
||||||
|
const extraArgs = languages.map((language) => `--language=${language}`);
|
||||||
|
if (languages.filter(languages_1.isTracedLanguage).length > 0) {
|
||||||
|
extraArgs.push("--begin-tracing");
|
||||||
|
if (processName !== undefined) {
|
||||||
|
extraArgs.push(`--trace-process-name=${processName}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extraArgs.push(`--trace-process-level=${processLevel || 3}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await runTool(cmd, [
|
||||||
|
"database",
|
||||||
|
"init",
|
||||||
|
"--db-cluster",
|
||||||
|
databasePath,
|
||||||
|
`--source-root=${sourceRoot}`,
|
||||||
|
...extraArgs,
|
||||||
|
...getExtraOptionsFromEnv(["database", "init"]),
|
||||||
|
]);
|
||||||
|
},
|
||||||
async runAutobuild(language) {
|
async runAutobuild(language) {
|
||||||
const cmdName = process.platform === "win32" ? "autobuild.cmd" : "autobuild.sh";
|
const cmdName = process.platform === "win32" ? "autobuild.cmd" : "autobuild.sh";
|
||||||
const autobuildCmd = path.join(path.dirname(cmd), language, "tools", cmdName);
|
const autobuildCmd = path.join(path.dirname(cmd), language, "tools", cmdName);
|
||||||
@@ -403,7 +489,7 @@ function getCodeQLForCmd(cmd) {
|
|||||||
const ext = process.platform === "win32" ? ".cmd" : ".sh";
|
const ext = process.platform === "win32" ? ".cmd" : ".sh";
|
||||||
const traceCommand = path.resolve(JSON.parse(extractorPath), "tools", `autobuild${ext}`);
|
const traceCommand = path.resolve(JSON.parse(extractorPath), "tools", `autobuild${ext}`);
|
||||||
// Run trace command
|
// Run trace command
|
||||||
await toolrunner_error_catcher_1.toolrunnerErrorCatcher(cmd, [
|
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, [
|
||||||
"database",
|
"database",
|
||||||
"trace-command",
|
"trace-command",
|
||||||
...getExtraOptionsFromEnv(["database", "trace-command"]),
|
...getExtraOptionsFromEnv(["database", "trace-command"]),
|
||||||
@@ -412,15 +498,18 @@ function getCodeQLForCmd(cmd) {
|
|||||||
traceCommand,
|
traceCommand,
|
||||||
], error_matcher_1.errorMatchers);
|
], error_matcher_1.errorMatchers);
|
||||||
},
|
},
|
||||||
async finalizeDatabase(databasePath, threadsFlag) {
|
async finalizeDatabase(databasePath, threadsFlag, memoryFlag) {
|
||||||
await toolrunner_error_catcher_1.toolrunnerErrorCatcher(cmd, [
|
const args = [
|
||||||
"database",
|
"database",
|
||||||
"finalize",
|
"finalize",
|
||||||
"--finalize-dataset",
|
"--finalize-dataset",
|
||||||
threadsFlag,
|
threadsFlag,
|
||||||
...getExtraOptionsFromEnv(["database", "finalize"]),
|
...getExtraOptionsFromEnv(["database", "finalize"]),
|
||||||
databasePath,
|
databasePath,
|
||||||
], error_matcher_1.errorMatchers);
|
];
|
||||||
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_RAM_FINALIZE))
|
||||||
|
args.push(memoryFlag);
|
||||||
|
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"];
|
||||||
@@ -474,20 +563,36 @@ function getCodeQLForCmd(cmd) {
|
|||||||
"interpret-results",
|
"interpret-results",
|
||||||
threadsFlag,
|
threadsFlag,
|
||||||
"--format=sarif-latest",
|
"--format=sarif-latest",
|
||||||
"--print-metrics-summary",
|
|
||||||
"--sarif-group-rules-by-pack",
|
|
||||||
"-v",
|
"-v",
|
||||||
`--output=${sarifFile}`,
|
`--output=${sarifFile}`,
|
||||||
addSnippetsFlag,
|
addSnippetsFlag,
|
||||||
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
||||||
];
|
];
|
||||||
if (automationDetailsId !== undefined) {
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_DIAGNOSTICS))
|
||||||
|
codeqlArgs.push("--print-diagnostics-summary");
|
||||||
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_METRICS))
|
||||||
|
codeqlArgs.push("--print-metrics-summary");
|
||||||
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_GROUP_RULES))
|
||||||
|
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 &&
|
||||||
|
(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, ...querySuitePaths);
|
||||||
// capture stdout, which contains analysis summaries
|
// capture stdout, which contains analysis summaries
|
||||||
return await runTool(cmd, codeqlArgs);
|
return await runTool(cmd, codeqlArgs);
|
||||||
},
|
},
|
||||||
|
async databasePrintBaseline(databasePath) {
|
||||||
|
const codeqlArgs = [
|
||||||
|
"database",
|
||||||
|
"print-baseline",
|
||||||
|
...getExtraOptionsFromEnv(["database", "print-baseline"]),
|
||||||
|
databasePath,
|
||||||
|
];
|
||||||
|
return await runTool(cmd, codeqlArgs);
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Download specified packs into the package cache. If the specified
|
* Download specified packs into the package cache. If the specified
|
||||||
* package and version already exists (e.g., from a previous analysis run),
|
* package and version already exists (e.g., from a previous analysis run),
|
||||||
@@ -533,16 +638,22 @@ function getCodeQLForCmd(cmd) {
|
|||||||
];
|
];
|
||||||
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}`,
|
||||||
];
|
];
|
||||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
if (checkVersion &&
|
||||||
|
!(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()}`);
|
||||||
|
}
|
||||||
|
return codeql;
|
||||||
}
|
}
|
||||||
function packWithVersionToString(pack) {
|
function packWithVersionToString(pack) {
|
||||||
return pack.version ? `${pack.packName}@${pack.version}` : pack.packName;
|
return pack.version ? `${pack.packName}@${pack.version}` : pack.packName;
|
||||||
@@ -585,11 +696,10 @@ function asExtraOptions(options, pathInfo) {
|
|||||||
* Exported for testing.
|
* Exported for testing.
|
||||||
*/
|
*/
|
||||||
function getExtraOptions(options, paths, pathInfo) {
|
function getExtraOptions(options, paths, pathInfo) {
|
||||||
var _a, _b, _c;
|
const all = asExtraOptions(options === null || options === void 0 ? void 0 : options["*"], pathInfo.concat("*"));
|
||||||
const all = asExtraOptions((_a = options) === null || _a === void 0 ? void 0 : _a["*"], pathInfo.concat("*"));
|
|
||||||
const specific = paths.length === 0
|
const specific = paths.length === 0
|
||||||
? asExtraOptions(options, pathInfo)
|
? asExtraOptions(options, pathInfo)
|
||||||
: getExtraOptions((_b = options) === null || _b === void 0 ? void 0 : _b[paths[0]], (_c = paths) === null || _c === void 0 ? void 0 : _c.slice(1), pathInfo.concat(paths[0]));
|
: getExtraOptions(options === null || options === void 0 ? void 0 : options[paths[0]], paths === null || paths === void 0 ? void 0 : paths.slice(1), pathInfo.concat(paths[0]));
|
||||||
return all.concat(specific);
|
return all.concat(specific);
|
||||||
}
|
}
|
||||||
exports.getExtraOptions = getExtraOptions;
|
exports.getExtraOptions = getExtraOptions;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
133
lib/codeql.test.js
generated
133
lib/codeql.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -11,16 +23,18 @@ 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");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
const sampleApiDetails = {
|
const sampleApiDetails = {
|
||||||
auth: "token",
|
auth: "token",
|
||||||
url: "https://github.com",
|
url: "https://github.com",
|
||||||
@@ -30,97 +44,97 @@ const sampleGHAEApiDetails = {
|
|||||||
url: "https://example.githubenterprise.com",
|
url: "https://example.githubenterprise.com",
|
||||||
};
|
};
|
||||||
ava_1.default.beforeEach(() => {
|
ava_1.default.beforeEach(() => {
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
||||||
});
|
});
|
||||||
ava_1.default("download codeql bundle cache", async (t) => {
|
(0, ava_1.default)("download codeql bundle cache", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
const versions = ["20200601", "20200610"];
|
const versions = ["20200601", "20200610"];
|
||||||
for (let i = 0; i < versions.length; i++) {
|
for (let i = 0; i < versions.length; i++) {
|
||||||
const version = versions[i];
|
const version = versions[i];
|
||||||
nock_1.default("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||||
}
|
}
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => {
|
(0, ava_1.default)("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
nock_1.default("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
nock_1.default("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("don't download codeql bundle cache with pinned different version cached", async (t) => {
|
(0, ava_1.default)("don't download codeql bundle cache with pinned different version cached", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
nock_1.default("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 1);
|
t.is(cachedVersions.length, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("download codeql bundle cache with different version cached (not pinned)", async (t) => {
|
(0, ava_1.default)("download codeql bundle cache with different version cached (not pinned)", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
nock_1.default("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
const platform = process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
: process.platform === "linux"
|
: process.platform === "linux"
|
||||||
? "linux64"
|
? "linux64"
|
||||||
: "osx64";
|
: "osx64";
|
||||||
nock_1.default("https://github.com")
|
(0, nock_1.default)("https://github.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => {
|
(0, ava_1.default)('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
nock_1.default("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
const platform = process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
: process.platform === "linux"
|
: process.platform === "linux"
|
||||||
? "linux64"
|
? "linux64"
|
||||||
: "osx64";
|
: "osx64";
|
||||||
nock_1.default("https://github.com")
|
(0, nock_1.default)("https://github.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("download codeql bundle from github ae endpoint", async (t) => {
|
(0, ava_1.default)("download codeql bundle from github ae endpoint", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
const bundleAssetID = 10;
|
const bundleAssetID = 10;
|
||||||
const platform = process.platform === "win32"
|
const platform = process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
@@ -128,28 +142,28 @@ ava_1.default("download codeql bundle from github ae endpoint", async (t) => {
|
|||||||
? "linux64"
|
? "linux64"
|
||||||
: "osx64";
|
: "osx64";
|
||||||
const codeQLBundleName = `codeql-bundle-${platform}.tar.gz`;
|
const codeQLBundleName = `codeql-bundle-${platform}.tar.gz`;
|
||||||
nock_1.default("https://example.githubenterprise.com")
|
(0, nock_1.default)("https://example.githubenterprise.com")
|
||||||
.get(`/api/v3/enterprise/code-scanning/codeql-bundle/find/${defaults.bundleVersion}`)
|
.get(`/api/v3/enterprise/code-scanning/codeql-bundle/find/${defaults.bundleVersion}`)
|
||||||
.reply(200, {
|
.reply(200, {
|
||||||
assets: { [codeQLBundleName]: bundleAssetID },
|
assets: { [codeQLBundleName]: bundleAssetID },
|
||||||
});
|
});
|
||||||
nock_1.default("https://example.githubenterprise.com")
|
(0, nock_1.default)("https://example.githubenterprise.com")
|
||||||
.get(`/api/v3/enterprise/code-scanning/codeql-bundle/download/${bundleAssetID}`)
|
.get(`/api/v3/enterprise/code-scanning/codeql-bundle/download/${bundleAssetID}`)
|
||||||
.reply(200, {
|
.reply(200, {
|
||||||
url: `https://example.githubenterprise.com/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`,
|
url: `https://example.githubenterprise.com/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`,
|
||||||
});
|
});
|
||||||
nock_1.default("https://example.githubenterprise.com")
|
(0, nock_1.default)("https://example.githubenterprise.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, tmpDir, util.GitHubVariant.GHAE, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, tmpDir, util.GitHubVariant.GHAE, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 1);
|
t.is(cachedVersions.length, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("parse codeql bundle url version", (t) => {
|
(0, ava_1.default)("parse codeql bundle url version", (t) => {
|
||||||
t.deepEqual(codeql.getCodeQLURLVersion("https://github.com/.../codeql-bundle-20200601/..."), "20200601");
|
t.deepEqual(codeql.getCodeQLURLVersion("https://github.com/.../codeql-bundle-20200601/..."), "20200601");
|
||||||
});
|
});
|
||||||
ava_1.default("convert to semver", (t) => {
|
(0, ava_1.default)("convert to semver", (t) => {
|
||||||
const tests = {
|
const tests = {
|
||||||
"20200601": "0.0.0-20200601",
|
"20200601": "0.0.0-20200601",
|
||||||
"20200601.0": "0.0.0-20200601.0",
|
"20200601.0": "0.0.0-20200601.0",
|
||||||
@@ -160,23 +174,23 @@ ava_1.default("convert to semver", (t) => {
|
|||||||
};
|
};
|
||||||
for (const [version, expectedVersion] of Object.entries(tests)) {
|
for (const [version, expectedVersion] of Object.entries(tests)) {
|
||||||
try {
|
try {
|
||||||
const parsedVersion = codeql.convertToSemVer(version, logging_1.getRunnerLogger(true));
|
const parsedVersion = codeql.convertToSemVer(version, (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(parsedVersion, expectedVersion);
|
t.deepEqual(parsedVersion, expectedVersion);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
t.fail(e.message);
|
t.fail(e instanceof Error ? e.message : String(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ava_1.default("getExtraOptions works for explicit paths", (t) => {
|
(0, ava_1.default)("getExtraOptions works for explicit paths", (t) => {
|
||||||
t.deepEqual(codeql.getExtraOptions({}, ["foo"], []), []);
|
t.deepEqual(codeql.getExtraOptions({}, ["foo"], []), []);
|
||||||
t.deepEqual(codeql.getExtraOptions({ foo: [42] }, ["foo"], []), ["42"]);
|
t.deepEqual(codeql.getExtraOptions({ foo: [42] }, ["foo"], []), ["42"]);
|
||||||
t.deepEqual(codeql.getExtraOptions({ foo: { bar: [42] } }, ["foo", "bar"], []), ["42"]);
|
t.deepEqual(codeql.getExtraOptions({ foo: { bar: [42] } }, ["foo", "bar"], []), ["42"]);
|
||||||
});
|
});
|
||||||
ava_1.default("getExtraOptions works for wildcards", (t) => {
|
(0, ava_1.default)("getExtraOptions works for wildcards", (t) => {
|
||||||
t.deepEqual(codeql.getExtraOptions({ "*": [42] }, ["foo"], []), ["42"]);
|
t.deepEqual(codeql.getExtraOptions({ "*": [42] }, ["foo"], []), ["42"]);
|
||||||
});
|
});
|
||||||
ava_1.default("getExtraOptions works for wildcards and explicit paths", (t) => {
|
(0, ava_1.default)("getExtraOptions works for wildcards and explicit paths", (t) => {
|
||||||
const o1 = { "*": [42], foo: [87] };
|
const o1 = { "*": [42], foo: [87] };
|
||||||
t.deepEqual(codeql.getExtraOptions(o1, ["foo"], []), ["42", "87"]);
|
t.deepEqual(codeql.getExtraOptions(o1, ["foo"], []), ["42", "87"]);
|
||||||
const o2 = { "*": [42], foo: [87] };
|
const o2 = { "*": [42], foo: [87] };
|
||||||
@@ -185,17 +199,17 @@ ava_1.default("getExtraOptions works for wildcards and explicit paths", (t) => {
|
|||||||
const p = ["foo", "bar"];
|
const p = ["foo", "bar"];
|
||||||
t.deepEqual(codeql.getExtraOptions(o3, p, []), ["42", "87", "99"]);
|
t.deepEqual(codeql.getExtraOptions(o3, p, []), ["42", "87", "99"]);
|
||||||
});
|
});
|
||||||
ava_1.default("getExtraOptions throws for bad content", (t) => {
|
(0, ava_1.default)("getExtraOptions throws for bad content", (t) => {
|
||||||
t.throws(() => codeql.getExtraOptions({ "*": 42 }, ["foo"], []));
|
t.throws(() => codeql.getExtraOptions({ "*": 42 }, ["foo"], []));
|
||||||
t.throws(() => codeql.getExtraOptions({ foo: 87 }, ["foo"], []));
|
t.throws(() => codeql.getExtraOptions({ foo: 87 }, ["foo"], []));
|
||||||
t.throws(() => codeql.getExtraOptions({ "*": [42], foo: { "*": 87, bar: [99] } }, ["foo", "bar"], []));
|
t.throws(() => codeql.getExtraOptions({ "*": [42], foo: { "*": 87, bar: [99] } }, ["foo", "bar"], []));
|
||||||
});
|
});
|
||||||
ava_1.default("getCodeQLActionRepository", (t) => {
|
(0, ava_1.default)("getCodeQLActionRepository", (t) => {
|
||||||
const logger = logging_1.getRunnerLogger(true);
|
const logger = (0, logging_1.getRunnerLogger)(true);
|
||||||
util_1.initializeEnvironment(util_1.Mode.runner, "1.2.3");
|
(0, util_1.initializeEnvironment)(util_1.Mode.runner, "1.2.3");
|
||||||
const repoActions = codeql.getCodeQLActionRepository(logger);
|
const repoActions = codeql.getCodeQLActionRepository(logger);
|
||||||
t.deepEqual(repoActions, "github/codeql-action");
|
t.deepEqual(repoActions, "github/codeql-action");
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
||||||
// isRunningLocalAction() === true
|
// isRunningLocalAction() === true
|
||||||
delete process.env["GITHUB_ACTION_REPOSITORY"];
|
delete process.env["GITHUB_ACTION_REPOSITORY"];
|
||||||
process.env["RUNNER_TEMP"] = path.dirname(__dirname);
|
process.env["RUNNER_TEMP"] = path.dirname(__dirname);
|
||||||
@@ -205,4 +219,25 @@ ava_1.default("getCodeQLActionRepository", (t) => {
|
|||||||
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
85
lib/config-utils.js
generated
85
lib/config-utils.js
generated
@@ -1,19 +1,35 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPacksRequireLanguage = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
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";
|
||||||
@@ -103,11 +119,26 @@ 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.
|
||||||
*/
|
*/
|
||||||
async function addBuiltinSuiteQueries(languages, codeQL, resultMap, suiteName, configFile) {
|
async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suiteName, featureFlags, configFile) {
|
||||||
const found = builtinSuites.find((suite) => suite === suiteName);
|
const found = builtinSuites.find((suite) => suite === suiteName);
|
||||||
if (!found) {
|
if (!found) {
|
||||||
throw new Error(getQueryUsesInvalid(configFile, suiteName));
|
throw new Error(getQueryUsesInvalid(configFile, suiteName));
|
||||||
}
|
}
|
||||||
|
// If we're running the JavaScript security-extended analysis (or a superset of it) and the repo
|
||||||
|
// is opted into the ML-powered queries beta, then add the ML-powered query pack so that we run
|
||||||
|
// the ML-powered queries.
|
||||||
|
if (languages.includes("javascript") &&
|
||||||
|
(found === "security-extended" || found === "security-and-quality") &&
|
||||||
|
(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({
|
||||||
|
packName: "codeql/javascript-experimental-atm-queries",
|
||||||
|
version: "~0.0.2",
|
||||||
|
});
|
||||||
|
}
|
||||||
const suites = languages.map((l) => `${l}-${suiteName}.qls`);
|
const suites = languages.map((l) => `${l}-${suiteName}.qls`);
|
||||||
await runResolveQueries(codeQL, resultMap, suites, undefined);
|
await runResolveQueries(codeQL, resultMap, suites, undefined);
|
||||||
}
|
}
|
||||||
@@ -167,7 +198,7 @@ async function addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetail
|
|||||||
* 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.
|
||||||
*/
|
*/
|
||||||
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));
|
||||||
@@ -179,7 +210,7 @@ async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir,
|
|||||||
}
|
}
|
||||||
// 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);
|
await addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, queryUses, featureFlags, configFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Otherwise, must be a reference to another repo
|
// Otherwise, must be a reference to another repo
|
||||||
@@ -338,7 +369,7 @@ async function getLanguagesInRepo(repository, apiDetails, logger) {
|
|||||||
// into an array gives us an array of languages ordered by popularity
|
// into an array gives us an array of languages ordered by popularity
|
||||||
const languages = new Set();
|
const languages = new Set();
|
||||||
for (const lang of Object.keys(response.data)) {
|
for (const lang of Object.keys(response.data)) {
|
||||||
const parsedLang = languages_1.parseLanguage(lang);
|
const parsedLang = (0, languages_1.parseLanguage)(lang);
|
||||||
if (parsedLang !== undefined) {
|
if (parsedLang !== undefined) {
|
||||||
languages.add(parsedLang);
|
languages.add(parsedLang);
|
||||||
}
|
}
|
||||||
@@ -378,7 +409,7 @@ async function getLanguages(codeQL, languagesInput, repository, apiDetails, logg
|
|||||||
const parsedLanguages = [];
|
const parsedLanguages = [];
|
||||||
const unknownLanguages = [];
|
const unknownLanguages = [];
|
||||||
for (const language of languages) {
|
for (const language of languages) {
|
||||||
const parsedLanguage = languages_1.parseLanguage(language);
|
const parsedLanguage = (0, languages_1.parseLanguage)(language);
|
||||||
if (parsedLanguage === undefined) {
|
if (parsedLanguage === undefined) {
|
||||||
unknownLanguages.push(language);
|
unknownLanguages.push(language);
|
||||||
}
|
}
|
||||||
@@ -391,12 +422,12 @@ 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) {
|
||||||
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);
|
await parseQueryUses(languages, codeQL, resultMap, packs, query, tempDir, workspacePath, apiDetails, featureFlags, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Returns true if either no queries were provided in the workflow.
|
// Returns true if either no queries were provided in the workflow.
|
||||||
@@ -412,7 +443,7 @@ function shouldAddConfigFileQueries(queriesInput) {
|
|||||||
/**
|
/**
|
||||||
* 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 = {};
|
||||||
@@ -423,10 +454,10 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
await addDefaultQueries(codeQL, languages, queries);
|
await addDefaultQueries(codeQL, languages, queries);
|
||||||
|
const packs = (_a = parsePacksFromInput(packsInput, languages)) !== null && _a !== void 0 ? _a : {};
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, workspacePath, apiDetails, logger);
|
await addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, queries, packs, tempDir, workspacePath, apiDetails, featureFlags, logger);
|
||||||
}
|
}
|
||||||
const packs = (_a = parsePacksFromInput(packsInput, languages), (_a !== null && _a !== void 0 ? _a : {}));
|
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
@@ -439,13 +470,16 @@ 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,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
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)) {
|
||||||
@@ -486,12 +520,13 @@ 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.
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, workspacePath, apiDetails, logger);
|
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) {
|
||||||
@@ -504,7 +539,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) {
|
||||||
@@ -529,7 +564,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], (_a !== null && _a !== void 0 ? _a : {})), packsInput, languages, configFile);
|
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
@@ -542,6 +576,9 @@ 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,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -586,8 +623,7 @@ function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
|||||||
}
|
}
|
||||||
exports.parsePacksFromConfig = parsePacksFromConfig;
|
exports.parsePacksFromConfig = parsePacksFromConfig;
|
||||||
function parsePacksFromInput(packsInput, languages) {
|
function parsePacksFromInput(packsInput, languages) {
|
||||||
var _a;
|
if (!(packsInput === null || packsInput === void 0 ? void 0 : packsInput.trim())) {
|
||||||
if (!((_a = packsInput) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (languages.length > 1) {
|
if (languages.length > 1) {
|
||||||
@@ -645,8 +681,7 @@ function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) {
|
|||||||
}
|
}
|
||||||
exports.parsePacks = parsePacks;
|
exports.parsePacks = parsePacks;
|
||||||
function shouldCombinePacks(packsInput) {
|
function shouldCombinePacks(packsInput) {
|
||||||
var _a;
|
return !!(packsInput === null || packsInput === void 0 ? void 0 : packsInput.trim().startsWith("+"));
|
||||||
return !!((_a = packsInput) === null || _a === void 0 ? void 0 : _a.trim().startsWith("+"));
|
|
||||||
}
|
}
|
||||||
function combinePacks(packs1, packs2) {
|
function combinePacks(packs1, packs2) {
|
||||||
const packs = {};
|
const packs = {};
|
||||||
@@ -669,16 +704,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.
|
||||||
@@ -712,7 +747,7 @@ function getLocalConfig(configFile, workspacePath) {
|
|||||||
if (!fs.existsSync(configFile)) {
|
if (!fs.existsSync(configFile)) {
|
||||||
throw new Error(getConfigFileDoesNotExistErrorMessage(configFile));
|
throw new Error(getConfigFileDoesNotExistErrorMessage(configFile));
|
||||||
}
|
}
|
||||||
return yaml.safeLoad(fs.readFileSync(configFile, "utf8"));
|
return yaml.load(fs.readFileSync(configFile, "utf8"));
|
||||||
}
|
}
|
||||||
async function getRemoteConfig(configFile, apiDetails) {
|
async function getRemoteConfig(configFile, apiDetails) {
|
||||||
// retrieve the various parts of the config location, and ensure they're present
|
// retrieve the various parts of the config location, and ensure they're present
|
||||||
@@ -740,7 +775,7 @@ async function getRemoteConfig(configFile, apiDetails) {
|
|||||||
else {
|
else {
|
||||||
throw new Error(getConfigFileFormatInvalidMessage(configFile));
|
throw new Error(getConfigFileFormatInvalidMessage(configFile));
|
||||||
}
|
}
|
||||||
return yaml.safeLoad(Buffer.from(fileContents, "base64").toString("binary"));
|
return yaml.load(Buffer.from(fileContents, "base64").toString("binary"));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the file path where the parsed config will be stored.
|
* Get the file path where the parsed config will be stored.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
270
lib/config-utils.test.js
generated
270
lib/config-utils.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -15,15 +27,16 @@ const path = __importStar(require("path"));
|
|||||||
const github = __importStar(require("@actions/github"));
|
const github = __importStar(require("@actions/github"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const semver_1 = require("semver");
|
const semver_1 = require("semver");
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
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");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
const sampleApiDetails = {
|
const sampleApiDetails = {
|
||||||
auth: "token",
|
auth: "token",
|
||||||
externalRepoAuth: "token",
|
externalRepoAuth: "token",
|
||||||
@@ -42,10 +55,10 @@ function mockGetContents(content) {
|
|||||||
const response = {
|
const response = {
|
||||||
data: content,
|
data: content,
|
||||||
};
|
};
|
||||||
const spyGetContents = sinon_1.default
|
const spyGetContents = sinon
|
||||||
.stub(client.repos, "getContent")
|
.stub(client.repos, "getContent")
|
||||||
.resolves(response);
|
.resolves(response);
|
||||||
sinon_1.default.stub(api, "getApiClient").value(() => client);
|
sinon.stub(api, "getApiClient").value(() => client);
|
||||||
return spyGetContents;
|
return spyGetContents;
|
||||||
}
|
}
|
||||||
function mockListLanguages(languages) {
|
function mockListLanguages(languages) {
|
||||||
@@ -57,14 +70,14 @@ function mockListLanguages(languages) {
|
|||||||
for (const language of languages) {
|
for (const language of languages) {
|
||||||
response.data[language] = 123;
|
response.data[language] = 123;
|
||||||
}
|
}
|
||||||
sinon_1.default.stub(client.repos, "listLanguages").resolves(response);
|
sinon.stub(client.repos, "listLanguages").resolves(response);
|
||||||
sinon_1.default.stub(api, "getApiClient").value(() => client);
|
sinon.stub(api, "getApiClient").value(() => client);
|
||||||
}
|
}
|
||||||
ava_1.default("load empty config", async (t) => {
|
(0, ava_1.default)("load empty config", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const logger = logging_1.getRunnerLogger(true);
|
const logger = (0, logging_1.getRunnerLogger)(true);
|
||||||
const languages = "javascript,python";
|
const languages = "javascript,python";
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
@@ -76,14 +89,14 @@ ava_1.default("load empty config", async (t) => {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
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));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("loading config saves config", async (t) => {
|
(0, ava_1.default)("loading config saves config", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const logger = logging_1.getRunnerLogger(true);
|
const logger = (0, logging_1.getRunnerLogger)(true);
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
@@ -99,7 +112,7 @@ ava_1.default("loading config saves config", async (t) => {
|
|||||||
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
|
||||||
@@ -107,10 +120,10 @@ ava_1.default("loading config saves config", async (t) => {
|
|||||||
t.deepEqual(config1, config2);
|
t.deepEqual(config1, config2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
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, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, 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) {
|
||||||
@@ -118,12 +131,12 @@ ava_1.default("load input outside of workspace", async (t) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("load non-local input with invalid repo syntax", async (t) => {
|
(0, ava_1.default)("load non-local input with invalid repo syntax", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
// 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, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, 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) {
|
||||||
@@ -131,13 +144,13 @@ ava_1.default("load non-local input with invalid repo syntax", async (t) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("load non-existent input", async (t) => {
|
(0, ava_1.default)("load non-existent input", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
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, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, 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) {
|
||||||
@@ -145,9 +158,9 @@ ava_1.default("load non-existent input", async (t) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("load non-empty input", async (t) => {
|
(0, ava_1.default)("load non-empty input", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
@@ -202,15 +215,18 @@ ava_1.default("load non-empty input", async (t) => {
|
|||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: "my-artifact",
|
||||||
|
debugDatabaseName: "my-db",
|
||||||
};
|
};
|
||||||
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, 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Default queries are used", async (t) => {
|
(0, ava_1.default)("Default queries are used", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
// Check that the default behaviour is to add the default queries.
|
// Check that the default behaviour is to add the default queries.
|
||||||
// In this case if a config file is specified but does not include
|
// In this case if a config file is specified but does not include
|
||||||
@@ -218,7 +234,7 @@ ava_1.default("Default queries are used", async (t) => {
|
|||||||
// We determine this by whether CodeQL.resolveQueries is called
|
// We determine this by whether CodeQL.resolveQueries is called
|
||||||
// with the correct arguments.
|
// with the correct arguments.
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries(queries, extraSearchPath) {
|
async resolveQueries(queries, extraSearchPath) {
|
||||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||||
return {
|
return {
|
||||||
@@ -241,7 +257,7 @@ ava_1.default("Default queries are used", async (t) => {
|
|||||||
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, 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, [
|
||||||
@@ -268,7 +284,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
multipleDeclaredLanguages: {},
|
multipleDeclaredLanguages: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
ava_1.default("Queries can be specified in config file", async (t) => {
|
(0, ava_1.default)("Queries can be specified in config file", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const inputFileContents = `
|
const inputFileContents = `
|
||||||
name: my config
|
name: my config
|
||||||
@@ -277,14 +293,14 @@ ava_1.default("Queries can be specified in config file", async (t) => {
|
|||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries(queries, extraSearchPath) {
|
async resolveQueries(queries, extraSearchPath) {
|
||||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||||
return queriesToResolvedQueryForm(queries);
|
return 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, 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.
|
||||||
@@ -298,7 +314,7 @@ ava_1.default("Queries can be specified in config file", async (t) => {
|
|||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/foo$/);
|
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/foo$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Queries from config file can be overridden in workflow file", async (t) => {
|
(0, ava_1.default)("Queries from config file can be overridden in workflow file", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const inputFileContents = `
|
const inputFileContents = `
|
||||||
name: my config
|
name: my config
|
||||||
@@ -310,14 +326,14 @@ ava_1.default("Queries from config file can be overridden in workflow file", asy
|
|||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
fs.mkdirSync(path.join(tmpDir, "override"));
|
fs.mkdirSync(path.join(tmpDir, "override"));
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries(queries, extraSearchPath) {
|
async resolveQueries(queries, extraSearchPath) {
|
||||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||||
return queriesToResolvedQueryForm(queries);
|
return 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, 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.
|
||||||
@@ -331,7 +347,7 @@ ava_1.default("Queries from config file can be overridden in workflow file", asy
|
|||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override$/);
|
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Queries in workflow file can be used in tandem with the 'disable default queries' option", async (t) => {
|
(0, ava_1.default)("Queries in workflow file can be used in tandem with the 'disable default queries' option", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
process.env["RUNNER_TEMP"] = tmpDir;
|
process.env["RUNNER_TEMP"] = tmpDir;
|
||||||
process.env["GITHUB_WORKSPACE"] = tmpDir;
|
process.env["GITHUB_WORKSPACE"] = tmpDir;
|
||||||
@@ -342,14 +358,14 @@ ava_1.default("Queries in workflow file can be used in tandem with the 'disable
|
|||||||
const testQueries = "./workflow-query";
|
const testQueries = "./workflow-query";
|
||||||
fs.mkdirSync(path.join(tmpDir, "workflow-query"));
|
fs.mkdirSync(path.join(tmpDir, "workflow-query"));
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries(queries, extraSearchPath) {
|
async resolveQueries(queries, extraSearchPath) {
|
||||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||||
return queriesToResolvedQueryForm(queries);
|
return 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, 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
|
||||||
@@ -362,20 +378,20 @@ ava_1.default("Queries in workflow file can be used in tandem with the 'disable
|
|||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/workflow-query$/);
|
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/workflow-query$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Multiple queries can be specified in workflow file, no config file required", async (t) => {
|
(0, ava_1.default)("Multiple queries can be specified in workflow file, no config file required", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
fs.mkdirSync(path.join(tmpDir, "override1"));
|
fs.mkdirSync(path.join(tmpDir, "override1"));
|
||||||
fs.mkdirSync(path.join(tmpDir, "override2"));
|
fs.mkdirSync(path.join(tmpDir, "override2"));
|
||||||
const testQueries = "./override1,./override2";
|
const testQueries = "./override1,./override2";
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries(queries, extraSearchPath) {
|
async resolveQueries(queries, extraSearchPath) {
|
||||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||||
return queriesToResolvedQueryForm(queries);
|
return 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, 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
|
||||||
@@ -392,7 +408,7 @@ ava_1.default("Multiple queries can be specified in workflow file, no config fil
|
|||||||
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/override2$/);
|
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/override2$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Queries in workflow file can be added to the set of queries without overriding config file", async (t) => {
|
(0, ava_1.default)("Queries in workflow file can be added to the set of queries without overriding config file", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
process.env["RUNNER_TEMP"] = tmpDir;
|
process.env["RUNNER_TEMP"] = tmpDir;
|
||||||
process.env["GITHUB_WORKSPACE"] = tmpDir;
|
process.env["GITHUB_WORKSPACE"] = tmpDir;
|
||||||
@@ -407,14 +423,14 @@ ava_1.default("Queries in workflow file can be added to the set of queries witho
|
|||||||
fs.mkdirSync(path.join(tmpDir, "additional1"));
|
fs.mkdirSync(path.join(tmpDir, "additional1"));
|
||||||
fs.mkdirSync(path.join(tmpDir, "additional2"));
|
fs.mkdirSync(path.join(tmpDir, "additional2"));
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries(queries, extraSearchPath) {
|
async resolveQueries(queries, extraSearchPath) {
|
||||||
resolveQueriesArgs.push({ queries, extraSearchPath });
|
resolveQueriesArgs.push({ queries, extraSearchPath });
|
||||||
return queriesToResolvedQueryForm(queries);
|
return 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, 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,
|
||||||
@@ -435,13 +451,13 @@ ava_1.default("Queries in workflow file can be added to the set of queries witho
|
|||||||
t.regex(config.queries["javascript"].custom[2].queries[0], /.*\/foo$/);
|
t.regex(config.queries["javascript"].custom[2].queries[0], /.*\/foo$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Invalid queries in workflow file handled correctly", async (t) => {
|
(0, ava_1.default)("Invalid queries in workflow file handled correctly", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const queries = "foo/bar@v1@v3";
|
const queries = "foo/bar@v1@v3";
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
// This function just needs to be type-correct; it doesn't need to do anything,
|
// This function just needs to be type-correct; it doesn't need to do anything,
|
||||||
// since we're deliberately passing in invalid data
|
// since we're deliberately passing in invalid data
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
@@ -453,7 +469,7 @@ ava_1.default("Invalid queries in workflow file handled correctly", async (t) =>
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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) {
|
||||||
@@ -461,9 +477,9 @@ ava_1.default("Invalid queries in workflow file handled correctly", async (t) =>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("API client used when reading remote config", async (t) => {
|
(0, ava_1.default)("API client used when reading remote config", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
@@ -496,17 +512,17 @@ ava_1.default("API client used when reading remote config", async (t) => {
|
|||||||
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, 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Remote config handles the case where a directory is provided", async (t) => {
|
(0, ava_1.default)("Remote config handles the case where a directory is provided", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const dummyResponse = []; // directories are returned as arrays
|
const dummyResponse = []; // directories are returned as arrays
|
||||||
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, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, 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) {
|
||||||
@@ -514,7 +530,7 @@ ava_1.default("Remote config handles the case where a directory is provided", as
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Invalid format of remote config handled correctly", async (t) => {
|
(0, ava_1.default)("Invalid format of remote config handled correctly", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const dummyResponse = {
|
const dummyResponse = {
|
||||||
// note no "content" property here
|
// note no "content" property here
|
||||||
@@ -522,7 +538,7 @@ ava_1.default("Invalid format of remote config handled correctly", async (t) =>
|
|||||||
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, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, 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) {
|
||||||
@@ -530,16 +546,16 @@ ava_1.default("Invalid format of remote config handled correctly", async (t) =>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("No detected languages", async (t) => {
|
(0, ava_1.default)("No detected languages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
mockListLanguages([]);
|
mockListLanguages([]);
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveLanguages() {
|
async resolveLanguages() {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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) {
|
||||||
@@ -547,11 +563,11 @@ ava_1.default("No detected languages", async (t) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Unknown languages", async (t) => {
|
(0, ava_1.default)("Unknown languages", async (t) => {
|
||||||
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, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, 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) {
|
||||||
@@ -559,9 +575,9 @@ ava_1.default("Unknown languages", async (t) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Config specifies packages", async (t) => {
|
(0, ava_1.default)("Config specifies packages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {},
|
byLanguage: {},
|
||||||
@@ -579,20 +595,20 @@ ava_1.default("Config specifies packages", async (t) => {
|
|||||||
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, 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]: [
|
||||||
{
|
{
|
||||||
packName: "a/b",
|
packName: "a/b",
|
||||||
version: semver_1.clean("1.2.3"),
|
version: (0, semver_1.clean)("1.2.3"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Config specifies packages for multiple languages", async (t) => {
|
(0, ava_1.default)("Config specifies packages for multiple languages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
@@ -618,18 +634,18 @@ ava_1.default("Config specifies packages for multiple languages", async (t) => {
|
|||||||
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, 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]: [
|
||||||
{
|
{
|
||||||
packName: "a/b",
|
packName: "a/b",
|
||||||
version: semver_1.clean("1.2.3"),
|
version: (0, semver_1.clean)("1.2.3"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[languages_1.Language.python]: [
|
[languages_1.Language.python]: [
|
||||||
{
|
{
|
||||||
packName: "c/d",
|
packName: "c/d",
|
||||||
version: semver_1.clean("1.2.3"),
|
version: (0, semver_1.clean)("1.2.3"),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
@@ -655,9 +671,9 @@ ava_1.default("Config specifies packages for multiple languages", async (t) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGenerator) {
|
function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGenerator) {
|
||||||
ava_1.default(`load invalid input - ${testName}`, async (t) => {
|
(0, ava_1.default)(`load invalid input - ${testName}`, async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = (0, codeql_1.setCodeQL)({
|
||||||
async resolveQueries() {
|
async resolveQueries() {
|
||||||
return {
|
return {
|
||||||
byLanguage: {},
|
byLanguage: {},
|
||||||
@@ -671,7 +687,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, 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) {
|
||||||
@@ -721,25 +737,25 @@ const validPaths = [
|
|||||||
"/foo",
|
"/foo",
|
||||||
];
|
];
|
||||||
const invalidPaths = ["a/***/b", "a/**b", "a/b**", "**"];
|
const invalidPaths = ["a/***/b", "a/**b", "a/b**", "**"];
|
||||||
ava_1.default("path validations", (t) => {
|
(0, ava_1.default)("path validations", (t) => {
|
||||||
// Dummy values to pass to validateAndSanitisePath
|
// Dummy values to pass to validateAndSanitisePath
|
||||||
const propertyName = "paths";
|
const propertyName = "paths";
|
||||||
const configFile = "./.github/codeql/config.yml";
|
const configFile = "./.github/codeql/config.yml";
|
||||||
for (const validPath of validPaths) {
|
for (const validPath of validPaths) {
|
||||||
t.truthy(configUtils.validateAndSanitisePath(validPath, propertyName, configFile, logging_1.getRunnerLogger(true)));
|
t.truthy(configUtils.validateAndSanitisePath(validPath, propertyName, configFile, (0, logging_1.getRunnerLogger)(true)));
|
||||||
}
|
}
|
||||||
for (const invalidPath of invalidPaths) {
|
for (const invalidPath of invalidPaths) {
|
||||||
t.throws(() => configUtils.validateAndSanitisePath(invalidPath, propertyName, configFile, logging_1.getRunnerLogger(true)));
|
t.throws(() => configUtils.validateAndSanitisePath(invalidPath, propertyName, configFile, (0, logging_1.getRunnerLogger)(true)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ava_1.default("path sanitisation", (t) => {
|
(0, ava_1.default)("path sanitisation", (t) => {
|
||||||
// Dummy values to pass to validateAndSanitisePath
|
// Dummy values to pass to validateAndSanitisePath
|
||||||
const propertyName = "paths";
|
const propertyName = "paths";
|
||||||
const configFile = "./.github/codeql/config.yml";
|
const configFile = "./.github/codeql/config.yml";
|
||||||
// Valid paths are not modified
|
// Valid paths are not modified
|
||||||
t.deepEqual(configUtils.validateAndSanitisePath("foo/bar", propertyName, configFile, logging_1.getRunnerLogger(true)), "foo/bar");
|
t.deepEqual(configUtils.validateAndSanitisePath("foo/bar", propertyName, configFile, (0, logging_1.getRunnerLogger)(true)), "foo/bar");
|
||||||
// Trailing stars are stripped
|
// Trailing stars are stripped
|
||||||
t.deepEqual(configUtils.validateAndSanitisePath("foo/**", propertyName, configFile, logging_1.getRunnerLogger(true)), "foo/");
|
t.deepEqual(configUtils.validateAndSanitisePath("foo/**", propertyName, configFile, (0, logging_1.getRunnerLogger)(true)), "foo/");
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* Test macro for ensuring the packs block is valid
|
* Test macro for ensuring the packs block is valid
|
||||||
@@ -766,40 +782,40 @@ function invalidPackNameMacro(t, name) {
|
|||||||
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`));
|
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`));
|
||||||
}
|
}
|
||||||
invalidPackNameMacro.title = (_, arg) => `Invalid pack string: ${arg}`;
|
invalidPackNameMacro.title = (_, arg) => `Invalid pack string: ${arg}`;
|
||||||
ava_1.default("no packs", parsePacksMacro, {}, [], {});
|
(0, ava_1.default)("no packs", parsePacksMacro, {}, [], {});
|
||||||
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]: [
|
||||||
{ packName: "a/b", version: undefined },
|
{ packName: "a/b", version: undefined },
|
||||||
{ packName: "c/d", version: semver_1.clean("1.2.3") },
|
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
ava_1.default("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], {
|
(0, ava_1.default)("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
{ packName: "a/b", version: undefined },
|
{ packName: "a/b", version: undefined },
|
||||||
{ packName: "c/d", version: semver_1.clean("1.2.3") },
|
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
ava_1.default("two packs with language", parsePacksMacro, {
|
(0, ava_1.default)("two packs with language", parsePacksMacro, {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
||||||
}, [languages_1.Language.cpp, languages_1.Language.java, languages_1.Language.csharp], {
|
}, [languages_1.Language.cpp, languages_1.Language.java, languages_1.Language.csharp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
{ packName: "a/b", version: undefined },
|
{ packName: "a/b", version: undefined },
|
||||||
{ packName: "c/d", version: semver_1.clean("1.2.3") },
|
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
|
||||||
],
|
],
|
||||||
[languages_1.Language.java]: [
|
[languages_1.Language.java]: [
|
||||||
{ packName: "d/e", version: undefined },
|
{ packName: "d/e", version: undefined },
|
||||||
{ packName: "f/g", version: semver_1.clean("1.2.3") },
|
{ packName: "f/g", version: (0, semver_1.clean)("1.2.3") },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
ava_1.default("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
|
(0, ava_1.default)("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
|
||||||
ava_1.default("invalid language", parsePacksErrorMacro, { [languages_1.Language.java]: ["c/d"] }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" has "java", but it is not one of the languages to analyze/);
|
(0, ava_1.default)("invalid language", parsePacksErrorMacro, { [languages_1.Language.java]: ["c/d"] }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" has "java", but it is not one of the languages to analyze/);
|
||||||
ava_1.default("not an array", parsePacksErrorMacro, { [languages_1.Language.cpp]: "c/d" }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/);
|
(0, ava_1.default)("not an array", parsePacksErrorMacro, { [languages_1.Language.cpp]: "c/d" }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/);
|
||||||
ava_1.default(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
|
(0, ava_1.default)(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
|
||||||
ava_1.default(invalidPackNameMacro, "c-/d");
|
(0, ava_1.default)(invalidPackNameMacro, "c-/d");
|
||||||
ava_1.default(invalidPackNameMacro, "-c/d");
|
(0, ava_1.default)(invalidPackNameMacro, "-c/d");
|
||||||
ava_1.default(invalidPackNameMacro, "c/d_d");
|
(0, ava_1.default)(invalidPackNameMacro, "c/d_d");
|
||||||
ava_1.default(invalidPackNameMacro, "c/d@x");
|
(0, ava_1.default)(invalidPackNameMacro, "c/d@x");
|
||||||
/**
|
/**
|
||||||
* Test macro for testing the packs block and the packs input
|
* Test macro for testing the packs block and the packs input
|
||||||
*/
|
*/
|
||||||
@@ -815,34 +831,34 @@ function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, langu
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`;
|
parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`;
|
||||||
ava_1.default("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [{ packName: "c/d", version: undefined }],
|
[languages_1.Language.cpp]: [{ packName: "c/d", version: undefined }],
|
||||||
});
|
});
|
||||||
ava_1.default("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
{ packName: "a/b", version: undefined },
|
{ packName: "a/b", version: undefined },
|
||||||
{ packName: "c/d", version: "1.2.3" },
|
{ packName: "c/d", version: "1.2.3" },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
ava_1.default("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
{ packName: "a/b", version: undefined },
|
{ packName: "a/b", version: undefined },
|
||||||
{ packName: "c/d", version: "1.2.3" },
|
{ packName: "c/d", version: "1.2.3" },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
ava_1.default("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
{ packName: "a/b", version: undefined },
|
{ packName: "a/b", version: undefined },
|
||||||
{ packName: "c/d", version: undefined },
|
{ packName: "c/d", version: undefined },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
ava_1.default("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
{ packName: "e/f", version: undefined },
|
{ packName: "e/f", version: undefined },
|
||||||
{ packName: "g/h", version: "1.2.3" },
|
{ packName: "g/h", version: "1.2.3" },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
ava_1.default("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
{ packName: "e/f", version: undefined },
|
{ packName: "e/f", version: undefined },
|
||||||
{ packName: "g/h", version: "1.2.3" },
|
{ packName: "g/h", version: "1.2.3" },
|
||||||
@@ -850,10 +866,54 @@ ava_1.default("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e
|
|||||||
{ packName: "c/d", version: undefined },
|
{ packName: "c/d", version: undefined },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
ava_1.default("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
|
(0, ava_1.default)("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
|
||||||
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/);
|
||||||
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 '\+'/);
|
||||||
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
|
async function mlPoweredQueriesMacro(t, codeQLVersion, isMlPoweredQueriesFlagEnabled, queriesInput, shouldRunMlPoweredQueries) {
|
||||||
// input w invalid pack name
|
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, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)(isMlPoweredQueriesFlagEnabled
|
||||||
|
? [feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled]
|
||||||
|
: []), (0, logging_1.getRunnerLogger)(true));
|
||||||
|
if (shouldRunMlPoweredQueries) {
|
||||||
|
t.deepEqual(packs, {
|
||||||
|
[languages_1.Language.javascript]: [
|
||||||
|
{
|
||||||
|
packName: "codeql/javascript-experimental-atm-queries",
|
||||||
|
version: "~0.0.2",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
t.deepEqual(packs, {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
mlPoweredQueriesMacro.title = (_providedTitle, codeQLVersion, isMlPoweredQueriesFlagEnabled, queriesInput, shouldRunMlPoweredQueries) => {
|
||||||
|
const queriesInputDescription = queriesInput
|
||||||
|
? `'queries: ${queriesInput}'`
|
||||||
|
: "default config";
|
||||||
|
return `ML-powered queries ${shouldRunMlPoweredQueries ? "are" : "aren't"} loaded for ${queriesInputDescription} using CLI v${codeQLVersion} when feature flag is ${isMlPoweredQueriesFlagEnabled ? "enabled" : "disabled"}`;
|
||||||
|
};
|
||||||
|
// macro, isMlPoweredQueriesFlagEnabled, queriesInput, shouldRunMlPoweredQueries
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.4", true, "security-extended", false);
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", false, "security-extended", false);
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, false);
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, "security-extended", true);
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, "security-and-quality", true);
|
||||||
//# sourceMappingURL=config-utils.test.js.map
|
//# sourceMappingURL=config-utils.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
23
lib/count-loc.js
generated
23
lib/count-loc.js
generated
@@ -1,8 +1,8 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.countLoc = void 0;
|
||||||
const github_linguist_1 = require("github-linguist");
|
const github_linguist_1 = require("github-linguist");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const util_1 = require("./util");
|
|
||||||
// Map from linguist language names to language prefixes used in the action and codeql
|
// Map from linguist language names to language prefixes used in the action and codeql
|
||||||
const linguistToMetrics = {
|
const linguistToMetrics = {
|
||||||
c: languages_1.Language.cpp,
|
c: languages_1.Language.cpp,
|
||||||
@@ -22,27 +22,6 @@ const nameToLinguist = Object.entries(linguistToMetrics).reduce((obj, [key, name
|
|||||||
obj[name].push(key);
|
obj[name].push(key);
|
||||||
return obj;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
function getIdPrefix(language) {
|
|
||||||
switch (language) {
|
|
||||||
case languages_1.Language.cpp:
|
|
||||||
return "cpp";
|
|
||||||
case languages_1.Language.csharp:
|
|
||||||
return "cs";
|
|
||||||
case languages_1.Language.go:
|
|
||||||
return "go";
|
|
||||||
case languages_1.Language.java:
|
|
||||||
return "java";
|
|
||||||
case languages_1.Language.javascript:
|
|
||||||
return "js";
|
|
||||||
case languages_1.Language.python:
|
|
||||||
return "py";
|
|
||||||
case languages_1.Language.ruby:
|
|
||||||
return "rb";
|
|
||||||
default:
|
|
||||||
util_1.assertNever(language);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.getIdPrefix = getIdPrefix;
|
|
||||||
/**
|
/**
|
||||||
* Count the lines of code of the specified language using the include
|
* Count the lines of code of the specified language using the include
|
||||||
* and exclude glob paths.
|
* and exclude glob paths.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"count-loc.js","sourceRoot":"","sources":["../src/count-loc.ts"],"names":[],"mappings":";;AAAA,qDAAyC;AAEzC,2CAAuC;AAEvC,iCAAqC;AAKrC,sFAAsF;AACtF,M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2E;YACzE,gEAAgE;YAChE,4EAA4E;YAC5E,4EAA4E;YAC5E,2EAA2E;YAC3E,6EAA6E;YAC7E,2CAA2C,CAC9C,CAAC;KACH;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AA9CD,4BA8CC"}
|
||||||
46
lib/count-loc.test.js
generated
46
lib/count-loc.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -16,49 +28,49 @@ const count_loc_1 = require("./count-loc");
|
|||||||
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");
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
ava_1.default("ensure lines of code works for cpp and js", async (t) => {
|
(0, ava_1.default)("ensure lines of code works for cpp and js", async (t) => {
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], [], [languages_1.Language.cpp, languages_1.Language.javascript], logging_1.getRunnerLogger(true));
|
const results = await (0, count_loc_1.countLoc)(path.join(__dirname, "../tests/multi-language-repo"), [], [], [languages_1.Language.cpp, languages_1.Language.javascript], (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(results, {
|
t.deepEqual(results, {
|
||||||
cpp: 6,
|
cpp: 6,
|
||||||
javascript: 9,
|
javascript: 9,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("ensure lines of code works for csharp", async (t) => {
|
(0, ava_1.default)("ensure lines of code works for csharp", async (t) => {
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], [], [languages_1.Language.csharp], logging_1.getRunnerLogger(true));
|
const results = await (0, count_loc_1.countLoc)(path.join(__dirname, "../tests/multi-language-repo"), [], [], [languages_1.Language.csharp], (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(results, {
|
t.deepEqual(results, {
|
||||||
csharp: 10,
|
csharp: 10,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("ensure lines of code can handle undefined language", async (t) => {
|
(0, ava_1.default)("ensure lines of code can handle undefined language", async (t) => {
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], [], [languages_1.Language.javascript, languages_1.Language.python, "hucairz"], logging_1.getRunnerLogger(true));
|
const results = await (0, count_loc_1.countLoc)(path.join(__dirname, "../tests/multi-language-repo"), [], [], [languages_1.Language.javascript, languages_1.Language.python, "hucairz"], (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(results, {
|
t.deepEqual(results, {
|
||||||
javascript: 9,
|
javascript: 9,
|
||||||
python: 5,
|
python: 5,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("ensure lines of code can handle empty languages", async (t) => {
|
(0, ava_1.default)("ensure lines of code can handle empty languages", async (t) => {
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], [], [], logging_1.getRunnerLogger(true));
|
const results = await (0, count_loc_1.countLoc)(path.join(__dirname, "../tests/multi-language-repo"), [], [], [], (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(results, {});
|
t.deepEqual(results, {});
|
||||||
});
|
});
|
||||||
ava_1.default("ensure lines of code can handle includes", async (t) => {
|
(0, ava_1.default)("ensure lines of code can handle includes", async (t) => {
|
||||||
// note that "**" is always included. The includes are for extra
|
// note that "**" is always included. The includes are for extra
|
||||||
// directories outside the normal structure.
|
// directories outside the normal structure.
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), ["../../src/testdata"], [], [languages_1.Language.javascript], logging_1.getRunnerLogger(true));
|
const results = await (0, count_loc_1.countLoc)(path.join(__dirname, "../tests/multi-language-repo"), ["../../src/testdata"], [], [languages_1.Language.javascript], (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(results, {
|
t.deepEqual(results, {
|
||||||
javascript: 12,
|
javascript: 12,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("ensure lines of code can handle empty includes", async (t) => {
|
(0, ava_1.default)("ensure lines of code can handle empty includes", async (t) => {
|
||||||
// note that "**" is always included. The includes are for extra
|
// note that "**" is always included. The includes are for extra
|
||||||
// directories outside the normal structure.
|
// directories outside the normal structure.
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), ["idontexist"], [], [languages_1.Language.javascript], logging_1.getRunnerLogger(true));
|
const results = await (0, count_loc_1.countLoc)(path.join(__dirname, "../tests/multi-language-repo"), ["idontexist"], [], [languages_1.Language.javascript], (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(results, {
|
t.deepEqual(results, {
|
||||||
// should get no results
|
// should get no results
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("ensure lines of code can handle exclude", async (t) => {
|
(0, ava_1.default)("ensure lines of code can handle exclude", async (t) => {
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], ["**/*.py"], [languages_1.Language.javascript, languages_1.Language.python], logging_1.getRunnerLogger(true));
|
const results = await (0, count_loc_1.countLoc)(path.join(__dirname, "../tests/multi-language-repo"), [], ["**/*.py"], [languages_1.Language.javascript, languages_1.Language.python], (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(results, {
|
t.deepEqual(results, {
|
||||||
javascript: 9,
|
javascript: 9,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"count-loc.test.js","sourceRoot":"","sources":["../src/count-loc.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6B;AAE7B,8CAAuB;AAEvB,2CAAuC;AACvC,2CAAuC;AACvC,uCAA4C;AAC5C,mDAA6C;AAE7C,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,2CAA2C,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC5D,MAAM,OAAO,GAAG,MAAM,oBAAQ,CAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,8BAA8B,CAAC,EACpD,EAAE,EACF,EAAE,EACF,CAAC,oBAAQ,CAAC,GAAG,EAAE,oBAAQ,CAAC,UAAU,CAAC,EACnC,yBAAe,CAAC,IAAI,CAAC,CACtB,CAAC;IAEF,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE;QACnB,GAAG,EAAE,CAAC;QACN,UAAU,EAAE,CAAC;KACd,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH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AC,CACtB,CAAC;IAEF,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE;IACnB,wBAAwB;KACzB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,yCAAyC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC1D,MAAM,OAAO,GAAG,MAAM,IAAA,oBAAQ,EAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,8BAA8B,CAAC,EACpD,EAAE,EACF,CAAC,SAAS,CAAC,EACX,CAAC,oBAAQ,CAAC,UAAU,EAAE,oBAAQ,CAAC,MAAM,CAAC,EACtC,IAAA,yBAAe,EAAC,IAAI,CAAC,CACtB,CAAC;IAEF,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE;QACnB,UAAU,EAAE,CAAC;KACd,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
79
lib/database-upload.js
generated
79
lib/database-upload.js
generated
@@ -1,18 +1,33 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.uploadDatabases = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
|
const util_1 = require("./util");
|
||||||
|
async function uploadDatabases(repositoryNwo, config, featureFlags, apiDetails, logger) {
|
||||||
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
|
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
|
||||||
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
||||||
return;
|
return;
|
||||||
@@ -27,38 +42,40 @@ async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
|
|||||||
logger.debug("Not analyzing default branch. Skipping upload.");
|
logger.debug("Not analyzing default branch. Skipping upload.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const client = api_client_1.getApiClient(apiDetails);
|
if (!(await featureFlags.getValue(feature_flags_1.FeatureFlag.DatabaseUploadsEnabled))) {
|
||||||
try {
|
logger.debug("Repository is not opted in to database uploads. Skipping upload.");
|
||||||
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;
|
return;
|
||||||
}
|
}
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
const client = (0, api_client_1.getApiClient)(apiDetails);
|
||||||
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
|
const useUploadDomain = await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled);
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
// 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`, {
|
if (useUploadDomain) {
|
||||||
owner: repositoryNwo.owner,
|
await client.request(`POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name`, {
|
||||||
repo: repositoryNwo.repo,
|
owner: repositoryNwo.owner,
|
||||||
language,
|
repo: repositoryNwo.repo,
|
||||||
data: payload,
|
language,
|
||||||
});
|
name: `${language}-database`,
|
||||||
|
data: payload,
|
||||||
|
headers: {
|
||||||
|
authorization: `token ${apiDetails.auth}`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await client.request(`PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language`, {
|
||||||
|
owner: repositoryNwo.owner,
|
||||||
|
repo: repositoryNwo.repo,
|
||||||
|
language,
|
||||||
|
data: payload,
|
||||||
|
});
|
||||||
|
}
|
||||||
logger.debug(`Successfully uploaded database for ${language}`);
|
logger.debug(`Successfully uploaded database for ${language}`);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|||||||
@@ -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,CAAC,wDAAwD,CAAC,CAAC;QACvE,OAAO;KACR;IAED,iDAAiD;IACjD,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;QAC3D,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,OAAO;KACR;IAED,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,wBAAwB,EAAE,CAAC,EAAE;QACnD,4EAA4E;QAC5E,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO;KACR;IAED,MAAM,MAAM,GAAG,yBAAY,CAAC,UAAU,CAAC,CAAC;IACxC,IAAI;QACF,MAAM,MAAM,CAAC,OAAO,CAClB,wDAAwD,EACxD;YACE,KAAK,EAAE,aAAa,CAAC,KAAK;YAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;SACzB,CACF,CAAC;KACH;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AE,CAAC,YAAY,CAC7B,MAAM,IAAA,eAAQ,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CACnD,CAAC;QACF,IAAI;YACF,IAAI,eAAe,EAAE;gBACnB,MAAM,MAAM,CAAC,OAAO,CAClB,wGAAwG,EACxG;oBACE,KAAK,EAAE,aAAa,CAAC,KAAK;oBAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;oBACxB,QAAQ;oBACR,IAAI,EAAE,GAAG,QAAQ,WAAW;oBAC5B,IAAI,EAAE,OAAO;oBACb,OAAO,EAAE;wBACP,aAAa,EAAE,SAAS,UAAU,CAAC,IAAI,EAAE;qBAC1C;iBACF,CACF,CAAC;aACH;iBAAM;gBACL,MAAM,MAAM,CAAC,OAAO,CAClB,kEAAkE,EAClE;oBACE,KAAK,EAAE,aAAa,CAAC,KAAK;oBAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;oBACxB,QAAQ;oBACR,IAAI,EAAE,OAAO;iBACd,CACF,CAAC;aACH;YACD,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;AA9ED,0CA8EC"}
|
||||||
218
lib/database-upload.test.js
generated
218
lib/database-upload.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -13,18 +25,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const github = __importStar(require("@actions/github"));
|
const github = __importStar(require("@actions/github"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const apiClient = __importStar(require("./api-client"));
|
const apiClient = __importStar(require("./api-client"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const database_upload_1 = require("./database-upload");
|
const database_upload_1 = require("./database-upload");
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
ava_1.default.beforeEach(() => {
|
ava_1.default.beforeEach(() => {
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
||||||
});
|
});
|
||||||
|
const uploadToUploadsDomainFlags = (0, feature_flags_1.createFeatureFlags)([
|
||||||
|
feature_flags_1.FeatureFlag.DatabaseUploadsEnabled,
|
||||||
|
feature_flags_1.FeatureFlag.UploadsDomainEnabled,
|
||||||
|
]);
|
||||||
const testRepoName = { owner: "github", repo: "example" };
|
const testRepoName = { owner: "github", repo: "example" };
|
||||||
const testApiDetails = {
|
const testApiDetails = {
|
||||||
auth: "1234",
|
auth: "1234",
|
||||||
@@ -43,192 +60,167 @@ 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,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function getRecordingLogger(messages) {
|
async function mockHttpRequests(featureFlags, 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_1.default.stub(client, "request");
|
const requestSpy = sinon.stub(client, "request");
|
||||||
const optInSpy = requestSpy.withArgs("GET /repos/:owner/:repo/code-scanning/codeql/databases");
|
const url = (await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled))
|
||||||
if (optInStatusCode < 300) {
|
? "POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name"
|
||||||
optInSpy.resolves(undefined);
|
: "PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language";
|
||||||
|
const databaseUploadSpy = requestSpy.withArgs(url);
|
||||||
|
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) {
|
sinon.stub(apiClient, "getApiClient").value(() => client);
|
||||||
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_1.default.stub(apiClient, "getApiClient").value(() => client);
|
|
||||||
}
|
}
|
||||||
ava_1.default("Abort database upload if 'upload-database' input set to false", async (t) => {
|
(0, ava_1.default)("Abort database upload if 'upload-database' input set to false", async (t) => {
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon_1.default
|
sinon
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("false");
|
.returns("false");
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Abort database upload if running against GHES", async (t) => {
|
(0, ava_1.default)("Abort database upload if running against GHES", async (t) => {
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon_1.default
|
sinon
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
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 database_upload_1.uploadDatabases(testRepoName, config, testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, config, (0, feature_flags_1.createFeatureFlags)([]), 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Abort database upload if running against GHAE", async (t) => {
|
(0, ava_1.default)("Abort database upload if running against GHAE", async (t) => {
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon_1.default
|
sinon
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
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 database_upload_1.uploadDatabases(testRepoName, config, testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, config, (0, feature_flags_1.createFeatureFlags)([]), 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Abort database upload if not analyzing default branch", async (t) => {
|
(0, ava_1.default)("Abort database upload if not analyzing default branch", async (t) => {
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon_1.default
|
sinon
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Abort database upload if opt-in request returns 404", async (t) => {
|
(0, ava_1.default)("Abort database upload if feature flag is disabled", async (t) => {
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon_1.default
|
sinon
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
mockHttpRequests(404);
|
(0, codeql_1.setCodeQL)({
|
||||||
codeql_1.setCodeQL({
|
|
||||||
async databaseBundle() {
|
async databaseBundle() {
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.UploadsDomainEnabled]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message ===
|
v.message ===
|
||||||
"Repository is not opted in to database uploads. Skipping upload.") !== undefined);
|
"Repository is not opted in to database uploads. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Abort database upload if opt-in request fails with something other than 404", async (t) => {
|
(0, ava_1.default)("Don't crash if uploading a database fails", async (t) => {
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon_1.default
|
sinon
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
mockHttpRequests(500);
|
const featureFlags = (0, feature_flags_1.createFeatureFlags)([
|
||||||
codeql_1.setCodeQL({
|
feature_flags_1.FeatureFlag.DatabaseUploadsEnabled,
|
||||||
async databaseBundle() {
|
]);
|
||||||
return;
|
await mockHttpRequests(featureFlags, 500);
|
||||||
},
|
(0, codeql_1.setCodeQL)({
|
||||||
});
|
|
||||||
const loggedMessages = [];
|
|
||||||
await 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);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Don't crash if uploading a database fails", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon_1.default
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
mockHttpRequests(204, 500);
|
|
||||||
codeql_1.setCodeQL({
|
|
||||||
async databaseBundle(_, outputFilePath) {
|
async databaseBundle(_, outputFilePath) {
|
||||||
fs.writeFileSync(outputFilePath, "");
|
fs.writeFileSync(outputFilePath, "");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), featureFlags, 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);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Successfully uploading a database", async (t) => {
|
(0, ava_1.default)("Successfully uploading a database to api.github.com", async (t) => {
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon_1.default
|
sinon
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
mockHttpRequests(204, 201);
|
await mockHttpRequests(uploadToUploadsDomainFlags, 201);
|
||||||
codeql_1.setCodeQL({
|
(0, codeql_1.setCodeQL)({
|
||||||
async databaseBundle(_, outputFilePath) {
|
async databaseBundle(_, outputFilePath) {
|
||||||
fs.writeFileSync(outputFilePath, "");
|
fs.writeFileSync(outputFilePath, "");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, 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(uploadToUploadsDomainFlags, 201);
|
||||||
|
(0, codeql_1.setCodeQL)({
|
||||||
|
async databaseBundle(_, outputFilePath) {
|
||||||
|
fs.writeFileSync(outputFilePath, "");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const loggedMessages = [];
|
||||||
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, 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-20210702"
|
"bundleVersion": "codeql-bundle-20220112"
|
||||||
}
|
}
|
||||||
|
|||||||
1
lib/error-matcher.js
generated
1
lib/error-matcher.js
generated
@@ -1,5 +1,6 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.errorMatchers = exports.namedMatchersForTesting = void 0;
|
||||||
// exported only for testing purposes
|
// exported only for testing purposes
|
||||||
exports.namedMatchersForTesting = {
|
exports.namedMatchersForTesting = {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"error-matcher.js","sourceRoot":"","sources":["../src/error-matcher.ts"],"names":[],"mappings":";;AAQA,qCAAqC;AACxB,QAAA,uBAAuB,GAAoC;IACtE;;MAEE;IACF,iBAAiB,EAAE;QACjB,QAAQ,EAAE,EAAE;QACZ,WAAW,EAAE,IAAI,MAAM,CAAC,2CAA2C,CAAC;QACpE,OAAO,EACL,+CAA+C;YAC/C,yJAAyJ;KAC5J;CACF,CAAC;AAEF,oEAAoE;AACvD,QAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,+BAAuB,CAAC,CAAC"}
|
{"version":3,"file":"error-matcher.js","sourceRoot":"","sources":["../src/error-matcher.ts"],"names":[],"mappings":";;;AAQA,qCAAqC;AACxB,QAAA,uBAAuB,GAAoC;IACtE;;MAEE;IACF,iBAAiB,EAAE;QACjB,QAAQ,EAAE,EAAE;QACZ,WAAW,EAAE,IAAI,MAAM,CAAC,2CAA2C,CAAC;QACpE,OAAO,EACL,+CAA+C;YAC/C,yJAAyJ;KAC5J;CACF,CAAC;AAEF,oEAAoE;AACvD,QAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,+BAAuB,CAAC,CAAC"}
|
||||||
2
lib/error-matcher.test.js
generated
2
lib/error-matcher.test.js
generated
@@ -8,7 +8,7 @@ const error_matcher_1 = require("./error-matcher");
|
|||||||
/*
|
/*
|
||||||
NB We test the regexes for all the matchers against example log output snippets.
|
NB We test the regexes for all the matchers against example log output snippets.
|
||||||
*/
|
*/
|
||||||
ava_1.default("noSourceCodeFound matches against example javascript output", async (t) => {
|
(0, ava_1.default)("noSourceCodeFound matches against example javascript output", async (t) => {
|
||||||
t.assert(testErrorMatcher("noSourceCodeFound", `
|
t.assert(testErrorMatcher("noSourceCodeFound", `
|
||||||
2020-09-07T17:39:53.9050522Z [2020-09-07 17:39:53] [build] Done extracting /opt/hostedtoolcache/CodeQL/0.0.0-20200630/x64/codeql/javascript/tools/data/externs/web/ie_vml.js (3 ms)
|
2020-09-07T17:39:53.9050522Z [2020-09-07 17:39:53] [build] Done extracting /opt/hostedtoolcache/CodeQL/0.0.0-20200630/x64/codeql/javascript/tools/data/externs/web/ie_vml.js (3 ms)
|
||||||
2020-09-07T17:39:53.9051849Z [2020-09-07 17:39:53] [build-err] No JavaScript or TypeScript code found.
|
2020-09-07T17:39:53.9051849Z [2020-09-07 17:39:53] [build-err] No JavaScript or TypeScript code found.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"error-matcher.test.js","sourceRoot":"","sources":["../src/error-matcher.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAEvB,mDAA0D;AAE1D;;EAEE;AAEF,aAAI,CAAC,6DAA6D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC9E,CAAC,CAAC,MAAM,CACN,gBAAgB,CACd,mBAAmB,EACnB;;;;;GAKH,CACE,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,WAAmB,EAAE,SAAiB;IAC9D,IAAI,CAAC,CAAC,WAAW,IAAI,uCAAuB,CAAC,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,mBAAmB,WAAW,EAAE,CAAC,CAAC;KACnD;IACD,MAAM,KAAK,GAAG,uCAAuB,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC;IAC/D,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,uBAAuB,WAAW,kBAAkB,CAAC,CAAC;KACvE;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC"}
|
{"version":3,"file":"error-matcher.test.js","sourceRoot":"","sources":["../src/error-matcher.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAEvB,mDAA0D;AAE1D;;EAEE;AAEF,IAAA,aAAI,EAAC,6DAA6D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC9E,CAAC,CAAC,MAAM,CACN,gBAAgB,CACd,mBAAmB,EACnB;;;;;GAKH,CACE,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,WAAmB,EAAE,SAAiB;IAC9D,IAAI,CAAC,CAAC,WAAW,IAAI,uCAAuB,CAAC,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,mBAAmB,WAAW,EAAE,CAAC,CAAC;KACnD;IACD,MAAM,KAAK,GAAG,uCAAuB,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC;IAC/D,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,uBAAuB,WAAW,kBAAkB,CAAC,CAAC;KACvE;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC"}
|
||||||
17
lib/external-queries.js
generated
17
lib/external-queries.js
generated
@@ -1,12 +1,25 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.buildCheckoutURL = exports.checkoutExternalRepository = 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"));
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"external-queries.js","sourceRoot":"","sources":["../src/external-queries.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAKpD;;GAEG;AACI,KAAK,UAAU,0BAA0B,CAC9C,UAAkB,EAClB,GAAW,EACX,UAAwC,EACxC,OAAe,EACf,MAAc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X;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAlCD,gEAkCC;AAED,SAAgB,gBAAgB,CAC9B,UAAkB,EAClB,UAAwC;IAExC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,UAAU,CAAC,gBAAgB,KAAK,SAAS,EAAE;QAC7C,YAAY,CAAC,QAAQ,GAAG,gBAAgB,CAAC;QACzC,YAAY,CAAC,QAAQ,GAAG,UAAU,CAAC,gBAAgB,CAAC;KACrD;IACD,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACxC,YAAY,CAAC,QAAQ,IAAI,GAAG,CAAC;KAC9B;IACD,YAAY,CAAC,QAAQ,IAAI,GAAG,UAAU,EAAE,CAAC;IACzC,OAAO,YAAY,CAAC,QAAQ,EAAE,CAAC;AACjC,CAAC;AAdD,4CAcC"}
|
||||||
26
lib/external-queries.test.js
generated
26
lib/external-queries.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -19,8 +31,8 @@ const externalQueries = __importStar(require("./external-queries"));
|
|||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
ava_1.default("checkoutExternalQueries", async (t) => {
|
(0, ava_1.default)("checkoutExternalQueries", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
// Create a test repo in a subdir of the temp dir.
|
// Create a test repo in a subdir of the temp dir.
|
||||||
// It should have a default branch with two commits after the initial commit, where
|
// It should have a default branch with two commits after the initial commit, where
|
||||||
@@ -81,20 +93,20 @@ ava_1.default("checkoutExternalQueries", async (t) => {
|
|||||||
const commit2Sha = await runGit(["rev-parse", "HEAD"]);
|
const commit2Sha = await runGit(["rev-parse", "HEAD"]);
|
||||||
// Checkout the first commit, which should contain 'a' and 'b'
|
// Checkout the first commit, which should contain 'a' and 'b'
|
||||||
t.false(fs.existsSync(path.join(tmpDir, repoName)));
|
t.false(fs.existsSync(path.join(tmpDir, repoName)));
|
||||||
await externalQueries.checkoutExternalRepository(repoName, commit1Sha, { url: `file://${testRepoBaseDir}`, externalRepoAuth: "" }, tmpDir, logging_1.getRunnerLogger(true));
|
await externalQueries.checkoutExternalRepository(repoName, commit1Sha, { url: `file://${testRepoBaseDir}`, externalRepoAuth: "" }, tmpDir, (0, logging_1.getRunnerLogger)(true));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName)));
|
t.true(fs.existsSync(path.join(tmpDir, repoName)));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha)));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha)));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha, "a")));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha, "a")));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha, "b")));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha, "b")));
|
||||||
// Checkout the second commit as well, which should only contain 'a'
|
// Checkout the second commit as well, which should only contain 'a'
|
||||||
t.false(fs.existsSync(path.join(tmpDir, repoName, commit2Sha)));
|
t.false(fs.existsSync(path.join(tmpDir, repoName, commit2Sha)));
|
||||||
await externalQueries.checkoutExternalRepository(repoName, commit2Sha, { url: `file://${testRepoBaseDir}`, externalRepoAuth: "" }, tmpDir, logging_1.getRunnerLogger(true));
|
await externalQueries.checkoutExternalRepository(repoName, commit2Sha, { url: `file://${testRepoBaseDir}`, externalRepoAuth: "" }, tmpDir, (0, logging_1.getRunnerLogger)(true));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit2Sha)));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit2Sha)));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit2Sha, "a")));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit2Sha, "a")));
|
||||||
t.false(fs.existsSync(path.join(tmpDir, repoName, commit2Sha, "b")));
|
t.false(fs.existsSync(path.join(tmpDir, repoName, commit2Sha, "b")));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("buildCheckoutURL", (t) => {
|
(0, ava_1.default)("buildCheckoutURL", (t) => {
|
||||||
t.deepEqual(externalQueries.buildCheckoutURL("foo/bar", {
|
t.deepEqual(externalQueries.buildCheckoutURL("foo/bar", {
|
||||||
url: "https://github.com",
|
url: "https://github.com",
|
||||||
externalRepoAuth: undefined,
|
externalRepoAuth: undefined,
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"external-queries.test.js","sourceRoot":"","sources":["../src/external-queries.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AACpD,8CAAuB;AAEvB,oEAAsD;AACtD,uCAA4C;AAC5C,mDAA6C;AAC7C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,yBAAyB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC1C,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,kDAAkD;QAClD,mFAAmF;QACnF,gDAAgD;QAChD,wCAAwC;QACxC,8EAA8E;QAC9E,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,WAAW,CAAC;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE/C,oDAAoD;QACpD,oCAAoC;QACpC,2DAA2D;QAC3D,MAAM,MAAM,GAAG,KAAK,WAAW,OAAiB;YAC9C,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,OAAO,GAAG;gBACR,aAAa,UAAU,EAAE;gBACzB,eAAe,QAAQ,EAAE;gBACzB,GAAG,OAAO;aACX,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,CAAC,IAAI,CAAC,G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CAAC;AAEH,aAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE;IAC7B,CAAC,CAAC,SAAS,CACT,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE;QAC1C,GAAG,EAAE,oBAAoB;QACzB,gBAAgB,EAAE,SAAS;KAC5B,CAAC,EACF,4BAA4B,CAC7B,CAAC;IACF,CAAC,CAAC,SAAS,CACT,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE;QAC1C,GAAG,EAAE,6BAA6B;QAClC,gBAAgB,EAAE,SAAS;KAC5B,CAAC,EACF,oCAAoC,CACrC,CAAC;IAEF,CAAC,CAAC,SAAS,CACT,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE;QAC1C,GAAG,EAAE,oBAAoB;QACzB,gBAAgB,EAAE,KAAK;KACxB,CAAC,EACF,+CAA+C,CAChD,CAAC;IACF,CAAC,CAAC,SAAS,CACT,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE;QAC1C,GAAG,EAAE,6BAA6B;QAClC,gBAAgB,EAAE,KAAK;KACxB,CAAC,EACF,uDAAuD,CACxD,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
{"version":3,"file":"external-queries.test.js","sourceRoot":"","sources":["../src/external-queries.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AACpD,8CAAuB;AAEvB,oEAAsD;AACtD,uCAA4C;AAC5C,mDAA6C;AAC7C,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,IAAA,aAAI,EAAC,yBAAyB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC1C,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,kDAAkD;QAClD,mFAAmF;QACnF,gDAAgD;QAChD,wCAAwC;QACxC,8EAA8E;QAC9E,MAAM,eAA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6BAA6B;QAClC,gBAAgB,EAAE,KAAK;KACxB,CAAC,EACF,uDAAuD,CACxD,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
||||||
91
lib/feature-flags.js
generated
Normal file
91
lib/feature-flags.js
generated
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
"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["DatabaseUploadsEnabled"] = "database_uploads_enabled";
|
||||||
|
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
||||||
|
FeatureFlag["UploadsDomainEnabled"] = "uploads_domain_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 preloadFeatureFlags() {
|
||||||
|
await this.getApiResponse();
|
||||||
|
}
|
||||||
|
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) {
|
||||||
|
// 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,WAIX;AAJD,WAAY,WAAW;IACrB,kEAAmD,CAAA;IACnD,qEAAsD,CAAA;IACtD,8DAA+C,CAAA;AACjD,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAUD,MAAa,kBAAkB;IAG7B,YACU,aAAiC,EACjC,UAA4B,EAC5B,aAA4B,EAC5B,MAAc;QAHd,kBAAa,GAAb,aAAa,CAAoB;QACjC,eAAU,GAAV,UAAU,CAAkB;QAC5B,kBAAa,GAAb,aAAa,CAAe;QAC5B,WAAM,GAAN,MAAM,CAAQ;IACrB,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,IAAiB;QAC9B,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACrD,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,iBAAiB,IAAI,uDAAuD,CAC7E,CAAC;YACF,OAAO,KAAK,CAAC;SACd;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC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ags.test.js
generated
Normal file
98
lib/feature-flags.test.js
generated
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
"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 [
|
||||||
|
"database_uploads_enabled",
|
||||||
|
"ml_powered_queries_enabled",
|
||||||
|
"uploads_domain_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.preloadFeatureFlags(), {
|
||||||
|
message: "Encountered an error while trying to load feature flags: Error: some error message",
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
const FEATURE_FLAGS = [
|
||||||
|
"database_uploads_enabled",
|
||||||
|
"ml_powered_queries_enabled",
|
||||||
|
"uploads_domain_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 = {
|
||||||
|
database_uploads_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.DatabaseUploadsEnabled),
|
||||||
|
ml_powered_queries_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled),
|
||||||
|
uploads_domain_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled),
|
||||||
|
};
|
||||||
|
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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C;YAChC,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE;gBAC7B,oBAAoB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;aACjC;YACD,oBAAoB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;YACzC,IAAA,0CAA0B,EAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;YAEtD,MAAM,kBAAkB,GAAG;gBACzB,wBAAwB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACnD,2BAAW,CAAC,sBAAsB,CACnC;gBACD,0BAA0B,EAAE,MAAM,YAAY,CAAC,QAAQ,CACrD,2BAAW,CAAC,uBAAuB,CACpC;gBACD,sBAAsB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACjD,2BAAW,CAAC,oBAAoB,CACjC;aACF,CAAC;YAEF,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ"}
|
||||||
28
lib/fingerprints.js
generated
28
lib/fingerprints.js
generated
@@ -1,15 +1,28 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
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.addFingerprints = exports.resolveUriToFile = exports.hash = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const long_1 = __importDefault(require("long"));
|
const long_1 = __importDefault(require("long"));
|
||||||
const tab = "\t".charCodeAt(0);
|
const tab = "\t".charCodeAt(0);
|
||||||
@@ -213,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, _d, _e;
|
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 = {};
|
||||||
@@ -225,11 +237,11 @@ async function addFingerprints(sarifContents, sourceRoot, logger) {
|
|||||||
for (const result of run.results || []) {
|
for (const result of run.results || []) {
|
||||||
// Check the primary location is defined correctly and is in the src root
|
// Check the primary location is defined correctly and is in the src root
|
||||||
const primaryLocation = (result.locations || [])[0];
|
const primaryLocation = (result.locations || [])[0];
|
||||||
if (!((_b = (_a = primaryLocation) === null || _a === void 0 ? void 0 : _a.physicalLocation) === null || _b === void 0 ? void 0 : _b.artifactLocation)) {
|
if (!((_a = primaryLocation === null || primaryLocation === void 0 ? void 0 : primaryLocation.physicalLocation) === null || _a === void 0 ? void 0 : _a.artifactLocation)) {
|
||||||
logger.debug(`Unable to compute fingerprint for invalid location: ${JSON.stringify(primaryLocation)}`);
|
logger.debug(`Unable to compute fingerprint for invalid location: ${JSON.stringify(primaryLocation)}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (((_e = (_d = (_c = primaryLocation) === null || _c === void 0 ? void 0 : _c.physicalLocation) === null || _d === void 0 ? void 0 : _d.region) === null || _e === void 0 ? void 0 : _e.startLine) === undefined) {
|
if (((_c = (_b = primaryLocation === null || primaryLocation === void 0 ? void 0 : primaryLocation.physicalLocation) === null || _b === void 0 ? void 0 : _b.region) === null || _c === void 0 ? void 0 : _c.startLine) === undefined) {
|
||||||
// Locations without a line number are unlikely to be source files
|
// Locations without a line number are unlikely to be source files
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -253,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
54
lib/fingerprints.test.js
generated
54
lib/fingerprints.test.js
generated
@@ -1,9 +1,21 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -17,7 +29,7 @@ const fingerprints = __importStar(require("./fingerprints"));
|
|||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
async function testHash(t, input, expectedHashes) {
|
async function testHash(t, input, expectedHashes) {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
const tmpFile = path.resolve(tmpDir, "testfile");
|
const tmpFile = path.resolve(tmpDir, "testfile");
|
||||||
@@ -32,7 +44,7 @@ async function testHash(t, input, expectedHashes) {
|
|||||||
t.is(index, input.split(/\r\n|\r|\n/).length);
|
t.is(index, input.split(/\r\n|\r|\n/).length);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ava_1.default("hash", async (t) => {
|
(0, ava_1.default)("hash", async (t) => {
|
||||||
// Try empty file
|
// Try empty file
|
||||||
await testHash(t, "", ["c129715d7a2bc9a3:1"]);
|
await testHash(t, "", ["c129715d7a2bc9a3:1"]);
|
||||||
// Try various combinations of newline characters
|
// Try various combinations of newline characters
|
||||||
@@ -116,9 +128,9 @@ function testResolveUriToFile(uri, index, artifactsURIs) {
|
|||||||
const artifacts = artifactsURIs.map((artifactURI) => ({
|
const artifacts = artifactsURIs.map((artifactURI) => ({
|
||||||
location: { uri: artifactURI },
|
location: { uri: artifactURI },
|
||||||
}));
|
}));
|
||||||
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), logging_1.getRunnerLogger(true));
|
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), (0, logging_1.getRunnerLogger)(true));
|
||||||
}
|
}
|
||||||
ava_1.default("resolveUriToFile", (t) => {
|
(0, ava_1.default)("resolveUriToFile", (t) => {
|
||||||
// The resolveUriToFile method checks that the file exists and is in the right directory
|
// The resolveUriToFile method checks that the file exists and is in the right directory
|
||||||
// so we need to give it real files to look at. We will use this file as an example.
|
// so we need to give it real files to look at. We will use this file as an example.
|
||||||
// For this to work we require the current working directory to be a parent, but this
|
// For this to work we require the current working directory to be a parent, but this
|
||||||
@@ -155,34 +167,28 @@ ava_1.default("resolveUriToFile", (t) => {
|
|||||||
t.is(testResolveUriToFile(dirpath, undefined, []), undefined);
|
t.is(testResolveUriToFile(dirpath, undefined, []), undefined);
|
||||||
t.is(testResolveUriToFile(`file://${dirpath}`, undefined, []), undefined);
|
t.is(testResolveUriToFile(`file://${dirpath}`, undefined, []), undefined);
|
||||||
});
|
});
|
||||||
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, logging_1.getRunnerLogger(true)), expected);
|
t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, (0, logging_1.getRunnerLogger)(true)), expected);
|
||||||
});
|
});
|
||||||
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, logging_1.getRunnerLogger(true)), expected);
|
t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, (0, logging_1.getRunnerLogger)(true)), expected);
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=fingerprints.test.js.map
|
//# sourceMappingURL=fingerprints.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
94
lib/init-action.js
generated
94
lib/init-action.js
generated
@@ -1,15 +1,29 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
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 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");
|
||||||
@@ -19,16 +33,16 @@ const util_1 = require("./util");
|
|||||||
const pkg = require("../package.json");
|
const pkg = require("../package.json");
|
||||||
async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
|
async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
|
||||||
var _a;
|
var _a;
|
||||||
const statusReportBase = await actions_util_1.createStatusReportBase("init", "success", startedAt);
|
const statusReportBase = await (0, actions_util_1.createStatusReportBase)("init", "success", startedAt);
|
||||||
const languages = config.languages.join(",");
|
const languages = config.languages.join(",");
|
||||||
const workflowLanguages = actions_util_1.getOptionalInput("languages");
|
const workflowLanguages = (0, actions_util_1.getOptionalInput)("languages");
|
||||||
const paths = (config.originalUserInput.paths || []).join(",");
|
const paths = (config.originalUserInput.paths || []).join(",");
|
||||||
const pathsIgnore = (config.originalUserInput["paths-ignore"] || []).join(",");
|
const pathsIgnore = (config.originalUserInput["paths-ignore"] || []).join(",");
|
||||||
const disableDefaultQueries = config.originalUserInput["disable-default-queries"]
|
const disableDefaultQueries = config.originalUserInput["disable-default-queries"]
|
||||||
? languages
|
? languages
|
||||||
: "";
|
: "";
|
||||||
const queries = [];
|
const queries = [];
|
||||||
let queriesInput = (_a = actions_util_1.getOptionalInput("queries")) === null || _a === void 0 ? void 0 : _a.trim();
|
let queriesInput = (_a = (0, actions_util_1.getOptionalInput)("queries")) === null || _a === void 0 ? void 0 : _a.trim();
|
||||||
if (queriesInput === undefined || queriesInput.startsWith("+")) {
|
if (queriesInput === undefined || queriesInput.startsWith("+")) {
|
||||||
queries.push(...(config.originalUserInput.queries || []).map((q) => q.uses));
|
queries.push(...(config.originalUserInput.queries || []).map((q) => q.uses));
|
||||||
}
|
}
|
||||||
@@ -46,48 +60,58 @@ async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
|
|||||||
paths_ignore: pathsIgnore,
|
paths_ignore: pathsIgnore,
|
||||||
disable_default_queries: disableDefaultQueries,
|
disable_default_queries: disableDefaultQueries,
|
||||||
queries: queries.join(","),
|
queries: queries.join(","),
|
||||||
tools_input: actions_util_1.getOptionalInput("tools") || "",
|
tools_input: (0, actions_util_1.getOptionalInput)("tools") || "",
|
||||||
tools_resolved_version: toolsVersion,
|
tools_resolved_version: toolsVersion,
|
||||||
};
|
};
|
||||||
await actions_util_1.sendStatusReport(statusReport);
|
await (0, actions_util_1.sendStatusReport)(statusReport);
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const logger = logging_1.getActionsLogger();
|
const logger = (0, logging_1.getActionsLogger)();
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, pkg.version);
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
||||||
let config;
|
let config;
|
||||||
let codeql;
|
let codeql;
|
||||||
let toolsVersion;
|
let toolsVersion;
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
auth: actions_util_1.getRequiredInput("token"),
|
auth: (0, actions_util_1.getRequiredInput)("token"),
|
||||||
externalRepoAuth: actions_util_1.getOptionalInput("external-repository-token"),
|
externalRepoAuth: (0, actions_util_1.getOptionalInput)("external-repository-token"),
|
||||||
url: util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
||||||
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);
|
||||||
|
void featureFlags.preloadFeatureFlags();
|
||||||
try {
|
try {
|
||||||
const workflowErrors = await actions_util_1.validateWorkflow();
|
const workflowErrors = await (0, actions_util_1.validateWorkflow)();
|
||||||
if (!(await actions_util_1.sendStatusReport(await actions_util_1.createStatusReportBase("init", "starting", startedAt, workflowErrors)))) {
|
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "starting", startedAt, workflowErrors)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const initCodeQLResult = await init_1.initCodeQL(actions_util_1.getOptionalInput("tools"), apiDetails, actions_util_1.getTemporaryDirectory(), actions_util_1.getToolCacheDirectory(), gitHubVersion.type, logger);
|
const initCodeQLResult = await (0, init_1.initCodeQL)((0, actions_util_1.getOptionalInput)("tools"), apiDetails, (0, actions_util_1.getTemporaryDirectory)(), (0, actions_util_1.getToolCacheDirectory)(), gitHubVersion.type, logger);
|
||||||
codeql = initCodeQLResult.codeql;
|
codeql = initCodeQLResult.codeql;
|
||||||
toolsVersion = initCodeQLResult.toolsVersion;
|
toolsVersion = initCodeQLResult.toolsVersion;
|
||||||
config = await init_1.initConfig(actions_util_1.getOptionalInput("languages"), actions_util_1.getOptionalInput("queries"), actions_util_1.getOptionalInput("packs"), actions_util_1.getOptionalInput("config-file"), actions_util_1.getOptionalInput("db-location"), repository_1.parseRepositoryNwo(util_1.getRequiredEnvParam("GITHUB_REPOSITORY")), actions_util_1.getTemporaryDirectory(), util_1.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
await (0, util_1.enrichEnvironment)(util_1.Mode.actions, codeql);
|
||||||
|
config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"), (0, actions_util_1.getOptionalInput)("debug") === "true", (0, actions_util_1.getOptionalInput)("debug-artifact-name") || util_1.DEFAULT_DEBUG_ARTIFACT_NAME, (0, actions_util_1.getOptionalInput)("debug-database-name") || util_1.DEFAULT_DEBUG_DATABASE_NAME, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), (0, util_1.getRequiredEnvParam)("RUNNER_TOOL_CACHE"), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, featureFlags, logger);
|
||||||
|
if (config.languages.some(languages_1.isTracedLanguage)) {
|
||||||
|
// We currently do not support tracing on Windows 11 and Windows Server 2022
|
||||||
|
(0, util_1.checkNotWindows11)();
|
||||||
|
}
|
||||||
if (config.languages.includes(languages_1.Language.python) &&
|
if (config.languages.includes(languages_1.Language.python) &&
|
||||||
actions_util_1.getRequiredInput("setup-python-dependencies") === "true") {
|
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
|
||||||
try {
|
try {
|
||||||
await init_1.installPythonDeps(codeql, logger);
|
await (0, init_1.installPythonDeps)(codeql, logger);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
logger.warning(`${err.message} You can call this action with 'setup-python-dependencies: false' to disable this process`);
|
const message = err instanceof Error ? err.message : String(err);
|
||||||
|
logger.warning(`${message} You can call this action with 'setup-python-dependencies: false' to disable this process`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
core.setFailed(e.message);
|
const message = e instanceof Error ? e.message : String(e);
|
||||||
|
core.setFailed(message);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
await actions_util_1.sendStatusReport(await actions_util_1.createStatusReportBase("init", "aborted", startedAt, e.message));
|
await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "aborted", startedAt, message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -97,25 +121,31 @@ 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"
|
||||||
const sourceRoot = path.resolve(util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), actions_util_1.getOptionalInput("source-root") || "");
|
// options at https://codeql.github.com/docs/codeql-cli/manual/database-trace-command/
|
||||||
const tracerConfig = await init_1.runInit(codeql, config, sourceRoot);
|
// 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 tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", undefined);
|
||||||
if (tracerConfig !== undefined) {
|
if (tracerConfig !== undefined) {
|
||||||
for (const [key, value] of Object.entries(tracerConfig.env)) {
|
for (const [key, value] of Object.entries(tracerConfig.env)) {
|
||||||
core.exportVariable(key, value);
|
core.exportVariable(key, value);
|
||||||
}
|
}
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32" &&
|
||||||
await init_1.injectWindowsTracer("Runner.Worker.exe", undefined, config, codeql, tracerConfig);
|
!(await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING))) {
|
||||||
|
await (0, init_1.injectWindowsTracer)("Runner.Worker.exe", undefined, config, codeql, tracerConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.setOutput("codeql-path", config.codeQLCmd);
|
core.setOutput("codeql-path", config.codeQLCmd);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(String(error));
|
||||||
console.log(error);
|
console.log(error);
|
||||||
await actions_util_1.sendStatusReport(await actions_util_1.createStatusReportBase("init", "failure", startedAt, error.message, error.stack));
|
await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "failure", 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
41
lib/init.js
generated
41
lib/init.js
generated
@@ -1,12 +1,25 @@
|
|||||||
"use strict";
|
"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) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
result["default"] = mod;
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.installPythonDeps = exports.injectWindowsTracer = exports.runInit = exports.initConfig = exports.initCodeQL = 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"));
|
||||||
@@ -16,30 +29,36 @@ const codeql_1 = require("./codeql");
|
|||||||
const configUtils = __importStar(require("./config-utils"));
|
const configUtils = __importStar(require("./config-utils"));
|
||||||
const tracer_config_1 = require("./tracer-config");
|
const tracer_config_1 = require("./tracer-config");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
|
const util_1 = require("./util");
|
||||||
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger) {
|
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger) {
|
||||||
logger.startGroup("Setup CodeQL tools");
|
logger.startGroup("Setup CodeQL tools");
|
||||||
const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger);
|
const { codeql, toolsVersion } = await (0, codeql_1.setupCodeQL)(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger, true);
|
||||||
await codeql.printVersion();
|
await codeql.printVersion();
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return { codeql, toolsVersion };
|
return { codeql, toolsVersion };
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, 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) {
|
async function runInit(codeql, config, sourceRoot, processName, processLevel) {
|
||||||
fs.mkdirSync(config.dbLocation, { recursive: true });
|
fs.mkdirSync(config.dbLocation, { recursive: true });
|
||||||
// TODO: replace this code once CodeQL supports multi-language tracing
|
if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
||||||
for (const language of config.languages) {
|
// Init a database cluster
|
||||||
// Init language database
|
await codeql.databaseInitCluster(config.dbLocation, config.languages, sourceRoot, processName, processLevel);
|
||||||
await codeql.databaseInit(util.getCodeQLDatabasePath(config, language), language, sourceRoot);
|
|
||||||
}
|
}
|
||||||
return await tracer_config_1.getCombinedTracerConfig(config, codeql);
|
else {
|
||||||
|
for (const language of config.languages) {
|
||||||
|
// Init language database
|
||||||
|
await codeql.databaseInit(util.getCodeQLDatabasePath(config, language), language, sourceRoot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql);
|
||||||
}
|
}
|
||||||
exports.runInit = runInit;
|
exports.runInit = runInit;
|
||||||
// Runs a powershell script to inject the tracer into a parent process
|
// Runs a powershell script to inject the tracer into a parent process
|
||||||
|
|||||||
@@ -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,qCAA+C;AAC/C,4DAA8C;AAG9C,mDAAwE;AACxE,6CAA+B;AAExB,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe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,QAAQ,KAAK,OAAO,EAAE;YAChC,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE;gBACvE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC;aAC9C,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAC7B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAC7C,CAAC,IAAI,EAAE,CAAC;SACV;QACD,MAAM,MAAM,GAAG,0BAA0B,CAAC;QAC1C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YAChC,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBAC/D,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE;gBAChE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAtCD,8CAsCC"}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user