Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/foundation/plugin-security/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ export class ObjectQLSecurityPlugin implements RuntimePlugin {
const registerHook = (name: string, handler: any) => {
if (typeof ctx.hook === 'function') {
ctx.hook(name, handler);
} else if (typeof (kernel as any).use === 'function') {
(kernel as any).use(name, handler);
} else if (typeof (kernel as any).hooks?.register === 'function') {
(kernel as any).hooks.register(name, handler);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kernel.hooks.register is invoked with only (name, handler), but in this repo the hook manager registration API is typically (event, objectName, handler, packageName?) (e.g. ObjectQL.on() delegates to kernel.hooks.register(event, objectName, handler, packageName)). If this branch is hit, hooks may be registered with the wrong arguments. Consider passing a wildcard object name (e.g. '*') and/or branching on kernel.hooks.register.length to support both 2-arg and 3+/4-arg signatures safely.

Suggested change
(kernel as any).hooks.register(name, handler);
const hooks = (kernel as any).hooks;
// Support both 2-arg and 3+/4-arg hook registration APIs.
// Typical kernel.hooks.register signature in this repo: (event, objectName, handler, packageName?)
if (typeof hooks.register === 'function' && hooks.register.length >= 3) {
// Use wildcard objectName so security hooks apply to all objects.
hooks.register(name, '*', handler);
} else {
// Fallback for runtimes that only support (name, handler).
hooks.register(name, handler);
}

Copilot uses AI. Check for mistakes.
} else {
Expand Down
Loading