Remove the scan information section
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b380c736c9
commit
9d78e9edf4
5 files changed
+6
-184
No files matched your search
@@ -79,9 +79,8 @@ def build_context(
|
||||
"sections": [_tool_section(name, report) for name, report in tools],
|
||||
}
|
||||
|
||||
# Without the pipeline's metadata these two pages would be nothing but gaps.
|
||||
# Without the pipeline's metadata this page would be nothing but gaps.
|
||||
if metadata:
|
||||
context["scan"] = _scan(sources, metadata)
|
||||
context["project"] = _project(metadata, project)
|
||||
|
||||
critical = _critical(tools, sca)
|
||||
@@ -142,7 +141,7 @@ def _tool_name(run: dict[str, Any]) -> str:
|
||||
|
||||
def _contents(context: dict[str, Any]) -> list[dict[str, str]]:
|
||||
"""The table of contents: every top-level part of the report that is actually in it."""
|
||||
parts = [context[key] for key in ("scan", "project", "summary", "critical") if key in context]
|
||||
parts = [context[key] for key in ("project", "summary", "critical") if key in context]
|
||||
|
||||
return [{"id": part["id"], "title": part["title"]} for part in [*parts, *context["sections"]]]
|
||||
|
||||
@@ -224,46 +223,6 @@ def _severity_ledger(tools: list[tuple[str, SarifReport]], sca: VdrReport | None
|
||||
return {"title": "True issues by severity", "rows": rows}
|
||||
|
||||
|
||||
def _scan(sources: ReportSources, metadata: dict[str, Any]) -> dict[str, Any]:
|
||||
"""What the pipeline did, stage by stage."""
|
||||
stages = [stage for stage in metadata.get("stages") or [] if isinstance(stage, dict)]
|
||||
failed = [stage["label"] for stage in stages if stage.get("status") not in ("success", None)]
|
||||
|
||||
return {
|
||||
"id": "scan",
|
||||
"title": "CipherCell Scan Information",
|
||||
"overview": [
|
||||
_fact("Scan started at", _moment(metadata.get("pipeline_start_iso"))),
|
||||
_fact("Scan duration", _duration(metadata.get("pipeline_duration_seconds"))),
|
||||
_fact("Scan completed at", _moment(metadata.get("pipeline_end_iso"))),
|
||||
_fact(
|
||||
"Pipeline Steps", ", ".join(_stated(stage.get("label") or stage.get("key")) for stage in stages) or None
|
||||
),
|
||||
_fact("Errors Detected", ", ".join(failed) if failed else "None" if stages else None),
|
||||
],
|
||||
"stages": [_stage(stage, sources) for stage in stages],
|
||||
}
|
||||
|
||||
|
||||
def _stage(stage: dict[str, Any], sources: ReportSources) -> dict[str, Any]:
|
||||
"""One stage of the pipeline.
|
||||
|
||||
The tools a stage ran and the profile it ran them under are not recorded in the metadata, so
|
||||
they are left unstated. What is recorded is when it ran, how it ended, and -- indirectly -- what
|
||||
it produced, which is read off the names of the files the scan stored.
|
||||
"""
|
||||
return {
|
||||
"title": stage.get("label") or stage.get("key") or UNKNOWN,
|
||||
"rows": [
|
||||
_fact("Selected Tools", None),
|
||||
_fact("Profile", None),
|
||||
_fact("Duration", _duration(stage.get("duration_seconds"))),
|
||||
_fact("Created Artifacts", ", ".join(sorted(sources.files)) or None, kind="mono"),
|
||||
_fact("Errors Detected", "None" if stage.get("status") == "success" else stage.get("status")),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def _version(metadata: dict[str, Any]) -> str | None:
|
||||
"""What version of the project was scanned: the stated one, else the commit the SBOM was uploaded for.
|
||||
|
||||
@@ -772,24 +731,3 @@ def _percent(share: float | None) -> str | None:
|
||||
return None
|
||||
|
||||
return f"{share * 100:.2f} %" if share < 0.01 else f"{share * 100:.1f} %"
|
||||
|
||||
|
||||
def _moment(stated: Any) -> str | None: # noqa: ANN401
|
||||
"""An ISO timestamp as the report writes it, or nothing where it cannot be read."""
|
||||
if not isinstance(stated, str):
|
||||
return None
|
||||
|
||||
try:
|
||||
return datetime.fromisoformat(stated).strftime("%A, %B %d, %Y %H:%M:%S (%Z)").replace("()", "").strip()
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
|
||||
def _duration(seconds: Any) -> str | None: # noqa: ANN401
|
||||
"""A number of seconds as ``HH:MM:SS``."""
|
||||
if not isinstance(seconds, (int, float)) or isinstance(seconds, bool):
|
||||
return None
|
||||
|
||||
whole = int(seconds)
|
||||
|
||||
return f"{whole // 3600:02d}:{whole % 3600 // 60:02d}:{whole % 60:02d}"
|
||||
Reference in new issue
Block a user