Skip to content

Only system.admin must be able to list exports #12303 - #12309

Merged
rymsha merged 1 commit into
masterfrom
claude/github-issue-12303-k47jdu
Aug 31, 2026
Merged

Only system.admin must be able to list exports #12303#12309
rymsha merged 1 commit into
masterfrom
claude/github-issue-12303-k47jdu

Conversation

@rymsha

@rymsha rymsha commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

This change adds authorization checks to the ExportService.list() method to ensure only users with the administrator role can list available node exports.

Key Changes

  • ExportServiceImpl: Added requireAdminRole() method that checks if the current user has the system.admin role and throws ForbiddenAccessException if not
  • ExportService interface: Added JavaDoc documenting that the list() method requires the system.admin role and can throw ForbiddenAccessException
  • ExportServiceImplTest:
    • Introduced ADMIN_CONTEXT static field to provide an admin-authenticated context for test execution
    • Created listAsAdmin() helper method to wrap all exportService.list() calls with admin context
    • Updated all existing test cases to use listAsAdmin() instead of direct calls
    • Added two new test cases to verify the authorization requirement:
      • list_requires_the_administrator_role() - verifies exception when called without authentication
      • list_requires_the_administrator_role_for_authenticated_user() - verifies exception when called with non-admin role
  • export.ts: Updated JSDoc to document the system.admin role requirement

Implementation Details

The authorization check uses ContextAccessor.current().getAuthInfo() to retrieve the current authentication context and validates that the user has the ADMIN role before allowing the operation. This follows the existing security pattern in the codebase.

https://claude.ai/code/session_01LHqacRZ9V5qnpc35sP8YUF

ExportService.list() enumerated the exports directory for any caller.
The only gate was in the HTTP layer, so any app calling
exportLib.list() from server-side JS could see every export name.

Move the check into ExportServiceImpl.list(), following the same
requireAdminRole() pattern as NodeServiceImpl.enumerate(), and throw
ForbiddenAccessException when the caller lacks role:system.admin.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LHqacRZ9V5qnpc35sP8YUF
@rymsha rymsha changed the title Add admin role requirement to ExportService.list() Only system.admin must be able to list exports #12303 Aug 31, 2026
@rymsha rymsha linked an issue Aug 31, 2026 that may be closed by this pull request
@codacy-production

Copy link
Copy Markdown

Codacy's Analysis Summary

0 new issue (≤ 0 issue)
0 new security issue
More details

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes. Give us feedback

@rymsha
rymsha marked this pull request as ready for review August 31, 2026 05:15
@rymsha
rymsha requested review from anatol-sialitski and a lite review from Copilot August 31, 2026 05:15

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.

Pull request overview

This PR tightens security around node export discovery by enforcing that only callers with the system.admin role can list available exports, aligning the core export service behavior with the intended administrative-only access model.

Changes:

  • Added an admin-role authorization gate to ExportServiceImpl.list() that throws ForbiddenAccessException for non-admin callers.
  • Documented the system.admin requirement in both the Java ExportService API and the JavaScript export.list() JSDoc.
  • Updated/extended unit tests to run existing list tests under an admin context and to assert forbidden behavior for unauthenticated and non-admin callers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
modules/lib/lib-export/src/main/resources/lib/xp/export.ts Documents that export.list() requires the system.admin role.
modules/core/core-export/src/test/java/com/enonic/xp/core/impl/export/ExportServiceImplTest.java Wraps list calls in an admin context and adds authorization-focused test cases.
modules/core/core-export/src/main/java/com/enonic/xp/core/impl/export/ExportServiceImpl.java Enforces system.admin role requirement in list() via requireAdminRole().
modules/core/core-api/src/main/java/com/enonic/xp/export/ExportService.java Adds JavaDoc describing the authorization requirement and possible exception.

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

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.10%. Comparing base (07395f0) to head (0cf971a).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #12309   +/-   ##
=========================================
  Coverage     87.10%   87.10%           
- Complexity    20845    20847    +2     
=========================================
  Files          2610     2610           
  Lines         69358    69367    +9     
  Branches       5749     5750    +1     
=========================================
+ Hits          60415    60423    +8     
  Misses         6270     6270           
- Partials       2673     2674    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rymsha
rymsha merged commit 18797da into master Aug 31, 2026
13 checks passed
@rymsha
rymsha deleted the claude/github-issue-12303-k47jdu branch August 31, 2026 06:25
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.

Only system.admin must be able to list exports

4 participants