@exodus/stasis 1.0.0-beta.1 → 1.0.0-beta.10
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 +32 -8
- package/bin/stasis.js +386 -213
- package/package.json +52 -12
- package/src/audit-corrections.js +96 -0
- package/src/audit.js +289 -64
- package/src/babel-worker.cjs +65 -0
- package/src/babel.js +131 -0
- package/src/bundle-from-lockfile.js +14 -22
- package/src/bundle-reader.js +77 -0
- package/src/cmd/build.js +96 -128
- package/src/cmd/bundle.js +1121 -654
- package/src/cmd/diff.js +2 -19
- package/src/cmd/github-bundle.js +39 -0
- package/src/cmd/output.js +36 -0
- package/src/cmd/sbom.js +7 -19
- package/src/diff.js +80 -129
- package/src/installed-commits.js +182 -0
- package/src/json-stream.js +283 -0
- package/src/loader-mock.js +8 -15
- package/src/loaders/bash.js +49 -116
- package/src/loaders/cargo.js +1716 -0
- package/src/loaders/foundry.js +923 -0
- package/src/loaders/paths.js +33 -0
- package/src/loaders/php.js +375 -402
- package/src/loaders/rust.js +3254 -242
- package/src/loaders/solidity-ownership.js +531 -0
- package/src/loaders/solidity.js +412 -162
- package/src/loaders/toml.js +68 -0
- package/src/metro-resolver.js +150 -0
- package/src/metro-transformer.js +3 -2
- package/src/mock.js +57 -165
- package/src/parse.js +4 -16
- package/src/resolve-fields.js +370 -0
- package/src/resolve-node.js +419 -0
- package/src/resolve-typescript.js +541 -0
- package/src/rollup.js +5 -0
- package/src/sbom.js +120 -97
- package/src/scan.js +348 -180
- package/src/vfs-bundle/entries.js +144 -0
- package/src/vfs-bundle/github.js +202 -0
- package/src/vfs-bundle/prisma.js +439 -0
- package/src/vfs-bundle/soldeer.js +125 -0
- package/src/vfs-bundle/tree.js +647 -0
- package/src/vfs-bundle.js +80 -0
- package/src/why.js +434 -0
- package/src/apis/npm/index.js +0 -36
- package/src/apis/npm/semver.cjs +0 -44
- package/src/cmd/extract.js +0 -193
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Path checks shared by the source-language loaders.
|
|
2
|
+
|
|
3
|
+
import { isAbsolute, relative, resolve } from 'node:path'
|
|
4
|
+
|
|
5
|
+
import { relativeEscapes, toPosix } from '@exodus/stasis-core/util'
|
|
6
|
+
|
|
7
|
+
// Reject absolute and `..`-escaping paths in a `.<lang>.txt` listing so a malicious or sloppy
|
|
8
|
+
// listing can't read files outside the listing's own directory.
|
|
9
|
+
export function assertWithinBase(baseDir, candidate, label) {
|
|
10
|
+
if (isAbsolute(candidate)) throw new Error(`${label} must not be absolute: ${candidate}`)
|
|
11
|
+
const rel = toPosix(relative(baseDir, resolve(baseDir, candidate)))
|
|
12
|
+
if (relativeEscapes(rel)) {
|
|
13
|
+
throw new Error(`${label} escapes baseDir: ${candidate}`)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Apply `segments` on `fromFile`'s directory, resolving '.'/'..'. Returns a baseDir-relative POSIX
|
|
18
|
+
// path ('' for baseDir itself), or null when traversal escapes the root.
|
|
19
|
+
export function applyToDir(fromFile, segments) {
|
|
20
|
+
const fromDir = fromFile.includes('/') ? fromFile.slice(0, fromFile.lastIndexOf('/')) : ''
|
|
21
|
+
const parts = [...(fromDir ? fromDir.split('/') : []), ...segments]
|
|
22
|
+
const resolved = []
|
|
23
|
+
for (const part of parts) {
|
|
24
|
+
if (part === '.' || part === '') continue
|
|
25
|
+
if (part === '..') {
|
|
26
|
+
if (resolved.length === 0) return null
|
|
27
|
+
resolved.pop()
|
|
28
|
+
} else {
|
|
29
|
+
resolved.push(part)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return resolved.join('/')
|
|
33
|
+
}
|