Skip to content

fix(detection): drop registry paths from search_code_patterns output - #209

Open
rudycelekli wants to merge 1 commit into
uber:mainfrom
rudycelekli:fix/detection-code-pattern-search-paths
Open

rudycelekli wants to merge 1 commit into
uber:mainfrom
rudycelekli:fix/detection-code-pattern-search-paths

Conversation

@rudycelekli

Copy link
Copy Markdown

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Related issue: N/A (found by reading the code; reproduced on main at 6b33dff)

What changed?
Map entries to name/category/description/capabilities, same as list_mcp_servers.

Why?
Context_providers/source_code_analyzer_server.py search_code_patterns returns filtered_servers (raw source_codes_registry.yaml entries) as available_servers, including path. All 26 vulnerable servers have paths under source_codes/mcp_servers_1/ (README: "Vulnerable tools (26 servers)"), so a reasoning-agent call to this tool (all tools of the server are reachable; no --allowedTools restriction) reveals the dataset label. The module's own design says "No pre-analysis or cheating metadata"; list_mcp_servers strips path, and get_source_code returns relative paths "so dataset directory names do not become classifier hints".

How did you test it?

  • Reproduction: probe on main: search_code_patterns('x')['available_servers'] paths -> {'mcp_servers_0': 78, 'mcp_servers_1': 26, 'mcp_servers_2': 12}. New test test_search_code_patterns_omits_registry_paths: main fails, branch passes (28 passed in that file).
  • Test suite: pytest tests/ -q -> 257 passed, 1 failed: test_kills_grandchild_process_holding_inherited_stdio (known load-flaky, untouched code; load average ~50; passed on immediate rerun).
  • Not tested: whether the paper's reasoning runs ever called this tool.

Potential risks
The change only affects the input described above; other paths go through the same code as before, and the component's existing tests pass.

AI assistance: Claude Code (model Claude Opus 5.5) found this bug, wrote the fix and test, and drafted this description; submitted by @rudycelekli.

🤖 Generated with Claude Code

search_code_patterns returned raw source registry entries, including
`path` values such as source_codes/mcp_servers_1/..., so the reasoning
agent could read the benign/vulnerable/environment dataset split from
the directory name. list_mcp_servers and get_source_code already strip
these hints. Return the same name/category/description/capabilities
metadata as list_mcp_servers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants