diff --git a/adapters/v1/backend.go b/adapters/v1/backend.go index 8a1c128..acb4601 100644 --- a/adapters/v1/backend.go +++ b/adapters/v1/backend.go @@ -24,6 +24,8 @@ import ( ) type BackendAdapter struct { + eventReceiverRestURL string + apiServerRestURL string clusterConfig pkgcautils.ClusterConfig getCVEExceptionsFunc func(string, string, *identifiers.PortalDesignator) ([]armotypes.VulnerabilityExceptionPolicy, error) httpPostFunc func(httputils.IHttpClient, string, map[string]string, []byte) (*http.Response, error) @@ -35,10 +37,10 @@ var _ ports.Platform = (*BackendAdapter)(nil) func NewBackendAdapter(accountID, apiServerRestURL, eventReceiverRestURL string) *BackendAdapter { return &BackendAdapter{ clusterConfig: pkgcautils.ClusterConfig{ - AccountID: accountID, - EventReceiverRestURL: eventReceiverRestURL, - ApiServerRestURL: apiServerRestURL, + AccountID: accountID, }, + eventReceiverRestURL: eventReceiverRestURL, + apiServerRestURL: apiServerRestURL, getCVEExceptionsFunc: backendClientV1.GetCVEExceptionByDesignator, httpPostFunc: httputils.HttpPost, sendStatusFunc: func(sender *backendClientV1.BaseReportSender, status string, sendReport bool, errChan chan<- error) { @@ -86,7 +88,7 @@ func (a *BackendAdapter) GetCVEExceptions(ctx context.Context) (domain.CVEExcept }, } - vulnExceptionList, err := a.getCVEExceptionsFunc(a.clusterConfig.ApiServerRestURL, a.clusterConfig.AccountID, &designator) + vulnExceptionList, err := a.getCVEExceptionsFunc(a.apiServerRestURL, a.clusterConfig.AccountID, &designator) if err != nil { return nil, err } @@ -119,7 +121,7 @@ func (a *BackendAdapter) SendStatus(ctx context.Context, step int) error { report.Details = details[step] ReportErrorsChan := make(chan error) - sender := backendClientV1.NewBaseReportSender(a.clusterConfig.EventReceiverRestURL, &http.Client{}, report) + sender := backendClientV1.NewBaseReportSender(a.eventReceiverRestURL, &http.Client{}, report) a.sendStatusFunc(sender, sysreport.JobSuccess, true, ReportErrorsChan) err := <-ReportErrorsChan return err @@ -226,11 +228,11 @@ func (a *BackendAdapter) SubmitCVE(ctx context.Context, cve domain.CVEManifest, firstVulnerabilitiesChunk := <-chunksChan firstChunkVulnerabilitiesCount := len(firstVulnerabilitiesChunk) // send the summary and the first chunk in one or two reports according to the size - nextPartNum := a.sendSummaryAndVulnerabilities(ctx, &finalReport, a.clusterConfig.EventReceiverRestURL, totalVulnerabilities, scanID, firstVulnerabilitiesChunk, errChan, sendWG) + nextPartNum := a.sendSummaryAndVulnerabilities(ctx, &finalReport, a.eventReceiverRestURL, totalVulnerabilities, scanID, firstVulnerabilitiesChunk, errChan, sendWG) // if not all vulnerabilities got into the first chunk if totalVulnerabilities != firstChunkVulnerabilitiesCount { //send the rest of the vulnerabilities - error channel will be closed when all vulnerabilities are sent - a.sendVulnerabilitiesRoutine(ctx, chunksChan, a.clusterConfig.EventReceiverRestURL, scanID, finalReport, errChan, sendWG, totalVulnerabilities, firstChunkVulnerabilitiesCount, nextPartNum) + a.sendVulnerabilitiesRoutine(ctx, chunksChan, a.eventReceiverRestURL, scanID, finalReport, errChan, sendWG, totalVulnerabilities, firstChunkVulnerabilitiesCount, nextPartNum) } else { //only one chunk will be sent so need to close the error channel when it is done go func(wg *sync.WaitGroup, errorChan chan error) { diff --git a/go.mod b/go.mod index ea1976e..abaef20 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/aquilax/truncate v1.0.0 github.com/armosec/armoapi-go v0.0.220 github.com/armosec/utils-go v0.0.20 - github.com/armosec/utils-k8s-go v0.0.17 + github.com/armosec/utils-k8s-go v0.0.18 github.com/distribution/distribution v2.8.2+incompatible github.com/docker/docker v24.0.5+incompatible github.com/eapache/go-resiliency v1.3.0 diff --git a/go.sum b/go.sum index 4e1201d..cdec6ce 100644 --- a/go.sum +++ b/go.sum @@ -288,8 +288,8 @@ github.com/armosec/gojay v1.2.15 h1:sSB2vnAvacUNkw9nzUYZKcPzhJOyk6/5LK2JCNdmoZY= github.com/armosec/gojay v1.2.15/go.mod h1:vzVAaay2TWJAngOpxu8aqLbye9jMgoKleuAOK+xsOts= github.com/armosec/utils-go v0.0.20 h1:bvr+TMumEYdMsGFGSsaQysST7K02nNROFvuajNuKPlw= github.com/armosec/utils-go v0.0.20/go.mod h1:ZEFiSv8KpTFNT19jHis1IengiF/BGDvg7tHmXo+cwxs= -github.com/armosec/utils-k8s-go v0.0.17 h1:HUntJGR0/PHt7bp8S0zLhVcJ6sDz061Hc9mAM9ha1lA= -github.com/armosec/utils-k8s-go v0.0.17/go.mod h1:FJRG/MRz7jT4ExSEYHIFsilVsAF11M+GJRhLl4PFZ4s= +github.com/armosec/utils-k8s-go v0.0.18 h1:SBmj+j/5JrROVQVLjlHsoMcPZKK/AKWEK1SMMf3hd1U= +github.com/armosec/utils-k8s-go v0.0.18/go.mod h1:FJRG/MRz7jT4ExSEYHIFsilVsAF11M+GJRhLl4PFZ4s= github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k= github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=