Skip to content

Commit 930fa41

Browse files
committed
feat: add appropriate handling for info not found
Signed-off-by: Demolus13 <parth.govale@oracle.com>
1 parent c5b5f30 commit 930fa41

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/macaron/slsa_analyzer/analyzer.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,12 @@ def add_repository(self, branch_name: str | None, git_obj: Git) -> Repository |
695695
)
696696

697697
self.rich_handler.add_description_table_content("Branch:", res_branch if res_branch else "None")
698-
self.rich_handler.add_description_table_content("Commit Hash:", commit_sha)
699-
self.rich_handler.add_description_table_content("Commit Date:", commit_date_str)
698+
self.rich_handler.add_description_table_content(
699+
"Commit Hash:", commit_sha if commit_sha else "[red]Not Found[/]"
700+
)
701+
self.rich_handler.add_description_table_content(
702+
"Commit Date:", commit_date_str if commit_date_str else "[red]Not Found[/]"
703+
)
700704

701705
return repository
702706

@@ -785,6 +789,9 @@ def add_component(
785789
# software component. If this happens, we don't raise error and treat the software component as if it
786790
# does not have any ``Repository`` attached to it.
787791
repository = None
792+
self.rich_handler.add_description_table_content("Branch:", "[red]Not Found[/]")
793+
self.rich_handler.add_description_table_content("Commit Hash:", "[red]Not Found[/]")
794+
self.rich_handler.add_description_table_content("Commit Date:", "[red]Not Found[/]")
788795

789796
if not analysis_target.parsed_purl:
790797
# If the PURL is not available. This will only mean that the user don't provide PURL but only provide the
@@ -1049,6 +1056,10 @@ def _determine_build_tools(self, analyze_ctx: AnalyzeContext, git_service: BaseG
10491056
)
10501057
else:
10511058
logger.info("Unable to discover build tools because repository is None.")
1059+
self.rich_handler.add_description_table_content(
1060+
"Build Tools:",
1061+
"[red]Not Found[/]",
1062+
)
10521063
else:
10531064
self.rich_handler.add_description_table_content(
10541065
"Build Tools:",
@@ -1058,6 +1069,10 @@ def _determine_build_tools(self, analyze_ctx: AnalyzeContext, git_service: BaseG
10581069
def _determine_ci_services(self, analyze_ctx: AnalyzeContext, git_service: BaseGitService) -> None:
10591070
"""Determine the CI services used by the software component."""
10601071
if isinstance(git_service, NoneGitService):
1072+
self.rich_handler.add_description_table_content(
1073+
"CI Services:",
1074+
"[red]Not Found[/]",
1075+
)
10611076
return
10621077

10631078
# Determine the CI services.
@@ -1095,6 +1110,11 @@ def _determine_ci_services(self, analyze_ctx: AnalyzeContext, git_service: BaseG
10951110
"CI Services:",
10961111
"\n".join([ci_service["service"].name for ci_service in analyze_ctx.dynamic_data["ci_services"]]),
10971112
)
1113+
else:
1114+
self.rich_handler.add_description_table_content(
1115+
"CI Services:",
1116+
"[red]Not Found[/]",
1117+
)
10981118

10991119
def _populate_package_registry_info(self) -> list[PackageRegistryInfo]:
11001120
"""Add all possible package registries to the analysis context."""

src/macaron/slsa_analyzer/checks/detect_malicious_metadata_check.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ class DetectMaliciousMetadataCheck(BaseCheck):
8282
def __init__(self) -> None:
8383
"""Initialize a check instance."""
8484
check_id = "mcn_detect_malicious_metadata_1"
85-
description = """Check if the package is malicious.
86-
"""
85+
description = """Check if the package is malicious."""
8786
super().__init__(check_id=check_id, description=description, eval_reqs=[])
8887

8988
def _should_skip(

0 commit comments

Comments
 (0)