v2

package
v0.0.246 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2023 License: Apache-2.0 Imports: 14 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PostureReportMockPassedSingleResource = `` /* 6734-byte string literal not displayed */
View Source
var ResourcesListMock = `` /* 69799-byte string literal not displayed */

Functions

func GetResourcesListMock

func GetResourcesListMock() []reporthandling.Resource

Types

type CloudMetadata added in v0.0.217

type CloudMetadata struct {
	CloudProvider apis.CloudProviderName `json:"cloudProvider,omitempty"`
	ShortName     string                 `json:"shortName,omitempty"`
	FullName      string                 `json:"fullName,omitempty"`
	PrefixName    string                 `json:"prefixName,omitempty"`
}

CloudMetadata metadata of the cloud the cluster is running on. Compatible with the reporthandling.ICloudMetadata interface

func NewCloudMetadata added in v0.0.217

func NewCloudMetadata(cloudParser apis.ICloudParser) *CloudMetadata

NewCloudMetadata creates a new CloudMetadata object

func (*CloudMetadata) GetFullName added in v0.0.217

func (cloudMetadata *CloudMetadata) GetFullName() string

Get full name as it appears in the config file

func (*CloudMetadata) GetName added in v0.0.217

func (cloudMetadata *CloudMetadata) GetName() string

Get the suffix of the name. For example, for a cluster named "gke_project_zone_my-cluster" in GKE, the suffix is "my-cluster"

func (*CloudMetadata) GetPrefix added in v0.0.217

func (cloudMetadata *CloudMetadata) GetPrefix() string

Get the prefix of the name. For example, for a cluster named "gke_project_zone_my-cluster" in GKE, the prefix is "gke_project_zone"

func (*CloudMetadata) GetProvider added in v0.0.217

func (cloudMetadata *CloudMetadata) GetProvider() apis.CloudProviderName

Get provider name

type ClusterMetadata

type ClusterMetadata struct {
	MapNamespaceToNumberOfResources map[string]int `json:"namespaceToNumberOfResources,omitempty"`
	CloudMetadata                   *CloudMetadata `json:"cloudMetadata,omitempty"`
	CloudProvider                   string         `json:"cloudProvider,omitempty"` // Deprecated - info should be in cloudMetadata
	ContextName                     string         `json:"contextName,omitempty"`
	NumberOfWorkerNodes             int            `json:"numberOfWorkerNodes,omitempty"`
}

func (*ClusterMetadata) NKeys

func (file *ClusterMetadata) NKeys() int

func (*ClusterMetadata) UnmarshalJSONObject

func (m *ClusterMetadata) UnmarshalJSONObject(dec *gojay.Decoder, key string) (err error)

UnmarshalJSONObject unmarshals incoming JSON data into a ClusterMetadata object

type ContextMetadata

type ContextMetadata struct {
	ClusterContextMetadata   *ClusterMetadata          `json:"clusterContextMetadata,omitempty"`
	RepoContextMetadata      *RepoContextMetadata      `json:"gitRepoContextMetadata,omitempty"`
	FileContextMetadata      *FileContextMetadata      `json:"fileContextMetadata,omitempty"`
	HelmContextMetadata      *HelmContextMetadata      `json:"helmContextMetadata,omitempty"`
	DirectoryContextMetadata *DirectoryContextMetadata `json:"directoryContextMetadata,omitempty"`
}

type DirectoryContextMetadata

type DirectoryContextMetadata struct {
	BasePath string `json:"basePath,omitempty"` // the scanning request base path
	HostName string `json:"hostName,omitempty"` // like "hostpath"
}

type FileContextMetadata

type FileContextMetadata struct {
	FilePath string `json:"filePath,omitempty"` // like "hostpath"
	HostName string `json:"hostName,omitempty"` // like "hostpath"
}

type HelmContextMetadata

type HelmContextMetadata struct {
	ChartName string `json:"chartName,omitempty"`
}

type IBasicPostureReport

type IBasicPostureReport interface {
	reportsummary.IBasicPostureReport
	GetScannigTarget() ScanningTarget
	GetContextMetadata() *ContextMetadata
	GetRepositoryHash() string
}

type Metadata

type Metadata struct {
	ContextMetadata ContextMetadata `json:"targetMetadata,omitempty"`
	ClusterMetadata ClusterMetadata `json:"clusterMetadata,omitempty"`
	ScanMetadata    ScanMetadata    `json:"scanMetadata,omitempty"`
}

func (*Metadata) NKeys

func (file *Metadata) NKeys() int

func (*Metadata) UnmarshalJSONObject

func (m *Metadata) UnmarshalJSONObject(dec *gojay.Decoder, key string) (err error)

UnmarshalJSONObject unmarshals incoming JSON data into a Metadata object

type PostureReport

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"`
}

PostureReport posture scanning report structure

func GetPostureReportMockPassedSingleResource

func GetPostureReportMockPassedSingleResource() *PostureReport

func (*PostureReport) AppendResourceResultToSummary

func (postureReport *PostureReport) AppendResourceResultToSummary(resourceResult *resourcesresults.Result)

AppendResourceResultToSummary get the result of a single resource. If resource not found will return nil

func (*PostureReport) GetClusterName

func (postureReport *PostureReport) GetClusterName() string

func (*PostureReport) GetContextMetadata

func (postureReport *PostureReport) GetContextMetadata() *ContextMetadata

func (*PostureReport) GetCustomerGUID

func (postureReport *PostureReport) GetCustomerGUID() string

========IPostureReport implementations =======

func (*PostureReport) GetJobID

func (postureReport *PostureReport) GetJobID() string

func (*PostureReport) GetReportGUID

func (postureReport *PostureReport) GetReportGUID() string

func (*PostureReport) GetRepositoryHash

func (postureReport *PostureReport) GetRepositoryHash() string

func (*PostureReport) GetResource

func (postureReport *PostureReport) GetResource(resourceID string) workloadinterface.IMetadata

GetResource get single resource in IMetadata interface representation

func (*PostureReport) GetScannigTarget

func (postureReport *PostureReport) GetScannigTarget() ScanningTarget

func (*PostureReport) GetStatus

func (postureReport *PostureReport) GetStatus() *helpersv1.Status

Status get the overall scanning status

func (*PostureReport) GetTimestamp

func (postureReport *PostureReport) GetTimestamp() *time.Time

func (*PostureReport) InitializeSummary

func (postureReport *PostureReport) InitializeSummary()

UpdateSummary get the result of a single resource. If resource not found will return nil

func (*PostureReport) ListControls

func (postureReport *PostureReport) ListControls() []reportsummary.IControlSummary

=========================================== List Controls ==================================== ListControls list all controls policies summary

func (*PostureReport) ListControlsIDs

func (postureReport *PostureReport) ListControlsIDs() *helpersv1.AllLists

ListControlsIDs list all controls names

func (*PostureReport) ListControlsNames

func (postureReport *PostureReport) ListControlsNames() *helpersv1.AllLists

ListControlsNames list all controls names

func (*PostureReport) ListFrameworks

func (postureReport *PostureReport) ListFrameworks() []reportsummary.IFrameworkSummary

ListFrameworksNames list all framework policies summary

func (*PostureReport) ListFrameworksNames

func (postureReport *PostureReport) ListFrameworksNames() *helpersv1.AllLists

ListFrameworksNames list all frameworks names

func (*PostureReport) ListResourcesIDs

func (postureReport *PostureReport) ListResourcesIDs(f *helpersv1.Filters) *helpersv1.AllLists

func (*PostureReport) NKeys

func (file *PostureReport) NKeys() int

func (*PostureReport) ResourceResult

func (postureReport *PostureReport) ResourceResult(resourceID string) *resourcesresults.Result

ResourceResult get the result of a single resource. If resource not found will return nil

func (*PostureReport) ResourceStatus

func (postureReport *PostureReport) ResourceStatus(resourceID string, f *helpersv1.Filters) apis.IStatus

ResourceStatus get single resource status. If resource not found will return an empty string

func (*PostureReport) ToBytes

func (pr *PostureReport) ToBytes() ([]byte, error)

func (*PostureReport) ToString

func (pr *PostureReport) ToString() string

func (*PostureReport) UnmarshalJSONObject

func (r *PostureReport) UnmarshalJSONObject(dec *gojay.Decoder, key string) (err error)
responsible on fast unmarshaling of various COMMON posture report v2 structure for basic validation

UnmarshalJSONObject - File inside a pkg

type RepoContextMetadata

type RepoContextMetadata struct {
	Provider      string                    `json:"provider,omitempty"` // repo provider name. e.g. github, gitlab
	Repo          string                    `json:"repo,omitempty"`
	Owner         string                    `json:"owner,omitempty"`
	Branch        string                    `json:"branch,omitempty"`
	DefaultBranch string                    `json:"defaultBranch,omitempty"`
	RemoteURL     string                    `json:"remoteURL,omitempty"`
	LastCommit    reporthandling.LastCommit `json:"lastCommit,omitempty"`
	LocalRootPath string                    `json:"localRootPath,omitempty"` // repo root path (local)
}

type ScanMetadata

type ScanMetadata struct {
	TargetType       string `json:"targetType,omitempty"`
	KubescapeVersion string `json:"kubescapeVersion,omitempty"`
	FormatVersion    string `json:"formatVersion,omitempty"`
	ControlsInputs   string `json:"controlsInputs,omitempty"`
	// Format that has been requested for the output results.
	//
	// Since Kubescape added support for multiple outputs, might be not a
	// single format, but a comma-separated string of the multiple
	// requested formats.
	//
	// Deprecated: Since Kubescape added support for multiple outputs,
	// `Format` exists only for backward compatibility. Please use the
	// `Formats` field instead.
	Format string `json:"format,omitempty"`
	// Formats that have been requested for the output results.
	Formats             []string       `json:"formats,omitempty"`
	UseExceptions       string         `json:"useExceptions,omitempty"`
	Logger              string         `json:"logger,omitempty"`
	ExcludedNamespaces  []string       `json:"excludedNamespaces,omitempty"`
	IncludeNamespaces   []string       `json:"includeNamespaces,omitempty"`
	TargetNames         []string       `json:"targetNames,omitempty"`
	FailThreshold       float32        `json:"failThreshold,omitempty"`
	ComplianceThreshold float32        `json:"complianceThreshold,omitempty"`
	ScanningTarget      ScanningTarget `json:"scanningTarget,omitempty"`
	HostScanner         bool           `json:"hostScanner,omitempty"`
	Submit              bool           `json:"submit,omitempty"`
	VerboseMode         bool           `json:"verboseMode,omitempty"`
}

func (*ScanMetadata) NKeys

func (file *ScanMetadata) NKeys() int

func (*ScanMetadata) UnmarshalJSONObject

func (m *ScanMetadata) UnmarshalJSONObject(dec *gojay.Decoder, key string) (err error)

UnmarshalJSONObject unmarshals incoming JSON data into a ScanMetadata object

type ScanningTarget

type ScanningTarget uint16
const (
	Cluster   ScanningTarget = 0
	File      ScanningTarget = 1
	Repo      ScanningTarget = 2
	GitLocal  ScanningTarget = 3
	Directory ScanningTarget = 4
)

func (*ScanningTarget) String

func (st *ScanningTarget) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL