Skip to content

Commit d5a6b39

Browse files
committed
Add docs for asdf, git submodules, vulns and enrichment libraries
1 parent 4951433 commit d5a6b39

File tree

7 files changed

+166
-3
lines changed

7 files changed

+166
-3
lines changed

content/docs/coverage.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ git pkgs ecosystems -f json # JSON output
1616
|-----------|-----------|-----------|----------|-------------|----------|
1717
| Alpine | APKBUILD | | || |
1818
| Arch | PKGBUILD | | | | |
19+
| asdf | .tool-versions | | | | |
1920
| Bazel | MODULE.bazel | | || |
2021
| Bower | bower.json | | || |
2122
| Cargo | Cargo.toml | Cargo.lock ||| cargo |
@@ -32,6 +33,7 @@ git pkgs ecosystems -f json # JSON output
3233
| Docker | Dockerfile, compose.yml | | || |
3334
| Dub | dub.json, dub.sdl | || | |
3435
| Elm | elm.json | ||| |
36+
| Git | .gitmodules | | | | |
3537
| Go | go.mod | go.sum ||| gomod |
3638
| GitHub Actions | .github/workflows/*.yml | | || |
3739
| Hackage | *.cabal | cabal.project.freeze ||| cabal, stack |

content/docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,6 @@ The `--include-submodules` flag works with all commands that scan the working di
9191

9292
## Supported ecosystems
9393

94-
git-pkgs parses lockfiles from npm, RubyGems, Go, Cargo, pip, Composer, Maven, CocoaPods, Hex, NuGet, Pub, GitHub Actions, and more. Run `git pkgs ecosystems` for the full list.
94+
git-pkgs parses lockfiles from npm, RubyGems, Go, Cargo, pip, Composer, Maven, CocoaPods, Hex, NuGet, Pub, GitHub Actions, and more. It also recognizes `.tool-versions` (asdf/mise) files and `.gitmodules` for git submodule tracking. Run `git pkgs ecosystems` for the full list.
9595

9696
For best results, commit your lockfiles. Manifests show version ranges but lockfiles show what actually got installed, including transitive dependencies.

content/docs/modules/_index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@ git-pkgs is built from a set of Go libraries that handle different aspects of de
88
- **manifests** parses lockfiles and manifest files to extract dependency information
99
- **managers** wraps package manager CLIs behind a common interface for install, add, update, and remove
1010
- **registries** fetches package metadata from registry APIs
11+
- **enrichment** combines registry and ecosyste.ms lookups behind a single interface
12+
- **vulns** queries vulnerability databases (OSV, NVD, GitHub Advisories) with PURL-based lookups
1113
- **purl** handles Package URL parsing and generation
1214
- **vers** parses version ranges across different ecosystem syntaxes
1315
- **spdx** normalizes and validates license expressions
1416

1517
{{< cards >}}
18+
{{< card link="enrichment" title="enrichment" subtitle="Package metadata enrichment" >}}
1619
{{< card link="managers" title="managers" subtitle="Package manager CLI wrapper" >}}
1720
{{< card link="manifests" title="manifests" subtitle="Manifest and lockfile parsing" >}}
1821
{{< card link="purl" title="purl" subtitle="Package URL handling" >}}
1922
{{< card link="registries" title="registries" subtitle="Registry API clients" >}}
2023
{{< card link="spdx" title="spdx" subtitle="SPDX license utilities" >}}
2124
{{< card link="vers" title="vers" subtitle="Version range parsing" >}}
25+
{{< card link="vulns" title="vulns" subtitle="Vulnerability database queries" >}}
2226
{{< /cards >}}

content/docs/modules/enrichment.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: enrichment
3+
---
4+
5+
A Go library for fetching package metadata from external sources. Combines registry queries and the [ecosyste.ms](https://packages.ecosyste.ms) API behind a single interface.
6+
7+
```go
8+
import (
9+
"context"
10+
"github.com/git-pkgs/enrichment"
11+
)
12+
13+
client, err := enrichment.NewClient()
14+
if err != nil {
15+
panic(err)
16+
}
17+
18+
info, err := client.BulkLookup(context.Background(), []string{
19+
"pkg:npm/lodash@4.17.21",
20+
"pkg:pypi/requests@2.31.0",
21+
})
22+
23+
for purl, pkg := range info {
24+
fmt.Printf("%s: latest=%s license=%s\n", purl, pkg.LatestVersion, pkg.License)
25+
}
26+
```
27+
28+
## How it works
29+
30+
By default, `NewClient()` returns a hybrid client that routes lookups based on the PURL:
31+
32+
- PURLs with a `repository_url` qualifier go directly to the registry
33+
- Everything else goes through ecosyste.ms
34+
35+
To skip ecosyste.ms and query all registries directly, set `GIT_PKGS_DIRECT=1` or `git config --global pkgs.direct true`.
36+
37+
## Key types
38+
39+
```go
40+
type Client interface {
41+
BulkLookup(ctx context.Context, purls []string) (map[string]*PackageInfo, error)
42+
GetVersions(ctx context.Context, purl string) ([]VersionInfo, error)
43+
GetVersion(ctx context.Context, purl string) (*VersionInfo, error)
44+
}
45+
46+
type PackageInfo struct {
47+
Ecosystem string
48+
Name string
49+
LatestVersion string
50+
License string
51+
Description string
52+
Homepage string
53+
Repository string
54+
RegistryURL string
55+
Source string // "ecosystems", "registries", or "depsdev"
56+
}
57+
58+
type VersionInfo struct {
59+
Number string
60+
PublishedAt time.Time
61+
Integrity string
62+
License string
63+
}
64+
```
65+
66+
## Installation
67+
68+
```bash
69+
go get github.com/git-pkgs/enrichment
70+
```
71+
72+
[View on GitHub](https://github.com/git-pkgs/enrichment)

content/docs/modules/manifests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ for _, dep := range result.Dependencies {
2525

2626
## Supported ecosystems
2727

28-
alpine, arch, bower, brew, cargo, carthage, clojars, cocoapods, composer, conan, conda, cpan, cran, crystal, deno, docker, dub, elm, gem, github-actions, golang, hackage, haxelib, hex, julia, luarocks, maven, nimble, nix, npm, nuget, pub, pypi, rpm, swift, vcpkg.
28+
alpine, arch, asdf, bower, brew, cargo, carthage, clojars, cocoapods, composer, conan, conda, cpan, cran, crystal, deno, docker, dub, elm, gem, git, github-actions, golang, hackage, haxelib, hex, julia, luarocks, maven, nimble, nix, npm, nuget, pub, pypi, rpm, swift, vcpkg.
2929

3030
## Types
3131

content/docs/modules/vulns.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
---
2+
title: vulns
3+
---
4+
5+
A Go library for querying vulnerability databases using PURLs. Supports OSV as the primary source, with additional backends for NVD, GitHub Advisories, and others.
6+
7+
```go
8+
import (
9+
"context"
10+
"github.com/git-pkgs/purl"
11+
"github.com/git-pkgs/vulns/osv"
12+
)
13+
14+
source := osv.New()
15+
p := purl.MakePURL("npm", "lodash", "4.17.20")
16+
17+
results, err := source.Query(context.Background(), p)
18+
if err != nil {
19+
panic(err)
20+
}
21+
22+
for _, v := range results {
23+
fmt.Printf("%s (%s): %s\n", v.ID, v.SeverityLevel(), v.Summary)
24+
if fixed := v.FixedVersion("npm", "lodash"); fixed != "" {
25+
fmt.Printf(" Fixed in: %s\n", fixed)
26+
}
27+
}
28+
```
29+
30+
## Sources
31+
32+
The `vulns.Source` interface is implemented by multiple backends:
33+
34+
- **osv** -- queries the [OSV API](https://osv.dev) (batch and single queries)
35+
36+
Each source returns results in a common `vulns.Vulnerability` format based on the OSV schema.
37+
38+
## Key types
39+
40+
```go
41+
type Source interface {
42+
Query(ctx context.Context, p *purl.PURL) ([]Vulnerability, error)
43+
QueryBatch(ctx context.Context, purls []*purl.PURL) ([][]Vulnerability, error)
44+
Get(ctx context.Context, id string) (*Vulnerability, error)
45+
}
46+
47+
type Vulnerability struct {
48+
ID string
49+
Summary string
50+
Details string
51+
Aliases []string
52+
Severity []Severity
53+
Affected []Affected
54+
// ...
55+
}
56+
```
57+
58+
## Vulnerability methods
59+
60+
```go
61+
v.SeverityLevel() // "critical", "high", "medium", "low", "unknown"
62+
v.CVSS() // parsed CVSS info (vector, score, level)
63+
v.FixedVersion("npm", "lodash") // first fixed version for a package
64+
v.IsVersionAffected("npm", "lodash", "4.17.20") // check if version is affected
65+
```
66+
67+
## CVSS parsing
68+
69+
The library parses CVSS v2.0, v3.0, v3.1, and v4.0 vectors:
70+
71+
```go
72+
cvss, err := vulns.ParseCVSS("CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H")
73+
fmt.Printf("Score: %.1f (%s)\n", cvss.Score, cvss.Level)
74+
// Score: 9.8 (critical)
75+
```
76+
77+
## Installation
78+
79+
```bash
80+
go get github.com/git-pkgs/vulns
81+
```
82+
83+
[View on GitHub](https://github.com/git-pkgs/vulns)

content/docs/vulnerabilities.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,6 @@ Your exposure:
112112

113113
## Data source
114114

115-
Vulnerability data comes from OSV, which aggregates advisories from GitHub (GHSA), NVD (CVE), RustSec, PyPI, Go, and others. Data is cached locally and refreshed when stale (>24h).
115+
Vulnerability data comes from [OSV](https://osv.dev), which aggregates advisories from GitHub (GHSA), NVD (CVE), RustSec, PyPI, Go, and others. Data is cached locally and refreshed when stale (>24h).
116+
117+
The underlying [`vulns`](/docs/modules/vulns) library handles API queries, CVSS parsing, and affected version matching.

0 commit comments

Comments
 (0)