tools-python
tools-python copied to clipboard
PackageDownloadLocation validation doesn't allow underscores in git URLs
This issue is related to https://github.com/spdx/spdx-java-model-2_X/issues/33 and has identical behaviour and an identical fix.
The regex that validates PackageDownloadLocation tags rejects git URLs with underscores in the repository name:
https://github.com/spdx/tools-python/blob/b7f9a3defe8b0af1414cd75f1447ec242428f1d0/src/spdx_tools/spdx/validation/uri_validators.py#L18
Example of a line from an SBOM that doesn't validate (because of the underscore in the repo name) but should:
PackageDownloadLocation: [email protected]:zephyrproject-rtos/CMSIS_6@06d952b6713a2ca41c9224a62075e4059402a151-off
Proposed fix:
- git_pattern = "(git\\+git@[a-zA-Z0-9\\.\\-]+:[a-zA-Z0-9/\\\\.@\\-]+)"
+ git_pattern = "(git\\+git@[a-zA-Z0-9\\.\\-]+:[a-zA-Z0-9/\\\\.@\\-_]+)"