Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Stop the pre-push secret check flagging generated operation-loader lines (#9667)

Garry Tana77fee63c9fb
diff --git a/.gstack/pregate.json b/.gstack/pregate.json
index 826644c00d..dc8dee366b 100644
--- a/.gstack/pregate.json
+++ b/.gstack/pregate.json
@@ -239,6 +239,14 @@
],
"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"
+ },
+ {
+ "finding": "env.kv",
+ "paths": [
+ "src/core/operation-loaders.generated.ts"
+ ],
+ "pattern": "\\[load_[a-z0-9_]+, \"(?:[a-z][A-Za-z]*Operations|[a-z]+(?:_[a-z]+)+)\"\\],?$",
+ "reason": "generated operation-loader table: each value is a loader identifier and an operations export name, never a credential; an operation named like a secret (reveal_secret) trips the key-name heuristic"
}
]
}
diff --git a/changelog.d/pregate-allow-op-loaders.md b/changelog.d/pregate-allow-op-loaders.md
new file mode 100644
index 0000000000..57019426b5
--- /dev/null
+++ b/changelog.d/pregate-allow-op-loaders.md
@@ -0,0 +1,6 @@
+**The pre-push secret check no longer flags the generated operation-loader table when an operation's name looks like a secret.**
+
+<!-- public-surface: no-behavior-change: a repository pre-push check allowlist entry; gbrain itself is unchanged -->
+
+### Fixed
+- `.gstack/pregate.json` allows the `env.kv` finding on `src/core/operation-loaders.generated.ts` only for values shaped `[load_<module>, "<name>Operations"]`, which are a loader identifier and an export name. Any other value in that file stays flagged.
diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsv
index fee588da52..7de0cc4f0d 100644
--- a/scripts/structural-suites.tsv
+++ b/scripts/structural-suites.tsv
@@ -288,6 +288,7 @@ test/postgres-driver-vendor.test.ts vendored Postgres driver packaging 5 readFil
test/postgres-engine.test.ts postgres-engine / search date filtering 2 source-surface-helper
test/postgres-engine.test.ts postgres-engine / search path timeout isolation 7 source-surface-helper
test/postgres15-sql-compat-7112.test.ts #7112: shipped SQL parses on every supported Postgres (15+) 2 readFileSync
+test/pregate-allowlist-cache-keys.test.ts (file-level) 6 readFileSync
test/private-visibility.test.ts shared private predicate lives once (#4352 remediation) 1 readFileSync
test/purge-root-metafile-7613.test.ts (file-level) 3 readFileSync
test/q2-typing-package.test.ts (file-level) 3 readFileSync
diff --git a/test/pregate-allowlist-cache-keys.test.ts b/test/pregate-allowlist-cache-keys.test.ts
index f11438ec91..2e1fdd1e04 100644
--- a/test/pregate-allowlist-cache-keys.test.ts
+++ b/test/pregate-allowlist-cache-keys.test.ts
@@ -1,6 +1,7 @@
/**
* .gstack/pregate.json allowlists gstack's `env.kv` secrets finding on the PGLite snapshot cache-key lines of the
- * workflow files, and nothing else. gstack (lib/pregate/allowlist.ts) tests an entry's pattern anchored at the
+ * workflow files and on the generated operation-loader lines (an operation named like a secret, such as reveal_secret),
+ * and nothing else. gstack (lib/pregate/allowlist.ts) tests an entry's pattern anchored at the
* finding's column in the added line, as `^(?:pattern)(?![\w-])`; for `env.kv` that column is the value after
* `key: `. This file applies the same anchoring to every cache-key line in .github/workflows (each must be covered)
* and to secret-shaped values (none may be).
@@ -12,7 +13,11 @@ import { join } from 'node:path';
const ROOT = join(import.meta.dir, '..');
const policy = JSON.parse(readFileSync(join(ROOT, '.gstack/pregate.json'), 'utf8')) as { allowlist: Array<{ finding: string; paths?: string[]; pattern?: string; reason: string }> };
const entries = policy.allowlist.filter(e => e.finding === 'env.kv');
-const covers = (value: string) => entries.some(e => new RegExp(`^(?:${e.pattern})(?![\\w-])`).test(value));
+const LOADERS = 'src/core/operation-loaders.generated.ts';
+const entryFor = (path: string) => entries.find(e => e.paths?.includes(path));
+const anchored = (pattern: string | undefined, value: string) => new RegExp(`^(?:${pattern})(?![\\w-])`).test(value);
+const covers = (value: string) => anchored(entryFor('.github/workflows/*.yml')?.pattern, value);
+const coversLoader = (value: string) => anchored(entryFor(LOADERS)?.pattern, value);
const WORKFLOWS = join(ROOT, '.github/workflows');
const cacheKeyValues = readdirSync(WORKFLOWS).filter(f => f.endsWith('.yml')).flatMap(f =>
@@ -22,10 +27,11 @@ const cacheKeyValues = readdirSync(WORKFLOWS).filter(f => f.endsWith('.yml')).fl
}));
describe('pregate allowlist: workflow cache keys', () => {
- test('one env.kv entry, scoped to workflow files and a pattern', () => {
- expect(entries).toHaveLength(1);
+ test('two env.kv entries: this one, scoped to workflow files and a pattern, and the operation-loader one', () => {
+ expect(entries).toHaveLength(2);
expect(entries[0]!.paths).toEqual(['.github/workflows/*.yml']);
expect(typeof entries[0]!.pattern).toBe('string');
+ expect(entries[1]).toEqual({ finding: 'env.kv', paths: [LOADERS], pattern: '\\[load_[a-z0-9_]+, "(?:[a-z][A-Za-z]*Operations|[a-z]+(?:_[a-z]+)+)"\\],?$', reason: expect.any(String) });
});
test('every pglite-snapshot cache key in the workflows is covered', () => {
@@ -57,3 +63,30 @@ describe('pregate allowlist: workflow cache keys', () => {
expect(performance.now() - started).toBeLessThan(500);
});
});
+
+describe('pregate allowlist: generated operation loaders', () => {
+ // test-reads-source-ok[generated-artifact]: the allowlist must cover every line the checked-in generated loader table holds.
+ const generated = readFileSync(join(ROOT, LOADERS), 'utf8').split('\n').flatMap(line => {
+ const at = line.indexOf('[load_');
+ return at < 0 ? [] : [line.slice(at)];
+ });
+
+ test('every loader line in the generated table is covered, a secret-named operation included', () => {
+ expect(generated.length).toBeGreaterThan(0);
+ for (const value of generated) expect({ value, covered: coversLoader(value) }).toEqual({ value, covered: true });
+ expect(coversLoader('[load_secrets, "secretsOperations"],')).toBe(true);
+ });
+
+ test('a credential-shaped value in that file is still flagged', () => {
+ const key = ['sk', 'proj', 'Zx9Qw8Lk2Mn4Bv6Cx1Za3Sd5Fg7Hj9Kl0Pq2Wr4'].join('-');
+ for (const value of [
+ `"${key}"`,
+ `[load_secrets, "${key}"],`,
+ `[load_secrets, "secretsOperations", "${key}"],`,
+ `[load_secrets, "secretsOperations"], "${key}"`,
+ `[${key}, "secretsOperations"],`,
+ `[load_secrets, "${['AKIA', 'EXAMPLENOTREAL00'].join('')}"],`,
+ `[load_secrets, "${['f8a7b6c5d4', 'e3f2a1b0c9'].join('')}"],`,
+ ]) expect({ value, covered: coversLoader(value) }).toEqual({ value, covered: false });
+ });
+});