Skip to content

Create a PURL Type Schema parser/analyser to automate the normalisation of components and verify the validity of a PURL string #18

@giterlizzi

Description

@giterlizzi

Currently, the rules for PURL types are defined in URI::PackageURL::Util->purl_components_normalize, where components for certain PURL types are checked and normalised.

Create a parser/analyser for the schema files that define the rules for PURL types.
Currently, the PR on PURL-SPEC only has 3 example PURL types (npm, swid and maven).

It is not necessary to use a JSON Schema distributions (eg. JSON::Validator).

Addon

A possible scheme for CPAN "could" be:

{
  "$schema": "https://purl-spec.org/schemas/purl-type.schema-1.0.json",
  "$id": "https://purl-spec.org/types/cpan.json",
  "type": "cpan",
  "name": "Comprehensive Perl Archive Network (CPAN)",
  "description": "PURL type for Perl package distributions published on CPAN",
  "definition": {
    "namespace": {
      "requirement": "required",
      "allowed_characters": "^[A-Z]+$",
      "case_rules": {
        "sensitivity": "case-sensitive",
        "normalization": "uppercase"
      },
      "native_label": "cpan-id"
    },
    "name": {
      "requirement": "required",
      "allowed_characters": "^[A-Za-z0-9-]+$",
      "case_rules": {
        "sensitivity": "case-sensitive"
      },
      "native_label": "distribution"
    },
    "version": {
      "requirement": "optional",
      "allowed_characters": "^[0-9a-zA-Z.-]+$",
      "native_label": "release"
    },
    "subpath": {
      "requirement": "optional",
      "allowed": true,
      "description": "A file or directory path within the package."
    },
    "qualifiers": [
      {
        "name": "repository_url",
        "requirement": "optional",
        "description": "CPAN/MetaCPAN/BackPAN/DarkPAN repository base URL (default is ``https://www.cpan.org``)"
      },
      {
        "name": "download_url",
        "requirement": "optional",
        "description": "URL of package or distribution"
      },
      {
        "name": "vcs_url",
        "requirement": "optional",
        "description": "extra URL for a package version control system"
      },
      {
        "name": "ext",
        "requirement": "optional",
        "description": "file extension (default is ``tar.gz``)"
      }
    ],
    "repository": {
      "uses_repository": true,
      "default": {
        "name": "CPAN repository",
        "url": "https://www.cpan.org/",
        "description": "The official CPAN repository."
      }
    }
  },
  "examples": [
    "pkg:cpan/DROLSKY/DateTime@1.55",
    "pkg:cpan/GDT/URI-PackageURL",
    "pkg:cpan/OALDERS/libwww-perl@6.76"
  ]
}

See

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions