Skip to content

Commit

Permalink
Customer guid generated flag (#136)
Browse files Browse the repository at this point in the history
* customerGUID generated field

Signed-off-by: Amir Malka <[email protected]>

* gojay unmarshal posture report

Signed-off-by: Amir Malka <[email protected]>

* gojay unmarshal scanning target

Signed-off-by: Amir Malka <[email protected]>

* updated go.mod

Signed-off-by: Amir Malka <[email protected]>

---------

Signed-off-by: Amir Malka <[email protected]>
  • Loading branch information
amirmalka authored Aug 15, 2023
1 parent f2007ec commit b4dbe79
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/kubescape/opa-utils
go 1.20

require (
github.com/armosec/armoapi-go v0.0.211
github.com/armosec/armoapi-go v0.0.220
github.com/armosec/utils-go v0.0.20
github.com/francoispqt/gojay v1.2.13
github.com/kubescape/k8s-interface v0.0.135-0.20230730135750-e6e709507847
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/armosec/armoapi-go v0.0.211 h1:OS4D56sfoaU7T6FOCyrufE2Ttdzv9tP7MZkFxh82ll0=
github.com/armosec/armoapi-go v0.0.211/go.mod h1:4AEdwBrbS1YCAn/lZzV+cOOR9BPa0MTHYHiJDlR1uRQ=
github.com/armosec/armoapi-go v0.0.220 h1:gfg2UmcFgcyStjp5ZXfwE8yb0H43eaRX9H/KkqFIv6w=
github.com/armosec/armoapi-go v0.0.220/go.mod h1:Y1ZcqPUTQ+F8JiQzErrToK5ULrPvClxZoshHmV9PIlU=
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=
Expand Down
27 changes: 14 additions & 13 deletions reporthandling/v2/datastructures.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ import (

// PostureReport posture scanning report structure
type PostureReport struct {
ReportGenerationTime time.Time `json:"generationTime"`
Metadata Metadata `json:"metadata,omitempty"`
ClusterAPIServerInfo *version.Info `json:"clusterAPIServerInfo"`
CustomerGUID string `json:"customerGUID"`
ClusterName string `json:"clusterName"`
ClusterCloudProvider string `json:"clusterCloudProvider"`
ReportID string `json:"reportGUID"`
JobID string `json:"jobID"`
Resources []reporthandling.Resource `json:"resources,omitempty"`
Attributes []reportsummary.PostureAttributes `json:"attributes"`
Results []resourcesresults.Result `json:"results,omitempty"`
SummaryDetails reportsummary.SummaryDetails `json:"summaryDetails,omitempty"`
PaginationInfo armoapi.PaginationMarks `json:"paginationInfo"`
ReportGenerationTime time.Time `json:"generationTime"`
ClusterAPIServerInfo *version.Info `json:"clusterAPIServerInfo"`
ClusterCloudProvider string `json:"clusterCloudProvider"`
CustomerGUID string `json:"customerGUID"`
ClusterName string `json:"clusterName"`
ReportID string `json:"reportGUID"`
JobID string `json:"jobID"`
SummaryDetails reportsummary.SummaryDetails `json:"summaryDetails,omitempty"`
Resources []reporthandling.Resource `json:"resources,omitempty"`
Attributes []reportsummary.PostureAttributes `json:"attributes"`
Results []resourcesresults.Result `json:"results,omitempty"`
Metadata Metadata `json:"metadata,omitempty"`
PaginationInfo armoapi.PaginationMarks `json:"paginationInfo"`
CustomerGUIDGenerated bool `json:"customerGUIDGenerated"`
}

type ClusterMetadata struct {
Expand Down
9 changes: 8 additions & 1 deletion reporthandling/v2/gojayunmarshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ func (r *PostureReport) UnmarshalJSONObject(dec *gojay.Decoder, key string) (err
r.ReportGenerationTime = r.ReportGenerationTime.Local()
case "metadata":
err = dec.Object(&(r.Metadata))
case "customerGUIDGenerated":
err = dec.Bool(&(r.CustomerGUIDGenerated))
case "paginationInfo":
err = dec.Object(&(r.PaginationInfo))
}
return err

}

// func (files *PkgFiles) UnmarshalJSONArray(dec *gojay.Decoder) error {
Expand Down Expand Up @@ -140,6 +143,10 @@ func (m *ScanMetadata) UnmarshalJSONObject(dec *gojay.Decoder, key string) (err
err = dec.String(&(m.ControlsInputs))
case "verboseMode": // bool
err = dec.Bool(&(m.VerboseMode))
case "scanningTarget":
var value uint16
err = dec.Uint16(&value)
m.ScanningTarget = ScanningTarget(value)
}
return err

Expand Down

0 comments on commit b4dbe79

Please sign in to comment.