Skip to content

feat(scanner): Add scan result parser#24

Open
heliocastro wants to merge 1 commit intomainfrom
feat/scanner_result
Open

feat(scanner): Add scan result parser#24
heliocastro wants to merge 1 commit intomainfrom
feat/scanner_result

Conversation

@heliocastro
Copy link
Owner

No description provided.

@heliocastro heliocastro self-assigned this Mar 13, 2026
Copilot AI review requested due to automatic review settings March 13, 2026 15:15
@heliocastro heliocastro added the enhancement New feature or request label Mar 13, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the Python ORT result model layer to support scanner results, including parsing snippet findings from ORT YAML output, and updates project metadata/dependencies accordingly.

Changes:

  • Add scanner-related models (ScannerRun, ScanResult, ScanSummary, ScannerDetails) plus supporting types (snippet findings, provenance resolution results, file lists, storage configs).
  • Add SPDX license-expression validation for snippet and license findings.
  • Update YAML loader and project/tooling configs (version bump, dependencies, pre-commit hooks, README usage example).

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
uv.lock Locks new runtime deps and bumps dev tools (ruff/ty).
tests/test_scan_result.py Adds tests covering scanner run + scan result parsing from YAML.
src/ort/utils/yaml_loader.py Simplifies loader selection (CSafeLoader fallback).
src/ort/models/vcstype.py Renames validator to satisfy naming/linting.
src/ort/models/text_location.py Makes TextLocation hashable/comparable for set usage.
src/ort/models/snippet_finding.py Adds SnippetFinding model (hashable for sets).
src/ort/models/snippet.py Adds Snippet model + SPDX expression validation.
src/ort/models/scanner_run.py Adds ScannerRun model to parse scanner run output.
src/ort/models/scanner_details.py Adds ScannerDetails model.
src/ort/models/scan_summary.py Adds ScanSummary model (findings + issues).
src/ort/models/scan_result.py Adds ScanResult model (provenance/scanner/summary).
src/ort/models/provenance_resolution_result.py Adds provenance resolution result model for scanner run.
src/ort/models/provenance.py Refactors provenance hierarchy for scan/snippet provenance parsing.
src/ort/models/ort_result.py Adds optional scanner section to OrtResult.
src/ort/models/license_finding.py Adds LicenseFinding model + SPDX expression validation.
src/ort/models/file_list.py Adds FileList and Entry models for scanner file lists.
src/ort/models/copyright_finding.py Adds CopyrightFinding model.
src/ort/models/config/scanner_configuration.py Adds scanner configuration model.
src/ort/models/config/scan_storage_configuration.py Adds scan storage configuration models + storage type enum.
src/ort/models/config/s3_file_storage_configuration.py Adds S3 file storage config model.
src/ort/models/config/provenance_storage_configuration.py Adds provenance storage config model.
src/ort/models/config/postgres_connection.py Adds Postgres connection config model.
src/ort/models/config/local_file_storage_configuration.py Adds local file storage config model.
src/ort/models/config/http_file_storage_configuration.py Adds HTTP file storage config model.
src/ort/models/config/file_storage_configuration.py Adds file storage root config model.
src/ort/models/config/file_list_storage_configuration.py Adds file list storage config model.
src/ort/models/config/file_archiver_configuration.py Adds file archiver config model.
src/ort/models/base_run.py Updates SPDX header metadata.
pyproject.toml Bumps package version, adds deps, updates tool versions/ruff ignores.
prek.toml Bumps hook versions and adds license-expression to ty hook deps.
README.md Expands docs with installation + YAML parsing example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,45 @@
# SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <dev@heliocastro.info>
# # SPDX-FileCopyrightText: 2026 CARIAD SE
@@ -0,0 +1,55 @@
# SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <dev@heliocastro.info>
# # SPDX-FileCopyrightText: 2026 CARIAD SE
Comment on lines +37 to +55
@field_validator("license", mode="before")
@classmethod
def validate_spdx(cls, value):
try:
licensing = get_spdx_licensing()
licensing.parse(value)
return value
except ExpressionError as e:
raise ValidationError(
[
{
"type": "value_error.license_expression",
"loc": ("license",),
"msg": str(e),
"input": value,
}
],
cls,
)
Comment on lines +64 to +82
@field_validator("license", mode="before")
@classmethod
def validate_spdx(cls, value):
try:
licensing = get_spdx_licensing()
licensing.parse(value)
return value
except ExpressionError as e:
raise ValidationError(
[
{
"type": "value_error.license_expression",
"loc": ("license",),
"msg": str(e),
"input": value,
}
],
cls,
)
Comment on lines 24 to 34
@@ -34,52 +34,64 @@ def validate_provenance(cls, v):
return UnknownProvenance()
@@ -0,0 +1,52 @@
# SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <dev@heliocastro.info>
# # SPDX-FileCopyrightText: 2026 CARIAD SE
Comment on lines +39 to +45
def __hash__(self) -> int:
return hash(str(self.provenance))

def __eq__(self, other) -> bool:
if not isinstance(other, ScanResult):
return NotImplemented
return self.provenance == other.provenance
Comment on lines +37 to +39
issues: dict[Identifier, set[Issue]] = Field(
default_factory=dict,
description="A map of [Identifier]s associated with a set of [Issue]s that occurred during a scan besides the"
Comment on lines +30 to +44
license_findings: set[LicenseFinding] = Field(
default_factory=set,
alias="licenses",
description="The detected license findings.",
)
copyright_findings: set[CopyrightFinding] = Field(
default_factory=set,
alias="copyrights",
description="The detected copyright findings.",
)
snippet_findings: set[SnippetFinding] = Field(
default_factory=set,
alias="snippets",
description="The detected snippet findings.",
)
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <dev@heliocastro.info>
# # SPDX-FileCopyrightText: 2026 CARIAD SE
Signed-off-by: Helio Chissini de Castro <dev@heliocastro.info>
Signed-off-by: Helio Chissini de Castro <helio.chissini.de.castro@cariad.technology>
@heliocastro heliocastro force-pushed the feat/scanner_result branch from c0a1e89 to 04cd0be Compare March 13, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants