Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: drop the redundant ** alternative from the pregate allowlist hashFiles argument (exponential backtracking on a long /** chain); timing probe stays under 500 ms

garrytan93612efb0a7d
diff --git a/.gstack/pregate.json b/.gstack/pregate.json
index 5c1fe0ed94..88211f0ea2 100644
--- a/.gstack/pregate.json
+++ b/.gstack/pregate.json
@@ -135,7 +135,7 @@
"paths": [
".github/workflows/*.yml"
],
- "pattern": "pglite-snapshot-(?:default-)?\\$\\{\\{ runner\\.os \\}\\}-\\$\\{\\{ hashFiles\\('(?:src|test|scripts)(?:/(?:\\*\\*|[a-z*][a-z*_-]*(?:\\.[a-z]+)?))+'(?:, '(?:src|test|scripts)(?:/(?:\\*\\*|[a-z*][a-z*_-]*(?:\\.[a-z]+)?))+')*\\) \\}\\}$",
+ "pattern": "pglite-snapshot-(?:default-)?\\$\\{\\{ runner\\.os \\}\\}-\\$\\{\\{ hashFiles\\('(?:src|test|scripts)(?:/[a-z*][a-z*_-]*(?:\\.[a-z]+)?)+'(?:, '(?:src|test|scripts)(?:/[a-z*][a-z*_-]*(?:\\.[a-z]+)?)+')*\\) \\}\\}$",
"reason": "GitHub Actions PGLite snapshot cache keys: the whole value is pglite-snapshot-[default-]${{ runner.os }}-${{ hashFiles(<args>) }} and every argument is a lowercase path or glob under src/, test/ or scripts/; an argument with digits, capitals or a ./ prefix is not covered and stays flagged"
}
]
diff --git a/test/pregate-allowlist-cache-keys.test.ts b/test/pregate-allowlist-cache-keys.test.ts
index 0e2fad6214..f11438ec91 100644
--- a/test/pregate-allowlist-cache-keys.test.ts
+++ b/test/pregate-allowlist-cache-keys.test.ts
@@ -49,4 +49,11 @@ describe('pregate allowlist: workflow cache keys', () => {
"pglite-snapshot-${{ runner.os }}-${{ hashFiles('src/*.ts', 'src/Zx9Qw8Lk2Mn4Bv6Cx1Za3Sd5Fg7Hj9Kl0Pq2Wr4.ts') }}",
]) expect({ value, covered: covers(value) }).toEqual({ value, covered: false });
});
+
+ test('a long ** chain in a hashFiles argument is rejected without backtracking', () => {
+ const value = "pglite-snapshot-${{ runner.os }}-${{ hashFiles('src" + '/**'.repeat(26) + "X') }}";
+ const started = performance.now();
+ expect(covers(value)).toBe(false);
+ expect(performance.now() - started).toBeLessThan(500);
+ });
});