tamperward 2.10.0 → 2.10.1

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 +56 -0
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -4626,6 +4626,61 @@ function repoRelative(path, ctx) {
4626
4626
  const rel = relative(ctx.cwd, path);
4627
4627
  return rel && !rel.startsWith("..") && !isAbsolute3(rel) ? rel : path;
4628
4628
  }
4629
+ var HUSKY_SHIM = '#!/usr/bin/env sh\n. "$(dirname "$0")/h"';
4630
+ var HUSKY_SHIM_NAMES = /* @__PURE__ */ new Set(["applypatch-msg", "commit-msg", "post-applypatch", "post-checkout", "post-commit", "post-merge", "post-rewrite", "pre-applypatch", "pre-auto-gc", "pre-commit", "pre-merge-commit", "pre-push", "pre-rebase", "prepare-commit-msg"]);
4631
+ var HUSKY_H_KNOWN = [
4632
+ // husky 9.1.x
4633
+ `#!/usr/bin/env sh
4634
+ [ "$HUSKY" = "2" ] && set -x
4635
+ n=$(basename "$0")
4636
+ s=$(dirname "$(dirname "$0")")/$n
4637
+
4638
+ [ ! -f "$s" ] && exit 0
4639
+
4640
+ if [ -f "$HOME/.huskyrc" ]; then
4641
+ echo "husky - '~/.huskyrc' is DEPRECATED, please move your code to ~/.config/husky/init.sh"
4642
+ fi
4643
+ i="\${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh"
4644
+ [ -f "$i" ] && . "$i"
4645
+
4646
+ [ "\${HUSKY-}" = "0" ] && exit 0
4647
+
4648
+ export PATH="node_modules/.bin:$PATH"
4649
+ sh -e "$s" "$@"
4650
+ c=$?
4651
+
4652
+ [ $c != 0 ] && echo "husky - $n script failed (code $c)"
4653
+ [ $c = 127 ] && echo "husky - command not found in PATH=$PATH"
4654
+ exit $c
4655
+ `
4656
+ ];
4657
+ var HUSKY_DEPRECATION = `echo "husky - DEPRECATED
4658
+
4659
+ Please remove the following two lines from $0:
4660
+
4661
+ #!/usr/bin/env sh
4662
+ . \\"\\$(dirname -- \\"\\$0\\")/_/husky.sh\\"
4663
+
4664
+ They WILL FAIL in v10.0.0
4665
+ "`;
4666
+ var stripTrailingNl = (s) => s.endsWith("\n") ? s.slice(0, -1) : s;
4667
+ function huskyRuntimeWrite(path, content, ctx) {
4668
+ const m = path.match(/(?:^|\/)\.husky\/_\/([^/]+)$/);
4669
+ if (!m || content == null) return false;
4670
+ const name = m[1];
4671
+ const body = stripTrailingNl(content);
4672
+ const ok = name === ".gitignore" ? body === "*" : name === "h" ? HUSKY_H_KNOWN.some((t) => stripTrailingNl(t) === body) : name === "husky.sh" ? stripTrailingNl(HUSKY_DEPRECATION) === body : HUSKY_SHIM_NAMES.has(name) && body === HUSKY_SHIM;
4673
+ if (!ok) return false;
4674
+ if (!ctx?.cwd) return false;
4675
+ const root = path.slice(0, path.length - m[0].length + (m[0].startsWith("/") ? 1 : 0));
4676
+ const entry = inspectRel(join3(ctx.cwd, root), ".husky/pre-commit");
4677
+ if (entry.kind !== "file") return false;
4678
+ const gate = textOf(entry);
4679
+ if (gate == null) return false;
4680
+ return invocations(gate.split("\n"), { errexit: true }).some(
4681
+ (i) => i.identity === "tamperward check --staged" && i.state === "live" && i.pin === TW_VERSION
4682
+ );
4683
+ }
4629
4684
  var isHuskyScript = (path) => /(?:^|\/)\.husky\/[^/]+$/.test(path);
4630
4685
  var isHookNote = (path) => /\.(?:md|markdown|txt)$|(?:^|\/)\.git(?:ignore|attributes)$/i.test(path);
4631
4686
  var hookTampering = {
@@ -4700,6 +4755,7 @@ var hookTampering = {
4700
4755
  } else if ((isLefthook(c.path) || isPreCommitConfig(c.path)) && (semantic = configFindings(c, changes, policy, ctx)) !== null) {
4701
4756
  out2.push(...semantic);
4702
4757
  } else if (!c.path.endsWith(POLICY_FILE)) {
4758
+ if ((c.op === "add" || c.op === "modify") && huskyRuntimeWrite(c.path, c.after, ctx)) continue;
4703
4759
  const husky = isHuskyScript(c.path);
4704
4760
  const opts = husky ? { errexit: true } : {};
4705
4761
  const beforePin = c.before != null && c.after != null ? initScriptPin(c.before) : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tamperward",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
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",