Application Security & DevSecOps Agents

Problem Statement

Standard container image scanners report thousands of package vulnerabilities (CVEs) in base layers (e.g., Alpine or Ubuntu OS packages). Many of these vulnerable libraries are never imported or executed by the application layer.

Goal

Implement an agent that evaluates container vulnerability scan results alongside application source code to flag only reachable, exploitable vulnerabilities.

Outcome Measurement

  1. Vulnerability Reduction: 85% reduction in actionable CVE backlog by discarding unreachable base-image vulnerabilities.
  2. Developer Efficiency: Reduced manual triage hours spent on non-exploitable container vulnerabilities.

How the Code was Built

Cross-references container CVE lists against application dependency imports.

Executable Code

from pydantic import BaseModel, Field
from langchain_openai import ChatOpenAI
class ContainerScanFilter(BaseModel):
cve_id: str
package_name: str
is_reachable: bool
actionable_priority: str
explanation: str
def evaluate_container_cve(cve_id: str, package: str, app_imports: list[str]) -> ContainerScanFilter:
llm = ChatOpenAI(model="gpt-4o", temperature=0)
structured_llm = llm.with_structured_output(ContainerScanFilter)
prompt = f"""
Evaluate if Container Package Vulnerability is reachable in application code:
CVE ID: {cve_id}
Vulnerable Package: {package}
Application Import Statements: {app_imports}
Determine if the application actually imports or calls functions from this package.
"""
return structured_llm.invoke(prompt)
if __name__ == "__main__":
res = evaluate_container_cve(
cve_id="CVE-2026-1122",
package="libpng-dev",
app_imports=["import os", "import json", "import flask"]
)
print(f"CVE: {res.cve_id}")
print(f"Reachable in App Code: {res.is_reachable}")
print(f"Priority: {res.actionable_priority}")
print(f"Explanation: {res.explanation}")

Leave a Reply

Trending