@cyberhub/shieldpm 0.1.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.
- package/LICENSE +21 -0
- package/README.md +239 -0
- package/dist/analyzer/static.d.ts +35 -0
- package/dist/analyzer/static.d.ts.map +1 -0
- package/dist/analyzer/static.js +416 -0
- package/dist/analyzer/static.js.map +1 -0
- package/dist/analyzer/typosquat.d.ts +30 -0
- package/dist/analyzer/typosquat.d.ts.map +1 -0
- package/dist/analyzer/typosquat.js +211 -0
- package/dist/analyzer/typosquat.js.map +1 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +621 -0
- package/dist/cli.js.map +1 -0
- package/dist/diff/dependency.d.ts +51 -0
- package/dist/diff/dependency.d.ts.map +1 -0
- package/dist/diff/dependency.js +222 -0
- package/dist/diff/dependency.js.map +1 -0
- package/dist/fingerprint/profile.d.ts +68 -0
- package/dist/fingerprint/profile.d.ts.map +1 -0
- package/dist/fingerprint/profile.js +233 -0
- package/dist/fingerprint/profile.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/monitor/permissions.d.ts +45 -0
- package/dist/monitor/permissions.d.ts.map +1 -0
- package/dist/monitor/permissions.js +265 -0
- package/dist/monitor/permissions.js.map +1 -0
- package/dist/sandbox/runner.d.ts +46 -0
- package/dist/sandbox/runner.d.ts.map +1 -0
- package/dist/sandbox/runner.js +216 -0
- package/dist/sandbox/runner.js.map +1 -0
- package/dist/utils/colors.d.ts +31 -0
- package/dist/utils/colors.d.ts.map +1 -0
- package/dist/utils/colors.js +54 -0
- package/dist/utils/colors.js.map +1 -0
- package/dist/utils/logger.d.ts +26 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +77 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +24 -0
- package/src/analyzer/static.ts +483 -0
- package/src/analyzer/typosquat.ts +272 -0
- package/src/cli.ts +700 -0
- package/src/diff/dependency.ts +297 -0
- package/src/fingerprint/profile.ts +333 -0
- package/src/index.ts +34 -0
- package/src/monitor/permissions.ts +330 -0
- package/src/sandbox/runner.ts +302 -0
- package/src/utils/colors.ts +58 -0
- package/src/utils/logger.ts +87 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ShieldPM — Sandbox Runner
|
|
3
|
+
* Executes commands (especially postinstall scripts) in a restricted environment
|
|
4
|
+
* with network blocking, timeout enforcement, and output capture.
|
|
5
|
+
*/
|
|
6
|
+
import { spawn } from 'node:child_process';
|
|
7
|
+
import { platform } from 'node:os';
|
|
8
|
+
// ── Safe environment builder ─────────────────────────────────────────────
|
|
9
|
+
const SAFE_ENV_VARS = new Set([
|
|
10
|
+
'PATH',
|
|
11
|
+
'HOME',
|
|
12
|
+
'USER',
|
|
13
|
+
'SHELL',
|
|
14
|
+
'LANG',
|
|
15
|
+
'LC_ALL',
|
|
16
|
+
'TERM',
|
|
17
|
+
'TMPDIR',
|
|
18
|
+
'TMP',
|
|
19
|
+
'TEMP',
|
|
20
|
+
'NODE_ENV',
|
|
21
|
+
'NODE_PATH',
|
|
22
|
+
]);
|
|
23
|
+
const SENSITIVE_ENV_VARS = new Set([
|
|
24
|
+
'AWS_ACCESS_KEY_ID',
|
|
25
|
+
'AWS_SECRET_ACCESS_KEY',
|
|
26
|
+
'AWS_SESSION_TOKEN',
|
|
27
|
+
'GITHUB_TOKEN',
|
|
28
|
+
'GH_TOKEN',
|
|
29
|
+
'NPM_TOKEN',
|
|
30
|
+
'NPM_AUTH_TOKEN',
|
|
31
|
+
'DOCKER_PASSWORD',
|
|
32
|
+
'SSH_AUTH_SOCK',
|
|
33
|
+
'GPG_TTY',
|
|
34
|
+
'DATABASE_URL',
|
|
35
|
+
'REDIS_URL',
|
|
36
|
+
'API_KEY',
|
|
37
|
+
'SECRET_KEY',
|
|
38
|
+
'PRIVATE_KEY',
|
|
39
|
+
]);
|
|
40
|
+
function buildSandboxEnv(blockNetwork, blockEnv, allowedEnvVars) {
|
|
41
|
+
const env = {};
|
|
42
|
+
if (blockEnv) {
|
|
43
|
+
// Only pass through safe variables
|
|
44
|
+
const allowed = new Set([...SAFE_ENV_VARS, ...allowedEnvVars]);
|
|
45
|
+
for (const key of allowed) {
|
|
46
|
+
if (process.env[key] !== undefined) {
|
|
47
|
+
env[key] = process.env[key];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// Pass through everything except sensitive vars
|
|
53
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
54
|
+
if (!SENSITIVE_ENV_VARS.has(key) && value !== undefined) {
|
|
55
|
+
env[key] = value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Also pass explicitly allowed
|
|
59
|
+
for (const key of allowedEnvVars) {
|
|
60
|
+
if (process.env[key] !== undefined) {
|
|
61
|
+
env[key] = process.env[key];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Block network via proxy settings
|
|
66
|
+
if (blockNetwork) {
|
|
67
|
+
env['HTTP_PROXY'] = 'http://blocked.shieldpm.local:0';
|
|
68
|
+
env['HTTPS_PROXY'] = 'http://blocked.shieldpm.local:0';
|
|
69
|
+
env['http_proxy'] = 'http://blocked.shieldpm.local:0';
|
|
70
|
+
env['https_proxy'] = 'http://blocked.shieldpm.local:0';
|
|
71
|
+
env['no_proxy'] = '';
|
|
72
|
+
env['NODE_OPTIONS'] = [
|
|
73
|
+
env['NODE_OPTIONS'] ?? '',
|
|
74
|
+
'--dns-result-order=verbatim',
|
|
75
|
+
].filter(Boolean).join(' ');
|
|
76
|
+
}
|
|
77
|
+
// Prevent spawning of sub-shells from modifying real config
|
|
78
|
+
env['npm_config_ignore_scripts'] = 'true';
|
|
79
|
+
return env;
|
|
80
|
+
}
|
|
81
|
+
// ── Platform-specific restrictions ───────────────────────────────────────
|
|
82
|
+
function buildPlatformArgs() {
|
|
83
|
+
const args = [];
|
|
84
|
+
if (platform() === 'linux') {
|
|
85
|
+
// On Linux, we could use unshare for network namespace isolation
|
|
86
|
+
// For now, we rely on proxy blocking; future: seccomp/landlock
|
|
87
|
+
}
|
|
88
|
+
return args;
|
|
89
|
+
}
|
|
90
|
+
// ── Output truncation ────────────────────────────────────────────────────
|
|
91
|
+
function truncateOutput(output, maxSize) {
|
|
92
|
+
if (Buffer.byteLength(output) <= maxSize)
|
|
93
|
+
return output;
|
|
94
|
+
const truncated = output.slice(0, maxSize);
|
|
95
|
+
return truncated + `\n... [output truncated at ${Math.round(maxSize / 1024)}KB]`;
|
|
96
|
+
}
|
|
97
|
+
// ── Main runner ──────────────────────────────────────────────────────────
|
|
98
|
+
/**
|
|
99
|
+
* Run a command inside a restricted sandbox environment.
|
|
100
|
+
*/
|
|
101
|
+
export async function runSandboxed(command, args = [], options = {}) {
|
|
102
|
+
const { cwd = process.cwd(), timeout = 30_000, blockNetwork = true, blockEnv = true, allowedEnvVars = [], maxOutputSize = 1024 * 1024, // 1MB
|
|
103
|
+
verbose = false, } = options;
|
|
104
|
+
const warnings = [];
|
|
105
|
+
const blocked = [];
|
|
106
|
+
// Build restricted environment
|
|
107
|
+
const env = buildSandboxEnv(blockNetwork, blockEnv, allowedEnvVars);
|
|
108
|
+
if (blockNetwork) {
|
|
109
|
+
blocked.push('network: HTTP/HTTPS proxied to blocked endpoint');
|
|
110
|
+
}
|
|
111
|
+
if (blockEnv) {
|
|
112
|
+
const removedCount = Object.keys(process.env).length - Object.keys(env).length;
|
|
113
|
+
blocked.push(`environment: ${removedCount} env vars stripped`);
|
|
114
|
+
}
|
|
115
|
+
const startTime = Date.now();
|
|
116
|
+
let timedOut = false;
|
|
117
|
+
return new Promise((resolve) => {
|
|
118
|
+
let child;
|
|
119
|
+
let stdoutChunks = [];
|
|
120
|
+
let stderrChunks = [];
|
|
121
|
+
let stdoutSize = 0;
|
|
122
|
+
let stderrSize = 0;
|
|
123
|
+
try {
|
|
124
|
+
child = spawn(command, args, {
|
|
125
|
+
cwd,
|
|
126
|
+
env,
|
|
127
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
128
|
+
shell: true,
|
|
129
|
+
// Kill the entire process group on timeout
|
|
130
|
+
detached: false,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
resolve({
|
|
135
|
+
exitCode: 1,
|
|
136
|
+
stdout: '',
|
|
137
|
+
stderr: `Failed to spawn process: ${err instanceof Error ? err.message : String(err)}`,
|
|
138
|
+
warnings,
|
|
139
|
+
blocked,
|
|
140
|
+
timedOut: false,
|
|
141
|
+
durationMs: Date.now() - startTime,
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Capture stdout
|
|
146
|
+
child.stdout?.on('data', (chunk) => {
|
|
147
|
+
if (stdoutSize < maxOutputSize) {
|
|
148
|
+
stdoutChunks.push(chunk);
|
|
149
|
+
stdoutSize += chunk.length;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
// Capture stderr
|
|
153
|
+
child.stderr?.on('data', (chunk) => {
|
|
154
|
+
if (stderrSize < maxOutputSize) {
|
|
155
|
+
stderrChunks.push(chunk);
|
|
156
|
+
stderrSize += chunk.length;
|
|
157
|
+
}
|
|
158
|
+
// Watch for suspicious patterns in stderr
|
|
159
|
+
const text = chunk.toString();
|
|
160
|
+
if (/ECONNREFUSED|ENOTFOUND|blocked\.shieldpm/.test(text)) {
|
|
161
|
+
warnings.push('Process attempted network access (blocked by sandbox)');
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
// Timeout
|
|
165
|
+
const timer = setTimeout(() => {
|
|
166
|
+
timedOut = true;
|
|
167
|
+
warnings.push(`Process killed: exceeded ${timeout}ms timeout`);
|
|
168
|
+
child.kill('SIGKILL');
|
|
169
|
+
}, timeout);
|
|
170
|
+
// Completion
|
|
171
|
+
child.on('close', (code) => {
|
|
172
|
+
clearTimeout(timer);
|
|
173
|
+
const stdout = truncateOutput(Buffer.concat(stdoutChunks).toString('utf-8'), maxOutputSize);
|
|
174
|
+
const stderr = truncateOutput(Buffer.concat(stderrChunks).toString('utf-8'), maxOutputSize);
|
|
175
|
+
if (code !== 0 && !timedOut) {
|
|
176
|
+
warnings.push(`Process exited with code ${code}`);
|
|
177
|
+
}
|
|
178
|
+
resolve({
|
|
179
|
+
exitCode: code,
|
|
180
|
+
stdout,
|
|
181
|
+
stderr,
|
|
182
|
+
warnings,
|
|
183
|
+
blocked,
|
|
184
|
+
timedOut,
|
|
185
|
+
durationMs: Date.now() - startTime,
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
child.on('error', (err) => {
|
|
189
|
+
clearTimeout(timer);
|
|
190
|
+
resolve({
|
|
191
|
+
exitCode: 1,
|
|
192
|
+
stdout: Buffer.concat(stdoutChunks).toString('utf-8'),
|
|
193
|
+
stderr: err.message,
|
|
194
|
+
warnings: [...warnings, `Spawn error: ${err.message}`],
|
|
195
|
+
blocked,
|
|
196
|
+
timedOut: false,
|
|
197
|
+
durationMs: Date.now() - startTime,
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
// Close stdin immediately
|
|
201
|
+
child.stdin?.end();
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Run an npm postinstall script in the sandbox.
|
|
206
|
+
*/
|
|
207
|
+
export async function runPostInstall(packageDir, script, options = {}) {
|
|
208
|
+
return runSandboxed('sh', ['-c', script], {
|
|
209
|
+
cwd: packageDir,
|
|
210
|
+
timeout: 30_000,
|
|
211
|
+
blockNetwork: true,
|
|
212
|
+
blockEnv: true,
|
|
213
|
+
...options,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.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R,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;aACnC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC;gBACN,QAAQ,EAAE,CAAC;gBACX,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;gBACrD,MAAM,EAAE,GAAG,CAAC,OAAO;gBACnB,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE,gBAAgB,GAAG,CAAC,OAAO,EAAE,CAAC;gBACtD,OAAO;gBACP,QAAQ,EAAE,KAAK;gBACf,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS;aACnC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,0BAA0B;QAC1B,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,UAAkB,EAClB,MAAc,EACd,UAA0B,EAAE;IAE5B,OAAO,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE;QACxC,GAAG,EAAE,UAAU;QACf,OAAO,EAAE,MAAM;QACf,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,IAAI;QACd,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ShieldPM — Terminal color helpers (zero dependencies)
|
|
3
|
+
* Simple ANSI escape code wrapper, no chalk needed.
|
|
4
|
+
*/
|
|
5
|
+
export declare const red: (text: string) => string;
|
|
6
|
+
export declare const green: (text: string) => string;
|
|
7
|
+
export declare const yellow: (text: string) => string;
|
|
8
|
+
export declare const blue: (text: string) => string;
|
|
9
|
+
export declare const magenta: (text: string) => string;
|
|
10
|
+
export declare const cyan: (text: string) => string;
|
|
11
|
+
export declare const white: (text: string) => string;
|
|
12
|
+
export declare const gray: (text: string) => string;
|
|
13
|
+
export declare const bold: (text: string) => string;
|
|
14
|
+
export declare const dim: (text: string) => string;
|
|
15
|
+
export declare const italic: (text: string) => string;
|
|
16
|
+
export declare const underline: (text: string) => string;
|
|
17
|
+
export declare const reset: (text: string) => string;
|
|
18
|
+
export declare const redBright: (text: string) => string;
|
|
19
|
+
export declare const greenBright: (text: string) => string;
|
|
20
|
+
export declare const yellowBright: (text: string) => string;
|
|
21
|
+
export declare const blueBright: (text: string) => string;
|
|
22
|
+
export declare const cyanBright: (text: string) => string;
|
|
23
|
+
export declare const bgRed: (text: string) => string;
|
|
24
|
+
export declare const bgGreen: (text: string) => string;
|
|
25
|
+
export declare const bgYellow: (text: string) => string;
|
|
26
|
+
export declare const boldRed: (t: string) => string;
|
|
27
|
+
export declare const boldGreen: (t: string) => string;
|
|
28
|
+
export declare const boldYellow: (t: string) => string;
|
|
29
|
+
export declare const boldCyan: (t: string) => string;
|
|
30
|
+
export declare const boldBlue: (t: string) => string;
|
|
31
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/utils/colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH,eAAO,MAAM,GAAG,SAPA,MAAM,KAAG,MAOU,CAAC;AACpC,eAAO,MAAM,KAAK,SARF,MAAM,KAAG,MAQY,CAAC;AACtC,eAAO,MAAM,MAAM,SATH,MAAM,KAAG,MASa,CAAC;AACvC,eAAO,MAAM,IAAI,SAVD,MAAM,KAAG,MAUW,CAAC;AACrC,eAAO,MAAM,OAAO,SAXJ,MAAM,KAAG,MAWc,CAAC;AACxC,eAAO,MAAM,IAAI,SAZD,MAAM,KAAG,MAYW,CAAC;AACrC,eAA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simple ANSI escape code wrapper, no chalk needed.
|
|
4
|
+
*/
|
|
5
|
+
const isColorSupported = () => {
|
|
6
|
+
if (process.env.NO_COLOR !== undefined)
|
|
7
|
+
return false;
|
|
8
|
+
if (process.env.FORCE_COLOR !== undefined)
|
|
9
|
+
return true;
|
|
10
|
+
if (!process.stdout.isTTY)
|
|
11
|
+
return false;
|
|
12
|
+
return true;
|
|
13
|
+
};
|
|
14
|
+
const enabled = isColorSupported();
|
|
15
|
+
const wrap = (open, close) => {
|
|
16
|
+
return (text) => {
|
|
17
|
+
if (!enabled)
|
|
18
|
+
return text;
|
|
19
|
+
return `\x1b[${open}m${text}\x1b[${close}m`;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
// Foreground colors
|
|
23
|
+
export const red = wrap('31', '39');
|
|
24
|
+
export const green = wrap('32', '39');
|
|
25
|
+
export const yellow = wrap('33', '39');
|
|
26
|
+
export const blue = wrap('34', '39');
|
|
27
|
+
export const magenta = wrap('35', '39');
|
|
28
|
+
export const cyan = wrap('36', '39');
|
|
29
|
+
export const white = wrap('37', '39');
|
|
30
|
+
export const gray = wrap('90', '39');
|
|
31
|
+
// Styles
|
|
32
|
+
export const bold = wrap('1', '22');
|
|
33
|
+
export const dim = wrap('2', '22');
|
|
34
|
+
export const italic = wrap('3', '23');
|
|
35
|
+
export const underline = wrap('4', '24');
|
|
36
|
+
// Reset
|
|
37
|
+
export const reset = wrap('0', '0');
|
|
38
|
+
// Bright variants
|
|
39
|
+
export const redBright = wrap('91', '39');
|
|
40
|
+
export const greenBright = wrap('92', '39');
|
|
41
|
+
export const yellowBright = wrap('93', '39');
|
|
42
|
+
export const blueBright = wrap('94', '39');
|
|
43
|
+
export const cyanBright = wrap('96', '39');
|
|
44
|
+
// Background colors
|
|
45
|
+
export const bgRed = wrap('41', '49');
|
|
46
|
+
export const bgGreen = wrap('42', '49');
|
|
47
|
+
export const bgYellow = wrap('43', '49');
|
|
48
|
+
// Composable: bold + color
|
|
49
|
+
export const boldRed = (t) => bold(red(t));
|
|
50
|
+
export const boldGreen = (t) => bold(green(t));
|
|
51
|
+
export const boldYellow = (t) => bold(yellow(t));
|
|
52
|
+
export const boldCyan = (t) => bold(cyan(t));
|
|
53
|
+
export const boldBlue = (t) => bold(blue(t));
|
|
54
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/utils/colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,gBAAgB,GAAG,GAAY,EAAE;IACrC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACvD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACxC,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;AAEnC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE;IAC3C,OAAO,CAAC,IAAY,EAAU,EAAE;QAC9B,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAC1B,OAAO,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,GAAG,CAAC;IAC9C,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,oBAAoB;AACpB,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,I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IAAI,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAEzC,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ShieldPM — Logger with levels and colored output
|
|
3
|
+
*/
|
|
4
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
5
|
+
export declare function setLogLevel(level: LogLevel): void;
|
|
6
|
+
export declare function getLogLevel(): LogLevel;
|
|
7
|
+
export declare function debug(...args: unknown[]): void;
|
|
8
|
+
export declare function info(...args: unknown[]): void;
|
|
9
|
+
export declare function warn(...args: unknown[]): void;
|
|
10
|
+
export declare function error(...args: unknown[]): void;
|
|
11
|
+
export declare function success(...args: unknown[]): void;
|
|
12
|
+
export declare function header(text: string): void;
|
|
13
|
+
export declare function table(rows: [string, string][]): void;
|
|
14
|
+
export declare const log: {
|
|
15
|
+
debug: typeof debug;
|
|
16
|
+
info: typeof info;
|
|
17
|
+
warn: typeof warn;
|
|
18
|
+
error: typeof error;
|
|
19
|
+
success: typeof success;
|
|
20
|
+
header: typeof header;
|
|
21
|
+
table: typeof table;
|
|
22
|
+
setLevel: typeof setLogLevel;
|
|
23
|
+
getLevel: typeof getLogLevel;
|
|
24
|
+
};
|
|
25
|
+
export default log;
|
|
26
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAYtE,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAEjD;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAEtC;AAUD,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAG9C;AAED,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAG7C;AAED,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAG7C;AAED,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAG9C;AAED,wBAAgB,OAAO,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAGhD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAKzC;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,IAAI,CAMpD;AAED,eAAO,MAAM,GAAG;;;;;;;;;;CAUf,CAAC;AAEF,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ShieldPM — Logger with levels and colored output
|
|
3
|
+
*/
|
|
4
|
+
import { red, green, yellow, cyan, dim, bold, boldRed, boldGreen, boldYellow } from './colors.js';
|
|
5
|
+
const LEVEL_PRIORITY = {
|
|
6
|
+
debug: 0,
|
|
7
|
+
info: 1,
|
|
8
|
+
warn: 2,
|
|
9
|
+
error: 3,
|
|
10
|
+
silent: 4,
|
|
11
|
+
};
|
|
12
|
+
let currentLevel = 'info';
|
|
13
|
+
export function setLogLevel(level) {
|
|
14
|
+
currentLevel = level;
|
|
15
|
+
}
|
|
16
|
+
export function getLogLevel() {
|
|
17
|
+
return currentLevel;
|
|
18
|
+
}
|
|
19
|
+
function shouldLog(level) {
|
|
20
|
+
return LEVEL_PRIORITY[level] >= LEVEL_PRIORITY[currentLevel];
|
|
21
|
+
}
|
|
22
|
+
function timestamp() {
|
|
23
|
+
return dim(new Date().toISOString().slice(11, 19));
|
|
24
|
+
}
|
|
25
|
+
export function debug(...args) {
|
|
26
|
+
if (!shouldLog('debug'))
|
|
27
|
+
return;
|
|
28
|
+
console.log(dim('[debug]'), timestamp(), ...args);
|
|
29
|
+
}
|
|
30
|
+
export function info(...args) {
|
|
31
|
+
if (!shouldLog('info'))
|
|
32
|
+
return;
|
|
33
|
+
console.log(cyan('i'), ...args);
|
|
34
|
+
}
|
|
35
|
+
export function warn(...args) {
|
|
36
|
+
if (!shouldLog('warn'))
|
|
37
|
+
return;
|
|
38
|
+
console.warn(boldYellow('!'), yellow('warn'), ...args);
|
|
39
|
+
}
|
|
40
|
+
export function error(...args) {
|
|
41
|
+
if (!shouldLog('error'))
|
|
42
|
+
return;
|
|
43
|
+
console.error(boldRed('x'), red('error'), ...args);
|
|
44
|
+
}
|
|
45
|
+
export function success(...args) {
|
|
46
|
+
if (!shouldLog('info'))
|
|
47
|
+
return;
|
|
48
|
+
console.log(boldGreen('\u2713'), green(args.map(String).join(' ')));
|
|
49
|
+
}
|
|
50
|
+
export function header(text) {
|
|
51
|
+
if (!shouldLog('info'))
|
|
52
|
+
return;
|
|
53
|
+
console.log();
|
|
54
|
+
console.log(bold(cyan(` ${text}`)));
|
|
55
|
+
console.log(dim(' ' + '\u2500'.repeat(text.length + 2)));
|
|
56
|
+
}
|
|
57
|
+
export function table(rows) {
|
|
58
|
+
if (!shouldLog('info'))
|
|
59
|
+
return;
|
|
60
|
+
const maxKey = Math.max(...rows.map(([k]) => k.length));
|
|
61
|
+
for (const [key, value] of rows) {
|
|
62
|
+
console.log(` ${dim(key.padEnd(maxKey))} ${value}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export const log = {
|
|
66
|
+
debug,
|
|
67
|
+
info,
|
|
68
|
+
warn,
|
|
69
|
+
error,
|
|
70
|
+
success,
|
|
71
|
+
header,
|
|
72
|
+
table,
|
|
73
|
+
setLevel: setLogLevel,
|
|
74
|
+
getLevel: getLogLevel,
|
|
75
|
+
};
|
|
76
|
+
export default log;
|
|
77
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIlG,MAAM,cAAc,GAA6B;IAC/C,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;CACV,CAAC;AAEF,IAAI,YAAY,GAAa,MAAM,CAAC;AAEpC,MAAM,UAAU,WAAW,CAAC,KAAe;IACzC,YAAY,GAAG,KAAK,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,YAAY,CAAC;AACtB,CAA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
2
|
+
"name": "@cyberhub/shieldpm",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Runtime-aware package firewall for Node.js — sandbox, monitor, and enforce least-privilege on every npm dependency",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Nrupak Shah",
|
|
7
|
+
"repository": { "type": "git", "url": "https://github.com/nrupaks/shieldpm" },
|
|
8
|
+
"bin": { "shieldpm": "./dist/cli.js" },
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsx src/cli.ts",
|
|
14
|
+
"test": "vitest",
|
|
15
|
+
"lint": "eslint src/"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"typescript": "^5.7.0",
|
|
20
|
+
"tsx": "^4.0.0",
|
|
21
|
+
"vitest": "^3.0.0",
|
|
22
|
+
"@types/node": "^22.0.0"
|
|
23
|
+
}
|
|
24
|
+
}
|