mirror of
https://github.com/stablyai/orca.git
synced 2026-11-15 18:37:24 +00:00
* fix(plugins): protect every security and destructive string from language packs Language packs could rewrite trust copy outside a hand-kept list of app areas (catalog-link dialog, browser-extension Allow/Deny, Node mirror). Protected keys are now generated from structure: every key in a file that renders a security surface, a destructive confirmation, or a native message box, or that carries a // @protected-copy pragma, plus same-directory copy modules. verify:localization-catalogs fails when the list is stale. Pack strings are also capped at max(64, 4x English) characters and may not contain control or bidi characters. Validation stays strict; loading drops only the offending entries. * chore(plugins): resync protected copy keys with main * fix(plugins): cap pack strings in shared strict checks and pin new trust copy * fix(plugins): keep the packaged CLI off the English catalog * chore(plugins): resync protected copy keys with main * chore(plugins): resync protected copy keys with main
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
// Generated by config/scripts/protected-copy-keys.mjs from security surfaces, destructive
|
|
// confirmations, native message boxes and `// @protected-copy` files.
|
|
import protectedCopy from './protected-copy-keys.json'
|
|
|
|
const PROTECTED_COPY_KEYS: ReadonlySet<string> = new Set(protectedCopy.keys)
|
|
const PROTECTED_COPY_PREFIXES: readonly string[] = protectedCopy.prefixes
|
|
const PLURAL_SUFFIX_RE = /_(?:zero|one|two|few|many|other)$/
|
|
|
|
/** True when `path` (or a plural form or child of it) is a protected copy key. */
|
|
export function isProtectedCopyPath(path: string): boolean {
|
|
if (PROTECTED_COPY_PREFIXES.some((prefix) => path.startsWith(prefix))) {
|
|
return true
|
|
}
|
|
let candidate = path
|
|
while (candidate) {
|
|
if (
|
|
PROTECTED_COPY_KEYS.has(candidate) ||
|
|
PROTECTED_COPY_KEYS.has(candidate.replace(PLURAL_SUFFIX_RE, ''))
|
|
) {
|
|
return true
|
|
}
|
|
const parent = candidate.lastIndexOf('.')
|
|
candidate = parent === -1 ? '' : candidate.slice(0, parent)
|
|
}
|
|
return false
|
|
}
|
|
|
|
/** The generated keys, for tests that pin specific trust copy. */
|
|
export function protectedCopyKeys(): ReadonlySet<string> {
|
|
return PROTECTED_COPY_KEYS
|
|
}
|