Documentation
¶
Overview ¶
Package notification provides the functionality to process notifications sent by Dependency-Track.
This package contains partially redundant struct definitions, because notification content differs from their respective API representations in a few ways.
Dependency-Track has special serialization logic for notifications, which is defined here: https://github.com/DependencyTrack/dependency-track/blob/4.5.0/src/main/java/org/dependencytrack/util/NotificationUtil.java
Example (Parse) ¶
This example demonstrates how to parse and process notifications.
package main import ( "fmt" "os" "github.com/DependencyTrack/client-go/notification" ) func main() { file, err := os.Open("./testdata/new-vulnerability.json") if err != nil { panic(err) } defer file.Close() n, err := notification.Parse(file) if err != nil { panic(err) } switch subject := n.Subject.(type) { case *notification.NewVulnerabilitySubject: fmt.Printf("new vulnerability identified: %s\n", subject.Vulnerability.VulnID) for _, project := range subject.AffectedProjects { fmt.Printf("=> Project: %s %s\n", project.Name, project.Version) fmt.Printf(" Component: %s %s\n", subject.Component.Name, subject.Component.Version) } } }
Output: new vulnerability identified: CVE-2012-5784 => Project: Acme Example 1.0.0 Component: axis 1.4
Index ¶
Examples ¶
Constants ¶
View Source
const ( GroupBOMConsumed = "BOM_CONSUMED" GroupBOMProcessed = "BOM_PROCESSED" GroupBOMProcessingFailed = "BOM_PROCESSING_FAILED" GroupNewVulnerableDependency = "NEW_VULNERABLE_DEPENDENCY" GroupNewVulnerability = "NEW_VULNERABILITY" GroupPolicyViolation = "POLICY_VIOLATION" GroupVEXConsumed = "VEX_CONSUMED" GroupVEXProcessed = "VEX_PROCESSED" LevelError = "ERROR" LevelInformational = "INFORMATIONAL" LevelWarning = "WARNING" ScopeSystem = "SYSTEM" ScopePortfolio = "PORTFOLIO" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BOMSubject ¶
type NewVulnerabilitySubject ¶
type NewVulnerabilitySubject struct { AffectedProjects []Project `json:"affectedProjects"` Component Component `json:"component"` Vulnerability Vulnerability `json:"vulnerability"` }
type NewVulnerableDependencySubject ¶
type NewVulnerableDependencySubject struct { Component Component `json:"component"` Project Project `json:"project"` Vulnerabilities []Vulnerability `json:"vulnerabilities"` }
type Notification ¶
type PolicyCondition ¶
type PolicyViolation ¶
type PolicyViolation struct { UUID uuid.UUID `json:"uuid"` Type string `json:"type"` Timestamp string `json:"timestamp"` PolicyCondition PolicyCondition `json:"policyCondition"` }
type PolicyViolationSubject ¶
type PolicyViolationSubject struct { Component Component `json:"component"` PolicyViolation PolicyViolation `json:"policyViolation"` Project Project `json:"project"` }
type VEXSubject ¶
type Vulnerability ¶
type Vulnerability struct { UUID uuid.UUID `json:"uuid"` VulnID string `json:"vulnId"` Source string `json:"source"` Title string `json:"title"` SubTitle string `json:"subtitle"` Description string `json:"description"` Recommendation string `json:"recommendation"` CVSSV2 float64 `json:"cvssv2"` CVSSV3 float64 `json:"cvssv3"` Severity string `json:"severity"` }
Click to show internal directories.
Click to hide internal directories.