Skip to content

fix(security): do not enforce security when no @Policy annotation is present#99

Open
SedaOran wants to merge 1 commit into
mainfrom
fix/minimal-test-no-policy
Open

fix(security): do not enforce security when no @Policy annotation is present#99
SedaOran wants to merge 1 commit into
mainfrom
fix/minimal-test-no-policy

Conversation

@SedaOran

Copy link
Copy Markdown
Contributor

Summary

  • Root cause: When a test has no @Policy annotation, scanForPackageName() returns "" (empty string) as the restricted package (the default when no package is found). Since every class name starts with "", the AOP advice treated every stack frame as restricted, causing SecurityException in trivial tests like @PublicTest void simpleTest() { assertTrue(true); }.
  • Fix: In JupiterSecurityExtension, security enforcement (createTestCases + executeTestCases) is now only activated when an explicit @Policy annotation is present. Without @Policy, settings are reset to a clean state but no restrictions are applied.
  • Also removes leftover System.err debug logging that was left in the beforeTestExecution callback.

Related Issues

Fixes: Minimal @PublicTest / @HiddenTest Fails — Issue #9 from the security audit.

Test plan

  • @PublicTest void simpleTest() { assertTrue(true); } — should PASS without any @Policy
  • @HiddenTest void hiddenSimple() { assertTrue(true); } — should PASS without any @Policy
  • Tests WITH @Policy still enforce the security rules correctly

🤖 Generated with Claude Code

…present

When a test has no @Policy annotation, scanForPackageName() returns the
empty string as the restricted package (the default when no package is
found in the project scan). Since every class name starts with "", the
AOP advice would treat every stack frame as restricted, causing
SecurityExceptions in trivial tests that perform no forbidden operations.

Fix: in JupiterSecurityExtension, only activate security enforcement
(createTestCases + executeTestCases) when an explicit @Policy annotation
is present. Without @Policy, settings are still reset to a clean state
but no restrictions are applied, so @publictest / @Hiddentest tests
without a policy annotation pass as expected.

Also removes leftover System.err debug logging that was left in the
beforeTestExecution callback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@SedaOran, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 28 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 876539f3-14a0-4285-bd8c-8fe40d2ed4cc

📥 Commits

Reviewing files that changed from the base of the PR and between dd4854f and 1f42006.

📒 Files selected for processing (1)
  • src/main/java/de/tum/cit/ase/ares/api/jupiter/JupiterSecurityExtension.java
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/minimal-test-no-policy

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 and usage tips.

@jerrycai0006 jerrycai0006 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.

This PR seems to conflict with a PR that has already been merged: #86

As far as I understand, the intended behavior introduced there was that the security mechanism should still be enforced even when no @Policy annotation is present.

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.

2 participants