Skip to content

Commit

Permalink
fix: add unique id for all PolicyReport report
Browse files Browse the repository at this point in the history
  • Loading branch information
devopstales committed Jun 30, 2022
1 parent b2c7a94 commit 569e0cd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions trivy-operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from OpenSSL import crypto
from datetime import datetime, timezone
import logging
import uuid

#############################################################################
# Logging
Expand Down Expand Up @@ -443,6 +444,7 @@ def delete_policyreports(namespace, name):
"properties": {
"artifact.repository": image_name.split(':')[0],
"artifact.tag": image_name.split(':')[1],
"resultID": str(uuid.uuid4()),
},
"resources": [],
"result": "error",
Expand Down Expand Up @@ -524,12 +526,14 @@ def delete_policyreports(namespace, name):
"policy": "Image Vulnerability",
"rule": item["VulnerabilityID"],
"properties": {
"artifact.repository": image_name.split(':')[0],
"artifact.tag": image_name.split(':')[1],
"registry.server": image_name.split('/')[0],
"artifact.repository": image_name.split('/')[1] + "/" + image_name.split('/')[2].split(':')[0],
"artifact.tag": image_name.split(':')[-1],
"resource": item["PkgName"],
"score": str(score),
"primaryLink": item["PrimaryURL"],
"installedVersion": item["InstalledVersion"],
"resultID": str(uuid.uuid4()),
},
"resources": [],
"severity": item["Severity"].lower(),
Expand Down Expand Up @@ -574,8 +578,10 @@ def delete_policyreports(namespace, name):
"policy": "Image Vulnerability",
"rule": item["VulnerabilityID"],
"properties": {
"artifact.repository": image_name.split(':')[0],
"registry.server": image_name.split('/')[0],
"artifact.repository": image_name.split('/')[1] + "/" + image_name.split('/')[2].split(':')[0],
"artifact.tag": image_name.split(':')[1],
"resultID": str(uuid.uuid4()),
},
"resources": [],
"result": "pass",
Expand Down Expand Up @@ -1038,7 +1044,7 @@ def validate1(logger, namespace, name, annotations, spec, **_):
elif b"unsupported MediaType" in error.strip():
logger.error(
"Unsupported MediaType: see https://github.com/google/go-containerregistry/issues/377")
elif b"MANIFEST_UNKNOWN: manifest unknown; map[Tag:latest]" in error.strip():
elif b"MANIFEST_UNKNOWN: manifest unknown" in error.strip():
logger.error("No tag in registry")
else:
logger.error("%s" % (error.strip()))
Expand Down

0 comments on commit 569e0cd

Please sign in to comment.