Skip to content

Commit 1c1df49

Browse files
authored
Generate versioned vuln scan results when a release is detected (#150)
1 parent 0f8caa6 commit 1c1df49

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

easy_infra/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ def is_status_expected(*, expected: int, response: dict) -> bool:
180180

181181

182182
def get_artifact_labels(*, variant: str) -> list[str]:
183-
"""For the provided variant of easy_infra, return a list of labels to use in the related artifacts"""
183+
"""
184+
For the provided variant of easy_infra, return a list of labels to use in the related artifacts
185+
The last element in the returned list MUST be the versioned label, if a release is detected
186+
"""
184187
cwd = Path(".").absolute()
185188
repo = git.Repo(cwd)
186189
commit_hash = repo.head.object.hexsha
@@ -192,6 +195,7 @@ def get_artifact_labels(*, variant: str) -> list[str]:
192195
f"v{__version__}" in repo.tags
193196
and repo.tags[f"v{__version__}"].commit.hexsha == commit_hash
194197
):
198+
# Release detected; appending a versioned artifact label
195199
artifact_labels.append(f"{variant}.v{__version__}")
196200

197201
return artifact_labels

tasks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ def sbom(_c, stage="all", debug=False):
292292
variants = process_stages(stage=stage)
293293

294294
for variant in variants:
295-
versioned_tag = CONTEXT[variant]["buildargs"]["VERSION"]
296-
image_and_tag = f"{constants.IMAGE}:{versioned_tag}"
295+
latest_tag = CONTEXT[variant]["buildargs"]["VERSION"]
296+
image_and_tag = f"{constants.IMAGE}:{latest_tag}"
297297

298298
try:
299299
artifact_labels = utils.get_artifact_labels(variant=variant)

tests/test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,8 @@ def run_cli(*, image: str):
10411041
def run_security(*, image: str, variant: str):
10421042
"""Run the security tests"""
10431043
artifact_labels = utils.get_artifact_labels(variant=variant)
1044-
label = artifact_labels[0]
1044+
# This assumes that the last element in the list is versioned, if it is a release
1045+
label = artifact_labels[-1]
10451046
sbom_file = Path(f"sbom.{label}.json")
10461047

10471048
if not sbom_file:

0 commit comments

Comments
 (0)