Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 16:00 UTC
refactor(cli): rename LocalToolkitSlugs.match to longestPrefix (#4145)
## Summary Renames `LocalToolkitSlugs.match` to `longestPrefix` to clear CodeQL code-scanning alert [#113](https://github.com/ComposioHQ/composio/security/code-scanning/113) (`js/regex-injection`, high). ## Why The alert flagged `local.match(toolSlug)` in `toolkit-from-tool-slug.ts` as a regular expression constructed from a command-line argument. It is a false positive: `local` is a `LocalToolkitSlugs` object, and its `match` member is a custom longest-prefix matcher (`makeLongestPrefixMatcher`) that only does `toolSlug.toLowerCase().split('_')` plus `Set` membership lookups — no `RegExp` is ever constructed. CodeQL's `js/regex-injection` sink is keyed on the `match` member name (matching `String.prototype.match`, which coerces a string argument into a `RegExp`), so it could not tell the custom method apart from the string sink. The member name `match` on a non-string object invited exactly that confusion — for the analyzer and for human readers. Renaming it to `longestPrefix` (mirroring the underlying `makeLongestPrefixMatcher` / `longestPrefix` helper) removes the false positive without suppressing anything, and reads more clearly. ## Changes - `services/toolkit-slug-catalog.ts`: interface member and object literal `match` → `longestPrefix` - `effects/toolkit-from-tool-slug.ts`: call site `local.match(...)` → `local.longestPrefix(...)` ## Verification - `pnpm typecheck` — 14/14 packages pass - lint-staged (oxlint + prettier) clean on commit The alert should clear on the next CodeQL scan of the merged commit.