Closed fupgang closed 1 week ago
The implementation of ComponentResource shows that a policy evaluation should be triggered when creating or updating a component. In createComponent and updateComponent it's implemented like this:
ComponentResource
createComponent
updateComponent
https://github.com/DependencyTrack/dependency-track/blob/3c265ed6e8880fde6c51302f8c54a04273276269/src/main/java/org/dependencytrack/resources/v1/ComponentResource.java#L368-L374
This does actually not happen. The project field is not set in the PolicyEvaluationEvent, therefore the PolicyEvaluationTask does nothing.
PolicyEvaluationEvent
PolicyEvaluationTask
https://github.com/DependencyTrack/dependency-track/blob/3c265ed6e8880fde6c51302f8c54a04273276269/src/main/java/org/dependencytrack/tasks/PolicyEvaluationTask.java#L50-L52
PolicyEngine
Creating or updating a component should trigger the policy evaluation for this single component. The simplest fix is to set the missing project:
.onSuccess(new PolicyEvaluationEvent(component).project(component.getProject()))
I provide an PR for this.
4.12.1
Container Image
PostgreSQL
No response
Google Chrome
Current Behavior
The implementation of
ComponentResource
shows that a policy evaluation should be triggered when creating or updating a component. IncreateComponent
andupdateComponent
it's implemented like this:https://github.com/DependencyTrack/dependency-track/blob/3c265ed6e8880fde6c51302f8c54a04273276269/src/main/java/org/dependencytrack/resources/v1/ComponentResource.java#L368-L374
This does actually not happen. The project field is not set in the
PolicyEvaluationEvent
, therefore thePolicyEvaluationTask
does nothing.https://github.com/DependencyTrack/dependency-track/blob/3c265ed6e8880fde6c51302f8c54a04273276269/src/main/java/org/dependencytrack/tasks/PolicyEvaluationTask.java#L50-L52
Steps to Reproduce
PolicyEngine
since it's not triggeredExpected Behavior
Creating or updating a component should trigger the policy evaluation for this single component. The simplest fix is to set the missing project:
.onSuccess(new PolicyEvaluationEvent(component).project(component.getProject()))
I provide an PR for this.
Dependency-Track Version
4.12.1
Dependency-Track Distribution
Container Image
Database Server
PostgreSQL
Database Server Version
No response
Browser
Google Chrome
Checklist