Skip to content

Expose created/updated date filters for Risk Acceptance API (created_before/after, updated_before/after)#14786

Open
PDFour4 wants to merge 1 commit intoDefectDojo:devfrom
bendnema:testing/risk-acceptance-filter
Open

Expose created/updated date filters for Risk Acceptance API (created_before/after, updated_before/after)#14786
PDFour4 wants to merge 1 commit intoDefectDojo:devfrom
bendnema:testing/risk-acceptance-filter

Conversation

@PDFour4
Copy link
Copy Markdown

@PDFour4 PDFour4 commented Apr 29, 2026

Summary

This adds before/after DateTime filter parameters for created and updated on the Risk Acceptance API and aligns the filter naming with existing API conventions.

Changes

  • dojo/filters.pyApiRiskAcceptanceFilter: use DateRangeFilter for created/updated and add explicit created_before, created_after, updated_before, updated_after (DateTimeFilter with lt/gt).
  • unittests/test_risk_acceptance_api.py — add create_risk_acceptance test helper and update tests to assert the new query params deterministically.

Why

Consumers need precise before/after semantics for risk acceptance timestamps. This follows the established pattern used across the API (DateRangeFilter + explicit _before/_after DateTime filters) and ensures OpenAPI schema exposes the correct params.

Fixes #14623

Testing

  • Unit tests added/updated under unittests/test_risk_acceptance_api.py. Run targeted tests:
./run-unittest.sh --test-case unittests.test_risk_acceptance_api.TestRiskAcceptanceApi.test_risk_acceptance_created_filter
./run-unittest.sh --test-case unittests.test_risk_acceptance_api.TestRiskAcceptanceApi.test_risk_acceptance_updated_filter

No migrations required.

@dryrunsecurity
Copy link
Copy Markdown

dryrunsecurity Bot commented Apr 29, 2026

DryRun Security

This pull request includes a sensitive edit to dojo/filters.py, which is flagged as a protected code path. The scanner notes that sensitive file paths and allowed authors can be configured in .dryrunsecurity.yaml.

🔴 Configured Codepaths Edit in dojo/filters.py (drs_6be7ceb8)
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.

@PDFour4 PDFour4 force-pushed the testing/risk-acceptance-filter branch from 1e2803f to 55a722f Compare April 29, 2026 22:50
Copy link
Copy Markdown

@bendnema bendnema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, overall test passing

@mtesauro
Copy link
Copy Markdown
Contributor

@PDFour4 PRs need to be against the Dev branch - please update this PR to be against that branch.

For details see:
https://github.com/DefectDojo/django-DefectDojo/blob/master/readme-docs/CONTRIBUTING.md#submitting-pull-requests

@PDFour4 PDFour4 changed the base branch from master to dev April 30, 2026 03:21
@PDFour4
Copy link
Copy Markdown
Author

PDFour4 commented Apr 30, 2026

@mtesauro I've updated the PR base branch from master to dev. Should be all set now!

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

• use DateRangeFilter for created and updated
• add explicit DateTimeFilter comparisons
• updated risk acceptance API tests to assert new query params and deterministic result inclusion
@PDFour4 PDFour4 force-pushed the testing/risk-acceptance-filter branch from 2d8bfa8 to 7a0ed0a Compare April 30, 2026 20:45
@github-actions
Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

@PDFour4
Copy link
Copy Markdown
Author

PDFour4 commented Apr 30, 2026

Update:

The filter implementation has evolved since this PR was initiated. The maintainers have refactored ApiRiskAcceptanceFilter to use a dictionary-style fields configuration with automatic lookup expressions (gt/lt), which replaces the original explicit DateTimeFilter definitions my team initially contributed. Both approaches provide identical functionality and expose the same query parameters in the OpenAPI schema.

This PR now focuses on adding comprehensive tests for the risk acceptance timestamp filters created_before/after, updated_before/after. The tests validate the new upstream implementation and ensure the filtering behavior works correctly.

Locally verified: Both test_risk_acceptance_created_filter and test_risk_acceptance_updated_filter pass successfully with the latest code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Risk Acceptance Endpoint is Missing Created and Update Date Filters

3 participants