This commit is contained in:
Avinesh Tripathi
2022-09-20 18:50:19 +05:30
parent d6427f0fc8
commit 87fdbfdcc5
7 changed files with 34 additions and 31 deletions
@@ -20,9 +20,9 @@ func NewGCPAdaptor(GCPCloudAPI *getter.GCPCloudAPI) *GCPAdaptor {
}
func (GCPAdaptor *GCPAdaptor) Login() error {
client, er := containeranalysis.NewClient(GCPAdaptor.GCPCloudAPI.GetContext(), option.WithCredentialsFile(GCPAdaptor.GCPCloudAPI.GetcrediantialsPath()))
if er != nil {
fmt.Printf("Error client: %v", er)
client, err := containeranalysis.NewClient(GCPAdaptor.GCPCloudAPI.GetContext(), option.WithCredentialsFile(GCPAdaptor.GCPCloudAPI.GetCrediantialsPath()))
if err != nil {
return err
}
GCPAdaptor.GCPCloudAPI.SetClient(client)
return nil
@@ -50,7 +50,7 @@ func (GCPAdaptor *GCPAdaptor) GetImageVulnerability(imageID *registryvulnerabili
Filter: fmt.Sprintf(`resourceUrl=%q`, resourceUrl),
}
it := GCPAdaptor.GCPCloudAPI.Getclient().GetGrafeasClient().ListOccurrences(GCPAdaptor.GCPCloudAPI.GetContext(), req)
it := GCPAdaptor.GCPCloudAPI.GetClient().GetGrafeasClient().ListOccurrences(GCPAdaptor.GCPCloudAPI.GetContext(), req)
occs := []*grafeaspb.Occurrence{}
var count int
for {
@@ -59,8 +59,7 @@ func (GCPAdaptor *GCPAdaptor) GetImageVulnerability(imageID *registryvulnerabili
break
}
if err != nil {
fmt.Println(err)
break
return nil, err
}
occs = append(occs, occ)
count++
@@ -8,7 +8,7 @@ import (
)
type GCPAdaptorMock struct {
resultList *[]registryvulnerabilities.ContainerImageVulnerabilityReport
resultList []registryvulnerabilities.ContainerImageVulnerabilityReport
}
func NewGCPAdaptorMock() (*GCPAdaptorMock, error) {
@@ -32,8 +32,8 @@ func (GCPAdaptorMock *GCPAdaptorMock) GetImagesVulnerabilities(imageIDs []regist
return resultList, nil
}
GCPAdaptorMock.resultList = &resultList
return *GCPAdaptorMock.resultList, nil
GCPAdaptorMock.resultList = resultList
return GCPAdaptorMock.resultList, nil
}
func (GCPAdaptorMock *GCPAdaptorMock) GetImageVulnerability(imageID *registryvulnerabilities.ContainerImageIdentifier) (*registryvulnerabilities.ContainerImageVulnerabilityReport, error) {
@@ -1,21 +1,15 @@
package v1
import (
"fmt"
"github.com/kubescape/kubescape/v2/core/pkg/registryadaptors/registryvulnerabilities"
grafeaspb "google.golang.org/genproto/googleapis/grafeas/v1"
)
func (GCPAdaptor *GCPAdaptor) getImageLastScanId(imageID *registryvulnerabilities.ContainerImageIdentifier) (string, error) {
var s string
return s, nil
// TODO
return "", nil
}
func GetResourceUrl(imageID *registryvulnerabilities.ContainerImageIdentifier) string {
return fmt.Sprintf("https:/%s/%s", imageID.Repository, imageID.Tag)
}
func responseObjectToVulnerabilities(vulnerabilityList []*grafeaspb.Occurrence, count int) []registryvulnerabilities.Vulnerability {
vulnerabilities := make([]registryvulnerabilities.Vulnerability, count)
+2 -2
View File
@@ -2,15 +2,15 @@ package resourcehandler
import (
"fmt"
logger "github.com/kubescape/go-logger"
"github.com/kubescape/k8s-interface/k8sinterface"
"github.com/kubescape/k8s-interface/workloadinterface"
"github.com/kubescape/kubescape/v2/core/cautils"
"github.com/kubescape/kubescape/v2/core/cautils/getter"
gcpadaptorv1 "github.com/kubescape/kubescape/v2/core/pkg/registryadaptors/GCP/v1"
armosecadaptorv1 "github.com/kubescape/kubescape/v2/core/pkg/registryadaptors/armosec/v1"
"github.com/kubescape/kubescape/v2/core/pkg/registryadaptors/registryvulnerabilities"
gcpadaptorv1 "github.com/kubescape/kubescape/v2/core/pkg/registryadaptors/GCP/v1"
"github.com/kubescape/opa-utils/shared"
)