tamperward 2.29.4 → 2.29.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +64 -16
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -3432,22 +3432,53 @@ function isCommentLine(trimmed, lang) {
|
|
|
3432
3432
|
return SLASH_COMMENT.test(trimmed);
|
|
3433
3433
|
}
|
|
3434
3434
|
function insideStringLiteral(line, idx, lang) {
|
|
3435
|
-
const
|
|
3435
|
+
const l = lang ?? "js";
|
|
3436
|
+
const hash = HASH_COMMENT_LANGS.has(l);
|
|
3436
3437
|
let quote = null;
|
|
3437
3438
|
for (let j = 0; j < idx; j++) {
|
|
3438
3439
|
const ch = line[j];
|
|
3439
3440
|
if (quote) {
|
|
3440
3441
|
if (ch === "\\") j++;
|
|
3441
|
-
else if (
|
|
3442
|
+
else if (quote.length === 3) {
|
|
3443
|
+
if (ch === quote[0] && line[j + 1] === quote[0] && line[j + 2] === quote[0]) {
|
|
3444
|
+
quote = null;
|
|
3445
|
+
j += 2;
|
|
3446
|
+
}
|
|
3447
|
+
} else if (ch === quote) quote = null;
|
|
3442
3448
|
continue;
|
|
3443
3449
|
}
|
|
3444
|
-
if (
|
|
3450
|
+
if (l === "py" && (ch === '"' || ch === "'") && line[j + 1] === ch && line[j + 2] === ch) {
|
|
3451
|
+
quote = ch.repeat(3);
|
|
3452
|
+
j += 2;
|
|
3453
|
+
} else if (ch === '"' || ch === "'" || ch === "`") quote = ch;
|
|
3445
3454
|
else if (ch === "/" && (line[j + 1] === "/" || line[j + 1] === "*")) return false;
|
|
3455
|
+
else if (l === "js" && ch === "/" && regexPosition(line.slice(0, j))) j = skipRegexLiteral(line, j);
|
|
3446
3456
|
else if (hash && ch === "#") return false;
|
|
3447
3457
|
}
|
|
3448
3458
|
return quote !== null;
|
|
3449
3459
|
}
|
|
3450
|
-
|
|
3460
|
+
function regexPosition(before) {
|
|
3461
|
+
const s = before.replace(/\s+$/, "");
|
|
3462
|
+
if (s === "") return true;
|
|
3463
|
+
const last = s[s.length - 1];
|
|
3464
|
+
if (/[\w$]/.test(last)) {
|
|
3465
|
+
const kw = /[A-Za-z_$][\w$]*$/.exec(s);
|
|
3466
|
+
return kw !== null && REGEX_KEYWORDS.has(kw[0]);
|
|
3467
|
+
}
|
|
3468
|
+
return last !== ")" && last !== "]" && last !== '"' && last !== "'" && last !== "`";
|
|
3469
|
+
}
|
|
3470
|
+
function skipRegexLiteral(line, start) {
|
|
3471
|
+
let inClass = false;
|
|
3472
|
+
for (let k = start + 1; k < line.length; k++) {
|
|
3473
|
+
const c = line[k];
|
|
3474
|
+
if (c === "\\") k++;
|
|
3475
|
+
else if (c === "[") inClass = true;
|
|
3476
|
+
else if (c === "]") inClass = false;
|
|
3477
|
+
else if (c === "/" && !inClass) return k;
|
|
3478
|
+
}
|
|
3479
|
+
return line.length - 1;
|
|
3480
|
+
}
|
|
3481
|
+
var CODE, EXT, COMMON, IMPORTS, HASH_COMMENT, DEBUG_ONLY, SLASH_COMMENT, HASH_COMMENT_LANGS, REGEX_KEYWORDS;
|
|
3451
3482
|
var init_files = __esm({
|
|
3452
3483
|
"src/detectors/files.ts"() {
|
|
3453
3484
|
"use strict";
|
|
@@ -3479,6 +3510,21 @@ var init_files = __esm({
|
|
|
3479
3510
|
DEBUG_ONLY = /^(?:console\.\w+\(.*\)\s*;?|debugger\s*;?)$/;
|
|
3480
3511
|
SLASH_COMMENT = /^(?:\/\/|\/\*|\*(?:\s|\/|$))/;
|
|
3481
3512
|
HASH_COMMENT_LANGS = /* @__PURE__ */ new Set(["py", "rb", "php"]);
|
|
3513
|
+
REGEX_KEYWORDS = /* @__PURE__ */ new Set([
|
|
3514
|
+
"return",
|
|
3515
|
+
"throw",
|
|
3516
|
+
"case",
|
|
3517
|
+
"yield",
|
|
3518
|
+
"do",
|
|
3519
|
+
"else",
|
|
3520
|
+
"in",
|
|
3521
|
+
"of",
|
|
3522
|
+
"typeof",
|
|
3523
|
+
"void",
|
|
3524
|
+
"delete",
|
|
3525
|
+
"instanceof",
|
|
3526
|
+
"new"
|
|
3527
|
+
]);
|
|
3482
3528
|
}
|
|
3483
3529
|
});
|
|
3484
3530
|
|
|
@@ -3890,8 +3936,8 @@ var init_lint_suppression = __esm({
|
|
|
3890
3936
|
{ re: /\bbiome-ignore\b/, why: "biome-ignore suppresses Biome diagnostics" }
|
|
3891
3937
|
],
|
|
3892
3938
|
py: [
|
|
3893
|
-
{ re: /#\s*noqa\b
|
|
3894
|
-
{ re: /#\s*(?:ruff|flake8):\s*noqa\b
|
|
3939
|
+
{ re: /#\s*noqa\b/i, why: "# noqa suppresses flake8/ruff findings" },
|
|
3940
|
+
{ re: /#\s*(?:ruff|flake8):\s*noqa\b/i, why: "# ruff: noqa / # flake8: noqa suppresses every finding in the file" },
|
|
3895
3941
|
{ re: /#\s*type:\s*ignore\b/, why: "# type: ignore suppresses the type checker" },
|
|
3896
3942
|
{ re: /#\s*mypy:\s*ignore-errors\b/, why: "# mypy: ignore-errors suppresses the type checker for the file" },
|
|
3897
3943
|
{ re: /#\s*pyright:\s*ignore\b/, why: "# pyright: ignore suppresses the type checker" },
|
|
@@ -10801,14 +10847,14 @@ function renderText(input, opts) {
|
|
|
10801
10847
|
const isBlock = f.severity === "block";
|
|
10802
10848
|
const mark = paint(isBlock ? "BLOCK" : "warn ", isBlock ? BOLD + RED : YELLOW, c);
|
|
10803
10849
|
const loc = f.file ? `${stripControl(escapeControl(f.file))}${f.line ? `:${f.line}` : ""}` : "(command)";
|
|
10804
|
-
out3.push(` ${mark} ${paint(stripControl(f.rule), BOLD, c)} ${paint(loc,
|
|
10850
|
+
out3.push(` ${mark} ${paint(stripControl(f.rule), BOLD, c)} ${paint(loc, CYAN, c)}`);
|
|
10805
10851
|
for (const l of wrap(f.message, opts.width - 4)) out3.push(` ${l}`);
|
|
10806
10852
|
const row = (key2, lines) => {
|
|
10807
10853
|
lines.forEach((l, i) => out3.push(` ${paint(pad(i === 0 ? key2 : ""), DIM, c)} ${l}`));
|
|
10808
10854
|
};
|
|
10809
10855
|
row("evidence", [paint(clip(f.evidence, body), DIM, c)]);
|
|
10810
10856
|
row("instead", wrap(f.remediation, body));
|
|
10811
|
-
if (f.signoff.required) row("sign-off", [stripControl(f.signoff.command)]);
|
|
10857
|
+
if (f.signoff.required) row("sign-off", [paint(stripControl(f.signoff.command), YELLOW, c)]);
|
|
10812
10858
|
out3.push("");
|
|
10813
10859
|
}
|
|
10814
10860
|
if (blocks2.length > 0) {
|
|
@@ -10818,7 +10864,7 @@ function renderText(input, opts) {
|
|
|
10818
10864
|
}
|
|
10819
10865
|
return out3.join("\n").replace(/\n+$/, "") + "\n";
|
|
10820
10866
|
}
|
|
10821
|
-
var ESC, RESET, BOLD, DIM, RED, YELLOW, GREEN, SIGNOFF_NOTE;
|
|
10867
|
+
var ESC, RESET, BOLD, DIM, truecolour, RED, YELLOW, GREEN, CYAN, SIGNOFF_NOTE;
|
|
10822
10868
|
var init_text = __esm({
|
|
10823
10869
|
"src/cli/render/text.ts"() {
|
|
10824
10870
|
"use strict";
|
|
@@ -10827,9 +10873,11 @@ var init_text = __esm({
|
|
|
10827
10873
|
RESET = `${ESC}[0m`;
|
|
10828
10874
|
BOLD = `${ESC}[1m`;
|
|
10829
10875
|
DIM = `${ESC}[2m`;
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10876
|
+
truecolour = (r, g, b) => `${ESC}[38;2;${r};${g};${b}m`;
|
|
10877
|
+
RED = truecolour(255, 107, 107);
|
|
10878
|
+
YELLOW = truecolour(227, 179, 65);
|
|
10879
|
+
GREEN = truecolour(63, 185, 80);
|
|
10880
|
+
CYAN = truecolour(86, 212, 221);
|
|
10833
10881
|
SIGNOFF_NOTE = "A blocking finding clears only with a human sign-off. In CI that sign-off is out-of-band \u2014 a PR label applied by a reviewer \u2014 never a file committed on the branch under review. See SPEC \xA75.4.";
|
|
10834
10882
|
}
|
|
10835
10883
|
});
|
|
@@ -18194,7 +18242,7 @@ async function runOnboard(opts, io = {}) {
|
|
|
18194
18242
|
if (kind === "ok") return GREEN2;
|
|
18195
18243
|
if (kind === "warn") return YELLOW2;
|
|
18196
18244
|
if (kind === "bad") return RED2;
|
|
18197
|
-
if (kind === "info") return
|
|
18245
|
+
if (kind === "info") return CYAN2;
|
|
18198
18246
|
return DIM2;
|
|
18199
18247
|
};
|
|
18200
18248
|
const status = (label, text, kind = "info") => {
|
|
@@ -18251,7 +18299,7 @@ async function runOnboard(opts, io = {}) {
|
|
|
18251
18299
|
const section = (n) => {
|
|
18252
18300
|
sectionNo = n;
|
|
18253
18301
|
out3("");
|
|
18254
|
-
out3(paint2(n + "/" + SECTIONS.length + " " + SECTIONS[n - 1], BOLD2 +
|
|
18302
|
+
out3(paint2(n + "/" + SECTIONS.length + " " + SECTIONS[n - 1], BOLD2 + CYAN2, colour));
|
|
18255
18303
|
};
|
|
18256
18304
|
const wrote = [];
|
|
18257
18305
|
let verifyCommand;
|
|
@@ -18593,7 +18641,7 @@ function runDemo(cwd, head, runners, out3) {
|
|
|
18593
18641
|
out3("changed it while the demo ran; inspect with `git status`.");
|
|
18594
18642
|
}
|
|
18595
18643
|
}
|
|
18596
|
-
var Aborted, SECTIONS, MANUAL_CONTROLS, ESC2, RESET2, BOLD2, DIM2, RED2, YELLOW2, GREEN2,
|
|
18644
|
+
var Aborted, SECTIONS, MANUAL_CONTROLS, ESC2, RESET2, BOLD2, DIM2, RED2, YELLOW2, GREEN2, CYAN2, JS_TEST_PATH, JS_TEST_BLOCK;
|
|
18597
18645
|
var init_onboard = __esm({
|
|
18598
18646
|
"src/cli/onboard.ts"() {
|
|
18599
18647
|
"use strict";
|
|
@@ -18630,7 +18678,7 @@ var init_onboard = __esm({
|
|
|
18630
18678
|
RED2 = `${ESC2}[31m`;
|
|
18631
18679
|
YELLOW2 = `${ESC2}[33m`;
|
|
18632
18680
|
GREEN2 = `${ESC2}[32m`;
|
|
18633
|
-
|
|
18681
|
+
CYAN2 = `${ESC2}[36m`;
|
|
18634
18682
|
JS_TEST_PATH = /(?:^|\/)(?:[^/]+\.(?:test|spec)\.[cm]?[jt]sx?|__tests__\/[^/]+\.[cm]?[jt]sx?)$/;
|
|
18635
18683
|
JS_TEST_BLOCK = /^(\s*)(it|test|describe)(\s*\()/m;
|
|
18636
18684
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamperward",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.6",
|
|
4
4
|
"description": "The deterministic agent-integrity gate. One ruleset, evaluated on the actual diff/commands as a verdict, enforced everywhere a change can be made.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "hexrift",
|