-
-
Notifications
You must be signed in to change notification settings - Fork 595
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Vulnerability update notifications #4067
Open
4naesthetic
wants to merge
4
commits into
DependencyTrack:master
Choose a base branch
from
4naesthetic:feat/vulnerability-change-notifications
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f8402c9
Feat: Add notification when severity of a vulnerability changes
66d50d7
Reduce quantity of notifications generated and emit events from misse…
4naesthetic a63290d
Additional test coverage
4naesthetic 1cb7273
Remove unnecessary component loop in analyzeNotificationCriteria
4naesthetic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,24 +37,25 @@ Notification levels behave identical to logging levels: | |
Each scope contains a set of notification groups that can be subscribed to. Some groups contain notifications of | ||
multiple levels, while others can only ever have a single level. | ||
|
||
| Scope | Group | Level(s) | Description | | ||
|-----------|---------------------------|---------------|-----------------------------------------------------------------------------------------------------------------------------------| | ||
| SYSTEM | ANALYZER | (Any) | Notifications generated as a result of interacting with an external source of vulnerability intelligence | | ||
| SYSTEM | DATASOURCE_MIRRORING | (Any) | Notifications generated when performing mirroring of one of the supported datasources such as the NVD | | ||
| SYSTEM | INDEXING_SERVICE | (Any) | Notifications generated as a result of performing maintenance on Dependency-Tracks internal index used for global searching | | ||
| SYSTEM | FILE_SYSTEM | (Any) | Notifications generated as a result of a file system operation. These are typically only generated on error conditions | | ||
| SYSTEM | REPOSITORY | (Any) | Notifications generated as a result of interacting with one of the supported repositories such as Maven Central, RubyGems, or NPM | | ||
| SYSTEM | USER_CREATED | INFORMATIONAL | Notifications generated as a result of a user creation | | ||
| SYSTEM | USER_DELETED | INFORMATIONAL | Notifications generated as a result of a user deletion | | ||
| PORTFOLIO | NEW_VULNERABILITY | INFORMATIONAL | Notifications generated whenever a new vulnerability is identified | | ||
| PORTFOLIO | NEW_VULNERABLE_DEPENDENCY | INFORMATIONAL | Notifications generated as a result of a vulnerable component becoming a dependency of a project | | ||
| PORTFOLIO | GLOBAL_AUDIT_CHANGE | INFORMATIONAL | Notifications generated whenever an analysis or suppression state has changed on a finding from a component (global) | | ||
| PORTFOLIO | PROJECT_AUDIT_CHANGE | INFORMATIONAL | Notifications generated whenever an analysis or suppression state has changed on a finding from a project | | ||
| PORTFOLIO | BOM_CONSUMED | INFORMATIONAL | Notifications generated whenever a supported BOM is ingested and identified | | ||
| PORTFOLIO | BOM_PROCESSED | INFORMATIONAL | Notifications generated after a supported BOM is ingested, identified, and successfully processed | | ||
| PORTFOLIO | BOM_PROCESSING_FAILED | ERROR | Notifications generated whenever a BOM upload process fails | | ||
| PORTFOLIO | BOM_VALIDATION_FAILED | ERROR | Notifications generated whenever an invalid BOM is uploaded | | ||
| PORTFOLIO | POLICY_VIOLATION | INFORMATIONAL | Notifications generated whenever a policy violation is identified | | ||
| Scope | Group | Level(s) | Description | | ||
|-----------|-------------------------------|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------| | ||
| SYSTEM | ANALYZER | (Any) | Notifications generated as a result of interacting with an external source of vulnerability intelligence | | ||
| SYSTEM | DATASOURCE_MIRRORING | (Any) | Notifications generated when performing mirroring of one of the supported datasources such as the NVD | | ||
| SYSTEM | INDEXING_SERVICE | (Any) | Notifications generated as a result of performing maintenance on Dependency-Tracks internal index used for global searching | | ||
| SYSTEM | FILE_SYSTEM | (Any) | Notifications generated as a result of a file system operation. These are typically only generated on error conditions | | ||
| SYSTEM | REPOSITORY | (Any) | Notifications generated as a result of interacting with one of the supported repositories such as Maven Central, RubyGems, or NPM | | ||
| SYSTEM | USER_CREATED | INFORMATIONAL | Notifications generated as a result of a user creation | | ||
| SYSTEM | USER_DELETED | INFORMATIONAL | Notifications generated as a result of a user deletion | | ||
| PORTFOLIO | NEW_VULNERABILITY | INFORMATIONAL | Notifications generated whenever a new vulnerability is identified | | ||
| PORTFOLIO | NEW_VULNERABLE_DEPENDENCY | INFORMATIONAL | Notifications generated as a result of a vulnerable component becoming a dependency of a project | | ||
| PORTFOLIO | PROJECT_VULNERABILITY_UPDATED | INFORMATIONAL | Notifications generated if a vulnerability associated with a project is updated after creation. Currently only triggers on severity updates. | | ||
| PORTFOLIO | GLOBAL_AUDIT_CHANGE | INFORMATIONAL | Notifications generated whenever an analysis or suppression state has changed on a finding from a component (global) | | ||
| PORTFOLIO | PROJECT_AUDIT_CHANGE | INFORMATIONAL | Notifications generated whenever an analysis or suppression state has changed on a finding from a project | | ||
| PORTFOLIO | BOM_CONSUMED | INFORMATIONAL | Notifications generated whenever a supported BOM is ingested and identified | | ||
| PORTFOLIO | BOM_PROCESSED | INFORMATIONAL | Notifications generated after a supported BOM is ingested, identified, and successfully processed | | ||
| PORTFOLIO | BOM_PROCESSING_FAILED | ERROR | Notifications generated whenever a BOM upload process fails | | ||
| PORTFOLIO | BOM_VALIDATION_FAILED | ERROR | Notifications generated whenever an invalid BOM is uploaded | | ||
| PORTFOLIO | POLICY_VIOLATION | INFORMATIONAL | Notifications generated whenever a policy violation is identified | | ||
|
||
## Configuring Publishers | ||
|
||
|
@@ -233,6 +234,55 @@ This type of notification will always contain: | |
|
||
> The `cwe` field is deprecated and will be removed in a later version. Please use `cwes` instead. | ||
|
||
#### PROJECT_VULNERABILITY_UPDATED | ||
This type of notification will always contain: | ||
* 1 vulnerability update | ||
* 1 component | ||
|
||
To minimise noise, a notification will only be published if the vulnerability already affects an existing project. This can be scoped down further by limiting notifications to specific projects when configuring an alert rule. | ||
|
||
```json | ||
{ | ||
"notification": { | ||
"level": "INFORMATIONAL", | ||
"scope": "PORTFOLIO", | ||
"group": "PROJECT_VULNERABILITY_UPDATED", | ||
"timestamp": "2018-08-27T23:26:22.961", | ||
"title": "Vulnerability Update", | ||
"content": "The vulnerability CVE-2012-5784 on component axis has changed severity from LOW to MEDIUM", | ||
"subject": { | ||
"vulnerability": { | ||
"uuid": "941a93f5-e06b-4304-84de-4d788eeb4969", | ||
"vulnId": "CVE-2012-5784", | ||
"source": "NVD", | ||
"aliases": [ | ||
{ | ||
"vulnId": "GHSA-55w9-c3g2-4rrh", | ||
"source": "GITHUB" | ||
} | ||
], | ||
"old": { | ||
"severity": "LOW" | ||
}, | ||
"new": { | ||
"severity": "MEDIUM" | ||
} | ||
}, | ||
"component": { | ||
"uuid": "4d5cd8df-cff7-4212-a038-91ae4ab79396", | ||
"group": "apache", | ||
"name": "axis", | ||
"version": "1.4", | ||
"md5": "03dcfdd88502505cc5a805a128bfdd8d", | ||
"sha1": "94a9ce681a42d0352b3ad22659f67835e560d107", | ||
"sha256": "05aebb421d0615875b4bf03497e041fe861bf0556c3045d8dda47e29241ffdd3", | ||
"purl": "pkg:maven/apache/[email protected]" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
#### PROJECT_AUDIT_CHANGE and GLOBAL_AUDIT_CHANGE | ||
This type of notification will always contain: | ||
* 1 component | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/org/dependencytrack/event/ProjectVulnerabilityUpdateEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* This file is part of Dependency-Track. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) OWASP Foundation. All Rights Reserved. | ||
*/ | ||
package org.dependencytrack.event; | ||
|
||
import alpine.event.framework.SingletonCapableEvent; | ||
import org.dependencytrack.model.Vulnerability; | ||
import org.dependencytrack.model.VulnerabilityUpdateDiff; | ||
|
||
|
||
public class ProjectVulnerabilityUpdateEvent extends SingletonCapableEvent { | ||
private final VulnerabilityUpdateDiff vulnerabilityUpdateDiff; | ||
private final Vulnerability vulnerability; | ||
|
||
public ProjectVulnerabilityUpdateEvent(Vulnerability vulnerability, VulnerabilityUpdateDiff vulnerabilityUpdateDiff) { | ||
this.vulnerability = vulnerability; | ||
this.vulnerabilityUpdateDiff = vulnerabilityUpdateDiff; | ||
} | ||
|
||
public Vulnerability getVulnerability() { | ||
return vulnerability; | ||
} | ||
|
||
public VulnerabilityUpdateDiff getVulnerabilityUpdateDiff() { | ||
return vulnerabilityUpdateDiff; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/org/dependencytrack/model/VulnerabilityUpdateDiff.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* This file is part of Dependency-Track. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright (c) OWASP Foundation. All Rights Reserved. | ||
*/ | ||
package org.dependencytrack.model; | ||
|
||
public class VulnerabilityUpdateDiff { | ||
private Severity oldSeverity; | ||
private Severity newSeverity; | ||
|
||
public VulnerabilityUpdateDiff(Severity oldSeverity, Severity newSeverity) { | ||
this.oldSeverity = oldSeverity; | ||
this.newSeverity = newSeverity; | ||
} | ||
|
||
public Severity getOldSeverity() { return oldSeverity; } | ||
|
||
public Severity getNewSeverity() { return newSeverity; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making this a
record
instead.