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: Refactor RepositoryAccessService and plagiarism access check #8209

Merged
merged 28 commits into from
Mar 24, 2024

Conversation

mateusmm01
Copy link
Contributor

@mateusmm01 mateusmm01 commented Mar 16, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I strictly followed the server coding and design guidelines.
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data.
  • I strictly followed the client coding and design guidelines.
  • Following the theming guidelines, I specified colors only in the theming variable files and checked that the changes look consistent in both the light and the dark theme.
  • I documented the TypeScript code using JSDoc style.
  • I translated all newly inserted strings into English and German.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).
  • I tested all changes and their related features with all corresponding user types on a test server configured with Gitlab and Jenkins.
  • I tested all changes and their related features with all corresponding user types on a test server configured with Bitbucket and Bamboo.

Motivation and Context

Currently, the RepositoryAccessService isn't very well written or easily readable. It plays a vital role in the security of Artemis programming exercises. Therefore, it should be refactored following these rules:
https://docs.artemis.cit.tum.de/admin/accessRights.html#programming-exercises-repository-access

Description

RepositoryAccessService was refactored. We also fetch the files for the plagiarism check separately with their own endpoints. These check the plagiarism access instead of the general repository access.

Steps for Testing

Prerequisites:

  • 1 Admin

  • 1 Instructor

  • 1 Tutor

  • 1 Student

  • 1 Programming Exercises

Create different Programming Exercises with different rules and check that you can only access the repositories in the expected way (https://docs.artemis.cit.tum.de/admin/accessRights.html#programming-exercises-repository-access)

Also check that instructors and students can still view the plagiarism views as expected

Exam Mode Testing

Prerequisites:

  • 1 Admin

  • 1 Instructor

  • 1 Tutor

  • 1 Student

  • 1 Exam with Programming Exercises

Create an Exam with different Programming Exercises with different rules and check that you can only access the repositories in the expected way (https://docs.artemis.cit.tum.de/admin/accessRights.html#programming-exercises-repository-access)

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked







Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

Screenshots

Summary by CodeRabbit

  • New Features
    • Introduced a method to verify access to plagiarism submissions.
    • New endpoints to retrieve files for plagiarism view in programming exercises.
  • Refactor
    • Simplified the constructor in RepositoryAccessService.
    • Enhanced access control logic in RepositoryAccessService to handle user roles and actions more effectively.
    • Improved file retrieval process in RepositoryService and RepositoryResource for better readability and maintainability.

@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) client Pull requests that update TypeScript code. (Added Automatically!) labels Mar 16, 2024
@mateusmm01 mateusmm01 marked this pull request as ready for review March 20, 2024 14:16
@mateusmm01 mateusmm01 requested a review from a team as a code owner March 20, 2024 14:16
Copy link

coderabbitai bot commented Mar 20, 2024

Walkthrough

This update introduces significant improvements to repository access control, file retrieval, and plagiarism functionality within the system. It simplifies the constructor of the RepositoryAccessService, enhances access control logic, adds methods for plagiarism submission access and file retrieval, and establishes a new service for managing programming exercise repositories. Additionally, it refactors existing methods for better maintainability and readability, ensuring a more robust handling of repositories and their associated files.

Changes

File Path Change Summary
src/main/java/de/tum/in/www1/artemis/service/RepositoryAccessService.java
src/main/java/de/tum/in/www1/artemis/web/rest/repository/RepositoryResource.java
Simplified constructor, refactored access control, added plagiarism submission access verification.
Refactored file retrieval logic for improved maintainability.
src/main/java/de/tum/in/www1/artemis/service/RepositoryParticipationService.java Introduced to manage programming exercise repositories and participations.
src/main/java/de/tum/in/www1/artemis/service/RepositoryService.java Added method to retrieve file content from a repository.
src/main/java/de/tum/in/www1/artemis/web/rest/repository/RepositoryProgrammingExerciseParticipationResource.java Added method for plagiarism view, refactored repository retrieval, added new endpoints for file access.

Related issues

  • Plagiarism, Programming Exercises: Side-by-side view incorrectly handles HTTP 409 responses from /api/repository/*/files #7026: The improvements in handling repository access and file retrieval, especially for plagiarism checks, could potentially address issues with incorrect rendering and error handling during plagiarism checks. This PR's enhancements in access control and file management might be relevant for ensuring accurate display and functionality in plagiarism views.
  • Exam: Divide the Testing Process into Steps #6621: Although this PR does not directly address the specifics of handling dummy tests in exam programming exercises, the underlying improvements in repository and file management could indirectly support more robust configurations and operations related to exams and testing processes. However, the direct connection is tenuous, and this linkage is more speculative without specific changes targeting exam processes.

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>.
    • Generate unit-tests 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 tests 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Member

@julian-christl julian-christl left a comment

Choose a reason for hiding this comment

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

Good job in general, I have a few remarks

mateusmm01 and others added 4 commits March 21, 2024 12:15
…ervice.java

Co-authored-by: Julian Christl <julian.christl@tum.de>
…ervice.java

Co-authored-by: Julian Christl <julian.christl@tum.de>
…ervice.java

Co-authored-by: Julian Christl <julian.christl@tum.de>
…ervice.java

Co-authored-by: Julian Christl <julian.christl@tum.de>
…access-service' into development/refactor-repository-access-service
julian-christl
julian-christl previously approved these changes Mar 21, 2024
Copy link
Member

@julian-christl julian-christl left a comment

Choose a reason for hiding this comment

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

That's also a nice way of doing it. Good job with the changes! Code looks good now!

…velopment/refactor-repository-access-service
mateusmm01 and others added 2 commits March 22, 2024 15:39
Strohgelaender
Strohgelaender previously approved these changes Mar 22, 2024
Copy link
Contributor

@Strohgelaender Strohgelaender left a comment

Choose a reason for hiding this comment

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

code looks good to me.

Tested locally, students are able to see the other student's code (in case of a plagriarism accousation) only after the deadline.

Copy link
Contributor

@milljoniaer milljoniaer left a comment

Choose a reason for hiding this comment

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

Code LGTM

Copy link
Contributor

@laurenzfb laurenzfb left a comment

Choose a reason for hiding this comment

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

demonstrated in testing session. lgtm

Copy link
Member

@julian-christl julian-christl left a comment

Choose a reason for hiding this comment

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

Reapprove code, changes look good

@krusche
Copy link
Member

krusche commented Mar 23, 2024

10 e2e tests consistently fail. Please double check what is happening there

@krusche krusche added this to the 6.9.4 milestone Mar 24, 2024
@krusche krusche merged commit fd8f9cd into develop Mar 24, 2024
26 of 32 checks passed
@krusche krusche deleted the development/refactor-repository-access-service branch March 24, 2024 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) ready to merge server Pull requests that update Java code. (Added Automatically!) tests
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

6 participants