wide-cli 0.0.0-stage → 0.3.101126

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 (172) hide show
  1. package/.github/workflows/ci.yml +29 -0
  2. package/LICENSE +674 -0
  3. package/README.md +80 -2
  4. package/assets/logo.png +0 -0
  5. package/assets/wide-logo.png +0 -0
  6. package/bin/wide.js +17 -0
  7. package/dist/agent/context.d.ts +7 -0
  8. package/dist/agent/context.d.ts.map +1 -0
  9. package/dist/agent/context.js +38 -0
  10. package/dist/agent/context.js.map +1 -0
  11. package/dist/agent/index.d.ts +16 -0
  12. package/dist/agent/index.d.ts.map +1 -0
  13. package/dist/agent/index.js +138 -0
  14. package/dist/agent/index.js.map +1 -0
  15. package/dist/config/index.d.ts +29 -0
  16. package/dist/config/index.d.ts.map +1 -0
  17. package/dist/config/index.js +66 -0
  18. package/dist/config/index.js.map +1 -0
  19. package/dist/config/workspace.d.ts +7 -0
  20. package/dist/config/workspace.d.ts.map +1 -0
  21. package/dist/config/workspace.js +31 -0
  22. package/dist/config/workspace.js.map +1 -0
  23. package/dist/decision/index.d.ts +113 -0
  24. package/dist/decision/index.d.ts.map +1 -0
  25. package/dist/decision/index.js +485 -0
  26. package/dist/decision/index.js.map +1 -0
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +167 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/providers/claude.d.ts +10 -0
  32. package/dist/providers/claude.d.ts.map +1 -0
  33. package/dist/providers/claude.js +147 -0
  34. package/dist/providers/claude.js.map +1 -0
  35. package/dist/providers/gemini.d.ts +10 -0
  36. package/dist/providers/gemini.d.ts.map +1 -0
  37. package/dist/providers/gemini.js +129 -0
  38. package/dist/providers/gemini.js.map +1 -0
  39. package/dist/providers/index.d.ts +4 -0
  40. package/dist/providers/index.d.ts.map +1 -0
  41. package/dist/providers/index.js +44 -0
  42. package/dist/providers/index.js.map +1 -0
  43. package/dist/providers/ollama.d.ts +10 -0
  44. package/dist/providers/ollama.d.ts.map +1 -0
  45. package/dist/providers/ollama.js +94 -0
  46. package/dist/providers/ollama.js.map +1 -0
  47. package/dist/providers/openai.d.ts +11 -0
  48. package/dist/providers/openai.d.ts.map +1 -0
  49. package/dist/providers/openai.js +142 -0
  50. package/dist/providers/openai.js.map +1 -0
  51. package/dist/providers/types.d.ts +22 -0
  52. package/dist/providers/types.d.ts.map +1 -0
  53. package/dist/providers/types.js +2 -0
  54. package/dist/providers/types.js.map +1 -0
  55. package/dist/repl/index.d.ts +2 -0
  56. package/dist/repl/index.d.ts.map +1 -0
  57. package/dist/repl/index.js +94 -0
  58. package/dist/repl/index.js.map +1 -0
  59. package/dist/security/fuzzer.d.ts +20 -0
  60. package/dist/security/fuzzer.d.ts.map +1 -0
  61. package/dist/security/fuzzer.js +109 -0
  62. package/dist/security/fuzzer.js.map +1 -0
  63. package/dist/security/loader.d.ts +17 -0
  64. package/dist/security/loader.d.ts.map +1 -0
  65. package/dist/security/loader.js +126 -0
  66. package/dist/security/loader.js.map +1 -0
  67. package/dist/security/payloads.d.ts +9 -0
  68. package/dist/security/payloads.d.ts.map +1 -0
  69. package/dist/security/payloads.js +88 -0
  70. package/dist/security/payloads.js.map +1 -0
  71. package/dist/security/rules.d.ts +14 -0
  72. package/dist/security/rules.d.ts.map +1 -0
  73. package/dist/security/rules.js +288 -0
  74. package/dist/security/rules.js.map +1 -0
  75. package/dist/security/scanner.d.ts +29 -0
  76. package/dist/security/scanner.d.ts.map +1 -0
  77. package/dist/security/scanner.js +136 -0
  78. package/dist/security/scanner.js.map +1 -0
  79. package/dist/tools/browser.d.ts +47 -0
  80. package/dist/tools/browser.d.ts.map +1 -0
  81. package/dist/tools/browser.js +441 -0
  82. package/dist/tools/browser.js.map +1 -0
  83. package/dist/tools/fs.d.ts +5 -0
  84. package/dist/tools/fs.d.ts.map +1 -0
  85. package/dist/tools/fs.js +131 -0
  86. package/dist/tools/fs.js.map +1 -0
  87. package/dist/tools/git.d.ts +3 -0
  88. package/dist/tools/git.d.ts.map +1 -0
  89. package/dist/tools/git.js +50 -0
  90. package/dist/tools/git.js.map +1 -0
  91. package/dist/tools/http.d.ts +3 -0
  92. package/dist/tools/http.d.ts.map +1 -0
  93. package/dist/tools/http.js +69 -0
  94. package/dist/tools/http.js.map +1 -0
  95. package/dist/tools/index.d.ts +5 -0
  96. package/dist/tools/index.d.ts.map +1 -0
  97. package/dist/tools/index.js +50 -0
  98. package/dist/tools/index.js.map +1 -0
  99. package/dist/tools/search.d.ts +4 -0
  100. package/dist/tools/search.d.ts.map +1 -0
  101. package/dist/tools/search.js +109 -0
  102. package/dist/tools/search.js.map +1 -0
  103. package/dist/tools/security.d.ts +5 -0
  104. package/dist/tools/security.d.ts.map +1 -0
  105. package/dist/tools/security.js +129 -0
  106. package/dist/tools/security.js.map +1 -0
  107. package/dist/tools/shell.d.ts +3 -0
  108. package/dist/tools/shell.d.ts.map +1 -0
  109. package/dist/tools/shell.js +50 -0
  110. package/dist/tools/shell.js.map +1 -0
  111. package/dist/tools/types.d.ts +33 -0
  112. package/dist/tools/types.d.ts.map +1 -0
  113. package/dist/tools/types.js +2 -0
  114. package/dist/tools/types.js.map +1 -0
  115. package/dist/ui/banner.d.ts +2 -0
  116. package/dist/ui/banner.d.ts.map +1 -0
  117. package/dist/ui/banner.js +14 -0
  118. package/dist/ui/banner.js.map +1 -0
  119. package/dist/ui/colors.d.ts +18 -0
  120. package/dist/ui/colors.d.ts.map +1 -0
  121. package/dist/ui/colors.js +19 -0
  122. package/dist/ui/colors.js.map +1 -0
  123. package/dist/ui/diff.d.ts +2 -0
  124. package/dist/ui/diff.d.ts.map +1 -0
  125. package/dist/ui/diff.js +26 -0
  126. package/dist/ui/diff.js.map +1 -0
  127. package/dist/ui/markdown.d.ts +2 -0
  128. package/dist/ui/markdown.d.ts.map +1 -0
  129. package/dist/ui/markdown.js +32 -0
  130. package/dist/ui/markdown.js.map +1 -0
  131. package/dist/ui/spinner.d.ts +12 -0
  132. package/dist/ui/spinner.d.ts.map +1 -0
  133. package/dist/ui/spinner.js +46 -0
  134. package/dist/ui/spinner.js.map +1 -0
  135. package/package.json +50 -4
  136. package/src/agent/context.ts +44 -0
  137. package/src/agent/index.ts +166 -0
  138. package/src/config/index.ts +88 -0
  139. package/src/config/workspace.ts +39 -0
  140. package/src/decision/index.ts +528 -0
  141. package/src/index.ts +180 -0
  142. package/src/providers/claude.ts +163 -0
  143. package/src/providers/gemini.ts +147 -0
  144. package/src/providers/index.ts +52 -0
  145. package/src/providers/ollama.ts +108 -0
  146. package/src/providers/openai.ts +159 -0
  147. package/src/providers/types.ts +29 -0
  148. package/src/repl/index.ts +100 -0
  149. package/src/security/fuzzer.ts +140 -0
  150. package/src/security/loader.ts +129 -0
  151. package/src/security/payloads.ts +95 -0
  152. package/src/security/rules.ts +300 -0
  153. package/src/security/scanner.ts +180 -0
  154. package/src/tools/browser.ts +528 -0
  155. package/src/tools/fs.ts +143 -0
  156. package/src/tools/git.ts +51 -0
  157. package/src/tools/http.ts +77 -0
  158. package/src/tools/index.ts +64 -0
  159. package/src/tools/search.ts +109 -0
  160. package/src/tools/security.ts +140 -0
  161. package/src/tools/shell.ts +56 -0
  162. package/src/tools/types.ts +33 -0
  163. package/src/ui/banner.ts +17 -0
  164. package/src/ui/colors.ts +19 -0
  165. package/src/ui/diff.ts +24 -0
  166. package/src/ui/markdown.ts +34 -0
  167. package/src/ui/spinner.ts +53 -0
  168. package/tests/browser.test.mjs +71 -0
  169. package/tests/decision.test.mjs +68 -0
  170. package/tests/loader.test.mjs +24 -0
  171. package/tests/suite.test.mjs +61 -0
  172. package/tsconfig.json +20 -0
@@ -0,0 +1,100 @@
1
+ import { createInterface } from "node:readline/promises";
2
+ import pc from "picocolors";
3
+ import { Agent } from "../agent/index.js";
4
+ import { configManager } from "../config/index.js";
5
+ import { createProvider } from "../providers/index.js";
6
+ import { executeTool } from "../tools/index.js";
7
+ import { printBanner } from "../ui/banner.js";
8
+
9
+ export async function startRepl(): Promise<void> {
10
+ printBanner();
11
+
12
+ const cfg = configManager.get();
13
+ console.log(` ${pc.gray("Model:")} ${pc.cyan(`${cfg.provider}/${cfg.model}`)} - ${pc.gray("Workspace:")} ${pc.dim(process.cwd())}\n`);
14
+
15
+ let agent: Agent;
16
+ try {
17
+ agent = new Agent(process.cwd());
18
+ } catch (err: any) {
19
+ console.log(`${pc.yellow("[WARN]")} ${err.message}`);
20
+ console.log(`${pc.dim("Configure an API key using 'wide config set-key gemini <KEY>' or run Ollama locally.\n")}`);
21
+ return;
22
+ }
23
+
24
+ const rl = createInterface({
25
+ input: process.stdin,
26
+ output: process.stdout,
27
+ });
28
+
29
+ const promptUser = async () => {
30
+ while (true) {
31
+ try {
32
+ const input = await rl.question(`${pc.cyan("wide")} ${pc.dim(">")} `);
33
+ const trimmed = input.trim();
34
+
35
+ if (!trimmed) continue;
36
+
37
+ if (trimmed === "exit" || trimmed === "quit" || trimmed === "/exit") {
38
+ console.log(pc.dim("Goodbye!"));
39
+ rl.close();
40
+ process.exit(0);
41
+ }
42
+
43
+ if (trimmed === "/clear") {
44
+ console.clear();
45
+ printBanner();
46
+ agent.clearHistory();
47
+ console.log(pc.green("[OK] Session history cleared.\n"));
48
+ continue;
49
+ }
50
+
51
+ if (trimmed === "/help") {
52
+ console.log(`\n${pc.bold("Available Slash Commands:")}`);
53
+ console.log(` ${pc.cyan("/help")} Show this help menu`);
54
+ console.log(` ${pc.cyan("/scan")} Run instant Wide SAST security scan in workspace`);
55
+ console.log(` ${pc.cyan("/model")} Show or change current LLM provider and model`);
56
+ console.log(` ${pc.cyan("/clear")} Clear chat context and screen`);
57
+ console.log(` ${pc.cyan("exit")} Exit Wide CLI\n`);
58
+ continue;
59
+ }
60
+
61
+ if (trimmed === "/scan") {
62
+ const res = await executeTool("run_security_scan", { path: "." }, { workingDirectory: process.cwd() });
63
+ console.log(res.output);
64
+ continue;
65
+ }
66
+
67
+ if (trimmed.startsWith("/model")) {
68
+ const parts = trimmed.split(" ").filter(Boolean);
69
+ if (parts.length === 1) {
70
+ const current = configManager.get();
71
+ console.log(`Current model: ${pc.cyan(current.provider)} / ${pc.bold(current.model)}\n`);
72
+ } else if (parts.length >= 3) {
73
+ const newProv = parts[1] as any;
74
+ const newMod = parts[2];
75
+ configManager.set("provider", newProv);
76
+ configManager.set("model", newMod);
77
+ agent.setProvider(createProvider(newProv, newMod));
78
+ console.log(pc.green(`[OK] Model switched to ${newProv}/${newMod}\n`));
79
+ } else {
80
+ console.log(`Usage: ${pc.cyan("/model <provider> <model_name>")}`);
81
+ console.log(`Example: ${pc.dim("/model ollama deepseek-r1:7b")} or ${pc.dim("/model gemini gemini-2.5-flash")}\n`);
82
+ }
83
+ continue;
84
+ }
85
+
86
+ console.log("");
87
+ try {
88
+ await agent.runPrompt(trimmed);
89
+ console.log("");
90
+ } catch (err: any) {
91
+ console.log(`\n${pc.red("Error:")} ${err.message}\n`);
92
+ }
93
+ } catch (err) {
94
+ break;
95
+ }
96
+ }
97
+ };
98
+
99
+ await promptUser();
100
+ }
@@ -0,0 +1,140 @@
1
+ import { getPayloadsForType } from "./payloads.js";
2
+
3
+ export interface FuzzFinding {
4
+ payload: string;
5
+ statusCode: number;
6
+ reflectionFound: boolean;
7
+ sqlErrorDetected: boolean;
8
+ lengthDiff: number;
9
+ indicator: string;
10
+ }
11
+
12
+ export interface FuzzReport {
13
+ url: string;
14
+ param: string;
15
+ payloadType: string;
16
+ baselineStatus: number;
17
+ baselineLength: number;
18
+ findings: FuzzFinding[];
19
+ isVulnerable: boolean;
20
+ summary: string;
21
+ }
22
+
23
+ const SQL_ERROR_PATTERNS = [
24
+ /you have an error in your sql syntax/i,
25
+ /warning: mysql/i,
26
+ /unclosed quotation mark after the character string/i,
27
+ /quoted string not properly terminated/i,
28
+ /postgresql.*?error/i,
29
+ /sqlite3::SQLException/i,
30
+ /syntax error in query expression/i,
31
+ /microsoft ole db provider for sql server/i
32
+ ];
33
+
34
+ export async function fuzzTargetEndpoint(
35
+ url: string,
36
+ param: string,
37
+ payloadType: string,
38
+ method = "GET"
39
+ ): Promise<FuzzReport> {
40
+ const payloads = getPayloadsForType(payloadType);
41
+ if (payloads.length === 0) {
42
+ throw new Error(`Unsupported payload type: '${payloadType}'. Available: sqli, xss, ssrf, traversal, cmd, ssti.`);
43
+ }
44
+
45
+ const baselineUrl = new URL(url);
46
+ if (method === "GET") {
47
+ baselineUrl.searchParams.set(param, "testbaselinevalue123");
48
+ }
49
+
50
+ let baselineStatus = 200;
51
+ let baselineBody = "";
52
+ try {
53
+ const baseRes = await fetch(baselineUrl.toString(), {
54
+ method,
55
+ headers: { "User-Agent": "Wide-Security-Agent/1.0" }
56
+ });
57
+ baselineStatus = baseRes.status;
58
+ baselineBody = await baseRes.text();
59
+ } catch (err: any) {
60
+ throw new Error(`Baseline probe failed for ${url}: ${err.message}`);
61
+ }
62
+
63
+ const findings: FuzzFinding[] = [];
64
+
65
+ for (const payload of payloads) {
66
+ const targetUrl = new URL(url);
67
+ const fetchOptions: RequestInit = {
68
+ method,
69
+ headers: { "User-Agent": "Wide-Security-Agent/1.0" }
70
+ };
71
+
72
+ if (method === "GET") {
73
+ targetUrl.searchParams.set(param, payload);
74
+ } else {
75
+ fetchOptions.headers = {
76
+ ...fetchOptions.headers,
77
+ "Content-Type": "application/x-www-form-urlencoded"
78
+ };
79
+ const bodyParams = new URLSearchParams();
80
+ bodyParams.set(param, payload);
81
+ fetchOptions.body = bodyParams.toString();
82
+ }
83
+
84
+ try {
85
+ const res = await fetch(targetUrl.toString(), fetchOptions);
86
+ const text = await res.text();
87
+ const lengthDiff = Math.abs(text.length - baselineBody.length);
88
+ const reflectionFound = text.includes(payload);
89
+
90
+ let sqlErrorDetected = false;
91
+ if (payloadType === "sqli") {
92
+ for (const pattern of SQL_ERROR_PATTERNS) {
93
+ if (pattern.test(text) && !pattern.test(baselineBody)) {
94
+ sqlErrorDetected = true;
95
+ break;
96
+ }
97
+ }
98
+ }
99
+
100
+ let indicator = "Normal Response";
101
+ if (sqlErrorDetected) {
102
+ indicator = "SQL Syntax Error Triggered";
103
+ } else if (reflectionFound && payloadType === "xss") {
104
+ indicator = "Raw Unencoded Reflection Detected";
105
+ } else if (res.status === 500 && baselineStatus === 200) {
106
+ indicator = "Server Internal Error (HTTP 500)";
107
+ } else if (lengthDiff > 500) {
108
+ indicator = `Significant Response Size Anomaly (${lengthDiff} bytes diff)`;
109
+ }
110
+
111
+ if (sqlErrorDetected || (reflectionFound && payloadType === "xss") || (res.status === 500 && baselineStatus === 200)) {
112
+ findings.push({
113
+ payload,
114
+ statusCode: res.status,
115
+ reflectionFound,
116
+ sqlErrorDetected,
117
+ lengthDiff,
118
+ indicator
119
+ });
120
+ }
121
+ } catch {
122
+ }
123
+ }
124
+
125
+ const isVulnerable = findings.length > 0;
126
+ const summary = isVulnerable
127
+ ? `Endpoint ${url} parameter '${param}' appears VULNERABLE to ${payloadType.toUpperCase()}. ${findings.length} anomalies confirmed.`
128
+ : `Endpoint ${url} parameter '${param}' tested with ${payloads.length} ${payloadType.toUpperCase()} payloads. No high-confidence anomalies triggered.`;
129
+
130
+ return {
131
+ url,
132
+ param,
133
+ payloadType,
134
+ baselineStatus,
135
+ baselineLength: baselineBody.length,
136
+ findings,
137
+ isVulnerable,
138
+ summary
139
+ };
140
+ }
@@ -0,0 +1,129 @@
1
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
2
+ import { resolve, join } from "node:path";
3
+ import { homedir } from "node:os";
4
+ import { SECURITY_RULES, DEFAULT_AGENT_RULES, SecurityRule } from "./rules.js";
5
+
6
+ const DEFAULT_CACHE_DIR = join(homedir(), ".wide", "rules");
7
+ const DEFAULT_CACHE_FILE = join(DEFAULT_CACHE_DIR, "rules.json");
8
+ const REMOTE_RULES_URL = "https://raw.githubusercontent.com/sl4de0day/wide-rules/main/dist/rules.json";
9
+
10
+ export class RuleLoader {
11
+ public static getCachePath(): string {
12
+ return DEFAULT_CACHE_FILE;
13
+ }
14
+
15
+ public static getAgentRulesPath(workspaceDir = process.cwd()): { active: string; workspace: string | null; cache: string } {
16
+ const wsAgentPath = resolve(workspaceDir, ".wide", "agent-rules.json");
17
+ if (existsSync(wsAgentPath)) {
18
+ return { active: wsAgentPath, workspace: wsAgentPath, cache: DEFAULT_CACHE_FILE };
19
+ }
20
+ const wsRulesPath = resolve(workspaceDir, ".wide", "rules.json");
21
+ if (existsSync(wsRulesPath)) {
22
+ return { active: wsRulesPath, workspace: wsRulesPath, cache: DEFAULT_CACHE_FILE };
23
+ }
24
+ if (existsSync(DEFAULT_CACHE_FILE)) {
25
+ return { active: DEFAULT_CACHE_FILE, workspace: null, cache: DEFAULT_CACHE_FILE };
26
+ }
27
+ return { active: "embedded", workspace: null, cache: DEFAULT_CACHE_FILE };
28
+ }
29
+
30
+ public static loadRules(customPath?: string, workspaceDir = process.cwd()): SecurityRule[] {
31
+ if (customPath) {
32
+ const resolvedCustom = resolve(workspaceDir, customPath);
33
+ if (existsSync(resolvedCustom)) {
34
+ const customRules = this.parseRulesFile(resolvedCustom);
35
+ if (customRules.length > 0) return customRules;
36
+ }
37
+ }
38
+
39
+ const workspaceRulesPath = resolve(workspaceDir, ".wide", "rules.json");
40
+ if (existsSync(workspaceRulesPath)) {
41
+ const wsRules = this.parseRulesFile(workspaceRulesPath);
42
+ if (wsRules.length > 0) return wsRules;
43
+ }
44
+
45
+ if (existsSync(DEFAULT_CACHE_FILE)) {
46
+ const cached = this.parseRulesFile(DEFAULT_CACHE_FILE);
47
+ if (cached.length > 0) return cached;
48
+ }
49
+
50
+ return [...SECURITY_RULES];
51
+ }
52
+
53
+ public static loadAgentRules(customPath?: string, workspaceDir = process.cwd()): SecurityRule[] {
54
+ if (customPath) {
55
+ const resolvedCustom = resolve(workspaceDir, customPath);
56
+ if (existsSync(resolvedCustom)) {
57
+ const customRules = this.parseRulesFile(resolvedCustom);
58
+ const filtered = customRules.filter(r => r.category === "AI_SECURITY" || r.id.includes("ai-"));
59
+ if (filtered.length > 0) return filtered;
60
+ if (customRules.length > 0) return customRules;
61
+ }
62
+ }
63
+
64
+ const workspaceAgentRulesPath = resolve(workspaceDir, ".wide", "agent-rules.json");
65
+ if (existsSync(workspaceAgentRulesPath)) {
66
+ const wsAgentRules = this.parseRulesFile(workspaceAgentRulesPath);
67
+ if (wsAgentRules.length > 0) return wsAgentRules;
68
+ }
69
+
70
+ const workspaceRulesPath = resolve(workspaceDir, ".wide", "rules.json");
71
+ if (existsSync(workspaceRulesPath)) {
72
+ const wsRules = this.parseRulesFile(workspaceRulesPath);
73
+ const filtered = wsRules.filter(r => r.category === "AI_SECURITY" || r.id.includes("ai-"));
74
+ if (filtered.length > 0) return filtered;
75
+ }
76
+
77
+ if (existsSync(DEFAULT_CACHE_FILE)) {
78
+ const cached = this.parseRulesFile(DEFAULT_CACHE_FILE);
79
+ const filtered = cached.filter(r => r.category === "AI_SECURITY" || r.id.includes("ai-"));
80
+ if (filtered.length > 0) return filtered;
81
+ }
82
+
83
+ return [...DEFAULT_AGENT_RULES];
84
+ }
85
+
86
+ public static async updateRules(): Promise<{ count: number; path: string }> {
87
+ mkdirSync(DEFAULT_CACHE_DIR, { recursive: true });
88
+ const response = await fetch(REMOTE_RULES_URL);
89
+ if (!response.ok) {
90
+ throw new Error(`Failed to download rules (${response.status}): ${response.statusText}`);
91
+ }
92
+ const data = await response.json() as any;
93
+ const rulesList = Array.isArray(data) ? data : (data?.rules || []);
94
+ writeFileSync(DEFAULT_CACHE_FILE, JSON.stringify(data, null, 2), "utf8");
95
+ return { count: rulesList.length, path: DEFAULT_CACHE_FILE };
96
+ }
97
+
98
+ private static parseRulesFile(filePath: string): SecurityRule[] {
99
+ try {
100
+ const raw = readFileSync(filePath, "utf8");
101
+ const parsed = JSON.parse(raw);
102
+ const list = Array.isArray(parsed) ? parsed : (parsed?.rules || []);
103
+ const result: SecurityRule[] = [];
104
+
105
+ for (const item of list) {
106
+ if (!item.id || !item.pattern) continue;
107
+ try {
108
+ const rule: SecurityRule = {
109
+ id: item.id,
110
+ cwe: item.cwe || "N/A",
111
+ category: item.category || "General Security",
112
+ severity: item.severity || "MEDIUM",
113
+ languages: item.languages || ["all"],
114
+ pattern: new RegExp(item.pattern, "i"),
115
+ sourcePattern: item["source-pattern"] ? new RegExp(item["source-pattern"], "i") : undefined,
116
+ message: item.message || "",
117
+ remediation: item.remediation || ""
118
+ };
119
+ result.push(rule);
120
+ } catch {
121
+ continue;
122
+ }
123
+ }
124
+ return result;
125
+ } catch {
126
+ return [];
127
+ }
128
+ }
129
+ }
@@ -0,0 +1,95 @@
1
+ export interface PayloadCategory {
2
+ type: string;
3
+ description: string;
4
+ payloads: string[];
5
+ }
6
+
7
+ export const SECURITY_PAYLOADS: Record<string, PayloadCategory> = {
8
+ sqli: {
9
+ type: "sqli",
10
+ description: "SQL injection detection and blind boolean probes",
11
+ payloads: [
12
+ "' OR '1'='1",
13
+ "' OR 1=1 --",
14
+ "admin' --",
15
+ "' UNION SELECT NULL, NULL, NULL --",
16
+ "1' AND SLEEP(5) --",
17
+ "1' AND (SELECT 1 FROM (SELECT(SLEEP(5)))a) --",
18
+ "1 AND 1=1",
19
+ "1 AND 1=2"
20
+ ]
21
+ },
22
+ xss: {
23
+ type: "xss",
24
+ description: "Cross-site scripting reflection and polyglot vectors",
25
+ payloads: [
26
+ "<script>alert(1)</script>",
27
+ "<img src=x onerror=alert(1)>",
28
+ "\" onfocus=alert(1) autofocus=\"",
29
+ "'><svg/onload=alert(1)>",
30
+ "javascript:alert(1)",
31
+ "<iframe src=\"javascript:alert(1)\">",
32
+ "{{constructor.constructor('alert(1)')()}}"
33
+ ]
34
+ },
35
+ ssrf: {
36
+ type: "ssrf",
37
+ description: "Server-side request forgery probe targets and metadata URLs",
38
+ payloads: [
39
+ "http://127.0.0.1:80",
40
+ "http://localhost:8080",
41
+ "http://169.254.169.254/latest/meta-data/",
42
+ "http://metadata.google.internal/computeMetadata/v1/",
43
+ "http://[::1]:80/",
44
+ "http://127.127.127.127",
45
+ "http://0.0.0.0/"
46
+ ]
47
+ },
48
+ traversal: {
49
+ type: "traversal",
50
+ description: "Directory traversal and arbitrary file retrieval vectors",
51
+ payloads: [
52
+ "../../../../etc/passwd",
53
+ "..\\..\\..\\..\\windows\\win.ini",
54
+ "....//....//....//etc/passwd",
55
+ "%2e%2e%2f%2e%2e%2f%2e%2e%2fetc%2fpasswd",
56
+ "/etc/passwd%00.png",
57
+ "file:///etc/passwd"
58
+ ]
59
+ },
60
+ cmd: {
61
+ type: "cmd",
62
+ description: "Command injection separators and exfiltration primitives",
63
+ payloads: [
64
+ "; id",
65
+ "| id",
66
+ "&& whoami",
67
+ "`id`",
68
+ "$(whoami)",
69
+ "; ping -c 1 127.0.0.1",
70
+ "& dir"
71
+ ]
72
+ },
73
+ ssti: {
74
+ type: "ssti",
75
+ description: "Server-side template injection arithmetic reflection probes",
76
+ payloads: [
77
+ "{{7*7}}",
78
+ "${7*7}",
79
+ "<%= 7*7 %>",
80
+ "#{7*7}",
81
+ "*{7*7}",
82
+ "{{config.items()}}"
83
+ ]
84
+ }
85
+ };
86
+
87
+ export function getPayloadsForType(type: string): string[] {
88
+ const norm = type.toLowerCase().trim();
89
+ const cat = SECURITY_PAYLOADS[norm];
90
+ return cat ? cat.payloads : [];
91
+ }
92
+
93
+ export function getAllPayloadTypes(): string[] {
94
+ return Object.keys(SECURITY_PAYLOADS);
95
+ }