Skip to content

Throw Error for Empty Database Policies - #3865

Open
RubenCerna2079 wants to merge 5 commits into
mainfrom
dev/rubencerna/logging-columns
Open

RubenCerna2079 wants to merge 5 commits into
mainfrom
dev/rubencerna/logging-columns

Conversation

@RubenCerna2079

@RubenCerna2079 RubenCerna2079 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Why make this change?

What is this change?

Checks that the database policy didn't compile to an empty predicate, in case that it does it will send a log warning message in development mode or throw an error in production mode.
Created the new AuditDatabasePolicyFailOpen function to create the log message and throw an error in case DAB is in production mode.

How was this tested?

  • Integration Tests
  • Unit Tests
    Added tests to ensure that an empty policy will return the expected log message and throw an error only if it is in production mode.

Sample Request(s)

image image

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.

🟡 Changes recommended

Nonempty policy text can still produce a null filter during parsing, bypassing the production safeguard.

1 open issue
What changed in this PR

This PR adds protection against configured database authorization policies that resolve to empty text, warning in development and rejecting requests in production.

Changes:

  • Adds structured audit logging and production authorization errors for empty resolved policies.
  • Allows authorization tests to inject a logger.
  • Adds tests for host-mode behavior and valid or unconfigured policies.
File Description
src/​Service.Tests/​Authorization/​AuthorizationResolverUnitTests.cs Tests empty-policy handling and audit contents.
src/​Service.Tests/​Authorization/​AuthorizationHelpers.cs Supports logger injection for tests.
src/​Core/​Authorization/​AuthorizationResolver.cs Adds empty-policy detection, auditing, and production rejection.

Review effort: Balanced

Comment thread src/Core/Authorization/AuthorizationResolver.cs
Comment thread src/Core/Authorization/AuthorizationResolver.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants