-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Add Advisor parsing #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
601e070
chore(deps): Update deps, add ty as a linter
heliocastro 625bfc8
chore(vscode): Remove specifics for workspace
heliocastro afe4ad8
feat(class): Rename OrtRepositoryConfiguration to RepositoryConfigura…
heliocastro e646f36
feat(vcsinfo): Move url field to str to match upstream
heliocastro 0c7b712
fix(remoteartifact): Allow string be empty
heliocastro 947e6ca
fix(curation): Use RemoteArtifact and remove unused CurationArtifact …
heliocastro 17eb184
fix(linkage): Proper process strings relates to packahelinkage enum
heliocastro 5a8f619
feat(advisor): Add Advisor models
heliocastro 4411d22
chore(imports): Rearrange imports
heliocastro a0ecdbd
feat(examples): Add switch for ort result example
heliocastro 61a97b1
feat(advisor): Make advisors options as generic
heliocastro 343a971
chore(version): Bump minor version for advisor
heliocastro 446a4c9
ci(typechecker): Use ty instead of pyrefly
heliocastro a7dd9fb
fix(typechecker): Type fixes
heliocastro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,64 @@ | ||
| # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| from .advisor_capability import AdvisorCapability | ||
| from .advisor_result import AdvisorResult | ||
| from .advisor_run import AdvisorRun | ||
| from .analyzer_result import AnalyzerResult | ||
| from .analyzer_run import AnalyzerRun | ||
| from .dependency_graph import DependencyGraph | ||
| from .dependency_graph_edge import DependencyGraphEdge | ||
| from .dependency_graph_node import DependencyGraphNode | ||
| from .dependency_reference import DependencyReference | ||
| from .hash import Hash | ||
| from .hash_algorithm import HashAlgorithm | ||
| from .identifier import Identifier | ||
| from .issue import Issue | ||
| from .ort_result import OrtResult | ||
| from .package import Package | ||
| from .package_curation import PackageCuration | ||
| from .package_curation_data import PackageCurationData | ||
| from .package_linkage import PackageLinkage | ||
| from .package_reference import PackageReference | ||
| from .project import Project | ||
| from .remote_artifact import RemoteArtifact | ||
| from .repository import Repository | ||
| from .repository_configuration import RepositoryConfiguration | ||
| from .root_dependency_index import RootDependencyIndex | ||
| from .scope import Scope | ||
| from .source_code_origin import SourceCodeOrigin | ||
| from .vcsinfo import VcsInfo | ||
| from .vcsinfo_curation_data import VcsInfoCurationData | ||
| from .vcstype import VcsType | ||
|
|
||
| __all__ = [ | ||
| "AdvisorCapability", | ||
| "AdvisorResult", | ||
| "AdvisorRun", | ||
| "AnalyzerResult", | ||
| "AnalyzerRun", | ||
| "DependencyGraph", | ||
| "DependencyGraphEdge", | ||
| "DependencyGraphNode", | ||
| "DependencyReference", | ||
| "Hash", | ||
| "HashAlgorithm", | ||
| "Identifier", | ||
| "Issue", | ||
| "OrtResult", | ||
| "Package", | ||
| "PackageCuration", | ||
| "PackageCurationData", | ||
| "PackageLinkage", | ||
| "PackageReference", | ||
| "Project", | ||
| "RemoteArtifact", | ||
| "Repository", | ||
| "RepositoryConfiguration", | ||
| "RootDependencyIndex", | ||
| "Scope", | ||
| "SourceCodeOrigin", | ||
| "VcsInfo", | ||
| "VcsInfoCurationData", | ||
| "VcsType", | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # SPDX-FileCopyrightText: 2025 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
|
|
||
| from enum import IntEnum | ||
|
|
||
|
|
||
| class AdvisorCapability(IntEnum): | ||
| """ | ||
| An enum class that defines the capabilities of a specific advisor implementation. | ||
|
|
||
| There are multiple types of findings that can be retrieved by an advisor, such as security vulnerabilities or | ||
| defects. An [AdvisorResult] has different fields for the different findings types. This enum corresponds to these | ||
| fields. It allows an advisor implementation to declare, which of these fields it can populate. This information is | ||
| of interest, for instance, when generating reports for specific findings to determine, which advisor may have | ||
| contributed. | ||
|
|
||
| """ | ||
|
|
||
| DEFECTS = 1 | ||
| VULNERABILITIES = 2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
|
|
||
| from pydantic import BaseModel, ConfigDict, Field, field_validator | ||
|
|
||
| from ort.models import AdvisorCapability | ||
heliocastro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class AdvisorDetails(BaseModel): | ||
| """ | ||
| Details about the used provider of vulnerability information. | ||
|
|
||
| """ | ||
|
|
||
| model_config = ConfigDict( | ||
| extra="forbid", | ||
| ) | ||
|
|
||
| name: str = Field(description="The name of the used advisor.") | ||
| capabilities: set[AdvisorCapability] = Field( | ||
| description="The capabilities of the used advisor. This property indicates, which kind of findings" | ||
| "are retrieved by the advisor." | ||
| ) | ||
|
|
||
| @field_validator("capabilities", mode="before") | ||
| @classmethod | ||
| def convert_capability(cls, v): | ||
| def _convert(item): | ||
| if isinstance(item, str): | ||
| try: | ||
| return AdvisorCapability[item] | ||
| except KeyError: | ||
| raise ValueError(f"Invalid capability: {item}") | ||
| return item | ||
|
|
||
| if isinstance(v, (list, set)): | ||
| return {_convert(item) for item in v} | ||
| if isinstance(v, str): | ||
| return _convert(v) | ||
| return v | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| from pydantic import BaseModel, ConfigDict, Field | ||
|
|
||
| from ort.models.vulnerabilities import Vulnerability | ||
|
|
||
| from .advisor_details import AdvisorDetails | ||
| from .advisor_summary import AdvisorSummary | ||
| from .defect import Defect | ||
|
|
||
|
|
||
| class AdvisorResult(BaseModel): | ||
| """ | ||
| The result of a specific advisor execution for a single package. | ||
|
|
||
| Different advisor implementations may produce findings of different types. To reflect this, this class has multiple | ||
| fields for findings of these types. It is up to a concrete advisor, which of these fields it populates. | ||
|
|
||
| """ | ||
|
|
||
| model_config = ConfigDict( | ||
| extra="forbid", | ||
| ) | ||
|
|
||
| advisor: AdvisorDetails = Field( | ||
| description="Details about the used advisor.", | ||
| ) | ||
|
|
||
| summary: AdvisorSummary = Field( | ||
| description="A summary of the advisor results.", | ||
| ) | ||
|
|
||
| defects: list[Defect] = Field( | ||
| default_factory=list, | ||
| description="The defects.", | ||
| ) | ||
|
|
||
| vulnerabilities: list[Vulnerability] = Field( | ||
| default_factory=list, | ||
| description="The vulnerabilities.", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # SPDX-FileCopyrightText: 2026 Helio Chissini de Castro <heliocastro@gmail.com> | ||
| # SPDX-License-Identifier: MIT | ||
|
|
||
| from datetime import datetime | ||
|
|
||
| from pydantic import BaseModel, ConfigDict, Field | ||
|
|
||
| from ort.models import AdvisorResult | ||
heliocastro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| from ort.models.config.advisor_configuration import AdvisorConfiguration | ||
| from ort.utils.environment import Environment | ||
|
|
||
| from .identifier import Identifier | ||
|
|
||
|
|
||
| class AdvisorRun(BaseModel): | ||
| """ | ||
| Type alias for a function that allows filtering of [AdvisorResult]s. | ||
|
|
||
| """ | ||
|
|
||
| model_config = ConfigDict( | ||
| extra="forbid", | ||
| ) | ||
| start_time: datetime = Field( | ||
| description="The time the advisor was started.", | ||
| ) | ||
| end_time: datetime = Field( | ||
| description="The time the advisor has finished.", | ||
| ) | ||
| environment: Environment = Field( | ||
| description="The [Environment] in which the advisor was executed.", | ||
| ) | ||
| config: AdvisorConfiguration = Field( | ||
| description="The [AdvisorConfiguration] used for this run.", | ||
| ) | ||
| results: dict[Identifier, list[AdvisorResult]] = Field( | ||
| default_factory=dict, | ||
| description="The result of this run.", | ||
| ) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.