utils

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2025 License: Apache-2.0 Imports: 7 Imported by: 6 modules, 27 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"

	WatchGitRepository = "gitRepository"
)

Variables

This section is empty.

Functions

func PollingAction added in v1.42.0

func PollingAction(client *jfroghttpclient.JfrogHttpClient, endPoint string, httpClientDetails httputils.HttpClientDetails) (action func() (shouldStop bool, responseBody []byte, err error))

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 added in v1.32.0

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 ExposureType added in v1.49.0

type ExposureType string
const (
	SecretExposureType ExposureType = "secrets"
	IacExposureType    ExposureType = "iac"
)

type ExposuresCategories added in v1.49.0

type ExposuresCategories struct {
	Secrets      bool `json:"secrets,omitempty"`
	Services     bool `json:"services,omitempty"`
	Applications bool `json:"applications,omitempty"`
	Iac          bool `json:"iac,omitempty"`
}

type ExposuresFilterName added in v1.43.0

type ExposuresFilterName struct {
	Categories []ExposureType `json:"categories,omitempty"`
	Scanners   []string       `json:"scanners,omitempty"`
	FilePath   []string       `json:"file_path,omitempty"`
}

type GraphNode added in v1.28.4

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 added in v1.28.4

func (currNode *GraphNode) NodeHasLoop() bool

type IgnoreFilterNameVersion added in v1.43.0

type IgnoreFilterNameVersion struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

type IgnoreFilterNameVersionPath added in v1.43.0

type IgnoreFilterNameVersionPath struct {
	IgnoreFilterNameVersion
	Path string `json:"path,omitempty"`
}

type IgnoreFilters added in v1.43.0

type IgnoreFilters struct {
	Vulnerabilities  []string                      `json:"vulnerabilities,omitempty"`
	Licenses         []string                      `json:"licenses,omitempty"`
	CVEs             []string                      `json:"cves,omitempty"`
	GitRepositories  []string                      `json:"git_repositories,omitempty"`
	Policies         []string                      `json:"policies,omitempty"`
	Watches          []string                      `json:"watches,omitempty"`
	DockerLayers     []string                      `json:"docker-layers,omitempty"`
	OperationalRisks []string                      `json:"operational_risk,omitempty"`
	Exposures        *ExposuresFilterName          `json:"exposures,omitempty"`
	Sast             *SastFilterName               `json:"sast,omitempty"`
	ReleaseBundles   []IgnoreFilterNameVersion     `json:"release-bundles,omitempty"`
	Builds           []IgnoreFilterNameVersion     `json:"builds,omitempty"`
	Components       []IgnoreFilterNameVersion     `json:"components,omitempty"`
	Artifacts        []IgnoreFilterNameVersionPath `json:"artifacts,omitempty"`
}

type IgnoreRuleBody added in v1.43.0

type IgnoreRuleBody struct {
	Id        string    `json:"id,omitempty"`
	Author    string    `json:"author,omitempty"`
	Created   time.Time `json:"created,omitempty"`
	IsExpired bool      `json:"is_expired,omitempty"`
	IgnoreRuleParams
}

func CreateIgnoreRuleBody added in v1.43.0

func CreateIgnoreRuleBody(ignoreRuleParams IgnoreRuleParams) IgnoreRuleBody

type IgnoreRuleParams added in v1.43.0

type IgnoreRuleParams struct {
	Notes         string        `json:"notes"`
	ExpiresAt     time.Time     `json:"expires_at,omitempty"`
	IgnoreFilters IgnoreFilters `json:"ignore_filters"`
}

func NewIgnoreRuleParams added in v1.43.0

func NewIgnoreRuleParams() IgnoreRuleParams

type OtherComponentIds added in v1.28.4

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

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"`
	Exposures             *PolicyExposureCriteria `json:"exposures,omitempty"`
	Sast                  *PolicySastCriteria     `json:"sast,omitempty"`
	SkipNotApplicableCVEs bool                    `json:"applicable_cves_only,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 CreateExposuresPolicyCriteria added in v1.49.0

func CreateExposuresPolicyCriteria(minSeverity Severity, secrets, applications, services, iac bool) *PolicyCriteria

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 CreateSastPolicyCriteria added in v1.49.0

func CreateSastPolicyCriteria(minSeverity Severity) *PolicyCriteria

func CreateSeverityPolicyCriteria added in v0.20.1

func CreateSeverityPolicyCriteria(minSeverity Severity, skipNotApplicableCves bool) *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 PolicyExposureCriteria added in v1.49.0

type PolicyExposureCriteria struct {
	MinSeverity   Severity `json:"min_severity,omitempty"`
	Secrets       *bool    `json:"secrets,omitempty"`
	Applications  *bool    `json:"applications,omitempty"`
	Services      *bool    `json:"services,omitempty"`
	IaC           *bool    `json:"iac,omitempty"`
	MaliciousCode *bool    `json:"malicious_code,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 PolicySastCriteria added in v1.49.0

type PolicySastCriteria struct {
	MinSeverity Severity `json:"min_severity,omitempty"`
}

type PolicyType added in v0.20.1

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

type ResourcesWatchesBody added in v1.49.0

type ResourcesWatchesBody struct {
	GitRepositoryWatches []string `json:"git_repository_watches,omitempty"`
	ProjectWatches       []string `json:"project_watches,omitempty"`
}

type SastFilterName added in v1.49.0

type SastFilterName struct {
	Fingerprint []string `json:"fingerprint,omitempty"`
	Rule        []string `json:"rule,omitempty"`
	FilePath    []string `json:"file_path,omitempty"`
}

type Severity added in v0.20.1

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 WatchGitRepositoryParams added in v1.49.0

type WatchGitRepositoryParams struct {
	Resources []string
}

type WatchParams

type WatchParams struct {
	Name        string
	Description string
	Active      bool

	Repositories    WatchRepositoriesParams
	GitRepositories WatchGitRepositoryParams
	Builds          WatchBuildsParams

	Policies []AssignedPolicy

	ProjectKey string
}

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