@xynogen/pix-gate 0.2.0 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-gate",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Pi extension — permission gate for dangerous bash commands (confirm/block with TUI dialog)",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@xynogen/pix-pretty": "^1.7.9",
46
46
  "@xynogen/pix-data": "^0.4.0",
47
- "@xynogen/pix-runtime": "^0.3.0"
47
+ "@xynogen/pix-runtime": "^0.4.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "@earendil-works/pi-coding-agent": "*",
package/src/gate.test.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, test } from "bun:test";
2
- import { buildRules, classify, DEFAULT_RULES, isSudoCommand } from "./lib.ts";
2
+ import { buildRules, classify, DEFAULT_RULES, extractPathsFromBash, isSudoCommand } from "./lib.ts";
3
3
 
4
4
  // ── isSudoCommand ─────────────────────────────────────────────────────────────
5
5
 
@@ -102,6 +102,21 @@ describe("classify", () => {
102
102
  });
103
103
  });
104
104
 
105
+ // ── extractPathsFromBash ─────────────────────────────────────────────────────
106
+
107
+ describe("extractPathsFromBash", () => {
108
+ test("does not treat the jq .key selector as a key file", () => {
109
+ expect(extractPathsFromBash("jq '.key' data.json")).toEqual([]);
110
+ expect(extractPathsFromBash("jq -r '.key' data.json")).toEqual([]);
111
+ });
112
+
113
+ test("still extracts key file paths", () => {
114
+ expect(extractPathsFromBash("cat private.key")).toContain("private.key");
115
+ expect(extractPathsFromBash("cat .private.key")).toContain(".private.key");
116
+ expect(extractPathsFromBash("jq '.' .private.key")).toContain(".private.key");
117
+ });
118
+ });
119
+
105
120
  // ── buildRules ────────────────────────────────────────────────────────────────
106
121
 
107
122
  describe("buildRules", () => {
package/src/lib.ts CHANGED
@@ -280,7 +280,7 @@ export function classifyPath(
280
280
  export function extractPathsFromBash(cmd: string): string[] {
281
281
  const out: string[] = [];
282
282
  const re =
283
- /(?:^|[\s=><|;&"'`(])((?:\.\.\/|\/|~\/|\.)[^\s"'`<>|;&)]+|\.env(?:\.[A-Za-z0-9_-]+)?|[A-Za-z0-9_./-]+\.(?:pem|key|p12|pfx|crt|cer|env|envrc|netrc))/g;
283
+ /(?:^|[\s=><|;&"'`(])((?:\.\.\/|\.\/|\/|~\/)[^\s"'`<>|;&)]+|\.env(?:\.[A-Za-z0-9_-]+)?|[A-Za-z0-9_./-]+\.(?:pem|key|p12|pfx|crt|cer|env|envrc|netrc))/g;
284
284
  for (const m of cmd.matchAll(re)) out.push(m[1] ?? "");
285
285
  return out;
286
286
  }