cipher-security 5.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 (75) hide show
  1. package/bin/cipher.js +465 -0
  2. package/lib/api/billing.js +321 -0
  3. package/lib/api/compliance.js +693 -0
  4. package/lib/api/controls.js +1401 -0
  5. package/lib/api/index.js +49 -0
  6. package/lib/api/marketplace.js +467 -0
  7. package/lib/api/openai-proxy.js +383 -0
  8. package/lib/api/server.js +685 -0
  9. package/lib/autonomous/feedback-loop.js +554 -0
  10. package/lib/autonomous/framework.js +512 -0
  11. package/lib/autonomous/index.js +97 -0
  12. package/lib/autonomous/leaderboard.js +594 -0
  13. package/lib/autonomous/modes/architect.js +412 -0
  14. package/lib/autonomous/modes/blue.js +386 -0
  15. package/lib/autonomous/modes/incident.js +684 -0
  16. package/lib/autonomous/modes/privacy.js +369 -0
  17. package/lib/autonomous/modes/purple.js +294 -0
  18. package/lib/autonomous/modes/recon.js +250 -0
  19. package/lib/autonomous/parallel.js +587 -0
  20. package/lib/autonomous/researcher.js +583 -0
  21. package/lib/autonomous/runner.js +955 -0
  22. package/lib/autonomous/scheduler.js +615 -0
  23. package/lib/autonomous/task-parser.js +127 -0
  24. package/lib/autonomous/validators/forensic.js +266 -0
  25. package/lib/autonomous/validators/osint.js +216 -0
  26. package/lib/autonomous/validators/privacy.js +296 -0
  27. package/lib/autonomous/validators/purple.js +298 -0
  28. package/lib/autonomous/validators/sigma.js +248 -0
  29. package/lib/autonomous/validators/threat-model.js +363 -0
  30. package/lib/benchmark/agent.js +119 -0
  31. package/lib/benchmark/baselines.js +43 -0
  32. package/lib/benchmark/builder.js +143 -0
  33. package/lib/benchmark/config.js +35 -0
  34. package/lib/benchmark/coordinator.js +91 -0
  35. package/lib/benchmark/index.js +20 -0
  36. package/lib/benchmark/llm.js +58 -0
  37. package/lib/benchmark/models.js +137 -0
  38. package/lib/benchmark/reporter.js +103 -0
  39. package/lib/benchmark/runner.js +103 -0
  40. package/lib/benchmark/sandbox.js +96 -0
  41. package/lib/benchmark/scorer.js +32 -0
  42. package/lib/benchmark/solver.js +166 -0
  43. package/lib/benchmark/tools.js +62 -0
  44. package/lib/bot/bot.js +130 -0
  45. package/lib/commands.js +99 -0
  46. package/lib/complexity.js +377 -0
  47. package/lib/config.js +213 -0
  48. package/lib/gateway/client.js +309 -0
  49. package/lib/gateway/commands.js +830 -0
  50. package/lib/gateway/config-validate.js +109 -0
  51. package/lib/gateway/gateway.js +367 -0
  52. package/lib/gateway/index.js +62 -0
  53. package/lib/gateway/mode.js +309 -0
  54. package/lib/gateway/plugins.js +222 -0
  55. package/lib/gateway/prompt.js +214 -0
  56. package/lib/mcp/server.js +262 -0
  57. package/lib/memory/compressor.js +425 -0
  58. package/lib/memory/engine.js +763 -0
  59. package/lib/memory/evolution.js +668 -0
  60. package/lib/memory/index.js +58 -0
  61. package/lib/memory/orchestrator.js +506 -0
  62. package/lib/memory/retriever.js +515 -0
  63. package/lib/memory/synthesizer.js +333 -0
  64. package/lib/pipeline/async-scanner.js +510 -0
  65. package/lib/pipeline/binary-analysis.js +1043 -0
  66. package/lib/pipeline/dom-xss-scanner.js +435 -0
  67. package/lib/pipeline/github-actions.js +792 -0
  68. package/lib/pipeline/index.js +124 -0
  69. package/lib/pipeline/osint.js +498 -0
  70. package/lib/pipeline/sarif.js +373 -0
  71. package/lib/pipeline/scanner.js +880 -0
  72. package/lib/pipeline/template-manager.js +525 -0
  73. package/lib/pipeline/xss-scanner.js +353 -0
  74. package/lib/setup-wizard.js +229 -0
  75. package/package.json +30 -0
@@ -0,0 +1,250 @@
1
+ // Copyright (c) 2026 defconxt. All rights reserved.
2
+ // Licensed under AGPL-3.0 — see LICENSE file for details.
3
+ // CIPHER is a trademark of defconxt.
4
+
5
+ /**
6
+ * RECON mode agent — OSINT Reconnaissance.
7
+ *
8
+ * Performs autonomous OSINT reconnaissance against a target domain.
9
+ * Ported from autonomous/modes/recon.py.
10
+ *
11
+ * @module autonomous/modes/recon
12
+ */
13
+
14
+ import { ModeAgentConfig, ToolRegistry } from '../framework.js';
15
+ import { OSINTValidator } from '../validators/osint.js';
16
+ import { DomainIntelligence } from '../../pipeline/osint.js';
17
+
18
+ // ---------------------------------------------------------------------------
19
+ // Tool handlers
20
+ // ---------------------------------------------------------------------------
21
+
22
+ /**
23
+ * Resolve DNS records for a target domain.
24
+ * @param {*} context
25
+ * @param {Object} toolInput
26
+ * @returns {string}
27
+ */
28
+ export function _reconDnsLookup(context, toolInput) {
29
+ const domain = toolInput.domain || '';
30
+ if (!domain) {
31
+ return "ERROR: 'domain' parameter is required.";
32
+ }
33
+
34
+ const result = DomainIntelligence.dnsLookup(domain);
35
+ return JSON.stringify(result.toDict ? result.toDict() : result, null, 2);
36
+ }
37
+
38
+ /**
39
+ * Perform WHOIS lookup for a target domain.
40
+ * @param {*} context
41
+ * @param {Object} toolInput
42
+ * @returns {string}
43
+ */
44
+ export function _reconWhoisLookup(context, toolInput) {
45
+ const domain = toolInput.domain || '';
46
+ if (!domain) {
47
+ return "ERROR: 'domain' parameter is required.";
48
+ }
49
+
50
+ const result = DomainIntelligence.whoisLookup(domain);
51
+ return JSON.stringify(result.toDict ? result.toDict() : result, null, 2);
52
+ }
53
+
54
+ /**
55
+ * Store a structured JSON intelligence report in context.
56
+ * @param {*} context
57
+ * @param {Object} toolInput
58
+ * @returns {string}
59
+ */
60
+ export function _reconWriteIntelReport(context, toolInput) {
61
+ const report = toolInput.report || '';
62
+
63
+ if (typeof context !== 'object' || context === null) {
64
+ return 'ERROR: Context must be a dict.';
65
+ }
66
+
67
+ let reportData;
68
+ if (typeof report === 'string') {
69
+ try {
70
+ reportData = JSON.parse(report);
71
+ } catch {
72
+ reportData = report;
73
+ }
74
+ } else {
75
+ reportData = report;
76
+ }
77
+
78
+ context.report = reportData;
79
+ const filename = toolInput.filename || 'intel_report.json';
80
+
81
+ return (
82
+ `Intelligence report stored as ${filename}. ` +
83
+ `Report is available in context['report'].`
84
+ );
85
+ }
86
+
87
+ // ---------------------------------------------------------------------------
88
+ // Tool schemas (Anthropic format)
89
+ // ---------------------------------------------------------------------------
90
+
91
+ const _RECON_DNS_LOOKUP_SCHEMA = {
92
+ name: 'dns_lookup',
93
+ description:
94
+ 'Resolve DNS records for a target domain. Returns A, AAAA, MX, NS, TXT, ' +
95
+ 'CNAME, and SOA records as structured JSON.',
96
+ input_schema: {
97
+ type: 'object',
98
+ properties: {
99
+ domain: {
100
+ type: 'string',
101
+ description: 'Target domain to resolve (e.g. example.com)',
102
+ },
103
+ },
104
+ required: ['domain'],
105
+ },
106
+ };
107
+
108
+ const _RECON_WHOIS_LOOKUP_SCHEMA = {
109
+ name: 'whois_lookup',
110
+ description:
111
+ 'Perform WHOIS lookup for a target domain. Returns registration data ' +
112
+ 'including registrar, creation date, expiration date, name servers.',
113
+ input_schema: {
114
+ type: 'object',
115
+ properties: {
116
+ domain: {
117
+ type: 'string',
118
+ description: 'Target domain to query (e.g. example.com)',
119
+ },
120
+ },
121
+ required: ['domain'],
122
+ },
123
+ };
124
+
125
+ const _RECON_WRITE_INTEL_REPORT_SCHEMA = {
126
+ name: 'write_intel_report',
127
+ description:
128
+ 'Submit the completed OSINT intelligence report as JSON with required ' +
129
+ 'sections: summary, target, dns_records, whois_data, technologies, findings.',
130
+ input_schema: {
131
+ type: 'object',
132
+ properties: {
133
+ report: {
134
+ type: 'string',
135
+ description:
136
+ 'Full JSON intelligence report with summary, target, dns_records, ' +
137
+ 'whois_data, technologies, and findings sections.',
138
+ },
139
+ filename: {
140
+ type: 'string',
141
+ description: 'Filename for the report (e.g. example_com_intel.json)',
142
+ },
143
+ },
144
+ required: ['report'],
145
+ },
146
+ };
147
+
148
+ // ---------------------------------------------------------------------------
149
+ // System prompt template
150
+ // ---------------------------------------------------------------------------
151
+
152
+ const _RECON_SYSTEM_PROMPT = `\
153
+ You are an expert OSINT analyst and reconnaissance specialist. Your task is \
154
+ to perform passive reconnaissance on a target domain and produce a structured \
155
+ intelligence report.
156
+
157
+ ## Target
158
+ Domain: {target_domain}
159
+ Description: {target_description}
160
+
161
+ ## Instructions
162
+ 1. Use \`dns_lookup\` to resolve DNS records for the target domain.
163
+ 2. Use \`whois_lookup\` to retrieve domain registration data.
164
+ 3. Analyze collected data to identify technology indicators, infrastructure, \
165
+ security posture, and attack surface.
166
+ 4. Produce a structured JSON report using \`write_intel_report\`.
167
+
168
+ ## Rules
169
+ - Stay PASSIVE — no active scanning, port probing, or exploitation
170
+ - Document confidence levels for all findings
171
+ - Include raw evidence supporting each finding
172
+ - Flag any privacy-sensitive data encountered
173
+ `;
174
+
175
+ // ---------------------------------------------------------------------------
176
+ // Output parser (fallback for text-based output)
177
+ // ---------------------------------------------------------------------------
178
+
179
+ /**
180
+ * Extract JSON intelligence report from LLM text output.
181
+ * @param {string} text
182
+ * @returns {Object}
183
+ */
184
+ export function _reconOutputParser(text) {
185
+ if (!text || !text.trim()) {
186
+ return { raw_text: text, parse_error: 'empty output' };
187
+ }
188
+
189
+ // Try explicit json-tagged fences first
190
+ let matches = [...text.matchAll(/```json\s*\n(.*?)```/gs)].map(m => m[1]);
191
+ if (matches.length > 0) {
192
+ const jsonText = matches.join('\n');
193
+ try { return JSON.parse(jsonText); } catch (e) {
194
+ return { raw_text: text, parse_error: e.message };
195
+ }
196
+ }
197
+
198
+ // Fall back to bare fences
199
+ matches = [...text.matchAll(/```\s*\n(.*?)```/gs)].map(m => m[1]);
200
+ if (matches.length > 0) {
201
+ const jsonText = matches.join('\n');
202
+ try { return JSON.parse(jsonText); } catch (e) {
203
+ return { raw_text: text, parse_error: e.message };
204
+ }
205
+ }
206
+
207
+ // Try parsing entire text as JSON
208
+ try { return JSON.parse(text); } catch (e) {
209
+ return { raw_text: text, parse_error: e.message };
210
+ }
211
+ }
212
+
213
+ // ---------------------------------------------------------------------------
214
+ // Factory function
215
+ // ---------------------------------------------------------------------------
216
+
217
+ /**
218
+ * Build a RECON-mode ModeAgentConfig for OSINT reconnaissance.
219
+ * @returns {ModeAgentConfig}
220
+ */
221
+ function _makeReconConfig() {
222
+ const reg = new ToolRegistry();
223
+ reg.register('dns_lookup', _RECON_DNS_LOOKUP_SCHEMA, _reconDnsLookup);
224
+ reg.register('whois_lookup', _RECON_WHOIS_LOOKUP_SCHEMA, _reconWhoisLookup);
225
+ reg.register('write_intel_report', _RECON_WRITE_INTEL_REPORT_SCHEMA, _reconWriteIntelReport);
226
+
227
+ return new ModeAgentConfig({
228
+ mode: 'RECON',
229
+ toolRegistry: reg,
230
+ systemPromptTemplate: _RECON_SYSTEM_PROMPT,
231
+ validator: new OSINTValidator(),
232
+ maxTurns: 15,
233
+ requiresSandbox: false,
234
+ completionCheck: null,
235
+ outputParser: _reconOutputParser,
236
+ outputFormat: 'json',
237
+ });
238
+ }
239
+
240
+ // ---------------------------------------------------------------------------
241
+ // Registration function — called by runner.initModes()
242
+ // ---------------------------------------------------------------------------
243
+
244
+ /**
245
+ * Register RECON mode with the given registerMode function.
246
+ * @param {Function} registerMode
247
+ */
248
+ export function register(registerMode) {
249
+ registerMode('RECON', _makeReconConfig);
250
+ }