trawly 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/README.md +155 -0
- package/SECURITY.md +18 -0
- package/dist/cli.js +1316 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.js +393 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
8
|
+
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
16
|
+
|
|
17
|
+
Full license text: https://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# trawly
|
|
2
|
+
|
|
3
|
+
A dependency sanity scanner for JavaScript projects. Reads exact installed
|
|
4
|
+
versions from your `package-lock.json` and queries the
|
|
5
|
+
[OSV](https://google.github.io/osv.dev/api/) advisory database for known
|
|
6
|
+
vulnerabilities.
|
|
7
|
+
|
|
8
|
+
> **Limitation:** trawly reports known advisories. It cannot prove a package is
|
|
9
|
+
> safe : absence of findings is not absence of risk.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install --save-dev trawly
|
|
15
|
+
# or run ad-hoc:
|
|
16
|
+
npx trawly scan
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Requires Node.js >= 20.
|
|
20
|
+
|
|
21
|
+
## Quickstart
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# log-only run (always exits 0) : best for interactive inspection
|
|
25
|
+
npx trawly inspect
|
|
26
|
+
|
|
27
|
+
# gating run : exits non-zero when findings meet --fail-on (default: high). Use this in CI.
|
|
28
|
+
npx trawly scan
|
|
29
|
+
|
|
30
|
+
# scan a specific lockfile
|
|
31
|
+
npx trawly scan --lockfile path/to/package-lock.json
|
|
32
|
+
|
|
33
|
+
# JSON output (stable schema, suitable for CI artefacts)
|
|
34
|
+
npx trawly scan --format json > trawly-report.json
|
|
35
|
+
|
|
36
|
+
# only production deps
|
|
37
|
+
npx trawly scan --prod
|
|
38
|
+
|
|
39
|
+
# show every advisory instead of grouping by package
|
|
40
|
+
npx trawly scan --details
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Two ways to run
|
|
44
|
+
|
|
45
|
+
trawly intentionally separates the gating and reporting concerns:
|
|
46
|
+
|
|
47
|
+
| Command | Exit code on findings | When to use |
|
|
48
|
+
| ---------------- | ------------------------------------------- | --------------------------------------------- |
|
|
49
|
+
| `trawly scan` | non-zero (`--fail-on`, default `high`) | CI, pre-commit, anywhere a build should fail |
|
|
50
|
+
| `trawly inspect` | always 0 unless an operational error occurs | local exploration, dashboards, "just show me" |
|
|
51
|
+
|
|
52
|
+
Both produce identical output. Only the exit behaviour differs.
|
|
53
|
+
|
|
54
|
+
## CLI
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
trawly scan [path] Gating run. Exits non-zero when --fail-on is met.
|
|
58
|
+
trawly inspect [path] Log-only run. Always exits 0 on findings.
|
|
59
|
+
|
|
60
|
+
Common options (both commands):
|
|
61
|
+
|
|
62
|
+
--lockfile <path> Explicit path to package-lock.json
|
|
63
|
+
--format table|json Output format (default: table)
|
|
64
|
+
--prod Skip dev dependencies
|
|
65
|
+
--include-dev Include dev dependencies (default)
|
|
66
|
+
--no-cache Bypass any local cache
|
|
67
|
+
-v, --details Show one row per advisory instead of grouping
|
|
68
|
+
-q, --summary Print only the one-line severity summary
|
|
69
|
+
|
|
70
|
+
scan-only:
|
|
71
|
+
--fail-on <level> Severity gate
|
|
72
|
+
(critical|high|moderate|low|none, default: high)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Exit codes
|
|
76
|
+
|
|
77
|
+
| Code | Meaning |
|
|
78
|
+
| ---- | --------------------------------------------------------------------------------------------- |
|
|
79
|
+
| 0 | `inspect`: any outcome with no operational error. `scan`: no finding at or above `--fail-on`. |
|
|
80
|
+
| 1 | `scan` only: at least one finding at or above `--fail-on`. |
|
|
81
|
+
| 2 | Operational error (e.g. lockfile read failed, OSV unreachable). |
|
|
82
|
+
| 3 | Invalid CLI input. |
|
|
83
|
+
|
|
84
|
+
## Library API
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { scanProject, scanLockfile } from "trawly";
|
|
88
|
+
|
|
89
|
+
const result = await scanProject({ cwd: process.cwd() });
|
|
90
|
+
for (const finding of result.findings) {
|
|
91
|
+
console.log(finding.packageName, finding.severity, finding.id);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The result follows this shape:
|
|
96
|
+
|
|
97
|
+
```jsonc
|
|
98
|
+
{
|
|
99
|
+
"scannedAt": "2026-05-03T12:34:56.000Z",
|
|
100
|
+
"packagesScanned": 412,
|
|
101
|
+
"findings": [
|
|
102
|
+
{
|
|
103
|
+
"id": "GHSA-...",
|
|
104
|
+
"source": "osv",
|
|
105
|
+
"type": "vulnerability",
|
|
106
|
+
"severity": "high",
|
|
107
|
+
"packageName": "lodash",
|
|
108
|
+
"installedVersion": "4.17.20",
|
|
109
|
+
"summary": "Prototype pollution in lodash",
|
|
110
|
+
"url": "https://github.com/advisories/GHSA-...",
|
|
111
|
+
"fixedVersions": ["4.17.21"],
|
|
112
|
+
"affectedPaths": ["node_modules/lodash"],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
"summary": {
|
|
116
|
+
"critical": 0,
|
|
117
|
+
"high": 1,
|
|
118
|
+
"moderate": 0,
|
|
119
|
+
"low": 0,
|
|
120
|
+
"unknown": 0,
|
|
121
|
+
},
|
|
122
|
+
"errors": [],
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## CI example (GitHub Actions)
|
|
127
|
+
|
|
128
|
+
```yaml
|
|
129
|
+
name: trawly
|
|
130
|
+
on: [push, pull_request]
|
|
131
|
+
jobs:
|
|
132
|
+
scan:
|
|
133
|
+
runs-on: ubuntu-latest
|
|
134
|
+
steps:
|
|
135
|
+
- uses: actions/checkout@v4
|
|
136
|
+
- uses: actions/setup-node@v4
|
|
137
|
+
with: { node-version: 20 }
|
|
138
|
+
- run: npm ci
|
|
139
|
+
- run: npx trawly scan --fail-on high --format json > trawly.json
|
|
140
|
+
- uses: actions/upload-artifact@v4
|
|
141
|
+
if: always()
|
|
142
|
+
with: { name: trawly-report, path: trawly.json }
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Roadmap
|
|
146
|
+
|
|
147
|
+
trawly v0 covers npm + OSV. Planned next:
|
|
148
|
+
|
|
149
|
+
- pnpm and Yarn lockfile support
|
|
150
|
+
- SARIF + Markdown reporters and a GitHub Action
|
|
151
|
+
- Config file with ignore entries (with required expiry)
|
|
152
|
+
- Baseline mode (fail only on new findings)
|
|
153
|
+
- Risk signals: install scripts, unexpected registries, package age
|
|
154
|
+
- Multi-ecosystem scanning via SBOM (SPDX, CycloneDX)
|
|
155
|
+
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Security policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability in trawly itself
|
|
4
|
+
|
|
5
|
+
If you believe you've found a security issue in trawly, please **do not** open
|
|
6
|
+
a public issue. Instead, contact the maintainers directly so we can fix and
|
|
7
|
+
disclose responsibly.
|
|
8
|
+
|
|
9
|
+
We will acknowledge reports within 5 business days and aim to ship a patch or
|
|
10
|
+
mitigation within 30 days, depending on severity.
|
|
11
|
+
|
|
12
|
+
## What trawly is and is not
|
|
13
|
+
|
|
14
|
+
- trawly checks installed package versions against published advisories.
|
|
15
|
+
- A clean trawly run does **not** mean a package is safe. It means trawly has
|
|
16
|
+
not found a known advisory for the exact installed versions.
|
|
17
|
+
- trawly does not currently verify package signatures, provenance, or runtime
|
|
18
|
+
behavior. Those are on the roadmap.
|