fix(api): add created/updated date filters to risk_acceptance endpoint#14792
fix(api): add created/updated date filters to risk_acceptance endpoint#14792SAY-5 wants to merge 1 commit intoDefectDojo:masterfrom
Conversation
Risk_Acceptance returns created and updated fields in its API response
but ApiRiskAcceptanceFilter exposed neither as a query parameter, while
the matching findings, products, and assets filters all do (see
ApiProductFilter for the same pattern).
Add DateRangeFilter('created') and DateRangeFilter('updated') to
ApiRiskAcceptanceFilter and expose both fields in the OrderingFilter so
clients can filter and sort risk_acceptance lists by date the same way
they already can for the sibling resources.
Closes DefectDojo#14623.
Signed-off-by: SAY-5 <say.apm35@gmail.com>
|
This pull request includes a sensitive edit in
🔴 Configured Codepaths Edit in
|
| Vulnerability | Configured Codepaths Edit |
|---|---|
| Description | Sensitive edits detected for this file. Sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml. |
We've notified @mtesauro.
Comment to provide feedback on these findings.
Report false positive: @dryrunsecurity fp [FINDING ID] [FEEDBACK]
Report low-impact: @dryrunsecurity nit [FINDING ID] [FEEDBACK]
Example: @dryrunsecurity fp drs_90eda195 This code is not user-facing
All finding details can be found in the DryRun Security Dashboard.
|
@SAY-5 Please make your PR against the DEV branch - we don't accept PRs against master. For more info, see https://github.com/DefectDojo/django-DefectDojo/blob/master/readme-docs/CONTRIBUTING.md#submitting-pull-requests |
Summary
Closes #14623.
The
risk_acceptanceAPI returnscreatedandupdatedtimestamps in its responses butApiRiskAcceptanceFilterdid not expose either as a query parameter, while the matchingfindings,products, andassetsfilters all do (seeApiProductFilter,ApiFindingFilterfor the same pattern). Clients had no way to scope listings by acceptance date.Change
Add
DateRangeFilter(created)andDateRangeFilter(updated)toApiRiskAcceptanceFilterand expose both fields in the existingOrderingFilter, matching the convention used by the sibling resources.Risk_Acceptance.created(auto_now_add) andRisk_Acceptance.updated(auto_now) already exist on the model (dojo/models.pyL3976–3977) so no migration is needed.Test plan
python -c 'import ast; ast.parse(open("dojo/filters.py").read())'— file parses/api/v2/risk_acceptance/listscreated,updated, andoquery parametersGET /api/v2/risk_acceptance/?created=weekreturns last week's acceptances;GET /api/v2/risk_acceptance/?o=-updatedsorts by most-recently-updated first