-
Notifications
You must be signed in to change notification settings - Fork 92
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
kbs: allow resource uri to have .
in safe ways
#596
Conversation
@@ -38,7 +38,7 @@ impl TryFrom<&str> for ResourceDesc { | |||
fn try_from(value: &str) -> Result<Self> { | |||
let regex = CELL.get_or_init(|| { | |||
Regex::new( | |||
r"^((?<repo>[a-zA-Z0-9_\-]+)/)?(?<type>[a-zA-Z0-9_\-]+)/(?<tag>[a-zA-Z0-9_\-]+)$", | |||
r"^((?<repo>[a-zA-Z0-9_\-]+[a-zA-Z0-9_\-\.]*)/)?(?<type>[a-zA-Z0-9_\-]+[a-zA-Z0-9_\-\.]*)/(?<tag>[a-zA-Z0-9_\-]+[a-zA-Z0-9_\-\.]*)$", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting the regex in online validator (https://regex101.com/) complains about unescaped /
.
Following pattern with escaping the /
worked
"^((?<repo>[a-zA-Z0-9_\-]+[a-zA-Z0-9_\-\.]*)\/)?(?<type>[a-zA-Z0-9_\-]+[a-zA-Z0-9_\-\.]*)\/(?<tag>[a-zA-Z0-9_\-]+[a-zA-Z0-9_\-\.]*)$"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Let me fix this
We deprecated `.` in resource uri to avoid security issues like accessing the upper directory with `..` path. However, in some cases `.` is safe like `example.txt`. This patch allows a string not starting with `.` to appear in a resource URI. Fixes confidential-containers#593 Signed-off-by: Xynnn007 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We deprecated
.
in resource uri to avoid security issues like accessing the upper directory with..
path. However, in some cases.
is safe likeexample.txt
. This patch allows a string not starting with.
to appear in a resource URI.Fixes #593
cc @bpradipt