-
Notifications
You must be signed in to change notification settings - Fork 50
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
securesystemslib: Add AnyNonemptyString, use for PATH_SCHEMA #244
securesystemslib: Add AnyNonemptyString, use for PATH_SCHEMA #244
Conversation
self.assertTrue(in_confined_directory('a/b/c.txt', [''])) ...presumably because that second parameter is now being enforced via |
I see this function for the first time. According to a comment, an empty string in the second parameter acts as some sort of "arbitrarily chosen" wildcard: securesystemslib/securesystemslib/util.py Lines 216 to 217 in 9b3a78e
The only place where this function is used is in @willwoodruff, for the time being I suggest to just patch that function to not validate the second argument as list of paths but rather as list of any strings (including empty string). |
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 for the patch, @woodruffw! Do you have bandwidth to add tests?
securesystemslib/schema.py
Outdated
def check_match(self, object): | ||
if not isinstance(object, six.string_types): | ||
raise securesystemslib.exceptions.FormatError('Expected a string' | ||
' but got ' + repr(object)) |
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.
Minor suggestion: We could subclass from AnyString and replace this first check with super().check_match
.
Subclassing would also make it safe to remove the constructor here. Because the implicitly called AnyString.__init__(): pass
will then prevent us from calling any further upper-level constructors (... which for some reason seem to be desired, or otherwise I don't understand the many __init__(): pass
here).
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.
Good call! super()
is a bit messy since this code (appears to be) Python 2.7 compatible, so I called AnyString.check_match(self, object)
explicitly. We could use super
if we turned the top-level Schema
class into a "new-style" one, but I figured that this was less invasive for a small change.
Sounds good to me. JFYI, you tagged another Will Woodruff 😉 I should also have some bandwidth for unit tests today. |
Makes Python 2.7 unhappy without "new-style" classes.
Yeah, this is some non-standard optional thing we should really get rid off. That, and the list of mirrors. Nobody uses them AFAIK. I would wholeheartedly endorse and merge any PR that does this. |
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.
[Apologies for mixing you two up, @willwoodruff and @woodruffw]
LGTM! Merging.
Thanks for weighing in, @trishankatdatadog. I opened an issue: #245 |
Corresponding to the securesyslib changes made in this pr: secure-systems-lab/securesystemslib#244 which changed the securesyslib.formats.PATH schema to be of type AnyNonemptystring. This made the tuf unit tests to fail because there are to places where functional arguments should comfront to the securesyslib.formats.PATH schema, but have a default value of empty string. Signed-off-by: Martin Vrachev <[email protected]>
Corresponding to the securesyslib changes made in this pr: secure-systems-lab/securesystemslib#244 which changed the securesyslib.formats.PATH schema to be of type AnyNonemptystring. This made the tuf unit tests to fail because there are to places where functional arguments should comply to the securesyslib.formats.PATH schema, but have a default value of empty string. Signed-off-by: Martin Vrachev <[email protected]>
Corresponding to the securesyslib changes made in this pr: secure-systems-lab/securesystemslib#244 which changed the securesyslib.formats.PATH schema to be of type AnyNonemptystring. This made the tuf unit tests to fail because there are to places where functional arguments should comply with the securesyslib.formats.PATH schema, but have a default value of an empty string. Signed-off-by: Martin Vrachev <[email protected]>
Corresponding to the securesyslib changes made in this pr: secure-systems-lab/securesystemslib#244 which changed the securesyslib.formats.PATH schema to be of type AnyNonemptystring. This made the tuf unit tests to fail because there are to places where functional arguments should comply with the securesyslib.formats.PATH schema, but have a default value of an empty string. Signed-off-by: Martin Vrachev <[email protected]>
TODO: Needs tests.
Fixes issue #: #241.
Description of the changes being introduced by the pull request:
Please verify and check that the pull request fulfils the following
requirements: