Skip to content
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

Add downloadLocation URI validation #3697

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

stgrace
Copy link

@stgrace stgrace commented Feb 28, 2025

Description

Please include a summary of the changes along with any relevant motivation and context,
or link to an issue where this is explained.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

@stgrace
Copy link
Author

stgrace commented Feb 28, 2025

Attempted same command with changes from issue #3696, which sets it to NOASSERTION because of the validation issue

{
            "name": "@isaacs/cliui",
            "SPDXID": "SPDXRef-Package-npm--isaacs-cliui-7026ea92955de2ad",
            "versionInfo": "8.0.2",
            "supplier": "Person: Ben Coe ([email protected])",
            "originator": "Person: Ben Coe ([email protected])",
            "downloadLocation": "NOASSERTION",
            "filesAnalyzed": false,
            "sourceInfo": "acquired package info from installed node module manifest file: /usr/local/lib/node_modules/npm/node_modules/@isaacs/cliui/package.json",
            "licenseConcluded": "NOASSERTION",
            "licenseDeclared": "ISC",
            "copyrightText": "NOASSERTION",
            "description": "easily create complex multi-column command-line-interfaces",
            "externalRefs": [
                {
                    "referenceCategory": "SECURITY",
                    "referenceType": "cpe23Type",
                    "referenceLocator": "cpe:2.3:a:\\@isaacs\\/cliui:\\@isaacs\\/cliui:8.0.2:*:*:*:*:*:*:*"
                },
                {
                    "referenceCategory": "PACKAGE-MANAGER",
                    "referenceType": "purl",
                    "referenceLocator": "pkg:npm/%40isaacs/[email protected]"
                }
            ]
        }

Signed-off-by: Stef Graces <[email protected]>
@stgrace stgrace force-pushed the validate-download-location-uri branch from 546541f to d411a32 Compare February 28, 2025 13:51
kzantow
kzantow previously approved these changes Feb 28, 2025
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks very much @stgrace !

@kzantow
Copy link
Contributor

kzantow commented Feb 28, 2025

Argh, I spoke too soon; it looks like we need some snapshots and other tests updated, but I think the core change here is the right thing. I can help with this, also fine if you'd like to do it.

make lint-fix should help the static analysis issue(s), but the naming it probably won't help with.

@kzantow kzantow dismissed their stale review February 28, 2025 15:50

I may have been hasty to think about the nuance between NONE and NOASSERTION

}

func UriValue(uri string) string {
if NoneIfEmpty(uri) != NONE {
Copy link
Contributor

@kzantow kzantow Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using NOASSERTION here actually ends up being the right thing to do. The reason is, we're not claiming that there is no download location, we're only claiming that we cannot provide one. As such, I think we should update this to: if isURIValid(uri) { return uri } return NOASSERTION, or instead get rid of this function altogether and just update the last bit of DownloadLocation to have this, and ensure isURIValid returns false for empty string. I'm happy to make these updates.

Very sorry for not giving this sufficient thought originally

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.

Download location is not a valid URI
2 participants