@buddysh/buddy 0.11.0
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/CHANGELOG.md +1633 -0
- package/LICENSE.md +21 -0
- package/README.md +1087 -0
- package/bin/cli.ts +3401 -0
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +188 -0
- package/dist/chunk-0j7z87kh.js +3 -0
- package/dist/chunk-0r8zt3d7.js +2 -0
- package/dist/chunk-16yqbccr.js +3 -0
- package/dist/chunk-1a53wj0h.js +1 -0
- package/dist/chunk-1c1gznm9.js +3 -0
- package/dist/chunk-1h3ey7k5.js +3 -0
- package/dist/chunk-1stt2whn.js +62 -0
- package/dist/chunk-1wjnd24b.js +24 -0
- package/dist/chunk-1xe07hzm.js +2 -0
- package/dist/chunk-2bp7tqca.js +2 -0
- package/dist/chunk-2dbkpfy9.js +2 -0
- package/dist/chunk-3q6czqs4.js +6 -0
- package/dist/chunk-3zdcekfj.js +5 -0
- package/dist/chunk-49ey79p0.js +5 -0
- package/dist/chunk-4c9m61yd.js +5 -0
- package/dist/chunk-4efbxdjr.js +4 -0
- package/dist/chunk-4f7panqj.js +21 -0
- package/dist/chunk-4hd3rre0.js +2 -0
- package/dist/chunk-4xsq18p3.js +9 -0
- package/dist/chunk-52x8mvh4.js +15 -0
- package/dist/chunk-54sc18p8.js +2 -0
- package/dist/chunk-56q4pwb5.js +3 -0
- package/dist/chunk-5c3qf34r.js +2 -0
- package/dist/chunk-5k40mwd4.js +4 -0
- package/dist/chunk-5kt03hx5.js +2 -0
- package/dist/chunk-63ept76v.js +2 -0
- package/dist/chunk-65b3vq52.js +2 -0
- package/dist/chunk-6d9hmjt8.js +3 -0
- package/dist/chunk-6g1y9yqh.js +3 -0
- package/dist/chunk-6k653r8w.js +2 -0
- package/dist/chunk-6md7qf2g.js +4 -0
- package/dist/chunk-6patq6bw.js +2 -0
- package/dist/chunk-6sgh49z1.js +2 -0
- package/dist/chunk-74pxb991.js +7 -0
- package/dist/chunk-7mgec8kb.js +7 -0
- package/dist/chunk-7tfrww3v.js +2 -0
- package/dist/chunk-7xk28xrv.js +2 -0
- package/dist/chunk-82dv4p13.js +2 -0
- package/dist/chunk-8661pvb8.js +3 -0
- package/dist/chunk-887s0w81.js +2 -0
- package/dist/chunk-8rc6042h.js +4 -0
- package/dist/chunk-9750tenz.js +3 -0
- package/dist/chunk-978wtejw.js +44 -0
- package/dist/chunk-9eqpaxfz.js +2 -0
- package/dist/chunk-9h04nskh.js +8 -0
- package/dist/chunk-9p1xkmjy.js +2 -0
- package/dist/chunk-agdesgzv.js +2 -0
- package/dist/chunk-akffynkc.js +3 -0
- package/dist/chunk-ar01x04a.js +2 -0
- package/dist/chunk-ay43f085.js +2 -0
- package/dist/chunk-bk9bqd5j.js +2 -0
- package/dist/chunk-bm8d40j0.js +69 -0
- package/dist/chunk-bxfc4g2x.js +73 -0
- package/dist/chunk-c3fczawt.js +2 -0
- package/dist/chunk-c9r9nd4t.js +1 -0
- package/dist/chunk-ctsz0ynx.js +3 -0
- package/dist/chunk-czremqk7.js +2 -0
- package/dist/chunk-da3wbh04.js +2 -0
- package/dist/chunk-dat582cg.js +2 -0
- package/dist/chunk-dfesffnr.js +3 -0
- package/dist/chunk-djntbp7a.js +105 -0
- package/dist/chunk-eagjp0dh.js +3 -0
- package/dist/chunk-eht72nnj.js +2 -0
- package/dist/chunk-f4nv5x3z.js +2 -0
- package/dist/chunk-fdfk918n.js +2 -0
- package/dist/chunk-fdj0tewy.js +20 -0
- package/dist/chunk-fm8ckj9b.js +2 -0
- package/dist/chunk-fqj7e6xa.js +2 -0
- package/dist/chunk-frm8zz31.js +2 -0
- package/dist/chunk-fvpr07dn.js +16 -0
- package/dist/chunk-g0nv8psv.js +2 -0
- package/dist/chunk-g0w8n555.js +19 -0
- package/dist/chunk-gkmvxjbe.js +2 -0
- package/dist/chunk-gngwjf70.js +7 -0
- package/dist/chunk-h7hs95wn.js +5 -0
- package/dist/chunk-hfvezfxh.js +3 -0
- package/dist/chunk-hw70wbzg.js +3 -0
- package/dist/chunk-j8asz4hb.js +15 -0
- package/dist/chunk-k62w2v03.js +2 -0
- package/dist/chunk-mcrfxphm.js +5 -0
- package/dist/chunk-mh3x7j6h.js +2 -0
- package/dist/chunk-naq32yx3.js +86 -0
- package/dist/chunk-nsmcjkas.js +2 -0
- package/dist/chunk-p1xm1jvz.js +2 -0
- package/dist/chunk-p3wsm8kz.js +2 -0
- package/dist/chunk-p4zwy518.js +4 -0
- package/dist/chunk-p7zgy37f.js +2 -0
- package/dist/chunk-ph1b3vbp.js +315 -0
- package/dist/chunk-pkjm2r0a.js +2 -0
- package/dist/chunk-pkkwb0n0.js +4 -0
- package/dist/chunk-pnpx1kqn.js +6 -0
- package/dist/chunk-q9n79dd3.js +3 -0
- package/dist/chunk-qpz9k66h.js +2 -0
- package/dist/chunk-qvn1rtgp.js +2 -0
- package/dist/chunk-qyf90zz3.js +2 -0
- package/dist/chunk-r06ce5g6.js +2 -0
- package/dist/chunk-r2sbprdb.js +49 -0
- package/dist/chunk-r3zyw8x0.js +3 -0
- package/dist/chunk-rb1fh9vd.js +1 -0
- package/dist/chunk-rqdep14r.js +2 -0
- package/dist/chunk-s1km8cyq.js +2 -0
- package/dist/chunk-s4ms8zag.js +2 -0
- package/dist/chunk-sp818c27.js +9 -0
- package/dist/chunk-tb5y0350.js +3 -0
- package/dist/chunk-thaxgm5p.js +2 -0
- package/dist/chunk-tn8prpny.js +503 -0
- package/dist/chunk-ts35hc5t.js +3 -0
- package/dist/chunk-tzs22es2.js +3 -0
- package/dist/chunk-vagxqhef.js +13 -0
- package/dist/chunk-vh504tcv.js +6 -0
- package/dist/chunk-vkctfqpm.js +3 -0
- package/dist/chunk-vyapg8ca.js +186 -0
- package/dist/chunk-wdwvt7gb.js +43 -0
- package/dist/chunk-wtjhehz9.js +4 -0
- package/dist/chunk-x0ya2r4r.js +3 -0
- package/dist/chunk-x3kragh9.js +12 -0
- package/dist/chunk-x9ctz1qc.js +1 -0
- package/dist/chunk-xakpdqaq.js +3 -0
- package/dist/chunk-xqx460y2.js +3 -0
- package/dist/chunk-xvptf9jy.js +3 -0
- package/dist/chunk-yk23nc4t.js +2 -0
- package/dist/chunk-yncea6ty.js +2 -0
- package/dist/chunk-yq0gxtzv.js +2 -0
- package/dist/chunk-yqhs08ky.js +2 -0
- package/dist/chunk-zb62jhwm.js +31 -0
- package/dist/chunk-zs3jaj0g.js +1023 -0
- package/dist/chunk-zve5d96e.js +2 -0
- package/dist/src/agent/index.d.ts +44 -0
- package/dist/src/agent/modes.d.ts +33 -0
- package/dist/src/agent/runner.d.ts +44 -0
- package/dist/src/agent/stacked.d.ts +83 -0
- package/dist/src/agent/tasks.d.ts +41 -0
- package/dist/src/agent/toolbelt.d.ts +19 -0
- package/dist/src/agent/tools/fs.d.ts +26 -0
- package/dist/src/agent/tools/shell.d.ts +32 -0
- package/dist/src/agent/types.d.ts +56 -0
- package/dist/src/ai/aliases.d.ts +62 -0
- package/dist/src/ai/client.d.ts +42 -0
- package/dist/src/ai/index.d.ts +35 -0
- package/dist/src/ai/learnings.d.ts +78 -0
- package/dist/src/ai/providers/anthropic.d.ts +12 -0
- package/dist/src/ai/providers/google.d.ts +12 -0
- package/dist/src/ai/providers/openai.d.ts +15 -0
- package/dist/src/ai/redact.d.ts +30 -0
- package/dist/src/ai/types.d.ts +75 -0
- package/dist/src/analysis/analyzers/actionlint.d.ts +11 -0
- package/dist/src/analysis/analyzers/external.d.ts +57 -0
- package/dist/src/analysis/analyzers/github-actions.d.ts +9 -0
- package/dist/src/analysis/analyzers/hadolint.d.ts +9 -0
- package/dist/src/analysis/analyzers/linter.d.ts +53 -0
- package/dist/src/analysis/analyzers/markdownlint.d.ts +11 -0
- package/dist/src/analysis/analyzers/secrets.d.ts +23 -0
- package/dist/src/analysis/analyzers/shellcheck.d.ts +8 -0
- package/dist/src/analysis/analyzers/syntax.d.ts +13 -0
- package/dist/src/analysis/engine.d.ts +38 -0
- package/dist/src/analysis/index.d.ts +13 -0
- package/dist/src/analysis/types.d.ts +14 -0
- package/dist/src/buddy.d.ts +17 -0
- package/dist/src/ci/classify.d.ts +49 -0
- package/dist/src/ci/fix.d.ts +42 -0
- package/dist/src/ci/index.d.ts +8 -0
- package/dist/src/commands/dispatcher.d.ts +49 -0
- package/dist/src/commands/handlers.d.ts +23 -0
- package/dist/src/commands/index.d.ts +22 -0
- package/dist/src/commands/parser.d.ts +71 -0
- package/dist/src/config-validation.d.ts +38 -0
- package/dist/src/config.d.ts +22 -0
- package/dist/src/dashboard/dashboard-generator.d.ts +10 -0
- package/dist/src/doctor.d.ts +44 -0
- package/dist/src/ecosystems/go.d.ts +10 -0
- package/dist/src/ecosystems/index.d.ts +60 -0
- package/dist/src/ecosystems/pep440.d.ts +57 -0
- package/dist/src/ecosystems/python.d.ts +12 -0
- package/dist/src/ecosystems/ruby.d.ts +9 -0
- package/dist/src/ecosystems/rust.d.ts +8 -0
- package/dist/src/ecosystems/scan.d.ts +49 -0
- package/dist/src/ecosystems/shared.d.ts +45 -0
- package/dist/src/ecosystems/types.d.ts +58 -0
- package/dist/src/events/bus.d.ts +41 -0
- package/dist/src/events/index.d.ts +11 -0
- package/dist/src/events/sinks.d.ts +33 -0
- package/dist/src/gates/ai-checks.d.ts +77 -0
- package/dist/src/gates/checks.d.ts +84 -0
- package/dist/src/gates/index.d.ts +17 -0
- package/dist/src/gates/post-merge.d.ts +56 -0
- package/dist/src/git/bitbucket-provider.d.ts +50 -0
- package/dist/src/git/github-provider.d.ts +50 -0
- package/dist/src/git/gitlab-provider.d.ts +51 -0
- package/dist/src/git/provider.d.ts +210 -0
- package/dist/src/headless/run.d.ts +78 -0
- package/dist/src/index.d.ts +243 -0
- package/dist/src/index.js +2 -0
- package/dist/src/issues/enrichment.d.ts +76 -0
- package/dist/src/issues/index.d.ts +16 -0
- package/dist/src/issues/quick-links.d.ts +55 -0
- package/dist/src/pr/auto-merge.d.ts +75 -0
- package/dist/src/pr/pr-generator.d.ts +9 -0
- package/dist/src/pr/pr-manifest.d.ts +82 -0
- package/dist/src/pr/templates.d.ts +44 -0
- package/dist/src/registry/docker-tags.d.ts +56 -0
- package/dist/src/registry/eol.d.ts +87 -0
- package/dist/src/registry/oci-client.d.ts +98 -0
- package/dist/src/registry/registry-client.d.ts +39 -0
- package/dist/src/reports/history.d.ts +51 -0
- package/dist/src/reports/index.d.ts +23 -0
- package/dist/src/reports/metrics.d.ts +89 -0
- package/dist/src/reports/render.d.ts +33 -0
- package/dist/src/review/diff.d.ts +50 -0
- package/dist/src/review/engine.d.ts +49 -0
- package/dist/src/review/findings.d.ts +102 -0
- package/dist/src/review/guidelines.d.ts +46 -0
- package/dist/src/review/index.d.ts +48 -0
- package/dist/src/review/local.d.ts +81 -0
- package/dist/src/review/marker.d.ts +34 -0
- package/dist/src/review/poster.d.ts +39 -0
- package/dist/src/review/run.d.ts +24 -0
- package/dist/src/rules/engine.d.ts +108 -0
- package/dist/src/rules/index.d.ts +9 -0
- package/dist/src/rules/renovate.d.ts +25 -0
- package/dist/src/rules/schedule.d.ts +44 -0
- package/dist/src/scanner/catalog-scan.d.ts +39 -0
- package/dist/src/scanner/package-json-extras.d.ts +101 -0
- package/dist/src/scanner/package-scanner.d.ts +17 -0
- package/dist/src/scanner/resolution-drift.d.ts +81 -0
- package/dist/src/scanner/workspace-catalog.d.ts +53 -0
- package/dist/src/scheduler/scheduler.d.ts +27 -0
- package/dist/src/security/engine.d.ts +12 -0
- package/dist/src/security/loader.d.ts +7 -0
- package/dist/src/security/parser.d.ts +15 -0
- package/dist/src/security/rules/bash-injection.d.ts +18 -0
- package/dist/src/security/rules/dangerous-pull-request-target.d.ts +18 -0
- package/dist/src/security/rules/excessive-permissions.d.ts +14 -0
- package/dist/src/security/rules/index.d.ts +16 -0
- package/dist/src/security/rules/missing-timeout.d.ts +9 -0
- package/dist/src/security/rules/self-hosted-exposure.d.ts +13 -0
- package/dist/src/security/rules/unpinned-action.d.ts +10 -0
- package/dist/src/security/rules/walk.d.ts +13 -0
- package/dist/src/security/types.d.ts +64 -0
- package/dist/src/services/deprecated-dependencies-checker.d.ts +16 -0
- package/dist/src/services/release-notes-fetcher.d.ts +70 -0
- package/dist/src/services/security-advisories.d.ts +59 -0
- package/dist/src/setup.d.ts +162 -0
- package/dist/src/setup.js +2 -0
- package/dist/src/templates/github-actions.d.ts +31 -0
- package/dist/src/templates/gitlab-ci.d.ts +46 -0
- package/dist/src/types.d.ts +449 -0
- package/dist/src/upgrades/index.d.ts +18 -0
- package/dist/src/upgrades/migrate.d.ts +45 -0
- package/dist/src/upgrades/plan.d.ts +112 -0
- package/dist/src/upgrades/report.d.ts +22 -0
- package/dist/src/upgrades/span.d.ts +47 -0
- package/dist/src/upgrades/usage.d.ts +30 -0
- package/dist/src/upgrades/wire.d.ts +61 -0
- package/dist/src/utils/concurrency.d.ts +50 -0
- package/dist/src/utils/dependency-file-parser.d.ts +17 -0
- package/dist/src/utils/dockerfile-parser.d.ts +69 -0
- package/dist/src/utils/endpoints.d.ts +58 -0
- package/dist/src/utils/errors.d.ts +35 -0
- package/dist/src/utils/file-changes.d.ts +14 -0
- package/dist/src/utils/github-actions-parser.d.ts +21 -0
- package/dist/src/utils/globs.d.ts +22 -0
- package/dist/src/utils/helpers.d.ts +73 -0
- package/dist/src/utils/http.d.ts +81 -0
- package/dist/src/utils/lock-file.d.ts +28 -0
- package/dist/src/utils/logger.d.ts +45 -0
- package/dist/src/utils/package-paths.d.ts +6 -0
- package/dist/src/utils/pantry-parser.d.ts +30 -0
- package/dist/src/utils/repository.d.ts +41 -0
- package/dist/src/utils/security-format.d.ts +18 -0
- package/dist/src/utils/zig-parser.d.ts +18 -0
- package/dist/src/version/version-resolver.d.ts +9 -0
- package/package.json +115 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The drift for one package, or null when nothing is worth saying.
|
|
3
|
+
*
|
|
4
|
+
* Two ways to be behind, and the distinction is the point. A package pinned at
|
|
5
|
+
* `1.0.0` by its *own* manifest is neither: it is pinned, that was a decision,
|
|
6
|
+
* and reporting it every run is how a report gets ignored.
|
|
7
|
+
*/
|
|
8
|
+
export declare function driftFor(input: DriftInput): Drift | null;
|
|
9
|
+
/** Every drifting package in a tree, worst gap first. */
|
|
10
|
+
// eslint-disable-next-line pickier/no-unused-vars -- false positive: `inputs` is read by the loop below
|
|
11
|
+
export declare function findDrift(inputs: readonly DriftInput[]): Drift[];
|
|
12
|
+
/** One line a person can act on. */
|
|
13
|
+
export declare function describeDrift(drift: Drift): string;
|
|
14
|
+
/**
|
|
15
|
+
* The name to use for the repository's own manifest.
|
|
16
|
+
*
|
|
17
|
+
* A cap in your own `package.json` is a decision you made and can see; a cap in
|
|
18
|
+
* a dependant's is neither. Only the second is reported, so the two have to be
|
|
19
|
+
* distinguishable.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ROOT: 'root';
|
|
22
|
+
/**
|
|
23
|
+
* Packages that are behind for a reason no manifest shows.
|
|
24
|
+
*
|
|
25
|
+
* Everything else buddy does compares a *declared* range against the
|
|
26
|
+
* registry: `^1.2.0` is declared, `1.5.0` is published, so there is an update.
|
|
27
|
+
* That misses an entire class of staleness, and the missed class is the one
|
|
28
|
+
* that wastes the most time, because from inside the repository everything
|
|
29
|
+
* looks correct.
|
|
30
|
+
*
|
|
31
|
+
* **The case this exists for, which happened.** An application declared
|
|
32
|
+
* `@stacksjs/database@^0.70.315` and got it. It also depended, transitively, on
|
|
33
|
+
* `buddy`, which declared `ts-pantry@^0.10.11` while the rest of that family
|
|
34
|
+
* had moved to `^0.11`. Under hoisted linking one copy wins for the whole tree,
|
|
35
|
+
* so the cap decided it: `ts-pantry@0.10.56` was installed while `0.11.19`
|
|
36
|
+
* existed and satisfied every range the application itself declared. A fix
|
|
37
|
+
* released *for that application*, in response to a bug it reported, could not
|
|
38
|
+
* reach it.
|
|
39
|
+
*
|
|
40
|
+
* Nothing reported anything. Every declared range was satisfiable and current,
|
|
41
|
+
* `bun install` succeeded, and the only symptom was a fix that appeared not to
|
|
42
|
+
* work. It took reading each installed package.json by hand to find the cap.
|
|
43
|
+
*
|
|
44
|
+
* So: compare what is *installed* against the newest version every declared
|
|
45
|
+
* range would allow, and when they differ, name the dependant responsible.
|
|
46
|
+
* Naming it is most of the value - "ts-pantry is behind" sends somebody to the
|
|
47
|
+
* wrong repository; "buddy caps ts-pantry at ^0.10.11" is the fix.
|
|
48
|
+
*/
|
|
49
|
+
/** A range somebody declared, and who declared it. */
|
|
50
|
+
export declare interface DeclaredRange {
|
|
51
|
+
by: string
|
|
52
|
+
range: string
|
|
53
|
+
}
|
|
54
|
+
export declare interface DriftInput {
|
|
55
|
+
name: string
|
|
56
|
+
installed: string
|
|
57
|
+
available: readonly string[]
|
|
58
|
+
declared: readonly DeclaredRange[]
|
|
59
|
+
}
|
|
60
|
+
export declare interface Drift {
|
|
61
|
+
name: string
|
|
62
|
+
kind: DriftKind
|
|
63
|
+
installed: string
|
|
64
|
+
reachable: string
|
|
65
|
+
capping: DeclaredRange[]
|
|
66
|
+
latest: string
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Why a package is behind, because the two have different fixes.
|
|
70
|
+
*
|
|
71
|
+
* - `lockfile` - the declared ranges already allow something newer and the
|
|
72
|
+
* installed copy is older anyway. One `bun update` fixes it, here.
|
|
73
|
+
* - `capped` - the installed copy is the newest anything allows, and a
|
|
74
|
+
* dependant's range is why. No amount of installing fixes it; somebody has to
|
|
75
|
+
* widen a range in another repository.
|
|
76
|
+
*
|
|
77
|
+
* Separating them is most of the value. Both read as "behind" in a list, and
|
|
78
|
+
* one of them cannot be fixed from the repository looking at the list - which
|
|
79
|
+
* is exactly the confusion this module exists to end.
|
|
80
|
+
*/
|
|
81
|
+
export type DriftKind = 'lockfile' | 'capped';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse the catalogs from a `pnpm-workspace.yaml`.
|
|
3
|
+
*
|
|
4
|
+
* pnpm's catalogs move the version out of every `package.json` and into one
|
|
5
|
+
* place, so a workspace using them has package files whose versions are all
|
|
6
|
+
* `catalog:` — updating those would write the protocol string over itself and
|
|
7
|
+
* change nothing. The catalog is where the version actually lives.
|
|
8
|
+
*
|
|
9
|
+
* @param content - File content
|
|
10
|
+
* @returns Catalog entries, and whether any catalog was declared
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const { entries } = parseWorkspaceCatalogs(await Bun.file('pnpm-workspace.yaml').text())
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseWorkspaceCatalogs(content: string): WorkspaceCatalogs;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve a `catalog:` reference to the version it names.
|
|
19
|
+
*
|
|
20
|
+
* @param reference - A version string from a package.json
|
|
21
|
+
* @param catalogs - Entries parsed from the workspace file
|
|
22
|
+
* @param packageName - The package the reference belongs to
|
|
23
|
+
* @returns The catalog's version, or null when the reference is not a catalog
|
|
24
|
+
* reference or names a catalog with no entry for this package
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveCatalogReference(reference: string, catalogs: CatalogEntry[], packageName: string): string | null;
|
|
27
|
+
/** Whether a version string is a `catalog:` reference. */
|
|
28
|
+
export declare function isCatalogReference(version: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Write an updated version into a `pnpm-workspace.yaml`.
|
|
31
|
+
*
|
|
32
|
+
* Line-based rather than a YAML round-trip, because re-serializing loses the
|
|
33
|
+
* comments and key order a maintainer arranged. Matching is scoped to the
|
|
34
|
+
* catalog block the entry belongs to, so two catalogs naming the same package
|
|
35
|
+
* at different versions each keep their own.
|
|
36
|
+
*
|
|
37
|
+
* @param content - Current file content
|
|
38
|
+
* @param entry - The entry to update
|
|
39
|
+
* @param newVersion - Version to write
|
|
40
|
+
* @returns The updated content, unchanged when the entry was not found
|
|
41
|
+
*/
|
|
42
|
+
export declare function applyCatalogUpdate(content: string, entry: CatalogEntry, newVersion: string): string;
|
|
43
|
+
/** A dependency declared in a pnpm workspace catalog. */
|
|
44
|
+
export declare interface CatalogEntry {
|
|
45
|
+
name: string
|
|
46
|
+
version: string
|
|
47
|
+
catalog: string
|
|
48
|
+
}
|
|
49
|
+
/** Everything a `pnpm-workspace.yaml` declares. */
|
|
50
|
+
export declare interface WorkspaceCatalogs {
|
|
51
|
+
entries: CatalogEntry[]
|
|
52
|
+
hasCatalogs: boolean
|
|
53
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BuddyConfig } from '../types';
|
|
2
|
+
export declare interface ScheduleConfig {
|
|
3
|
+
cron: string
|
|
4
|
+
timezone?: string
|
|
5
|
+
runOnStartup?: boolean
|
|
6
|
+
maxRuntime?: number
|
|
7
|
+
}
|
|
8
|
+
export declare interface SchedulerJob {
|
|
9
|
+
id: string
|
|
10
|
+
name: string
|
|
11
|
+
schedule: ScheduleConfig
|
|
12
|
+
lastRun?: Date
|
|
13
|
+
nextRun?: Date
|
|
14
|
+
status: 'idle' | 'running' | 'error'
|
|
15
|
+
config: BuddyConfig
|
|
16
|
+
}
|
|
17
|
+
export declare class Scheduler {
|
|
18
|
+
constructor(verbose?: boolean);
|
|
19
|
+
addJob(job: SchedulerJob): void;
|
|
20
|
+
removeJob(jobId: string): void;
|
|
21
|
+
start(): void;
|
|
22
|
+
stop(): void;
|
|
23
|
+
getJobStatus(jobId: string): SchedulerJob | undefined;
|
|
24
|
+
getAllJobs(): SchedulerJob[];
|
|
25
|
+
static createJobFromConfig(config: BuddyConfig, jobId?: string): SchedulerJob;
|
|
26
|
+
static readonly PRESETS: unknown;
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AuditOptions, AuditResult, ParsedWorkflow } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Top-level entry point: discover workflows under `root` and run every
|
|
4
|
+
* rule against each one. Failure is determined by the presence of any
|
|
5
|
+
* `error`-severity finding so callers can `process.exit` on it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function audit(root: string, options?: AuditOptions): Promise<AuditResult>;
|
|
8
|
+
/**
|
|
9
|
+
* Run rules against an already-loaded set of workflows. Useful when the
|
|
10
|
+
* caller (e.g. buddy) has its own loader or supplies fixtures.
|
|
11
|
+
*/
|
|
12
|
+
export declare function auditParsed(workflows: ParsedWorkflow[], options?: AuditOptions): AuditResult;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ParsedWorkflow } from './types';
|
|
2
|
+
/*.{yml,yaml}` file under `root` and
|
|
3
|
+
* parse each one. Subdirectories of `workflows/` (composite actions live
|
|
4
|
+
* elsewhere; this is for triggered workflows specifically) are not
|
|
5
|
+
* traversed — GitHub itself only loads top-level files.
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadWorkflows(root: string): Promise<ParsedWorkflow[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ParsedWorkflow } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse a workflow file. Returns `null` if the YAML is unparseable so the
|
|
4
|
+
* caller can carry on with the rest of the suite — broken YAML is the
|
|
5
|
+
* checker's user's problem to fix, not buddy's to crash on.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseWorkflow(file: string, raw: string): ParsedWorkflow | null;
|
|
8
|
+
/**
|
|
9
|
+
* Best-effort 1-based line lookup for a literal substring. Used by rules
|
|
10
|
+
* to attach line numbers to findings — `Bun.YAML.parse` strips position
|
|
11
|
+
* info, so we scan the raw text instead. Returns `undefined` when the
|
|
12
|
+
* needle isn't found verbatim (rules then fall back to a file-level
|
|
13
|
+
* finding).
|
|
14
|
+
*/
|
|
15
|
+
export declare function findLine(raw: string, needle: string): number | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Rule } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* `${{ ... }}` interpolation inside a `run:` block is evaluated by the
|
|
4
|
+
* runner *before* the shell sees it — the resulting string becomes part
|
|
5
|
+
* of the command line. When the source is attacker-controlled (PR title,
|
|
6
|
+
* branch name, issue body, …), this is shell injection by design.
|
|
7
|
+
*
|
|
8
|
+
* Allowlist of known-safe contexts: anything from `secrets.*`, `vars.*`,
|
|
9
|
+
* `runner.*`, `env.*` (the env was set by the workflow, not the
|
|
10
|
+
* attacker), `github.repository`, `github.workflow`, `github.run_id`,
|
|
11
|
+
* `github.run_number`, `github.event_name`, `github.actor` (still risky
|
|
12
|
+
* but commonly accepted), `github.sha` (commit SHA, hex only).
|
|
13
|
+
*
|
|
14
|
+
* Anything else triggers a finding. We're deliberately noisy here — the
|
|
15
|
+
* cost of a false positive is low (move the value into `env:` and
|
|
16
|
+
* reference it as `"$VAR"`), the cost of a miss is RCE.
|
|
17
|
+
*/
|
|
18
|
+
export declare const bashInjection: Rule;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Rule } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* `pull_request_target` runs in the context of the *base* repo with full
|
|
4
|
+
* write permissions and access to secrets — but combining it with a
|
|
5
|
+
* `actions/checkout` of `${{ github.event.pull_request.head.sha }}` (or
|
|
6
|
+
* any reference that resolves to PR-author-controlled code) lets a
|
|
7
|
+
* malicious PR execute arbitrary code with those secrets. This is the
|
|
8
|
+
* single most exploited misconfiguration in GitHub Actions.
|
|
9
|
+
*
|
|
10
|
+
* We flag any workflow that:
|
|
11
|
+
* 1. Triggers on `pull_request_target`, AND
|
|
12
|
+
* 2. Uses `actions/checkout` (any version) with a `with.ref` referencing
|
|
13
|
+
* the PR head, OR uses checkout without an explicit `ref:` (the
|
|
14
|
+
* default `ref` in `pull_request_target` is the base, which is safe
|
|
15
|
+
* — but most authors don't realise this and still trip the next rule
|
|
16
|
+
* below).
|
|
17
|
+
*/
|
|
18
|
+
export declare const dangerousPullRequestTarget: Rule;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Flag two distinct hazards under the same rule because the fix shape is
|
|
4
|
+
* the same:
|
|
5
|
+
*
|
|
6
|
+
* 1. `permissions: write-all` — grants every scope, defeating GitHub's
|
|
7
|
+
* least-privilege model. A compromised step can do anything the token
|
|
8
|
+
* can do.
|
|
9
|
+
* 2. No top-level `permissions` block at all — the job inherits the
|
|
10
|
+
* repository default, which is `write-all` on most repos created
|
|
11
|
+
* before 2023. Explicit `permissions: contents: read` or similar is
|
|
12
|
+
* the safer default.
|
|
13
|
+
*/
|
|
14
|
+
export declare const excessivePermissions: Rule;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { bashInjection } from './bash-injection';
|
|
2
|
+
import { dangerousPullRequestTarget } from './dangerous-pull-request-target';
|
|
3
|
+
import { excessivePermissions } from './excessive-permissions';
|
|
4
|
+
import { missingTimeout } from './missing-timeout';
|
|
5
|
+
import { selfHostedExposure } from './self-hosted-exposure';
|
|
6
|
+
import { unpinnedAction } from './unpinned-action';
|
|
7
|
+
import type { Rule } from '../types';
|
|
8
|
+
export declare const rules: Rule[];
|
|
9
|
+
export {
|
|
10
|
+
bashInjection,
|
|
11
|
+
dangerousPullRequestTarget,
|
|
12
|
+
excessivePermissions,
|
|
13
|
+
missingTimeout,
|
|
14
|
+
selfHostedExposure,
|
|
15
|
+
unpinnedAction,
|
|
16
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rule } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Jobs without `timeout-minutes` default to GitHub's 6-hour cap. A
|
|
4
|
+
* compromised dependency that hangs (or a malicious script that mines
|
|
5
|
+
* crypto) can burn six hours of compute before the runner is reaped. A
|
|
6
|
+
* tighter explicit timeout limits the blast radius of resource-exhaustion
|
|
7
|
+
* attacks and surfaces hung CI quickly.
|
|
8
|
+
*/
|
|
9
|
+
export declare const missingTimeout: Rule;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Rule } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* `runs-on: self-hosted` without an additional label restriction lets any
|
|
4
|
+
* job in the repo (and, on a public repo, any PR) land on a self-hosted
|
|
5
|
+
* runner. That runner persists state between jobs by default — a single
|
|
6
|
+
* malicious checkout can implant tools that affect every subsequent job.
|
|
7
|
+
*
|
|
8
|
+
* The advice from GitHub's own hardening guide: never use bare
|
|
9
|
+
* `self-hosted` on a public repo, and always combine it with at least one
|
|
10
|
+
* scoping label (project name, environment, etc.) so the matching pool
|
|
11
|
+
* is explicit.
|
|
12
|
+
*/
|
|
13
|
+
export declare const selfHostedExposure: Rule;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Rule } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Flag third-party actions referenced by a mutable tag (`@v4`, `@main`).
|
|
4
|
+
* The canonical defence against the Shai-Hulud-style worm is to pin to a
|
|
5
|
+
* full commit SHA so a malicious release/branch push can't silently swap
|
|
6
|
+
* the binary you're running. We exempt actions owned by `actions/` and
|
|
7
|
+
* `github/` because GitHub itself controls those orgs — the rest of the
|
|
8
|
+
* world should be SHA-pinned.
|
|
9
|
+
*/
|
|
10
|
+
export declare const unpinnedAction: Rule;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ParsedWorkflow, WorkflowJob, WorkflowStep } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Iterate over every step in every job. Rules use this so they don't each
|
|
4
|
+
* re-implement the nested-object walk.
|
|
5
|
+
*/
|
|
6
|
+
export declare function walkSteps(wf: ParsedWorkflow): Generator<WalkedStep>;
|
|
7
|
+
export declare function walkJobs(wf: ParsedWorkflow): Generator<{ jobId: string, job: WorkflowJob }>;
|
|
8
|
+
export declare interface WalkedStep {
|
|
9
|
+
jobId: string
|
|
10
|
+
job: WorkflowJob
|
|
11
|
+
stepIndex: number
|
|
12
|
+
step: WorkflowStep
|
|
13
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export declare interface Finding {
|
|
2
|
+
ruleId: string
|
|
3
|
+
severity: Severity
|
|
4
|
+
message: string
|
|
5
|
+
detail?: string
|
|
6
|
+
file: string
|
|
7
|
+
line?: number
|
|
8
|
+
fix?: string
|
|
9
|
+
}
|
|
10
|
+
export declare interface ParsedWorkflow {
|
|
11
|
+
file: string
|
|
12
|
+
raw: string
|
|
13
|
+
data: WorkflowData
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Loose shape of a GitHub Actions workflow. We only declare the fields we
|
|
17
|
+
* inspect — the parser hands back whatever YAML produced and rules narrow
|
|
18
|
+
* as needed.
|
|
19
|
+
*/
|
|
20
|
+
export declare interface WorkflowData {
|
|
21
|
+
name?: string
|
|
22
|
+
on?: WorkflowTriggers
|
|
23
|
+
permissions?: WorkflowPermissions
|
|
24
|
+
jobs?: Record<string, WorkflowJob>
|
|
25
|
+
[key: string]: unknown
|
|
26
|
+
}
|
|
27
|
+
export declare interface WorkflowJob {
|
|
28
|
+
'name'?: string
|
|
29
|
+
'runs-on'?: string | string[]
|
|
30
|
+
'permissions'?: WorkflowPermissions
|
|
31
|
+
'timeout-minutes'?: number
|
|
32
|
+
'steps'?: WorkflowStep[]
|
|
33
|
+
[key: string]: unknown
|
|
34
|
+
}
|
|
35
|
+
export declare interface WorkflowStep {
|
|
36
|
+
name?: string
|
|
37
|
+
uses?: string
|
|
38
|
+
with?: Record<string, unknown>
|
|
39
|
+
run?: string
|
|
40
|
+
env?: Record<string, string>
|
|
41
|
+
[key: string]: unknown
|
|
42
|
+
}
|
|
43
|
+
export declare interface Rule {
|
|
44
|
+
id: string
|
|
45
|
+
defaultSeverity: Severity
|
|
46
|
+
description: string
|
|
47
|
+
check: (workflow: ParsedWorkflow) => Finding[]
|
|
48
|
+
}
|
|
49
|
+
export declare interface AuditOptions {
|
|
50
|
+
rules?: Rule[]
|
|
51
|
+
ignore?: string[]
|
|
52
|
+
}
|
|
53
|
+
export declare interface AuditResult {
|
|
54
|
+
workflows: ParsedWorkflow[]
|
|
55
|
+
findings: Finding[]
|
|
56
|
+
failed: boolean
|
|
57
|
+
}
|
|
58
|
+
export type Severity = 'error' | 'warning' | 'info';
|
|
59
|
+
export type WorkflowTriggers = | string
|
|
60
|
+
| string[]
|
|
61
|
+
| Record<string, unknown>;
|
|
62
|
+
export type WorkflowPermissions = | 'read-all'
|
|
63
|
+
| 'write-all'
|
|
64
|
+
| Record<string, 'read' | 'write' | 'none'>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Logger } from '../utils/logger';
|
|
2
|
+
import type { PackageFile } from '../types';
|
|
3
|
+
export declare interface DeprecatedDependency {
|
|
4
|
+
name: string
|
|
5
|
+
currentVersion: string
|
|
6
|
+
datasource: string
|
|
7
|
+
file: string
|
|
8
|
+
type: string
|
|
9
|
+
replacementAvailable: boolean
|
|
10
|
+
suggestedReplacement?: string
|
|
11
|
+
deprecationMessage?: string
|
|
12
|
+
}
|
|
13
|
+
export declare class DeprecatedDependenciesChecker {
|
|
14
|
+
constructor(logger?: Logger);
|
|
15
|
+
checkDeprecatedDependencies(packageFiles: PackageFile[]): Promise<DeprecatedDependency[]>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Logger } from '../utils/logger';
|
|
2
|
+
export declare interface ReleaseNote {
|
|
3
|
+
version: string
|
|
4
|
+
date: string
|
|
5
|
+
title: string
|
|
6
|
+
body: string
|
|
7
|
+
htmlUrl: string
|
|
8
|
+
compareUrl?: string
|
|
9
|
+
author?: string
|
|
10
|
+
isPrerelease: boolean
|
|
11
|
+
assets?: ReleaseAsset[]
|
|
12
|
+
}
|
|
13
|
+
export declare interface ReleaseAsset {
|
|
14
|
+
name: string
|
|
15
|
+
downloadUrl: string
|
|
16
|
+
size: number
|
|
17
|
+
contentType: string
|
|
18
|
+
}
|
|
19
|
+
export declare interface ChangelogEntry {
|
|
20
|
+
version: string
|
|
21
|
+
date: string
|
|
22
|
+
changes: {
|
|
23
|
+
added?: string[]
|
|
24
|
+
changed?: string[]
|
|
25
|
+
deprecated?: string[]
|
|
26
|
+
removed?: string[]
|
|
27
|
+
fixed?: string[]
|
|
28
|
+
security?: string[]
|
|
29
|
+
}
|
|
30
|
+
notes?: string
|
|
31
|
+
}
|
|
32
|
+
export declare interface PackageInfo {
|
|
33
|
+
name: string
|
|
34
|
+
description?: string
|
|
35
|
+
homepage?: string
|
|
36
|
+
repository?: {
|
|
37
|
+
type: string
|
|
38
|
+
url: string
|
|
39
|
+
directory?: string
|
|
40
|
+
}
|
|
41
|
+
license?: string
|
|
42
|
+
author?: string | { name: string, email?: string, url?: string }
|
|
43
|
+
keywords?: string[]
|
|
44
|
+
weeklyDownloads?: number
|
|
45
|
+
lastPublish?: string
|
|
46
|
+
maintainers?: Array<{ name: string, email?: string }>
|
|
47
|
+
}
|
|
48
|
+
export declare class ReleaseNotesFetcher {
|
|
49
|
+
constructor(logger?: Logger);
|
|
50
|
+
fetchPackageInfo(packageName: string, currentVersion: string, newVersion: string): Promise<{
|
|
51
|
+
packageInfo: PackageInfo
|
|
52
|
+
releaseNotes: ReleaseNote[]
|
|
53
|
+
changelog: ChangelogEntry[]
|
|
54
|
+
compareUrl?: string
|
|
55
|
+
}>;
|
|
56
|
+
fetchSpanReleases(packageName: string, currentVersion: string, newVersion: string, maxPages?: number): Promise<ReleaseNote[]>;
|
|
57
|
+
generatePackageBadges(packageInfo: PackageInfo, currentVersion: string, newVersion: string): {
|
|
58
|
+
age: string
|
|
59
|
+
adoption: string
|
|
60
|
+
passing: string
|
|
61
|
+
confidence: string
|
|
62
|
+
};
|
|
63
|
+
fetchComposerPackageInfo(packageName: string): Promise<PackageInfo>;
|
|
64
|
+
generateComposerBadges(packageInfo: PackageInfo, currentVersion: string, newVersion: string): {
|
|
65
|
+
age: string
|
|
66
|
+
adoption: string
|
|
67
|
+
passing: string
|
|
68
|
+
confidence: string
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Dependency, PackageUpdate, SecurityAdvisory, VulnerabilitySeverity } from '../types';
|
|
2
|
+
import type { Logger } from '../utils/logger';
|
|
3
|
+
/**
|
|
4
|
+
* Map a buddy dependency type onto an OSV ecosystem identifier.
|
|
5
|
+
*
|
|
6
|
+
* Returns `null` for dependency kinds OSV does not index (GitHub Actions,
|
|
7
|
+
* Docker images, pkgx packages) so callers can skip them without a request.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toOsvEcosystem(dependencyType: Dependency['type']): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Normalize the several severity encodings OSV records carry into buddy's
|
|
12
|
+
* four-level scale.
|
|
13
|
+
*
|
|
14
|
+
* GitHub-sourced records expose a plain word under `database_specific`; others
|
|
15
|
+
* only carry a CVSS vector, which is bucketed by its base score band. Records
|
|
16
|
+
* with neither are treated as `moderate` — reporting them is more useful than
|
|
17
|
+
* dropping them, and understating a real advisory is worse than overstating.
|
|
18
|
+
*/
|
|
19
|
+
export declare function normalizeSeverity(vuln: OsvVulnerability): VulnerabilitySeverity;
|
|
20
|
+
/** Stable key identifying a package version across batch request/response. */
|
|
21
|
+
export declare function advisoryKey(query: AdvisoryQuery): string;
|
|
22
|
+
declare interface OsvVulnerability {
|
|
23
|
+
id: string
|
|
24
|
+
aliases?: string[]
|
|
25
|
+
summary?: string
|
|
26
|
+
details?: string
|
|
27
|
+
severity?: Array<{ type?: string, score?: string }>
|
|
28
|
+
database_specific?: { severity?: string }
|
|
29
|
+
affected?: Array<{
|
|
30
|
+
package?: { name?: string, ecosystem?: string }
|
|
31
|
+
ranges?: Array<{ type?: string, events?: Array<{ introduced?: string, fixed?: string }> }>
|
|
32
|
+
}>
|
|
33
|
+
}
|
|
34
|
+
export declare interface AdvisoryQuery {
|
|
35
|
+
name: string
|
|
36
|
+
version: string
|
|
37
|
+
ecosystem: string
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Looks up known vulnerabilities for dependency versions via the OSV.dev
|
|
41
|
+
* aggregated advisory database.
|
|
42
|
+
*
|
|
43
|
+
* OSV is used rather than the GitHub Advisory GraphQL API because it needs no
|
|
44
|
+
* authentication, covers npm and Packagist from one endpoint, and offers a
|
|
45
|
+
* batch query that resolves an entire dependency tree in a couple of requests.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const service = new SecurityAdvisoryService(logger)
|
|
50
|
+
* const advisories = await service.findAdvisories([
|
|
51
|
+
* { name: 'lodash', version: '4.17.15', ecosystem: 'npm' },
|
|
52
|
+
* ])
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare class SecurityAdvisoryService {
|
|
56
|
+
constructor(logger: Logger, concurrency?: number);
|
|
57
|
+
findAdvisories(queries: readonly AdvisoryQuery[]): Promise<Map<string, SecurityAdvisory[]>>;
|
|
58
|
+
annotateUpdates(updates: PackageUpdate[], minimumSeverity?: VulnerabilitySeverity): Promise<PackageUpdate[]>;
|
|
59
|
+
}
|