Skip to content

Commit

Permalink
fix: properly close the downloaded sbom artifact file before accessin…
Browse files Browse the repository at this point in the history
…g it
  • Loading branch information
Thomas Neidhart committed Feb 19, 2025
1 parent d6ceff9 commit e84e8cd
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions otterdog/webapp/tasks/policies/upload_sbom.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ async def _process_artifact(self, rest_api: RestApi, artifact_id: int) -> None:
async with aiofiles.open(artifact_file_name, "wb") as artifact_file:
await rest_api.action.download_artifact(artifact_file, self.org_id, self.repo_name, artifact_id)

with zipfile.ZipFile(artifact_file_name, "r") as zip_file:
zip_file.extractall(tmp_dir)
with zipfile.ZipFile(artifact_file_name, "r") as zip_file:
zip_file.extractall(tmp_dir)

bom_file_name = os.path.join(tmp_dir, "bom.json")
metadata_file_name = os.path.join(tmp_dir, "metadata.json")
bom_file_name = os.path.join(tmp_dir, "bom.json")
metadata_file_name = os.path.join(tmp_dir, "metadata.json")

with open(bom_file_name) as bom_file:
bom = json.load(bom_file)
with open(bom_file_name) as bom_file:
bom = json.load(bom_file)

with open(metadata_file_name) as metadata_file:
metadata = Metadata.model_validate(json.load(metadata_file))
with open(metadata_file_name) as metadata_file:
metadata = Metadata.model_validate(json.load(metadata_file))

await self._upload_bom(bom, metadata)
await self._upload_bom(bom, metadata)

async def _upload_bom(self, bom: dict[str, Any], meta_data: Metadata) -> None:
async with aiohttp.ClientSession() as session:
Expand Down

0 comments on commit e84e8cd

Please sign in to comment.