fix: assorted small validation and robustness fixes#2410
Closed
andrewwhitecdw wants to merge 3 commits into
Closed
fix: assorted small validation and robustness fixes#2410andrewwhitecdw wants to merge 3 commits into
andrewwhitecdw wants to merge 3 commits into
Conversation
validate_label_key and validate_label_value used Unicode-aware char::is_alphanumeric(), so values like 'café' or '日本語' passed gateway validation even though the Kubernetes label spec (([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])? is ASCII-only and the API server rejects such labels later. The same functions already validate the key prefix with ASCII-only checks. Use is_ascii_alphanumeric() and add regression tests for Unicode keys and values. Signed-off-by: Andrew White <andrewh@cdw.com>
Two display paths in sandbox policy commands sliced server-supplied strings without guarding: - sandbox_policy_set used &resp.policy_hash[..12] unconditionally; an empty or short proto3 hash field would panic. Use the existing short_hash() helper, as nearby call sites already do. - The policy revision table truncated load_error at a fixed byte index (&rev.load_error[..40]), panicking on multi-byte UTF-8 in server error messages. Back off to a char boundary instead. Signed-off-by: Andrew White <andrewh@cdw.com>
The IANA dynamic/private (ephemeral) port range is 49152-65535 inclusive, but the check used port > 49152, silently omitting the advisory note for port 49152 itself. Signed-off-by: Andrew White <andrewh@cdw.com>
andrewwhitecdw
requested review from
a team,
derekwaynecarr,
maxamillion and
mrunalp
as code owners
July 22, 2026 04:19
|
Thank you for your interest in contributing to OpenShell, @andrewwhitecdw. This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer. To get vouched:
See CONTRIBUTING.md for details. |
|
Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text: I have read the DCO document and I hereby sign the DCO. You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot. |
6 tasks
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.
Summary
Three small, independent robustness fixes found during code review, one commit each:
is_alphanumeric(), so labels likecaféor日本語passed gateway validation but would be rejected by the Kubernetes API server (the label spec is ASCII-only). The same functions already validate the key prefix with ASCII-only checks.&resp.policy_hash[..12](panics on empty/short proto3 hash; a guardedshort_hash()helper already existed nearby) and&rev.load_error[..40](panics on multi-byte UTF-8, same bug class as fix(cli): avoid panic on multi-byte UTF-8 in --since duration #2406).port > 49152, omitting port 49152 itself from the IANA dynamic/private range (49152–65535 inclusive).Related Issue
N/A — small fixes found during code review.
Changes
validate_label_key/validate_label_value: useis_ascii_alphanumeric(); added Unicode rejection testssandbox_policy_set: use existingshort_hash()helper instead of unguarded slicingload_errormechanistic_mapper:port >= 49152for the ephemeral range noteTesting
mise run pre-commitpasses (mise unavailable in this environment; ran equivalentcargo fmt+cargo clippyon all touched crates — clean)cargo test -p openshell-server validate_label— 40 passed, incl. 2 new)Checklist