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

URI cleanup for JSON #68

Merged
merged 1 commit into from
May 2, 2021
Merged

URI cleanup for JSON #68

merged 1 commit into from
May 2, 2021

Conversation

stevespringett
Copy link
Member

Ensure consistency for all URI/URLs to be defined as strings that must conform to the iri-reference format.

…at must conform to the iri-reference format.
@stevespringett stevespringett added this to the 1.3 milestone Apr 29, 2021
@coderpatros
Copy link
Member

LGTM, do we have valid/invalid tests for those?

@stevespringett
Copy link
Member Author

LGTM, do we have valid/invalid tests for those?

Good point. No, but let me add that.

@stevespringett
Copy link
Member Author

Valid test cases were committed with #71 which added support for hashes in references. The json test includes urls which passed validation. So in terms of backward compatibility, we should be good.

However, creating an invalid test seems to be problematic. I haven't been able to get it to properly fail. According to https://json-schema.org/understanding-json-schema/reference/string.html:

JSON Schema implementations are not required to implement this part of the specification, and many of them do not.

According to https://opis.io/json-schema/2.x/formats.html#iri-reference, the following should fail, but does not:

{
  "bomFormat": "CycloneDX",
  "specVersion": "1.3",
  "serialNumber": "urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79",
  "version": 1,
  "components": [
    {
      "type": "library",
      "publisher": "Acme Inc",
      "group": "org.example",
      "name": "mylibrary",
      "version": "1.0.0",
      "externalReferences": [
        {
          "type": "bom",
          "url": "\"\\\\\\\\WINDOWS\\\\filëßåré\""
        }
      ]
    }
  ]
}

If I change the JSON Schema to only accept uuid as the format, then validation fails like it should. I think most JSON schema validators have such a loose interpretation of iri-reference that everything basically passes. So I don't think it possible to add an invalid test case here.

@coderpatros
Copy link
Member

Working with JSON schema is so infuriating sometimes.

@coderpatros coderpatros merged commit da260eb into v1.3 May 2, 2021
@coderpatros coderpatros deleted the uri_json_cleanup branch January 2, 2022 00:08
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.

2 participants