tamperward 2.2.1 → 2.3.0

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.
Files changed (2) hide show
  1. package/dist/cli/index.js +96 -5
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -3907,18 +3907,62 @@ var VERIFICATION_SURFACE = [
3907
3907
  "**/setup.cfg",
3908
3908
  "**/tox.ini",
3909
3909
  "**/pyproject.toml",
3910
+ "**/setup.py",
3911
+ // a pytest rootdir marker, and what an editable install executes
3912
+ // Interpreter start-up hooks: imported by site.py before pytest exists,
3913
+ // wherever the tree reaches sys.path (PYTHONPATH=., an editable install).
3914
+ "**/sitecustomize.py",
3915
+ "**/usercustomize.py",
3910
3916
  // JavaScript / TypeScript runners and the transforms they load
3911
3917
  "**/jest.config.*",
3912
3918
  "**/jest.setup.*",
3913
3919
  "**/vitest.config.*",
3914
3920
  "**/vitest.workspace.*",
3915
3921
  "**/.mocharc.*",
3922
+ "**/mocha.opts",
3916
3923
  "**/karma.conf.*",
3924
+ "**/ava.config.*",
3925
+ "**/.taprc",
3926
+ "**/spec/support/jasmine.json",
3927
+ "**/playwright.config.*",
3928
+ "**/cypress.config.*",
3929
+ "**/.nycrc*",
3930
+ "**/.c8rc*",
3917
3931
  "**/babel.config.*",
3918
3932
  "**/.babelrc*",
3919
3933
  "**/vite.config.*",
3920
3934
  "**/.swcrc",
3921
3935
  "**/package.json",
3936
+ // Package-manager configuration: read before the runner starts, and able to
3937
+ // choose what the runner is started under (`node-options`), which shell runs
3938
+ // the script (`script-shell`), or which program is run at all (`yarn-path`).
3939
+ "**/.npmrc",
3940
+ "**/.yarnrc",
3941
+ "**/.yarnrc.yml",
3942
+ // pnpm 10 reads its settings (`nodeOptions` among them) from here as well,
3943
+ // and its environment layer does NOT outrank this file (verified, pnpm
3944
+ // 10.33) — so the file list is the only control for it.
3945
+ "**/pnpm-workspace.yaml",
3946
+ "**/.pnpmfile.cjs",
3947
+ // The runner the package manager executes when the project pins one: yarn's
3948
+ // `yarnPath` release and its plugins, and the PnP loader every spawned node
3949
+ // is made to `--require`.
3950
+ "**/.yarn/releases/*",
3951
+ "**/.yarn/plugins/**",
3952
+ "**/.pnp.cjs",
3953
+ "**/.pnp.js",
3954
+ "**/.pnp.loader.mjs",
3955
+ // dotenv files: `node --env-file`, a jest/vitest setup that loads dotenv,
3956
+ // pytest-dotenv. An .env carries NODE_OPTIONS as easily as an .npmrc does.
3957
+ "**/.env",
3958
+ "**/.env.*",
3959
+ // Version-manager pins: which interpreter the shims select for this cwd.
3960
+ "**/.nvmrc",
3961
+ "**/.node-version",
3962
+ "**/.python-version",
3963
+ // What git does to content on its way into and out of the tree — the base's
3964
+ // decision, never the candidate's.
3965
+ "**/.gitattributes",
3922
3966
  // Ruby / PHP / .NET
3923
3967
  "**/.rspec",
3924
3968
  "**/phpunit.xml",
@@ -4064,6 +4108,31 @@ const timer = setTimeout(() => finish({ timedOut: true }), Number(budgetMs));
4064
4108
  child.on('error', (e) => { clearTimeout(timer); finish({ error: String(e) }); });
4065
4109
  child.on('exit', (code, signal) => { clearTimeout(timer); finish({ exit: code, signal }); });
4066
4110
  `;
4111
+ var DROPPED_ENV = /* @__PURE__ */ new Set([
4112
+ "NODE_OPTIONS",
4113
+ "NODE_PATH",
4114
+ "NODE_REPL_EXTERNAL_MODULE",
4115
+ "PYTHONPATH",
4116
+ "PYTHONSTARTUP",
4117
+ "PYTEST_ADDOPTS",
4118
+ "PYTEST_PLUGINS"
4119
+ ]);
4120
+ var PINNED_NPM = /^npm_config_(node_options|userconfig|globalconfig)$/i;
4121
+ function suiteEnv(scratch) {
4122
+ const env = {};
4123
+ for (const [k, v] of Object.entries(process.env)) {
4124
+ if (DROPPED_ENV.has(k) || PINNED_NPM.test(k)) continue;
4125
+ env[k] = v;
4126
+ }
4127
+ const userRc = join11(scratch, "npmrc-user");
4128
+ const globalRc = join11(scratch, "npmrc-global");
4129
+ for (const f of [userRc, globalRc]) writeFileSync6(f, "", { mode: 292 });
4130
+ env.npm_config_userconfig = userRc;
4131
+ env.npm_config_globalconfig = globalRc;
4132
+ env.npm_config_node_options = " ";
4133
+ env.YARN_IGNORE_PATH = "1";
4134
+ return env;
4135
+ }
4067
4136
  function runSuite(dir, cmd, budgetSecs) {
4068
4137
  const t0 = Date.now();
4069
4138
  const outDir = mkdtempSync2(join11(tmpdir2(), "tw-verify-run-"));
@@ -4071,6 +4140,7 @@ function runSuite(dir, cmd, budgetSecs) {
4071
4140
  try {
4072
4141
  spawnSync(process.execPath, ["-e", SUPERVISOR, cmd, String(budgetSecs * 1e3), outFile], {
4073
4142
  cwd: dir,
4143
+ env: suiteEnv(outDir),
4074
4144
  stdio: "ignore",
4075
4145
  timeout: budgetSecs * 1e3 + 3e4,
4076
4146
  // backstop only; the supervisor enforces the budget
@@ -4093,6 +4163,10 @@ function runSuite(dir, cmd, budgetSecs) {
4093
4163
  function runVerify(opts) {
4094
4164
  const cwd = opts.cwd ?? process.cwd();
4095
4165
  const out2 = (s) => void process.stdout.write(s + "\n");
4166
+ if (opts.invalid) {
4167
+ out2(`verify: ${opts.invalid} \u2014 failing closed`);
4168
+ return 2;
4169
+ }
4096
4170
  let policy;
4097
4171
  try {
4098
4172
  if (opts.policyOverride) policy = opts.policyOverride;
@@ -4236,15 +4310,32 @@ function runVerify(opts) {
4236
4310
  }
4237
4311
  function parseVerify(args) {
4238
4312
  const o = {};
4313
+ const value = (i, flag) => {
4314
+ const v = args[i + 1];
4315
+ if (v === void 0 || v.startsWith("--")) {
4316
+ o.invalid ??= `${flag} needs a value` + (v === void 0 ? "" : ` (got the flag "${v}")`);
4317
+ return void 0;
4318
+ }
4319
+ return v;
4320
+ };
4239
4321
  for (let i = 0; i < args.length; i++) {
4240
4322
  const a = args[i];
4241
- if (a === "--base" && args[i + 1]) o.base = args[++i];
4242
- else if (a === "--cmd" && args[i + 1]) o.cmd = args[++i];
4243
- else if (a === "--budget" && args[i + 1]) o.budget = Number(args[++i]);
4244
- else if (a === "--json") o.json = true;
4323
+ if (a === "--json") o.json = true;
4245
4324
  else if (a === "--keep") o.keep = true;
4246
4325
  else if (a === "--require-ancestor") o.requireAncestor = true;
4247
- else if (a === "--cwd" && args[i + 1]) o.cwd = args[++i];
4326
+ else if (a === "--base" || a === "--cmd" || a === "--cwd" || a === "--budget") {
4327
+ const v = value(i, a);
4328
+ if (v === void 0) continue;
4329
+ i++;
4330
+ if (a === "--base") o.base = v;
4331
+ else if (a === "--cmd") o.cmd = v;
4332
+ else if (a === "--cwd") o.cwd = v;
4333
+ else {
4334
+ o.budget = Number(v);
4335
+ if (!Number.isFinite(o.budget) || o.budget <= 0)
4336
+ o.invalid ??= `--budget needs a positive number of seconds (got "${v}")`;
4337
+ }
4338
+ }
4248
4339
  }
4249
4340
  return o;
4250
4341
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tamperward",
3
- "version": "2.2.1",
3
+ "version": "2.3.0",
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",