openpen 0.2.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 +30 -0
- package/dist/checks/auth-bypass.d.ts +12 -0
- package/dist/checks/auth-bypass.js +93 -0
- package/dist/checks/bac.d.ts +12 -0
- package/dist/checks/bac.js +107 -0
- package/dist/checks/base.d.ts +22 -0
- package/dist/checks/base.js +13 -0
- package/dist/checks/index.d.ts +7 -0
- package/dist/checks/index.js +40 -0
- package/dist/checks/llm-leak.d.ts +23 -0
- package/dist/checks/llm-leak.js +251 -0
- package/dist/checks/mass-assignment.d.ts +12 -0
- package/dist/checks/mass-assignment.js +169 -0
- package/dist/checks/prompt-injection.d.ts +23 -0
- package/dist/checks/prompt-injection.js +262 -0
- package/dist/checks/security-headers.d.ts +12 -0
- package/dist/checks/security-headers.js +133 -0
- package/dist/checks/sensitive-data.d.ts +12 -0
- package/dist/checks/sensitive-data.js +122 -0
- package/dist/checks/sqli.d.ts +12 -0
- package/dist/checks/sqli.js +178 -0
- package/dist/checks/ssrf.d.ts +12 -0
- package/dist/checks/ssrf.js +126 -0
- package/dist/checks/xss.d.ts +12 -0
- package/dist/checks/xss.js +79 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +300 -0
- package/dist/fuzzer/engine.d.ts +27 -0
- package/dist/fuzzer/engine.js +126 -0
- package/dist/fuzzer/mutator.d.ts +8 -0
- package/dist/fuzzer/mutator.js +54 -0
- package/dist/fuzzer/payloads.d.ts +13 -0
- package/dist/fuzzer/payloads.js +167 -0
- package/dist/reporter/index.d.ts +5 -0
- package/dist/reporter/index.js +5 -0
- package/dist/reporter/json.d.ts +5 -0
- package/dist/reporter/json.js +14 -0
- package/dist/reporter/terminal.d.ts +5 -0
- package/dist/reporter/terminal.js +59 -0
- package/dist/spec/openapi.d.ts +5 -0
- package/dist/spec/openapi.js +119 -0
- package/dist/spec/parser.d.ts +11 -0
- package/dist/spec/parser.js +45 -0
- package/dist/types.d.ts +145 -0
- package/dist/types.js +4 -0
- package/dist/utils/http.d.ts +37 -0
- package/dist/utils/http.js +92 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/logger.js +20 -0
- package/dist/ws/checks.d.ts +18 -0
- package/dist/ws/checks.js +558 -0
- package/dist/ws/engine.d.ts +47 -0
- package/dist/ws/engine.js +139 -0
- package/package.json +41 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level HTTP helpers wrapping native fetch
|
|
3
|
+
*/
|
|
4
|
+
import { verbose } from './logger.js';
|
|
5
|
+
export async function sendRequest(opts) {
|
|
6
|
+
const { url, method, headers = {}, body, timeout = 10000 } = opts;
|
|
7
|
+
const reqHeaders = {
|
|
8
|
+
'User-Agent': 'openpen/0.1.0',
|
|
9
|
+
...headers,
|
|
10
|
+
};
|
|
11
|
+
if (body && !reqHeaders['Content-Type']) {
|
|
12
|
+
reqHeaders['Content-Type'] = 'application/json';
|
|
13
|
+
}
|
|
14
|
+
verbose(` -> ${method} ${url}`);
|
|
15
|
+
const start = Date.now();
|
|
16
|
+
const res = await fetch(url, {
|
|
17
|
+
method,
|
|
18
|
+
headers: reqHeaders,
|
|
19
|
+
body: body || undefined,
|
|
20
|
+
signal: AbortSignal.timeout(timeout),
|
|
21
|
+
redirect: 'follow',
|
|
22
|
+
});
|
|
23
|
+
const responseTime = Date.now() - start;
|
|
24
|
+
const responseBody = await res.text();
|
|
25
|
+
const responseHeaders = {};
|
|
26
|
+
for (const [k, v] of res.headers) {
|
|
27
|
+
responseHeaders[k] = v;
|
|
28
|
+
}
|
|
29
|
+
verbose(` <- ${res.status} (${responseTime}ms, ${responseBody.length} bytes)`);
|
|
30
|
+
return {
|
|
31
|
+
request: {
|
|
32
|
+
url,
|
|
33
|
+
method,
|
|
34
|
+
headers: reqHeaders,
|
|
35
|
+
body,
|
|
36
|
+
},
|
|
37
|
+
response: {
|
|
38
|
+
statusCode: res.status,
|
|
39
|
+
headers: responseHeaders,
|
|
40
|
+
bodySnippet: responseBody.slice(0, 500),
|
|
41
|
+
responseTime,
|
|
42
|
+
},
|
|
43
|
+
rawHeaders: res.headers,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Simple concurrency limiter
|
|
48
|
+
*/
|
|
49
|
+
export class Semaphore {
|
|
50
|
+
max;
|
|
51
|
+
queue = [];
|
|
52
|
+
active = 0;
|
|
53
|
+
constructor(max) {
|
|
54
|
+
this.max = max;
|
|
55
|
+
}
|
|
56
|
+
async acquire() {
|
|
57
|
+
if (this.active < this.max) {
|
|
58
|
+
this.active++;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
return new Promise(resolve => {
|
|
62
|
+
this.queue.push(() => {
|
|
63
|
+
this.active++;
|
|
64
|
+
resolve();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
release() {
|
|
69
|
+
this.active--;
|
|
70
|
+
const next = this.queue.shift();
|
|
71
|
+
if (next)
|
|
72
|
+
next();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Simple rate limiter (token bucket)
|
|
77
|
+
*/
|
|
78
|
+
export class RateLimiter {
|
|
79
|
+
lastTime = 0;
|
|
80
|
+
minInterval;
|
|
81
|
+
constructor(maxPerSecond) {
|
|
82
|
+
this.minInterval = 1000 / maxPerSecond;
|
|
83
|
+
}
|
|
84
|
+
async wait() {
|
|
85
|
+
const now = Date.now();
|
|
86
|
+
const elapsed = now - this.lastTime;
|
|
87
|
+
if (elapsed < this.minInterval) {
|
|
88
|
+
await new Promise(r => setTimeout(r, this.minInterval - elapsed));
|
|
89
|
+
}
|
|
90
|
+
this.lastTime = Date.now();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verbosity-aware logger
|
|
3
|
+
*/
|
|
4
|
+
export declare function setVerbose(v: boolean): void;
|
|
5
|
+
export declare function info(msg: string): void;
|
|
6
|
+
export declare function verbose(msg: string): void;
|
|
7
|
+
export declare function warn(msg: string): void;
|
|
8
|
+
export declare function error(msg: string): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verbosity-aware logger
|
|
3
|
+
*/
|
|
4
|
+
let verboseMode = false;
|
|
5
|
+
export function setVerbose(v) {
|
|
6
|
+
verboseMode = v;
|
|
7
|
+
}
|
|
8
|
+
export function info(msg) {
|
|
9
|
+
console.log(msg);
|
|
10
|
+
}
|
|
11
|
+
export function verbose(msg) {
|
|
12
|
+
if (verboseMode)
|
|
13
|
+
console.log(msg);
|
|
14
|
+
}
|
|
15
|
+
export function warn(msg) {
|
|
16
|
+
console.error(`[!] ${msg}`);
|
|
17
|
+
}
|
|
18
|
+
export function error(msg) {
|
|
19
|
+
console.error(`[ERROR] ${msg}`);
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket security checks
|
|
3
|
+
* Built-in protocol tests for common WS vulnerabilities
|
|
4
|
+
*/
|
|
5
|
+
import type { WsTestResult } from '../types.js';
|
|
6
|
+
export interface WsCheckInfo {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
}
|
|
11
|
+
type WsCheck = {
|
|
12
|
+
info: WsCheckInfo;
|
|
13
|
+
run: (url: string, timeout: number) => Promise<WsTestResult>;
|
|
14
|
+
};
|
|
15
|
+
export declare function getAllWsChecks(): WsCheck[];
|
|
16
|
+
export declare function getWsChecksByIds(ids: string[]): WsCheck[];
|
|
17
|
+
export declare function listWsChecks(): WsCheckInfo[];
|
|
18
|
+
export {};
|