@exodus/stasis 1.0.0-beta.1 → 1.0.0-beta.11

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.
Files changed (48) hide show
  1. package/README.md +32 -8
  2. package/bin/stasis.js +386 -213
  3. package/package.json +52 -12
  4. package/src/audit-corrections.js +96 -0
  5. package/src/audit.js +319 -64
  6. package/src/babel-worker.cjs +65 -0
  7. package/src/babel.js +131 -0
  8. package/src/bundle-from-lockfile.js +14 -22
  9. package/src/bundle-reader.js +77 -0
  10. package/src/cmd/build.js +96 -128
  11. package/src/cmd/bundle.js +1121 -654
  12. package/src/cmd/diff.js +2 -19
  13. package/src/cmd/github-bundle.js +39 -0
  14. package/src/cmd/output.js +36 -0
  15. package/src/cmd/sbom.js +7 -19
  16. package/src/diff.js +80 -129
  17. package/src/installed-commits.js +182 -0
  18. package/src/json-stream.js +283 -0
  19. package/src/loader-mock.js +8 -15
  20. package/src/loaders/bash.js +49 -116
  21. package/src/loaders/cargo.js +1716 -0
  22. package/src/loaders/foundry.js +923 -0
  23. package/src/loaders/paths.js +33 -0
  24. package/src/loaders/php.js +375 -402
  25. package/src/loaders/rust.js +3254 -242
  26. package/src/loaders/solidity-ownership.js +531 -0
  27. package/src/loaders/solidity.js +412 -162
  28. package/src/loaders/toml.js +68 -0
  29. package/src/metro-resolver.js +150 -0
  30. package/src/metro-transformer.js +3 -2
  31. package/src/mock.js +57 -165
  32. package/src/parse.js +4 -16
  33. package/src/resolve-fields.js +370 -0
  34. package/src/resolve-node.js +419 -0
  35. package/src/resolve-typescript.js +541 -0
  36. package/src/rollup.js +5 -0
  37. package/src/sbom.js +120 -97
  38. package/src/scan.js +348 -180
  39. package/src/vfs-bundle/entries.js +144 -0
  40. package/src/vfs-bundle/github.js +204 -0
  41. package/src/vfs-bundle/prisma.js +439 -0
  42. package/src/vfs-bundle/soldeer.js +125 -0
  43. package/src/vfs-bundle/tree.js +647 -0
  44. package/src/vfs-bundle.js +80 -0
  45. package/src/why.js +436 -0
  46. package/src/apis/npm/index.js +0 -36
  47. package/src/apis/npm/semver.cjs +0 -44
  48. package/src/cmd/extract.js +0 -193
package/package.json CHANGED
@@ -1,54 +1,80 @@
1
1
  {
2
2
  "name": "@exodus/stasis",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.11",
4
4
  "description": "File-level source bundles and lockfiles",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  "./esbuild": "./src/esbuild.js",
8
8
  "./webpack": "./src/webpack.js",
9
+ "./rollup": "./src/rollup.js",
9
10
  "./metro": "./src/metro.js",
10
11
  "./metro-transformer": "./src/metro-transformer.js",
11
12
  "./loader": "./src/loader.js",
12
13
  "./mock": "./src/mock.js",
13
14
  "./bundle": "./src/bundle.js",
15
+ "./bundle-reader": "./src/bundle-reader.js",
14
16
  "./cmd/bundle": "./src/cmd/bundle.js",
15
17
  "./cmd/build": "./src/cmd/build.js",
16
18
  "./diff": "./src/diff.js",
17
19
  "./lockfile": "./src/lockfile.js",
18
20
  "./prune": "./src/prune.js",
19
21
  "./sbom": "./src/sbom.js",
22
+ "./audit-corrections": "./src/audit-corrections.js",
23
+ "./vfs-bundle": "./src/vfs-bundle.js",
20
24
  "./logo.svg": "./logo.svg"
21
25
  },
22
26
  "files": [
23
27
  "bin/stasis.js",
24
28
  "logo.svg",
25
- "src/apis/npm/index.js",
26
- "src/apis/npm/semver.cjs",
29
+ "src/audit-corrections.js",
27
30
  "src/audit.js",
31
+ "src/babel.js",
32
+ "src/babel-worker.cjs",
28
33
  "src/bundle.js",
29
34
  "src/bundle-from-lockfile.js",
35
+ "src/bundle-reader.js",
30
36
  "src/cmd/bundle.js",
31
37
  "src/cmd/build.js",
32
38
  "src/cmd/diff.js",
33
- "src/cmd/extract.js",
39
+ "src/cmd/github-bundle.js",
40
+ "src/cmd/output.js",
34
41
  "src/cmd/sbom.js",
35
42
  "src/diff.js",
36
43
  "src/esbuild.js",
44
+ "src/installed-commits.js",
45
+ "src/json-stream.js",
37
46
  "src/loader.js",
38
47
  "src/loader-mock.js",
39
48
  "src/loaders/bash.js",
49
+ "src/loaders/cargo.js",
50
+ "src/loaders/foundry.js",
40
51
  "src/loaders/rust.js",
41
52
  "src/loaders/solidity.js",
53
+ "src/loaders/solidity-ownership.js",
54
+ "src/loaders/toml.js",
42
55
  "src/loaders/php.js",
56
+ "src/loaders/paths.js",
43
57
  "src/lockfile.js",
44
58
  "src/metro.js",
59
+ "src/metro-resolver.js",
45
60
  "src/metro-transformer.js",
46
61
  "src/mock.js",
47
62
  "src/parse.js",
48
63
  "src/prune.js",
64
+ "src/resolve-fields.js",
65
+ "src/resolve-node.js",
66
+ "src/resolve-typescript.js",
67
+ "src/rollup.js",
49
68
  "src/sbom.js",
50
69
  "src/scan.js",
51
- "src/webpack.js"
70
+ "src/vfs-bundle.js",
71
+ "src/vfs-bundle/entries.js",
72
+ "src/vfs-bundle/github.js",
73
+ "src/vfs-bundle/prisma.js",
74
+ "src/vfs-bundle/soldeer.js",
75
+ "src/vfs-bundle/tree.js",
76
+ "src/webpack.js",
77
+ "src/why.js"
52
78
  ],
53
79
  "engines": {
54
80
  "node": ">=24.14.0"
@@ -58,26 +84,40 @@
58
84
  },
59
85
  "repository": {
60
86
  "type": "git",
61
- "url": "git+https://github.com/ExodusOSS/stasis.git",
87
+ "url": "git+https://github.com/PreventiveMeasures/stasis.git",
62
88
  "directory": "stasis"
63
89
  },
64
90
  "author": "Exodus Movement, Inc.",
65
91
  "license": "MIT",
66
92
  "bugs": {
67
- "url": "https://github.com/ExodusOSS/stasis/issues"
93
+ "url": "https://github.com/PreventiveMeasures/stasis/issues"
68
94
  },
69
- "homepage": "https://github.com/ExodusOSS/stasis#readme",
95
+ "homepage": "https://github.com/PreventiveMeasures/stasis#readme",
70
96
  "dependencies": {
71
- "@exodus/stasis-core": "1.0.0-beta.1",
72
- "@exodus/stasis-plugins": "1.0.0-beta.1",
73
- "oxc-parser": "^0.94.0"
97
+ "@exodus/bytes": "^1.16.0",
98
+ "@exodus/stasis-core": "1.0.0-beta.11",
99
+ "@exodus/stasis-plugins": "1.0.0-beta.11",
100
+ "@preventive/archive": "^1.2.0",
101
+ "@preventive/deptree": "^1.0.1",
102
+ "@preventive/lockfile": "^1.2.0",
103
+ "@preventive/upstream": "^1.3.0",
104
+ "@preventive/vfs": "1.0.0-beta.4",
105
+ "oxc-parser": "^0.152.0"
74
106
  },
75
107
  "peerDependencies": {
76
- "esbuild": "*"
108
+ "@prisma/client-generator-ts": "7.10.0",
109
+ "esbuild": "*",
110
+ "flow-remove-types": "*"
77
111
  },
78
112
  "peerDependenciesMeta": {
113
+ "@prisma/client-generator-ts": {
114
+ "optional": true
115
+ },
79
116
  "esbuild": {
80
117
  "optional": true
118
+ },
119
+ "flow-remove-types": {
120
+ "optional": true
81
121
  }
82
122
  }
83
123
  }
@@ -0,0 +1,96 @@
1
+ import { satisfies, valid } from '@preventive/upstream/semver.js'
2
+
3
+ // Manual corrections to audit findings: files that must NOT count as evidence
4
+ // that a (potentially vulnerable) package's code is present. An import edge whose
5
+ // target is one of these files is not evidence the package is really used, so a
6
+ // package pulled in only through corrected files is skipped by the audit (see
7
+ // collectPackagesFromFile) -- none of its real code ships, so no advisory applies.
8
+ //
9
+ // Exported as `@exodus/stasis/audit-corrections`, as plain data, so a tool that
10
+ // lays out or reads packages without stasis -- a tree @preventive/deptree builds,
11
+ // a server reading bundles -- can apply the same corrections without its own copy.
12
+ // Each entry names a package of `ecosystem`, one audit-irrelevant `file` (relative
13
+ // to the module dir), `range` -- the semver range VERIFIED to match the rationale --
14
+ // and `integrity`, the sha512 of every distinct copy of `file` the versions in
15
+ // `range` publish, as a stasis lockfile records a file: a holder of the file's bytes
16
+ // can tell they are one of the copies verified. The correction never applies outside
17
+ // the range: a release could change the file, so the range is widened only after
18
+ // re-checking the file in the new versions, adding any new copy's integrity. Frozen,
19
+ // as the audit reads these very objects.
20
+ export const CORRECTIONS = Object.freeze([
21
+ {
22
+ // ws's browser build is a noop stub -- `module.exports = function () { throw
23
+ // new Error('ws does not work in the browser...') }` -- with none of the
24
+ // WebSocket implementation in it. browser.js ships from 6.0.0 on; every copy
25
+ // through 8.22.0 (latest at the time of writing) is one of these two, which
26
+ // differ only in a space; re-check browser.js before widening.
27
+ ecosystem: 'npm',
28
+ name: 'ws',
29
+ file: 'browser.js',
30
+ range: '<=8.22.0',
31
+ integrity: [
32
+ 'sha512-98uEc4/THUpHCA7AQwBKLHHmxV6leyGmPkDAYZsoBiigxjKL8//TIb/oUKDUJLc+s/pwdGA9LR0F9e7nZHfXUQ==', // `function ()`: 6.0.0 - 6.1.1, 7.3.1 - 8.22.0
33
+ 'sha512-F7vx6oiX9vsFoxNPTudk20Hjp7IzJePAJCYaSoX9FMJ2JaGVcFx4Bkw5W7+I3a1DsonitnosbpuG1qAMsUwH7w==', // `function()`: 6.1.2 - 7.3.0
34
+ ],
35
+ },
36
+ {
37
+ // node-fetch's browser build re-exports the environment's native fetch
38
+ // (`module.exports = globalObject.fetch`, plus Headers/Request/Response) --
39
+ // none of the node-fetch implementation, where its advisories live, is in it.
40
+ // browser.js ships only from 2.0.0 through 2.7.0 (3.x dropped it); every copy
41
+ // in the range is one of these, which differ in how they find the global.
42
+ ecosystem: 'npm',
43
+ name: 'node-fetch',
44
+ file: 'browser.js',
45
+ range: '<=2.7.0',
46
+ integrity: [
47
+ 'sha512-uCZB0X6rUVIf5lZU2NN9/Z1Fd6cPCLg4M9eduYxOgSP3QZNwi0/xSa/s6AUFtvLz4y4MK02SJihOIhDoFIzdiA==', // 2.0.0 - 2.1.1
48
+ 'sha512-toQ4RDdyjsAxTaxnaLs2AE56rXws+jMZV896U8pP0MSuKRiq8ZGKkOTMsvyCJoAJTbrgoQpr89H2n8+Z1ALcYA==', // 2.1.2
49
+ 'sha512-LOd+I1R3xYSCHFN9oj3xeN3wa7fYYx5XQKTiKkvWn4dSYVgHI2jsXZp0mJt5KlQg3ECXXh5UtpEW7kGu1dG/aQ==', // 2.2.0 - 2.2.1
50
+ 'sha512-2yo4Ysl+g09ocycwEBcN7IkSvM/KPpO9CW+1FI+0QfzvWJfaQepo+WEqn1/o5Og1weM14flcdv23hqZtxFXFUw==', // 2.3.0 - 2.6.0
51
+ 'sha512-WgHaZJVwFovVrKVySaKzxzXssn5kY8y3x8NJThodDRL9nwUxV7Q1z/RRzuLZ2lNkxabHLpG/l+vu7KQ2tGbP8g==', // 2.6.1 - 2.6.7
52
+ 'sha512-84sQFcu3uzgEsJOjIhz6tE8vInV1STCA4sX5EI9NK3Tt8n/Kb1serbKMz+YkdOAuCspHRiSUW2qV01z0wOgIXg==', // 2.6.8
53
+ 'sha512-SkBfLO20d2Ngr6nhxgh/Pt6Yqe6oW8EB99KSPq0lrW0se8jIiRF3YpOe7hHbfNWxuNCsKoZZT98uCJI9OJAa/Q==', // 2.6.9 - 2.7.0
54
+ ],
55
+ },
56
+ ].map((correction) => Object.freeze({ ...correction, integrity: Object.freeze(correction.integrity) })))
57
+
58
+ // Is `rel` (a file path relative to the module dir) audit-irrelevant for
59
+ // `name@version` of `ecosystem`? Unknown or unparsable versions are never
60
+ // corrected (fail closed: the package stays audited).
61
+ function isCorrectedFile(name, version, rel, ecosystem) {
62
+ for (const correction of CORRECTIONS) {
63
+ if (correction.ecosystem !== ecosystem || correction.name !== name || correction.file !== rel) continue
64
+ if (valid(version) && satisfies(version, correction.range)) return true
65
+ }
66
+ return false
67
+ }
68
+
69
+ // A manifest (top-level or nested) is never code: the resolution graph records
70
+ // resolver/metadata reads of `package.json` as edges (react-native scans sibling
71
+ // packages' manifests for Haste/asset resolution) and consumers record them
72
+ // alongside bundled files, but no package code ships through one. So too for the
73
+ // manifests the other ecosystems' bundles carry beside a dependency's code
74
+ // (--cargo-manifests, --manifests): its Cargo.toml and the checksums cargo vendored
75
+ // it with (a registry's copy, a git checkout's, or one whose source isn't known),
76
+ // its composer.json, a Solidity dependency's foundry.toml and remappings.
77
+ const CARGO_MANIFESTS = new Set(['Cargo.toml', 'Cargo.lock', '.cargo-checksum.json'])
78
+ const MANIFESTS = {
79
+ npm: new Set(['package.json']),
80
+ cargo: CARGO_MANIFESTS,
81
+ 'cargo-git': CARGO_MANIFESTS,
82
+ 'cargo-unknown': CARGO_MANIFESTS,
83
+ composer: new Set(['composer.json', 'composer.lock']),
84
+ soldeer: new Set(['package.json', 'foundry.toml', 'remappings.txt', 'soldeer.toml']),
85
+ github: new Set(['package.json', 'foundry.toml', 'remappings.txt', 'soldeer.toml']),
86
+ }
87
+ const isManifest = (rel, ecosystem) => MANIFESTS[ecosystem]?.has(rel.slice(rel.lastIndexOf('/') + 1)) ?? false
88
+
89
+ // Is `rel` evidence that `name@version`'s REAL code is present, of a dependency of
90
+ // `ecosystem` (npm by default)? This is the one rule every audit surface shares --
91
+ // package presence, the reason column, and the --why chain graph all count a file
92
+ // (or an edge targeting it) only when it passes. Manifests never do; CORRECTIONS'
93
+ // files don't within their verified range.
94
+ export function isEvidenceFile(name, version, rel, ecosystem = 'npm') {
95
+ return !isManifest(rel, ecosystem) && !isCorrectedFile(name, version, rel, ecosystem)
96
+ }