nexusiq

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package nexusiq provides a number of functions that interact with the Nexus IQ REST API. All functions require a new RM instance which can be instantiated as such:

iq, err := nexusiq.New("http://localhost:8070", "username", "password")
if err != nil {
    panic(err)
}

Index

Examples

Constants

View Source
const (

	// RemediationTypeNoViolations is a type of remediation version change where the version does not violate any policies
	RemediationTypeNoViolations = "next-no-violations"
	// RemediationTypeNonFailing is a type of remediation version change where the version does not fail any policies, even if it violates them
	RemediationTypeNonFailing = "next-non-failing"
)
View Source
const (
	StageProxy                = "proxy"
	StageDevelop              = "develop"
	StageBuild                = "build"
	StageStageRelease         = "stage-release"
	StageRelease              = "release"
	StageOperate              = "operate"
	StageContinuousMonitoring = "continuous-monitoring"
)

Provides a constants for the IQ stages

View Source
const (
	MemberTypeUser  = "USER"
	MemberTypeGroup = "GROUP"
)

Constants to describe a Member Type

View Source
const (

	// RootOrganization is the ID of the ... Root ... Organization
	RootOrganization = "ROOT_ORGANIZATION_ID"
)

Variables

This section is empty.

Functions

func ComponentLabelApply

func ComponentLabelApply(iq IQ, comp Component, appID, label string) error

ComponentLabelApply adds an existing label to a component for a given application

func ComponentLabelUnapply

func ComponentLabelUnapply(iq IQ, comp Component, appID, label string) error

ComponentLabelUnapply removes an existing association between a label and a component

func ComponentVersions

func ComponentVersions(iq IQ, comp Component) (versions []string, err error)

ComponentVersions returns all known versions of a given component

func CreateApplication

func CreateApplication(iq IQ, name, id, organizationID string) (string, error)

CreateApplication creates an application in IQ with the given name and identifier

Example
iq, err := New("http://localhost:8070", "user", "password")
if err != nil {
	panic(err)
}

appID, err := CreateApplication(iq, "name", "id", "organization")
if err != nil {
	panic(err)
}
fmt.Printf("Application ID: %s\n", appID)
Output:

func CreateOrganization

func CreateOrganization(iq IQ, name string) (string, error)

CreateOrganization creates an organization in IQ with the given name

Example
iq, err := New("http://localhost:8070", "user", "password")
if err != nil {
	panic(err)
}

orgID, err := CreateOrganization(iq, "DatabaseTeam")
if err != nil {
	panic(err)
}
fmt.Printf("Organization ID: %s\n", orgID)
Output:

func CreateSourceControlEntry

func CreateSourceControlEntry(iq IQ, applicationID, repositoryURL, token string) error

CreateSourceControlEntry creates a source control entry in IQ

func CreateWaiverByViolationId

func CreateWaiverByViolationId(iq IQ, properties PolicyWaiverProperties, ownerType, ownerId string) (err error)

func DeleteApplication

func DeleteApplication(iq IQ, applicationID string) error

DeleteApplication deletes an application in IQ with the given id

func DeleteComponentLabelForApplication

func DeleteComponentLabelForApplication(iq IQ, appID, label string) error

DeleteComponentLabelForApplication deletes a label from an application

func DeleteComponentLabelForOrganization

func DeleteComponentLabelForOrganization(iq IQ, organization, label string) error

DeleteComponentLabelForOrganization deletes a label from an organization

func DeleteSourceControlEntry

func DeleteSourceControlEntry(iq IQ, applicationID, sourceControlID string) error

DeleteSourceControlEntry deletes a source control entry in IQ

func DeleteSourceControlEntryByApp

func DeleteSourceControlEntryByApp(iq IQ, applicationID string) error

DeleteSourceControlEntryByApp deletes a source control entry in IQ for the given application

func DeleteUser

func DeleteUser(iq IQ, username string) error

DeleteUser removes the named user

func GetSystemAdminID

func GetSystemAdminID(iq IQ) (string, error)

GetSystemAdminID returns the identifier of the System Administrator role

func RevokeApplicationGroup

func RevokeApplicationGroup(iq IQ, name, roleName, group string) error

RevokeApplicationGroup removes a group and role from the named application

func RevokeApplicationUser

func RevokeApplicationUser(iq IQ, name, roleName, user string) error

RevokeApplicationUser removes a user and role from the named application

func RevokeGlobalGroup

func RevokeGlobalGroup(iq IQ, roleName, group string) error

RevokeGlobalGroup revoke the role and group that can have access to the global

func RevokeGlobalUser

func RevokeGlobalUser(iq IQ, roleName, user string) error

RevokeGlobalUser revoke the role and user that can have access to the global

func RevokeOrganizationGroup

func RevokeOrganizationGroup(iq IQ, name, roleName, group string) error

RevokeOrganizationGroup removes a group and role from the named organization

func RevokeOrganizationUser

func RevokeOrganizationUser(iq IQ, name, roleName, user string) error

RevokeOrganizationUser removes a user and role from the named organization

func RevokeRepositoriesGroup

func RevokeRepositoriesGroup(iq IQ, roleName, group string) error

RevokeRepositoriesGroup revoke the role and group that can have access to the repositories

func RevokeRepositoriesUser

func RevokeRepositoriesUser(iq IQ, roleName, user string) error

RevokeRepositoriesUser revoke the role and user that can have access to the repositories

func SetApplicationGroup

func SetApplicationGroup(iq IQ, name, roleName, group string) error

SetApplicationGroup sets the role and group that can have access to an application

func SetApplicationUser

func SetApplicationUser(iq IQ, name, roleName, user string) error

SetApplicationUser sets the role and user that can have access to an application

func SetGlobalGroup

func SetGlobalGroup(iq IQ, roleName, group string) error

SetGlobalGroup sets the role and group that can have access to the global

func SetGlobalUser

func SetGlobalUser(iq IQ, roleName, user string) error

SetGlobalUser sets the role and user that can have access to the repositories

func SetOrganizationGroup

func SetOrganizationGroup(iq IQ, name, roleName, group string) error

SetOrganizationGroup sets the role and group that can have access to an organization

func SetOrganizationUser

func SetOrganizationUser(iq IQ, name, roleName, user string) error

SetOrganizationUser sets the role and user that can have access to an organization

func SetRepositoriesGroup

func SetRepositoriesGroup(iq IQ, roleName, group string) error

SetRepositoriesGroup sets the role and group that can have access to the repositories

func SetRepositoriesUser

func SetRepositoriesUser(iq IQ, roleName, user string) error

SetRepositoriesUser sets the role and user that can have access to the repositories

func SetRetentionPolicies

func SetRetentionPolicies(iq IQ, orgName string, policies DataRetentionPolicies) error

SetRetentionPolicies updates the retention policies

func SetUser

func SetUser(iq IQ, user User) (err error)

SetUser creates a new user

func UpdateSourceControlEntry

func UpdateSourceControlEntry(iq IQ, applicationID, repositoryURL, token string) error

UpdateSourceControlEntry updates a source control entry in IQ

Types

type Application

type Application struct {
	ID              string `json:"id"`
	PublicID        string `json:"publicId,omitempty"`
	Name            string `json:"name"`
	OrganizationID  string `json:"organizationId"`
	ContactUserName string `json:"contactUserName,omitempty"`
	ApplicationTags []struct {
		ID            string `json:"id,omitempty"`
		TagID         string `json:"tagId,omitempty"`
		ApplicationID string `json:"applicationId,omitempty"`
	} `json:"applicationTags,omitempty"`
}

Application captures information of an IQ application

func GetAllApplications

func GetAllApplications(iq IQ) ([]Application, error)

GetAllApplications returns a slice of all of the applications in an IQ instance

Example
iq, err := New("http://localhost:8070", "username", "password")
if err != nil {
	panic(err)
}

applications, err := GetAllApplications(iq)
if err != nil {
	panic(err)
}

fmt.Printf("%v\n", applications)
Output:

func GetApplicationByPublicID

func GetApplicationByPublicID(iq IQ, applicationPublicID string) (*Application, error)

GetApplicationByPublicID returns details on the named IQ application

func GetApplicationsByOrganization

func GetApplicationsByOrganization(iq IQ, organizationName string) ([]Application, error)

GetApplicationsByOrganization returns all applications under a given organization

type ApplicationReports

type ApplicationReports struct {
	Stages map[Stage]DataRetentionPolicy `json:"stages"`
}

ApplicationReports captures the policies related to application reports

type ApplicationViolation

type ApplicationViolation struct {
	Application      Application       `json:"application"`
	PolicyViolations []PolicyViolation `json:"policyViolations"`
}

ApplicationViolation encapsulates the information about which violations an application has

func GetAllPolicyViolations

func GetAllPolicyViolations(iq IQ) ([]ApplicationViolation, error)

GetAllPolicyViolations returns all policy violations

func GetPolicyViolationsByName

func GetPolicyViolationsByName(iq IQ, policyNames ...string) ([]ApplicationViolation, error)

GetPolicyViolationsByName returns the policy violations by policy name

type Component

type Component struct {
	Hash        string               `json:"hash,omitempty"`
	ComponentID *ComponentIdentifier `json:"componentIdentifier,omitempty"`
	Proprietary bool                 `json:"proprietary,omitempty"`
	PackageURL  string               `json:"packageUrl,omitempty"`
	MatchState  string               `json:"matchState,omitempty"`
	Pathnames   []string             `json:"pathnames,omitempty"`
}

Component encapsulates the details of a component in IQ

func NewComponentFromPURL

func NewComponentFromPURL(purl string) (*Component, error)

NewComponentFromPURL creates a new Component object from the given PURL string

func NewComponentFromString

func NewComponentFromString(str string) (*Component, error)

NewComponentFromString creates a new Component object by parsing a string in the expected format; format:group:name:version:ext

type ComponentDetail

type ComponentDetail struct {
	Component          Component   `json:"component"`
	MatchState         string      `json:"matchState"`
	CatalogDate        string      `json:"catalogDate"`
	RelativePopularity int64       `json:"relativePopularity,omitempty"`
	LicenseData        LicenseData `json:"licenseData"`
	SecurityData       struct {
		SecurityIssues []SecurityIssue `json:"securityIssues"`
	} `json:"securityData"`
}

ComponentDetail lists information about a given component

func GetAllComponents

func GetAllComponents(iq IQ) ([]ComponentDetail, error)

GetAllComponents returns an array with all components along with their

func GetComponent

func GetComponent(iq IQ, component Component) (ComponentDetail, error)

GetComponent returns information on a named component

func GetComponents

func GetComponents(iq IQ, components []Component) ([]ComponentDetail, error)

GetComponents returns information on the named components

func GetComponentsByApplication

func GetComponentsByApplication(iq IQ, appPublicID string) ([]ComponentDetail, error)

GetComponentsByApplication returns an array with all components along with their

type ComponentEvaluationResult

type ComponentEvaluationResult struct {
	Component    Component   `json:"component"`
	MatchState   string      `json:"matchState"`
	CatalogDate  string      `json:"catalogDate"`
	LicensesData LicenseData `json:"licenseData"`
	SecurityData struct {
		SecurityIssues []SecurityIssue `json:"securityIssues"`
	} `json:"securityData"`
	PolicyData struct {
		PolicyViolations []PolicyViolation `json:"policyViolations"`
	} `json:"policyData,omitempty"`
}

ComponentEvaluationResult holds the results of a component evaluation

func (*ComponentEvaluationResult) HighestThreatPolicy

func (c *ComponentEvaluationResult) HighestThreatPolicy() *PolicyViolation

HighestThreatPolicy returns the policy with the highest threat value

type ComponentIdentifier

type ComponentIdentifier struct {
	Format      string      `json:"format,omitempty"`
	Coordinates Coordinates `json:"coordinates,omitempty"`
}

ComponentIdentifier identifies the format and coordinates of a component

func (ComponentIdentifier) String

func (c ComponentIdentifier) String() string

String returns a string representation of the ComponentIdentifier object

type ComponentMatcher

type ComponentMatcher string

ComponentMatcher type defines the component scope of the waiver

const (
	MatchExactComponent ComponentMatcher = "EXACT_COMPONENT"
	MatchAllComponents  ComponentMatcher = "ALL_COMPONENTS"
	MatchAllVersions    ComponentMatcher = "ALL_VERSIONS"
)

Provides guide rails for the matcher strategies

type Coordinates

type Coordinates struct {
	ArtifactID string `json:"artifactId,omitempty"`
	GroupID    string `json:"groupId,omitempty"`
	Version    string `json:"version,omitempty"`
	Extension  string `json:"extension,omitempty"`
	Classifier string `json:"classifier,omitempty"`
}

Coordinates lists the unique values identifing a component

func (Coordinates) String

func (c Coordinates) String() string

String returns a string representation of the Coordinates object

type DataRetentionPolicies

type DataRetentionPolicies struct {
	ApplicationReports ApplicationReports  `json:"applicationReports"`
	SuccessMetrics     DataRetentionPolicy `json:"successMetrics"`
}

DataRetentionPolicies encapsulates an organization's retention policies

func GetRetentionPolicies

func GetRetentionPolicies(iq IQ, orgName string) (policies DataRetentionPolicies, err error)

GetRetentionPolicies returns the current retention policies

type DataRetentionPolicy

type DataRetentionPolicy struct {
	InheritPolicy bool   `json:"inheritPolicy"`
	EnablePurging bool   `json:"enablePurging"`
	MaxAge        string `json:"maxAge"`
}

DataRetentionPolicy describes the retention policies for a pipeline stage

type Evaluation

type Evaluation struct {
	SubmittedDate  string                      `json:"submittedDate"`
	EvaluationDate string                      `json:"evaluationDate"`
	ApplicationID  string                      `json:"applicationId"`
	Results        []ComponentEvaluationResult `json:"results"`
	IsError        bool                        `json:"isError"`
	ErrorMessage   interface{}                 `json:"errorMessage"`
}

Evaluation response thingy

func EvaluateComponents

func EvaluateComponents(iq IQ, components []Component, applicationID string) (*Evaluation, error)

EvaluateComponents evaluates the list of components

type IQ

type IQ interface {
	nexus.Client
}

IQ is the interface which allows interacting with an IQ server

func New

func New(host, username, password string) (IQ, error)

New creates a new IQ instance

type IQCategory

type IQCategory struct {
	ID    string `json:"id"`
	Name  string `json:"name"`
	Color string `json:"color"`
}

IQCategory encapsulates the category that can be created in IQ

type IqCliResults

type IqCliResults struct {
	ApplicationID          string                 `json:"applicationId"`
	ScanID                 string                 `json:"scanId"`
	ReportHTMLURL          string                 `json:"reportHtmlUrl"`
	ReportPDFURL           string                 `json:"reportPdfUrl"`
	ReportDataURL          string                 `json:"reportDataUrl"`
	PolicyAction           string                 `json:"policyAction"`
	PolicyEvaluationResult policyEvaluationResult `json:"policyEvaluationResult"`
}

IqCliResults encapsulates the JSON object generated by an evaluation with the Nexus IQ CLI

func ReadIqCliResultFile

func ReadIqCliResultFile(filename string) (IqCliResults, error)

ReadIqCliResultFile marshals into a struct the results file from a Nexus IQ CLI evaluation

type IqComponentLabel

type IqComponentLabel struct {
	ID             string `json:"id,omitempty"`
	OwnerID        string `json:"ownerId,omitempty"`
	Label          string `json:"label"`
	LabelLowercase string `json:"labelLowercase,omitempty"`
	Description    string `json:"description,omitempty"`
	Color          string `json:"color"`
}

IqComponentLabel describes a component label

func CreateComponentLabelForApplication

func CreateComponentLabelForApplication(iq IQ, appID, label, description, color string) (IqComponentLabel, error)

CreateComponentLabelForApplication creates a label for an application

func CreateComponentLabelForOrganization

func CreateComponentLabelForOrganization(iq IQ, organization, label, description, color string) (IqComponentLabel, error)

CreateComponentLabelForOrganization creates a label for an organization

func GetComponentLabelsByAppID

func GetComponentLabelsByAppID(iq IQ, appID string) ([]IqComponentLabel, error)

GetComponentLabelsByAppID retrieves an array of an organization's component label

func GetComponentLabelsByOrganization

func GetComponentLabelsByOrganization(iq IQ, organization string) ([]IqComponentLabel, error)

GetComponentLabelsByOrganization retrieves an array of an organization's component label

type License

type License struct {
	LicenseID   string `json:"licenseId"`
	LicenseName string `json:"licenseName"`
}

License identifier an OSS license recognized by Sonatype

type LicenseData

type LicenseData struct {
	Status                  string    `json:"status,omitempty"`
	DeclaredLicenses        []License `json:"declaredLicenses,omitempty"`
	ObservedLicenses        []License `json:"observedLicenses,omitempty"`
	OverriddenLicenses      []License `json:"overriddenLicenses,omitempty"`
	EffectiveLicenseThreats []struct {
		LicenseThreatGroupCategory string `json:"licenseThreatGroupCategory,omitempty"`
		LicenseThreatGroupLevel    int64  `json:"licenseThreatGroupLevel,omitempty"`
		LicenseThreatGroupName     string `json:"licenseThreatGroupName,omitempty"`
	} `json:"effectiveLicenseThreats,omitempty"`
}

LicenseData encapsulates the information on the different licenses of a component

type Member

type Member struct {
	OwnerID         string `json:"ownerId,omitempty"`
	OwnerType       string `json:"ownerType,omitempty"`
	Type            string `json:"type"`
	UserOrGroupName string `json:"userOrGroupName"`
}

Member describes a member to map with a role

type MemberMapping

type MemberMapping struct {
	RoleID  string   `json:"roleId"`
	Members []Member `json:"members"`
}

MemberMapping describes a list of Members against a Role

func ApplicationAuthorizations

func ApplicationAuthorizations(iq IQ, name string) ([]MemberMapping, error)

ApplicationAuthorizations returns the member mappings of an application

func ApplicationAuthorizationsByRole

func ApplicationAuthorizationsByRole(iq IQ, roleName string) ([]MemberMapping, error)

ApplicationAuthorizationsByRole returns the member mappings of all applications which match the given role

func GlobalAuthorizations

func GlobalAuthorizations(iq IQ) ([]MemberMapping, error)

GlobalAuthorizations returns all of the users and roles who have the administrator role across all of IQ

func MembersByRole

func MembersByRole(iq IQ, roleName string) ([]MemberMapping, error)

MembersByRole returns all users and groups by role name

func OrganizationAuthorizations

func OrganizationAuthorizations(iq IQ, name string) ([]MemberMapping, error)

OrganizationAuthorizations returns the member mappings of an organization

func OrganizationAuthorizationsByRole

func OrganizationAuthorizationsByRole(iq IQ, roleName string) ([]MemberMapping, error)

OrganizationAuthorizationsByRole returns the member mappings of all organizations which match the given role

func RepositoriesAuthorizations

func RepositoriesAuthorizations(iq IQ) ([]MemberMapping, error)

RepositoriesAuthorizations returns the member mappings of all repositories

func RepositoriesAuthorizationsByRole

func RepositoriesAuthorizationsByRole(iq IQ, roleName string) ([]MemberMapping, error)

RepositoriesAuthorizationsByRole returns the member mappings of all repositories which match the given role

type Metrics

type Metrics struct {
	ApplicationID       string        `json:"applicationId,omitempty"`
	ApplicationPublicID string        `json:"applicationPublicId,omitempty"`
	ApplicationName     string        `json:"applicationName,omitempty"`
	OrganizationID      string        `json:"organizationId,omitempty"`
	OrganizationName    string        `json:"organizationName,omitempty"`
	Aggregations        []aggregation `json:"aggregations,omitempty"`
}

Metrics encapsulates the data generate

func GenerateMetrics

func GenerateMetrics(iq IQ, builder *MetricsRequestBuilder) ([]Metrics, error)

GenerateMetrics creates metrics from the given qualifiers

Example
iq, err := New("http://localhost:8070", "admin", "admin123")
if err != nil {
	panic(err)
}

reqLastYear := NewMetricsRequestBuilder().Monthly().StartingOn(time.Now().Add(-(24 * time.Hour) * 365)).WithApplication("WebGoat")

metrics, err := GenerateMetrics(iq, reqLastYear)
if err != nil {
	panic(err)
}

buf, err := json.MarshalIndent(metrics, "", "  ")
if err != nil {
	panic(err)
}

fmt.Println(string(buf))
Output:

type MetricsRequestBuilder

type MetricsRequestBuilder struct {
	// contains filtered or unexported fields
}

MetricsRequestBuilder builds a request to retrieve metrics data from IQ

func NewMetricsRequestBuilder

func NewMetricsRequestBuilder() *MetricsRequestBuilder

NewMetricsRequestBuilder returns a new builder instance

func (*MetricsRequestBuilder) EndingOn

EndingOn allows you to set the ending time period for the data gathering. Optional

func (*MetricsRequestBuilder) Monthly

Monthly sets the request to use a monthly time period

func (*MetricsRequestBuilder) StartingOn

StartingOn allows you to set the starting time period for the data gathering

func (*MetricsRequestBuilder) Weekly

Weekly sets the request to use a weekly time period

func (*MetricsRequestBuilder) WithApplication

func (b *MetricsRequestBuilder) WithApplication(v string) *MetricsRequestBuilder

WithApplication adds an application (by Public ID) whose data to include

func (*MetricsRequestBuilder) WithOrganization

func (b *MetricsRequestBuilder) WithOrganization(v string) *MetricsRequestBuilder

WithOrganization adds an organization whose data to include in†he report

type Organization

type Organization struct {
	ID   string       `json:"id"`
	Name string       `json:"name"`
	Tags []IQCategory `json:"tags,omitempty"`
}

Organization describes the data in IQ about a given organization

func GetAllOrganizations

func GetAllOrganizations(iq IQ) ([]Organization, error)

GetAllOrganizations returns a slice of all of the organizations in an IQ instance

func GetOrganizationByName

func GetOrganizationByName(iq IQ, organizationName string) (*Organization, error)

GetOrganizationByName returns details on the named IQ organization

type OwnerType

type OwnerType string

OwnerType type defines the organizational scope of the waiver

const (
	OwnerApplication         OwnerType = "application"
	OwnerOrganization        OwnerType = "organization"
	OwnerRepository          OwnerType = "repository"
	OwnerRepositoryContainer OwnerType = "repository_container"
)

Provides guide rails for the owner types

type PolicyInfo

type PolicyInfo struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	OwnerID     string `json:"ownerId"`
	OwnerType   string `json:"ownerType"`
	ThreatLevel int    `json:"threatLevel"`
	PolicyType  string `json:"policyType"`
}

PolicyInfo encapsulates the identifying information of an individual IQ policy

func GetPolicies

func GetPolicies(iq IQ) ([]PolicyInfo, error)

GetPolicies returns a list of all of the policies in IQ

func GetPolicyInfoByName

func GetPolicyInfoByName(iq IQ, policyName string) (PolicyInfo, error)

GetPolicyInfoByName returns an information object for the named policy

type PolicyReportComponent

type PolicyReportComponent struct {
	Component
	Violations []PolicyReportViolation `json:"violations"`
}

PolicyReportComponent encapsulates a component which violates a policy

type PolicyReportViolation

type PolicyReportViolation struct {
	Constraints []struct {
		Conditions []struct {
			ConditionReason  string `json:"conditionReason"`
			ConditionSummary string `json:"conditionSummary"`
		} `json:"conditions"`
		ConstraintID   string `json:"constraintId"`
		ConstraintName string `json:"constraintName"`
	} `json:"constraints"`
	Grandfathered        bool   `json:"grandfathered"`
	PolicyID             string `json:"policyId"`
	PolicyViolationId    string `json:"policyViolationId"`
	PolicyName           string `json:"policyName"`
	PolicyThreatCategory string `json:"policyThreatCategory"`
	PolicyThreatLevel    int64  `json:"policyThreatLevel"`
	Waived               bool   `json:"waived"`
}

type PolicyViolation

type PolicyViolation struct {
	PolicyID             string `json:"policyId"`
	PolicyName           string `json:"policyName"`
	StageID              string `json:"stageId,omitempty"`
	ReportURL            string `json:"reportUrl,omitempty"`
	ThreatLevel          int    `json:"threatLevel"`
	ConstraintViolations []struct {
		ConstraintID   string `json:"constraintId"`
		ConstraintName string `json:"constraintName"`
		Reasons        []struct {
			Reason string `json:"reason"`
		} `json:"reasons"`
		Component Component `json:"component,omitempty"`
	} `json:"constraintViolations"`
}

PolicyViolation is the policies violated by a component

type PolicyWaiverProperties

type PolicyWaiverProperties struct {
	Comment              string    `json:"comment,omitempty"`
	ExpiryTime           time.Time `json:"expiryTime,omitempty"` // time.RFC3339Nano
	MatcherStrategy      string    `json:"matcherStrategy"`
	ApplyToAllComponents bool      `json:"applytoAllComponents"`
}

type Remediation

type Remediation struct {
	Component      Component                  `json:"component,omitempty"`
	VersionChanges []remediationVersionChange `json:"versionChanges"`
}

Remediation encapsulates the remediation information for a component

func GetRemediationByApp

func GetRemediationByApp(iq IQ, component Component, stage, applicationID string) (Remediation, error)

GetRemediationByApp retrieves the remediation information on a component based on an application's policies

func GetRemediationByOrg

func GetRemediationByOrg(iq IQ, component Component, stage, organizationName string) (Remediation, error)

GetRemediationByOrg retrieves the remediation information on a component based on an organization's policies

func GetRemediationsByAppReport

func GetRemediationsByAppReport(iq IQ, applicationID, reportID string) (remediations []Remediation, err error)

GetRemediationsByAppReport retrieves the remediation information on each component of a report

func (Remediation) ComponentForRemediationType

func (r Remediation) ComponentForRemediationType(remType string) (Component, error)

ComponentForRemediationType returns the component which satisfies the given remediation strategy

type Report

type Report struct {
	Policy ReportPolicy `json:"policyReport"`
	Raw    ReportRaw    `json:"rawReport"`
}

Report encapsulates the policy and raw report of an application

func GetAllReports

func GetAllReports(iq IQ) ([]Report, error)

GetAllReports returns all policy and raw reports

func GetReportByAppID

func GetReportByAppID(iq IQ, appID, stage string) (report Report, err error)

GetReportByAppID returns report information by application public ID

func GetReportByAppReportID

func GetReportByAppReportID(iq IQ, appID, reportID string) (report Report, err error)

GetReportByAppReportID returns raw and policy report information for a given report ID

func GetReportsByOrganization

func GetReportsByOrganization(iq IQ, organizationName string) (reports []Report, err error)

GetReportsByOrganization returns all reports for an given organization

type ReportDiff

type ReportDiff struct {
	Reports []Report                `json:"reports"`
	Waived  []PolicyReportComponent `json:"waived,omitempty"`
	Fixed   []PolicyReportComponent `json:"fixed,omitempty"`
}

ReportDiff encapsulates the differences between reports

func ReportsDiff

func ReportsDiff(iq IQ, appID, report1ID, report2ID string) (ReportDiff, error)

ReportsDiff returns a structure describing various differences between two reports

type ReportInfo

type ReportInfo struct {
	ApplicationID           string `json:"applicationId"`
	EmbeddableReportHTMLURL string `json:"embeddableReportHtmlUrl"`
	EvaluationDateStr       string `json:"evaluationDate"`
	ReportDataURL           string `json:"reportDataUrl"`
	ReportHTMLURL           string `json:"reportHtmlUrl"`
	ReportPdfURL            string `json:"reportPdfUrl"`
	Stage                   string `json:"stage"`
	// contains filtered or unexported fields
}

ReportInfo encapsulates the summary information on a given report

func GetAllReportInfos

func GetAllReportInfos(iq IQ) ([]ReportInfo, error)

GetAllReportInfos returns all report infos

func GetReportInfoByAppIDStage

func GetReportInfoByAppIDStage(iq IQ, appID, stage string) (ReportInfo, error)

GetReportInfoByAppIDStage returns report information by application public ID and stage

func GetReportInfosByAppID

func GetReportInfosByAppID(iq IQ, appID string) (infos []ReportInfo, err error)

GetReportInfosByAppID returns report information by application public ID

func GetReportInfosByOrganization

func GetReportInfosByOrganization(iq IQ, organizationName string) (infos []ReportInfo, err error)

GetReportInfosByOrganization returns report information by organization name

func (*ReportInfo) EvaluationDate

func (r *ReportInfo) EvaluationDate() time.Time

EvaluationDate returns a time object of the report's EvaluationDate

func (*ReportInfo) ReportID

func (r *ReportInfo) ReportID() string

ReportID compares two ReportInfo objects

type ReportPolicy

type ReportPolicy struct {
	Application Application             `json:"application"`
	Components  []PolicyReportComponent `json:"components"`
	Counts      policyReportCounts      `json:"counts"`
	ReportTime  int64                   `json:"reportTime"`
	ReportTitle string                  `json:"reportTitle"`
	ReportInfo  ReportInfo              `json:"reportInfo,omitempty"`
}

ReportPolicy descrpibes the policies violated by the components in an application report

func GetPolicyReportByAppID

func GetPolicyReportByAppID(iq IQ, appID, stage string) (ReportPolicy, error)

GetPolicyReportByAppID returns report information by application public ID

type ReportRaw

type ReportRaw struct {
	Components   []rawReportComponent  `json:"components"`
	MatchSummary rawReportMatchSummary `json:"matchSummary"`
	ReportInfo   ReportInfo            `json:"reportInfo,omitempty"`
}

ReportRaw describes the raw data of an application report

func GetRawReportByAppID

func GetRawReportByAppID(iq IQ, appID, stage string) (ReportRaw, error)

GetRawReportByAppID returns report information by application public ID

type Role

type Role struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

Role describes an IQ role

func RoleByName

func RoleByName(iq IQ, name string) (Role, error)

RoleByName returns the named role

func Roles

func Roles(iq IQ) ([]Role, error)

Roles returns a slice of all the roles in the IQ instance

type SearchQueryBuilder

type SearchQueryBuilder struct {
	// contains filtered or unexported fields
}

SearchQueryBuilder allows you to build a search query

func NewSearchQueryBuilder

func NewSearchQueryBuilder() *SearchQueryBuilder

NewSearchQueryBuilder creates a new instance of SearchQueryBuilder

func (*SearchQueryBuilder) Build

func (b *SearchQueryBuilder) Build() string

Build will build the assembled search query

func (*SearchQueryBuilder) ComponentIdentifier

func (b *SearchQueryBuilder) ComponentIdentifier(c ComponentIdentifier) *SearchQueryBuilder

ComponentIdentifier allows specifiying a component identifier to filter by

func (*SearchQueryBuilder) Coordinates

Coordinates allows specifiying component coordinates to filter by

func (*SearchQueryBuilder) Format

Format allows specifiying a format to filter by

func (*SearchQueryBuilder) Hash

Hash allows specifiying a sha1 hash to filter by

func (*SearchQueryBuilder) PackageURL

func (b *SearchQueryBuilder) PackageURL(v string) *SearchQueryBuilder

PackageURL allows specifiying a purl to filter by

func (*SearchQueryBuilder) Stage

Stage allows specifiying a stage to filter by

type SearchResult

type SearchResult struct {
	ApplicationID       string              `json:"applicationId"`
	ApplicationName     string              `json:"applicationName"`
	ReportURL           string              `json:"reportUrl"`
	Hash                string              `json:"hash"`
	PackageURL          string              `json:"packageUrl"`
	ComponentIdentifier ComponentIdentifier `json:"componentIdentifier"`
}

SearchResult describes a component found based on search criteria

func SearchComponents

func SearchComponents(iq IQ, query nexus.SearchQueryBuilder) ([]SearchResult, error)

SearchComponents allows searching the indicated IQ instance for specific components

Example
iq, err := New("http://localhost:8070", "admin", "admin123")
if err != nil {
	panic(err)
}

query := NewSearchQueryBuilder()
query = query.Stage(StageBuild)
query = query.PackageURL("pkg:maven/commons-collections/commons-collections@3.2")

components, err := SearchComponents(iq, query)
if err != nil {
	panic(fmt.Sprintf("Did not complete search: %v", err))
}

fmt.Printf("%q\n", components)
Output:

type SecurityIssue

type SecurityIssue struct {
	Source         string  `json:"source"`
	Reference      string  `json:"reference"`
	Severity       float64 `json:"severity"`
	Status         string  `json:"status,omitempty"`
	URL            string  `json:"url"`
	ThreatCategory string  `json:"threatCategory"`
}

SecurityIssue encapsulates a security issue in the Sonatype database

type SourceControlEntry

type SourceControlEntry struct {
	ID            string `json:"id,omitempty"`
	ApplicationID string `json:"applicationId"`
	RepositoryURL string `json:"repositoryUrl"`
	Token         string `json:"token"`
}

SourceControlEntry describes a Source Control entry in IQ

func GetAllSourceControlEntries

func GetAllSourceControlEntries(iq IQ) ([]SourceControlEntry, error)

GetAllSourceControlEntries lists of all of the Source Control entries in the IQ instance

func GetSourceControlEntry

func GetSourceControlEntry(iq IQ, applicationID string) (SourceControlEntry, error)

GetSourceControlEntry lists of all of the Source Control entries for the given application

type Stage

type Stage string

Stage type describes a pipeline stage

type User

type User struct {
	Username  string `json:"username,omitempty"`
	FirstName string `json:"firstName,omitempty"`
	LastName  string `json:"lastName,omitempty"`
	Email     string `json:"email,omitempty"`
	Password  string `json:"password,omitempty"`
}

User encapsulates the information of a user in IQ

func GetUser

func GetUser(iq IQ, username string) (user User, err error)

GetUser returns user details for the given name

Directories

Path Synopsis
Package iqwebhooks provides structs for all of the Nexus IQ webhook events as well as an http.HandlerFunc which will take the http.Request and put any IQ webhook it finds on a channel.
Package iqwebhooks provides structs for all of the Nexus IQ webhook events as well as an http.HandlerFunc which will take the http.Request and put any IQ webhook it finds on a channel.

Jump to

Keyboard shortcuts

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