From a3cd7e6385365a1d190a9e8439311cb9d5eeda56 Mon Sep 17 00:00:00 2001 From: Johannes Kleinlercher Date: Sun, 18 Feb 2024 16:47:19 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20set=20result=20name=20and=20namespace=20?= =?UTF-8?q?to=20trivy=20vulnreport=20and=20configaudi=E2=80=A6=20(#869)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: set result name and namespace to trivy vulnreport and configauditreport Signed-off-by: Johannes Kleinlercher * fix: increase linter timeout Signed-off-by: Johannes Kleinlercher --------- Signed-off-by: Johannes Kleinlercher Signed-off-by: Johannes Kleinlercher Co-authored-by: Alex Jones --- .github/workflows/golangci_lint.yaml | 2 +- pkg/integration/trivy/analyzer.go | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/golangci_lint.yaml b/.github/workflows/golangci_lint.yaml index fedfcff424..e9f18e16cb 100644 --- a/.github/workflows/golangci_lint.yaml +++ b/.github/workflows/golangci_lint.yaml @@ -16,5 +16,5 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} reporter: github-pr-check - golangci_lint_flags: "--timeout=120s" + golangci_lint_flags: "--timeout=240s" level: warning diff --git a/pkg/integration/trivy/analyzer.go b/pkg/integration/trivy/analyzer.go index 547575d7a3..8fdc78b63c 100644 --- a/pkg/integration/trivy/analyzer.go +++ b/pkg/integration/trivy/analyzer.go @@ -15,9 +15,10 @@ package trivy import ( "fmt" - ctrl "sigs.k8s.io/controller-runtime/pkg/client" "strings" + ctrl "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/aquasecurity/trivy-operator/pkg/apis/aquasecurity/v1alpha1" "github.com/k8sgpt-ai/k8sgpt/pkg/common" "github.com/k8sgpt-ai/k8sgpt/pkg/util" @@ -59,8 +60,8 @@ func (TrivyAnalyzer) analyzeVulnerabilityReports(a common.Analyzer) ([]common.Re } } if len(failures) > 0 { - preAnalysis[fmt.Sprintf("%s/%s", report.Labels["trivy-operator.resource.namespace"], - report.Labels["trivy-operator.resource.name"])] = common.PreAnalysis{ + preAnalysis[fmt.Sprintf("%s/%s", report.Namespace, + report.Name)] = common.PreAnalysis{ TrivyVulnerabilityReport: report, FailureDetails: failures, } @@ -122,8 +123,8 @@ func (t TrivyAnalyzer) analyzeConfigAuditReports(a common.Analyzer) ([]common.Re } if len(failures) > 0 { - preAnalysis[fmt.Sprintf("%s/%s", report.Labels["trivy-operator.resource.namespace"], - report.Labels["trivy-operator.resource.name"])] = common.PreAnalysis{ + preAnalysis[fmt.Sprintf("%s/%s", report.Namespace, + report.Name)] = common.PreAnalysis{ TrivyConfigAuditReport: report, FailureDetails: failures, }