Skip to content

fix(audit): support open-ended date filters - #5684

Merged
nobodyiam merged 2 commits into
apolloconfig:masterfrom
nobodyiam:codex/fix-audit-date-filter
Sep 30, 2026
Merged

nobodyiam merged 2 commits into
apolloconfig:masterfrom
nobodyiam:codex/fix-audit-date-filter

Conversation

@nobodyiam

@nobodyiam nobodyiam commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

What's the purpose of this PR

Audit log searches with only a start or end date currently return no rows because the missing bound is still included in a SQL comparison. Select the query for the bounds that are present so clearing either date preserves the other inclusive bound, descending order, and pagination.

Which issue(s) this PR fixes

No linked issue. This fixes AUD-01.03 in the release regression handbook.

Brief changelog

  • Add queries for a start date alone and an end date alone, and document null dates as unbounded.
  • Add real H2/JPA regression tests for all four date-bound combinations, inclusive boundaries, operation filtering, and pagination. H2 is a test-scoped dependency only. Extend the JavaScript tests for clearing either bound and loading subsequent pages.
  • Correct the release handbook expectations for app information, release previews, matching change batches, private gray rules, and gray instance views. Preserve all 160 check IDs. Use authorized HTTP writes plus Chrome verification for user credential setup and profile updates, and remove the password-mismatch scenario.

Validation

  • ./mvnw -B -ntp clean test on JDK 17: passed for the full reactor after rebasing onto master; one existing test is disabled because it requires an admin server.
  • node --test apollo-portal/src/test/resources/static/scripts/test_auditLogDates.js: passed.
  • ./mvnw spotless:apply scoped to the changed Java files: passed with no formatting changes.
  • Handbook consistency: 60 groups, 160 unique check IDs in their original order, and valid local references.

Follow this checklist to help us incorporate your contribution quickly and easily:

  • Read the Contributing Guide before making this pull request.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit tests to verify the code.
  • Run mvn clean test to make sure this pull request doesn't break anything.
  • Run mvn spotless:apply to format your code.
  • Update the CHANGES log.

Summary by CodeRabbit

  • New Features

    • Audit log searches now support an optional start date, end date, or both, while retaining inclusive filtering when both dates are provided.
  • Documentation

    • Updated release regression guidance for audit date filtering and other Portal checks, including verification steps and reporting requirements.

Preserve optional audit date bounds and pagination with real JPA regression coverage. Align the 160-check release handbook with supported UI behavior and authorized HTTP credential setup.
Copilot AI balanced review requested due to automatic review settings September 30, 2026 13:59
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 39bdfee7-50ad-4abb-8eb7-0e39d546e225

📥 Commits

Reviewing files that changed from the base of the PR and between 5d0755e and 940aaa9.

📒 Files selected for processing (8)
  • CHANGES.md
  • apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogQueryApi.java
  • apollo-audit/apollo-audit-impl/pom.xml
  • apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/repository/ApolloAuditLogRepository.java
  • apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogService.java
  • apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogServiceTest.java
  • apollo-portal/src/test/resources/static/scripts/test_auditLogDates.js
  • e2e/portal-e2e/release-regression/README.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The audit service now supports operation-name queries with either or both date bounds omitted. Tests cover date filtering and pagination. The release-regression manual updates account-management procedures and several application, release, gray-rule, instance, and admin checks.

Changes

Audit date filters

Layer / File(s) Summary
Document and implement date-bound queries
apollo-audit/apollo-audit-api/src/main/java/com/ctrip/framework/apollo/audit/api/ApolloAuditLogQueryApi.java, apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/repository/ApolloAuditLogRepository.java, apollo-audit/apollo-audit-impl/src/main/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogService.java, CHANGES.md
The API documentation describes null date bounds. The service uses operation-name-only, lower-bound, upper-bound, or bounded queries. The release notes describe the open-ended filters.
Test date filtering and pagination
apollo-audit/apollo-audit-impl/pom.xml, apollo-audit/apollo-audit-impl/src/test/java/com/ctrip/framework/apollo/audit/service/ApolloAuditLogServiceTest.java, apollo-portal/src/test/resources/static/scripts/test_auditLogDates.js, e2e/portal-e2e/release-regression/README.md
H2-backed service tests cover date bounds, operation matching, and pagination. Portal tests check clearing either bound and retaining the other bound in paged requests. The release manual specifies expected audit date-filter results.

Release-regression instructions

Layer / File(s) Summary
Specify account-write and verification procedure
e2e/portal-e2e/release-regression/README.md
The manual documents authorized interface writes for account creation and profile changes, credential handling, Chrome and independent-login verification, cleanup, and result reporting.
Revise regression scenario checks
e2e/portal-e2e/release-regression/README.md
The manual revises application information, release-batch filtering, gray-rule maintenance, gray-instance empty-state, and admin validation checks.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 940aa

Audit log searches with only a start date or only an end date now return the expected results. No merge-blocking risk was found. The author's reported Maven and Node test results were not independently reproduced here.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 940aa

Open-ended searches retain operation filtering, pagination, and existing access checks. No introduced security issue was established, but deployment-level authentication and audit-data isolation were not fully verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Caller-selected dates now produce results for formerly failing one-sided searches, but those results remain subsets of the existing operation-only API query. No additional record fields or write authority are introduced in this flow. Deployment and tenant isolation remain outside the verified scope.

Trust Boundaries and Controls

  • observed — Portal management audit searches retain super-admin and portal-user checks. The direct audit endpoint retains its query-permission annotation, but the default pre-authorizer returns true. This permissive default predates the PR; upstream protection of that route was not established.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 5 files. (3 skipped: 3… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: support for open-ended audit date filters.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 5 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation handles all bound combinations and includes focused integration and client-side regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Adds open-ended audit date filtering while preserving inclusive bounds, ordering, and pagination.

Changes:

  • Adds one-sided repository queries and documents nullable bounds.
  • Adds H2/JPA and JavaScript regression coverage.
  • Updates release-regression handbook expectations and credential workflow.
File Description
e2e/​portal-e2e/​release-regression/​README.md Updates regression procedures and expectations.
apollo-portal/​src/​test/​resources/​static/​scripts/​test_auditLogDates.js Tests cleared bounds across pagination.
apollo-audit/​apollo-audit-impl/​src/​test/​java/​com/​ctrip/​framework/​apollo/​audit/​service/​ApolloAuditLogServiceTest.java Adds integration coverage for date filtering.
apollo-audit/​apollo-audit-impl/​src/​main/​java/​com/​ctrip/​framework/​apollo/​audit/​service/​ApolloAuditLogService.java Selects queries based on present bounds.
apollo-audit/​apollo-audit-impl/​src/​main/​java/​com/​ctrip/​framework/​apollo/​audit/​repository/​ApolloAuditLogRepository.java Adds one-sided date queries.
apollo-audit/​apollo-audit-impl/​pom.xml Adds test-scoped H2.
apollo-audit/​apollo-audit-api/​src/​main/​java/​com/​ctrip/​framework/​apollo/​audit/​api/​ApolloAuditLogQueryApi.java Documents null bounds as unbounded.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@nobodyiam
nobodyiam merged commit ce54e20 into apolloconfig:master Sep 30, 2026
18 checks passed
@nobodyiam
nobodyiam deleted the codex/fix-audit-date-filter branch September 30, 2026 23:44
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants