defense-mcp-server 0.6.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 (186) hide show
  1. package/CHANGELOG.md +471 -0
  2. package/LICENSE +21 -0
  3. package/README.md +242 -0
  4. package/build/core/auto-installer.d.ts +102 -0
  5. package/build/core/auto-installer.d.ts.map +1 -0
  6. package/build/core/auto-installer.js +833 -0
  7. package/build/core/backup-manager.d.ts +63 -0
  8. package/build/core/backup-manager.d.ts.map +1 -0
  9. package/build/core/backup-manager.js +189 -0
  10. package/build/core/changelog.d.ts +75 -0
  11. package/build/core/changelog.d.ts.map +1 -0
  12. package/build/core/changelog.js +123 -0
  13. package/build/core/command-allowlist.d.ts +129 -0
  14. package/build/core/command-allowlist.d.ts.map +1 -0
  15. package/build/core/command-allowlist.js +849 -0
  16. package/build/core/config.d.ts +79 -0
  17. package/build/core/config.d.ts.map +1 -0
  18. package/build/core/config.js +193 -0
  19. package/build/core/dependency-validator.d.ts +106 -0
  20. package/build/core/dependency-validator.d.ts.map +1 -0
  21. package/build/core/dependency-validator.js +405 -0
  22. package/build/core/distro-adapter.d.ts +177 -0
  23. package/build/core/distro-adapter.d.ts.map +1 -0
  24. package/build/core/distro-adapter.js +481 -0
  25. package/build/core/distro.d.ts +68 -0
  26. package/build/core/distro.d.ts.map +1 -0
  27. package/build/core/distro.js +457 -0
  28. package/build/core/encrypted-state.d.ts +76 -0
  29. package/build/core/encrypted-state.d.ts.map +1 -0
  30. package/build/core/encrypted-state.js +209 -0
  31. package/build/core/executor.d.ts +56 -0
  32. package/build/core/executor.d.ts.map +1 -0
  33. package/build/core/executor.js +350 -0
  34. package/build/core/installer.d.ts +92 -0
  35. package/build/core/installer.d.ts.map +1 -0
  36. package/build/core/installer.js +1072 -0
  37. package/build/core/logger.d.ts +102 -0
  38. package/build/core/logger.d.ts.map +1 -0
  39. package/build/core/logger.js +132 -0
  40. package/build/core/parsers.d.ts +151 -0
  41. package/build/core/parsers.d.ts.map +1 -0
  42. package/build/core/parsers.js +479 -0
  43. package/build/core/policy-engine.d.ts +170 -0
  44. package/build/core/policy-engine.d.ts.map +1 -0
  45. package/build/core/policy-engine.js +656 -0
  46. package/build/core/preflight.d.ts +157 -0
  47. package/build/core/preflight.d.ts.map +1 -0
  48. package/build/core/preflight.js +638 -0
  49. package/build/core/privilege-manager.d.ts +108 -0
  50. package/build/core/privilege-manager.d.ts.map +1 -0
  51. package/build/core/privilege-manager.js +363 -0
  52. package/build/core/rate-limiter.d.ts +67 -0
  53. package/build/core/rate-limiter.d.ts.map +1 -0
  54. package/build/core/rate-limiter.js +129 -0
  55. package/build/core/rollback.d.ts +73 -0
  56. package/build/core/rollback.d.ts.map +1 -0
  57. package/build/core/rollback.js +278 -0
  58. package/build/core/safeguards.d.ts +58 -0
  59. package/build/core/safeguards.d.ts.map +1 -0
  60. package/build/core/safeguards.js +448 -0
  61. package/build/core/sanitizer.d.ts +118 -0
  62. package/build/core/sanitizer.d.ts.map +1 -0
  63. package/build/core/sanitizer.js +459 -0
  64. package/build/core/secure-fs.d.ts +67 -0
  65. package/build/core/secure-fs.d.ts.map +1 -0
  66. package/build/core/secure-fs.js +143 -0
  67. package/build/core/spawn-safe.d.ts +55 -0
  68. package/build/core/spawn-safe.d.ts.map +1 -0
  69. package/build/core/spawn-safe.js +146 -0
  70. package/build/core/sudo-guard.d.ts +145 -0
  71. package/build/core/sudo-guard.d.ts.map +1 -0
  72. package/build/core/sudo-guard.js +349 -0
  73. package/build/core/sudo-session.d.ts +100 -0
  74. package/build/core/sudo-session.d.ts.map +1 -0
  75. package/build/core/sudo-session.js +319 -0
  76. package/build/core/tool-dependencies.d.ts +61 -0
  77. package/build/core/tool-dependencies.d.ts.map +1 -0
  78. package/build/core/tool-dependencies.js +571 -0
  79. package/build/core/tool-registry.d.ts +111 -0
  80. package/build/core/tool-registry.d.ts.map +1 -0
  81. package/build/core/tool-registry.js +656 -0
  82. package/build/core/tool-wrapper.d.ts +73 -0
  83. package/build/core/tool-wrapper.d.ts.map +1 -0
  84. package/build/core/tool-wrapper.js +296 -0
  85. package/build/index.d.ts +3 -0
  86. package/build/index.d.ts.map +1 -0
  87. package/build/index.js +247 -0
  88. package/build/tools/access-control.d.ts +9 -0
  89. package/build/tools/access-control.d.ts.map +1 -0
  90. package/build/tools/access-control.js +1818 -0
  91. package/build/tools/api-security.d.ts +12 -0
  92. package/build/tools/api-security.d.ts.map +1 -0
  93. package/build/tools/api-security.js +901 -0
  94. package/build/tools/app-hardening.d.ts +11 -0
  95. package/build/tools/app-hardening.d.ts.map +1 -0
  96. package/build/tools/app-hardening.js +768 -0
  97. package/build/tools/backup.d.ts +8 -0
  98. package/build/tools/backup.d.ts.map +1 -0
  99. package/build/tools/backup.js +381 -0
  100. package/build/tools/cloud-security.d.ts +17 -0
  101. package/build/tools/cloud-security.d.ts.map +1 -0
  102. package/build/tools/cloud-security.js +739 -0
  103. package/build/tools/compliance.d.ts +10 -0
  104. package/build/tools/compliance.d.ts.map +1 -0
  105. package/build/tools/compliance.js +1225 -0
  106. package/build/tools/container-security.d.ts +14 -0
  107. package/build/tools/container-security.d.ts.map +1 -0
  108. package/build/tools/container-security.js +788 -0
  109. package/build/tools/deception.d.ts +13 -0
  110. package/build/tools/deception.d.ts.map +1 -0
  111. package/build/tools/deception.js +763 -0
  112. package/build/tools/dns-security.d.ts +93 -0
  113. package/build/tools/dns-security.d.ts.map +1 -0
  114. package/build/tools/dns-security.js +745 -0
  115. package/build/tools/drift-detection.d.ts +8 -0
  116. package/build/tools/drift-detection.d.ts.map +1 -0
  117. package/build/tools/drift-detection.js +326 -0
  118. package/build/tools/ebpf-security.d.ts +15 -0
  119. package/build/tools/ebpf-security.d.ts.map +1 -0
  120. package/build/tools/ebpf-security.js +294 -0
  121. package/build/tools/encryption.d.ts +9 -0
  122. package/build/tools/encryption.d.ts.map +1 -0
  123. package/build/tools/encryption.js +1667 -0
  124. package/build/tools/firewall.d.ts +9 -0
  125. package/build/tools/firewall.d.ts.map +1 -0
  126. package/build/tools/firewall.js +1398 -0
  127. package/build/tools/hardening.d.ts +10 -0
  128. package/build/tools/hardening.d.ts.map +1 -0
  129. package/build/tools/hardening.js +2654 -0
  130. package/build/tools/ids.d.ts +9 -0
  131. package/build/tools/ids.d.ts.map +1 -0
  132. package/build/tools/ids.js +624 -0
  133. package/build/tools/incident-response.d.ts +10 -0
  134. package/build/tools/incident-response.d.ts.map +1 -0
  135. package/build/tools/incident-response.js +1180 -0
  136. package/build/tools/logging.d.ts +12 -0
  137. package/build/tools/logging.d.ts.map +1 -0
  138. package/build/tools/logging.js +454 -0
  139. package/build/tools/malware.d.ts +10 -0
  140. package/build/tools/malware.d.ts.map +1 -0
  141. package/build/tools/malware.js +532 -0
  142. package/build/tools/meta.d.ts +11 -0
  143. package/build/tools/meta.d.ts.map +1 -0
  144. package/build/tools/meta.js +2278 -0
  145. package/build/tools/network-defense.d.ts +12 -0
  146. package/build/tools/network-defense.d.ts.map +1 -0
  147. package/build/tools/network-defense.js +760 -0
  148. package/build/tools/patch-management.d.ts +3 -0
  149. package/build/tools/patch-management.d.ts.map +1 -0
  150. package/build/tools/patch-management.js +708 -0
  151. package/build/tools/process-security.d.ts +12 -0
  152. package/build/tools/process-security.d.ts.map +1 -0
  153. package/build/tools/process-security.js +784 -0
  154. package/build/tools/reporting.d.ts +11 -0
  155. package/build/tools/reporting.d.ts.map +1 -0
  156. package/build/tools/reporting.js +559 -0
  157. package/build/tools/secrets.d.ts +9 -0
  158. package/build/tools/secrets.d.ts.map +1 -0
  159. package/build/tools/secrets.js +596 -0
  160. package/build/tools/siem-integration.d.ts +18 -0
  161. package/build/tools/siem-integration.d.ts.map +1 -0
  162. package/build/tools/siem-integration.js +754 -0
  163. package/build/tools/sudo-management.d.ts +18 -0
  164. package/build/tools/sudo-management.d.ts.map +1 -0
  165. package/build/tools/sudo-management.js +737 -0
  166. package/build/tools/supply-chain-security.d.ts +8 -0
  167. package/build/tools/supply-chain-security.d.ts.map +1 -0
  168. package/build/tools/supply-chain-security.js +256 -0
  169. package/build/tools/threat-intel.d.ts +22 -0
  170. package/build/tools/threat-intel.d.ts.map +1 -0
  171. package/build/tools/threat-intel.js +749 -0
  172. package/build/tools/vulnerability-management.d.ts +11 -0
  173. package/build/tools/vulnerability-management.d.ts.map +1 -0
  174. package/build/tools/vulnerability-management.js +667 -0
  175. package/build/tools/waf.d.ts +12 -0
  176. package/build/tools/waf.d.ts.map +1 -0
  177. package/build/tools/waf.js +843 -0
  178. package/build/tools/wireless-security.d.ts +19 -0
  179. package/build/tools/wireless-security.d.ts.map +1 -0
  180. package/build/tools/wireless-security.js +826 -0
  181. package/build/tools/zero-trust-network.d.ts +8 -0
  182. package/build/tools/zero-trust-network.d.ts.map +1 -0
  183. package/build/tools/zero-trust-network.js +367 -0
  184. package/docs/SAFEGUARDS.md +518 -0
  185. package/docs/TOOLS-REFERENCE.md +665 -0
  186. package/package.json +87 -0
@@ -0,0 +1,102 @@
1
+ /**
2
+ * logger.ts — Structured logging module for security event correlation.
3
+ *
4
+ * Outputs JSON-formatted log entries with consistent fields for easy parsing
5
+ * by log aggregation systems (ELK, Splunk, Loki, etc.).
6
+ *
7
+ * Supports standard log levels plus a `security` level for security-relevant
8
+ * events (authentication, privilege escalation, policy violations).
9
+ *
10
+ * @module logger
11
+ * @see CICD-027
12
+ */
13
+ /** Supported log levels, ordered by severity (lowest to highest). */
14
+ export type LogLevel = "debug" | "info" | "warn" | "error" | "security";
15
+ /** A structured log entry written as JSON to stderr. */
16
+ export interface LogEntry {
17
+ /** ISO 8601 UTC timestamp */
18
+ timestamp: string;
19
+ /** Log severity level */
20
+ level: LogLevel;
21
+ /** Module or subsystem that produced the log (e.g., "preflight", "executor") */
22
+ component: string;
23
+ /** Action being performed (e.g., "tool_invoked", "sudo_elevated") */
24
+ action: string;
25
+ /** Human-readable message */
26
+ message: string;
27
+ /** Optional structured details (tool params, error info, metrics, etc.) */
28
+ details?: Record<string, unknown>;
29
+ }
30
+ /**
31
+ * Structured logger that outputs JSON to stderr.
32
+ *
33
+ * Uses stderr so log output doesn't interfere with MCP protocol messages
34
+ * on stdout (StdioServerTransport).
35
+ *
36
+ * Usage:
37
+ * ```typescript
38
+ * import { logger } from './logger.js';
39
+ *
40
+ * logger.info('preflight', 'cache_hit', 'Pre-flight cache hit for tool', { toolName: 'firewall_iptables' });
41
+ * logger.security('sudo-guard', 'elevation_requested', 'Sudo elevation requested', { tool: 'harden_sysctl' });
42
+ * ```
43
+ */
44
+ export declare class Logger {
45
+ private minLevel;
46
+ constructor(minLevel?: LogLevel);
47
+ /**
48
+ * Read the minimum log level from `KALI_DEFENSE_LOG_LEVEL` env var.
49
+ * Falls back to `"info"` if unset or invalid.
50
+ */
51
+ private parseEnvLevel;
52
+ /** Check whether a message at `level` should be emitted. */
53
+ private shouldLog;
54
+ /**
55
+ * Emit a structured log entry as a single JSON line to stderr.
56
+ *
57
+ * @param level - Severity level
58
+ * @param component - Subsystem name (e.g., "executor", "preflight")
59
+ * @param action - Action identifier (e.g., "command_executed", "cache_miss")
60
+ * @param message - Human-readable description
61
+ * @param details - Optional structured metadata
62
+ */
63
+ log(level: LogLevel, component: string, action: string, message: string, details?: Record<string, unknown>): void;
64
+ /** Log a debug-level message. */
65
+ debug(component: string, action: string, message: string, details?: Record<string, unknown>): void;
66
+ /** Log an info-level message. */
67
+ info(component: string, action: string, message: string, details?: Record<string, unknown>): void;
68
+ /** Log a warning-level message. */
69
+ warn(component: string, action: string, message: string, details?: Record<string, unknown>): void;
70
+ /** Log an error-level message. */
71
+ error(component: string, action: string, message: string, details?: Record<string, unknown>): void;
72
+ /**
73
+ * Log a security-relevant event.
74
+ *
75
+ * Security events are **always** emitted regardless of the configured
76
+ * minimum log level. Use for:
77
+ * - Authentication / privilege escalation events
78
+ * - Policy violations
79
+ * - Rate limit breaches
80
+ * - Suspicious input patterns
81
+ * - Configuration changes with security impact
82
+ */
83
+ security(component: string, action: string, message: string, details?: Record<string, unknown>): void;
84
+ /**
85
+ * Update the minimum log level at runtime.
86
+ * Useful for tests or dynamic configuration changes.
87
+ */
88
+ setLevel(level: LogLevel): void;
89
+ /** Get the current minimum log level. */
90
+ getLevel(): LogLevel;
91
+ }
92
+ /**
93
+ * Default singleton logger instance.
94
+ *
95
+ * Import and use directly:
96
+ * ```typescript
97
+ * import { logger } from '../core/logger.js';
98
+ * logger.info('my-module', 'action', 'Something happened');
99
+ * ```
100
+ */
101
+ export declare const logger: Logger;
102
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,qEAAqE;AACrE,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAYxE,wDAAwD;AACxD,MAAM,WAAW,QAAQ;IACvB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB;IACzB,KAAK,EAAE,QAAQ,CAAC;IAChB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAID;;;;;;;;;;;;;GAaG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAW;gBAEf,QAAQ,CAAC,EAAE,QAAQ;IAI/B;;;OAGG;IACH,OAAO,CAAC,aAAa;IAQrB,4DAA4D;IAC5D,OAAO,CAAC,SAAS;IAIjB;;;;;;;;OAQG;IACH,GAAG,CACD,KAAK,EAAE,QAAQ,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI;IAgBP,iCAAiC;IACjC,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI;IAIP,iCAAiC;IACjC,IAAI,CACF,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI;IAIP,mCAAmC;IACnC,IAAI,CACF,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI;IAIP,kCAAkC;IAClC,KAAK,CACH,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI;IAIP;;;;;;;;;;OAUG;IACH,QAAQ,CACN,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI;IAIP;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI/B,yCAAyC;IACzC,QAAQ,IAAI,QAAQ;CAGrB;AAID;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,QAAe,CAAC"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * logger.ts — Structured logging module for security event correlation.
3
+ *
4
+ * Outputs JSON-formatted log entries with consistent fields for easy parsing
5
+ * by log aggregation systems (ELK, Splunk, Loki, etc.).
6
+ *
7
+ * Supports standard log levels plus a `security` level for security-relevant
8
+ * events (authentication, privilege escalation, policy violations).
9
+ *
10
+ * @module logger
11
+ * @see CICD-027
12
+ */
13
+ /** Numeric severity for each log level (used for filtering). */
14
+ const LOG_LEVEL_SEVERITY = {
15
+ debug: 0,
16
+ info: 1,
17
+ warn: 2,
18
+ error: 3,
19
+ /** Security events always log regardless of level (severity 999). */
20
+ security: 999,
21
+ };
22
+ // ── Logger Class ─────────────────────────────────────────────────────────────
23
+ /**
24
+ * Structured logger that outputs JSON to stderr.
25
+ *
26
+ * Uses stderr so log output doesn't interfere with MCP protocol messages
27
+ * on stdout (StdioServerTransport).
28
+ *
29
+ * Usage:
30
+ * ```typescript
31
+ * import { logger } from './logger.js';
32
+ *
33
+ * logger.info('preflight', 'cache_hit', 'Pre-flight cache hit for tool', { toolName: 'firewall_iptables' });
34
+ * logger.security('sudo-guard', 'elevation_requested', 'Sudo elevation requested', { tool: 'harden_sysctl' });
35
+ * ```
36
+ */
37
+ export class Logger {
38
+ minLevel;
39
+ constructor(minLevel) {
40
+ this.minLevel = minLevel ?? this.parseEnvLevel();
41
+ }
42
+ /**
43
+ * Read the minimum log level from `KALI_DEFENSE_LOG_LEVEL` env var.
44
+ * Falls back to `"info"` if unset or invalid.
45
+ */
46
+ parseEnvLevel() {
47
+ const raw = process.env.KALI_DEFENSE_LOG_LEVEL?.toLowerCase();
48
+ if (raw && raw in LOG_LEVEL_SEVERITY) {
49
+ return raw;
50
+ }
51
+ return "info";
52
+ }
53
+ /** Check whether a message at `level` should be emitted. */
54
+ shouldLog(level) {
55
+ return LOG_LEVEL_SEVERITY[level] >= LOG_LEVEL_SEVERITY[this.minLevel];
56
+ }
57
+ /**
58
+ * Emit a structured log entry as a single JSON line to stderr.
59
+ *
60
+ * @param level - Severity level
61
+ * @param component - Subsystem name (e.g., "executor", "preflight")
62
+ * @param action - Action identifier (e.g., "command_executed", "cache_miss")
63
+ * @param message - Human-readable description
64
+ * @param details - Optional structured metadata
65
+ */
66
+ log(level, component, action, message, details) {
67
+ if (!this.shouldLog(level))
68
+ return;
69
+ const entry = {
70
+ timestamp: new Date().toISOString(),
71
+ level,
72
+ component,
73
+ action,
74
+ message,
75
+ ...(details !== undefined ? { details } : {}),
76
+ };
77
+ // Single-line JSON to stderr — safe for MCP stdio transport
78
+ process.stderr.write(JSON.stringify(entry) + "\n");
79
+ }
80
+ /** Log a debug-level message. */
81
+ debug(component, action, message, details) {
82
+ this.log("debug", component, action, message, details);
83
+ }
84
+ /** Log an info-level message. */
85
+ info(component, action, message, details) {
86
+ this.log("info", component, action, message, details);
87
+ }
88
+ /** Log a warning-level message. */
89
+ warn(component, action, message, details) {
90
+ this.log("warn", component, action, message, details);
91
+ }
92
+ /** Log an error-level message. */
93
+ error(component, action, message, details) {
94
+ this.log("error", component, action, message, details);
95
+ }
96
+ /**
97
+ * Log a security-relevant event.
98
+ *
99
+ * Security events are **always** emitted regardless of the configured
100
+ * minimum log level. Use for:
101
+ * - Authentication / privilege escalation events
102
+ * - Policy violations
103
+ * - Rate limit breaches
104
+ * - Suspicious input patterns
105
+ * - Configuration changes with security impact
106
+ */
107
+ security(component, action, message, details) {
108
+ this.log("security", component, action, message, details);
109
+ }
110
+ /**
111
+ * Update the minimum log level at runtime.
112
+ * Useful for tests or dynamic configuration changes.
113
+ */
114
+ setLevel(level) {
115
+ this.minLevel = level;
116
+ }
117
+ /** Get the current minimum log level. */
118
+ getLevel() {
119
+ return this.minLevel;
120
+ }
121
+ }
122
+ // ── Singleton Export ─────────────────────────────────────────────────────────
123
+ /**
124
+ * Default singleton logger instance.
125
+ *
126
+ * Import and use directly:
127
+ * ```typescript
128
+ * import { logger } from '../core/logger.js';
129
+ * logger.info('my-module', 'action', 'Something happened');
130
+ * ```
131
+ */
132
+ export const logger = new Logger();
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Output parsing utilities for defensive security tool output.
3
+ * Converts raw command output into structured data for MCP responses.
4
+ */
5
+ /** MCP text content type */
6
+ export interface McpTextContent {
7
+ type: "text";
8
+ text: string;
9
+ [key: string]: unknown;
10
+ }
11
+ /**
12
+ * Parses key:value pair output into a Record.
13
+ * Lines without the separator are skipped.
14
+ */
15
+ export declare function parseKeyValue(output: string, separator?: string): Record<string, string>;
16
+ /**
17
+ * Parses whitespace-delimited table output into an array of Records.
18
+ * First non-empty line is treated as the header row.
19
+ */
20
+ export declare function parseTable(output: string): Record<string, string>[];
21
+ /**
22
+ * Safely parses JSON text. Returns null on parse failure.
23
+ */
24
+ export declare function parseJsonSafe(text: string): unknown | null;
25
+ /**
26
+ * Formats any data into MCP text content.
27
+ * Objects are JSON-stringified with indentation.
28
+ */
29
+ export declare function formatToolOutput(data: unknown): McpTextContent;
30
+ /**
31
+ * Creates a simple MCP text content object.
32
+ */
33
+ export declare function createTextContent(text: string): McpTextContent;
34
+ /**
35
+ * Creates an MCP text content object with an error prefix.
36
+ */
37
+ export declare function createErrorContent(msg: string): McpTextContent;
38
+ /** Structured iptables rule */
39
+ export interface IptablesRule {
40
+ chain: string;
41
+ policy?: string;
42
+ packets: string;
43
+ bytes: string;
44
+ target: string;
45
+ protocol: string;
46
+ opt: string;
47
+ in: string;
48
+ out: string;
49
+ source: string;
50
+ destination: string;
51
+ extra: string;
52
+ }
53
+ /**
54
+ * Parses `iptables -L -n -v` output into structured rules.
55
+ */
56
+ export declare function parseIptablesOutput(output: string): IptablesRule[];
57
+ /**
58
+ * Parses `nft list ruleset` output into structured sections.
59
+ */
60
+ export declare function parseNftOutput(output: string): Record<string, string[]>;
61
+ /** Structured sysctl entry */
62
+ export interface SysctlEntry {
63
+ key: string;
64
+ value: string;
65
+ }
66
+ /**
67
+ * Parses `sysctl -a` output into structured entries.
68
+ */
69
+ export declare function parseSysctlOutput(output: string): SysctlEntry[];
70
+ /** Structured audit log entry */
71
+ export interface AuditEntry {
72
+ type: string;
73
+ timestamp: string;
74
+ fields: Record<string, string>;
75
+ }
76
+ /**
77
+ * Parses `ausearch` output into structured audit entries.
78
+ */
79
+ export declare function parseAuditdOutput(output: string): AuditEntry[];
80
+ /** Lynis finding */
81
+ export interface LynisFinding {
82
+ severity: string;
83
+ testId: string;
84
+ description: string;
85
+ }
86
+ /**
87
+ * Parses Lynis audit output for findings/warnings/suggestions.
88
+ */
89
+ export declare function parseLynisOutput(output: string): LynisFinding[];
90
+ /** OpenSCAP result entry */
91
+ export interface OscapResult {
92
+ ruleId: string;
93
+ result: string;
94
+ severity: string;
95
+ title: string;
96
+ }
97
+ /**
98
+ * Parses OpenSCAP text/XML results output.
99
+ * Handles the common text report format.
100
+ */
101
+ export declare function parseOscapOutput(output: string): OscapResult[];
102
+ /** ClamAV scan result */
103
+ export interface ClamavResult {
104
+ file: string;
105
+ status: "OK" | "FOUND" | "ERROR";
106
+ virus?: string;
107
+ }
108
+ /**
109
+ * Parses `clamscan` output into structured results.
110
+ */
111
+ export declare function parseClamavOutput(output: string): ClamavResult[];
112
+ /** Structured socket entry from ss */
113
+ export interface SsEntry {
114
+ state: string;
115
+ recv: string;
116
+ send: string;
117
+ local: string;
118
+ peer: string;
119
+ process: string;
120
+ }
121
+ /**
122
+ * Parses `ss -tulnp` output into structured entries.
123
+ */
124
+ export declare function parseSsOutput(output: string): SsEntry[];
125
+ /** Structured fail2ban jail status */
126
+ export interface Fail2banJail {
127
+ name: string;
128
+ status: string;
129
+ currentlyFailed: number;
130
+ totalFailed: number;
131
+ currentlyBanned: number;
132
+ totalBanned: number;
133
+ bannedIPs: string[];
134
+ }
135
+ /**
136
+ * Parses `fail2ban-client status` output.
137
+ */
138
+ export declare function parseFail2banOutput(output: string): Fail2banJail[];
139
+ /** Structured systemctl unit entry */
140
+ export interface SystemctlUnit {
141
+ unit: string;
142
+ load: string;
143
+ active: string;
144
+ sub: string;
145
+ description: string;
146
+ }
147
+ /**
148
+ * Parses `systemctl list-units` output into structured entries.
149
+ */
150
+ export declare function parseSystemctlOutput(output: string): SystemctlUnit[];
151
+ //# sourceMappingURL=parsers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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