Repository navigation
Conversation
DependencyTrack 5.0 added a CEL filter expression to notification rules,
evaluated by NotificationRouter after the scope, level, group, project and
tag checks:
if (!evaluateFilterExpression(rule, notification, subject)) {
LOGGER.debug("Notification did not match the rule's filter expression");
return false;
}
It is persisted on NotificationRule as FILTER_EXPRESSION and serialised as
filterExpression, but the field is absent from this struct, so a rule's
expression cannot be read or written through this client. Round-tripping a
rule through Update also silently drops any expression set elsewhere.
The field is omitempty, so rules without an expression serialise exactly as
before.
Signed-off-by: 1azunna <26540897+1azunna@users.noreply.github.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
DependencyTrack 5.0 added a CEL filter expression to notification rules, but
NotificationRulehas no corresponding field, so it cannot be read or written through this client.It is persisted on the model (
NotificationRule.java):and evaluated by
NotificationRouterafter the scope, level, group, project and tag checks:The expression environment (
NotificationFilterExpressionEnv,@since 5.0.0) exposeslevel,scope,group,title,content,timestampandsubject, so rules can be narrowed well beyondnotifyOn— for example to only notify on policy violations whose policy is atFAIL:There is a second-order problem: because the field is missing from the struct, reading a rule and passing it back to
Updatesilently drops an expression set through the UI or API.Change
NotificationRule.FilterExpression, taggedjson:"filterExpression,omitempty"omitemptymeans rules without an expression serialise byte-identically to before, so this is purely additive.Tests
notification_rule_filter_test.go, written as unit tests so they run without a container, followingutil_test.go:filterExpressionis emitted when setgo build ./...andgo test -run TestNotificationRule ./...pass.Context
Found while managing notification rules with SolarFactories/terraform-provider-dependencytrack, which has no way to express this today. A follow-up PR there depends on this one.
Independent of #64, which adds
ViolationTypetoPolicyCondition; the two touch different files and can merge in either order.