@@ -38,6 +38,8 @@ const (
3838 vulnerabilityJitter = 10 * time .Minute
3939
4040 reportChunkSize = 15
41+
42+ repositoryURLAnnotationKey = "platform.plural.sh/repository-url"
4143)
4244
4345// VulnerabilityReportReconciler reconciles a Trivy VulnerabilityReport resource.
@@ -63,18 +65,23 @@ func (r *VulnerabilityReportReconciler) Reconcile(ctx context.Context, req ctrl.
6365 return ctrl.Result {}, nil
6466 }
6567
66- var serviceId * string
68+ var serviceId , repositoryURL * string
6769 if len (vulnerabilityReport .OwnerReferences ) > 0 {
6870 k8sObj , err := GetObjectFromOwnerReference (ctx , r .Client , vulnerabilityReport .OwnerReferences [0 ], vulnerabilityReport .Namespace )
6971 if err != nil {
7072 return ctrl.Result {}, err
7173 }
72- svcId , ok := k8sObj .GetAnnotations ()[smcommon .OwningInventoryKey ]
73- if ok {
74+
75+ annotations := k8sObj .GetAnnotations ()
76+ if svcId , ok := annotations [smcommon .OwningInventoryKey ]; ok {
7477 serviceId = lo .ToPtr (svcId )
7578 }
79+
80+ if repoURL , ok := annotations [repositoryURLAnnotationKey ]; ok {
81+ repositoryURL = lo .ToPtr (repoURL )
82+ }
7683 }
77- attrs , timestamp := createVulnAttributes (* vulnerabilityReport , serviceId )
84+ attrs , timestamp := createVulnAttributes (* vulnerabilityReport , serviceId , repositoryURL )
7885 r .reports .Set (req .String (), vulnReport {
7986 attributes : & attrs ,
8087 timestamp : timestamp ,
@@ -85,7 +92,7 @@ func (r *VulnerabilityReportReconciler) Reconcile(ctx context.Context, req ctrl.
8592 return jitterRequeue (vulnerabilityRequeueAfter , vulnerabilityJitter ), nil
8693}
8794
88- func createVulnAttributes (vulnerabilityReport trivy.VulnerabilityReport , serviceID * string ) (console.VulnerabilityReportAttributes , time.Time ) {
95+ func createVulnAttributes (vulnerabilityReport trivy.VulnerabilityReport , serviceID * string , repositoryURL * string ) (console.VulnerabilityReportAttributes , time.Time ) {
8996 var namespaces []* console.NamespaceVulnAttributes
9097 os := & console.VulnOsAttributes {
9198 Eosl : lo .ToPtr (vulnerabilityReport .Report .OS .Eosl ),
@@ -147,6 +154,7 @@ func createVulnAttributes(vulnerabilityReport trivy.VulnerabilityReport, service
147154 Class : lo .ToPtr (v .Class ),
148155 PackageType : lo .ToPtr (v .PackageType ),
149156 PkgPath : lo .ToPtr (v .PkgPath ),
157+ RepositoryURL : repositoryURL ,
150158 }
151159 if v .PublishedDate != "" {
152160 vulnerabilityAttr .PublishedDate = lo .ToPtr (v .PublishedDate )
0 commit comments