diff --git a/.env.example b/.env.example index a850c3828..e9c24532d 100644 --- a/.env.example +++ b/.env.example @@ -7,6 +7,9 @@ SECUSCAN_LOG_LEVEL=INFO SECUSCAN_BIND_ADDRESS=127.0.0.1 SECUSCAN_BIND_PORT=8000 +SECUSCAN_REPOSITORY_URL=https://github.com/utksh1/SecuScan +SECUSCAN_SARIF_SCHEMA_URL=https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json + # Storage and Cache # SECUSCAN_DATABASE_PATH=backend/data/secuscan.db # SECUSCAN_REDIS_URL=redis://127.0.0.1:6379/0 diff --git a/backend/secuscan/config.py b/backend/secuscan/config.py index 35bcf2823..e094891bc 100644 --- a/backend/secuscan/config.py +++ b/backend/secuscan/config.py @@ -18,6 +18,15 @@ class Settings(BaseSettings): # Server Configuration bind_address: str = "127.0.0.1" bind_port: int = 8000 + + # Repository Configuration + repository_url: str = "https://github.com/utksh1/SecuScan" + + # SARIF Schema Configuration + sarif_schema_url: str = ( + "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json" + ) + debug: bool = True # Primary data store diff --git a/backend/secuscan/reporting.py b/backend/secuscan/reporting.py index f71658f09..72293797b 100644 --- a/backend/secuscan/reporting.py +++ b/backend/secuscan/reporting.py @@ -3,6 +3,8 @@ import html import io import json + +from .config import settings import re from .redaction import redact, redact_dict from .ai_summary import generate_summary @@ -1238,23 +1240,29 @@ def generate_sarif_report(cls, task: Dict[str, Any], result: Dict[str, Any]) -> results.append(sarif_result) sarif_output = { - "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json", - "version": "2.1.0", - "runs": [ - { - "tool": { - "driver": { - "name": tool_name, - "version": "1.0.0", - "informationUri": "https://github.com/utksh1/SecuScan", - "rules": rules - } + "$schema": settings.sarif_schema_url, + "version": "2.1.0", + "runs": [ + { + "tool": { + "driver": { + "name": tool_name, + "version": "1.0.0", + "informationUri": settings.repository_url, + "rules": rules, + "properties": { + "generatorVersion": _version_, }, - "results": results } - ] + }, + "properties": { + "pluginId": task.get("plugin_id"), + "exportTimestamp": datetime.now(timezone.utc).isoformat(), + }, + "results": results, } - + ] +} return json.dumps(sarif_output, indent=2)