feat(ql3): harden cluster secret projection checks

This commit is contained in:
whyour committed 2026-08-13 11:45:42 +08:00
1 parent 8ba27dc148
commit 5e70b89f55
7 files changed
+321 -59

No files matched your search

@@ -0,0 +1,18 @@
import { createHash } from 'node:crypto';
import { parseSecretRef } from './secretReference';
export const SECRET_PROJECTION_FILE_NAME_PATTERN = /^[0-9a-f]{64}$/;
/**
* Maps one canonical SecretRef to a path-free, non-reversible projection key.
* The function does not inspect or resolve Secret material.
*/
export function secretProjectionFileName(secretRef: string): string {
parseSecretRef(secretRef);
const result = createHash('sha256').update(secretRef, 'utf8').digest('hex');
if (!SECRET_PROJECTION_FILE_NAME_PATTERN.test(result)) {
throw new TypeError('Secret projection file name is invalid');
}
return result;
}