@exodus/stasis 1.0.0-beta.8 → 1.0.0-rc.0

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 (66) hide show
  1. package/README.md +7 -2
  2. package/bin/stasis.js +263 -446
  3. package/package.json +38 -13
  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 +1718 -908
  13. package/src/cmd/diff.js +1 -4
  14. package/src/cmd/github-bundle.js +48 -21
  15. package/src/cmd/output.js +24 -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 +221 -475
  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 +170 -235
  44. package/src/resolve-node.js +33 -46
  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 +241 -278
  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 +54 -46
  57. package/src/vfs-bundle/github.js +115 -92
  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 +434 -259
  63. package/src/vfs-bundle/yarnclean.js +79 -0
  64. package/src/vfs-bundle.js +25 -51
  65. package/src/webpack.js +0 -4
  66. package/src/why.js +79 -231
@@ -1,33 +1,22 @@
1
- // Path checks shared by the source-language loaders.
1
+ import { dirname } from 'node:path'
2
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.
3
+ // `segments` applied on `fromFile`'s directory, as a baseDir-relative POSIX path ('' for baseDir
4
+ // itself); null when a `..` escapes the root.
19
5
  export function applyToDir(fromFile, segments) {
20
- const fromDir = fromFile.includes('/') ? fromFile.slice(0, fromFile.lastIndexOf('/')) : ''
21
- const parts = [...(fromDir ? fromDir.split('/') : []), ...segments]
22
6
  const resolved = []
23
- for (const part of parts) {
7
+ for (const part of [...fromFile.split('/').slice(0, -1), ...segments]) {
24
8
  if (part === '.' || part === '') continue
25
- if (part === '..') {
26
- if (resolved.length === 0) return null
27
- resolved.pop()
28
- } else {
29
- resolved.push(part)
30
- }
9
+ if (part !== '..') resolved.push(part)
10
+ else if (resolved.length === 0) return null
11
+ else resolved.pop()
31
12
  }
32
13
  return resolved.join('/')
33
14
  }
15
+
16
+ // A `.`-led name such as `..cache/a.php` is a bare specifier, not a relative one.
17
+ export const isDotRelative = (spec) => spec === '.' || spec === '..' || spec.startsWith('./') || spec.startsWith('../')
18
+
19
+ export function* ancestors(dir) {
20
+ for (; dir !== dirname(dir); dir = dirname(dir)) yield dir
21
+ yield dir
22
+ }