feat: cross ns security#226
Merged
Merged
Conversation
22b64a1 to
46d6d61
Compare
baab210 to
899640d
Compare
marcdavoli
approved these changes
Dec 2, 2025
There was a problem hiding this comment.
Pull request overview
This PR implements a security feature that restricts cross-namespace access to kubeconfig secrets. ResourceSyncs can only use kubeconfig secrets from other namespaces if those secrets have the sinker.influxdata.io/allowed-namespaces annotation containing a regex pattern that matches the ResourceSync's namespace.
Key Changes:
- Added namespace-based access control for kubeconfig secrets via regex annotation
- Error messages for unauthorized access are masked to prevent information leakage
- Comprehensive test coverage including edge cases and concurrent access scenarios
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/resources.rs |
Adds ALLOWED_NAMESPACES_ANNOTATION constant and changes visibility of annotation constants to pub const |
src/resource_extensions.rs |
Implements security validation logic in cluster_client() and adds verify_kubeconfig_secret_access() function with comprehensive tests |
src/lib.rs |
Adds UnauthorizedKubeconfigAccess error variant for security violations |
Cargo.toml |
Adds regex dependency (v1.12.2) for pattern matching |
Cargo.lock |
Updates lockfile with regex dependency and winnow version bump |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let mut rng = StdRng::seed_from_u64(84); | ||
|
|
||
| for _ in 0..6 { | ||
| let ns = format!("proj-{}", rng.random_range(10_u8..99_u8)); |
There was a problem hiding this comment.
The method random_range does not exist in the rand 0.9.x Rng trait. The correct method is gen_range. This should be:
let ns = format!("proj-{}", rng.gen_range(10_u8..99_u8));
Suggested change
| let ns = format!("proj-{}", rng.random_range(10_u8..99_u8)); | |
| let ns = format!("proj-{}", rng.gen_range(10_u8..99_u8)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://github.com/influxdata/starfleet/issues/184
Prevents the use of kubeconfig secrets outside of the
ResourceSync's namespace except when the kubeconfig secret has the annotationsinker.influxdata.io/allowed-namespaces. The contents of the annotation must be a valid regex and Sinker requires that theResourceSync's namespace matches the expression.