Identifies which Contrast Security application corresponds to a code repository. Scans the repo for modules, scores them against the org's Contrast app list, and returns the best match.
identify_repo(repo)
├── discover_modules(depth=2) # find modules (pom.xml, package.json, etc.)
├── resolve_modules(apps) # score all modules against Contrast app list
├── pick best match # highest confidence wins
└── LLM fallback # if below threshold or ambiguous, agent investigates
→ {app_id, app_name, confidence}
Three layers:
- Discovery — filesystem scan + manifest parsing across 7 ecosystems (Java, Node, Python, Go, .NET, PHP, Ruby).
contrast_security.yamloverrides manifest names when present. - Deterministic scoring — Jaccard token similarity + language alignment. Fetches org app list once via MCP, scores locally.
- LLM fallback — Pydantic AI agent with filesystem + Contrast MCP tools for cases where scoring can't decide.
import asyncio
from module_identifier.config import ContrastConfig
from module_identifier.identify import identify_repo
from module_identifier.llm import LLMConfig
async def main():
config = ContrastConfig.from_env()
llm_config = LLMConfig.from_env()
match = await identify_repo("/path/to/repo", config, llm_config)
if match:
print(f"{match.app_name} ({match.app_id})")
else:
print("No matching Contrast application found")
asyncio.run(main())pip install -e ".[dev]"Requires a .env with Contrast credentials (see .env.example).
MCP server: jar path via MCP_CONTRAST_JAR_PATH env var, falls back to Docker contrast/mcp-contrast:latest.
pytest module_identifier/tests/ -qCovers:
- Module discovery (scanner + declarations) across all ecosystems
- Name extraction from manifests
- Scoring (exact match, token overlap, language bonus)
contrast_security.yamloverride- Golden dataset tests against real org data (1,317 apps, 6 languages)
- MCP response parsing
- LLM agent (mocked, no real LLM calls)