Skip to content

Commit

Permalink
updated cluster config
Browse files Browse the repository at this point in the history
Signed-off-by: Amir Malka <amirm@armosec.io>
  • Loading branch information
amirmalka committed Aug 29, 2023
1 parent d10c09d commit 29bf976
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions adapters/v1/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 29bf976

Please sign in to comment.