Documentation
¶
Overview ¶
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.
For more information on Nexus IQ webhooks, see here: https://help.sonatype.com/iqserver/automating/iq-server-webhooks
Index ¶
- func ApplicationEvaluationEvents() (<-chan WebhookApplicationEvaluation, func())
- func LicenseOverrideEvents() (<-chan WebhookLicenseOverride, func())
- func Listen(w http.ResponseWriter, r *http.Request)
- func PolicyManagementEvents() (<-chan WebhookPolicyManagement, func())
- func SecurityOverrideEvents() (<-chan WebhookSecurityOverride, func())
- func ViolationAlertEvents() (<-chan WebhookViolationAlert, func())
- type WebhookApplicationEvaluation
- type WebhookEvent
- type WebhookEventType
- type WebhookLicenseOverride
- type WebhookPolicyManagement
- type WebhookSecurityOverride
- type WebhookViolationAlert
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplicationEvaluationEvents ¶
func ApplicationEvaluationEvents() (<-chan WebhookApplicationEvaluation, func())
ApplicationEvaluationEvents returns a channel (and closer) where new Application Evaluation events are sent
func LicenseOverrideEvents ¶
func LicenseOverrideEvents() (<-chan WebhookLicenseOverride, func())
LicenseOverrideEvents returns a channel (and closer) where new Violation Alert events are sent
func Listen ¶
func Listen(w http.ResponseWriter, r *http.Request)
Listen will handle any HTTP requests which are genuine Nexus IQ Webhooks
Example ¶
appEvalEvents, _ := ApplicationEvaluationEvents()
violationAlertEvents, _ := ViolationAlertEvents()
policyMgmtEvents, _ := PolicyManagementEvents()
licenseOverride, _ := LicenseOverrideEvents()
securityOverride, _ := SecurityOverrideEvents()
go func() {
for {
select {
case <-appEvalEvents:
log.Println("Received Application Evaluation event")
case <-violationAlertEvents:
log.Println("Received Violation Alert event")
case <-policyMgmtEvents:
log.Println("Received Policy Management event")
case <-licenseOverride:
log.Println("Received License Overridden event")
case <-securityOverride:
log.Println("Received Security Vulnerability Overridden event")
default:
}
}
}()
http.HandleFunc("/ingest", Listen)
log.Fatal(http.ListenAndServe(":9876", nil))
func PolicyManagementEvents ¶
func PolicyManagementEvents() (<-chan WebhookPolicyManagement, func())
PolicyManagementEvents returns a channel (and closer) where new Violation Alert events are sent
func SecurityOverrideEvents ¶
func SecurityOverrideEvents() (<-chan WebhookSecurityOverride, func())
SecurityOverrideEvents returns a channel (and closer) where new Violation Alert events are sent
func ViolationAlertEvents ¶
func ViolationAlertEvents() (<-chan WebhookViolationAlert, func())
ViolationAlertEvents returns a channel (and closer) where new Violation Alert events are sent
Types ¶
type WebhookApplicationEvaluation ¶
type WebhookApplicationEvaluation struct {
Timestamp string `json:"timestamp"`
Initiator string `json:"initiator"`
ID string `json:"id"`
ApplicationEvaluation webhookAppEval `json:"applicationEvaluation"`
}
WebhookApplicationEvaluation is the payload for an Application Evaluation webhook event
type WebhookEventType ¶
type WebhookEventType string
WebhookEventType identifies a webhook event typu
const ( WebhookEventApplicationEvaluation WebhookEventType = "iq:applicationEvaluation" WebhookEventViolationAlert WebhookEventType = "iq:policyAlert" WebhookEventPolicyManagement WebhookEventType = "iq:policyManagement" WebhookEventLicenseOverride WebhookEventType = "iq:licenseOverrideManagement" WebhookEventSecurityOverride WebhookEventType = "iq:securityVulnerabilityOverrideManagement" )
Enumeration of every Webhook event type
func IsWebhookEvent ¶
func IsWebhookEvent(r *http.Request) (ok bool, whtype WebhookEventType)
IsWebhookEvent determines if HTTP request is an IQ Webhook payload and identifies the type
type WebhookLicenseOverride ¶
type WebhookLicenseOverride struct {
LicenseOverride licenseOverride `json:"licenseOverride"`
}
WebhookLicenseOverride is the payload for a License Override webhook event
type WebhookPolicyManagement ¶
type WebhookPolicyManagement struct {
Owner policyOwner `json:"owner"`
}
WebhookPolicyManagement is the payload for a Policy Management webhook event
type WebhookSecurityOverride ¶
type WebhookSecurityOverride struct {
SecurityVulnerabilityOverride securityVulnerabilityOverride `json:"securityVulnerabilityOverride"`
}
WebhookSecurityOverride is the payload for a Security Vulnerability Override webhook event
type WebhookViolationAlert ¶
type WebhookViolationAlert struct {
Initiator string `json:"initiator"`
ApplicationEvaluation webhookAppEval `json:"applicationEvaluation"`
Application nexusiq.Application `json:"application"`
PolicyAlerts []policyAlert `json:"policyAlerts"`
}
WebhookViolationAlert is the payload for a Violation Alert webhook event