feat: Add optional namespace support for secretKeyRef in Analysis argument#4648
feat: Add optional namespace support for secretKeyRef in Analysis argument#4648Mujib-Ahasan wants to merge 3 commits intoargoproj:masterfrom
Conversation
…ument Signed-off-by: Mujib Ahasan <[email protected]>
|
I will write the unit tests shortly. |
Published E2E Test Results 4 files 4 suites 3h 54m 55s ⏱️ For more details on these failures, see this check. Results for commit b97218d. ♻️ This comment has been updated with latest results. |
Published Unit Test Results2 446 tests 2 446 ✅ 3m 18s ⏱️ Results for commit b97218d. ♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4648 +/- ##
==========================================
+ Coverage 84.87% 84.92% +0.04%
==========================================
Files 164 164
Lines 18907 18990 +83
==========================================
+ Hits 16048 16127 +79
- Misses 2001 2006 +5
+ Partials 858 857 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Mujib Ahasan <[email protected]>
|
test cases have been added! Ready for the review. |
|
I am not sure I love the security implications of this, the usage also makes it easy to say pull secrets from any listed namespace in the allowed list so in say multi team setups if you allow namespace a and b but you want to not let b see a you can't currently in this PR. I wonder if a middle ground would be to just do something under the secret ref like controllerNamespace: true that then pulls secrets from the namespace the controller is in, this just make it seem more limited to a single namespace? I do see the issue with ClusterAnalysis needing secrets though, just not sure which way is the best option yet. |
|
The PR is also missing any kind of documentation. Not only it needs documentation, but also we should place some big red warnings about the security implications that Zach already highlighted. Since this is disabled by default and admins need to enable it, I think it is understandable that they choose the risk. But they should at least know about the risk from the docs. Also the messages "cross-namespace secret references are disabled" and "cross-namespace secret references to namespace %q are not allowed" are not very descriptive. It would be better to explain to the user where the error comes from (the analysis) and what causes it (the namespace property there). I don't see any e2e tests. Maybe we need some? Or do the unit tests cover everything? |
I totally understand the risk. and I am gonna add them properly.
Sure, I will update these shortly.🙂
probably, I need to take a deeper look. |
Signed-off-by: Mujib Ahasan <[email protected]>
|
|
I have updated the docs and also error messages. also IMO these unit test are sufficient for this changes because the behavior is focused in analysis args resolution than in a broader rollout flowing. Still, let me know if I need to work on it. |
|
I still think I want to scope it down to a single namespace not a list because it better aligns the k8s rbac with the behavior vs documenting it, because at that point if admins want someone to be able to see the secrests at the k8s rbac level they have to grant them access to the single namespace and they are not misslead in say team a can put secrets in namespace a and team b can use namespace b, if they just miss or ignore the fact that team b can pull teams a secrete via analysis. Would a single namespace meet your requimrnets? |
|
Makes sense, I am ok with either way. I think for single namespace we still have the copy secrets to a single namespace. Although the risk is less here but manual work is there. for multiple namespace, high risk and no manual work. I am confused😅. Even though the risks are documented, admins have to choose their security approaches. |


Description
This PR adds support for referencing secrets from explicitly allowed namespaces when resolving
secretKeyRefin Analysis arguments.so currently, secrets referenced by
ClusterAnalysisTemplatemust be copied into every namespace where the template is used. This PR allows referencing a shared secret stored in an admin-controlled namespace instead. This PR also takes care of backward compatibility.changes
CRDs have been generated
Added an optional
namespacefield toSecretKeyReImplemented cross-namespace secret resolution in resolveArgs()
Added controller flags:
-
--enable-cross-namespace-secret-refs-
--allowed-secret-ref-namespacesAdded validation to ensure cross-namespace secret access is: disabled by default (backward compatibilty)
restricted to explicitly allowed namespace only
fixes: #4611
Checklist:
"fix(controller): Updates such and such. Fixes #1234".