@xynogen/pix-gate 0.4.3 → 0.4.4

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/package.json +1 -1
  2. package/src/lib.ts +4 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-gate",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Pi extension \u2014 permission gate for dangerous bash commands (confirm/block with TUI dialog)",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/lib.ts CHANGED
@@ -323,8 +323,11 @@ export function buildRules(cfg: UserConfig): {
323
323
  pathRules: PathRule[];
324
324
  } {
325
325
  const base = cfg.guardrails === "off" ? [] : DEFAULT_RULES.slice();
326
+ // `g`/`y` make RegExp.test() stateful (lastIndex), so the same command would
327
+ // match on one call and slip through on the next. Strip them.
328
+ const stateless = (flags: string) => flags.replace(/[gy]/g, "");
326
329
  const extra = (cfg.extraRules ?? []).map((r) => ({
327
- pattern: new RegExp(r.pattern, r.flags ?? "i"),
330
+ pattern: new RegExp(r.pattern, stateless(r.flags ?? "i")),
328
331
  severity: (r.severity ?? "dangerous") as Severity,
329
332
  reason: r.reason ?? "user-defined rule",
330
333
  }));