Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Update endpoints used by Scorpio #10323

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

janthoXO
Copy link
Contributor

@janthoXO janthoXO commented Feb 14, 2025

Description

This PR adjustes the endpoints needed by the VSCode API. This change just includes changes to endpoint authorization hooks which verify tokens send by the VSCode extension.

Testserver States

You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.

Summary by CodeRabbit

  • Refactor
    • Simplified access controls for build result details, broadening endpoint visibility.
    • Enhanced security for exercise details by enforcing specific access requirements.
    • Streamlined the participation endpoint by removing specialized tool-based restrictions.

@janthoXO janthoXO self-assigned this Feb 14, 2025
@janthoXO janthoXO requested a review from a team as a code owner February 14, 2025 02:49
@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) assessment Pull requests that affect the corresponding module exercise Pull requests that affect the corresponding module labels Feb 14, 2025
@janthoXO janthoXO changed the title update endpoints used by scorpio Development: Update Endpoints used by Scorpio VSCode Extension Feb 14, 2025
Copy link

coderabbitai bot commented Feb 14, 2025

Walkthrough

This pull request modifies the access control annotations on several REST endpoints. In the ResultResource and ParticipationResource classes, the @AllowedTools(ToolTokenType.SCORPIO) annotation and corresponding import statements have been removed, thereby simplifying access control. Conversely, the ExerciseResource class now includes the annotation and its import statements to enforce tool-based restrictions on the getExercise method.

Changes

File(s) Change Summary
.../assessment/web/ResultResource.java
.../exercise/web/ParticipationResource.java
Removed the @AllowedTools(ToolTokenType.SCORPIO) annotation (and related imports in ResultResource) from methods that previously applied security restrictions.
.../exercise/web/ExerciseResource.java Added the @AllowedTools(ToolTokenType.SCORPIO) annotation and corresponding import statements to the getExercise method to enforce access control.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant ER as ExerciseResource
    participant SM as SecurityModule
    User->>ER: Request getExercise(exerciseId)
    ER->>SM: Validate @AllowedTools(ToolTokenType.SCORPIO)
    SM-->>ER: Token Valid/Invalid
    ER-->>User: Return exercise details
Loading
sequenceDiagram
    participant User as User
    participant RR as ResultResource
    User->>RR: Request getResultDetails(resultId)
    RR-->>User: Return build result details
Loading

Possibly related PRs

Suggested labels

config-change, programming

Suggested reviewers

  • iyannsch
  • SimonEntholzer
  • JohannesStoehr
  • FelixTJDietrich

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 PMD (7.8.0)
src/main/java/de/tum/cit/aet/artemis/exercise/web/ExerciseResource.java

[ERROR] Error at ruleset.xml:58:5
56|
57|
58|
^^^^^ Unable to find referenced rule BooleanInstantiation; perhaps the rule name is misspelled?

59|
60|
[WARN] Warning at ruleset.xml:66:5
64|
65|
66|
^^^^^ Use Rule name category/java/bestpractices.xml/DefaultLabelNotLastInSwitch instead of the deprecated Rule name category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt. PMD 8.0.0 will remove support for this deprecated Rule name usage.

67|
68|
[ERROR] Error at ruleset.xml:71:5
69|
70|
71|
^^^^^ Unable to find referenced rule DontImportJavaLang; perhaps the rule name is misspelled?

72|
73|
[ERROR] Error at ruleset.xml:75:5
73|
74|
75|
^^^^^ Unable to find referenced rule DuplicateImports; perhaps the rule name is misspelled?

76|
77|
[ERROR] Error at ruleset.xml:78:5
76|
77|
78|
^^^^^ Unable to find referenced rule EmptyFinallyBlock; perhaps the rule name is misspelled?

79|
80|
[ERROR] Error at ruleset.xml:79:5
77|
78|
79|
^^^^^ Unable to find referenced rule EmptyIfStmt; perhaps the rule name is misspelled?

80|
81|
[ERROR] Error at ruleset.xml:81:5
79|
80|
81|
^^^^^ Unable to find referenced rule EmptyInitializer; perhaps the rule name is misspelled?

82|
83|
[ERROR] Error at ruleset.xml:82:5
80|
81|
82|
^^^^^ Unable to find referenced rule EmptyStatementBlock; perhaps the rule name is misspelled?

83|
84|
[ERROR] Error at ruleset.xml:83:5
81|
82|
83|
^^^^^ Unable to find referenced rule EmptyStatementNotInLoop; perhaps the rule name is misspelled?

84|
85|
[ERROR] Error at ruleset.xml:84:5
82|
83|
84|
^^^^^ Unable to find referenced rule EmptySwitchStatements; perhaps the rule name is misspelled?

85|
86|
[ERROR] Error at ruleset.xml:85:5
83|
84|
85|
^^^^^ Unable to find referenced rule EmptySynchronizedBlock; perhaps the rule name is misspelled?

86|
87|
[ERROR] Error at ruleset.xml:86:5
84|
85|
86|
^^^^^ Unable to find referenced rule EmptyTryBlock; perhaps the rule name is misspelled?

87|
88|
[ERROR] Error at ruleset.xml:87:5
85|
86|
87|
^^^^^ Unable to find referenced rule EmptyWhileStmt; perhaps the rule name is misspelled?

88|
89|
[ERROR] Error at ruleset.xml:90:5
88|
89|
90|
^^^^^ Unable to find referenced rule ExcessiveClassLength; perhaps the rule name is misspelled?

91|
92|
[ERROR] Error at ruleset.xml:91:5
89|
90|
91|
^^^^^ Unable to find referenced rule ExcessiveMethodLength; perhaps the rule name is misspelled?

92|
93|
[ERROR] Error at ruleset.xml:106:5
104|
105|
106|
^^^^^ Unable to find referenced rule ImportFromSamePackage; perhaps the rule name is misspelled?

107|
108|
[ERROR] Error at ruleset.xml:119:5
117|
118|
119|
^^^^^ Unable to find referenced rule MissingBreakInSwitch; perhaps the rule name is misspelled?

120|
121|
[WARN] Warning at ruleset.xml:124:5
122|
123|
124|
^^^^^ Use Rule name category/java/errorprone.xml/NonCaseLabelInSwitch instead of the deprecated Rule name category/java/errorprone.xml/NonCaseLabelInSwitchStatement. PMD 8.0.0 will remove support for this deprecated Rule name usage.

125|
126|
[ERROR] Error at ruleset.xml:134:9
132|
133| // It's okay to use short variable names in DTOs, e.g. "id" or "name"
134| ./de/tum/in/www1/artemis/web/rest/dto/.
^^^^^^^^^^^^^^^^ Unexpected element 'exclude-pattern' in rule ShortVariable

135|
136|
[ERROR] Error at ruleset.xml:137:5
135|
136|
137|
^^^^^ Unable to find referenced rule SimplifyBooleanAssertion; perhaps the rule name is misspelled?

138|
139|
[WARN] Warning at ruleset.xml:184:5
182|
183|
184|
^^^^^ Use Rule name category/ecmascript/errorprone.xml/InaccurateNumericLiteral instead of the deprecated Rule name category/ecmascript/errorprone.xml/InnaccurateNumericLiteral. PMD 8.0.0 will remove support for this deprecated Rule name usage.

185|
186|
[ERROR] Cannot load ruleset category/vm/bestpractices.xml: Cannot resolve rule/ruleset reference 'category/vm/bestpractices.xml'. Make sure the resource is a valid file or URL and is on the CLASSPATH. Use --debug (or a fine log level) to see the current classpath.
[WARN] Progressbar rendering conflicts with reporting to STDOUT. No progressbar will be shown. Try running with argument -r to output the report to a file instead.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbe907c and dcaa924.

📒 Files selected for processing (3)
  • src/main/java/de/tum/cit/aet/artemis/assessment/web/ResultResource.java (0 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exercise/web/ExerciseResource.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/exercise/web/ParticipationResource.java (0 hunks)
💤 Files with no reviewable changes (2)
  • src/main/java/de/tum/cit/aet/artemis/exercise/web/ParticipationResource.java
  • src/main/java/de/tum/cit/aet/artemis/assessment/web/ResultResource.java
🧰 Additional context used
📓 Path-based instructions (1)
`src/main/java/**/*.java`: naming:CamelCase; principles:{sin...

src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

  • src/main/java/de/tum/cit/aet/artemis/exercise/web/ExerciseResource.java
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: Call Build Workflow / Build and Push Docker Image
  • GitHub Check: Call Build Workflow / Build .war artifact
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: client-style
  • GitHub Check: client-tests
  • GitHub Check: server-style
  • GitHub Check: server-tests
  • GitHub Check: Analyse
🔇 Additional comments (2)
src/main/java/de/tum/cit/aet/artemis/exercise/web/ExerciseResource.java (2)

40-41: LGTM! Clean import additions.

The new imports for security annotations are properly organized and follow Java conventions.


139-142:

✅ Verification successful

Security enhancement looks good!

The addition of @AllowedTools(ToolTokenType.SCORPIO) properly restricts this endpoint to VSCode extension access while maintaining existing role-based security with @EnforceAtLeastStudent.

Let's verify that this is the only endpoint that needs SCORPIO tool token access:


🏁 Script executed:

#!/bin/bash
# Search for other endpoints that might need SCORPIO tool token access
rg -l "ToolTokenType\.SCORPIO" --type java

Length of output: 677


Security annotation update verified!

The addition of @AllowedTools(ToolTokenType.SCORPIO) in ExerciseResource.java is consistent with its usage elsewhere in the codebase (e.g., in CourseResource.java, AccountResource.java, ParticipationResource.java, and PlantUmlResource.java). This comprehensive use confirms that the security model combining tool-based access control with the existing @EnforceAtLeastStudent role check is applied uniformly across endpoints. No additional adjustments are necessary.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@helios-aet helios-aet bot temporarily deployed to artemis-test3.artemis.cit.tum.de February 14, 2025 09:44 Inactive
@krusche krusche changed the title Development: Update Endpoints used by Scorpio VSCode Extension Development: Update endpoints used by Scorpio Feb 15, 2025
@krusche krusche merged commit 161b564 into develop Feb 15, 2025
30 of 36 checks passed
@krusche krusche deleted the chore/update-scorpio-endpoints branch February 15, 2025 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assessment Pull requests that affect the corresponding module exercise Pull requests that affect the corresponding module ready to merge server Pull requests that update Java code. (Added Automatically!)
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

2 participants