Skip to content

feat: Asset subtype population for container remedies from Trivy - #21

Merged
NachoCamposMarti merged 1 commit into
ASPMAIN-5492_fix-versions-added-to-remedies-from-importsfrom
ASPMAIN-5492_asset-subtype
Jun 22, 2026
Merged

feat: Asset subtype population for container remedies from Trivy#21
NachoCamposMarti merged 1 commit into
ASPMAIN-5492_fix-versions-added-to-remedies-from-importsfrom
ASPMAIN-5492_asset-subtype

Conversation

@NachoCamposMarti

Copy link
Copy Markdown
Contributor

No description provided.

@NachoCamposMarti
NachoCamposMarti merged commit a60fa82 into ASPMAIN-5492_fix-versions-added-to-remedies-from-imports Jun 22, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for an optional asset_sub_type parameter during asset imports, passing it through the batching process and including it in the final API payload. Additionally, it adds a helper method to automatically set the subtype to "CONTAINER_IMAGE" when using the TrivyTranslator. The review feedback correctly points out that unconditionally applying this subtype for all Trivy scans is problematic, as Trivy can scan non-container assets. It is recommended to update the helper method to only apply the "CONTAINER_IMAGE" subtype when container assets are actually present in the parsed list.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +623 to +628
@staticmethod
def _trivy_asset_sub_type(translator) -> Optional[str]:
"""Trivy container imports require assessment.assetSubType=CONTAINER_IMAGE."""
if translator and translator.__class__.__name__ == "TrivyTranslator":
return "CONTAINER_IMAGE"
return None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Unconditionally returning "CONTAINER_IMAGE" for any scan processed by TrivyTranslator is problematic. Trivy is a multi-purpose scanner that can also scan filesystems, git repositories, virtual machines, and cloud accounts (which map to REPOSITORY, BUILD, INFRA, or CLOUD asset types). Setting the assessment's assetSubType to "CONTAINER_IMAGE" for these non-container scans will result in mismatched metadata or API validation failures in the Phoenix backend.

We should restrict this subtype population to only when the parsed assets are actually of type CONTAINER.

Suggested change
@staticmethod
def _trivy_asset_sub_type(translator) -> Optional[str]:
"""Trivy container imports require assessment.assetSubType=CONTAINER_IMAGE."""
if translator and translator.__class__.__name__ == "TrivyTranslator":
return "CONTAINER_IMAGE"
return None
@staticmethod
def _trivy_asset_sub_type(translator, assets: list) -> Optional[str]:
"""Trivy container imports require assessment.assetSubType=CONTAINER_IMAGE."""
if translator and translator.__class__.__name__ == "TrivyTranslator":
if assets and any(getattr(asset, "asset_type", None) == "CONTAINER" for asset in assets):
return "CONTAINER_IMAGE"
return None

assessment_name = self._generate_assessment_name(file_path, detected_scanner)

# Step 6: Import with or without batching
asset_sub_type = self._trivy_asset_sub_type(translator)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Update the call to _trivy_asset_sub_type to pass the parsed assets list, ensuring the subtype is only applied when container assets are actually present.

Suggested change
asset_sub_type = self._trivy_asset_sub_type(translator)
asset_sub_type = self._trivy_asset_sub_type(translator, assets)

NachoCamposMarti added a commit that referenced this pull request Jun 22, 2026
* fix: fixVersions included in import assets HTTP call

* feat: Asset subtype population for container remedies from Trivy (#21)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant