mirror of
https://github.com/github/codeql-action.git
synced 2026-08-08 05:41:19 -05:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f8c44ba62 | |||
| 7d9249f5a5 | |||
| 8ebf1091b0 | |||
| bdf39710a2 | |||
| 74cfae9be6 | |||
| 47a0a833bb | |||
| 6a90bf1f54 | |||
| c5995f544d | |||
| 76c44396d3 | |||
| fad141fa6c | |||
| 7d82f1132f | |||
| 37bdbde050 |
@@ -63,7 +63,7 @@ jobs:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Install Java
|
||||
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
|
||||
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
|
||||
with:
|
||||
java-version: ${{ inputs.java-version || '17' }}
|
||||
distribution: temurin
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ jobs:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||
- name: Install Java
|
||||
uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
|
||||
uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0
|
||||
with:
|
||||
java-version: ${{ inputs.java-version || '17' }}
|
||||
distribution: temurin
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
|
||||
|
||||
## [UNRELEASED]
|
||||
|
||||
No user facing changes.
|
||||
|
||||
## 4.37.6 - 04 Aug 2026
|
||||
|
||||
- Changed the default filepath for the new remote file address format that was introduced in CodeQL Action 4.37.0 / 3.37.0 to `.github/codeql-config.yml` to align it with the suggested path that is used elsewhere. [#4070](https://github.com/github/codeql-action/pull/4070)
|
||||
|
||||
Generated
+401
-197
@@ -31227,6 +31227,8 @@ var require_brace_expansion = __commonJS({
|
||||
var escClose2 = "\0CLOSE" + Math.random() + "\0";
|
||||
var escComma2 = "\0COMMA" + Math.random() + "\0";
|
||||
var escPeriod2 = "\0PERIOD" + Math.random() + "\0";
|
||||
var EXPANSION_MAX2 = 1e5;
|
||||
var EXPANSION_MAX_LENGTH2 = 4e6;
|
||||
function numeric2(str) {
|
||||
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
||||
}
|
||||
@@ -31260,11 +31262,12 @@ var require_brace_expansion = __commonJS({
|
||||
if (!str)
|
||||
return [];
|
||||
options = options || {};
|
||||
var max = options.max == null ? Infinity : options.max;
|
||||
var max = options.max == null ? EXPANSION_MAX2 : options.max;
|
||||
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH2 : options.maxLength;
|
||||
if (str.substr(0, 2) === "{}") {
|
||||
str = "\\{\\}" + str.substr(2);
|
||||
}
|
||||
return expand3(escapeBraces2(str), max, true).map(unescapeBraces2);
|
||||
return expand3(escapeBraces2(str), max, maxLength, true).map(unescapeBraces2);
|
||||
}
|
||||
function embrace2(str) {
|
||||
return "{" + str + "}";
|
||||
@@ -31278,11 +31281,82 @@ var require_brace_expansion = __commonJS({
|
||||
function gte7(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
function expand3(str, max, isTop) {
|
||||
var expansions = [];
|
||||
function combine2(acc, base, pre, values, max, maxLength, dropEmpties, outBase) {
|
||||
var out = [];
|
||||
var length = 0;
|
||||
for (var a = 0; a < acc.length; a++) {
|
||||
for (var v = 0; v < values.length; v++) {
|
||||
if (out.length >= max) return out;
|
||||
var expansion = acc[a] + pre + values[v];
|
||||
if (dropEmpties && expansion.length === base[a]) continue;
|
||||
if (length + expansion.length > maxLength) return out;
|
||||
out.push(expansion);
|
||||
outBase.push(base[a]);
|
||||
length += expansion.length;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function expandSequence2(body, isAlphaSequence, max, maxLength) {
|
||||
var n = body.split(/\.\./);
|
||||
var N = [];
|
||||
if (n[0] === void 0 || n[1] === void 0) {
|
||||
return N;
|
||||
}
|
||||
var x = numeric2(n[0]);
|
||||
var y = numeric2(n[1]);
|
||||
var width = Math.max(n[0].length, n[1].length);
|
||||
var incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric2(n[2])), 1) : 1;
|
||||
var test = lte2;
|
||||
var reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte7;
|
||||
}
|
||||
var pad = n.some(isPadded2);
|
||||
var length = 0;
|
||||
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
||||
var c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === "\\") {
|
||||
c = "";
|
||||
}
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
var need = width - c.length;
|
||||
if (need > 0) {
|
||||
var z = new Array(need + 1).join("0");
|
||||
if (i < 0) {
|
||||
c = "-" + z + c.slice(1);
|
||||
} else {
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (length + c.length > maxLength) break;
|
||||
N.push(c);
|
||||
length += c.length;
|
||||
}
|
||||
return N;
|
||||
}
|
||||
function expand3(str, max, maxLength, isTop) {
|
||||
var acc = [""];
|
||||
var accBase = [0];
|
||||
var dropEmpties = false;
|
||||
var firstGroup = true;
|
||||
var nextBase;
|
||||
for (; ; ) {
|
||||
var m = balanced2("{", "}", str);
|
||||
if (!m || /\$$/.test(m.pre)) return [str];
|
||||
if (!m) {
|
||||
return combine2(acc, accBase, str, [""], max, maxLength, dropEmpties, []);
|
||||
}
|
||||
var pre = m.pre;
|
||||
if (/\$$/.test(pre)) {
|
||||
return combine2(acc, accBase, str, [""], max, maxLength, dropEmpties, []);
|
||||
}
|
||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isSequence = isNumericSequence || isAlphaSequence;
|
||||
@@ -31291,76 +31365,91 @@ var require_brace_expansion = __commonJS({
|
||||
if (m.post.match(/,(?!,).*\}/)) {
|
||||
str = m.pre + "{" + m.body + escClose2 + m.post;
|
||||
isTop = true;
|
||||
firstGroup = true;
|
||||
dropEmpties = false;
|
||||
accBase = [];
|
||||
for (var b = 0; b < acc.length; b++) {
|
||||
accBase.push(acc[b].length);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return [str];
|
||||
return combine2(
|
||||
acc,
|
||||
accBase,
|
||||
pre + "{" + m.body + "}" + m.post,
|
||||
[""],
|
||||
max,
|
||||
maxLength,
|
||||
dropEmpties,
|
||||
[]
|
||||
);
|
||||
}
|
||||
var n;
|
||||
if (firstGroup) {
|
||||
dropEmpties = isTop && !isSequence;
|
||||
firstGroup = false;
|
||||
}
|
||||
var values;
|
||||
if (isSequence) {
|
||||
n = m.body.split(/\.\./);
|
||||
values = expandSequence2(m.body, isAlphaSequence, max, maxLength);
|
||||
} else {
|
||||
n = parseCommaParts2(m.body);
|
||||
if (n.length === 1) {
|
||||
n = expand3(n[0], max, false).map(embrace2);
|
||||
var n = parseCommaParts2(m.body);
|
||||
if (n.length === 1 && n[0] !== void 0) {
|
||||
n = expand3(n[0], max, maxLength, false).map(embrace2);
|
||||
if (n.length === 1) {
|
||||
var post = m.post.length ? expand3(m.post, max, false) : [""];
|
||||
return post.map(function(p) {
|
||||
return m.pre + n[0] + p;
|
||||
});
|
||||
nextBase = [];
|
||||
acc = combine2(
|
||||
acc,
|
||||
accBase,
|
||||
pre + n[0],
|
||||
[""],
|
||||
max,
|
||||
maxLength,
|
||||
dropEmpties && !m.post.length,
|
||||
nextBase
|
||||
);
|
||||
accBase = nextBase;
|
||||
if (!m.post.length) break;
|
||||
str = m.post;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
var pre = m.pre;
|
||||
var post = m.post.length ? expand3(m.post, max, false) : [""];
|
||||
var N;
|
||||
if (isSequence) {
|
||||
var x = numeric2(n[0]);
|
||||
var y = numeric2(n[1]);
|
||||
var width = Math.max(n[0].length, n[1].length);
|
||||
var incr = n.length == 3 ? Math.max(Math.abs(numeric2(n[2])), 1) : 1;
|
||||
var test = lte2;
|
||||
var reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte7;
|
||||
var dropsEmpties = dropEmpties && !m.post.length && !pre;
|
||||
for (var d = 0; dropsEmpties && d < acc.length; d++) {
|
||||
if (acc[d].length !== accBase[d]) {
|
||||
dropsEmpties = false;
|
||||
}
|
||||
}
|
||||
var pad = n.some(isPadded2);
|
||||
N = [];
|
||||
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
||||
var c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === "\\")
|
||||
c = "";
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
var need = width - c.length;
|
||||
if (need > 0) {
|
||||
var z = new Array(need + 1).join("0");
|
||||
if (i < 0)
|
||||
c = "-" + z + c.slice(1);
|
||||
else
|
||||
c = z + c;
|
||||
}
|
||||
values = [];
|
||||
var valuesLength = 0;
|
||||
outer: for (var j = 0; j < n.length; j++) {
|
||||
var expanded = expand3(n[j], max, maxLength, false);
|
||||
for (var k = 0; k < expanded.length; k++) {
|
||||
var v = expanded[k];
|
||||
if (dropsEmpties && !v) continue;
|
||||
if (values.length >= max || valuesLength + v.length > maxLength) {
|
||||
break outer;
|
||||
}
|
||||
values.push(v);
|
||||
valuesLength += v.length;
|
||||
}
|
||||
N.push(c);
|
||||
}
|
||||
} else {
|
||||
N = concatMap(n, function(el) {
|
||||
return expand3(el, max, false);
|
||||
});
|
||||
}
|
||||
for (var j = 0; j < N.length; j++) {
|
||||
for (var k = 0; k < post.length && expansions.length < max; k++) {
|
||||
var expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion)
|
||||
expansions.push(expansion);
|
||||
}
|
||||
}
|
||||
return expansions;
|
||||
nextBase = [];
|
||||
acc = combine2(
|
||||
acc,
|
||||
accBase,
|
||||
pre,
|
||||
values,
|
||||
max,
|
||||
maxLength,
|
||||
dropEmpties && !m.post.length,
|
||||
nextBase
|
||||
);
|
||||
accBase = nextBase;
|
||||
if (!m.post.length) break;
|
||||
str = m.post;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -89012,6 +89101,8 @@ var require_brace_expansion2 = __commonJS({
|
||||
var escClose2 = "\0CLOSE" + Math.random() + "\0";
|
||||
var escComma2 = "\0COMMA" + Math.random() + "\0";
|
||||
var escPeriod2 = "\0PERIOD" + Math.random() + "\0";
|
||||
var EXPANSION_MAX2 = 1e5;
|
||||
var EXPANSION_MAX_LENGTH2 = 4e6;
|
||||
function numeric2(str) {
|
||||
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
||||
}
|
||||
@@ -89045,11 +89136,12 @@ var require_brace_expansion2 = __commonJS({
|
||||
if (!str)
|
||||
return [];
|
||||
options = options || {};
|
||||
var max = options.max == null ? Infinity : options.max;
|
||||
var max = options.max == null ? EXPANSION_MAX2 : options.max;
|
||||
var maxLength = options.maxLength == null ? EXPANSION_MAX_LENGTH2 : options.maxLength;
|
||||
if (str.substr(0, 2) === "{}") {
|
||||
str = "\\{\\}" + str.substr(2);
|
||||
}
|
||||
return expand3(escapeBraces2(str), max, true).map(unescapeBraces2);
|
||||
return expand3(escapeBraces2(str), max, maxLength, true).map(unescapeBraces2);
|
||||
}
|
||||
function embrace2(str) {
|
||||
return "{" + str + "}";
|
||||
@@ -89063,19 +89155,89 @@ var require_brace_expansion2 = __commonJS({
|
||||
function gte7(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
function expand3(str, max, isTop) {
|
||||
var expansions = [];
|
||||
function combine2(acc, pre, values, max, maxLength, dropEmpties) {
|
||||
var out = [];
|
||||
var length = 0;
|
||||
for (var a = 0; a < acc.length; a++) {
|
||||
for (var v = 0; v < values.length; v++) {
|
||||
if (out.length >= max) return out;
|
||||
var expansion = acc[a] + pre + values[v];
|
||||
if (dropEmpties && !expansion) continue;
|
||||
if (length + expansion.length > maxLength) return out;
|
||||
out.push(expansion);
|
||||
length += expansion.length;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function expandSequence2(body, isAlphaSequence, max, maxLength) {
|
||||
var n = body.split(/\.\./);
|
||||
var N = [];
|
||||
if (n[0] === void 0 || n[1] === void 0) {
|
||||
return N;
|
||||
}
|
||||
var x = numeric2(n[0]);
|
||||
var y = numeric2(n[1]);
|
||||
var width = Math.max(n[0].length, n[1].length);
|
||||
var incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric2(n[2])), 1) : 1;
|
||||
var test = lte2;
|
||||
var reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte7;
|
||||
}
|
||||
var pad = n.some(isPadded2);
|
||||
var length = 0;
|
||||
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
||||
var c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === "\\") {
|
||||
c = "";
|
||||
}
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
var need = width - c.length;
|
||||
if (need > 0) {
|
||||
var z = new Array(need + 1).join("0");
|
||||
if (i < 0) {
|
||||
c = "-" + z + c.slice(1);
|
||||
} else {
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (length + c.length > maxLength) break;
|
||||
N.push(c);
|
||||
length += c.length;
|
||||
}
|
||||
return N;
|
||||
}
|
||||
function expand3(str, max, maxLength, isTop) {
|
||||
var acc = [""];
|
||||
var dropEmpties = false;
|
||||
var firstGroup = true;
|
||||
for (; ; ) {
|
||||
const m = balanced2("{", "}", str);
|
||||
if (!m) return [str];
|
||||
if (!m) {
|
||||
return combine2(acc, str, [""], max, maxLength, dropEmpties);
|
||||
}
|
||||
const pre = m.pre;
|
||||
if (/\$$/.test(m.pre)) {
|
||||
const post2 = m.post.length ? expand3(m.post, max, false) : [""];
|
||||
for (let k2 = 0; k2 < post2.length && k2 < max; k2++) {
|
||||
const expansion2 = pre + "{" + m.body + "}" + post2[k2];
|
||||
expansions.push(expansion2);
|
||||
}
|
||||
return expansions;
|
||||
if (/\$$/.test(pre)) {
|
||||
acc = combine2(
|
||||
acc,
|
||||
pre + "{" + m.body + "}",
|
||||
[""],
|
||||
max,
|
||||
maxLength,
|
||||
dropEmpties && !m.post.length
|
||||
);
|
||||
firstGroup = false;
|
||||
if (!m.post.length) break;
|
||||
str = m.post;
|
||||
continue;
|
||||
}
|
||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||
@@ -89087,73 +89249,66 @@ var require_brace_expansion2 = __commonJS({
|
||||
isTop = true;
|
||||
continue;
|
||||
}
|
||||
return [str];
|
||||
return combine2(
|
||||
acc,
|
||||
pre + "{" + m.body + "}" + m.post,
|
||||
[""],
|
||||
max,
|
||||
maxLength,
|
||||
dropEmpties
|
||||
);
|
||||
}
|
||||
const post = m.post.length ? expand3(m.post, max, false) : [""];
|
||||
var n;
|
||||
if (firstGroup) {
|
||||
dropEmpties = isTop && !isSequence;
|
||||
firstGroup = false;
|
||||
}
|
||||
var values;
|
||||
if (isSequence) {
|
||||
n = m.body.split(/\.\./);
|
||||
values = expandSequence2(m.body, isAlphaSequence, max, maxLength);
|
||||
} else {
|
||||
n = parseCommaParts2(m.body);
|
||||
if (n.length === 1) {
|
||||
n = expand3(n[0], max, false).map(embrace2);
|
||||
var n = parseCommaParts2(m.body);
|
||||
if (n.length === 1 && n[0] !== void 0) {
|
||||
n = expand3(n[0], max, maxLength, false).map(embrace2);
|
||||
if (n.length === 1) {
|
||||
return post.map(function(p) {
|
||||
return m.pre + n[0] + p;
|
||||
});
|
||||
acc = combine2(
|
||||
acc,
|
||||
pre + n[0],
|
||||
[""],
|
||||
max,
|
||||
maxLength,
|
||||
dropEmpties && !m.post.length
|
||||
);
|
||||
if (!m.post.length) break;
|
||||
str = m.post;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
var N;
|
||||
if (isSequence) {
|
||||
var x = numeric2(n[0]);
|
||||
var y = numeric2(n[1]);
|
||||
var width = Math.max(n[0].length, n[1].length);
|
||||
var incr = n.length == 3 ? Math.max(Math.abs(numeric2(n[2])), 1) : 1;
|
||||
var test = lte2;
|
||||
var reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte7;
|
||||
var dropsEmpties = dropEmpties && !m.post.length && !pre;
|
||||
for (var d = 0; dropsEmpties && d < acc.length; d++) {
|
||||
if (acc[d]) {
|
||||
dropsEmpties = false;
|
||||
}
|
||||
}
|
||||
var pad = n.some(isPadded2);
|
||||
N = [];
|
||||
for (var i = x; test(i, y) && N.length < max; i += incr) {
|
||||
var c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === "\\")
|
||||
c = "";
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
var need = width - c.length;
|
||||
if (need > 0) {
|
||||
var z = new Array(need + 1).join("0");
|
||||
if (i < 0)
|
||||
c = "-" + z + c.slice(1);
|
||||
else
|
||||
c = z + c;
|
||||
}
|
||||
values = [];
|
||||
var valuesLength = 0;
|
||||
outer: for (var j = 0; j < n.length; j++) {
|
||||
var expanded = expand3(n[j], max, maxLength, false);
|
||||
for (var k = 0; k < expanded.length; k++) {
|
||||
var v = expanded[k];
|
||||
if (dropsEmpties && !v) continue;
|
||||
if (values.length >= max || valuesLength + v.length > maxLength) {
|
||||
break outer;
|
||||
}
|
||||
values.push(v);
|
||||
valuesLength += v.length;
|
||||
}
|
||||
N.push(c);
|
||||
}
|
||||
} else {
|
||||
N = [];
|
||||
for (var j = 0; j < n.length; j++) {
|
||||
N.push.apply(N, expand3(n[j], max, false));
|
||||
}
|
||||
}
|
||||
for (var j = 0; j < N.length; j++) {
|
||||
for (var k = 0; k < post.length && expansions.length < max; k++) {
|
||||
var expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion)
|
||||
expansions.push(expansion);
|
||||
}
|
||||
}
|
||||
return expansions;
|
||||
acc = combine2(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
|
||||
if (!m.post.length) break;
|
||||
str = m.post;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -145426,7 +145581,7 @@ function getDiffRangesJsonFilePath(env = getEnv()) {
|
||||
return path2.join(getTemporaryDirectory(env), PR_DIFF_RANGE_JSON_FILENAME);
|
||||
}
|
||||
function getActionVersion() {
|
||||
return "4.37.6";
|
||||
return "4.37.7";
|
||||
}
|
||||
function getWorkflowEventName(env = getEnv()) {
|
||||
return env.getRequired("GITHUB_EVENT_NAME" /* GITHUB_EVENT_NAME */);
|
||||
@@ -155679,6 +155834,7 @@ var closePattern = /\\}/g;
|
||||
var commaPattern = /\\,/g;
|
||||
var periodPattern = /\\\./g;
|
||||
var EXPANSION_MAX = 1e5;
|
||||
var EXPANSION_MAX_LENGTH = 4e6;
|
||||
function numeric(str) {
|
||||
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
|
||||
}
|
||||
@@ -155713,11 +155869,11 @@ function expand2(str, options = {}) {
|
||||
if (!str) {
|
||||
return [];
|
||||
}
|
||||
const { max = EXPANSION_MAX } = options;
|
||||
const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH } = options;
|
||||
if (str.slice(0, 2) === "{}") {
|
||||
str = "\\{\\}" + str.slice(2);
|
||||
}
|
||||
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
||||
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
|
||||
}
|
||||
function embrace(str) {
|
||||
return "{" + str + "}";
|
||||
@@ -155731,20 +155887,87 @@ function lte(i, y) {
|
||||
function gte6(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
function expand_(str, max, isTop) {
|
||||
const expansions = [];
|
||||
function combine(acc, pre, values, max, maxLength, dropEmpties) {
|
||||
const out = [];
|
||||
let length = 0;
|
||||
for (let a = 0; a < acc.length; a++) {
|
||||
for (let v = 0; v < values.length; v++) {
|
||||
if (out.length >= max)
|
||||
return out;
|
||||
const expansion = acc[a] + pre + values[v];
|
||||
if (dropEmpties && !expansion)
|
||||
continue;
|
||||
if (length + expansion.length > maxLength)
|
||||
return out;
|
||||
out.push(expansion);
|
||||
length += expansion.length;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
function expandSequence(body, isAlphaSequence, max, maxLength) {
|
||||
const n = body.split(/\.\./);
|
||||
const N = [];
|
||||
if (n[0] === void 0 || n[1] === void 0) {
|
||||
return N;
|
||||
}
|
||||
const x = numeric(n[0]);
|
||||
const y = numeric(n[1]);
|
||||
const width = Math.max(n[0].length, n[1].length);
|
||||
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
||||
let test = lte;
|
||||
const reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte6;
|
||||
}
|
||||
const pad = n.some(isPadded);
|
||||
let length = 0;
|
||||
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
||||
let c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === "\\") {
|
||||
c = "";
|
||||
}
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
const need = width - c.length;
|
||||
if (need > 0) {
|
||||
const z = new Array(need + 1).join("0");
|
||||
if (i < 0) {
|
||||
c = "-" + z + c.slice(1);
|
||||
} else {
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (length + c.length > maxLength)
|
||||
break;
|
||||
N.push(c);
|
||||
length += c.length;
|
||||
}
|
||||
return N;
|
||||
}
|
||||
function expand_(str, max, maxLength, isTop) {
|
||||
let acc = [""];
|
||||
let dropEmpties = false;
|
||||
let firstGroup = true;
|
||||
for (; ; ) {
|
||||
const m = balanced("{", "}", str);
|
||||
if (!m)
|
||||
return [str];
|
||||
if (!m) {
|
||||
return combine(acc, str, [""], max, maxLength, dropEmpties);
|
||||
}
|
||||
const pre = m.pre;
|
||||
if (/\$$/.test(m.pre)) {
|
||||
const post2 = m.post.length ? expand_(m.post, max, false) : [""];
|
||||
for (let k = 0; k < post2.length && k < max; k++) {
|
||||
const expansion = pre + "{" + m.body + "}" + post2[k];
|
||||
expansions.push(expansion);
|
||||
}
|
||||
return expansions;
|
||||
if (/\$$/.test(pre)) {
|
||||
acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
|
||||
firstGroup = false;
|
||||
if (!m.post.length)
|
||||
break;
|
||||
str = m.post;
|
||||
continue;
|
||||
}
|
||||
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||
@@ -155756,74 +155979,55 @@ function expand_(str, max, isTop) {
|
||||
isTop = true;
|
||||
continue;
|
||||
}
|
||||
return [str];
|
||||
return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
|
||||
}
|
||||
const post = m.post.length ? expand_(m.post, max, false) : [""];
|
||||
let n;
|
||||
if (firstGroup) {
|
||||
dropEmpties = isTop && !isSequence;
|
||||
firstGroup = false;
|
||||
}
|
||||
let values;
|
||||
if (isSequence) {
|
||||
n = m.body.split(/\.\./);
|
||||
values = expandSequence(m.body, isAlphaSequence, max, maxLength);
|
||||
} else {
|
||||
n = parseCommaParts(m.body);
|
||||
let n = parseCommaParts(m.body);
|
||||
if (n.length === 1 && n[0] !== void 0) {
|
||||
n = expand_(n[0], max, false).map(embrace);
|
||||
n = expand_(n[0], max, maxLength, false).map(embrace);
|
||||
if (n.length === 1) {
|
||||
return post.map((p) => m.pre + n[0] + p);
|
||||
acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
|
||||
if (!m.post.length)
|
||||
break;
|
||||
str = m.post;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
let N;
|
||||
if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
|
||||
const x = numeric(n[0]);
|
||||
const y = numeric(n[1]);
|
||||
const width = Math.max(n[0].length, n[1].length);
|
||||
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
||||
let test = lte;
|
||||
const reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte6;
|
||||
let dropsEmpties = dropEmpties && !m.post.length && !pre;
|
||||
for (let d = 0; dropsEmpties && d < acc.length; d++) {
|
||||
if (acc[d]) {
|
||||
dropsEmpties = false;
|
||||
}
|
||||
}
|
||||
const pad = n.some(isPadded);
|
||||
N = [];
|
||||
for (let i = x; test(i, y) && N.length < max; i += incr) {
|
||||
let c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === "\\") {
|
||||
c = "";
|
||||
values = [];
|
||||
let valuesLength = 0;
|
||||
outer: for (let j = 0; j < n.length; j++) {
|
||||
const expanded = expand_(n[j], max, maxLength, false);
|
||||
for (let k = 0; k < expanded.length; k++) {
|
||||
const v = expanded[k];
|
||||
if (dropsEmpties && !v)
|
||||
continue;
|
||||
if (values.length >= max || valuesLength + v.length > maxLength) {
|
||||
break outer;
|
||||
}
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
const need = width - c.length;
|
||||
if (need > 0) {
|
||||
const z = new Array(need + 1).join("0");
|
||||
if (i < 0) {
|
||||
c = "-" + z + c.slice(1);
|
||||
} else {
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
N.push(c);
|
||||
}
|
||||
} else {
|
||||
N = [];
|
||||
for (let j = 0; j < n.length; j++) {
|
||||
N.push.apply(N, expand_(n[j], max, false));
|
||||
}
|
||||
}
|
||||
for (let j = 0; j < N.length; j++) {
|
||||
for (let k = 0; k < post.length && expansions.length < max; k++) {
|
||||
const expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion) {
|
||||
expansions.push(expansion);
|
||||
values.push(v);
|
||||
valuesLength += v.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
return expansions;
|
||||
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
|
||||
if (!m.post.length)
|
||||
break;
|
||||
str = m.post;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
|
||||
// node_modules/readdir-glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
||||
|
||||
Generated
+27
-27
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "4.37.6",
|
||||
"version": "4.37.7",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "codeql",
|
||||
"version": "4.37.6",
|
||||
"version": "4.37.7",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"pr-checks"
|
||||
@@ -61,7 +61,7 @@
|
||||
"eslint-plugin-jsdoc": "^62.9.0",
|
||||
"eslint-plugin-no-async-foreach": "^0.1.1",
|
||||
"glob": "^13.0.6",
|
||||
"globals": "^17.7.0",
|
||||
"globals": "^17.8.0",
|
||||
"nock": "^14.0.16",
|
||||
"sinon": "^22.1.0",
|
||||
"typescript": "^6.0.3",
|
||||
@@ -374,9 +374,9 @@
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@actions/artifact/node_modules/brace-expansion": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.2.tgz",
|
||||
"integrity": "sha512-w5JZcKgdhDOgOwm8H+KgbosopHMuGcl6qbulwjtz3SM7I7P3yW1eAjzMPLrIE+NQ9vjgANKHWeMHnrT0OXW1oA==",
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
||||
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0"
|
||||
@@ -2843,9 +2843,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
||||
"version": "5.0.8",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.8.tgz",
|
||||
"integrity": "sha512-JZyDyq3D4AUifKTPOB7DELf6XsB3WdPuNxCtob1vFXPsSXhdAiHBWJ/tJ8HAc9aH84BK+5JFZLNkJKx3G9kzQg==",
|
||||
"version": "5.0.9",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -3864,9 +3864,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.16",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.16.tgz",
|
||||
"integrity": "sha512-IDw48K2/2kRkg9LdJxurvq3lV3aBgq0REY89duEqFRthjlPdXHKMj7EnQOXVckxzgisinf3nHfrcE2FufFLXMw==",
|
||||
"version": "1.1.18",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
|
||||
"integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0",
|
||||
@@ -5115,16 +5115,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-import-x/node_modules/brace-expansion": {
|
||||
"version": "5.0.7",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.7.tgz",
|
||||
"integrity": "sha512-7oFy703dxfY3/NLxC1fh2SUCQ0H9rmAY+5EpDVfXjUTTs+HEwR2nYaqLv+GWcTsumwxPfiz6CzCNkwXwBUwqCA==",
|
||||
"version": "5.0.9",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-import-x/node_modules/minimatch": {
|
||||
@@ -6111,15 +6111,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/glob/node_modules/brace-expansion": {
|
||||
"version": "5.0.7",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.7.tgz",
|
||||
"integrity": "sha512-7oFy703dxfY3/NLxC1fh2SUCQ0H9rmAY+5EpDVfXjUTTs+HEwR2nYaqLv+GWcTsumwxPfiz6CzCNkwXwBUwqCA==",
|
||||
"version": "5.0.9",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/glob/node_modules/minimatch": {
|
||||
@@ -6138,9 +6138,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "17.7.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-17.7.0.tgz",
|
||||
"integrity": "sha512-Czmyns5dUsq4seFBR/Kdydhmo8y9kC79hiSkPn0YcGtNnYWnrgt0vjrSjx9tspoDGWm2CMarffRuLjM4xUz8xg==",
|
||||
"version": "17.8.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-17.8.0.tgz",
|
||||
"integrity": "sha512-Zz/LMDZScFmkakeL2cTHzf+PbWKdpU3uclqkZT7TjDG58j5WPt0PpA+n9uPI24fZtlw07q0OtEi84K+umsRzqQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
@@ -8090,15 +8090,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/readdir-glob/node_modules/brace-expansion": {
|
||||
"version": "5.0.7",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.7.tgz",
|
||||
"integrity": "sha512-7oFy703dxfY3/NLxC1fh2SUCQ0H9rmAY+5EpDVfXjUTTs+HEwR2nYaqLv+GWcTsumwxPfiz6CzCNkwXwBUwqCA==",
|
||||
"version": "5.0.9",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
||||
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"balanced-match": "^4.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22"
|
||||
"node": "20 || >=22"
|
||||
}
|
||||
},
|
||||
"node_modules/readdir-glob/node_modules/minimatch": {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "4.37.6",
|
||||
"version": "4.37.7",
|
||||
"private": true,
|
||||
"description": "CodeQL action",
|
||||
"scripts": {
|
||||
@@ -69,7 +69,7 @@
|
||||
"eslint-plugin-jsdoc": "^62.9.0",
|
||||
"eslint-plugin-no-async-foreach": "^0.1.1",
|
||||
"glob": "^13.0.6",
|
||||
"globals": "^17.7.0",
|
||||
"globals": "^17.8.0",
|
||||
"nock": "^14.0.16",
|
||||
"sinon": "^22.1.0",
|
||||
"typescript": "^6.0.3",
|
||||
|
||||
+2
-2
@@ -253,8 +253,8 @@ const languageSetups: LanguageSetups = {
|
||||
name: "Install Java",
|
||||
uses: pinnedUses(
|
||||
"actions/setup-java",
|
||||
"03ad4de0992f5dab5e18fcb136590ce7c4a0ac95",
|
||||
"v5.6.0",
|
||||
"b6effb05e454b25005698d916606bdc6ffcbf961",
|
||||
"v5.7.0",
|
||||
),
|
||||
with: {
|
||||
"java-version": `\${{ inputs.java-version || '${defaultLanguageVersions.java}' }}`,
|
||||
|
||||
@@ -39,12 +39,6 @@ export enum EnvVar {
|
||||
*/
|
||||
CODE_SCANNING_REF = "CODE_SCANNING_REF",
|
||||
|
||||
/**
|
||||
* `PersistedVersionInfo` for the CodeQL CLI, so later Actions steps can reuse it instead of
|
||||
* invoking `codeql version` again.
|
||||
*/
|
||||
CODEQL_VERSION_INFO = "CODEQL_ACTION_CLI_VERSION_INFO",
|
||||
|
||||
/** Whether the CodeQL Action has invoked the Go autobuilder. */
|
||||
DID_AUTOBUILD_GOLANG = "CODEQL_ACTION_DID_AUTOBUILD_GOLANG",
|
||||
|
||||
|
||||
+62
-34
@@ -10,7 +10,7 @@ import * as sinon from "sinon";
|
||||
import * as api from "./api-client";
|
||||
import { EnvVar } from "./environment";
|
||||
import { getRunnerLogger } from "./logging";
|
||||
import { setupTests } from "./testing-utils";
|
||||
import { getTestEnv, setupTests } from "./testing-utils";
|
||||
import * as util from "./util";
|
||||
|
||||
setupTests(test);
|
||||
@@ -535,55 +535,83 @@ test("Failure.orElse returns the default value for a failure result", (t) => {
|
||||
|
||||
test.serial(
|
||||
"getCachedCodeQlVersion reuses a version persisted by an earlier step",
|
||||
(t) => {
|
||||
process.env[EnvVar.CODEQL_VERSION_INFO] = JSON.stringify({
|
||||
cmd: "/path/to/codeql",
|
||||
version: { version: "2.20.0" },
|
||||
});
|
||||
t.deepEqual(util.getCachedCodeQlVersion("/path/to/codeql"), {
|
||||
version: "2.20.0",
|
||||
async (t) => {
|
||||
await util.withTmpDir(async (tmpDir: string) => {
|
||||
const cacheFile = path.join(tmpDir, "version.json");
|
||||
fs.writeFileSync(
|
||||
cacheFile,
|
||||
JSON.stringify({
|
||||
cmd: "/path/to/codeql",
|
||||
version: { version: "2.20.0" },
|
||||
}),
|
||||
"utf8",
|
||||
);
|
||||
const env = getTestEnv({ [EnvVar.TEMP]: tmpDir });
|
||||
t.deepEqual(util.getCachedCodeQlVersion("/path/to/codeql", env), {
|
||||
version: "2.20.0",
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"getCachedCodeQlVersion ignores a persisted version from a different CLI",
|
||||
(t) => {
|
||||
process.env[EnvVar.CODEQL_VERSION_INFO] = JSON.stringify({
|
||||
cmd: "/path/to/other-codeql",
|
||||
version: { version: "2.20.0" },
|
||||
async (t) => {
|
||||
await util.withTmpDir(async (tmpDir: string) => {
|
||||
const cacheFile = path.join(tmpDir, "version.json");
|
||||
fs.writeFileSync(
|
||||
cacheFile,
|
||||
JSON.stringify({
|
||||
cmd: "/path/to/other-codeql",
|
||||
version: { version: "2.20.0" },
|
||||
}),
|
||||
"utf8",
|
||||
);
|
||||
const env = getTestEnv({ [EnvVar.TEMP]: tmpDir });
|
||||
t.is(util.getCachedCodeQlVersion("/path/to/codeql", env), undefined);
|
||||
});
|
||||
t.is(util.getCachedCodeQlVersion("/path/to/codeql"), undefined);
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"getCachedCodeQlVersion ignores a malformed persisted value",
|
||||
(t) => {
|
||||
process.env[EnvVar.CODEQL_VERSION_INFO] = "not valid json";
|
||||
t.is(util.getCachedCodeQlVersion("/path/to/codeql"), undefined);
|
||||
async (t) => {
|
||||
await util.withTmpDir(async (tmpDir: string) => {
|
||||
const cacheFile = path.join(tmpDir, "version.json");
|
||||
fs.writeFileSync(cacheFile, "not valid json", "utf8");
|
||||
const env = getTestEnv({ [EnvVar.TEMP]: tmpDir });
|
||||
t.is(util.getCachedCodeQlVersion("/path/to/codeql", env), undefined);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
test.serial(
|
||||
"getCachedCodeQlVersion ignores a persisted value with the wrong structure",
|
||||
(t) => {
|
||||
for (const value of [
|
||||
JSON.stringify({ cmd: "/path/to/codeql" }),
|
||||
JSON.stringify({ cmd: "/path/to/codeql", version: {} }),
|
||||
JSON.stringify({ cmd: "/path/to/codeql", version: { version: 2 } }),
|
||||
JSON.stringify({ version: { version: "2.20.0" } }),
|
||||
JSON.stringify({
|
||||
cmd: "/path/to/codeql",
|
||||
version: { version: "2.20.0", overlayVersion: "1" },
|
||||
}),
|
||||
JSON.stringify({
|
||||
cmd: "/path/to/codeql",
|
||||
version: { version: "2.20.0", features: "nope" },
|
||||
}),
|
||||
]) {
|
||||
process.env[EnvVar.CODEQL_VERSION_INFO] = value;
|
||||
t.is(util.getCachedCodeQlVersion("/path/to/codeql"), undefined, value);
|
||||
}
|
||||
async (t) => {
|
||||
await util.withTmpDir(async (tmpDir: string) => {
|
||||
const cacheFile = path.join(tmpDir, "version.json");
|
||||
const env = getTestEnv({ [EnvVar.TEMP]: tmpDir });
|
||||
for (const value of [
|
||||
JSON.stringify({ cmd: "/path/to/codeql" }),
|
||||
JSON.stringify({ cmd: "/path/to/codeql", version: {} }),
|
||||
JSON.stringify({ cmd: "/path/to/codeql", version: { version: 2 } }),
|
||||
JSON.stringify({ version: { version: "2.20.0" } }),
|
||||
JSON.stringify({
|
||||
cmd: "/path/to/codeql",
|
||||
version: { version: "2.20.0", overlayVersion: "1" },
|
||||
}),
|
||||
JSON.stringify({
|
||||
cmd: "/path/to/codeql",
|
||||
version: { version: "2.20.0", features: "nope" },
|
||||
}),
|
||||
]) {
|
||||
fs.writeFileSync(cacheFile, value, "utf8");
|
||||
t.is(
|
||||
util.getCachedCodeQlVersion("/path/to/codeql", env),
|
||||
undefined,
|
||||
value,
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
+38
-9
@@ -9,11 +9,12 @@ import getFolderSize from "get-folder-size";
|
||||
import * as yaml from "js-yaml";
|
||||
import * as semver from "semver";
|
||||
|
||||
import { getTemporaryDirectory } from "./actions-util";
|
||||
import * as apiCompatibility from "./api-compatibility.json";
|
||||
import type { CodeQL, VersionInfo } from "./codeql";
|
||||
import type { Pack } from "./config/db-config";
|
||||
import type { Config } from "./config-utils";
|
||||
import { EnvVar, getRequiredEnvParam } from "./environment";
|
||||
import { Env, EnvVar, getEnv, getRequiredEnvParam } from "./environment";
|
||||
import * as json from "./json";
|
||||
import { Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
@@ -638,7 +639,25 @@ function isPersistedVersionInfo(x: unknown): x is PersistedVersionInfo {
|
||||
);
|
||||
}
|
||||
|
||||
export function cacheCodeQlVersion(cmd: string, version: VersionInfo): void {
|
||||
/**
|
||||
* Returns the file path to the `codeql version` output cache.
|
||||
* @param env The environment variables to use—only necessary for testing.
|
||||
*/
|
||||
function getPathToCodeQLVersionCacheFile(env: Env): string {
|
||||
return path.join(getTemporaryDirectory(env), "version.json");
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches the CodeQL CLI version both in-memory and on disk.
|
||||
* @param cmd The path to the CodeQL CLI.
|
||||
* @param version The version information to cache.
|
||||
* @param env The environment variables to use—only necessary for testing.
|
||||
*/
|
||||
export function cacheCodeQlVersion(
|
||||
cmd: string,
|
||||
version: VersionInfo,
|
||||
env: Env = getEnv(),
|
||||
): void {
|
||||
if (cachedCodeQlVersion !== undefined) {
|
||||
throw new Error("cacheCodeQlVersion() should be called only once");
|
||||
}
|
||||
@@ -647,23 +666,33 @@ export function cacheCodeQlVersion(cmd: string, version: VersionInfo): void {
|
||||
// processes, can reuse it rather than invoking `codeql version` again. We
|
||||
// record the CLI path so that a different step using a different CodeQL bundle
|
||||
// doesn't pick up a stale version.
|
||||
core.exportVariable(
|
||||
EnvVar.CODEQL_VERSION_INFO,
|
||||
fs.writeFileSync(
|
||||
getPathToCodeQLVersionCacheFile(env),
|
||||
JSON.stringify({ cmd, version }),
|
||||
"utf8",
|
||||
);
|
||||
}
|
||||
|
||||
export function getCachedCodeQlVersion(cmd?: string): undefined | VersionInfo {
|
||||
/**
|
||||
* Returns the cached CodeQL CLI version, if any. If not cached,
|
||||
* attempts to read and parse it from disk.
|
||||
* @param cmd The path to the CodeQL CLI.
|
||||
* @param env The environment variables to use—only necessary for testing.
|
||||
*/
|
||||
export function getCachedCodeQlVersion(
|
||||
cmd?: string,
|
||||
env: Env = getEnv(),
|
||||
): undefined | VersionInfo {
|
||||
if (cachedCodeQlVersion !== undefined) {
|
||||
return cachedCodeQlVersion;
|
||||
}
|
||||
// Fall back to the value persisted by an earlier Actions step, if any. This is
|
||||
// best-effort: any malformed or mismatched value is ignored so that the caller
|
||||
// invokes `codeql version` instead.
|
||||
const serialized = process.env[EnvVar.CODEQL_VERSION_INFO];
|
||||
if (!serialized) {
|
||||
return undefined;
|
||||
}
|
||||
const serialized = fs.readFileSync(
|
||||
getPathToCodeQLVersionCacheFile(env),
|
||||
"utf8",
|
||||
);
|
||||
let persisted: unknown;
|
||||
try {
|
||||
persisted = JSON.parse(serialized);
|
||||
|
||||
Reference in New Issue
Block a user