Security audit fixes: docs (security.md, content.md, i18n.md, AGENT.md, skills), changelog, static-rule judgments for the merged doctor and 2FA code, hook mark for the account-rule tests
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e9f9947eb7
commit
e5964d4e05
@@ -69,6 +69,9 @@ export class RefusedSortError extends APIError {
|
||||
}
|
||||
}
|
||||
|
||||
/** Marks the hook {@link buildQueryGuardHook} made, like the plugin's other hooks (`Symbol.for('iapl.…')`). */
|
||||
export const QUERY_GUARD_MARK = Symbol.for('iapl.queryGuard')
|
||||
|
||||
const LIST_OPERATIONS = new Set(['findVersions', 'read', 'readDistinct'])
|
||||
|
||||
/**
|
||||
@@ -82,7 +85,7 @@ export function buildQueryGuardHook(options: {
|
||||
}): CollectionBeforeOperationHook {
|
||||
const limit = options.listLimit === false ? null : { max: DEFAULT_LIST_LIMIT, staff: false, ...options.listLimit }
|
||||
const refuseSort = options.refuseOperatorSort !== false
|
||||
return (({ args, collection, operation, req }: HookArgs) => {
|
||||
const iaplQueryGuard = (({ args, collection, operation, req }: HookArgs) => {
|
||||
if (!LIST_OPERATIONS.has(operation) || !fromOutside(req)) {return args}
|
||||
const list = args as ListArgs
|
||||
if (refuseSort && isOperatorSort(list.sort)) {
|
||||
@@ -92,8 +95,12 @@ export function buildQueryGuardHook(options: {
|
||||
if (!limit.staff && isStaffRequest(req)) {return args}
|
||||
return capListLimit(list, limit.max)
|
||||
}) as CollectionBeforeOperationHook
|
||||
return Object.assign(iaplQueryGuard, { [QUERY_GUARD_MARK]: true })
|
||||
}
|
||||
|
||||
/** True for a hook {@link buildQueryGuardHook} made: for tests and tools that count a collection's hooks. */
|
||||
export const isQueryGuardHook = (hook: unknown): boolean => typeof hook === 'function' && Boolean((hook as unknown as Record<symbol, unknown>)[QUERY_GUARD_MARK])
|
||||
|
||||
/** The hook added to every collection of the config (the project's, the plugin's, other plugins' before iapl). */
|
||||
export function applyQueryGuard(
|
||||
config: Config,
|
||||
|
||||
Reference in New Issue
Block a user