-
Notifications
You must be signed in to change notification settings - Fork 0
Add kernel.use fallback to plugin-security hook registration #366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add kernel.use fallback to plugin-security hook registration #366
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes plugin-security hook registration compatibility by adding a kernel.use() fallback when ctx.hook() is not available, aligning behavior with the established pattern used by other plugins (e.g. multi-tenancy) and unblocking test mocks.
Changes:
- Added
kernel.use(name, handler)fallback inregisterSecurityHooks()whenctx.hookis not provided. - Kept existing fallback to
kernel.hooks.register(...)and warning when no hook registration mechanism exists.
| } 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); |
Copilot
AI
Feb 10, 2026
There was a problem hiding this comment.
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.
| (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); | |
| } |
CI failing with 7 test failures in
plugin-security. Hook registration was missingkernel.usefallback, causing test mocks to fail.Changes
Added
kernel.usefallback to match the pattern inplugin-multitenancy:This provides compatibility with test mocks and legacy kernel implementations that use the simpler
kernel.use()API.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
fastdl.mongodb.org/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/objectql/objectql/node_modules/.bin/../vitest/vitest.mjs run(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/objectql/objectql/node_modules/.bin/../vitest/vitest.mjs run --reporter=verbose conf�� get --global s pull.rebase(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.