6 | Utilities to extract/fetch data on NPM contacts (author, maintainers etc..) 7 |
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/contact 18 | # or 19 | $ yarn add @nodesecure/contact 20 | ``` 21 | 22 | ## Usage example 23 | 24 | Here is an example of usage from the Scanner. In this case, we are using **dependenciesMap**, which is a `Record6 | Up to date typescript definitions for npm registry content 7 |
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/npm-types -D 18 | # or 19 | $ yarn add @nodesecure/npm-types -D 20 | ``` 21 | 22 | ## Usage example 23 | 24 | ```ts 25 | import type { PackageJSON } from "@nodesecure/npm-types"; 26 | ``` 27 | -------------------------------------------------------------------------------- /workspaces/npm-types/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@nodesecure/npm-types", 3 | "version": "1.2.1", 4 | "description": "Up to date typescript definitions for npm registry content", 5 | "types": "./src/index.d.ts", 6 | "exports": "./src/index.d.ts", 7 | "files": [ 8 | "src" 9 | ], 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/NodeSecure/scanner.git" 13 | }, 14 | "keywords": [ 15 | "npm registry", 16 | "types", 17 | "typescript", 18 | "definitions", 19 | "typings" 20 | ], 21 | "author": "NodeSecure", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/NodeSecure/scanner/issues" 25 | }, 26 | "homepage": "https://github.com/NodeSecure/tree/master/workspaces/npm-types#readme", 27 | "private": false 28 | } 29 | -------------------------------------------------------------------------------- /workspaces/npm-types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../../tsconfig.base.json" 3 | } 4 | -------------------------------------------------------------------------------- /workspaces/rc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@nodesecure/rc", 3 | "version": "4.1.0", 4 | "description": "NodeSecure runtime configuration", 5 | "type": "module", 6 | "main": "./dist/index.js", 7 | "types": "./dist/index.d.ts", 8 | "engines": { 9 | "node": ">=20" 10 | }, 11 | "scripts": { 12 | "build": "tsc", 13 | "prepublishOnly": "npm run build", 14 | "test-only": "tsx --test ./test/**/*.spec.ts", 15 | "test:tsd": "npm run build && tsd", 16 | "test": "c8 -r html npm run test-only && npm run test:tsd" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/NodeSecure/scanner.git" 21 | }, 22 | "files": [ 23 | "dist" 24 | ], 25 | "keywords": [ 26 | "rc", 27 | "config", 28 | "configuration" 29 | ], 30 | "author": "GENTILHOMME Thomas6 | The documentation of this project is in the root README 7 |
8 | -------------------------------------------------------------------------------- /workspaces/scanner/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@nodesecure/scanner", 3 | "version": "6.5.0", 4 | "description": "A package API to run a static analysis of your module's dependencies.", 5 | "type": "module", 6 | "exports": "./dist/index.js", 7 | "types": "./dist/index.d.ts", 8 | "engines": { 9 | "node": ">=20" 10 | }, 11 | "scripts": { 12 | "build": "tsc -b", 13 | "lint": "eslint src test", 14 | "prepublishOnly": "npm run build && pkg-ok", 15 | "test": "npm run test-only", 16 | "test-only": "tsx --test ./test/**/*.spec.ts", 17 | "coverage": "c8 -r html npm run test-only" 18 | }, 19 | "files": [ 20 | "dist" 21 | ], 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/NodeSecure/scanner.git" 25 | }, 26 | "keywords": [ 27 | "node", 28 | "nodejs", 29 | "security", 30 | "cli", 31 | "sast", 32 | "scanner", 33 | "static", 34 | "code", 35 | "analysis", 36 | "node_modules", 37 | "tree", 38 | "npm", 39 | "registry", 40 | "graph", 41 | "visualization", 42 | "dependencies" 43 | ], 44 | "author": "NodeSecure", 45 | "license": "MIT", 46 | "bugs": { 47 | "url": "https://github.com/NodeSecure/scanner/issues" 48 | }, 49 | "homepage": "https://github.com/NodeSecure/tree/master/workspaces/scanner#readme", 50 | "dependencies": { 51 | "@fastify/deepmerge": "^3.1.0", 52 | "@nodesecure/conformance": "^1.0.0", 53 | "@nodesecure/contact": "^1.0.1", 54 | "@nodesecure/flags": "^3.0.3", 55 | "@nodesecure/i18n": "^4.0.1", 56 | "@nodesecure/js-x-ray": "^8.1.0", 57 | "@nodesecure/mama": "^1.2.0", 58 | "@nodesecure/npm-registry-sdk": "^3.0.0", 59 | "@nodesecure/npm-types": "^1.2.0", 60 | "@nodesecure/rc": "^4.1.0", 61 | "@nodesecure/tarball": "^1.2.0", 62 | "@nodesecure/tree-walker": "^1.3.0", 63 | "@nodesecure/vulnera": "^2.0.1", 64 | "@openally/mutex": "^1.0.0", 65 | "frequency-set": "^1.0.2", 66 | "pacote": "^21.0.0", 67 | "semver": "^7.5.4", 68 | "type-fest": "^4.41.0" 69 | }, 70 | "devDependencies": { 71 | "@types/node": "^22.15.17", 72 | "c8": "^10.1.3", 73 | "tsx": "^4.19.4", 74 | "typescript": "^5.8.3" 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /workspaces/scanner/src/class/logger.class.ts: -------------------------------------------------------------------------------- 1 | // Import Node.js Dependencies 2 | import { EventEmitter } from "node:events"; 3 | import { performance } from "node:perf_hooks"; 4 | 5 | export const ScannerLoggerEvents = { 6 | done: "depWalkerFinished", 7 | analysis: { 8 | tree: "walkTree", 9 | tarball: "tarball", 10 | registry: "registry" 11 | }, 12 | manifest: { 13 | read: "readManifest", 14 | fetch: "fetchManifest" 15 | } 16 | } as const; 17 | 18 | export interface LoggerEventData { 19 | /** UNIX Timestamp */ 20 | startedAt: number; 21 | /** Count of triggered event */ 22 | count: number; 23 | } 24 | 25 | export class Logger extends EventEmitter { 26 | public events: Map6 | Utilities to extract and deeply analyze NPM tarball 7 |
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