tamperward 2.23.6 → 2.23.7
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 +44 -2
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -6197,6 +6197,30 @@ They WILL FAIL in v10.0.0
|
|
|
6197
6197
|
});
|
|
6198
6198
|
|
|
6199
6199
|
// src/detectors/suite-config.ts
|
|
6200
|
+
function runnerSkips(path) {
|
|
6201
|
+
const parts = path.split("/");
|
|
6202
|
+
if (/\.rs$/.test(path)) {
|
|
6203
|
+
const i = parts.indexOf("tests");
|
|
6204
|
+
if (i < 0 || parts.slice(0, i).includes("src")) return null;
|
|
6205
|
+
const rest = parts.slice(i + 1);
|
|
6206
|
+
if (rest.length === 1 || rest.length === 2 && rest[1] === "main.rs") return null;
|
|
6207
|
+
return "cargo builds only tests/*.rs and tests/*/main.rs as test targets";
|
|
6208
|
+
}
|
|
6209
|
+
if (/\.go$/.test(path)) {
|
|
6210
|
+
const hit = parts.find((p) => p === "testdata" || p.startsWith("_") || p.startsWith("."));
|
|
6211
|
+
if (hit === void 0) return null;
|
|
6212
|
+
return `go test skips ${hit === "testdata" ? "testdata/" : hit.startsWith("_") ? "_*" : ".*"} paths (${JSON.stringify(hit)})`;
|
|
6213
|
+
}
|
|
6214
|
+
if (/\.py$/.test(path)) {
|
|
6215
|
+
const hit = PYTEST_DEFAULT_IGNORE.find((g) => globs3([g])(path));
|
|
6216
|
+
return hit === void 0 ? null : `pytest's default norecursedirs matches it (${JSON.stringify(hit)})`;
|
|
6217
|
+
}
|
|
6218
|
+
if (/\.[cm]?[jt]sx?$/.test(path)) {
|
|
6219
|
+
const hit = JS_UNWALKED.find((g) => globs3([g])(path));
|
|
6220
|
+
return hit === void 0 ? null : `the runner's default exclude matches it (${JSON.stringify(hit)})`;
|
|
6221
|
+
}
|
|
6222
|
+
return null;
|
|
6223
|
+
}
|
|
6200
6224
|
function keyName2(name) {
|
|
6201
6225
|
if (ts.isIdentifier(name) || ts.isStringLiteral(name)) return name.text;
|
|
6202
6226
|
return null;
|
|
@@ -6537,7 +6561,7 @@ function suiteNarrowings(before, after, path, samples) {
|
|
|
6537
6561
|
}
|
|
6538
6562
|
return out3;
|
|
6539
6563
|
}
|
|
6540
|
-
var JEST_DEFAULT_MATCH, JEST_DEFAULT_IGNORE, VITEST_DEFAULT_INCLUDE, PYTEST_DEFAULT_INCLUDE, PYTEST_DEFAULT_IGNORE, VITEST_DEFAULT_EXCLUDE, CANONICAL_SAMPLES, PYTEST_CANONICAL_SAMPLES, isStr, PYTEST_INI_ORDER, pathGlobs, isWorkspaceFile, empty, stripRootDir, JEST_SELECTION_KEYS, globs3, globList2, regexes, underDir;
|
|
6564
|
+
var JEST_DEFAULT_MATCH, JEST_DEFAULT_IGNORE, VITEST_DEFAULT_INCLUDE, PYTEST_DEFAULT_INCLUDE, PYTEST_DEFAULT_IGNORE, VITEST_DEFAULT_EXCLUDE, JS_UNWALKED, CANONICAL_SAMPLES, PYTEST_CANONICAL_SAMPLES, isStr, PYTEST_INI_ORDER, pathGlobs, isWorkspaceFile, empty, stripRootDir, JEST_SELECTION_KEYS, globs3, globList2, regexes, underDir;
|
|
6541
6565
|
var init_suite_config = __esm({
|
|
6542
6566
|
"src/detectors/suite-config.ts"() {
|
|
6543
6567
|
"use strict";
|
|
@@ -6555,6 +6579,7 @@ var init_suite_config = __esm({
|
|
|
6555
6579
|
"**/.{idea,git,cache,output,temp}/**",
|
|
6556
6580
|
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*"
|
|
6557
6581
|
];
|
|
6582
|
+
JS_UNWALKED = [...VITEST_DEFAULT_EXCLUDE, "**/.*/**"];
|
|
6558
6583
|
CANONICAL_SAMPLES = [
|
|
6559
6584
|
"src/a.test.ts",
|
|
6560
6585
|
"src/a.spec.ts",
|
|
@@ -6786,6 +6811,9 @@ function leavesGlob(dir, dest, policy, ctx) {
|
|
|
6786
6811
|
const to = dest.replace(/^\.\//, "").replace(/\/+$/, "") + "/";
|
|
6787
6812
|
return files.some((f) => f.startsWith(src) && isProtected(f, policy, "tests") && !isProtected(to + f.slice(src.length), policy, "tests"));
|
|
6788
6813
|
}
|
|
6814
|
+
function leavesWalk(from, to) {
|
|
6815
|
+
return runnerSkips(from) === null ? runnerSkips(to) : null;
|
|
6816
|
+
}
|
|
6789
6817
|
function pytestPrecedenceFindings(changes, policy, ctx) {
|
|
6790
6818
|
const touched = /* @__PURE__ */ new Map();
|
|
6791
6819
|
for (const c of changes) {
|
|
@@ -6902,6 +6930,15 @@ var init_test_deletion = __esm({
|
|
|
6902
6930
|
remediation: "Restoring the path. Renaming a spec out of the glob silently removes it from the suite."
|
|
6903
6931
|
})
|
|
6904
6932
|
);
|
|
6933
|
+
} else if (c.op === "rename" && c.oldPath && isSpec(c.oldPath) && isTest && leavesWalk(c.oldPath, c.path)) {
|
|
6934
|
+
out3.push(
|
|
6935
|
+
makeFinding(RULE8, policy, {
|
|
6936
|
+
file: c.path,
|
|
6937
|
+
message: `A test file was renamed into a path the runner does not walk (${c.oldPath} \u2192 ${c.path}): ${leavesWalk(c.oldPath, c.path)}.`,
|
|
6938
|
+
evidence: `${c.oldPath} \u2192 ${c.path}`,
|
|
6939
|
+
remediation: "Restoring the path. A spec the runner never opens is removed from the suite as surely as a deleted one."
|
|
6940
|
+
})
|
|
6941
|
+
);
|
|
6905
6942
|
} else if ((c.op === "modify" || c.op === "rename") && isTest && c.before != null && c.after != null) {
|
|
6906
6943
|
const before = countTests(c.before, c.path);
|
|
6907
6944
|
const after = countTests(c.after, c.path);
|
|
@@ -7014,6 +7051,9 @@ var init_test_deletion = __esm({
|
|
|
7014
7051
|
if (dest && testToks.length > 0 && !isSpec(dest)) {
|
|
7015
7052
|
why = "mv renames a test file out of the test glob";
|
|
7016
7053
|
evidence = `${testToks[0]} \u2192 ${dest}`;
|
|
7054
|
+
} else if (dest && testToks.length > 0 && testToks[0] !== dest && leavesWalk(testToks[0], dest)) {
|
|
7055
|
+
why = "mv renames a test file into a path the runner does not walk";
|
|
7056
|
+
evidence = `${testToks[0]} \u2192 ${dest}`;
|
|
7017
7057
|
} else if (dest && testToks.length === 0 && dirToks[0] !== dest && leavesGlob(dirToks[0] ?? "", dest, policy, ctx)) {
|
|
7018
7058
|
why = "mv renames a test directory so its specs leave the test glob";
|
|
7019
7059
|
evidence = `${dirToks[0]} \u2192 ${dest}`;
|
|
@@ -7535,7 +7575,9 @@ function key(f) {
|
|
|
7535
7575
|
function isSuppressed(c, policy) {
|
|
7536
7576
|
if (c.kind !== "file") return false;
|
|
7537
7577
|
if (isPolicyFile(c.path) || c.oldPath != null && isPolicyFile(c.oldPath)) return false;
|
|
7538
|
-
|
|
7578
|
+
if (!isIgnored(c.path, policy)) return false;
|
|
7579
|
+
if (c.oldPath == null) return true;
|
|
7580
|
+
return isIgnored(c.oldPath, policy) && !isProtected(c.oldPath, policy);
|
|
7539
7581
|
}
|
|
7540
7582
|
function activeChanges(changes, policy) {
|
|
7541
7583
|
return changes.filter((c) => !isSuppressed(c, policy));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tamperward",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.7",
|
|
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",
|