Skip to content

Stop Spring Data REST from exporting repositories - #499

Merged
laffer1 merged 1 commit into
masterfrom
disable-data-rest-export
Nov 3, 2026
Merged

laffer1 merged 1 commit into
masterfrom
disable-data-rest-export

Conversation

@laffer1

@laffer1 laffer1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Spring Data REST was publishing 26 repositories at the site root (/users, /entries, /comments, /userContacts, /queueMails, …) with no login check, and /users overlapped the ActivityPub actor routes.

Nothing calls them:

Change: JustJournalRepositoryRestConfiguration sets the annotated detection strategy, so only repositories marked @RepositoryRestResource can be exported. Every annotated one already says exported = false. The exposeIdsFor call is gone; it only affected exported repositories.

Tests

  • New JustJournalRepositoryRestConfigurationTests scans com.justjournal.repository and checks no repository is exported. Passes locally, along with the other config tests.
  • ITAppTest.repositoriesAreNotExported expects 404 from /entries, /comments, /userContacts and /queueMails. Not run locally (the it profile couldn't reach Elasticsearch); needs CI.

🤖 Generated with Claude Code

Summary by Sourcery

Disable unintended Spring Data REST repository exposure at the site root.

Bug Fixes:

  • Prevent Spring Data REST from exposing repository endpoints at unauthenticated site-root paths, including routes that conflicted with ActivityPub actors.

Enhancements:

  • Restrict repository detection to explicitly annotated repositories, ensuring the application’s repositories are not exported.

Tests:

  • Add configuration coverage verifying that no repository is considered exportable.
  • Add integration coverage confirming representative repository endpoints return 404.

Spring Data REST published 26 repositories at the site root (/users,
/entries, /comments, /userContacts, /queueMails and so on) with no login
check, and /users overlapped the ActivityPub actor routes. Nothing on the
site or in the unix, Java, Windows or Dashboard clients called them; they
all use /api or the older servlets.

Only repositories annotated with @RepositoryRestResource can be exported
now, and every annotated one already says exported = false. A unit test
checks no repository is exported, and ITAppTest expects 404 from a few of
the old paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR closes unintended Spring Data REST exposure by switching repository discovery to annotated-only mode, relying on existing exported=false annotations, and adds unit and integration tests to verify repositories are not published at the site root.

File-Level Changes

Change Details Files
Restrict Spring Data REST repository discovery to explicitly annotated repositories, preventing accidental root-level publication.
  • Replace ID exposure configuration with the ANNOTATED repository detection strategy.
  • Document that annotated repositories are already disabled with exported=false and that clients use /api or legacy servlet routes.
src/main/java/com/justjournal/config/JustJournalRepositoryRestConfiguration.java
Add integration coverage confirming previously exposed repository endpoints are unavailable.
  • Assert 404 responses for entries, comments, user contacts, and queue mails root paths.
src/test/java/com/justjournal/ITAppTest.java
Add focused configuration testing to verify every repository in the repository package is non-exported under the configured detection strategy.
  • Scan repository interfaces and assert the configuration is applied and none are considered exported.
  • Guard against an incomplete scan by requiring more than 30 repositories to be discovered.
src/test/java/com/justjournal/config/JustJournalRepositoryRestConfigurationTests.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@laffer1

laffer1 commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator Author

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@laffer1
laffer1 merged commit b3c0dc6 into master Nov 3, 2026
6 checks passed
@laffer1
laffer1 deleted the disable-data-rest-export branch November 3, 2026 08:28

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepsource-io

deepsource-io Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

DeepSource Code Review

We reviewed changes in 8e92b65...cd75073 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Nov 3, 2026 8:29a.m. Review ↗
Java Nov 3, 2026 8:29a.m. Review ↗
Shell Nov 3, 2026 8:29a.m. Review ↗
JavaScript Nov 3, 2026 8:29a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

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