Skip to content

feat(utils): add shared scanner package with MCP runner and RunAll orchestrator#1738

Merged
paralta merged 2 commits into
mainfrom
feat/security-scan-refactor
Jul 2, 2026
Merged

feat(utils): add shared scanner package with MCP runner and RunAll orchestrator#1738
paralta merged 2 commits into
mainfrom
feat/security-scan-refactor

Conversation

@paralta

@paralta paralta commented Jul 1, 2026

Copy link
Copy Markdown
Member

The dir-importer had all security scanning logic isolated within its own packages, making it impossible for the reconciler to reuse it without duplication. This PR introduces utils/scanner as the shared home for scanner interfaces and runner implementations, so both the importer (companion PR in dir-importer to follow) and the upcoming reconciler scan task can call into the same code.

The package exposes three things: a Runner interface that any scanner CLI wrapper implements; a RunAll function that executes all registered runners against a *corev1.Record, merges results, and returns a single ScanResult; and MCPRunner, the first concrete runner, which clones the record's source repository and invokes mcp-scanner behavioral --raw to detect malicious MCP server behaviours. Tests cover both the merge logic and RunAll's error-handling contracts (partial failure, all-fail, no runners).

  • Runner takes *corev1.Record directly rather than an intermediate input type, which required adding github.com/agntcy/dir/api as a dependency of utils/. This is intentional — utils/ is released in lockstep with api/, so the coupling is expected.
  • RunAll returns an error only when all runners fail; a partial failure is logged and skipped so a transient scanner outage does not silently reject records downstream.
  • merge is unexported; RunAll is the only public entry point for orchestration, keeping the surface area minimal for callers.

…chestrator

Signed-off-by: Catarina Paralta <clouropa@cisco.com>
@paralta paralta linked an issue Jul 1, 2026 that may be closed by this pull request
2 tasks
@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Jul 1, 2026
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.64286% with 51 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
utils/scanner/mcp.go 57.9% 51 Missing ⚠️

📢 Thoughts on this report? Let us know!

Signed-off-by: Catarina Paralta <clouropa@cisco.com>
@github-actions github-actions Bot added size/L Denotes a PR that changes 1000-1999 lines and removed size/M Denotes a PR that changes 200-999 lines labels Jul 1, 2026
@paralta
paralta marked this pull request as ready for review July 2, 2026 09:09
@paralta
paralta requested a review from a team as a code owner July 2, 2026 09:09
@paralta
paralta merged commit 845adae into main Jul 2, 2026
33 checks passed
@paralta
paralta deleted the feat/security-scan-refactor branch July 2, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 1000-1999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Create shared scanner package in the utils/ module

2 participants