Skip to content
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

Validation for paths #23

Merged
merged 2 commits into from
Nov 6, 2023
Merged

Validation for paths #23

merged 2 commits into from
Nov 6, 2023

Conversation

jchadwick-buf
Copy link
Member

@jchadwick-buf jchadwick-buf commented Nov 6, 2023

  • Rejects paths with backslashes
  • Limits length to 4096 (will be enforced in v1alpha1 as well.)
  • Enforces relative paths (no preceding slash.)
  • Enforces no trailing slash
  • Enforces normalized paths (no . or .. elements)

Explanation

Regular expression breakdown:

Path := PathSegment(/PathSegment)*
PathSegment := [^/.][^/]?|[^/][^/.]|[^/]{3,}
  • Path enforces normalized, relative paths by ensuring that there is one or more path segments with one and only one / between them and nowhere else.
  • PathSegment enforces each path segment can't be . or .. and must be non-empty. It does this by matching any 1 character segment that isn't ., any 2 character segment that isn't .., and any 3 character segment.

Overall path length is then enforced with max_len and Windows-style paths are rejected using not_contains to generally disallow backslashes in paths.

@jchadwick-buf jchadwick-buf requested a review from bufdev as a code owner November 6, 2023 20:50
@jchadwick-buf jchadwick-buf requested a review from bufdev November 6, 2023 21:39
@bufdev bufdev merged commit 70fdcda into main Nov 6, 2023
6 checks passed
@bufdev bufdev deleted the jchadwick/path-validation branch November 6, 2023 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants