@nodesecure/tarball 1.0.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 +80 -0
  2. package/dist/constants.d.ts +10 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/constants.js +14 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +2 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/manifest.d.ts +18 -0
  11. package/dist/manifest.d.ts.map +1 -0
  12. package/dist/manifest.js +55 -0
  13. package/dist/manifest.js.map +1 -0
  14. package/dist/sast/file.d.ts +14 -0
  15. package/dist/sast/file.d.ts.map +1 -0
  16. package/dist/sast/file.js +44 -0
  17. package/dist/sast/file.js.map +1 -0
  18. package/dist/sast/index.d.ts +2 -0
  19. package/dist/sast/index.d.ts.map +1 -0
  20. package/dist/sast/index.js +2 -0
  21. package/dist/sast/index.js.map +1 -0
  22. package/dist/tarball.d.ts +60 -0
  23. package/dist/tarball.d.ts.map +1 -0
  24. package/dist/tarball.js +123 -0
  25. package/dist/tarball.js.map +1 -0
  26. package/dist/types.d.ts +31 -0
  27. package/dist/types.d.ts.map +1 -0
  28. package/dist/types.js +2 -0
  29. package/dist/types.js.map +1 -0
  30. package/dist/utils/analyzeDependencies.d.ts +19 -0
  31. package/dist/utils/analyzeDependencies.d.ts.map +1 -0
  32. package/dist/utils/analyzeDependencies.js +109 -0
  33. package/dist/utils/analyzeDependencies.js.map +1 -0
  34. package/dist/utils/booleanToFlags.d.ts +6 -0
  35. package/dist/utils/booleanToFlags.d.ts.map +1 -0
  36. package/dist/utils/booleanToFlags.js +12 -0
  37. package/dist/utils/booleanToFlags.js.map +1 -0
  38. package/dist/utils/filterDependencyKind.d.ts +8 -0
  39. package/dist/utils/filterDependencyKind.d.ts.map +1 -0
  40. package/dist/utils/filterDependencyKind.js +36 -0
  41. package/dist/utils/filterDependencyKind.js.map +1 -0
  42. package/dist/utils/getPackageName.d.ts +9 -0
  43. package/dist/utils/getPackageName.d.ts.map +1 -0
  44. package/dist/utils/getPackageName.js +16 -0
  45. package/dist/utils/getPackageName.js.map +1 -0
  46. package/dist/utils/getSemverWarning.d.ts +3 -0
  47. package/dist/utils/getSemverWarning.d.ts.map +1 -0
  48. package/dist/utils/getSemverWarning.js +13 -0
  49. package/dist/utils/getSemverWarning.js.map +1 -0
  50. package/dist/utils/getTarballComposition.d.ts +7 -0
  51. package/dist/utils/getTarballComposition.d.ts.map +1 -0
  52. package/dist/utils/getTarballComposition.js +34 -0
  53. package/dist/utils/getTarballComposition.js.map +1 -0
  54. package/dist/utils/index.d.ts +7 -0
  55. package/dist/utils/index.d.ts.map +1 -0
  56. package/dist/utils/index.js +7 -0
  57. package/dist/utils/index.js.map +1 -0
  58. package/dist/utils/isSensitiveFile.d.ts +5 -0
  59. package/dist/utils/isSensitiveFile.d.ts.map +1 -0
  60. package/dist/utils/isSensitiveFile.js +13 -0
  61. package/dist/utils/isSensitiveFile.js.map +1 -0
  62. package/dist/warnings.d.ts +4 -0
  63. package/dist/warnings.d.ts.map +1 -0
  64. package/dist/warnings.js +25 -0
  65. package/dist/warnings.js.map +1 -0
  66. package/package.json +43 -0
package/README.md ADDED
@@ -0,0 +1,80 @@
1
+ <p align="center"><h1 align="center">
2
+ @nodesecure/tarball
3
+ </h1>
4
+
5
+ <p align="center">
6
+ Utilities to extract and deeply analyze NPM tarball
7
+ </p>
8
+
9
+ ## Requirements
10
+ - [Node.js](https://nodejs.org/en/) v20 or higher
11
+
12
+ ## Getting Started
13
+
14
+ This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).
15
+
16
+ ```bash
17
+ $ npm i @nodesecure/tarball
18
+ # or
19
+ $ yarn add @nodesecure/tarball
20
+ ```
21
+
22
+ ## Usage example
23
+
24
+ ```ts
25
+ import * as tarball from "@nodesecure/tarball";
26
+
27
+ const scanResult = await tarball.scanPackage(
28
+ process.cwd()
29
+ );
30
+ console.log(scanResult);
31
+ ```
32
+
33
+ > [!NOTE]
34
+ > This package has been designed to be used by the Scanner package/workspace.
35
+
36
+ ## API
37
+
38
+ ### scanDirOrArchive
39
+
40
+ Method created for Scanner (to be refactored soon)
41
+
42
+ ```ts
43
+ export interface scanDirOrArchiveOptions {
44
+ ref: DependencyRef;
45
+ location?: string;
46
+ tmpLocation?: null | string;
47
+ locker: Locker;
48
+ registry: string;
49
+ }
50
+ ```
51
+
52
+ ### scanPackage(dest: string, packageName?: string): Promise< ScannedPackageResult >
53
+
54
+ Scan a given tarball archive or a local project.
55
+
56
+ ```ts
57
+ interface ScannedPackageResult {
58
+ files: {
59
+ /** Complete list of files for the given package */
60
+ list: string[];
61
+ /** Complete list of extensions (.js, .md etc.) */
62
+ extensions: string[];
63
+ /** List of minified javascript files */
64
+ minified: string[];
65
+ };
66
+ /** Size of the directory in bytes */
67
+ directorySize: number;
68
+ /** Unique license contained in the tarball (MIT, ISC ..) */
69
+ uniqueLicenseIds: string[];
70
+ /** All licenses with their SPDX */
71
+ licenses: ntlp.SpdxLicenseConformance[];
72
+ ast: {
73
+ dependencies: Record<string, Record<string, Dependency>>;
74
+ warnings: Warning[];
75
+ };
76
+ }
77
+ ```
78
+
79
+ ## License
80
+ MIT
@@ -0,0 +1,10 @@
1
+ export declare const NPM_TOKEN: {
2
+ token: string;
3
+ } | {
4
+ token?: undefined;
5
+ };
6
+ /**
7
+ * @see https://www.nerdycode.com/prevent-npm-executing-scripts-security/
8
+ */
9
+ export declare const UNSAFE_SCRIPTS: Set<string>;
10
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;CAElB,CAAC;AAEL;;GAEG;AACH,eAAO,MAAM,cAAc,aAMzB,CAAC"}
@@ -0,0 +1,14 @@
1
+ export const NPM_TOKEN = typeof process.env.NODE_SECURE_TOKEN === "string" ?
2
+ { token: process.env.NODE_SECURE_TOKEN } :
3
+ {};
4
+ /**
5
+ * @see https://www.nerdycode.com/prevent-npm-executing-scripts-security/
6
+ */
7
+ export const UNSAFE_SCRIPTS = new Set([
8
+ "install",
9
+ "preinstall",
10
+ "postinstall",
11
+ "preuninstall",
12
+ "postuninstall"
13
+ ]);
14
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,KAAK,QAAQ,CAAC,CAAC;IAC1E,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC1C,EAAE,CAAC;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IACpC,SAAS;IACT,YAAY;IACZ,aAAa;IACb,cAAc;IACd,eAAe;CAChB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./tarball.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./tarball.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { PackageJSON } from "@nodesecure/npm-types";
2
+ export declare function read(location: string): Promise<PackageJSON>;
3
+ export declare function readAnalyze(location: string): Promise<{
4
+ author: import("@nodesecure/utils").ParsedMaintainer | null;
5
+ description: string;
6
+ engines: Record<string, string>;
7
+ repository: {};
8
+ scripts: Record<string, string>;
9
+ hasScript: boolean;
10
+ packageDeps: string[];
11
+ packageDevDeps: string[];
12
+ nodejs: {
13
+ imports: Record<`#${string}`, string | import("@nodesecure/npm-types").NodeImport>;
14
+ };
15
+ hasNativeElements: boolean;
16
+ integrity: string;
17
+ }>;
18
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAazD,wBAAsB,IAAI,CACxB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAOtB;AAED,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM;;;;;;;;;;;;;;GAsDjD"}
@@ -0,0 +1,55 @@
1
+ // Import Node.js Dependencies
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import crypto from "node:crypto";
5
+ import { parseAuthor } from "@nodesecure/utils";
6
+ // Import Internal Dependencies
7
+ import { UNSAFE_SCRIPTS } from "./constants.js";
8
+ // CONSTANTS
9
+ // PR welcome to contribute to this list!
10
+ const kNativeNpmPackages = new Set([
11
+ "node-gyp", "node-pre-gyp", "node-gyp-build", "node-addon-api"
12
+ ]);
13
+ const kNodemodulesBinPrefix = "node_modules/.bin/";
14
+ export async function read(location) {
15
+ const packageStr = await fs.readFile(path.join(location, "package.json"), "utf-8");
16
+ return JSON.parse(packageStr);
17
+ }
18
+ export async function readAnalyze(location) {
19
+ const { name, version, description = "", author = {}, scripts = {}, dependencies = {}, devDependencies = {}, gypfile = false, engines = {}, repository = {}, imports = {}, license = "" } = await read(location);
20
+ for (const [scriptName, scriptValue] of Object.entries(scripts)) {
21
+ if (scriptValue.startsWith(kNodemodulesBinPrefix)) {
22
+ scripts[scriptName] = scriptValue.replaceAll(kNodemodulesBinPrefix, "");
23
+ }
24
+ }
25
+ const integrityObj = {
26
+ name,
27
+ version,
28
+ dependencies,
29
+ license,
30
+ scripts
31
+ };
32
+ const integrity = crypto
33
+ .createHash("sha256")
34
+ .update(JSON.stringify(integrityObj))
35
+ .digest("hex");
36
+ const packageDeps = Object.keys(dependencies);
37
+ const packageDevDeps = Object.keys(devDependencies);
38
+ const hasNativePackage = [...packageDevDeps, ...packageDeps]
39
+ .some((pkg) => kNativeNpmPackages.has(pkg));
40
+ return {
41
+ author: parseAuthor(author),
42
+ description,
43
+ engines,
44
+ repository,
45
+ scripts,
46
+ hasScript: Object.keys(scripts)
47
+ .some((value) => UNSAFE_SCRIPTS.has(value.toLowerCase())),
48
+ packageDeps,
49
+ packageDevDeps,
50
+ nodejs: { imports },
51
+ hasNativeElements: hasNativePackage || gypfile,
52
+ integrity
53
+ };
54
+ }
55
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,aAAa,CAAC;AAIjC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,+BAA+B;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,YAAY;AACZ,yCAAyC;AACzC,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,UAAU,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB;CAC/D,CAAC,CAAC;AACH,MAAM,qBAAqB,GAAG,oBAAoB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,QAAgB;IAEhB,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,QAAQ,CAClC,IAAI,CAAC,IAAI,CAAC,QAAQ,E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,GAAG,EAAE,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9C,OAAO;QACL,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC;QAC3B,WAAW;QACX,OAAO;QACP,UAAU;QACV,OAAO;QACP,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;aAC5B,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;QAC3D,WAAW;QACX,cAAc;QACd,MAAM,EAAE,EAAE,OAAO,EAAE;QACnB,iBAAiB,EAAE,gBAAgB,IAAI,OAAO;QAC9C,SAAS;KACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type WarningName, type WarningDefault } from "@nodesecure/js-x-ray";
2
+ export interface scanFileReport {
3
+ file: string;
4
+ warnings: (Omit<WarningDefault<WarningName>, "value"> & {
5
+ file: string;
6
+ })[];
7
+ isMinified: boolean;
8
+ tryDependencies: string[];
9
+ dependencies: string[];
10
+ filesDependencies: string[];
11
+ }
12
+ export declare function scanFile(destination: string, file: string, packageName: string): Promise<scanFileReport>;
13
+ export declare function scanManyFiles(files: string[], destination: string, packageName: string): Promise<scanFileReport[]>;
14
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/sast/file.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAU9B,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;KAAE,CAAC,EAAE,CAAC;IAC7E,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED,wBAAsB,QAAQ,CAC5B,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC,CAoCzB;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EAAE,EACf,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,EAAE,CAAC,CAU3B"}
@@ -0,0 +1,44 @@
1
+ // Import Node.js Dependencies
2
+ import path from "node:path";
3
+ // Import Third-party Dependencies
4
+ import { AstAnalyser } from "@nodesecure/js-x-ray";
5
+ // Import Internal Dependencies
6
+ import { filterDependencyKind } from "../utils/index.js";
7
+ // CONSTANTS
8
+ const kJsExtname = new Set([".js", ".mjs", ".cjs"]);
9
+ export async function scanFile(destination, file, packageName) {
10
+ const result = await new AstAnalyser().analyseFile(path.join(destination, file), {
11
+ packageName
12
+ });
13
+ const warnings = result.warnings.map((curr) => Object.assign({}, curr, { file }));
14
+ if (result.ok) {
15
+ const { packages, files } = filterDependencyKind([...result.dependencies.keys()], path.dirname(file));
16
+ const tryDependencies = [...result.dependencies.entries()]
17
+ .flatMap(([name, dependency]) => (dependency.inTry ? [name] : []));
18
+ return {
19
+ file,
20
+ warnings,
21
+ isMinified: result.isMinified,
22
+ tryDependencies,
23
+ dependencies: packages,
24
+ filesDependencies: files
25
+ };
26
+ }
27
+ return {
28
+ file,
29
+ warnings,
30
+ isMinified: false,
31
+ tryDependencies: [],
32
+ dependencies: [],
33
+ filesDependencies: []
34
+ };
35
+ }
36
+ export async function scanManyFiles(files, destination, packageName) {
37
+ const scannedFiles = await Promise.allSettled(files
38
+ .filter((fileName) => kJsExtname.has(path.extname(fileName)))
39
+ .map((file) => scanFile(destination, file, packageName)));
40
+ return scannedFiles
41
+ .filter((result) => result.status === "fulfilled")
42
+ .map((result) => result.value);
43
+ }
44
+ //# sourceMappingURL=file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/sast/file.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,kCAAkC;AAClC,OAAO,EACL,WAAW,EAGZ,MAAM,sBAAsB,CAAC;AAE9B,+BAA+B;AAC/B,OAAO,EACL,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B,YAAY;AACZ,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAWpD,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,WAAmB,EACnB,IAAY,EACZ,WAAmB;IAEnB,MAAM,MAAM,GAAG,MAAM,IAAI,WAAW,EAAE,CAAC,WAAW,CAChD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,EAC5B;QACE,WAAW;KACZ,CACF,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAClF,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;QACd,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,oBAAoB,CAC9C,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,EAC/B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CACnB,CAAC;QAEF,MAAM,eAAe,GAAG,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;aACvD,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAErE,OAAO;YACL,IAAI;YACJ,QAAQ;YACR,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,eAAe;YACf,YAAY,EAAE,QAAQ;YACtB,iBAAiB,EAAE,KAAK;SACzB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI;QACJ,QAAQ;QACR,UAAU,EAAE,KAAK;QACjB,eAAe,EAAE,EAAE;QACnB,YAAY,EAAE,EAAE;QAChB,iBAAiB,EAAE,EAAE;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,KAAe,EACf,WAAmB,EACnB,WAAmB;IAEnB,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,UAAU,CAC3C,KAAK;SACF,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;SAC5D,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAC3D,CAAC;IAEF,OAAO,YAAY;SAChB,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,WAAW,CAAC;SACjD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./file.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sast/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./file.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sast/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { type Warning, type Dependency } from "@nodesecure/js-x-ray";
2
+ import * as conformance from "@nodesecure/conformance";
3
+ export interface DependencyRef {
4
+ id: number;
5
+ usedBy: Record<string, string>;
6
+ isDevDependency: boolean;
7
+ existOnRemoteRegistry: boolean;
8
+ flags: string[];
9
+ description: string;
10
+ size: number;
11
+ author: Record<string, any>;
12
+ engines: Record<string, any>;
13
+ repository: any;
14
+ scripts: Record<string, string>;
15
+ warnings: any;
16
+ licenses: conformance.SpdxFileLicenseConformance[];
17
+ uniqueLicenseIds: string[];
18
+ gitUrl: string | null;
19
+ alias: Record<string, string>;
20
+ composition: {
21
+ extensions: string[];
22
+ files: string[];
23
+ minified: string[];
24
+ unused: string[];
25
+ missing: string[];
26
+ required_files: string[];
27
+ required_nodejs: string[];
28
+ required_thirdparty: string[];
29
+ required_subpath: Record<string, string>;
30
+ };
31
+ }
32
+ export interface scanDirOrArchiveOptions {
33
+ ref: DependencyRef;
34
+ location?: string;
35
+ tmpLocation?: null | string;
36
+ registry: string;
37
+ }
38
+ export declare function scanDirOrArchive(name: string, version: string, options: scanDirOrArchiveOptions): Promise<void>;
39
+ export interface ScannedPackageResult {
40
+ files: {
41
+ /** Complete list of files for the given package */
42
+ list: string[];
43
+ /** Complete list of extensions (.js, .md etc.) */
44
+ extensions: string[];
45
+ /** List of minified javascript files */
46
+ minified: string[];
47
+ };
48
+ /** Size of the directory in bytes */
49
+ directorySize: number;
50
+ /** Unique license contained in the tarball (MIT, ISC ..) */
51
+ uniqueLicenseIds: string[];
52
+ /** All licenses with their SPDX */
53
+ licenses: conformance.SpdxFileLicenseConformance[];
54
+ ast: {
55
+ dependencies: Record<string, Record<string, Dependency>>;
56
+ warnings: Warning[];
57
+ };
58
+ }
59
+ export declare function scanPackage(dest: string, packageName?: string): Prom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CAAC;QAC1B,mBAAmB,EAAE,MAAM,EAAE,CAAC;QAC9B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C,CAAA;CACF;AAWD,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,aAAa,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,uBAAuB,iBA+FjC;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE;QACL,mDAAmD;QACnD,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,kDAAkD;QAClD,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,wCAAwC;QACxC,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,qCAAqC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mCAAmC;IACnC,QAAQ,EAAE,WAAW,CAAC,0BAA0B,EAAE,CAAC;IACnD,GAAG,EAAE;QACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;QACzD,QAAQ,EAAE,OAAO,EAAE,CAAC;KACrB,CAAC;CACH;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,oBAAoB,CAAC,CAkD/B"}
@@ -0,0 +1,123 @@
1
+ // Import Node.js Dependencies
2
+ import path from "node:path";
3
+ import os from "node:os";
4
+ // Import Third-party Dependencies
5
+ import { AstAnalyser } from "@nodesecure/js-x-ray";
6
+ import pacote from "pacote";
7
+ import * as conformance from "@nodesecure/conformance";
8
+ import { ManifestManager } from "@nodesecure/mama";
9
+ // Import Internal Dependencies
10
+ import { getTarballComposition, isSensitiveFile, analyzeDependencies, booleanToFlags } from "./utils/index.js";
11
+ import * as warnings from "./warnings.js";
12
+ import * as sast from "./sast/index.js";
13
+ // CONSTANTS
14
+ const NPM_TOKEN = typeof process.env.NODE_SECURE_TOKEN === "string" ?
15
+ { token: process.env.NODE_SECURE_TOKEN } :
16
+ {};
17
+ const kNativeCodeExtensions = new Set([".gyp", ".c", ".cpp", ".node", ".so", ".h"]);
18
+ const kJsExtname = new Set([".js", ".mjs", ".cjs"]);
19
+ export async function scanDirOrArchive(name, version, options) {
20
+ const { ref, location = process.cwd(), tmpLocation = null, registry } = options;
21
+ const isNpmTarball = !(tmpLocation === null);
22
+ const dest = isNpmTarball ? path.join(tmpLocation, `${name}@${version}`) : location;
23
+ // If this is an NPM tarball then we extract it on the disk with pacote.
24
+ if (isNpmTarball) {
25
+ await pacote.extract(ref.flags.includes("isGit") ? ref.gitUrl : `${name}@${version}`, dest, {
26
+ ...NPM_TOKEN,
27
+ registry,
28
+ cache: `${os.homedir()}/.npm`
29
+ });
30
+ }
31
+ // Read the package.json at the root of the directory or archive.
32
+ const [mama, composition, spdx] = await Promise.all([
33
+ ManifestManager.fromPackageJSON(dest),
34
+ getTarballComposition(dest),
35
+ conformance.extractLicenses(dest)
36
+ ]);
37
+ {
38
+ const { description, engines, repository, scripts } = mama.document;
39
+ Object.assign(ref, {
40
+ description, engines, repository, scripts,
41
+ author: mama.author,
42
+ integrity: mama.integrity
43
+ });
44
+ }
45
+ ref.licenses = spdx.licenses;
46
+ ref.uniqueLicenseIds = spdx.uniqueLicenseIds;
47
+ // Get the composition of the (extracted) directory
48
+ if (composition.files.length === 1 && composition.files.includes("package.json")) {
49
+ ref.warnings.push(warnings.getEmptyPackageWarning());
50
+ }
51
+ // Search for minified and runtime dependencies
52
+ // Run a JS-X-Ray analysis on each JavaScript files of the project!
53
+ const scannedFiles = await sast.scanManyFiles(composition.files, dest, name);
54
+ ref.warnings.push(...scannedFiles.flatMap((row) => row.warnings));
55
+ if (/^0(\.\d+)*$/.test(version)) {
56
+ ref.warnings.push(warnings.getSemVerWarning(version));
57
+ }
58
+ const dependencies = [...new Set(scannedFiles.flatMap((row) => row.dependencies))];
59
+ const filesDependencies = [...new Set(scannedFiles.flatMap((row) => row.filesDependencies))];
60
+ const tryDependencies = new Set(scannedFiles.flatMap((row) => row.tryDependencies));
61
+ const minifiedFiles = scannedFiles.filter((row) => row.isMinified).flatMap((row) => row.file);
62
+ const { nodeDependencies, thirdPartyDependencies, subpathImportsDependencies, missingDependencies, unusedDependencies, flags } = analyzeDependencies(dependencies, { mama, tryDependencies });
63
+ ref.size = composition.size;
64
+ ref.composition.extensions.push(...composition.ext);
65
+ ref.composition.files.push(...composition.files);
66
+ ref.composition.required_thirdparty = thirdPartyDependencies;
67
+ ref.composition.required_subpath = subpathImportsDependencies;
68
+ ref.composition.unused.push(...unusedDependencies);
69
+ ref.composition.missing.push(...missingDependencies);
70
+ ref.composition.required_files = filesDependencies;
71
+ ref.composition.required_nodejs = nodeDependencies;
72
+ ref.composition.minified = minifiedFiles;
73
+ ref.flags.push(...booleanToFlags({
74
+ ...flags,
75
+ hasNoLicense: spdx.uniqueLicenseIds.length === 0,
76
+ hasMultipleLicenses: spdx.uniqueLicenseIds.length > 1,
77
+ hasMinifiedCode: minifiedFiles.length > 0,
78
+ hasWarnings: ref.warnings.length > 0 && !ref.flags.includes("hasWarnings"),
79
+ hasBannedFile: composition.files.some((path) => isSensitiveFile(path)),
80
+ hasNativeCode: mama.flags.isNative ||
81
+ composition.files.some((file) => kNativeCodeExtensions.has(path.extname(file))),
82
+ hasScript: mama.flags.hasUnsafeScripts
83
+ }));
84
+ }
85
+ export async function scanPackage(dest, packageName) {
86
+ const [mama, composition, spdx] = await Promise.all([
87
+ ManifestManager.fromPackageJSON(dest),
88
+ getTarballComposition(dest),
89
+ conformance.extractLicenses(dest)
90
+ ]);
91
+ const { type = "script" } = mama.document;
92
+ // Search for runtime dependencies
93
+ const dependencies = Object.create(null);
94
+ const minified = [];
95
+ const warnings = [];
96
+ const JSFiles = composition.files
97
+ .filter((name) => kJsExtname.has(path.extname(name)));
98
+ for (const file of JSFiles) {
99
+ const result = await new AstAnalyser().analyseFile(path.join(dest, file), {
100
+ packageName: packageName ?? mama.document.name,
101
+ module: type === "module"
102
+ });
103
+ warnings.push(...result.warnings.map((curr) => Object.assign({}, curr, { file })));
104
+ if (result.ok) {
105
+ dependencies[file] = Object.fromEntries(result.dependencies);
106
+ if (result.isMinified) {
107
+ minified.push(file);
108
+ }
109
+ }
110
+ }
111
+ return {
112
+ files: {
113
+ list: composition.files,
114
+ extensions: [...composition.ext],
115
+ minified
116
+ },
117
+ directorySize: composition.size,
118
+ uniqueLicenseIds: spdx.uniqueLicenseIds,
119
+ licenses: spdx.licenses,
120
+ ast: { dependencies, warnings }
121
+ };
122
+ }
123
+ //# sourceMappingURL=tarball.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tarball.js","sourceRoot":"","sources":["../src/tarball.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,kCAAkC;AAClC,OAAO,EACL,WAAW,EAGZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,+BAA+B;AAC/B,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAiCxC,YAAY;AACZ,MAAM,SAAS,GAAG,OAAO,OAA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ACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE;YACL,IAAI,EAAE,WAAW,CAAC,KAAK;YACvB,UAAU,EAAE,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC;YAChC,QAAQ;SACT;QACD,aAAa,EAAE,WAAW,CAAC,IAAI;QAC/B,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;QACvC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,GAAG,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE;KAChC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { SpdxFileLicenseConformance } from "@nodesecure/conformance";
2
+ export interface DependencyRef {
3
+ id: number;
4
+ usedBy: Record<string, string>;
5
+ isDevDependency: boolean;
6
+ existOnRemoteRegistry: boolean;
7
+ flags: string[];
8
+ description: string;
9
+ size: number;
10
+ author: Record<string, any>;
11
+ engines: Record<string, any>;
12
+ repository: any;
13
+ scripts: Record<string, string>;
14
+ warnings: any;
15
+ licenses: SpdxFileLicenseConformance[];
16
+ uniqueLicenseIds: string[];
17
+ gitUrl: string | null;
18
+ alias: Record<string, string>;
19
+ composition: {
20
+ extensions: string[];
21
+ files: string[];
22
+ minified: string[];
23
+ unused: string[];
24
+ missing: string[];
25
+ required_files: string[];
26
+ required_nodejs: string[];
27
+ required_thirdparty: string[];
28
+ required_subpath: Record<string, string>;
29
+ };
30
+ }
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,UAAU,EAAE,GAAG,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,WAAW,EAAE;QACX,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,cAAc,EAAE,MAAM,EAAE,CAAC;QACzB,eAAe,EAAE,MAAM,EAAE,CAAC;QAC1B,mBAAmB,EAAE,MAAM,EAAE,CAAC;QAC9B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C,CAAA;CACF"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import { ManifestManager } from "@nodesecure/mama";
2
+ export declare const builtins: Set<string>;
3
+ export interface analyzeDependenciesOptions {
4
+ mama: Pick<ManifestManager, "dependencies" | "devDependencies"> & Partial<Pick<ManifestManager, "nodejsImports">>;
5
+ tryDependencies: Set<string>;
6
+ }
7
+ export interface analyzeDependenciesResult {
8
+ nodeDependencies: string[];
9
+ thirdPartyDependencies: string[];
10
+ subpathImportsDependencies: Record<string, string>;
11
+ unusedDependencies: string[];
12
+ missingDependencies: string[];
13
+ flags: {
14
+ hasExternalCapacity: boolean;
15
+ hasMissingOrUnusedDependency: boolean;
16
+ };
17
+ }
18
+ export declare function analyzeDependencies(sourceDependencies: string[], options: analyzeDependenciesOptions): analyzeDependenciesResult;
19
+ //# sourceMappingURL=analyzeDependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzeDependencies.d.ts","sourceRoot":"","sources":["../../src/utils/analyzeDependencies.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOnD,eAAO,MAAM,QAAQ,aA6CnB,CAAC;AAIH,MAAM,WAAW,0BAA0B;IACzC,IAAI,EACF,IAAI,CAAC,eAAe,EAAE,cAAc,GAAG,iBAAiB,CAAC,GACzD,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC;IAClD,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,yBAAyB;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,KAAK,EAAE;QACL,mBAAmB,EAAE,OAAO,CAAC;QAC7B,4BAA4B,EAAE,OAAO,CAAC;KACvC,CAAA;CACF;AAED,wBAAgB,mBAAmB,CACjC,kBAAkB,EAAE,MAAM,EAAE,EAC5B,OAAO,EAAE,0BAA0B,GAClC,yBAAyB,CA8C3B"}
@@ -0,0 +1,109 @@
1
+ // Import Node.js Dependencies
2
+ import path from "node:path";
3
+ // Import Third-party Dependencies
4
+ import { ManifestManager } from "@nodesecure/mama";
5
+ // Import Internal Dependencies
6
+ import { getPackageName } from "./getPackageName.js";
7
+ // CONSTANTS
8
+ export const builtins = new Set([
9
+ "assert",
10
+ "buffer",
11
+ "child_process",
12
+ "cluster",
13
+ "console",
14
+ "constants",
15
+ "crypto",
16
+ "dgram",
17
+ "dns",
18
+ "domain",
19
+ "events",
20
+ "fs",
21
+ "http",
22
+ "https",
23
+ "module",
24
+ "net",
25
+ "os",
26
+ "path",
27
+ "punycode",
28
+ "querystring",
29
+ "readline",
30
+ "repl",
31
+ "stream",
32
+ "string_decoder",
33
+ "sys",
34
+ "timers",
35
+ "tls",
36
+ "tty",
37
+ "url",
38
+ "util",
39
+ "vm",
40
+ "zlib",
41
+ "freelist",
42
+ "v8",
43
+ "process",
44
+ "inspector",
45
+ "async_hooks",
46
+ "http2",
47
+ "perf_hooks",
48
+ "trace_events",
49
+ "worker_threads",
50
+ "node:test",
51
+ "wasi",
52
+ "diagnostics_channel"
53
+ ]);
54
+ const kExternalModules = new Set(["http", "https", "net", "http2", "dgram", "child_process"]);
55
+ export function analyzeDependencies(sourceDependencies, options) {
56
+ const { mama, tryDependencies } = options;
57
+ const { dependencies, devDependencies, nodejsImports = {} } = mama;
58
+ // See: https://nodejs.org/api/packages.html#subpath-imports
59
+ const subpathImportsDependencies = Object.fromEntries(sourceDependencies
60
+ .filter((name) => isAliasFileModule(name) && name in nodejsImports)
61
+ .map((name) => buildSubpathDependency(name, nodejsImports)));
62
+ const thirdPartyDependenciesAliased = new Set(Object.values(subpathImportsDependencies).filter((mod) => !isFile(mod)));
63
+ const thirdPartyDependencies = sourceDependencies.flatMap((sourceName) => {
64
+ const name = dependencies.includes(sourceName) ? sourceName : getPackageName(sourceName);
65
+ return isFile(name) ||
66
+ isCoreModule(name) ||
67
+ devDependencies.includes(name) ||
68
+ tryDependencies.has(name) ?
69
+ [] : name;
70
+ });
71
+ const unusedDependencies = difference(dependencies.filter((name) => !name.startsWith("@types")), [...thirdPartyDependencies, ...thirdPartyDependenciesAliased]);
72
+ const missingDependencies = [
73
+ ...new Set(difference(thirdPartyDependencies, dependencies))
74
+ ]
75
+ .filter((name) => !(name in nodejsImports) && !thirdPartyDependenciesAliased.has(name));
76
+ const nodeDependencies = sourceDependencies.filter((name) => isCoreModule(name));
77
+ return {
78
+ nodeDependencies,
79
+ thirdPartyDependencies: [...new Set(thirdPartyDependencies)],
80
+ subpathImportsDependencies,
81
+ unusedDependencies,
82
+ missingDependencies,
83
+ flags: {
84
+ hasExternalCapacity: nodeDependencies.some((depName) => kExternalModules.has(depName)),
85
+ hasMissingOrUnusedDependency: unusedDependencies.length > 0 || missingDependencies.length > 0
86
+ }
87
+ };
88
+ }
89
+ function difference(arr1, arr2) {
90
+ return arr1.filter((item) => !arr2.includes(item));
91
+ }
92
+ function isFile(name) {
93
+ return name.startsWith(".") || path.extname(name) !== "";
94
+ }
95
+ function isCoreModule(moduleName) {
96
+ const cleanModuleName = moduleName.startsWith("node:") ? moduleName.slice(5) : moduleName;
97
+ // Note: We need to also check moduleName because builtins package only return true for 'node:test'.
98
+ return builtins.has(cleanModuleName) || builtins.has(moduleName);
99
+ }
100
+ function isAliasFileModule(moduleName) {
101
+ return moduleName.charAt(0) === "#";
102
+ }
103
+ function buildSubpathDependency(alias, nodeImports) {
104
+ const importEntry = nodeImports[alias];
105
+ return typeof importEntry === "string" ?
106
+ [alias, importEntry] :
107
+ [alias, "node" in importEntry ? importEntry.node : importEntry.default];
108
+ }
109
+ //# sourceMappingURL=analyzeDependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzeDependencies.js","sourceRoot":"","sources":["../../src/utils/analyzeDependencies.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,+BAA+B;AA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AAE,CAAC;IAExC,OAAO,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC;QACtC,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC;QACtB,CAAC,KAAK,EAAE,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @example
3
+ * console.log(...booleanToFlags({ hasScript: true })); // "hasScript"
4
+ */
5
+ export declare function booleanToFlags(flagsRecord: Record<string, boolean>): IterableIterator<string>;
6
+ //# sourceMappingURL=booleanToFlags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"booleanToFlags.d.ts","sourceRoot":"","sources":["../../src/utils/booleanToFlags.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAiB,cAAc,CAC7B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,gBAAgB,CAAC,MAAM,CAAC,CAM1B"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @example
3
+ * console.log(...booleanToFlags({ hasScript: true })); // "hasScript"
4
+ */
5
+ export function* booleanToFlags(flagsRecord) {
6
+ for (const [flagName, boolValue] of Object.entries(flagsRecord)) {
7
+ if (boolValue) {
8
+ yield flagName;
9
+ }
10
+ }
11
+ }
12
+ //# sourceMappingURL=booleanToFlags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"booleanToFlags.js","sourceRoot":"","sources":["../../src/utils/booleanToFlags.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,SAAS,CAAC,CAAC,cAAc,CAC7B,WAAoC;IAEpC,KAAK,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QAChE,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,QAAQ,CAAC;QACjB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @see https://nodejs.org/docs/latest/api/modules.html#file-modules
3
+ */
4
+ export declare function filterDependencyKind(dependencies: string[], relativeFileLocation: string): {
5
+ packages: string[];
6
+ files: string[];
7
+ };
8
+ //# sourceMappingURL=filterDependencyKind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterDependencyKind.d.ts","sourceRoot":"","sources":["../../src/utils/filterDependencyKind.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EAAE,EACtB,oBAAoB,EAAE,MAAM,GAC3B;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CA+BzC"}
@@ -0,0 +1,36 @@
1
+ // Import Node.js Dependencies
2
+ import path from "node:path";
3
+ // CONSTANTS
4
+ const kRelativeImportPath = new Set([".", "..", "./", "../"]);
5
+ /**
6
+ * @see https://nodejs.org/docs/latest/api/modules.html#file-modules
7
+ */
8
+ export function filterDependencyKind(dependencies, relativeFileLocation) {
9
+ const packages = [];
10
+ const files = [];
11
+ for (const moduleNameOrPath of dependencies) {
12
+ const firstChar = moduleNameOrPath.charAt(0);
13
+ /**
14
+ * @example
15
+ * require("..");
16
+ * require("/home/marco/foo.js");
17
+ */
18
+ if (firstChar === "." || firstChar === "/") {
19
+ // Note: condition only possible for CJS
20
+ if (kRelativeImportPath.has(moduleNameOrPath)) {
21
+ files.push(path.join(moduleNameOrPath, "index.js"));
22
+ }
23
+ else {
24
+ // Note: we are speculating that the extension is .js (but it could be .json or .node)
25
+ const fixedFileName = path.extname(moduleNameOrPath) === "" ?
26
+ `${moduleNameOrPath}.js` : moduleNameOrPath;
27
+ files.push(path.join(relativeFileLocation, fixedFileName));
28
+ }
29
+ }
30
+ else {
31
+ packages.push(moduleNameOrPath);
32
+ }
33
+ }
34
+ return { packages, files };
35
+ }
36
+ //# sourceMappingURL=filterDependencyKind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filterDependencyKind.js","sourceRoot":"","sources":["../../src/utils/filterDependencyKind.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,YAAY;AACZ,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,YAAsB,EACtB,oBAA4B;IAE5B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,gBAAgB,IAAI,YAAY,EAAE,CAAC;QAC5C,MAAM,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAE7C;;;;WAIG;QACH,IAAI,SAAS,KAAK,GAAG,IAAI,SAAS,KAAK,GAAG,EAAE,CAAC;YAC3C,wCAAwC;YACxC,IAAI,mBAAmB,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAAE,CAAC;gBAC9C,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,CAAC,CAAC;YACtD,CAAC;iBACI,CAAC;gBACJ,sFAAsF;gBACtF,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC,CAAC;oBAC3D,GAAG,gBAAgB,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC;gBAE9C,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;aACI,CAAC;YACJ,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @see https://github.com/npm/validate-npm-package-name#naming-rules
3
+ * @example
4
+ * getPackageName("foo"); // foo
5
+ * getPackageName("foo/bar"); // foo
6
+ * getPackageName("@org/bar"); // @org/bar
7
+ */
8
+ export declare function getPackageName(name: string): string;
9
+ //# sourceMappingURL=getPackageName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPackageName.d.ts","sourceRoot":"","sources":["../../src/utils/getPackageName.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,GACX,MAAM,CAKR"}
@@ -0,0 +1,16 @@
1
+ // CONSTANTS
2
+ const kPackageSeparator = "/";
3
+ const kPackageOrgSymbol = "@";
4
+ /**
5
+ * @see https://github.com/npm/validate-npm-package-name#naming-rules
6
+ * @example
7
+ * getPackageName("foo"); // foo
8
+ * getPackageName("foo/bar"); // foo
9
+ * getPackageName("@org/bar"); // @org/bar
10
+ */
11
+ export function getPackageName(name) {
12
+ const parts = name.split(kPackageSeparator);
13
+ // Note: only scoped package are allowed to start with @
14
+ return name.startsWith(kPackageOrgSymbol) ? `${parts[0]}/${parts[1]}` : parts[0];
15
+ }
16
+ //# sourceMappingURL=getPackageName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPackageName.js","sourceRoot":"","sources":["../../src/utils/getPackageName.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAY;IAEZ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAE5C,wDAAwD;IACxD,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC;AACpF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { WarningDefault } from "@nodesecure/js-x-ray";
2
+ export declare function getSemVerWarning(value: string): WarningDefault<"zero-semver">;
3
+ //# sourceMappingURL=getSemverWarning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSemverWarning.d.ts","sourceRoot":"","sources":["../../src/utils/getSemverWarning.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GACZ,cAAc,CAAC,aAAa,CAAC,CAW/B"}
@@ -0,0 +1,13 @@
1
+ export function getSemVerWarning(value) {
2
+ return {
3
+ kind: "zero-semver",
4
+ file: "package.json",
5
+ value,
6
+ location: null,
7
+ i18n: "sast_warnings.zeroSemVer",
8
+ severity: "Information",
9
+ source: "Scanner",
10
+ experimental: false
11
+ };
12
+ }
13
+ //# sourceMappingURL=getSemverWarning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSemverWarning.js","sourceRoot":"","sources":["../../src/utils/getSemverWarning.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,gBAAgB,CAC9B,KAAa;IAEb,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,cAAc;QACpB,KAAK;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,0BAA0B;QAChC,QAAQ,EAAE,aAAa;QACvB,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface TarballComposition {
2
+ ext: Set<string>;
3
+ size: number;
4
+ files: string[];
5
+ }
6
+ export declare function getTarballComposition(tarballDir: string): Promise<TarballComposition>;
7
+ //# sourceMappingURL=getTarballComposition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTarballComposition.d.ts","sourceRoot":"","sources":["../../src/utils/getTarballComposition.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,kBAAkB,CAAC,CA8B7B"}
@@ -0,0 +1,34 @@
1
+ // Import Node.js Dependencies
2
+ import { Stats, promises as fs } from "node:fs";
3
+ import path from "node:path";
4
+ // Import Third-party Dependencies
5
+ import { walk } from "@nodesecure/fs-walk";
6
+ export async function getTarballComposition(tarballDir) {
7
+ const ext = new Set();
8
+ const files = [];
9
+ const dirs = [];
10
+ let { size } = await fs.stat(tarballDir);
11
+ for await (const [dirent, file] of walk(tarballDir)) {
12
+ if (dirent.isFile()) {
13
+ ext.add(path.extname(file));
14
+ files.push(file);
15
+ }
16
+ else if (dirent.isDirectory()) {
17
+ dirs.push(file);
18
+ }
19
+ }
20
+ const sizeUnfilteredResult = await Promise.allSettled([
21
+ ...files.map((file) => fs.stat(file)),
22
+ ...dirs.map((file) => fs.stat(file))
23
+ ]);
24
+ const sizeAll = sizeUnfilteredResult
25
+ .filter((promiseSettledResult) => promiseSettledResult.status === "fulfilled")
26
+ .map((promiseSettledResult) => promiseSettledResult.value);
27
+ size += sizeAll.reduce((prev, curr) => prev + curr.size, 0);
28
+ return {
29
+ ext,
30
+ size,
31
+ files: files.map((fileLocation) => path.relative(tarballDir, fileLocation)).sort()
32
+ };
33
+ }
34
+ //# sourceMappingURL=getTarballComposition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTarballComposition.js","sourceRoot":"","sources":["../../src/utils/getTarballComposition.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC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MAAM,KAAK,WAAW,CAAC;SAC7E,GAAG,CAAC,CAAC,oBAAoB,EAAE,EAAE,CAAE,oBAAsD,CAAC,KAAK,CAAC,CAAC;IAChG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAE5D,OAAO;QACL,GAAG;QACH,IAAI;QACJ,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE;KACnF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./analyzeDependencies.js";
2
+ export * from "./booleanToFlags.js";
3
+ export * from "./isSensitiveFile.js";
4
+ export * from "./getPackageName.js";
5
+ export * from "./getTarballComposition.js";
6
+ export * from "./filterDependencyKind.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./analyzeDependencies.js";
2
+ export * from "./booleanToFlags.js";
3
+ export * from "./isSensitiveFile.js";
4
+ export * from "./getPackageName.js";
5
+ export * from "./getTarballComposition.js";
6
+ export * from "./filterDependencyKind.js";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @see https://github.com/jandre/safe-commit-hook/blob/master/git-deny-patterns.json
3
+ */
4
+ export declare function isSensitiveFile(fileName: string): boolean;
5
+ //# sourceMappingURL=isSensitiveFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSensitiveFile.d.ts","sourceRoot":"","sources":["../../src/utils/isSensitiveFile.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GACf,OAAO,CAGT"}
@@ -0,0 +1,13 @@
1
+ // Import Node.js Dependencies
2
+ import path from "node:path";
3
+ // CONSTANTS
4
+ const kSensitiveFileName = new Set([".npmrc", ".env"]);
5
+ const kSensitiveFileExtension = new Set([".key", ".pem"]);
6
+ /**
7
+ * @see https://github.com/jandre/safe-commit-hook/blob/master/git-deny-patterns.json
8
+ */
9
+ export function isSensitiveFile(fileName) {
10
+ return kSensitiveFileName.has(path.basename(fileName)) ||
11
+ kSensitiveFileExtension.has(path.extname(fileName));
12
+ }
13
+ //# sourceMappingURL=isSensitiveFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isSensitiveFile.js","sourceRoot":"","sources":["../../src/utils/isSensitiveFile.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,YAAY;AACZ,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AACvD,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB;IAEhB,OAAO,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpD,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { WarningDefault } from "@nodesecure/js-x-ray";
2
+ export declare function getSemVerWarning(value: string): WarningDefault<"zero-semver">;
3
+ export declare function getEmptyPackageWarning(): WarningDefault<"empty-package">;
4
+ //# sourceMappingURL=warnings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warnings.d.ts","sourceRoot":"","sources":["../src/warnings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GACZ,cAAc,CAAC,aAAa,CAAC,CAW/B;AAED,wBAAgB,sBAAsB,IAAI,cAAc,CAAC,eAAe,CAAC,CAWxE"}
@@ -0,0 +1,25 @@
1
+ export function getSemVerWarning(value) {
2
+ return {
3
+ kind: "zero-semver",
4
+ file: "package.json",
5
+ value,
6
+ location: null,
7
+ i18n: "sast_warnings.zeroSemVer",
8
+ severity: "Information",
9
+ source: "Scanner",
10
+ experimental: false
11
+ };
12
+ }
13
+ export function getEmptyPackageWarning() {
14
+ return {
15
+ kind: "empty-package",
16
+ file: "package.json",
17
+ value: "package.json",
18
+ location: null,
19
+ i18n: "sast_warnings.emptyPackage",
20
+ severity: "Critical",
21
+ source: "Scanner",
22
+ experimental: false
23
+ };
24
+ }
25
+ //# sourceMappingURL=warnings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warnings.js","sourceRoot":"","sources":["../src/warnings.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,gBAAgB,CAC9B,KAAa;IAEb,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,IAAI,EAAE,cAAc;QACpB,KAAK;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,0BAA0B;QAChC,QAAQ,EAAE,aAAa;QACvB,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB;IACpC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,cAAc;QACrB,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,4BAA4B;QAClC,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,SAAS;QACjB,YAAY,EAAE,KAAK;KACpB,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@nodesecure/tarball",
3
+ "version": "1.0.0",
4
+ "description": "NodeSecure tarball scanner",
5
+ "type": "module",
6
+ "exports": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc -b",
10
+ "prepublishOnly": "npm run build",
11
+ "test-only": "glob -c \"tsx --test\" \"./test/**/*.spec.ts\"",
12
+ "test": "c8 -r html npm run test-only"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "keywords": [
18
+ "NodeSecure",
19
+ "tarball"
20
+ ],
21
+ "author": "GENTILHOMME Thomas <gentilhomme.thomas@gmail.com>",
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/NodeSecure/scanner.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/NodeSecure/scanner/issues"
29
+ },
30
+ "homepage": "https://github.com/NodeSecure/tree/master/workspaces/tarball#readme",
31
+ "dependencies": {
32
+ "@nodesecure/conformance": "^1.0.0",
33
+ "@nodesecure/fs-walk": "^2.0.0",
34
+ "@nodesecure/js-x-ray": "^7.3.0",
35
+ "@nodesecure/mama": "^1.0.0",
36
+ "@nodesecure/npm-types": "^1.1.0",
37
+ "@nodesecure/utils": "^2.1.0",
38
+ "pacote": "^18.0.6"
39
+ },
40
+ "devDependencies": {
41
+ "get-folder-size": "^5.0.0"
42
+ }
43
+ }