-
Notifications
You must be signed in to change notification settings - Fork 305
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
Programming exercises
: Add logging of failed authorization attempts to the VCS access log
#10369
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request introduces modifications across authentication and version control access handling. The changes extend the enumeration of authentication mechanisms by adding a new constant Changes
Suggested labels
Suggested reviewers
✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code seems fine, see my inline comments.
just as a pointer: some server tests are currently failing as no exception seem to be thrown anymore. also, coverage is mildly violated 🙃
src/main/java/de/tum/cit/aet/artemis/programming/service/localvc/LocalVCServletService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also tested on TS6, works fine.
Code + Manual test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code + manual test, LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm
121de51
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-approve after re-throwing exception instead of throwing a new one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions
src/main/java/de/tum/cit/aet/artemis/programming/domain/AuthenticationMechanism.java
Outdated
Show resolved
Hide resolved
src/main/java/de/tum/cit/aet/artemis/programming/service/localvc/LocalVCServletService.java
Outdated
Show resolved
Hide resolved
f659e98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change. Code looks good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/main/java/de/tum/cit/aet/artemis/programming/service/localvc/AuthenticationContext.java (3)
7-26
: Add JavaDoc documentation to improve code maintainability.The new
AuthenticationContext
interface design is clean and follows good principles, but would benefit from proper documentation explaining:
- The purpose of this interface
- How it relates to logging failed authorization attempts
- When to use each implementation
Add documentation like:
/** * Provides a common interface for accessing authentication context information * from different sources (SSH sessions and HTTP requests). * Used primarily for logging failed authorization attempts to the VCS access log. */ public sealed interface AuthenticationContext { /** * Implementation for SSH-based authentication. */ record Session(ServerSession session) implements AuthenticationContext { // ... } /** * Implementation for HTTP-based authentication. */ record Request(HttpServletRequest request) implements AuthenticationContext { // ... } /** * Returns the IP address of the client. * @return the IP address as a string */ String getIpAddress(); }
12-14
: Consider adding null checks for defensive programming.The implementation assumes that
session
will never be null. If there's a possibility of null values, consider adding defensive checks.@Override public String getIpAddress() { - return session.getClientAddress().toString(); + return session != null && session.getClientAddress() != null + ? session.getClientAddress().toString() + : "unknown"; }
20-22
: Consider adding null checks for defensive programming.Similar to the Session implementation, consider adding checks for null request.
@Override public String getIpAddress() { - return request.getRemoteAddr(); + return request != null ? request.getRemoteAddr() : "unknown"; }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/java/de/tum/cit/aet/artemis/programming/domain/AuthenticationMechanism.java
(1 hunks)src/main/java/de/tum/cit/aet/artemis/programming/service/localvc/AuthenticationContext.java
(1 hunks)src/main/java/de/tum/cit/aet/artemis/programming/service/localvc/LocalVCServletService.java
(5 hunks)src/main/java/de/tum/cit/aet/artemis/programming/service/localvc/SshGitLocationResolverService.java
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- src/main/java/de/tum/cit/aet/artemis/programming/domain/AuthenticationMechanism.java
- src/main/java/de/tum/cit/aet/artemis/programming/service/localvc/SshGitLocationResolverService.java
- src/main/java/de/tum/cit/aet/artemis/programming/service/localvc/LocalVCServletService.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/programming/service/localvc/AuthenticationContext.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-tests
- GitHub Check: server-style
- GitHub Check: Analyse
Checklist
General
Server
Changes affecting Programming Exercises
Motivation and Context
At the moment the VCS access log, logs only fully successful interactions, and interactions failing at the authentication step already.
When pushing/pulling fails at the authorization, Artemis writes no VCS access log, in the case of HTTPS not even a server log.
Description
Steps for Testing
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.
Review Progress
Code Review
Manual Tests
Test Coverage
Screenshots
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes