@exodus/stasis 1.0.0-beta.2 → 1.0.0-beta.5

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 (45) hide show
  1. package/README.md +23 -3
  2. package/bin/stasis.js +375 -170
  3. package/package.json +44 -11
  4. package/src/audit-corrections.js +68 -0
  5. package/src/audit.js +243 -59
  6. package/src/babel-worker.cjs +65 -0
  7. package/src/babel.js +131 -0
  8. package/src/bundle-from-lockfile.js +12 -18
  9. package/src/bundle-reader.js +77 -0
  10. package/src/cmd/build.js +95 -128
  11. package/src/cmd/bundle.js +877 -641
  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 +4 -18
  16. package/src/diff.js +67 -124
  17. package/src/json-stream.js +283 -0
  18. package/src/loader-mock.js +8 -15
  19. package/src/loaders/bash.js +49 -116
  20. package/src/loaders/cargo.js +1699 -0
  21. package/src/loaders/foundry.js +923 -0
  22. package/src/loaders/paths.js +33 -0
  23. package/src/loaders/php.js +339 -394
  24. package/src/loaders/rust.js +3254 -242
  25. package/src/loaders/solidity-ownership.js +531 -0
  26. package/src/loaders/solidity.js +412 -162
  27. package/src/loaders/toml.js +68 -0
  28. package/src/metro-resolver.js +150 -0
  29. package/src/mock.js +57 -165
  30. package/src/parse.js +4 -16
  31. package/src/resolve-fields.js +331 -0
  32. package/src/resolve-node.js +416 -0
  33. package/src/resolve-typescript.js +427 -0
  34. package/src/rollup.js +5 -0
  35. package/src/sbom.js +64 -92
  36. package/src/scan.js +234 -156
  37. package/src/vfs-bundle/entries.js +140 -0
  38. package/src/vfs-bundle/github.js +193 -0
  39. package/src/vfs-bundle/soldeer.js +125 -0
  40. package/src/vfs-bundle/tree.js +606 -0
  41. package/src/vfs-bundle.js +74 -0
  42. package/src/why.js +434 -0
  43. package/src/apis/npm/index.js +0 -36
  44. package/src/apis/npm/semver.cjs +0 -44
  45. 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
+ }