-
Notifications
You must be signed in to change notification settings - Fork 55
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
Clarify PATHPATTERN wildcards are glob-like #174
Clarify PATHPATTERN wildcards are glob-like #174
Conversation
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.
This matches my expectations, thanks.
The common interpretation of PATHPATTERN's use shell-style wildcards is that they match the behaviour of a UNIX glob: https://man7.org/linux/man-pages/man7/glob.7.html However, the reference implementation currently ( https://github.com/theupdateframework/tuf/blob/04bbc03b9f16e49ee114ed9b5eae69fdea266b93/tuf/client/updater.py#L2868 ) implements PATHPATTERN wildcard matching using fnmatch ( https://docs.python.org/3/library/fnmatch.html#module-fnmatch) where, unlike a glob, wildcards in PATHPATTERN will match path separators in the PATHPATTERN. The existing recommendation in the spec to treat `/` as a directory separator implies that, like a glob, a '/' in a pathname SHOULD not be matched by a wildcard in a PATHPATTERN. Edit the description of PATHPATTERN to be explicit that this is glob-like behaviour AND we do not expect a wildcard to match a path separator. Make this even more explicit by including an examples demonstrating how a path separator would not match. Signed-off-by: Joshua Lock <[email protected]>
ef14bc9
to
6fffd36
Compare
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, thanks @joshuagl
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
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with fnmatch.fnmatch() which doesn't see "/" separator as special symbol. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with fnmatch.fnmatch() which doesn't see "/" separator as special symbol. That's why before using fnmatch.fnmatch() we should manually check that both the pattern directory and the given target directory are the same and then we can get a valid result if a target path matches the pattern. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with fnmatch.fnmatch() which doesn't see "/" separator as special symbol. That's why before using fnmatch.fnmatch() we should manually check that both the pattern directory and the given target directory are the same and then we can get a valid result if a target path matches the pattern. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with fnmatch.fnmatch() which doesn't see "/" separator as special symbol. That's why before using fnmatch.fnmatch() we should manually check that both the pattern directory and the given target directory are the same and then we can get a valid result if a target path matches the pattern. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. That's why before using `fnmatch.fnmatch()` we should manually check that either: - pattern directory = target directory - or that pattern directory contains the target directory and `*` is used in the end of the pattern. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. That's why before using `fnmatch.fnmatch()` we should manually check that either: - pattern directory = target directory - or that pattern directory contains the target directory and `*` is used at the end of the pattern. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. That's why before using `fnmatch.fnmatch()` we should manually check that either: - pattern directory = target directory - or that pattern directory contains the target directory and `*` is used at the end of the pattern. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. That's why before using `fnmatch.fnmatch()` we should manually check that either: - pattern directory = target directory - or that pattern directory contains the target directory and `*` is used at the end of the pattern. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. That's why before using `fnmatch.fnmatch()` we should manually check that "targetname" and "pathpattern" are pointing to the same directory. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. That's why before using `fnmatch.fnmatch()` we should manually check that "targetname" and "pathpattern" are pointing to the same directory. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. That's why before using `fnmatch.fnmatch()` we should manually check that "targetname" and "pathpattern" are pointing to the same directory. Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a regex we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a regex we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a regex we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a regex we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a glob pattern we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a glob pattern we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a glob pattern we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a glob pattern we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a glob pattern we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a glob pattern we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a glob pattern we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
According to the recently updated version of the specification the shell style wildcard matching is glob-like (see theupdateframework/specification#174), and therefore a path separator in a path should not be matched by a wildcard in the PATHPATTERN. That's not what happens with `fnmatch.fnmatch()` which doesn't see "/" separator as a special symbol. For example: fnmatch.fnmatch("targets/foo.tgz", "*.tgz") will return True which is not what glob-like implementation will do. We should make sure that target_path and the pathpattern contain the same number of directories and because each part of the pathpattern could include a glob pattern we should check that fnmatch.fnmatch() is true on each target and pathpattern directory fragment separated by "/". Signed-off-by: Martin Vrachev <[email protected]>
Addresses #173 by emphasising that the shell style wildcard matching of the specification is glob-like, and therefore a path separator in a path should not be matched by a wildcard in the
PATHPATTERN
.