@exodus/stasis 1.0.0-beta.15 → 1.0.0-beta.16
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/README.md +1 -1
- package/bin/stasis.js +19 -6
- package/package.json +10 -9
- package/src/audit-corrections.js +11 -42
- package/src/audit.js +113 -233
- package/src/babel.js +39 -122
- package/src/bundle-from-lockfile.js +9 -21
- package/src/bundle-reader.js +5 -9
- package/src/bundle.js +0 -3
- package/src/cmd/build.js +50 -166
- package/src/cmd/bundle-options.js +110 -167
- package/src/cmd/bundle.js +853 -1344
- package/src/cmd/diff.js +1 -4
- package/src/cmd/github-bundle.js +18 -22
- package/src/cmd/output.js +15 -12
- package/src/cmd/sbom.js +3 -8
- package/src/cmd/tokens.js +10 -23
- package/src/define.js +34 -97
- package/src/diff.js +72 -128
- package/src/esbuild.js +0 -4
- package/src/flow.js +10 -25
- package/src/installed.js +265 -0
- package/src/json-stream.js +4 -9
- package/src/loader-mock.js +3 -8
- package/src/loader.js +1 -5
- package/src/loaders/bash.js +41 -93
- package/src/loaders/cargo.js +298 -805
- package/src/loaders/foundry.js +109 -285
- package/src/loaders/paths.js +13 -13
- package/src/loaders/php.js +210 -489
- package/src/loaders/rust.js +507 -1430
- package/src/loaders/solidity-ownership.js +48 -128
- package/src/loaders/solidity.js +39 -122
- package/src/loaders/toml.js +7 -17
- package/src/lockfile.js +0 -3
- package/src/metro-assets.js +9 -33
- package/src/metro-resolver.js +20 -47
- package/src/metro-transformer.js +0 -5
- package/src/metro.js +0 -4
- package/src/mock.js +32 -80
- package/src/parse.js +2 -5
- package/src/prune.js +0 -3
- package/src/resolve-fields.js +90 -220
- package/src/resolve-node.js +27 -45
- package/src/resolve-typescript.js +109 -313
- package/src/rollup.js +0 -4
- package/src/run-installed.js +10 -0
- package/src/sbom.js +52 -128
- package/src/scan.js +136 -283
- package/src/sixel.js +18 -41
- package/src/table.js +14 -35
- package/src/validate-notes.d.ts +3 -2
- package/src/validate-notes.js +25 -19
- package/src/validate.d.ts +38 -11
- package/src/validate.js +478 -512
- package/src/vfs-bundle/entries.js +40 -57
- package/src/vfs-bundle/github.js +77 -121
- package/src/vfs-bundle/glob.js +4 -45
- package/src/vfs-bundle/lazy.js +27 -56
- package/src/vfs-bundle/prisma.js +167 -110
- package/src/vfs-bundle/soldeer.js +28 -49
- package/src/vfs-bundle/tree.js +295 -318
- package/src/vfs-bundle/yarnclean.js +10 -31
- package/src/vfs-bundle.js +23 -64
- package/src/webpack.js +0 -4
- package/src/why.js +75 -231
- package/src/installed-commits.js +0 -184
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ Each command's options are documented in [doc/](https://github.com/PreventiveMea
|
|
|
91
91
|
[`audit`](https://github.com/PreventiveMeasures/stasis/blob/main/doc/audit.md),
|
|
92
92
|
[`validate`](https://github.com/PreventiveMeasures/stasis/blob/main/doc/validate.md),
|
|
93
93
|
[`sbom`](https://github.com/PreventiveMeasures/stasis/blob/main/doc/sbom.md).
|
|
94
|
-
`stasis bundle` also bundles Solidity, PHP, Bash and
|
|
94
|
+
`stasis bundle` also bundles Solidity, PHP, Bash, Rust and TEAL sources, see [file formats](https://github.com/PreventiveMeasures/stasis/blob/main/doc/file-formats.md#source-language-bundles-solidity--php--bash--rust--teal).
|
|
95
95
|
|
|
96
96
|
## Runtime
|
|
97
97
|
|
package/bin/stasis.js
CHANGED
|
@@ -19,12 +19,12 @@ assert(basename(jsname) === 'stasis' || pathsEqual(jsname, fileURLToPath(import.
|
|
|
19
19
|
|
|
20
20
|
const HELP = `Usage:
|
|
21
21
|
stasis run --lock=(add|replace|frozen|ignore) [--bundle=(add|replace|load|frozen|ignore)] [--bundle-file=path/to/bundle.br] [--resources-bundle-file=path/to/resources.br] [--dependencies] [--child-process] [--package-json] [--mock] [--import=module ...] [--fs=(sync|async)] [--resources=ext,ext] [--brotli-quality=0..11] path/to/file.js ...
|
|
22
|
-
stasis bundle [--deptree] [--scope=(node_modules|full)] [--conditions=cond1,cond2] [--mainFields=field1,field2] [--metro [--metro-resolver] [--babel|--babel-aliases=path/to/aliases.json] --platforms=ios,android] [--jsx] [--flow] [--typescript [--tsconfig=path/to/tsconfig.json]] [--resources=ext,ext] [--define=K=V ...] [--package-json] [--lockfile=path/to/stasis.lock.json] [--brotli-quality=0..11] [--add] [--output=(path|-)] path/to/file.(js|ts|jsx|tsx) ...
|
|
22
|
+
stasis bundle [--deptree] [--scope=(node_modules|full)] [--conditions=cond1,cond2] [--mainFields=field1,field2] [--metro [--metro-resolver] [--babel|--babel-aliases=path/to/aliases.json] --platforms=ios,android] [--jsx] [--flow] [--typescript [--tsconfig=path/to/tsconfig.json]] [--resources=ext,ext] [--define=K=V ...] [--package-json] [--lockfile=path/to/stasis.lock.json [--lockfile-only]] [--brotli-quality=0..11] [--add] [--output=(path|-)] path/to/file.(js|ts|jsx|tsx) ...
|
|
23
23
|
stasis bundle [--deptree] [--mapping=path/to/remappings(.txt|.toml)] [--manifests] [--add] [--output=(path|-)] path/to/(file.sol|dir) ...
|
|
24
24
|
stasis bundle [--cargo] [--cargo-features=a,b,pkg/c] [--cargo-no-default-features] [--cargo-all-features] [--cargo-target=(triple|host)] [--cargo-manifests] [--add] [--output=(path|-)] path/to/file.rs ...
|
|
25
25
|
stasis bundle [--add] [--output=(path|-)] path/to/file.(php|sh|bash) ...
|
|
26
|
-
stasis bundle [--deptree] [--babel] [--metro-resolver] [--cargo] [--cargo-target=(triple|host)] [--lockfile=path/to/stasis.lock.json] [--brotli-quality=0..11] [--add] [--output=(path|-)] [entry ...] (the entries' options from stasis.config.json's entries)
|
|
27
|
-
stasis github-bundle (owner/name[/path]|--github=owner/name [--directory=path]) [--sha=commit|--tag=name] [--package-manager=(pnpm|yarn1|npm|soldeer) [--package-manager-version=version]] [--no-lazy] [--generate=prisma|--no-generate] [--lockfile=path/to/stasis.lock.json] [--output=(path|-)] [stasis bundle's options for the entries] [path/in/repo/to/(file.(js|ts|jsx|tsx)|file.sol|dir) ...]
|
|
26
|
+
stasis bundle [--deptree] [--babel] [--metro-resolver] [--cargo] [--cargo-target=(triple|host)] [--lockfile=path/to/stasis.lock.json [--lockfile-only]] [--brotli-quality=0..11] [--add] [--output=(path|-)] [entry ...] (the entries' options from stasis.config.json's entries)
|
|
27
|
+
stasis github-bundle (owner/name[/path]|--github=owner/name [--directory=path]) [--sha=commit|--tag=name] [--package-manager=(pnpm|yarn1|npm|soldeer) [--package-manager-version=version]] [--no-lazy] [--generate=prisma|--no-generate] [--lockfile=path/to/stasis.lock.json [--lockfile-only]] [--output=(path|-)] [stasis bundle's options for the entries] [path/in/repo/to/(file.(js|ts|jsx|tsx)|file.sol|dir) ...]
|
|
28
28
|
stasis add path/to/(file|dir) ...
|
|
29
29
|
stasis build --output=(dir|file.js) [--format=(esm|cjs|iife)] [--platform=(node|browser|neutral|hermes)] [--babel|--flow] [--minify] [--sourcemap] [--define=K=V ...] [--external=pkg ...] [--loader=.ext:name ...] [--metro=(ios|android|...) [--assets-dest=dir]] path/to/(stasis.code.br|stasis.lock.json) [entry]
|
|
30
30
|
stasis extract [--output=path/to/dir] [--lock=(frozen|add|replace|ignore|none)] path/to/bundle.stasis.code.br
|
|
@@ -126,6 +126,8 @@ if (command === '-v' || command === '--version') {
|
|
|
126
126
|
// import map matches a non-mock run; native addons still can't load (--allow-addons off).
|
|
127
127
|
nodeArgs.push('--conditions=node-addons')
|
|
128
128
|
}
|
|
129
|
+
// Before the loader, whose State reads the install through it.
|
|
130
|
+
nodeArgs.push('--import', import.meta.resolve('../src/run-installed.js'))
|
|
129
131
|
// --mock uses stasis's loader-mock entry (composes the mock before installing the hooks), whose
|
|
130
132
|
// denials the --import preloads then run under.
|
|
131
133
|
const loader = import.meta.resolve(values.mock ? '../src/loader-mock.js' : '@exodus/stasis-core/loader')
|
|
@@ -161,6 +163,7 @@ if (command === '-v' || command === '--version') {
|
|
|
161
163
|
output: { type: 'string', short: 'o' },
|
|
162
164
|
scope: { type: 'string' },
|
|
163
165
|
lockfile: { type: 'string' },
|
|
166
|
+
'lockfile-only': { type: 'boolean' },
|
|
164
167
|
conditions: { type: 'string' },
|
|
165
168
|
mainFields: { type: 'string' },
|
|
166
169
|
metro: { type: 'boolean' },
|
|
@@ -195,6 +198,13 @@ if (command === '-v' || command === '--version') {
|
|
|
195
198
|
if (github === undefined) fail('Error: github-bundle requires the repo to bundle: owner/name[/path], or --github=owner/name')
|
|
196
199
|
if (values.sha !== undefined && values.tag !== undefined) fail('Error: github-bundle takes --sha or --tag, not both')
|
|
197
200
|
if (values.generate !== undefined && values['no-generate']) fail('Error: github-bundle takes --generate or --no-generate, not both')
|
|
201
|
+
const lockfileOnly = Boolean(values['lockfile-only'])
|
|
202
|
+
if (lockfileOnly) {
|
|
203
|
+
// Before anything is fetched.
|
|
204
|
+
const { lockfileOnlyError } = await import('../src/cmd/output.js')
|
|
205
|
+
const refused = lockfileOnlyError({ lockfile: values.lockfile, output: values.output, brotliQuality: values['brotli-quality'] })
|
|
206
|
+
if (refused !== null) fail(`Error: github-bundle: ${refused}`)
|
|
207
|
+
}
|
|
198
208
|
// Whether each option applies to the entries is buildGitHubBundle's to say.
|
|
199
209
|
const list = (value) => [value ?? []].flat().flatMap((v) => v.split(',')).map((s) => s.trim()).filter(Boolean)
|
|
200
210
|
const brotliQuality = brotliQualityOption(values['brotli-quality'], fail)
|
|
@@ -226,6 +236,7 @@ if (command === '-v' || command === '--version') {
|
|
|
226
236
|
manifests: Boolean(values.manifests),
|
|
227
237
|
output: values.output,
|
|
228
238
|
lockfile: values.lockfile,
|
|
239
|
+
lockfileOnly,
|
|
229
240
|
scope: values.scope,
|
|
230
241
|
conditions: list(values.conditions),
|
|
231
242
|
mainFields: values.mainFields === undefined ? undefined : list(values.mainFields),
|
|
@@ -243,6 +254,7 @@ if (command === '-v' || command === '--version') {
|
|
|
243
254
|
brotliQuality,
|
|
244
255
|
})
|
|
245
256
|
} else if (command === 'add') {
|
|
257
|
+
await import('../src/run-installed.js')
|
|
246
258
|
await addCli(argv, { label: 'stasis', fail })
|
|
247
259
|
} else if (command === 'build') {
|
|
248
260
|
const options = {
|
|
@@ -374,12 +386,13 @@ if (command === '-v' || command === '--version') {
|
|
|
374
386
|
const { setCacheDir } = await import('@preventive/upstream/npm.js')
|
|
375
387
|
setCacheDir(userCacheDir())
|
|
376
388
|
const { AuditError, audit, printAuditReport } = await import('../src/audit.js')
|
|
377
|
-
// With no file, the package manager's lockfile installing the project too
|
|
378
|
-
//
|
|
389
|
+
// With no file, the package manager's lockfile installing the project too, or each JS one its
|
|
390
|
+
// stasis.config.json names in its `lockfiles`: their packages the bundle doesn't hold checked for
|
|
391
|
+
// malware (npm's registry alone), their being found or refused told, not failed.
|
|
379
392
|
let lockfile = null
|
|
380
393
|
if (plan !== undefined) {
|
|
381
394
|
try {
|
|
382
|
-
lockfile = await (await import('../src/validate.js')).
|
|
395
|
+
lockfile = await (await import('../src/validate.js')).lockedNpmPackages(plan.cwd)
|
|
383
396
|
} catch (cause) {
|
|
384
397
|
console.error(`Lockfile not checked for malware: ${cause.message}`)
|
|
385
398
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/stasis",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.16",
|
|
4
4
|
"description": "File-level source bundles and lockfiles",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"src/diff.js",
|
|
54
54
|
"src/esbuild.js",
|
|
55
55
|
"src/flow.js",
|
|
56
|
-
"src/installed
|
|
56
|
+
"src/installed.js",
|
|
57
57
|
"src/json-stream.js",
|
|
58
58
|
"src/loader.js",
|
|
59
59
|
"src/loader-mock.js",
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"src/resolve-node.js",
|
|
79
79
|
"src/resolve-typescript.js",
|
|
80
80
|
"src/rollup.js",
|
|
81
|
+
"src/run-installed.js",
|
|
81
82
|
"src/sbom.js",
|
|
82
83
|
"src/sixel.js",
|
|
83
84
|
"src/table.js",
|
|
@@ -117,13 +118,13 @@
|
|
|
117
118
|
"homepage": "https://github.com/PreventiveMeasures/stasis#readme",
|
|
118
119
|
"dependencies": {
|
|
119
120
|
"@exodus/bytes": "^1.16.0",
|
|
120
|
-
"@exodus/stasis-core": "1.0.0-beta.
|
|
121
|
-
"@exodus/stasis-plugins": "1.0.0-beta.
|
|
122
|
-
"@preventive/archive": "^1.
|
|
123
|
-
"@preventive/deptree": "^1.
|
|
124
|
-
"@preventive/lockfile": "^1.
|
|
125
|
-
"@preventive/rn": "1.0.0-alpha.
|
|
126
|
-
"@preventive/upstream": "^1.
|
|
121
|
+
"@exodus/stasis-core": "1.0.0-beta.16",
|
|
122
|
+
"@exodus/stasis-plugins": "1.0.0-beta.16",
|
|
123
|
+
"@preventive/archive": "^1.4.0",
|
|
124
|
+
"@preventive/deptree": "^1.4.1",
|
|
125
|
+
"@preventive/lockfile": "^1.3.0",
|
|
126
|
+
"@preventive/rn": "1.0.0-alpha.6",
|
|
127
|
+
"@preventive/upstream": "^1.6.0",
|
|
127
128
|
"@preventive/vfs": "^1.1.0",
|
|
128
129
|
"flow-remove-types": "^2.322.0",
|
|
129
130
|
"oxc-parser": "^0.152.0"
|
package/src/audit-corrections.js
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
import { satisfies, valid } from '@preventive/upstream/semver.js'
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
//
|
|
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
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
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
|
|
70
|
-
//
|
|
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:
|
|
85
|
-
github:
|
|
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
|
-
//
|
|
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
|
}
|