e140477c0b
CI / nodejs-build (push) Successful in 3m12s
CI / test-go (push) Has been skipped
CI / iace-gt-coverage (push) Has been skipped
CI / test-python-backend (push) Successful in 39s
CI / test-python-document-crawler (push) Has been skipped
CI / test-python-dsms-gateway (push) Has been skipped
CI / detect-changes (push) Successful in 15s
CI / branch-name (push) Has been skipped
CI / guardrail-integrity (push) Has been skipped
CI / secret-scan (push) Has been skipped
CI / dep-audit (push) Has been skipped
CI / sbom-scan (push) Has been skipped
CI / build-sha-integrity (push) Successful in 12s
CI / validate-canonical-controls (push) Successful in 12s
CI / loc-budget (push) Successful in 25s
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
(2) Wir als MCP-Client zum compliance-scanner-agent: - scanner_mcp_client.fetch_findings(): streamablehttp_client + ClientSession → list_findings, parst JSON-Text zu Finding-Dicts. Config via SCANNER_MCP_URL/ SCANNER_MCP_TOKEN (unset = leer → UI behält Demo). Transport lazy-importiert. - POST /v1/cra/assess-from-scanner: rohe Scanner-Dicts → toleranter Mapper (behält scan_type/cvss_score/file_path) → assess + Breadth. - Tests: parse_findings_text + no-config-Pfad. Live-Verdrahtung der UI folgt, sobald ihr Endpoint+Token stehen (dann nur Env setzen + useCRA auf /assess-from-scanner zeigen). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
30 lines
965 B
Python
30 lines
965 B
Python
"""Pull-flow client: parse the scanner's list_findings result + safe no-config path."""
|
|
import asyncio
|
|
|
|
from compliance.services.scanner_mcp_client import fetch_findings, parse_findings_text
|
|
|
|
|
|
def test_parse_plain_array():
|
|
out = parse_findings_text('[{"_id":"a","title":"x"},{"_id":"b"}]')
|
|
assert len(out) == 2
|
|
assert out[0]["_id"] == "a"
|
|
|
|
|
|
def test_parse_wrapped_findings_key():
|
|
assert parse_findings_text('{"findings":[{"_id":"a"}]}') == [{"_id": "a"}]
|
|
|
|
|
|
def test_parse_wrapped_results_key():
|
|
assert parse_findings_text('{"results":[{"_id":"a"}]}') == [{"_id": "a"}]
|
|
|
|
|
|
def test_parse_garbage_returns_empty():
|
|
assert parse_findings_text("not json") == []
|
|
assert parse_findings_text("") == []
|
|
assert parse_findings_text('{"x":1}') == []
|
|
|
|
|
|
def test_fetch_findings_no_url_returns_empty():
|
|
# Unconfigured + no override -> [] (no MCP lib needed; transport is lazy-imported).
|
|
assert asyncio.run(fetch_findings(base_url="")) == []
|