Validate .spec.name and apply its default consistently - #584
Merged
Conversation
.spec.name is projected into workload containers as a volume mount
directory at $SERVICE_BINDING_ROOT/<name>, but was never validated.
path.Join cleans its result, so `spec.name: ../../etc` produced
MountPath: /etc, mounting the bound Secret over an arbitrary directory in
every workload matched by .spec.workload.
The specification already requires binding names to match
[a-z0-9\-\.]{1,253}; the rule simply was not implemented. Enforce it,
anchored, and additionally reject "." and "..". Those are the only values
in that character set whose path.Join result can leave the intended
directory: the set contains no "/", so the name is always one path
element, and Clean gives special meaning to exactly those two.
Name validation is ratcheted on update, so ServiceBindings created before
this rule remain writable and deletable -- deletion clears a finalizer,
which is an UPDATE, and would otherwise be rejected.
Signed-off-by: Rashed Kamal <rashed.kamal@broadcom.com>
rashedkvm
force-pushed
the
validate-binding-name
branch
from
August 11, 2026 22:30
db2f29e to
a501c69
Compare
scothis
reviewed
Aug 12, 2026
scothis
left a comment
Member
There was a problem hiding this comment.
Thanks for finding this issue and proposing a fix.
Inline comments are minor. I can polish them up if you don't have capacity.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #584 +/- ##
==========================================
+ Coverage 73.01% 73.27% +0.25%
==========================================
Files 28 28
Lines 1460 1474 +14
==========================================
+ Hits 1066 1080 +14
Misses 324 324
Partials 70 70 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Move the name format check next to the immutable field checks in ValidateUpdate, so the old object no longer needs to be plumbed through validate() and ServiceBindingSpec.validate(). ValidateUpdate applies the check only when the value changes, so that objects predating the rule are not frozen by it: deleting one clears a finalizer, which is an update. Signed-off-by: Rashed Kamal <rashed.kamal@broadcom.com>
rashedkvm
force-pushed
the
validate-binding-name
branch
from
August 12, 2026 13:53
4f3fbb2 to
edca2ef
Compare
scothis
reviewed
Aug 12, 2026
Signed-off-by: Scott Andrews <scott@andrews.me>
scothis
enabled auto-merge (squash)
August 12, 2026 15:53
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.
.spec.nameis projected into workload containers as a volume mount directory at$SERVICE_BINDING_ROOT/<name>, but nothing validated it.path.Joincleans its result, so aServiceBinding with
spec.name: "../../etc"producedMountPath: /etc— mounting the bound Secretover an arbitrary directory in every workload matched by
.spec.workload.The specification already forbids this. From Workload Projection:
That rule simply was not implemented. This PR implements it.