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

Integrated code lifecycle: Add access log for repositories #9184

Merged
merged 81 commits into from
Sep 19, 2024

Conversation

SimonEntholzer
Copy link
Contributor

@SimonEntholzer SimonEntholzer commented Aug 4, 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 multiple integration tests (Spring) related to the features (with a high test coverage).
  • 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 (e.g. using paging).
  • I strictly followed the principle of data economy for all client-server REST calls.
  • 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 added multiple integration tests (Jest) related to the features (with a high test coverage), while following the test guidelines.
  • I added authorities to all new routes and checked the course groups for displaying navigation elements (links, buttons).
  • I documented the TypeScript code using JSDoc style.
  • I added multiple screenshots/screencasts of my UI changes.
  • 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).

Motivation and Context

Similar to gitlab we want to be able to log accesses to LocalVC repositories. Especially knowing the pushing user, and the IP address could help to prevent fraud (e.g. during exams). Further this helps us quantitively see, which authentication mechanisms users use (SSH, password or tokens).
We want to show these logs to instructors of a course/exercise. This UI will be implemented in a follow up.

Description

This PR adds a access log for LocalVC repositories. When a user pushes or pulls, a log entry is written to the database.
An entry in the new access log table contains:

user_id
participation_id
name
email
repository_action_type   ∈ {READ, WRITE}
authentication_mechanism ∈ {SSH, PASSWORD, USER_VCS_ACCESS_TOKEN, PARTICIPATION_VCS_ACCESS_TOKEN}
commit_hash
ip_address

-> see screenshot below

Steps for Testing

This change should have no visible effect.

  1. With a student account, go to a programming exercise, and clone the repository via the clone link (over SSH/token or just HTTPs)
  2. Make sure, clone/push/pull work as they should.
  3. With an instructor of that exercise, go to the participations page, use the code button to open the repository
4. Go to the repository view, and use the "open access log" button, to view the access log for the repository. 5. Check that the entries make sense.

Testserver States

Note

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







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

Test Coverage

Screenshots

The vcs-access-log button in the code editor (repository view):
image

The new vcs-access-log page:
image

In the database:
image

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added methods to retrieve VCS access logs for specific participation and exercise repositories.
    • Introduced a new component to display VCS access logs, enhancing user experience with clear visibility of access patterns.
    • Enhanced logging of user actions in the code editor through integration with the VcsAccessLogService.
    • Added new API endpoints for instructors to access VCS access logs.
  • Bug Fixes

    • Improved error handling for VCS access log retrieval requests.
    • Enhanced security and audit capabilities for user access logging.

@github-actions github-actions bot added server Pull requests that update Java code. (Added Automatically!) database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. labels Aug 4, 2024
@SimonEntholzer SimonEntholzer changed the title Development: Log access to LocalVC repositories Development: Create access log for LocalVC repositories Aug 5, 2024
@dfuchss dfuchss self-requested a review August 6, 2024 21:52
Copy link

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

@github-actions github-actions bot added the stale label Aug 14, 2024
@github-actions github-actions bot removed the stale label Aug 15, 2024
coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 19, 2024
@SimonEntholzer SimonEntholzer changed the title Development: Create access log for LocalVC repositories Development: Add access log for LocalVC repositories Aug 20, 2024
@SimonEntholzer SimonEntholzer marked this pull request as ready for review August 20, 2024 09:56
@SimonEntholzer SimonEntholzer requested a review from a team as a code owner August 20, 2024 09:56
Copy link

coderabbitai bot commented Aug 20, 2024

Walkthrough

The changes introduce a VcsAccessLogRepository and a VcsAccessLogService to manage version control system (VCS) access logs within the Artemis application. The repository provides methods for querying logs based on participation ID and commit status, while the service handles log storage and updates. Additionally, a new Angular component is created to display these logs, and the ProgrammingExerciseParticipationService is updated to include methods for log retrieval. Integration and unit tests are also added to ensure functionality.

Changes

Files Change Summary
.../repository/VcsAccessLogRepository.java Introduced a repository interface for VcsAccessLog, with methods to find logs by participation ID and commit status.
.../service/VcsAccessLogService.java Added a service to manage VCS access logs, including methods to store logs and update commit hashes.
.../service/programming/ProgrammingExerciseParticipationService.java Added methods to retrieve VCS access logs for participations and repositories.
.../localvc/vcs-repository-access-log-view/vcs-repository-access-log-view.component.ts Created a component to display VCS access logs, loading logs based on participation or exercise ID.
.../localvcci/LocalVCLocalCIParticipationIntegrationTest.java Enhanced integration tests to verify retrieval of VCS access logs.
.../spec/component/localvc/vcs-repository-access-log-view.component.spec.ts Added unit tests for the VCS access log view component.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Service as ProgrammingExerciseParticipationService
    participant Component as VcsRepositoryAccessLogViewComponent
    participant LogRepo as VcsAccessLogRepository

    User->>Component: Request VCS Access Logs
    Component->>Service: Get VCS Access Log for Participation
    Service->>LogRepo: Retrieve Logs by Participation ID
    LogRepo-->>Service: Return Logs
    Service-->>Component: Provide Logs
    Component-->>User: Display VCS Access Logs
Loading
sequenceDiagram
    participant User
    participant RepoService as RepositoryService
    participant LogService as VcsAccessLogService

    User->>RepoService: Commit Changes
    RepoService->>LogService: Store Code Editor Access Log
    LogService-->>RepoService: Log Stored
    RepoService-->>User: Changes Committed
Loading

Possibly related PRs

Suggested labels

component:Programming, priority:high, bugfix


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 generate interesting stats about this repository and render them as a table.
    -- @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 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.

Tip

Early access features: enabled

We are currently testing the following features in early access:

  • OpenAI o1 for code reviews: OpenAI's new o1 model is being tested for code reviews. This model has advanced reasoning capabilities and can provide more nuanced feedback on your code.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 20, 2024
Copy link
Contributor

@pzdr7 pzdr7 left a comment

Choose a reason for hiding this comment

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

Reapprove

@krusche krusche added this to the 7.5.3 milestone Sep 14, 2024
Copy link
Contributor

@dfuchss dfuchss left a comment

Choose a reason for hiding this comment

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

Code

@krusche krusche modified the milestones: 7.5.3, 7.5.4 Sep 18, 2024
@krusche krusche changed the title Development: Add access log for LocalVC repositories Integrated code lifecycle: Add access log for LocalVC repositories Sep 19, 2024
@krusche krusche changed the title Integrated code lifecycle: Add access log for LocalVC repositories Integrated code lifecycle: Add access log for repositories Sep 19, 2024
@krusche krusche merged commit 2d38488 into develop Sep 19, 2024
23 of 35 checks passed
@krusche krusche deleted the feature/repository-access-logging branch September 19, 2024 20:35
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!) config-change Pull requests that change the config in a way that they require a deployment via Ansible. database Pull requests that update the database. (Added Automatically!). Require a CRITICAL deployment. ready for review 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.

10 participants