@devries-cameron20 / composio-1 / commits / a71b812db
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

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.

Alberto Schiabel committed Aug 16, 2026 at 18:33 UTC a71b812db1b00c2566ef0656ec9fbe214a6597d4
2 files changed +3 -3
ts/packages/cli/src/effects/toolkit-from-tool-slug.ts
+1 -1
@@ -38,7 +38,7 @@ export const toolkitFromToolSlug = (
38 const catalog = yield* ToolkitSlugCatalog;
39 const local = yield* catalog.local;
40
41 - const match = local.match(toolSlug);
41 + const match = local.longestPrefix(toolSlug);
42 if (match !== undefined) {
43 return toolkitFromMatchedPrefix(match);
44 }
ts/packages/cli/src/services/toolkit-slug-catalog.ts
+2 -2
@@ -74,7 +74,7 @@ export interface LocalToolkitSlugs {
74 * or undefined when nothing local matches — which is what a toolkit released
75 * after this binary looks like.
76 */
77 - readonly match: (toolSlug: string) => string | undefined;
77 + readonly longestPrefix: (toolSlug: string) => string | undefined;
78 }
79
80 const loadLocalToolkitSlugs = Effect.gen(function* () {
@@ -83,7 +83,7 @@ const loadLocalToolkitSlugs = Effect.gen(function* () {
83
84 yield* refreshInBackgroundIfStale(learned);
85
86 - return { slugs, match: makeLongestPrefixMatcher(slugs) } satisfies LocalToolkitSlugs;
86 + return { slugs, longestPrefix: makeLongestPrefixMatcher(slugs) } satisfies LocalToolkitSlugs;
87 });
88
89 /**