Skip to content

harden(guard): block side-effecting selects and document the contract - #50

Merged
stbischof merged 1 commit into
eclipse-daanse:mainfrom
stbischof:wip/sqlquery-querymap
Aug 25, 2026
Merged

stbischof merged 1 commit into
eclipse-daanse:mainfrom
stbischof:wip/sqlquery-querymap

Conversation

@stbischof

Copy link
Copy Markdown
Contributor

Build on the data-modifying-CTE fix already on main. Extend SqlGuard's read-only enforcement to the rest of the "parses as Select but has a side effect" class, and document the contract:

  • reject SELECT ... INTO (writes a table) and FOR UPDATE/FOR SHARE (locks);
  • fail closed: any unexpected RuntimeException during validation now becomes a GuardException instead of propagating or passing through;
  • add javadoc to SqlGuard.guard()/SqlGuardFactory.create() and a guard/README.md covering the read-only contract and the function whitelist (full-match case-sensitive regex, empty = deny-all).

Extends ReadOnlyStatementValidator and adds integration tests for each new case.

Build on the data-modifying-CTE fix already on main. Extend SqlGuard's
read-only enforcement to the rest of the "parses as Select but has a
side effect" class, and document the contract:

- reject SELECT ... INTO (writes a table) and FOR UPDATE/FOR SHARE (locks);
- fail closed: any unexpected RuntimeException during validation now
  becomes a GuardException instead of propagating or passing through;
- add javadoc to SqlGuard.guard()/SqlGuardFactory.create() and a
  guard/README.md covering the read-only contract and the function
  whitelist (full-match case-sensitive regex, empty = deny-all).

Extends ReadOnlyStatementValidator and adds integration tests for each
new case.

Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
@stbischof
stbischof merged commit f0636d8 into eclipse-daanse:main Aug 25, 2026
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant