stackparity 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stackparity/__init__.py +17 -0
- stackparity/_engine/agents/investigator.py +294 -0
- stackparity/_engine/agents/memory_agent.py +37 -0
- stackparity/_engine/agents/pipeline_agent.py +152 -0
- stackparity/_engine/agents/remediation_agent.py +248 -0
- stackparity/_engine/agents/runtime.py +177 -0
- stackparity/_engine/agents/specialists.py +709 -0
- stackparity/_engine/agents/suspicious_change_agent.py +1275 -0
- stackparity/_engine/cli/__init__.py +2 -0
- stackparity/_engine/cli/main.py +1252 -0
- stackparity/_engine/cli/remediate.py +461 -0
- stackparity/_engine/cli/term.py +44 -0
- stackparity/_engine/config/__init__.py +0 -0
- stackparity/_engine/config/constants.py +88 -0
- stackparity/_engine/config/loader.py +155 -0
- stackparity/_engine/config/settings.py +108 -0
- stackparity/_engine/containers/__init__.py +12 -0
- stackparity/_engine/containers/discovery.py +143 -0
- stackparity/_engine/containers/models.py +72 -0
- stackparity/_engine/containers/trivy_image_scanner.py +165 -0
- stackparity/_engine/core/__init__.py +0 -0
- stackparity/_engine/core/capabilities.py +107 -0
- stackparity/_engine/core/finding_schema.py +305 -0
- stackparity/_engine/core/git_manager.py +206 -0
- stackparity/_engine/core/http.py +64 -0
- stackparity/_engine/core/models.py +109 -0
- stackparity/_engine/core/netpolicy.py +242 -0
- stackparity/_engine/core/plugins.py +43 -0
- stackparity/_engine/core/repository_inspector.py +243 -0
- stackparity/_engine/core/safe_env.py +48 -0
- stackparity/_engine/core/scan_orchestrator.py +289 -0
- stackparity/_engine/core/scan_state.py +58 -0
- stackparity/_engine/core/url_validator.py +135 -0
- stackparity/_engine/ecosystems/__init__.py +1 -0
- stackparity/_engine/ecosystems/registry.py +138 -0
- stackparity/_engine/evidence/__init__.py +1 -0
- stackparity/_engine/evidence/store.py +65 -0
- stackparity/_engine/explainability/__init__.py +0 -0
- stackparity/_engine/explainability/evidence_formatter.py +30 -0
- stackparity/_engine/explainability/explanation_engine.py +132 -0
- stackparity/_engine/explainability/explanation_validator.py +54 -0
- stackparity/_engine/explainability/prompt_templates.py +18 -0
- stackparity/_engine/graph/__init__.py +0 -0
- stackparity/_engine/graph/dependency_tracer.py +86 -0
- stackparity/_engine/graph/graph_builder.py +165 -0
- stackparity/_engine/graph/graph_diff.py +57 -0
- stackparity/_engine/graph/graph_exporter.py +194 -0
- stackparity/_engine/graph/graph_validator.py +46 -0
- stackparity/_engine/graph/impact_analyzer.py +23 -0
- stackparity/_engine/graph/tree_view.py +185 -0
- stackparity/_engine/intel/__init__.py +0 -0
- stackparity/_engine/intel/epss.py +53 -0
- stackparity/_engine/llm/__init__.py +1 -0
- stackparity/_engine/llm/client.py +138 -0
- stackparity/_engine/monitor/__init__.py +0 -0
- stackparity/_engine/monitor/watch.py +171 -0
- stackparity/_engine/non_cve/__init__.py +7 -0
- stackparity/_engine/non_cve/base.py +62 -0
- stackparity/_engine/non_cve/iac.py +144 -0
- stackparity/_engine/non_cve/sast.py +272 -0
- stackparity/_engine/non_cve/supply_chain.py +147 -0
- stackparity/_engine/orchestration/__init__.py +1 -0
- stackparity/_engine/orchestration/pipeline.py +279 -0
- stackparity/_engine/orchestration/supervisor.py +167 -0
- stackparity/_engine/pipeline_analysis/__init__.py +0 -0
- stackparity/_engine/pipeline_analysis/analyzer.py +90 -0
- stackparity/_engine/pipeline_analysis/ci.py +189 -0
- stackparity/_engine/pipeline_analysis/ci_adapters/__init__.py +24 -0
- stackparity/_engine/pipeline_analysis/ci_adapters/azure_pipelines.py +221 -0
- stackparity/_engine/pipeline_analysis/ci_adapters/base.py +239 -0
- stackparity/_engine/pipeline_analysis/ci_adapters/circleci.py +176 -0
- stackparity/_engine/pipeline_analysis/ci_adapters/github_actions.py +356 -0
- stackparity/_engine/pipeline_analysis/ci_adapters/gitlab_ci.py +268 -0
- stackparity/_engine/pipeline_analysis/ci_adapters/jenkins.py +180 -0
- stackparity/_engine/pipeline_analysis/ci_adapters/registry.py +80 -0
- stackparity/_engine/pipeline_analysis/ci_models.py +72 -0
- stackparity/_engine/pipeline_analysis/dockerfile.py +235 -0
- stackparity/_engine/pipeline_analysis/eol.py +62 -0
- stackparity/_engine/pipeline_analysis/models.py +37 -0
- stackparity/_engine/policy/__init__.py +0 -0
- stackparity/_engine/policy/engine.py +216 -0
- stackparity/_engine/policy/resources/default.yaml +56 -0
- stackparity/_engine/policy/resources/strict.yaml +35 -0
- stackparity/_engine/reachability/__init__.py +0 -0
- stackparity/_engine/reachability/app_reachability.py +186 -0
- stackparity/_engine/reachability/scanners.py +215 -0
- stackparity/_engine/remediation/__init__.py +0 -0
- stackparity/_engine/remediation/adapters.py +198 -0
- stackparity/_engine/remediation/apply_local.py +309 -0
- stackparity/_engine/remediation/code_fixes.py +383 -0
- stackparity/_engine/remediation/compat.py +156 -0
- stackparity/_engine/remediation/container_plan.py +127 -0
- stackparity/_engine/remediation/delivery.py +31 -0
- stackparity/_engine/remediation/export.py +44 -0
- stackparity/_engine/remediation/lifecycle.py +623 -0
- stackparity/_engine/remediation/local_trial.py +358 -0
- stackparity/_engine/remediation/patchers.py +215 -0
- stackparity/_engine/remediation/planner.py +285 -0
- stackparity/_engine/remediation/pr_template_engine.py +234 -0
- stackparity/_engine/remediation/reachability_impact.py +147 -0
- stackparity/_engine/remediation/versions.py +92 -0
- stackparity/_engine/remediation/whatif.py +64 -0
- stackparity/_engine/remediation/worktree_pr.py +434 -0
- stackparity/_engine/reporting/__init__.py +0 -0
- stackparity/_engine/reporting/counts.py +63 -0
- stackparity/_engine/reporting/fix_pdf.py +343 -0
- stackparity/_engine/reporting/fix_report.py +135 -0
- stackparity/_engine/reporting/json_exporter.py +61 -0
- stackparity/_engine/reporting/report_generator.py +200 -0
- stackparity/_engine/reporting/sarif.py +71 -0
- stackparity/_engine/reporting/vex.py +57 -0
- stackparity/_engine/reporting/view.py +166 -0
- stackparity/_engine/risk_analysis/__init__.py +0 -0
- stackparity/_engine/risk_analysis/contextual_scorer.py +253 -0
- stackparity/_engine/risk_analysis/evidence_collector.py +62 -0
- stackparity/_engine/risk_analysis/evidence_normalizer.py +37 -0
- stackparity/_engine/risk_analysis/finding_correlator.py +90 -0
- stackparity/_engine/risk_analysis/function_impact.py +184 -0
- stackparity/_engine/risk_analysis/production_context.py +252 -0
- stackparity/_engine/risk_analysis/risk_rules.py +81 -0
- stackparity/_engine/risk_analysis/risk_scorer.py +390 -0
- stackparity/_engine/sandbox/__init__.py +0 -0
- stackparity/_engine/sandbox/runner.py +142 -0
- stackparity/_engine/sbom/__init__.py +0 -0
- stackparity/_engine/sbom/adapters/__init__.py +19 -0
- stackparity/_engine/sbom/adapters/builtin.py +29 -0
- stackparity/_engine/sbom/adapters/syft.py +26 -0
- stackparity/_engine/sbom/adapters/trivy.py +76 -0
- stackparity/_engine/sbom/builtin_generator.py +227 -0
- stackparity/_engine/sbom/cyclonedx_validator.py +166 -0
- stackparity/_engine/sbom/exporters.py +153 -0
- stackparity/_engine/sbom/fusion/__init__.py +5 -0
- stackparity/_engine/sbom/fusion/engine.py +315 -0
- stackparity/_engine/sbom/fusion/hashes.py +47 -0
- stackparity/_engine/sbom/fusion/ledger.py +96 -0
- stackparity/_engine/sbom/fusion/registries.py +271 -0
- stackparity/_engine/sbom/fusion/resolver.py +143 -0
- stackparity/_engine/sbom/fusion/writer.py +114 -0
- stackparity/_engine/sbom/lockfile_analyzer.py +114 -0
- stackparity/_engine/sbom/merge.py +71 -0
- stackparity/_engine/sbom/package_extractors/common.py +104 -0
- stackparity/_engine/sbom/package_extractors/manifests.py +101 -0
- stackparity/_engine/sbom/package_extractors/npm.py +206 -0
- stackparity/_engine/sbom/package_extractors/others.py +267 -0
- stackparity/_engine/sbom/package_extractors/python.py +143 -0
- stackparity/_engine/sbom/quality_analyzer.py +191 -0
- stackparity/_engine/sbom/scanner_engine.py +98 -0
- stackparity/_engine/sbom/syft_runner.py +100 -0
- stackparity/_engine/sbom/tool_locator.py +69 -0
- stackparity/_engine/sbom/trivy_runner.py +82 -0
- stackparity/_engine/storage/__init__.py +0 -0
- stackparity/_engine/storage/cache.py +56 -0
- stackparity/_engine/storage/database.py +295 -0
- stackparity/_engine/storage/memory.py +146 -0
- stackparity/_engine/suspicious_changes/__init__.py +12 -0
- stackparity/_engine/suspicious_changes/analyzer.py +1022 -0
- stackparity/_engine/suspicious_changes/change_correlation.py +861 -0
- stackparity/_engine/suspicious_changes/lifecycle_script_detector.py +263 -0
- stackparity/_engine/suspicious_changes/lockfile_change_detector.py +316 -0
- stackparity/_engine/suspicious_changes/manifest_diff_detector.py +251 -0
- stackparity/_engine/suspicious_changes/package_risk.py +78 -0
- stackparity/_engine/suspicious_changes/popular_packages.py +94 -0
- stackparity/_engine/suspicious_changes/registry_detector.py +354 -0
- stackparity/_engine/suspicious_changes/suspicious_models.py +57 -0
- stackparity/_engine/suspicious_changes/typosquatting_detector.py +298 -0
- stackparity/_engine/tools/__init__.py +1 -0
- stackparity/_engine/tools/builtin.py +93 -0
- stackparity/_engine/tools/registry.py +66 -0
- stackparity/_engine/ui/__init__.py +0 -0
- stackparity/_engine/ui/components/__init__.py +0 -0
- stackparity/_engine/ui/components/common.py +238 -0
- stackparity/_engine/ui/components/live_progress.py +157 -0
- stackparity/_engine/ui/components/memory_panel.py +82 -0
- stackparity/_engine/ui/pages/__init__.py +0 -0
- stackparity/_engine/ui/pages/agents_page.py +76 -0
- stackparity/_engine/ui/pages/architecture_page.py +44 -0
- stackparity/_engine/ui/pages/fixes_page.py +98 -0
- stackparity/_engine/ui/pages/graph_page.py +203 -0
- stackparity/_engine/ui/pages/health_page.py +117 -0
- stackparity/_engine/ui/pages/monitor_page.py +67 -0
- stackparity/_engine/ui/pages/pipeline_page.py +219 -0
- stackparity/_engine/ui/pages/remediation_page.py +409 -0
- stackparity/_engine/ui/pages/reports_page.py +54 -0
- stackparity/_engine/ui/pages/sbom_page.py +210 -0
- stackparity/_engine/ui/pages/scan_page.py +131 -0
- stackparity/_engine/ui/pages/suspicious_page.py +551 -0
- stackparity/_engine/ui/pages/vulns_page.py +201 -0
- stackparity/_engine/ui/state.py +116 -0
- stackparity/_engine/ui/theme.py +201 -0
- stackparity/_engine/ui/visualizations/__init__.py +0 -0
- stackparity/_engine/ui/visualizations/graphs.py +373 -0
- stackparity/_engine/vulnerability/__init__.py +0 -0
- stackparity/_engine/vulnerability/cvss.py +58 -0
- stackparity/_engine/vulnerability/kev_client.py +47 -0
- stackparity/_engine/vulnerability/nvd_client.py +74 -0
- stackparity/_engine/vulnerability/osv_client.py +139 -0
- stackparity/_engine/vulnerability/remediation_engine.py +50 -0
- stackparity/_engine/vulnerability/verification.py +94 -0
- stackparity/_engine/vulnerability/version_matcher.py +299 -0
- stackparity/_engine/vulnerability/vulnerability_correlator.py +303 -0
- stackparity/_engine/vulnerability/vulnerability_models.py +64 -0
- stackparity/cli.py +30 -0
- stackparity/dashboard_app.py +95 -0
- stackparity/web_dist/assets/index-DRJYw2Du.css +1 -0
- stackparity/web_dist/assets/index-Q6LLpbEi.js +495 -0
- stackparity/web_dist/index.html +13 -0
- stackparity/web_server.py +533 -0
- stackparity-1.0.0.dist-info/METADATA +204 -0
- stackparity-1.0.0.dist-info/RECORD +212 -0
- stackparity-1.0.0.dist-info/WHEEL +4 -0
- stackparity-1.0.0.dist-info/entry_points.txt +2 -0
- stackparity-1.0.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Page 7: reports and downloads."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import streamlit as st
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
|
|
8
|
+
from config.settings import get_settings
|
|
9
|
+
from reporting import json_exporter, report_generator
|
|
10
|
+
from reporting.sarif import to_sarif
|
|
11
|
+
from reporting.vex import to_vex
|
|
12
|
+
from storage.database import Database
|
|
13
|
+
from storage.memory import Memory
|
|
14
|
+
from ui.components.common import page_header, read_file, require_result
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def render() -> None:
|
|
18
|
+
page_header("Reports & Downloads", "Export security artifacts, download machine-readable JSON feeds, and preview human-readable reports.")
|
|
19
|
+
r = require_result()
|
|
20
|
+
if not r:
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
name = r["repo"]["name"]
|
|
24
|
+
try:
|
|
25
|
+
mem = Memory(Database(get_settings().db_path))
|
|
26
|
+
extras = {"decisions": mem.decisions(r["repo"]["url"]), "approvals": mem.approvals(r["repo"]["url"]), "audit": mem.audit_log(r["repo"]["url"], 30)}
|
|
27
|
+
except Exception: # noqa: BLE001
|
|
28
|
+
extras = {}
|
|
29
|
+
c1, c2 = st.columns(2)
|
|
30
|
+
sbom = read_file(r.get("sbom_path"))
|
|
31
|
+
|
|
32
|
+
with c1:
|
|
33
|
+
if sbom:
|
|
34
|
+
st.download_button("Download CycloneDX SBOM (JSON)", sbom, f"{name}-sbom.cdx.json", "application/json", key="dl_sbom", use_container_width=True)
|
|
35
|
+
else:
|
|
36
|
+
st.caption("CycloneDX SBOM artifact not available.")
|
|
37
|
+
st.download_button("Download Dependency Graph (JSON)", json_exporter.dumps(json_exporter.graph_export(r)), f"{name}-dependency-graph.json", "application/json", key="dl_graph2", use_container_width=True)
|
|
38
|
+
st.download_button("Download Vulnerability Findings (JSON)", json_exporter.dumps(json_exporter.vulnerability_export(r)), f"{name}-vulnerabilities.json", "application/json", key="dl_vuln", use_container_width=True)
|
|
39
|
+
|
|
40
|
+
with c2:
|
|
41
|
+
st.download_button("Download Suspicious Changes (JSON)", json_exporter.dumps(json_exporter.suspicious_export(r)), f"{name}-suspicious-changes.json", "application/json", key="dl_susp", use_container_width=True)
|
|
42
|
+
st.download_button("Download Consolidated Report (JSON)", json_exporter.dumps(json_exporter.consolidated_export(r)), f"{name}-consolidated.json", "application/json", key="dl_cons", use_container_width=True)
|
|
43
|
+
md = report_generator.generate_markdown(r, extras)
|
|
44
|
+
st.download_button("Download Guardian Report (Markdown)", md, f"{name}-guardian-report.md", "text/markdown", key="dl_md", use_container_width=True)
|
|
45
|
+
st.download_button("Download Guardian Report (HTML)", report_generator.generate_html(r, extras), f"{name}-guardian-report.html", "text/html", key="dl_html", use_container_width=True)
|
|
46
|
+
st.markdown("**Machine-readable security exchange formats**")
|
|
47
|
+
d1, d2, d3 = st.columns(3)
|
|
48
|
+
d1.download_button("SARIF 2.1.0 (code scanning)", json_exporter.dumps(to_sarif(r)), f"{name}.sarif", "application/sarif+json", key="dl_sarif", use_container_width=True)
|
|
49
|
+
d2.download_button("CycloneDX VEX (exploitability)", json_exporter.dumps(to_vex(r, extras.get("decisions"))), f"{name}.vex.json", "application/json", key="dl_vex", use_container_width=True)
|
|
50
|
+
if r.get("policy_result"):
|
|
51
|
+
d3.download_button("Policy gate result (JSON)", json.dumps(r["policy_result"], indent=2, default=str), f"{name}-policy.json", "application/json", key="dl_pol", use_container_width=True)
|
|
52
|
+
|
|
53
|
+
with st.expander("Report Preview", expanded=False):
|
|
54
|
+
st.markdown(md)
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""Page 2: SBOM explorer and quality assessment."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import streamlit as st
|
|
5
|
+
|
|
6
|
+
from reporting.counts import package_components
|
|
7
|
+
|
|
8
|
+
from ui.components.common import df, kv_table, page_header, read_file, require_result
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def render() -> None:
|
|
12
|
+
page_header("SBOM Explorer", "Component inventory, CycloneDX structural validation, and quality assessment.")
|
|
13
|
+
r = require_result()
|
|
14
|
+
if not r:
|
|
15
|
+
return
|
|
16
|
+
|
|
17
|
+
q, comps = r.get("quality", {}), package_components(r["components"])
|
|
18
|
+
tool = r.get("sbom_tool") or {}
|
|
19
|
+
used = tool.get("used") or r.get("inventory_source")
|
|
20
|
+
if used in (None, "none"):
|
|
21
|
+
st.error("No SBOM could be generated for this scan (no Syft/Trivy and no parsable lockfiles/manifests).")
|
|
22
|
+
else:
|
|
23
|
+
label = {"syft": "Syft", "trivy": "Trivy", "builtin": "Built-in rule engine"}.get(used, used)
|
|
24
|
+
ver = f" {tool.get('version')}" if tool.get("version") else ""
|
|
25
|
+
st.caption(f"SBOM generated by **{label}{ver}** · requested scanner: `{tool.get('requested', 'auto')}`")
|
|
26
|
+
|
|
27
|
+
fusion = r.get("metadata_fusion") or {}
|
|
28
|
+
mm = fusion.get("integrity_mismatches") or []
|
|
29
|
+
if mm:
|
|
30
|
+
st.error(f"**{len(mm)}** lockfile digest(s) do not match the registry's digest for the same version (possible tampered lockfile or republished package). See the Metadata tab.", icon=":material/error:")
|
|
31
|
+
c = st.columns(5)
|
|
32
|
+
c[0].metric("Components", len(comps), help="Software packages. CI actions and container images are listed on the Pipeline & Containers page.")
|
|
33
|
+
c[1].metric("Inventory", (q.get("inventory_status") or "n/a").replace("_", " ").title())
|
|
34
|
+
c[2].metric("Relationships", q.get("dependency_relationships", "n/a"))
|
|
35
|
+
c[3].metric("Metadata completeness", f"{fusion['average_completeness']:.0%}" if fusion else (q.get("metadata_status") or "n/a").replace("_", " ").title())
|
|
36
|
+
c[4].metric("Unresolved", q.get("unresolved_components", 0))
|
|
37
|
+
|
|
38
|
+
t1, t_meta, t2, t3, t_raw, t4 = st.tabs(["Components", "Metadata", "Quality", "Scanner & validation", "SBOM file", "Downloads"])
|
|
39
|
+
|
|
40
|
+
with t1:
|
|
41
|
+
f1, f2, f3 = st.columns([1, 1, 2])
|
|
42
|
+
ecos = sorted({x["ecosystem"] or x["purl_type"] or "unknown" for x in comps})
|
|
43
|
+
sel_e = f1.multiselect("Ecosystem", ecos, placeholder="All ecosystems")
|
|
44
|
+
svcs = sorted({x["service_dir"] or "." for x in comps})
|
|
45
|
+
sel_s = f2.multiselect("Service", svcs, placeholder="All services")
|
|
46
|
+
text = f3.text_input("Search package or PURL", placeholder="Filter by name...")
|
|
47
|
+
|
|
48
|
+
rows = [x for x in comps if (not sel_e or (x["ecosystem"] or x["purl_type"] or "unknown") in sel_e)
|
|
49
|
+
and (not sel_s or (x["service_dir"] or ".") in sel_s)
|
|
50
|
+
and (not text or text.lower() in (x["name"] + (x["purl"] or "")).lower())]
|
|
51
|
+
|
|
52
|
+
st.caption(f"Showing {len(rows)} of {len(comps)} components")
|
|
53
|
+
df([{"Name": x["name"], "Version": x["version"], "Ecosystem": x["ecosystem"] or x["purl_type"],
|
|
54
|
+
"Service": x["service_dir"], "License": ", ".join(x["licenses"]) or "n/a",
|
|
55
|
+
"Scope": x.get("scope") or "n/a", "Integrity": (x.get("integrity") or {}).get("status") or "n/a",
|
|
56
|
+
"Hash": "yes" if x.get("hashes") else "no", "Install script": "yes" if x.get("install_script") else "",
|
|
57
|
+
"Resolution": x.get("resolution") or "scanner", "Complete": x.get("completeness") if x.get("completeness") is not None else None,
|
|
58
|
+
"Supplier": x["supplier"] or "n/a", "PURL": x["purl"]} for x in rows], height=380)
|
|
59
|
+
|
|
60
|
+
if rows:
|
|
61
|
+
with st.expander("Component Inspector", expanded=False):
|
|
62
|
+
pick = st.selectbox("Inspect component", [f"{x['name']}@{x['version']}" for x in rows[:300]])
|
|
63
|
+
idx = [f"{x['name']}@{x['version']}" for x in rows[:300]].index(pick)
|
|
64
|
+
sel = rows[idx]
|
|
65
|
+
kv_table({k: v for k, v in sel.items() if k not in ("hashes", "provenance", "integrity", "external_refs", "enriched")})
|
|
66
|
+
prov = {k: v for k, v in (sel.get("provenance") or {}).items() if not k.startswith("_")}
|
|
67
|
+
if prov:
|
|
68
|
+
st.markdown("**Where each value came from**")
|
|
69
|
+
df([{"Field": k, "Source": v["source"], "Confidence": v.get("confidence"), "Evidence": v.get("evidence", ""),
|
|
70
|
+
"Conflicts": "; ".join(f"{c['source']}={c['value']}" for c in v.get("conflicts", []))} for k, v in prov.items()], height="content")
|
|
71
|
+
miss = ((sel.get("provenance") or {}).get("_missing") or {}).get("reasons") or {}
|
|
72
|
+
if miss:
|
|
73
|
+
st.markdown("**Missing, and why**")
|
|
74
|
+
df([{"Field": k, "Reason": v} for k, v in miss.items()], height="content")
|
|
75
|
+
if sel.get("integrity"):
|
|
76
|
+
st.markdown("**Integrity**")
|
|
77
|
+
st.json(sel["integrity"])
|
|
78
|
+
if sel.get("hashes"):
|
|
79
|
+
st.markdown("**Hashes**")
|
|
80
|
+
st.json(sel["hashes"])
|
|
81
|
+
if sel.get("external_refs"):
|
|
82
|
+
st.markdown("**Links**")
|
|
83
|
+
df(sel["external_refs"], height="content")
|
|
84
|
+
|
|
85
|
+
with t_meta:
|
|
86
|
+
if not fusion:
|
|
87
|
+
st.info("Metadata fusion did not run for this scan (no SBOM or an older stored scan). Rescan with 'Reuse cached scan' unticked.")
|
|
88
|
+
else:
|
|
89
|
+
st.caption("Every field keeps its source. Order of trust: lockfile (exact pin) > manifest > registry > SBOM scanner > inferred. A lower-trust value never overwrites a higher-trust one; disagreements are listed as conflicts.")
|
|
90
|
+
cov = fusion["coverage"]
|
|
91
|
+
df([{"Field": f.replace("_", " "), "Scanner only": c["before"], "After fusion": c["after"], "Of": fusion["components"], "Coverage %": c["percent"]} for f, c in cov.items()], height="content")
|
|
92
|
+
a, b, c3 = st.columns(3)
|
|
93
|
+
integ = fusion["integrity"]
|
|
94
|
+
a.metric("Digest verified", integ.get("verified", 0), help="Lockfile digest equals the registry's digest for this exact version")
|
|
95
|
+
b.metric("Digest mismatch", integ.get("mismatch", 0), help="Possible tampered lockfile or republished package")
|
|
96
|
+
c3.metric("No lockfile digest", integ.get("absent", 0), help="Registry digest was added with medium confidence")
|
|
97
|
+
if mm:
|
|
98
|
+
st.markdown("**Integrity mismatches**")
|
|
99
|
+
df(mm, height="content")
|
|
100
|
+
reg = fusion.get("registry_phase") or {}
|
|
101
|
+
if not reg.get("skipped"):
|
|
102
|
+
st.caption(f"Registries: {reg.get('fetched', 0)} fetched · {reg.get('from_cache', 0)} cached · {reg.get('not_found', 0)} not found · {reg.get('unavailable', 0)} unavailable"
|
|
103
|
+
+ (f" · tripped: {', '.join(reg['hosts_tripped'])}" if reg.get("hosts_tripped") else "") + (f" · no client for: {', '.join(reg['unsupported_ecosystems'])}" if reg.get("unsupported_ecosystems") else ""))
|
|
104
|
+
rs = r.get("registry_resolution") or {}
|
|
105
|
+
if rs.get("candidates"):
|
|
106
|
+
st.markdown("**Registry resolution of manifest-only services** (no lockfile: transitive packages resolved by deps.dev; labelled `registry-resolved`)")
|
|
107
|
+
st.caption(f"{rs['resolved']}/{rs['candidates']} pinned direct dependencies resolved -> {rs['derived_packages']} additional transitive packages. Each direct dependency is resolved on its own; the project's real version mediation may differ.")
|
|
108
|
+
st.markdown("**Fields by source**")
|
|
109
|
+
st.bar_chart(fusion.get("fields_by_source") or {})
|
|
110
|
+
if fusion.get("install_script_packages"):
|
|
111
|
+
with st.expander(f"{len(fusion['install_script_packages'])} package(s) run code at install time"):
|
|
112
|
+
st.write(", ".join(fusion["install_script_packages"]))
|
|
113
|
+
if fusion.get("deprecated_packages"):
|
|
114
|
+
with st.expander(f"{len(fusion['deprecated_packages'])} deprecated package(s)"):
|
|
115
|
+
st.write(", ".join(fusion["deprecated_packages"]))
|
|
116
|
+
if fusion.get("conflict_count"):
|
|
117
|
+
with st.expander(f"{fusion['conflict_count']} source conflict(s)"):
|
|
118
|
+
df([{"Component": x["component"], "Field": x["field"], "Chosen from": x["chosen"], "Other sources": "; ".join(f"{c['source']}={c['value']}" for c in x["conflicts"])} for x in fusion["conflicts"]], height=260)
|
|
119
|
+
|
|
120
|
+
with t2:
|
|
121
|
+
col_m1, col_m2 = st.columns(2)
|
|
122
|
+
with col_m1:
|
|
123
|
+
st.markdown(f"**Missing Lockfile Entries** ({q.get('lockfile_missing_from_sbom_count', 0)})")
|
|
124
|
+
df(q.get("lockfile_missing_from_sbom", []), height=220)
|
|
125
|
+
with col_m2:
|
|
126
|
+
st.markdown(f"**SBOM Components Absent from Lockfiles** ({q.get('sbom_absent_from_lockfile_count', 0)})")
|
|
127
|
+
df(q.get("sbom_absent_from_lockfile", []), height=220)
|
|
128
|
+
|
|
129
|
+
st.caption(f"Relationships: {q.get('relationship_edges', 0)} edges recorded · {q.get('missing_relationships', 0)} components without relationships")
|
|
130
|
+
|
|
131
|
+
with t3:
|
|
132
|
+
v = r["sbom"].get("validation", {})
|
|
133
|
+
st.markdown(f"**Spec:** CycloneDX {r['sbom'].get('spec_version') or 'n/a'} · **Valid:** {v.get('valid', False)} · **Components:** {v.get('stats', {}).get('components', 0)}")
|
|
134
|
+
for e in v.get("errors", []):
|
|
135
|
+
st.error(e)
|
|
136
|
+
|
|
137
|
+
if tool.get("used") == "builtin":
|
|
138
|
+
st.success("**CycloneDX 1.5 SBOM generated by StackParity's built-in rule engine** (in-process fallback; external Syft/Trivy CLI binaries are optional).", icon=":material/check_circle:")
|
|
139
|
+
else:
|
|
140
|
+
st.success(f"**CycloneDX 1.5 SBOM generated using {tool.get('used', 'scanner')}**.", icon=":material/check_circle:")
|
|
141
|
+
|
|
142
|
+
st.markdown("**Scanner attempts** (in the order tried)")
|
|
143
|
+
att = tool.get("attempts") or []
|
|
144
|
+
|
|
145
|
+
def _format_result(a: dict) -> str:
|
|
146
|
+
if a["ok"]:
|
|
147
|
+
return "Used"
|
|
148
|
+
err = (a.get("error") or "").lower()
|
|
149
|
+
if "not found" in err or "not installed" in err:
|
|
150
|
+
return "Not installed (skipped)"
|
|
151
|
+
return "Failed"
|
|
152
|
+
|
|
153
|
+
df([{"Scanner": a["scanner"], "Result": _format_result(a), "Version": a.get("version") or "—",
|
|
154
|
+
"Seconds": a.get("duration_s"), "Detail": a.get("error") or "ok"} for a in att], height="content")
|
|
155
|
+
for a in att:
|
|
156
|
+
if a.get("command"):
|
|
157
|
+
st.code(a["command"], language="bash")
|
|
158
|
+
es = tool.get("engine_stats")
|
|
159
|
+
if es:
|
|
160
|
+
st.markdown("**Rule engine statistics** (rules R1–R6 in `sbom/builtin_generator.py`)")
|
|
161
|
+
kv_table(es)
|
|
162
|
+
av = tool.get("available") or {}
|
|
163
|
+
if av:
|
|
164
|
+
st.caption("Installed: " + ", ".join(f"{k}={'yes' if x else 'no'}" for k, x in av.items() if k != "builtin") + ". Install Syft/Trivy for broader coverage; see README.")
|
|
165
|
+
|
|
166
|
+
with t_raw:
|
|
167
|
+
files = r.get("sbom_files") or ([{"label": "SBOM", "path": r.get("sbom_path")}] if r.get("sbom_path") else [])
|
|
168
|
+
sel_path = r.get("sbom_path")
|
|
169
|
+
if len(files) > 1:
|
|
170
|
+
pick = st.selectbox("SBOM file", range(len(files)), format_func=lambda i: files[i]["label"])
|
|
171
|
+
sel_path = files[pick]["path"]
|
|
172
|
+
raw = read_file(sel_path)
|
|
173
|
+
if not raw:
|
|
174
|
+
st.warning("The SBOM file is no longer on disk (artifacts were cleaned). Re-run the scan with *Reuse cached scan* unticked to regenerate it.")
|
|
175
|
+
else:
|
|
176
|
+
import json as _json
|
|
177
|
+
text = raw.decode("utf-8", "replace")
|
|
178
|
+
try:
|
|
179
|
+
doc = _json.loads(text)
|
|
180
|
+
except ValueError:
|
|
181
|
+
doc = None
|
|
182
|
+
st.caption(f"`{sel_path}` · {len(raw):,} bytes · exactly as written by the scanner")
|
|
183
|
+
views = ["Full file", "Header", "Components", "Dependencies"] if doc else ["Full file"]
|
|
184
|
+
view = st.radio("View", views, horizontal=True)
|
|
185
|
+
if view == "Full file":
|
|
186
|
+
lines = text.splitlines()
|
|
187
|
+
per = 400
|
|
188
|
+
pages = max(1, (len(lines) + per - 1) // per)
|
|
189
|
+
pg = st.number_input(f"Page ({per} lines per page, {len(lines):,} lines)", 1, pages, 1)
|
|
190
|
+
st.code(chr(10).join(lines[(pg - 1) * per: pg * per]), language="json", line_numbers=True)
|
|
191
|
+
elif view == "Header":
|
|
192
|
+
st.json({k: x for k, x in doc.items() if k not in ("components", "dependencies")})
|
|
193
|
+
elif view == "Components":
|
|
194
|
+
q_ = st.text_input("Filter components by name / purl", key="rawq").lower()
|
|
195
|
+
items = [c for c in doc.get("components", []) if not q_ or q_ in (str(c.get("name")) + str(c.get("purl"))).lower()]
|
|
196
|
+
size = 25
|
|
197
|
+
pg = st.number_input(f"Page ({size} per page, {len(items)} components)", 1, max(1, (len(items) + size - 1) // size), 1)
|
|
198
|
+
st.json(items[(pg - 1) * size: pg * size])
|
|
199
|
+
else:
|
|
200
|
+
deps = doc.get("dependencies", [])
|
|
201
|
+
size = 40
|
|
202
|
+
pg = st.number_input(f"Page ({size} per page, {len(deps)} records)", 1, max(1, (len(deps) + size - 1) // size), 1, key="dep_p")
|
|
203
|
+
st.json(deps[(pg - 1) * size: pg * size])
|
|
204
|
+
|
|
205
|
+
with t4:
|
|
206
|
+
data = read_file(r.get("sbom_path"))
|
|
207
|
+
if data:
|
|
208
|
+
st.download_button(f"Download CycloneDX JSON ({used})", data, file_name=f"{r['repo']['name']}-sbom.cdx.json", mime="application/json", use_container_width=True)
|
|
209
|
+
else:
|
|
210
|
+
st.info("No SBOM artifact file available.")
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"""Page 1: repository submission, progress and repository overview."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import streamlit as st
|
|
5
|
+
|
|
6
|
+
from config.settings import get_settings
|
|
7
|
+
from sbom.scanner_engine import SCANNER_CHOICES, SCANNER_LABELS, available_scanners
|
|
8
|
+
from core.scan_orchestrator import ScanOptions, run_scan
|
|
9
|
+
from core.url_validator import InvalidRepositoryURL
|
|
10
|
+
from storage.database import Database
|
|
11
|
+
from ui.components.memory_panel import history_banner
|
|
12
|
+
from ui.components.common import df, get_result, page_header, repo_caption
|
|
13
|
+
from ui.components.live_progress import LiveProgress
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def render() -> None:
|
|
17
|
+
page_header("Repository Scan", "Analyze software supply chain security for public GitHub repositories or local project folders statically.")
|
|
18
|
+
s = get_settings()
|
|
19
|
+
|
|
20
|
+
from llm.client import detect_provider
|
|
21
|
+
prov = (s.llm_provider or detect_provider(s.llm_api_key)) if s.llm_api_key else None
|
|
22
|
+
if not s.llm_api_key:
|
|
23
|
+
st.warning("⚠️ **LLM Provider API Key Missing**: Please add an LLM provider API key in `.env` (e.g. `LLM_API_KEY=gsk_...` for Groq, `AIza...` for Gemini, `sk-ant-...` for Anthropic, or `sk-...` for OpenAI) since requirements for this phase require an active LLM for autonomous AI reasoning.")
|
|
24
|
+
elif not prov:
|
|
25
|
+
st.error("❌ **Invalid LLM API Key**: Key format unrecognized. Please verify your `LLM_API_KEY` in `.env` (expected `gsk_...`, `AIza...`, `sk-ant-...`, or `sk-...`).")
|
|
26
|
+
|
|
27
|
+
with st.form("scan_form"):
|
|
28
|
+
url = st.text_input("GitHub repository URL or local project folder", placeholder="https://github.com/OWASP/NodeGoat or C:\\projects\\my-app",
|
|
29
|
+
value=st.session_state.get("last_url", ""), help="Paste a public GitHub URL, or the path to a project folder on this machine (scanned in place, read-only).")
|
|
30
|
+
c1, c2 = st.columns(2)
|
|
31
|
+
ref = c1.text_input("Branch or tag (optional)", help="Defaults to default branch.")
|
|
32
|
+
commits = c2.number_input("Lockfile history commits", 1, 25, 1, help="Commits to inspect for lockfile tampering.")
|
|
33
|
+
with st.expander("Scan Options", expanded=False):
|
|
34
|
+
o1, o2, o3 = st.columns(3)
|
|
35
|
+
use_nvd = o1.checkbox("NVD CVSS enrichment", True)
|
|
36
|
+
use_kev = o1.checkbox("CISA KEV known exploited", True)
|
|
37
|
+
registry = o2.checkbox("Typosquatting checks", True)
|
|
38
|
+
enrich = o2.checkbox("Fill missing metadata from registries", True, help="deps.dev, npm, PyPI, crates.io, Maven Central: licenses, hashes, links; also verifies lockfile digests. Cached.")
|
|
39
|
+
reuse = o3.checkbox("Reuse cached scan", True)
|
|
40
|
+
keep = o3.checkbox("Keep clone workspace", False)
|
|
41
|
+
llm_disabled = not s.llm_api_key or not prov
|
|
42
|
+
llm = o3.checkbox("Optional LLM reasoning", value=bool(s.llm_api_key and prov), disabled=llm_disabled,
|
|
43
|
+
help="Enable LLM reasoning. Requires LLM_API_KEY in .env.")
|
|
44
|
+
if not s.llm_api_key:
|
|
45
|
+
o3.caption("⚠️ *Add LLM_API_KEY in .env to enable*")
|
|
46
|
+
elif not prov:
|
|
47
|
+
o3.caption("❌ *Invalid LLM API key*")
|
|
48
|
+
else:
|
|
49
|
+
o3.caption(f"🤖 *Active provider: {prov}*")
|
|
50
|
+
investigate = o3.checkbox("Investigator (reachability, EPSS)", True)
|
|
51
|
+
remediate = o3.checkbox("Remediation planning", True)
|
|
52
|
+
sbom_scanner = st.selectbox("SBOM scanner", list(SCANNER_CHOICES), format_func=lambda k: SCANNER_LABELS[k],
|
|
53
|
+
help="Auto tries Syft, then Trivy, then the built-in rule engine, so an SBOM is always produced.")
|
|
54
|
+
avail = available_scanners(s)
|
|
55
|
+
st.caption("Detected: " + " · ".join(f"**{k}** {'✓' if v else '✗ not installed'}" for k, v in avail.items() if k != "builtin") + " · **built-in rule engine** ✓")
|
|
56
|
+
baseline = st.text_input("Comparison baseline (optional)")
|
|
57
|
+
go = st.form_submit_button("Start Security Scan", type="primary", use_container_width=True)
|
|
58
|
+
|
|
59
|
+
if go:
|
|
60
|
+
_run(url, ref, ScanOptions(
|
|
61
|
+
url=url, ref=ref or None, use_nvd=use_nvd, use_kev=use_kev,
|
|
62
|
+
registry_checks=registry, metadata_registry=enrich,
|
|
63
|
+
lockfile_commits=int(commits), baseline=baseline or None,
|
|
64
|
+
reuse_cached=reuse, use_llm=llm, keep_workspace=keep, sbom_scanner=sbom_scanner, investigate=investigate, remediate=remediate,
|
|
65
|
+
))
|
|
66
|
+
|
|
67
|
+
r = get_result()
|
|
68
|
+
if r and r.get("status") != "failed":
|
|
69
|
+
_overview(r)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _run(url: str, ref: str, opts: ScanOptions) -> None:
|
|
73
|
+
st.session_state["last_url"] = url
|
|
74
|
+
live = LiveProgress()
|
|
75
|
+
try:
|
|
76
|
+
result = run_scan(opts, on_event=live)
|
|
77
|
+
except InvalidRepositoryURL as e:
|
|
78
|
+
live.finish(False)
|
|
79
|
+
st.error(f"Invalid repository URL or folder: {e}")
|
|
80
|
+
return
|
|
81
|
+
except Exception as e:
|
|
82
|
+
live.finish(False)
|
|
83
|
+
st.error(f"Scan failed unexpectedly: {type(e).__name__}: {e}")
|
|
84
|
+
return
|
|
85
|
+
|
|
86
|
+
live.finish(result.get("status") != "failed")
|
|
87
|
+
if result.get("status") == "failed":
|
|
88
|
+
st.error(result.get("error", "Scan failed"))
|
|
89
|
+
return
|
|
90
|
+
|
|
91
|
+
st.session_state["result"] = result
|
|
92
|
+
if result.get("from_cache"):
|
|
93
|
+
st.info("Loaded cached scan for this commit.")
|
|
94
|
+
elif result["status"] == "completed_with_errors":
|
|
95
|
+
st.warning("Scan finished with stage warnings - see limitations below.")
|
|
96
|
+
else:
|
|
97
|
+
st.success("Scan completed. Navigate via sidebar to inspect results.")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _overview(r: dict) -> None:
|
|
101
|
+
repo, insp, sm = r["repo"], r["inspection"], r.get("summary", {})
|
|
102
|
+
st.markdown("#### Scan Summary")
|
|
103
|
+
|
|
104
|
+
c = st.columns(4)
|
|
105
|
+
c[0].metric("Repository", repo["name"])
|
|
106
|
+
c[1].metric("Commit", repo["commit_sha"][:8] if repo.get("commit_sha") else "n/a")
|
|
107
|
+
c[2].metric("Components", sm.get("components", 0))
|
|
108
|
+
c[3].metric("Confirmed Vulns", sm.get("vulnerabilities_confirmed", 0))
|
|
109
|
+
|
|
110
|
+
history_banner(r)
|
|
111
|
+
col_left, col_right = st.columns([1, 1])
|
|
112
|
+
|
|
113
|
+
with col_left:
|
|
114
|
+
st.markdown("**Analyst Assessment**")
|
|
115
|
+
if r.get("analyst"):
|
|
116
|
+
st.markdown(f"_{r['analyst']['headline']}_")
|
|
117
|
+
for pri in r["analyst"].get("priorities", [])[:3]:
|
|
118
|
+
st.markdown(f"• {pri}")
|
|
119
|
+
else:
|
|
120
|
+
st.caption("No analyst assessment generated.")
|
|
121
|
+
|
|
122
|
+
with col_right:
|
|
123
|
+
st.markdown("**Detected Ecosystems & Languages**")
|
|
124
|
+
st.markdown(f"**Ecosystems:** {', '.join(insp.get('ecosystems', [])) or 'None'}")
|
|
125
|
+
langs = [f"{k} ({round(v['bytes']/1024, 1)} KB)" for k, v in insp.get("languages", {}).items()][:6]
|
|
126
|
+
st.markdown(f"**Languages:** {', '.join(langs) or 'None'}")
|
|
127
|
+
|
|
128
|
+
with st.expander("Manifests & Coverage Details", expanded=False):
|
|
129
|
+
df([{"Path": m["path"], "Kind": m["kind"], "Ecosystem": m["ecosystem"]} for m in insp.get("manifests", [])], height=200)
|
|
130
|
+
for lim in r.get("limitations", [])[:4]:
|
|
131
|
+
st.caption(f"• {lim}")
|