defense-mcp-server 0.9.3 → 0.9.4
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/package.json +2 -2
- package/build/core/auto-installer.d.ts +0 -102
- package/build/core/auto-installer.d.ts.map +0 -1
- package/build/core/backup-manager.d.ts +0 -63
- package/build/core/backup-manager.d.ts.map +0 -1
- package/build/core/changelog.d.ts +0 -119
- package/build/core/changelog.d.ts.map +0 -1
- package/build/core/command-allowlist.d.ts +0 -129
- package/build/core/command-allowlist.d.ts.map +0 -1
- package/build/core/config.d.ts +0 -107
- package/build/core/config.d.ts.map +0 -1
- package/build/core/dependency-validator.d.ts +0 -106
- package/build/core/dependency-validator.d.ts.map +0 -1
- package/build/core/distro-adapter.d.ts +0 -172
- package/build/core/distro-adapter.d.ts.map +0 -1
- package/build/core/distro.d.ts +0 -57
- package/build/core/distro.d.ts.map +0 -1
- package/build/core/encrypted-state.d.ts +0 -69
- package/build/core/encrypted-state.d.ts.map +0 -1
- package/build/core/executor.d.ts +0 -65
- package/build/core/executor.d.ts.map +0 -1
- package/build/core/installer.d.ts +0 -129
- package/build/core/installer.d.ts.map +0 -1
- package/build/core/logger.d.ts +0 -118
- package/build/core/logger.d.ts.map +0 -1
- package/build/core/metrics.d.ts +0 -74
- package/build/core/metrics.d.ts.map +0 -1
- package/build/core/metrics.js +0 -97
- package/build/core/output-redactor.d.ts +0 -26
- package/build/core/output-redactor.d.ts.map +0 -1
- package/build/core/pam-utils.d.ts +0 -356
- package/build/core/pam-utils.d.ts.map +0 -1
- package/build/core/parsers.d.ts +0 -191
- package/build/core/parsers.d.ts.map +0 -1
- package/build/core/policy-engine.d.ts +0 -170
- package/build/core/policy-engine.d.ts.map +0 -1
- package/build/core/preflight.d.ts +0 -157
- package/build/core/preflight.d.ts.map +0 -1
- package/build/core/privilege-manager.d.ts +0 -108
- package/build/core/privilege-manager.d.ts.map +0 -1
- package/build/core/progress.d.ts +0 -99
- package/build/core/progress.d.ts.map +0 -1
- package/build/core/rate-limiter.d.ts +0 -101
- package/build/core/rate-limiter.d.ts.map +0 -1
- package/build/core/rollback.d.ts +0 -73
- package/build/core/rollback.d.ts.map +0 -1
- package/build/core/run-command.d.ts +0 -14
- package/build/core/run-command.d.ts.map +0 -1
- package/build/core/safeguards.d.ts +0 -58
- package/build/core/safeguards.d.ts.map +0 -1
- package/build/core/sanitizer.d.ts +0 -118
- package/build/core/sanitizer.d.ts.map +0 -1
- package/build/core/secure-fs.d.ts +0 -67
- package/build/core/secure-fs.d.ts.map +0 -1
- package/build/core/spawn-safe.d.ts +0 -55
- package/build/core/spawn-safe.d.ts.map +0 -1
- package/build/core/sudo-guard.d.ts +0 -167
- package/build/core/sudo-guard.d.ts.map +0 -1
- package/build/core/sudo-session.d.ts +0 -143
- package/build/core/sudo-session.d.ts.map +0 -1
- package/build/core/third-party-installer.d.ts +0 -58
- package/build/core/third-party-installer.d.ts.map +0 -1
- package/build/core/third-party-manifest.d.ts +0 -48
- package/build/core/third-party-manifest.d.ts.map +0 -1
- package/build/core/tool-annotations.d.ts +0 -13
- package/build/core/tool-annotations.d.ts.map +0 -1
- package/build/core/tool-dependencies.d.ts +0 -60
- package/build/core/tool-dependencies.d.ts.map +0 -1
- package/build/core/tool-durations.d.ts +0 -71
- package/build/core/tool-durations.d.ts.map +0 -1
- package/build/core/tool-registry.d.ts +0 -112
- package/build/core/tool-registry.d.ts.map +0 -1
- package/build/core/tool-wrapper.d.ts +0 -73
- package/build/core/tool-wrapper.d.ts.map +0 -1
- package/build/index.d.ts +0 -3
- package/build/index.d.ts.map +0 -1
- package/build/tools/access-control.d.ts +0 -11
- package/build/tools/access-control.d.ts.map +0 -1
- package/build/tools/api-security.d.ts +0 -12
- package/build/tools/api-security.d.ts.map +0 -1
- package/build/tools/app-hardening.d.ts +0 -11
- package/build/tools/app-hardening.d.ts.map +0 -1
- package/build/tools/backup.d.ts +0 -8
- package/build/tools/backup.d.ts.map +0 -1
- package/build/tools/cloud-security.d.ts +0 -17
- package/build/tools/cloud-security.d.ts.map +0 -1
- package/build/tools/compliance.d.ts +0 -11
- package/build/tools/compliance.d.ts.map +0 -1
- package/build/tools/container-security.d.ts +0 -14
- package/build/tools/container-security.d.ts.map +0 -1
- package/build/tools/deception.d.ts +0 -13
- package/build/tools/deception.d.ts.map +0 -1
- package/build/tools/dns-security.d.ts +0 -93
- package/build/tools/dns-security.d.ts.map +0 -1
- package/build/tools/ebpf-security.d.ts +0 -15
- package/build/tools/ebpf-security.d.ts.map +0 -1
- package/build/tools/encryption.d.ts +0 -12
- package/build/tools/encryption.d.ts.map +0 -1
- package/build/tools/firewall.d.ts +0 -9
- package/build/tools/firewall.d.ts.map +0 -1
- package/build/tools/hardening.d.ts +0 -8
- package/build/tools/hardening.d.ts.map +0 -1
- package/build/tools/incident-response.d.ts +0 -11
- package/build/tools/incident-response.d.ts.map +0 -1
- package/build/tools/integrity.d.ts +0 -15
- package/build/tools/integrity.d.ts.map +0 -1
- package/build/tools/logging.d.ts +0 -21
- package/build/tools/logging.d.ts.map +0 -1
- package/build/tools/malware.d.ts +0 -10
- package/build/tools/malware.d.ts.map +0 -1
- package/build/tools/meta.d.ts +0 -13
- package/build/tools/meta.d.ts.map +0 -1
- package/build/tools/network-defense.d.ts +0 -11
- package/build/tools/network-defense.d.ts.map +0 -1
- package/build/tools/patch-management.d.ts +0 -3
- package/build/tools/patch-management.d.ts.map +0 -1
- package/build/tools/process-security.d.ts +0 -12
- package/build/tools/process-security.d.ts.map +0 -1
- package/build/tools/secrets.d.ts +0 -8
- package/build/tools/secrets.d.ts.map +0 -1
- package/build/tools/sudo-management.d.ts +0 -17
- package/build/tools/sudo-management.d.ts.map +0 -1
- package/build/tools/supply-chain-security.d.ts +0 -8
- package/build/tools/supply-chain-security.d.ts.map +0 -1
- package/build/tools/threat-intel.d.ts +0 -22
- package/build/tools/threat-intel.d.ts.map +0 -1
- package/build/tools/vulnerability-management.d.ts +0 -11
- package/build/tools/vulnerability-management.d.ts.map +0 -1
- package/build/tools/waf.d.ts +0 -12
- package/build/tools/waf.d.ts.map +0 -1
- package/build/tools/wireless-security.d.ts +0 -19
- package/build/tools/wireless-security.d.ts.map +0 -1
- package/build/tools/zero-trust-network.d.ts +0 -8
- package/build/tools/zero-trust-network.d.ts.map +0 -1
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DistroAdapter — unified cross-distribution API for the Defense MCP Server.
|
|
3
|
-
*
|
|
4
|
-
* This module provides a single, cached adapter instance that abstracts away
|
|
5
|
-
* distribution-specific differences in:
|
|
6
|
-
* - Package management (apt / dnf / yum / zypper / pacman / apk)
|
|
7
|
-
* - Service management (systemd / openrc / sysvinit / launchd)
|
|
8
|
-
* - Firewall backends (iptables / nftables / ufw / firewalld)
|
|
9
|
-
* - File system paths (logs, PAM configs, syslog, package tools)
|
|
10
|
-
* - Package integrity checking (debsums / rpm -V)
|
|
11
|
-
* - Automatic updates configuration
|
|
12
|
-
*
|
|
13
|
-
* Supported distributions:
|
|
14
|
-
* Debian, Ubuntu, Kali, Linux Mint, Pop!_OS → debian family
|
|
15
|
-
* RHEL, CentOS, Fedora, Rocky, AlmaLinux → rhel family
|
|
16
|
-
* openSUSE, SLES → suse family
|
|
17
|
-
* Arch, Manjaro → arch family
|
|
18
|
-
* Alpine → alpine family
|
|
19
|
-
*
|
|
20
|
-
* Usage:
|
|
21
|
-
* import { getDistroAdapter } from "../core/distro-adapter.js";
|
|
22
|
-
* const da = await getDistroAdapter();
|
|
23
|
-
* const cmd = da.pkg.installCmd("nginx"); // distro-correct install
|
|
24
|
-
* const logPath = da.paths.syslog; // "/var/log/syslog" or "/var/log/messages"
|
|
25
|
-
*/
|
|
26
|
-
import { type DistroInfo, type PackageManagerCommands, type ServiceManagerCommands, type FirewallBackendCommands } from "./distro.js";
|
|
27
|
-
/** System paths that vary across distributions. */
|
|
28
|
-
export interface DistroPaths {
|
|
29
|
-
/** Primary syslog file */
|
|
30
|
-
syslog: string;
|
|
31
|
-
/** Authentication log */
|
|
32
|
-
authLog: string;
|
|
33
|
-
/** PAM common-auth or system-auth equivalent */
|
|
34
|
-
pamAuth: string;
|
|
35
|
-
/** PAM common-password or password-auth equivalent */
|
|
36
|
-
pamPassword: string;
|
|
37
|
-
/** PAM common-session equivalent */
|
|
38
|
-
pamSession: string;
|
|
39
|
-
/** PAM common-account equivalent */
|
|
40
|
-
pamAccount: string;
|
|
41
|
-
/** All PAM config files to audit */
|
|
42
|
-
pamAllConfigs: string[];
|
|
43
|
-
/** Auto-update config dir (apt.conf.d, dnf automatic, etc.) */
|
|
44
|
-
autoUpdateConfig: string;
|
|
45
|
-
/** Auto-update package name */
|
|
46
|
-
autoUpdatePackage: string;
|
|
47
|
-
/** Auto-update service name */
|
|
48
|
-
autoUpdateService: string;
|
|
49
|
-
/** Firewall persistence config path */
|
|
50
|
-
firewallPersistenceConfig: string;
|
|
51
|
-
/** Package manager lock file */
|
|
52
|
-
packageLockFile: string;
|
|
53
|
-
/** Network interface config dir */
|
|
54
|
-
networkConfigDir: string;
|
|
55
|
-
/** Kernel modules blacklist config */
|
|
56
|
-
modprobeDir: string;
|
|
57
|
-
/** GRUB config file */
|
|
58
|
-
grubConfig: string;
|
|
59
|
-
/** GRUB defaults file */
|
|
60
|
-
grubDefaults: string;
|
|
61
|
-
/** GRUB update command */
|
|
62
|
-
grubUpdateCmd: string[];
|
|
63
|
-
}
|
|
64
|
-
/** Package integrity check configuration. */
|
|
65
|
-
export interface IntegrityCheckConfig {
|
|
66
|
-
/** Whether integrity checking is supported */
|
|
67
|
-
supported: boolean;
|
|
68
|
-
/** The command to check package integrity */
|
|
69
|
-
checkCmd: string[];
|
|
70
|
-
/** The command to check a specific package */
|
|
71
|
-
checkPackageCmd: (pkg: string) => string[];
|
|
72
|
-
/** Name of the integrity tool */
|
|
73
|
-
toolName: string;
|
|
74
|
-
/** How to install the integrity tool */
|
|
75
|
-
installHint: string;
|
|
76
|
-
}
|
|
77
|
-
/** Auto-update audit configuration. */
|
|
78
|
-
export interface AutoUpdateConfig {
|
|
79
|
-
/** Whether auto-updates are supported on this distro */
|
|
80
|
-
supported: boolean;
|
|
81
|
-
/** Package name for auto-updates */
|
|
82
|
-
packageName: string;
|
|
83
|
-
/** How to check if auto-update is installed */
|
|
84
|
-
checkInstalledCmd: string[];
|
|
85
|
-
/** Service name to check */
|
|
86
|
-
serviceName: string;
|
|
87
|
-
/** Config files to audit */
|
|
88
|
-
configFiles: string[];
|
|
89
|
-
/** How to install auto-updates */
|
|
90
|
-
installHint: string;
|
|
91
|
-
}
|
|
92
|
-
/** Package listing/querying commands. */
|
|
93
|
-
export interface PackageQueryCommands {
|
|
94
|
-
/** List all installed packages */
|
|
95
|
-
listInstalledCmd: string[];
|
|
96
|
-
/** Query a specific package (returns version info) */
|
|
97
|
-
queryPackageCmd: (pkg: string) => string[];
|
|
98
|
-
/** List available upgrades */
|
|
99
|
-
listUpgradableCmd: string[];
|
|
100
|
-
/** Show held/locked packages */
|
|
101
|
-
showHeldCmd: string[];
|
|
102
|
-
/** Simulate upgrade (dry-run) */
|
|
103
|
-
simulateUpgradeCmd: string[];
|
|
104
|
-
/** Show package changelog */
|
|
105
|
-
changelogCmd: (pkg: string) => string[];
|
|
106
|
-
/** Show package policy/info */
|
|
107
|
-
policyCmd: (pkg: string) => string[];
|
|
108
|
-
/** Check if a specific package is installed */
|
|
109
|
-
isInstalledCmd: (pkg: string) => string[];
|
|
110
|
-
/** List installed kernel packages */
|
|
111
|
-
listKernelsCmd: string[];
|
|
112
|
-
/** Check for auto-removable packages */
|
|
113
|
-
autoRemoveCmd: string[];
|
|
114
|
-
}
|
|
115
|
-
/** Firewall persistence commands. */
|
|
116
|
-
export interface FirewallPersistenceConfig {
|
|
117
|
-
/** Package name for firewall persistence */
|
|
118
|
-
packageName: string;
|
|
119
|
-
/** How to check if persistence is installed */
|
|
120
|
-
checkInstalledCmd: string[];
|
|
121
|
-
/** Install command (already includes sudo) */
|
|
122
|
-
installCmd: string[];
|
|
123
|
-
/** Service name for persistence */
|
|
124
|
-
serviceName: string;
|
|
125
|
-
/** Enable persistence service */
|
|
126
|
-
enableCmd: string[];
|
|
127
|
-
/** Save rules command */
|
|
128
|
-
saveCmd: string[];
|
|
129
|
-
/** Rollback/uninstall hint */
|
|
130
|
-
uninstallHint: string;
|
|
131
|
-
}
|
|
132
|
-
export declare class DistroAdapter {
|
|
133
|
-
readonly distro: DistroInfo;
|
|
134
|
-
readonly pkg: PackageManagerCommands;
|
|
135
|
-
readonly svc: ServiceManagerCommands;
|
|
136
|
-
readonly fw: FirewallBackendCommands;
|
|
137
|
-
readonly paths: DistroPaths;
|
|
138
|
-
readonly integrity: IntegrityCheckConfig;
|
|
139
|
-
readonly autoUpdate: AutoUpdateConfig;
|
|
140
|
-
readonly pkgQuery: PackageQueryCommands;
|
|
141
|
-
readonly fwPersistence: FirewallPersistenceConfig;
|
|
142
|
-
constructor(distro: DistroInfo, pkg: PackageManagerCommands, svc: ServiceManagerCommands, fw: FirewallBackendCommands);
|
|
143
|
-
/** Human-readable summary of the detected environment. */
|
|
144
|
-
get summary(): string;
|
|
145
|
-
/** Whether the distro family is Debian-based. */
|
|
146
|
-
get isDebian(): boolean;
|
|
147
|
-
/** Whether the distro family is RHEL-based. */
|
|
148
|
-
get isRhel(): boolean;
|
|
149
|
-
/** Whether the distro family is SUSE-based. */
|
|
150
|
-
get isSuse(): boolean;
|
|
151
|
-
/** Whether the distro family is Arch-based. */
|
|
152
|
-
get isArch(): boolean;
|
|
153
|
-
/** Whether the distro family is Alpine. */
|
|
154
|
-
get isAlpine(): boolean;
|
|
155
|
-
/** Install a package using the distro's package manager (returns command array). */
|
|
156
|
-
installPkg(pkg: string): {
|
|
157
|
-
command: string;
|
|
158
|
-
args: string[];
|
|
159
|
-
};
|
|
160
|
-
/** Remove a package using the distro's package manager (returns command array). */
|
|
161
|
-
removePkg(pkg: string): {
|
|
162
|
-
command: string;
|
|
163
|
-
args: string[];
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Returns the singleton DistroAdapter.
|
|
168
|
-
* On first call it detects the distribution and builds all adapters.
|
|
169
|
-
* Subsequent calls return the cached instance.
|
|
170
|
-
*/
|
|
171
|
-
export declare function getDistroAdapter(): Promise<DistroAdapter>;
|
|
172
|
-
//# sourceMappingURL=distro-adapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"distro-adapter.d.ts","sourceRoot":"","sources":["../../src/core/distro-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,aAAa,CAAC;AAIrB,mDAAmD;AACnD,MAAM,WAAW,WAAW;IAC1B,0BAA0B;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,+DAA+D;IAC/D,gBAAgB,EAAE,MAAM,CAAC;IACzB,+BAA+B;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+BAA+B;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,uCAAuC;IACvC,yBAAyB,EAAE,MAAM,CAAC;IAClC,gCAAgC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,UAAU,EAAE,MA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,IAAI,OAAO,CAA4C;IAEnE,+CAA+C;IAC/C,IAAI,MAAM,IAAI,OAAO,CAA0C;IAE/D,+CAA+C;IAC/C,IAAI,MAAM,IAAI,OAAO,CAA0C;IAE/D,+CAA+C;IAC/C,IAAI,MAAM,IAAI,OAAO,CAA0C;IAE/D,2CAA2C;IAC3C,IAAI,QAAQ,IAAI,OAAO,CAA4C;IAEnE,oFAAoF;IACpF,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE;IAK5D,mFAAmF;IACnF,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE;CAI5D;AA0ZD;;;;GAIG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CAa/D"}
|
package/build/core/distro.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Top-level operating system family.
|
|
3
|
-
* 'wsl' is reported when running inside Windows Subsystem for Linux.
|
|
4
|
-
*/
|
|
5
|
-
export type OsFamily = "linux" | "darwin" | "wsl";
|
|
6
|
-
/** Linux distribution family identifiers. */
|
|
7
|
-
export type DistroFamily = "debian" | "rhel" | "arch" | "alpine" | "suse" | "unknown";
|
|
8
|
-
export type SpecificDistro = "debian" | "ubuntu" | "kali" | "fedora" | "rhel" | "centos" | "arch" | "alpine" | "opensuse" | "macos" | "unknown";
|
|
9
|
-
/** Package manager identifiers (extended with brew). */
|
|
10
|
-
export type PackageManagerName = "apt" | "dnf" | "yum" | "pacman" | "brew" | "apk" | "zypper" | "unknown";
|
|
11
|
-
export type InitSystem = "systemd" | "openrc" | "launchd" | "sysvinit" | "unknown";
|
|
12
|
-
export interface PackageManagerCommands {
|
|
13
|
-
installCmd(pkg: string): string[];
|
|
14
|
-
removeCmd(pkg: string): string[];
|
|
15
|
-
updateCmd(): string[];
|
|
16
|
-
searchCmd(term: string): string[];
|
|
17
|
-
listInstalledCmd(): string[];
|
|
18
|
-
}
|
|
19
|
-
export interface ServiceManagerCommands {
|
|
20
|
-
startCmd(svc: string): string[];
|
|
21
|
-
stopCmd(svc: string): string[];
|
|
22
|
-
enableCmd(svc: string): string[];
|
|
23
|
-
disableCmd(svc: string): string[];
|
|
24
|
-
statusCmd(svc: string): string[];
|
|
25
|
-
listServicesCmd(): string[];
|
|
26
|
-
}
|
|
27
|
-
export type FirewallBackendName = "iptables" | "nftables" | "ufw" | "firewalld" | "pf" | "unknown";
|
|
28
|
-
export interface FirewallBackendCommands {
|
|
29
|
-
readonly name: FirewallBackendName;
|
|
30
|
-
allowCmd(port: number, proto?: string): string[];
|
|
31
|
-
denyCmd(port: number, proto?: string): string[];
|
|
32
|
-
listCmd(): string[];
|
|
33
|
-
flushCmd(): string[];
|
|
34
|
-
}
|
|
35
|
-
export interface DistroInfo {
|
|
36
|
-
id: string;
|
|
37
|
-
name: string;
|
|
38
|
-
version: string;
|
|
39
|
-
osFamily: OsFamily;
|
|
40
|
-
specificDistro: SpecificDistro;
|
|
41
|
-
family: DistroFamily;
|
|
42
|
-
packageManager: PackageManagerName;
|
|
43
|
-
initSystem: InitSystem;
|
|
44
|
-
hasFirewalld: boolean;
|
|
45
|
-
hasUfw: boolean;
|
|
46
|
-
hasSelinux: boolean;
|
|
47
|
-
hasApparmor: boolean;
|
|
48
|
-
}
|
|
49
|
-
export declare function detectDistro(): Promise<DistroInfo>;
|
|
50
|
-
export declare function getPackageManager(nameOrDistro?: string): PackageManagerCommands;
|
|
51
|
-
export declare function getServiceManager(initSystem?: InitSystem): ServiceManagerCommands;
|
|
52
|
-
export declare function getFirewallBackend(): Promise<FirewallBackendCommands>;
|
|
53
|
-
/** @deprecated Prefer getPackageManager(pkgManager).installCmd(pkg) */
|
|
54
|
-
export declare function getInstallCommand(pkgManager: PackageManagerName, pkg: string): string[];
|
|
55
|
-
/** @deprecated Prefer getPackageManager(pkgManager).updateCmd() */
|
|
56
|
-
export declare function getUpdateCommand(pkgManager: PackageManagerName): string[];
|
|
57
|
-
//# sourceMappingURL=distro.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"distro.d.ts","sourceRoot":"","sources":["../../src/core/distro.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAIlD,6CAA6C;AAC7C,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,SAAS,CAAC;AAId,MAAM,MAAM,cAAc,GACtB,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAC3D,MAAM,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAIzD,wDAAwD;AACxD,MAAM,MAAM,kBAAkB,GAC1B,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC;AAK7E,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAAC;AAInF,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,SAAS,IAAI,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,gBAAgB,IAAI,MAAM,EAAE,CAAC;CAC9B;AAID,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,OAAO,C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4D/E;AA4BD,wBAAgB,iBAAiB,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,sBAAsB,CAoCjF;AAmDD,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAc3E;AAID,uEAAuE;AACvE,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAEvF;AAED,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAEzE"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* encrypted-state.ts — Encrypted storage for sensitive state data.
|
|
3
|
-
*
|
|
4
|
-
* Provides AES-256-GCM encrypted at-rest storage for rollback data,
|
|
5
|
-
* policy files, sudo session tokens, and other sensitive state.
|
|
6
|
-
*
|
|
7
|
-
* Key derivation uses PBKDF2 from a configurable secret via the
|
|
8
|
-
* `DEFENSE_MCP_STATE_KEY` environment variable. If no key is
|
|
9
|
-
* configured, falls back to unencrypted mode with a warning.
|
|
10
|
-
*
|
|
11
|
-
* @module encrypted-state
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Encrypted state storage for sensitive data at rest.
|
|
15
|
-
*
|
|
16
|
-
* Uses AES-256-GCM with PBKDF2-derived keys when `DEFENSE_MCP_STATE_KEY`
|
|
17
|
-
* is set. Falls back to plaintext JSON when no key is configured.
|
|
18
|
-
*/
|
|
19
|
-
export declare class SecureStateStore {
|
|
20
|
-
private readonly stateDir;
|
|
21
|
-
private readonly secret;
|
|
22
|
-
/**
|
|
23
|
-
* @param stateDir - Directory for state files (default: `/tmp/defense-mcp/state/`)
|
|
24
|
-
* @param secret - Encryption secret. If omitted, reads from `DEFENSE_MCP_STATE_KEY` env var.
|
|
25
|
-
* Pass empty string or omit to use unencrypted fallback.
|
|
26
|
-
*/
|
|
27
|
-
constructor(stateDir?: string, secret?: string);
|
|
28
|
-
/**
|
|
29
|
-
* Whether the store is operating in encrypted mode.
|
|
30
|
-
*/
|
|
31
|
-
get encrypted(): boolean;
|
|
32
|
-
/**
|
|
33
|
-
* Save a state object to disk.
|
|
34
|
-
*
|
|
35
|
-
* @param id - Unique identifier for the state (used as filename stem)
|
|
36
|
-
* @param data - JSON-serializable object to persist
|
|
37
|
-
*/
|
|
38
|
-
save(id: string, data: object): void;
|
|
39
|
-
/**
|
|
40
|
-
* Load a state object from disk.
|
|
41
|
-
*
|
|
42
|
-
* @param id - Unique identifier for the state
|
|
43
|
-
* @returns The deserialized object, or `null` if the state file doesn't exist
|
|
44
|
-
*/
|
|
45
|
-
load(id: string): object | null;
|
|
46
|
-
/**
|
|
47
|
-
* Delete a state file from disk.
|
|
48
|
-
*
|
|
49
|
-
* @param id - Unique identifier for the state to delete
|
|
50
|
-
*/
|
|
51
|
-
delete(id: string): void;
|
|
52
|
-
/** Build the full file path for a state ID. */
|
|
53
|
-
private filePath;
|
|
54
|
-
/** Ensure the state directory exists with secure permissions. */
|
|
55
|
-
private ensureStateDir;
|
|
56
|
-
/** Derive an AES-256 key from the secret and a salt. */
|
|
57
|
-
private deriveKey;
|
|
58
|
-
/**
|
|
59
|
-
* Encrypt plaintext JSON using AES-256-GCM.
|
|
60
|
-
* Returns a Buffer: [salt (16)] [iv (12)] [authTag (16)] [ciphertext]
|
|
61
|
-
*/
|
|
62
|
-
private encrypt;
|
|
63
|
-
/**
|
|
64
|
-
* Decrypt an AES-256-GCM encrypted buffer.
|
|
65
|
-
* Expects format: [salt (16)] [iv (12)] [authTag (16)] [ciphertext]
|
|
66
|
-
*/
|
|
67
|
-
private decrypt;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=encrypted-state.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encrypted-state.d.ts","sourceRoot":"","sources":["../../src/core/encrypted-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA4DH;;;;;GAKG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgB;IAEvC;;;;OAIG;gBACS,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAwB9C;;OAEG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;;;;OAKG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAmBpC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAiB/B;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAcxB,+CAA+C;IAC/C,OAAO,CAAC,QAAQ;IAMhB,iEAAiE;IACjE,OAAO,CAAC,cAAc;IAOtB,wDAAwD;IACxD,OAAO,CAAC,SAAS;IAajB;;;OAGG;IACH,OAAO,CAAC,OAAO;IAgBf;;;OAGG;IACH,OAAO,CAAC,OAAO;CAoChB"}
|
package/build/core/executor.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options for executing a command.
|
|
3
|
-
*/
|
|
4
|
-
export interface ExecuteOptions {
|
|
5
|
-
/** The command binary to execute */
|
|
6
|
-
command: string;
|
|
7
|
-
/** Arguments to pass to the command */
|
|
8
|
-
args: string[];
|
|
9
|
-
/** Timeout in milliseconds (overrides default) */
|
|
10
|
-
timeout?: number;
|
|
11
|
-
/** Working directory for the command */
|
|
12
|
-
cwd?: string;
|
|
13
|
-
/** Additional environment variables */
|
|
14
|
-
env?: Record<string, string>;
|
|
15
|
-
/** Data to pipe to stdin (Buffer preferred for sensitive data like passwords) */
|
|
16
|
-
stdin?: string | Buffer;
|
|
17
|
-
/** Maximum output buffer size in bytes */
|
|
18
|
-
maxBuffer?: number;
|
|
19
|
-
/** Tool name for rate-limiting and timeout lookup (REQUIRED) */
|
|
20
|
-
toolName: string;
|
|
21
|
-
/** Skip automatic sudo credential injection (used internally) */
|
|
22
|
-
skipSudoInjection?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Skip auto-sudo wrapping for this command.
|
|
25
|
-
*
|
|
26
|
-
* When a SudoSession is active, `executeCommand()` automatically wraps
|
|
27
|
-
* non-sudo commands with `sudo` so credentials are injected transparently.
|
|
28
|
-
* Set this to `true` for commands that must NOT run as root (e.g.,
|
|
29
|
-
* user-level operations or sudo-session management itself).
|
|
30
|
-
*/
|
|
31
|
-
skipAutoSudo?: boolean;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Result of a command execution.
|
|
35
|
-
*/
|
|
36
|
-
export interface CommandResult {
|
|
37
|
-
/** Standard output content */
|
|
38
|
-
stdout: string;
|
|
39
|
-
/** Standard error content */
|
|
40
|
-
stderr: string;
|
|
41
|
-
/** Process exit code (124 on timeout) */
|
|
42
|
-
exitCode: number;
|
|
43
|
-
/** Whether the command was killed due to timeout */
|
|
44
|
-
timedOut: boolean;
|
|
45
|
-
/** Wall-clock duration in milliseconds */
|
|
46
|
-
duration: number;
|
|
47
|
-
/**
|
|
48
|
-
* Whether the command failed due to insufficient privileges.
|
|
49
|
-
* Detected by analyzing stderr/stdout against known permission error patterns.
|
|
50
|
-
* When `true`, the caller should prompt the user to call `sudo_elevate`.
|
|
51
|
-
*/
|
|
52
|
-
permissionDenied: boolean;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Executes a command safely using spawn with shell: false.
|
|
56
|
-
*
|
|
57
|
-
* - Transparently injects sudo credentials from SudoSession when available
|
|
58
|
-
* - Uses AbortController for timeout enforcement
|
|
59
|
-
* - Caps stdout/stderr buffers to maxBuffer
|
|
60
|
-
* - Tracks execution duration
|
|
61
|
-
* - Handles stdin piping
|
|
62
|
-
* - Catches spawn errors gracefully
|
|
63
|
-
*/
|
|
64
|
-
export declare function executeCommand(options: ExecuteOptions): Promise<CommandResult>;
|
|
65
|
-
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../src/core/executor.ts"],"names":[],"mappings":"AAmFA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,iFAAiF;IACjF,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,QAAQ,EAAE,OAAO,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AA0FD;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,CAoPxB"}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Category of a defensive tool.
|
|
3
|
-
*/
|
|
4
|
-
export type ToolCategory = "hardening" | "firewall" | "monitoring" | "assessment" | "network" | "access" | "access-control" | "encryption" | "container" | "malware" | "forensics" | "integrity" | "compliance" | "logging" | "supply-chain";
|
|
5
|
-
/**
|
|
6
|
-
* Package names per distribution family.
|
|
7
|
-
*/
|
|
8
|
-
export interface PackageNames {
|
|
9
|
-
debian?: string;
|
|
10
|
-
rhel?: string;
|
|
11
|
-
arch?: string;
|
|
12
|
-
alpine?: string;
|
|
13
|
-
suse?: string;
|
|
14
|
-
fallback?: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Requirements for a defensive tool.
|
|
18
|
-
*/
|
|
19
|
-
export interface ToolRequirement {
|
|
20
|
-
/** Human-readable tool name */
|
|
21
|
-
name: string;
|
|
22
|
-
/** Binary name to check for availability */
|
|
23
|
-
binary: string;
|
|
24
|
-
/** Package names per distribution */
|
|
25
|
-
packages: PackageNames;
|
|
26
|
-
/** Category of the tool */
|
|
27
|
-
category: ToolCategory;
|
|
28
|
-
/** Whether the tool is required (vs optional) */
|
|
29
|
-
required: boolean;
|
|
30
|
-
/** If this tool is an alternative for another */
|
|
31
|
-
alternativeFor?: string;
|
|
32
|
-
/**
|
|
33
|
-
* If true, this tool is NOT a standalone binary — it's a PAM module, library,
|
|
34
|
-
* or other non-binary dependency. Binary existence checks should be skipped;
|
|
35
|
-
* instead check for the package being installed (e.g. via dpkg -l).
|
|
36
|
-
*/
|
|
37
|
-
isPackageOnly?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* If true, this tool is NOT available in standard distro repos and requires
|
|
40
|
-
* third-party installation (manual download, external repo, npm global, etc.).
|
|
41
|
-
* The `thirdPartyInstallHint` field provides the install command.
|
|
42
|
-
*/
|
|
43
|
-
isThirdParty?: boolean;
|
|
44
|
-
/** Install command/instructions for third-party tools not in standard repos. */
|
|
45
|
-
thirdPartyInstallHint?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Known conflicts with other packages. If any of these packages are installed,
|
|
48
|
-
* this tool cannot be installed alongside them.
|
|
49
|
-
*/
|
|
50
|
-
conflictsWith?: string[];
|
|
51
|
-
/**
|
|
52
|
-
* Notes about availability, deprecation, or platform-specific issues.
|
|
53
|
-
*/
|
|
54
|
-
availabilityNote?: string;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Result of checking a tool's availability.
|
|
58
|
-
*/
|
|
59
|
-
export interface ToolCheckResult {
|
|
60
|
-
/** Tool requirement info */
|
|
61
|
-
tool: ToolRequirement;
|
|
62
|
-
/** Whether the tool is installed */
|
|
63
|
-
installed: boolean;
|
|
64
|
-
/** Detected version string (if available) */
|
|
65
|
-
version?: string;
|
|
66
|
-
/** Path to the binary (if found) */
|
|
67
|
-
path?: string;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Result of installing a tool.
|
|
71
|
-
*/
|
|
72
|
-
export interface InstallResult {
|
|
73
|
-
/** Tool requirement info */
|
|
74
|
-
tool: ToolRequirement;
|
|
75
|
-
/** Whether installation succeeded */
|
|
76
|
-
success: boolean;
|
|
77
|
-
/** Output/error message */
|
|
78
|
-
message: string;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Comprehensive list of defensive security tools across categories.
|
|
82
|
-
*/
|
|
83
|
-
export declare const DEFENSIVE_TOOLS: ToolRequirement[];
|
|
84
|
-
/**
|
|
85
|
-
* Checks whether a tool binary is available on the system.
|
|
86
|
-
* Uses the command allowlist (which already resolved paths via existsSync at
|
|
87
|
-
* startup) or falls back to probing standard binary directories with
|
|
88
|
-
* existsSync. This avoids shelling out to `which`, which is blocked by the
|
|
89
|
-
* command allowlist.
|
|
90
|
-
*/
|
|
91
|
-
export declare function checkTool(binary: string): Promise<{
|
|
92
|
-
installed: boolean;
|
|
93
|
-
version?: string;
|
|
94
|
-
path?: string;
|
|
95
|
-
}>;
|
|
96
|
-
/**
|
|
97
|
-
* Checks all defensive tools or a specific category.
|
|
98
|
-
*
|
|
99
|
-
* @param category Optional category to filter by
|
|
100
|
-
* @returns Array of check results
|
|
101
|
-
*/
|
|
102
|
-
export declare function checkAllTools(category?: ToolCategory): Promise<ToolCheckResult[]>;
|
|
103
|
-
/**
|
|
104
|
-
* Installs a tool using the detected distribution's package manager.
|
|
105
|
-
*
|
|
106
|
-
* @param tool Tool requirement to install
|
|
107
|
-
* @returns Installation result
|
|
108
|
-
*/
|
|
109
|
-
export declare function installTool(tool: ToolRequirement): Promise<InstallResult>;
|
|
110
|
-
/**
|
|
111
|
-
* Checks for missing tools and optionally installs them.
|
|
112
|
-
*
|
|
113
|
-
* @param category Optional category filter
|
|
114
|
-
* @param dryRun If true, only report what would be installed
|
|
115
|
-
* @returns Array of install results (or what would be installed)
|
|
116
|
-
*/
|
|
117
|
-
export declare function installMissing(category?: ToolCategory, dryRun?: boolean): Promise<InstallResult[]>;
|
|
118
|
-
/**
|
|
119
|
-
* Returns a human-readable install command for a given tool on the detected distro.
|
|
120
|
-
* E.g. "sudo apt install -y lynis"
|
|
121
|
-
*/
|
|
122
|
-
export declare function getInstallHint(tool: ToolRequirement): Promise<string | null>;
|
|
123
|
-
/**
|
|
124
|
-
* Builds a reverse lookup from alternativeFor: primary tool name → alternative tools.
|
|
125
|
-
* Used by the audit gate to skip blocking on a required tool when its alternative
|
|
126
|
-
* is installed.
|
|
127
|
-
*/
|
|
128
|
-
export declare function getAlternativesMap(): Map<string, ToolRequirement[]>;
|
|
129
|
-
//# sourceMappingURL=installer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../../src/core/installer.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,SAAS,GACT,QAAQ,GACR,gBAAgB,GAChB,YAAY,GACZ,WAAW,GACX,SAAS,GACT,WAAW,GACX,WAAW,GACX,YAAY,GACZ,SAAS,GACT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3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,eAAe,EAo9B5C,CAAC;AAYF;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAgDlE;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,QAAQ,CAAC,EAAE,YAAY,GACtB,OAAO,CAAC,eAAe,EAAE,CAAC,CAkB5B;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,aAAa,CAAC,CA0DxB;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,QAAQ,CAAC,EAAE,YAAY,EACvB,MAAM,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,aAAa,EAAE,CAAC,CAgC1B;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQlF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC,CAYnE"}
|
package/build/core/logger.d.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
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
|
-
* Optional file-based logging with size-based rotation via:
|
|
11
|
-
* DEFENSE_MCP_LOG_FILE=/path/to/logfile.json
|
|
12
|
-
* DEFENSE_MCP_LOG_MAX_SIZE=10485760 (10 MB default)
|
|
13
|
-
* DEFENSE_MCP_LOG_MAX_FILES=5 (keep 5 rotated files)
|
|
14
|
-
*
|
|
15
|
-
* @module logger
|
|
16
|
-
* @see CICD-027
|
|
17
|
-
*/
|
|
18
|
-
/** Supported log levels, ordered by severity (lowest to highest). */
|
|
19
|
-
export type LogLevel = "debug" | "info" | "warn" | "error" | "security";
|
|
20
|
-
/** A structured log entry written as JSON to stderr. */
|
|
21
|
-
export interface LogEntry {
|
|
22
|
-
/** ISO 8601 UTC timestamp */
|
|
23
|
-
timestamp: string;
|
|
24
|
-
/** Log severity level */
|
|
25
|
-
level: LogLevel;
|
|
26
|
-
/** Module or subsystem that produced the log (e.g., "preflight", "executor") */
|
|
27
|
-
component: string;
|
|
28
|
-
/** Action being performed (e.g., "tool_invoked", "sudo_elevated") */
|
|
29
|
-
action: string;
|
|
30
|
-
/** Human-readable message */
|
|
31
|
-
message: string;
|
|
32
|
-
/** Optional structured details (tool params, error info, metrics, etc.) */
|
|
33
|
-
details?: Record<string, unknown>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Structured logger that outputs JSON to stderr.
|
|
37
|
-
*
|
|
38
|
-
* Uses stderr so log output doesn't interfere with MCP protocol messages
|
|
39
|
-
* on stdout (StdioServerTransport).
|
|
40
|
-
*
|
|
41
|
-
* Optionally writes to a file with automatic size-based rotation when
|
|
42
|
-
* DEFENSE_MCP_LOG_FILE is set.
|
|
43
|
-
*
|
|
44
|
-
* Usage:
|
|
45
|
-
* ```typescript
|
|
46
|
-
* import { logger } from './logger.js';
|
|
47
|
-
*
|
|
48
|
-
* logger.info('preflight', 'cache_hit', 'Pre-flight cache hit for tool', { toolName: 'firewall_iptables' });
|
|
49
|
-
* logger.security('sudo-guard', 'elevation_requested', 'Sudo elevation requested', { tool: 'harden_sysctl' });
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare class Logger {
|
|
53
|
-
private minLevel;
|
|
54
|
-
private logFile;
|
|
55
|
-
private maxFileSize;
|
|
56
|
-
private maxFiles;
|
|
57
|
-
constructor(minLevel?: LogLevel);
|
|
58
|
-
/**
|
|
59
|
-
* Read the minimum log level from `DEFENSE_MCP_LOG_LEVEL` env var.
|
|
60
|
-
* Falls back to `"info"` if unset or invalid.
|
|
61
|
-
*/
|
|
62
|
-
private parseEnvLevel;
|
|
63
|
-
/** Check whether a message at `level` should be emitted. */
|
|
64
|
-
private shouldLog;
|
|
65
|
-
/**
|
|
66
|
-
* Write a log line to the file, with size-based rotation.
|
|
67
|
-
* This is best-effort — file write failures don't throw.
|
|
68
|
-
*/
|
|
69
|
-
private writeToFile;
|
|
70
|
-
/**
|
|
71
|
-
* Emit a structured log entry as a single JSON line to stderr.
|
|
72
|
-
*
|
|
73
|
-
* @param level - Severity level
|
|
74
|
-
* @param component - Subsystem name (e.g., "executor", "preflight")
|
|
75
|
-
* @param action - Action identifier (e.g., "command_executed", "cache_miss")
|
|
76
|
-
* @param message - Human-readable description
|
|
77
|
-
* @param details - Optional structured metadata
|
|
78
|
-
*/
|
|
79
|
-
log(level: LogLevel, component: string, action: string, message: string, details?: Record<string, unknown>): void;
|
|
80
|
-
/** Log a debug-level message. */
|
|
81
|
-
debug(component: string, action: string, message: string, details?: Record<string, unknown>): void;
|
|
82
|
-
/** Log an info-level message. */
|
|
83
|
-
info(component: string, action: string, message: string, details?: Record<string, unknown>): void;
|
|
84
|
-
/** Log a warning-level message. */
|
|
85
|
-
warn(component: string, action: string, message: string, details?: Record<string, unknown>): void;
|
|
86
|
-
/** Log an error-level message. */
|
|
87
|
-
error(component: string, action: string, message: string, details?: Record<string, unknown>): void;
|
|
88
|
-
/**
|
|
89
|
-
* Log a security-relevant event.
|
|
90
|
-
*
|
|
91
|
-
* Security events are **always** emitted regardless of the configured
|
|
92
|
-
* minimum log level. Use for:
|
|
93
|
-
* - Authentication / privilege escalation events
|
|
94
|
-
* - Policy violations
|
|
95
|
-
* - Rate limit breaches
|
|
96
|
-
* - Suspicious input patterns
|
|
97
|
-
* - Configuration changes with security impact
|
|
98
|
-
*/
|
|
99
|
-
security(component: string, action: string, message: string, details?: Record<string, unknown>): void;
|
|
100
|
-
/**
|
|
101
|
-
* Update the minimum log level at runtime.
|
|
102
|
-
* Useful for tests or dynamic configuration changes.
|
|
103
|
-
*/
|
|
104
|
-
setLevel(level: LogLevel): void;
|
|
105
|
-
/** Get the current minimum log level. */
|
|
106
|
-
getLevel(): LogLevel;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Default singleton logger instance.
|
|
110
|
-
*
|
|
111
|
-
* Import and use directly:
|
|
112
|
-
* ```typescript
|
|
113
|
-
* import { logger } from '../core/logger.js';
|
|
114
|
-
* logger.info('my-module', 'action', 'Something happened');
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
|
-
export declare const logger: Logger;
|
|
118
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAOH,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;AA6CD;;;;;;;;;;;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