GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - aboutcode-org/purlvalidator-go: Offline Package URL validator using a prebuilt FST of known packages.

BranchesTags
Open more actions menu

Latest commit

 

History

1,928 Commits
1,928 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
cmd
cmd
 
 
testdata
testdata
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
go.mod
go.mod
 
 
go.sum
go.sum
 
 
purls.fst
purls.fst
 
 
purlvalidator.go
purlvalidator.go
 
 
purlvalidator_test.go
purlvalidator_test.go
 
 

Repository files navigation

purlvalidator

License Version Test

purlvalidator is a Go library for validating Package-URLs (PURLs). It works fully offline, including in air-gapped or restricted environments, and answers one key question: Does the package this PURL represents actually exist?

How It Works

purlvalidator is shipped with a pre-built FST (Finite State Transducer), a set of compact automata containing latest Package-URLs mined by the MineCode1. Library uses this FST to perform lookups and confirm whether the base PURL2 exists.

Currently Supported Ecosystems

  • apk
  • cargo
  • composer
  • conan
  • cpan
  • cran
  • debian
  • maven
  • npm
  • nuget
  • pypi
  • swift

Usage

Add purlvalidator as a dependency:

go get github.com/aboutcode-org/purlvalidator-go

Or add it to go.mod:

require github.com/aboutcode-org/purlvalidator-go v1.0.0

Use it in your code like this:

package main

import (
	"fmt"
	"log"

	purlvalidator "github.com/aboutcode-org/purlvalidator-go"
)

func main() {
	exists, err := purlvalidator.Validate("pkg:nuget/FluentValidation")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(exists)
}

Examples and errors:

exists, err := purlvalidator.Validate("pkg:nuget/FluentValidation")
// exists == true, err == nil

exists, err = purlvalidator.Validate("pkg:nuget/non-existent-foo-bar")
// exists == false, err == nil

exists, err = purlvalidator.Validate("pkg:nuget/[email protected]")
// err reports that only base PURLs are supported.

exists, err = purlvalidator.Validate("test:nuget/FluentValidation")
// err reports that the PURL scheme is invalid.

Validate returns:

  • true, nil when the base PURL exists in the packaged data.
  • false, nil when the base PURL is syntactically valid but unknown.
  • false, err when the input is not a valid PURL or contains a version, qualifiers, or subpath.

Use the released module version when you need reproducible validation results. Use a newer patch release when you need newer packaged PURL data.

How to get latest Package-URL data?

A patch release is published daily with the latest FST generated from newly mined package-urls.

Contribution

We welcome contributions from the community! If you find a bug or have an idea for a new feature, please open an issue on the GitHub repository. If you want to contribute code, you can fork the repository, make your changes, and submit a pull request.

  • Please try to write a good commit message, see good commit message wiki.
  • Add DCO Sign Off to your commits.

Development Setup

Run these commands, starting from a git clone of https://github.com/aboutcode-org/purlvalidator-go.git

Generate FST:

make build-fst

Run tests:

make test

Fix formatting and linting:

make valid

License

SPDX-License-Identifier: Apache-2.0

purl-validator is licensed under Apache License version 2.0.

You may not use this software except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Footnotes

  1. MineCode continuously collects package metadata from various package ecosystems to maintain an up-to-date catalog of known packages. ↩

  2. A Base Package-URL is a Package-URL without a version, qualifiers, or subpath. ↩

About

Offline Package URL validator using a prebuilt FST of known packages.

pkg.go.dev/github.com/aboutcode-org/purlvalidator-go

Topics

airgappedfstpackageurlpurlsbom-tool

Resources

Readme
Apache-2.0 license

Security policy

Security policy
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

1 fork
Report repository

Releases

Sponsor this project

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.