@exodus/stasis 1.0.0-beta.0 → 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.
Files changed (48) hide show
  1. package/README.md +32 -8
  2. package/bin/stasis.js +389 -214
  3. package/package.json +52 -12
  4. package/src/audit-corrections.js +96 -0
  5. package/src/audit.js +289 -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 +202 -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 +434 -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
@@ -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
+ }