-
Notifications
You must be signed in to change notification settings - Fork 5k
fix(robot): system robots with wildcard permissions can create project robots #22352
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
base: main
Are you sure you want to change the base?
fix(robot): system robots with wildcard permissions can create project robots #22352
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22352 +/- ##
===========================================
+ Coverage 45.36% 65.88% +20.51%
===========================================
Files 244 1072 +828
Lines 13333 115962 +102629
Branches 2719 2927 +208
===========================================
+ Hits 6049 76397 +70348
- Misses 6983 35331 +28348
- Partials 301 4234 +3933
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
I've pushed two additional commits: Commit 952ea2a - Formatting
Commit 671c112 - Tests
The 163 line increase is mostly test code (155 lines). The original implementation remains unchanged. |
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.
Overall LGTM,
Tested, it works I can now create Project Robot Accounts with system robot account
I would suggest to remove the additional formatting in test_robot_account.py
671c112
to
c267182
Compare
…roject robots System robots with wildcard project permissions (/project/*/robot) were unable to create project-level robots due to insufficient RBAC validation. This fix enhances the permission validation logic with two layers: 1. Enhanced requireAccess() method to handle wildcard permissions for system robots 2. Added fallback creator robot lookup in CreateRobot() method Also includes helper function hasWildcardRobotPermission() to reduce code duplication and comprehensive integration test. Fixes goharbor#21406 Signed-off-by: Thomas <thomas@quantum-sicarius.za.net> Signed-off-by: Thomas Scholtz <thomas@labs.epiuse.com>
- Run gofmt on Go files to fix formatting issues - Apply black formatter to Python test file - Fix Python linting issues (unused imports, comparison style) - Remove unused local variables in Python tests This resolves CI formatting failures. Signed-off-by: Thomas Scholtz <thomas@labs.epiuse.com>
…ements - Add TestHasWildcardRobotPermission with 9 test cases covering: - Positive cases: wildcard project permissions for robot actions - Negative cases: wrong resource, action, scope, or nil permissions - Edge cases: multiple permissions and boundary conditions - Enhance test_03_SystemRobotCreatesProjectRobot integration test: - Add repository:pull permission to work around robot library constraints - Improve test documentation and permission setup - Ensure test properly validates system robot creation capabilities - Validates privilege escalation prevention in existing test suite - Ensures comprehensive coverage of wildcard permission scenarios - Provides thorough testing of system robot functionality The unit tests verify the core hasWildcardRobotPermission helper function that enables system robots with wildcard permissions to create project robots while maintaining security boundaries and preventing privilege escalation. Signed-off-by: Thomas Scholtz <thomas@labs.epiuse.com>
- Revert excessive black formatting changes from previous commit - Remove unused harbor_url import from test_robot_account.py - Preserve test_03_SystemRobotCreatesProjectRobot functionality - Maintain original project formatting style for maintainer review This addresses maintainer feedback to undo black formatting while keeping functional improvements and the new integration test intact. Signed-off-by: Thomas Scholtz <thomas@labs.epiuse.com>
c267182
to
f705aac
Compare
I'm submitting this fix for issue #21406 where system robots with wildcard project permissions (/project/*/robot) couldn't create project-level robots.
Being new to Harbor development, I want to be transparent about the scope of this change and request thorough review from experienced maintainers.
Main change in src/common/security/robot/context.go:117:
Root cause: System robots were missing consistent RBAC policy filtering - project-level robots had filterRobotPolicies but system robots didn't, creating permission inconsistencies.
Additional changes:
Testing completed:
Areas needing review:
This is a focused fix addressing the specific permission gap, but given the RBAC implications I'd appreciate careful review.
Fixes #21406