@exodus/stasis 1.0.0-beta.9 → 1.0.0-rc.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.
Files changed (67) hide show
  1. package/README.md +6 -2
  2. package/bin/stasis.js +222 -334
  3. package/package.json +38 -14
  4. package/src/audit-corrections.js +11 -42
  5. package/src/audit.js +256 -212
  6. package/src/babel.js +119 -82
  7. package/src/bundle-from-lockfile.js +9 -21
  8. package/src/bundle-reader.js +24 -8
  9. package/src/bundle.js +0 -3
  10. package/src/cmd/build.js +211 -117
  11. package/src/cmd/bundle-options.js +347 -0
  12. package/src/cmd/bundle.js +1664 -1001
  13. package/src/cmd/diff.js +1 -4
  14. package/src/cmd/github-bundle.js +48 -21
  15. package/src/cmd/output.js +25 -12
  16. package/src/cmd/sbom.js +6 -9
  17. package/src/cmd/tokens.js +60 -0
  18. package/src/define.js +218 -0
  19. package/src/diff.js +73 -129
  20. package/src/esbuild.js +0 -4
  21. package/src/flow.js +27 -0
  22. package/src/installed.js +265 -0
  23. package/src/json-stream.js +4 -9
  24. package/src/loader-mock.js +3 -8
  25. package/src/loader.js +1 -5
  26. package/src/loaders/bash.js +43 -120
  27. package/src/loaders/cargo.js +301 -808
  28. package/src/loaders/foundry.js +112 -290
  29. package/src/loaders/paths.js +15 -26
  30. package/src/loaders/php.js +211 -492
  31. package/src/loaders/rust.js +518 -1461
  32. package/src/loaders/solidity-ownership.js +51 -142
  33. package/src/loaders/solidity.js +42 -188
  34. package/src/loaders/toml.js +7 -17
  35. package/src/lockfile.js +0 -3
  36. package/src/metro-assets.js +41 -0
  37. package/src/metro-resolver.js +58 -133
  38. package/src/metro-transformer.js +0 -6
  39. package/src/metro.js +0 -4
  40. package/src/mock.js +32 -80
  41. package/src/parse.js +8 -7
  42. package/src/prune.js +0 -3
  43. package/src/resolve-fields.js +152 -249
  44. package/src/resolve-node.js +29 -45
  45. package/src/resolve-typescript.js +166 -298
  46. package/src/rollup.js +0 -4
  47. package/src/run-installed.js +10 -0
  48. package/src/sbom.js +70 -97
  49. package/src/scan.js +240 -282
  50. package/src/sixel.js +310 -0
  51. package/src/table.js +95 -0
  52. package/src/validate-notes.d.ts +19 -0
  53. package/src/validate-notes.js +72 -0
  54. package/src/validate.d.ts +159 -0
  55. package/src/validate.js +1315 -0
  56. package/src/vfs-bundle/entries.js +50 -46
  57. package/src/vfs-bundle/github.js +114 -94
  58. package/src/vfs-bundle/glob.js +379 -0
  59. package/src/vfs-bundle/lazy.js +99 -0
  60. package/src/vfs-bundle/prisma.js +235 -105
  61. package/src/vfs-bundle/soldeer.js +28 -49
  62. package/src/vfs-bundle/tree.js +418 -277
  63. package/src/vfs-bundle/yarnclean.js +79 -0
  64. package/src/vfs-bundle.js +24 -55
  65. package/src/webpack.js +0 -4
  66. package/src/why.js +79 -231
  67. package/src/installed-commits.js +0 -182
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/stasis",
3
- "version": "1.0.0-beta.9",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "File-level source bundles and lockfiles",
5
5
  "type": "module",
6
6
  "exports": {
@@ -20,7 +20,15 @@
20
20
  "./prune": "./src/prune.js",
21
21
  "./sbom": "./src/sbom.js",
22
22
  "./audit-corrections": "./src/audit-corrections.js",
23
+ "./validate": {
24
+ "types": "./src/validate.d.ts",
25
+ "default": "./src/validate.js"
26
+ },
23
27
  "./vfs-bundle": "./src/vfs-bundle.js",
28
+ "./validate-notes": {
29
+ "types": "./src/validate-notes.d.ts",
30
+ "default": "./src/validate-notes.js"
31
+ },
24
32
  "./logo.svg": "./logo.svg"
25
33
  },
26
34
  "files": [
@@ -34,14 +42,18 @@
34
42
  "src/bundle-from-lockfile.js",
35
43
  "src/bundle-reader.js",
36
44
  "src/cmd/bundle.js",
45
+ "src/cmd/bundle-options.js",
37
46
  "src/cmd/build.js",
38
47
  "src/cmd/diff.js",
39
48
  "src/cmd/github-bundle.js",
40
49
  "src/cmd/output.js",
41
50
  "src/cmd/sbom.js",
51
+ "src/cmd/tokens.js",
52
+ "src/define.js",
42
53
  "src/diff.js",
43
54
  "src/esbuild.js",
44
- "src/installed-commits.js",
55
+ "src/flow.js",
56
+ "src/installed.js",
45
57
  "src/json-stream.js",
46
58
  "src/loader.js",
47
59
  "src/loader-mock.js",
@@ -56,6 +68,7 @@
56
68
  "src/loaders/paths.js",
57
69
  "src/lockfile.js",
58
70
  "src/metro.js",
71
+ "src/metro-assets.js",
59
72
  "src/metro-resolver.js",
60
73
  "src/metro-transformer.js",
61
74
  "src/mock.js",
@@ -65,14 +78,24 @@
65
78
  "src/resolve-node.js",
66
79
  "src/resolve-typescript.js",
67
80
  "src/rollup.js",
81
+ "src/run-installed.js",
68
82
  "src/sbom.js",
83
+ "src/sixel.js",
84
+ "src/table.js",
85
+ "src/validate.d.ts",
86
+ "src/validate.js",
87
+ "src/validate-notes.d.ts",
88
+ "src/validate-notes.js",
69
89
  "src/scan.js",
70
90
  "src/vfs-bundle.js",
71
91
  "src/vfs-bundle/entries.js",
72
92
  "src/vfs-bundle/github.js",
93
+ "src/vfs-bundle/glob.js",
94
+ "src/vfs-bundle/lazy.js",
73
95
  "src/vfs-bundle/prisma.js",
74
96
  "src/vfs-bundle/soldeer.js",
75
97
  "src/vfs-bundle/tree.js",
98
+ "src/vfs-bundle/yarnclean.js",
76
99
  "src/webpack.js",
77
100
  "src/why.js"
78
101
  ],
@@ -95,19 +118,20 @@
95
118
  "homepage": "https://github.com/PreventiveMeasures/stasis#readme",
96
119
  "dependencies": {
97
120
  "@exodus/bytes": "^1.16.0",
98
- "@exodus/stasis-core": "1.0.0-beta.9",
99
- "@exodus/stasis-plugins": "1.0.0-beta.9",
100
- "@preventive/archive": "1.0.0-beta.4",
101
- "@preventive/deptree": "1.0.0-alpha.11",
102
- "@preventive/lockfile": "1.0.0-alpha.7",
103
- "@preventive/upstream": "1.0.0-alpha.12",
104
- "@preventive/vfs": "1.0.0-beta.4",
121
+ "@exodus/stasis-core": "1.0.0-rc.1",
122
+ "@exodus/stasis-plugins": "1.0.0-rc.1",
123
+ "@preventive/archive": "^1.4.0",
124
+ "@preventive/deptree": "^1.5.0",
125
+ "@preventive/lockfile": "^1.3.0",
126
+ "@preventive/rn": "1.0.0-alpha.6",
127
+ "@preventive/upstream": "^1.6.0",
128
+ "@preventive/vfs": "^1.1.0",
129
+ "flow-remove-types": "^2.322.0",
105
130
  "oxc-parser": "^0.152.0"
106
131
  },
107
132
  "peerDependencies": {
108
133
  "@prisma/client-generator-ts": "7.10.0",
109
- "esbuild": "*",
110
- "flow-remove-types": "*"
134
+ "esbuild": "*"
111
135
  },
112
136
  "peerDependenciesMeta": {
113
137
  "@prisma/client-generator-ts": {
@@ -115,9 +139,9 @@
115
139
  },
116
140
  "esbuild": {
117
141
  "optional": true
118
- },
119
- "flow-remove-types": {
120
- "optional": true
121
142
  }
143
+ },
144
+ "optionalDependencies": {
145
+ "minimatch": "^10.2.6"
122
146
  }
123
147
  }
@@ -1,22 +1,7 @@
1
1
  import { satisfies, valid } from '@preventive/upstream/semver.js'
2
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.
3
+ // Files that are no evidence of a package's real code: one shipped only as these is not audited. Each `range` is
4
+ // VERIFIED, widened only after re-checking `file`; `integrity` is the sha512 of each copy of it there, as a lockfile has it.
20
5
  export const CORRECTIONS = Object.freeze([
21
6
  {
22
7
  // ws's browser build is a noop stub -- `module.exports = function () { throw
@@ -55,42 +40,26 @@ export const CORRECTIONS = Object.freeze([
55
40
  },
56
41
  ].map((correction) => Object.freeze({ ...correction, integrity: Object.freeze(correction.integrity) })))
57
42
 
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
- }
43
+ // An unknown or unparsable version is never corrected: fail closed, the package stays audited.
44
+ const isCorrectedFile = (name, version, rel, ecosystem) => CORRECTIONS.some((correction) => correction.ecosystem === ecosystem && correction.name === name
45
+ && correction.file === rel && valid(version) && satisfies(version, correction.range))
68
46
 
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.
47
+ // A manifest is never code, though the graph records resolver reads of `package.json` (react-native scans its siblings'
48
+ // for Haste), nor are those other ecosystems' bundles carry (--cargo-manifests, --manifests).
77
49
  const CARGO_MANIFESTS = new Set(['Cargo.toml', 'Cargo.lock', '.cargo-checksum.json'])
50
+ const FOUNDRY_MANIFESTS = new Set(['package.json', 'foundry.toml', 'remappings.txt', 'soldeer.toml'])
78
51
  const MANIFESTS = {
79
52
  npm: new Set(['package.json']),
80
53
  cargo: CARGO_MANIFESTS,
81
54
  'cargo-git': CARGO_MANIFESTS,
82
55
  'cargo-unknown': CARGO_MANIFESTS,
83
56
  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']),
57
+ soldeer: FOUNDRY_MANIFESTS,
58
+ github: FOUNDRY_MANIFESTS,
86
59
  }
87
60
  const isManifest = (rel, ecosystem) => MANIFESTS[ecosystem]?.has(rel.slice(rel.lastIndexOf('/') + 1)) ?? false
88
61
 
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.
62
+ // The one rule package presence, the reason column and the --why graph share.
94
63
  export function isEvidenceFile(name, version, rel, ecosystem = 'npm') {
95
64
  return !isManifest(rel, ecosystem) && !isCorrectedFile(name, version, rel, ecosystem)
96
65
  }