Repository navigation
fix(agent-discovery): report containerized agents with the same agent types as the other scanners - #4366
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
PR Review Summary
Verdict: AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims. |
|
🟡 Contributor Check: MEDIUM
Automated check by AGT Contributor Check. |
a74a1f0 to
5561941
Compare
MohammadHaroonAbuomar
left a comment
There was a problem hiding this comment.
- Verified: on main the container scanner set agent_type to the raw matched text, so a Docker or Compose agent was typed langgraph, mcp_server or semantic_kernel and never matched the fixed names the risk rules, the reconciler and the inventory counts compare against. Pairing each pattern with its canonical type fixes that, the fingerprint and merge keys still use the pattern text so saved inventories keep merging, and detection and confidence are unchanged. Five of the nine tests fail on main and pass here; the package suite passes (66); lint and spelling are clean.
One item blocks merge: the new file agent-governance-python/agent-discovery/tests/test_config_scanner.py has no Microsoft license header, and both license-header checks fail on it. Please add the two header lines at the top (scripts/check_license_headers.py --fix does it) and keep the sign-off on the amended commit.
Housekeeping: #4367 and this PR add a changelog bullet at the same spot, and #4325 edits the same block of config.py, so whichever lands second will need a small rebase.
…t types ConfigScanner used the matched Dockerfile/Compose text as the agent type, so langgraph, agent_governance, mcp_server and semantic_kernel produced types no other scanner uses. Risk scoring skipped the type factor for them and reconciliation never suggested mcp-scan for an mcp_server container. Each Docker pattern now carries the type the process scanner reports. Fingerprints are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Shivam Sharma <192242476+ShivamSharma43@users.noreply.github.com>
5561941 to
0cb5f25
Compare
|
MohammadHaroonAbuomar thanks. Added the license header to |
Addressed on 0cb5f25: the new test file now carries the Microsoft license header and the header check passes; the source and changelog changes are unchanged from the head I reviewed. Package suite passes (66), lint and spelling clean. Nothing left to fix; I will approve and merge once the gated checks on this head are green, after #4367 or before it depending on which lands first.
MohammadHaroonAbuomar
left a comment
There was a problem hiding this comment.
Verified the fix in code and ran the tests locally; CI is green on the current head.
Related Issue
None. This is a bug I found in
agent_discovery.scanners.config.ConfigScanner; the sections below are filled in as the template asks.Problem & Solution
Problem. When a Dockerfile or Compose file matches one of
DOCKER_AGENT_PATTERNS, the scanner uses the matched text as the agent type:The other scanners report a fixed type per framework (
langchain,agt,mcp-server,semantic-kernel, ...), andRiskScorerandReconcilercompare against those names. A container therefore gets whatever spelling its file happened to use:RUN pip install langgraphlanggraphlangchainRUN pip install agent_governanceagent_governanceagtCMD python -m my_mcp_servermcp_servermcp-serverRUN pip install semantic_kernelsemantic_kernelsemantic-kernelThe effects:
RiskScoreradds no type factor: alanggraphcontainer misses the +15 high-risk score, and asemantic_kernelcontainer misses the +10 medium-risk score.Reconcilernever recommends runningmcp-scanfor anmcp_servercontainer, because it checksagent_type == "mcp-server".AgentInventory.search(agent_type=...)and theby_typecounts inagent-discovery inventory -o summarysplit one framework across several spellings.Solution. Each entry in
DOCKER_AGENT_PATTERNSnow pairs the regex with the type it reports, using the same names as the process scanner. The fingerprint still uses the pattern text, so agents already in a saved inventory keep their fingerprints and merge with new scans as before.Impact on Your Work
agent-discovery reconcileranks shadow agents by risk score. Before this fix, containerized agents could rank lower than they should, depending on how their Dockerfile spelled the framework name.Timeline
None.
Alternatives Considered
_→-). That fixesmcp_serverandsemantic_kernel, butlanggraphandagent_governancestill don't map tolangchainandagt. An explicit type per pattern is simpler and matches how the process and GitHub scanners do it.Type of Change
Package(s) Affected
Governance & security:
Testing
Unit Testing
New
tests/test_config_scanner.py:test_reports_the_canonical_agent_type, parametrized over a Dockerfile line for each pattern (langgraph,LangChain,crewai,autogen-agentchat,agent_governance,my_mcp_server,semantic_kernel). Each reports the process scanner's type.test_container_agent_type_drives_risk_scoring: asemantic_kernelcontainer gets theMedium-risk agent type: semantic-kernelfactor.test_fingerprint_keeps_the_matched_pattern: the merge key is still the pattern text.The
langgraph,agent_governance,my_mcp_serverandsemantic_kernelcases and the risk-scoring test fail on main.Manual Testing
agent-discovery/tests: 66 passed.scripts/check_license_headers.pyon the changed files: clean.ruff checkandruff format --check: clean.cspellwith.cspell.jsonon the added lines; no issues.Checklist
Attribution & Prior Art
None.
AI Assistance
I used Claude Code (Claude Opus) to help find the bug and draft the fix and tests. I reviewed the full diff and will handle review comments myself.
IP, Patents, and Licensing
🤖 Generated with Claude Code