Skip to content

Report '.' and '..' path segments in namespace and name as invalid - #233

Open
MGpromax wants to merge 1 commit into
package-url:mainfrom
MGpromax:validate-dot-segments
Open

Report '.' and '..' path segments in namespace and name as invalid#233
MGpromax wants to merge 1 commit into
package-url:mainfrom
MGpromax:validate-dot-segments

Conversation

@MGpromax

Copy link
Copy Markdown

Closes #228

Following the direction discussed in #228 and #229 -- from_string() stays a recovering parser and validation lives in the validation API -- this adds ERROR-severity ValidationMessages when a purl's namespace contains a . or .. path segment, or when the name itself is . or ..:

>>> PackageURL.validate_string("pkg:golang/busybox.org/../busybox@1.35.0")
[ValidationMessage(severity=ERROR, message="Namespace contains a '.' or '..' path segment: 'busybox.org/..'")]
>>> PackageURL.validate_string("pkg:golang/busybox.org/..@1.35.0")
[ValidationMessage(severity=ERROR, message="Name cannot be a '.' or '..' path segment: '..'")]

Names or namespace segments that merely contain dots (example.com, my..pkg) are unaffected. The checks live in the base type-definition validator so they apply to every purl type.

Full test suite passes with the purl-spec submodule test corpus (988 passed), plus three new tests covering the namespace case, the name case, and the non-regression on dotted names.

The recovering parser accepts purls such as
pkg:golang/busybox.org/../busybox@1.35.0 and reports 'busybox.org/..'
as the namespace. Following the direction in issue package-url#228, keep parsing
permissive and instead report these from the validation API: a '.'
or '..' segment in the namespace, or as the name, now yields an ERROR
ValidationMessage from validate() and validate_string().

Closes package-url#228

Signed-off-by: Manoj Gowda <manojgowdabs18@gmail.com>
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.

drop '..' from parts other than subpath

1 participant