utils

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: Apache-2.0 Imports: 5 Imported by: 16

Documentation

Index

Constants

View Source
const (
	Critical    Severity = "Critical"
	High                 = "High"
	Medium               = "Medium"
	Low                  = "Low"
	Normal               = "Normal"
	Pending              = "Pending"
	Information          = "Information"
	Unknown              = "Unknown"
)
View Source
const (
	// WatchBuildAll is the option where all builds are watched
	WatchBuildAll WatchBuildType = "all"
	// WatchBuildByName is the option where builds are selected by name to be watched
	WatchBuildByName WatchBuildType = "byname"

	// WatchRepositoryLocal is a local repository
	WatchRepositoryLocal WatchRepositoryType = "local"
	// WatchRepositoryRemote is a remote repository
	WatchRepositoryRemote WatchRepositoryType = "remote"

	// WatchRepositoriesAll is the option where all repositories are watched
	WatchRepositoriesAll WatchRepositoriesType = "all"
	// WatchRepositoriesByName is the option where repositories are selected by name to be watched
	WatchRepositoriesByName WatchRepositoriesType = "byname"
)

Variables

This section is empty.

Functions

func UnpackWatchBody

func UnpackWatchBody(watch *WatchParams, body *WatchBody)

UnpackWatchBody unpacks a payload response from Xray. It transforms the data into the params object so that a consumer can interact with a watch in a consistent way.

Types

type AssignedPolicy

type AssignedPolicy struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

AssignedPolicy struct is used to define a policy associated with a watch

type PolicyAction added in v0.20.1

type PolicyAction struct {
	Webhooks                       []string            `json:"webhooks,omitempty"`
	BlockDownload                  PolicyBlockDownload `json:"block_download,omitempty"`
	BlockReleaseBundleDistribution bool                `json:"block_release_bundle_distribution,omitempty"`
	FailBuild                      bool                `json:"fail_build,omitempty"`
	NotifyDeployer                 bool                `json:"notify_deployer,omitempty"`
	NotifyWatchRecipients          bool                `json:"notify_watch_recipients,omitempty"`
	CustomSeverity                 Severity            `json:"custom_severity,omitempty"`
}

type PolicyBlockDownload added in v0.20.1

type PolicyBlockDownload struct {
	Active    bool `json:"active,omitempty"`
	Unscanned bool `json:"unscanned,omitempty"`
}

type PolicyBody added in v0.20.1

type PolicyBody struct {
	Name        string       `json:"name,omitempty"`
	Type        PolicyType   `json:"type,omitempty"`
	Description string       `json:"description,omitempty"`
	Author      string       `json:"author,omitempty"`
	Rules       []PolicyRule `json:"rules,omitempty"`
	Created     time.Time    `json:"created,omitempty"`
	Modified    time.Time    `json:"modified,omitempty"`
}

PolicyBody is the top level payload to be sent to Xray

func CreatePolicyBody added in v0.20.1

func CreatePolicyBody(policyParams PolicyParams) PolicyBody

type PolicyCriteria added in v0.20.1

type PolicyCriteria struct {
	// Security
	MinSeverity Severity         `json:"min_severity,omitempty"`
	CvssRange   *PolicyCvssRange `json:"cvss_range,omitempty"`

	// License
	AllowedLicenses        []string `json:"allowed_licenses,omitempty"`
	BannedLicenses         []string `json:"banned_licenses,omitempty"`
	AllowUnknown           bool     `json:"allow_unknown,omitempty"`
	MultiLicensePermissive bool     `json:"multi_license_permissive,omitempty"`
}

func CreateCvssRangePolicyCriteria added in v0.20.1

func CreateCvssRangePolicyCriteria(from float64, to float64) *PolicyCriteria

Create security policy criteria with range. from - CVSS range from 0.0 to 10.0 to - CVSS range from 0.0 to 10.0

func CreateLicensePolicyCriteria added in v0.20.1

func CreateLicensePolicyCriteria(allowedLicenses, allowUnknown, multiLicensePermissive bool, licenses ...string) *PolicyCriteria

Create license policy criteria allowedLicenses - true if the provided licenses are allowed, false if banned allowUnknown - true if should allow unknown licenses, otherwise a violation will be generated for artifacts with unknown licenses multiLicensePermissive - do not generate a violation if at least one license is valid in cases whereby multiple licenses were detected on the component licenses - the target licenses

func CreateSeverityPolicyCriteria added in v0.20.1

func CreateSeverityPolicyCriteria(minSeverity Severity) *PolicyCriteria

Create security policy criteria with min severity

type PolicyCvssRange added in v0.20.1

type PolicyCvssRange struct {
	From float64 `json:"from,omitempty"`
	To   float64 `json:"to,omitempty"`
}

type PolicyParams added in v0.20.1

type PolicyParams struct {
	Name        string
	Type        PolicyType
	Description string
	Rules       []PolicyRule
}

func NewPolicyParams added in v0.20.1

func NewPolicyParams() PolicyParams

type PolicyRule added in v0.20.1

type PolicyRule struct {
	Name     string         `json:"name,omitempty"`
	Criteria PolicyCriteria `json:"criteria,omitempty"`
	Actions  *PolicyAction  `json:"actions,omitempty"`
	Priority int            `json:"priority,omitempty"`
}

type PolicyType added in v0.20.1

type PolicyType string
const (
	Security PolicyType = "security"
	License             = "license"
)

type Severity added in v0.20.1

type Severity string

type WatchBody

type WatchBody struct {
	GeneralData      watchGeneralParams    `json:"general_data"`
	ProjectResources watchProjectResources `json:"project_resources,omitempty"`
	AssignedPolicies []AssignedPolicy      `json:"assigned_policies,omitempty"`
}

WatchBody is the top level payload to be sent to Xray

func CreateBody

func CreateBody(params WatchParams) (*WatchBody, error)

CreateBody creates a payload to configure a Watch in Xray This can configure repositories and builds However, bundles are not supported.

type WatchBuildType

type WatchBuildType string

WatchBuildType defines the type of filter for a builds on a watch

type WatchBuildsAllParams

type WatchBuildsAllParams struct {
	BinMgrID string
	WatchPathFilters
}

WatchBuildsAllParams is used to define the parameters when a watch uses all builds

type WatchBuildsByNameParams

type WatchBuildsByNameParams struct {
	Name     string
	BinMgrID string
}

WatchBuildsByNameParams is used to define a specific build in a watch

type WatchBuildsParams

type WatchBuildsParams struct {
	Type    WatchBuildType
	All     WatchBuildsAllParams
	ByNames map[string]WatchBuildsByNameParams
}

WatchBuildsParams is a struct that stores the build configuration for watch

type WatchParams

type WatchParams struct {
	Name        string
	Description string
	Active      bool

	Repositories WatchRepositoriesParams

	Builds   WatchBuildsParams
	Policies []AssignedPolicy
}

WatchParams defines all the properties to create an Xray watch

func NewWatchParams

func NewWatchParams() WatchParams

NewWatchParams creates a new struct to configure an Xray watch

type WatchPathFilters

type WatchPathFilters struct {
	ExcludePatterns []string `json:"ExcludePatterns"`
	IncludePatterns []string `json:"IncludePatterns"`
}

WatchPathFilters is used to define path filters on a repository or a build in a watch

type WatchRepositoriesParams

type WatchRepositoriesParams struct {
	Type         WatchRepositoriesType
	All          WatchRepositoryAll
	Repositories map[string]WatchRepository
	WatchPathFilters
}

WatchRepositoriesParams is a struct that stores the repository configuration for watch

type WatchRepositoriesType

type WatchRepositoriesType string

WatchRepositoriesType defines the type of filter for a repositories on a watch

type WatchRepository

type WatchRepository struct {
	Name     string
	BinMgrID string
	RepoType WatchRepositoryType
	Filters  watchFilters
}

WatchRepository is used to define a specific repository in a watch

func NewWatchRepository

func NewWatchRepository(name string, binMgrID string, repoType WatchRepositoryType) WatchRepository

NewWatchRepository creates a new repository struct to configure an Xray Watch

type WatchRepositoryAll

type WatchRepositoryAll struct {
	Filters watchFilters
}

WatchRepositoryAll is used to define the parameters when a watch uses all repositories

type WatchRepositoryType added in v0.17.0

type WatchRepositoryType string

WatchRepositoryType defines the type of Repository for a watch

Jump to

Keyboard shortcuts

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