utils

package
v1.41.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

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 BinaryGraphNode

type BinaryGraphNode struct {
	// Component Id in the JFrog standard.
	// For instance, for maven: gav://<groupId>:<artifactId>:<version>
	// For detailed format examples please see:
	// https://www.jfrog.com/confluence/display/JFROG/Xray+REST+API#XrayRESTAPI-ComponentIdentifiers
	Id string `json:"component_id,omitempty"`
	// Sha of the binary representing the component.
	Sha256 string `json:"sha256,omitempty"`
	Sha1   string `json:"sha1,omitempty"`
	// For root file shall be the file name.
	// For internal components shall be the internal path. (Relevant only for binary scan).
	Path string `json:"path,omitempty"`
	// List of license names
	Licenses []string `json:"licenses,omitempty"`
	// Component properties
	Properties map[string]string `json:"properties,omitempty"`
	// List of subcomponents.
	Nodes []*BinaryGraphNode `json:"nodes,omitempty"`
	// Other component IDs field is populated by the Xray indexer to get a better accuracy in '.deb' files.
	OtherComponentIds []OtherComponentIds `json:"other_component_ids,omitempty"`
}

Binary Scan Graph Node

type GraphNode

type GraphNode struct {
	// Node parent (for internal use)
	Parent *GraphNode `json:"-"`
	// The "classifier" attribute in a Maven pom.xml specifies an additional qualifier for a dependency
	Classifier *string `json:"-"`
	// Node file types (tar, jar, zip, pom)
	Types *[]string `json:"-"`
	Id    string    `json:"component_id,omitempty"`
	// List of subcomponents.
	Nodes []*GraphNode `json:"nodes,omitempty"`
}

Audit Graph Node

func (*GraphNode) NodeHasLoop

func (currNode *GraphNode) NodeHasLoop() bool

type OtherComponentIds

type OtherComponentIds struct {
	Id     string `json:"component_id,omitempty"`
	Origin int    `json:"origin,omitempty"`
}

type PolicyAction

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

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

type PolicyBody

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

func CreatePolicyBody(policyParams PolicyParams) PolicyBody

type PolicyCriteria

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

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

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

func CreateSeverityPolicyCriteria(minSeverity Severity) *PolicyCriteria

Create security policy criteria with min severity

type PolicyCvssRange

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

type PolicyParams

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

func NewPolicyParams

func NewPolicyParams() PolicyParams

type PolicyRule

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

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

type Severity

type Severity string
const (
	Critical    Severity = "Critical"
	High        Severity = "High"
	Medium      Severity = "Medium"
	Low         Severity = "Low"
	Normal      Severity = "Normal"
	Pending     Severity = "Pending"
	Information Severity = "Information"
	Unknown     Severity = "Unknown"
)

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

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