@jishankai/solid-cli 1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 macOS Security Analysis CLI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,276 @@
1
+ # macOS System & Security Analysis Agent CLI (solid-cli)
2
+
3
+ A **local-first** macOS security and performance analysis CLI. It runs a unified, adaptive set of analysis agents on your machine and can (optionally) use an LLM (Claude or OpenAI) to generate structured recommendations.
4
+
5
+ > Note: LLM use is **optional**. When enabled, the CLI applies prompt sanitization and will **abort AI analysis** if sensitive patterns are detected.
6
+
7
+ ## 快速开始(Quick Start)
8
+
9
+ ```bash
10
+ # Run once (no install)
11
+ npx solid-cli
12
+
13
+ # Or install globally
14
+ npm install -g solid-cli
15
+ solid-cli
16
+
17
+ # Show help
18
+ solid-cli --help
19
+ ```
20
+
21
+ Optional (enable AI analysis):
22
+ ```bash
23
+ export ANTHROPIC_API_KEY=sk-ant-...
24
+ # or
25
+ export OPENAI_API_KEY=sk-...
26
+
27
+ solid-cli
28
+ ```
29
+
30
+ Reports are written to `./reports/<YYYY>/<Month>/` by default.
31
+
32
+ ## Features
33
+
34
+ - **Unified Adaptive Analysis**: runs a core set of agents every time, then conditionally expands analysis (e.g. blockchain/DeFi) when indicators are detected.
35
+ - **Core Security Coverage**:
36
+ - System integrity checks (SIP, Gatekeeper, updates)
37
+ - Persistence mechanism detection (LaunchAgents/LaunchDaemons, Login Items, crontab)
38
+ - Process analysis for suspicious activity
39
+ - Network connection analysis (optionally enriched with IP geolocation)
40
+ - Privacy permission auditing
41
+ - **Blockchain/DeFi Safety Add-on (adaptive)**: triggers wallet/DeFi threat checks only when crypto indicators are found.
42
+ - **Privacy-protected AI insights (optional)**:
43
+ - Provider auto-detection (Claude preferred when both keys exist)
44
+ - Prompt sanitization + sensitive-pattern blocking
45
+ - Threshold-based skipping when findings are below configured triggers
46
+ - **Professional Reports**: Markdown and/or PDF (Puppeteer) with templates.
47
+ - **Structured Logging**: operational logs under `./logs/`.
48
+
49
+ ## Architecture
50
+
51
+ ```
52
+ ┌─────────────┐
53
+ │ CLI UI │ inquirer + chalk
54
+ └─────┬───────┘
55
+
56
+ ┌─────▼────────────────────┐
57
+ │ Orchestrator (Unified) │ Phase 1 core + Phase 2 adaptive
58
+ └─────┬────────────────────┘
59
+
60
+ ┌────▼────┐ ┌───────────────▼───────────────┐
61
+ │ Core │ │ Adaptive Agents (conditional) │
62
+ │ Agents │ │ Blockchain / DeFi │
63
+ └────┬────┘ └───────────────┬───────────────┘
64
+ │ │
65
+ ┌─────▼───────────┐ ┌─────▼───────────┐
66
+ │ LLM Analyzer │ │ Report Manager │
67
+ │ (optional) │ │ Markdown / PDF │
68
+ └──────────────────┘ └─────────────────┘
69
+ ```
70
+
71
+ ## Requirements
72
+
73
+ - **macOS** 10.15 or later
74
+ - **Node.js** 20.0 or later
75
+ - **API Keys** (optional): Anthropic Claude and/or OpenAI
76
+
77
+ ## Installation
78
+
79
+ ### Install from npm
80
+
81
+ ```bash
82
+ npm install -g solid-cli
83
+ solid-cli
84
+ ```
85
+
86
+ Run once without installing:
87
+ ```bash
88
+ npx solid-cli
89
+ ```
90
+
91
+ ### Local development
92
+
93
+ ```bash
94
+ npm install
95
+ npm start
96
+ ```
97
+
98
+ Optional: make the entry executable:
99
+ ```bash
100
+ chmod +x src/index.js
101
+ ```
102
+
103
+ ## Usage
104
+
105
+ Run the interactive CLI:
106
+
107
+ ```bash
108
+ solid-cli
109
+ # or, in this repo
110
+ npm start
111
+ ```
112
+
113
+ Show help:
114
+ ```bash
115
+ solid-cli --help
116
+ # or
117
+ npm start -- --help
118
+ ```
119
+
120
+ ### What the CLI will ask (current flow)
121
+
122
+ 1. **LLM auto-detection** (no manual provider picker)
123
+ - If `ANTHROPIC_API_KEY` is present, the CLI uses **Claude**.
124
+ - Else if `OPENAI_API_KEY` is present, it uses **OpenAI**.
125
+ - Else it runs **report-only**.
126
+ 2. **AI analysis option**: you can still choose **AI analysis** or **report-only**.
127
+ 3. **Report format**: PDF or Markdown.
128
+ 4. **IP geolocation**: controlled by config (`security.enableGeoLookup`) and shown in the run summary.
129
+ 5. Analysis starts automatically (no extra confirmation prompt).
130
+
131
+ ### Report output
132
+
133
+ - Default output root: `./reports` (configurable via `reports.outputDir`).
134
+ - Directory layout: `./reports/<YYYY>/<Month>/`
135
+ - Filenames:
136
+ - `Security-Report-<REPORT_ID>.md`
137
+ - `Security-Report-<REPORT_ID>.pdf`
138
+ - `metadata-<YYYY-MM-DD>.json`
139
+
140
+ ### Example run (illustrative)
141
+
142
+ ```text
143
+ $ solid-cli
144
+
145
+ ✅ Claude (Anthropic) - API key detected
146
+ ? 🤖 AI Analysis Option: (Use arrow keys)
147
+ 🧠 Use AI Analysis (CLAUDE) - Enhanced insights & recommendations
148
+ 📋 Generate Security Report Only - Maximum privacy protection
149
+
150
+ ? Select report format: PDF (.pdf)
151
+ ✅ IP geolocation enabled
152
+
153
+ 🔍 Starting unified adaptive analysis...
154
+
155
+ Phase 1: Core Security Analysis
156
+ ✓ ResourceAgent completed - Risk: LOW
157
+ ✓ SystemAgent completed - Risk: MEDIUM
158
+ ...
159
+
160
+ Phase 2: Adaptive Analysis
161
+ No blockchain indicators detected - skipping blockchain analysis
162
+
163
+ 📁 Saved Reports:
164
+ 📑 Pdf: reports/2025/December/Security-Report-RPT-XXXXXX.pdf
165
+ ```
166
+
167
+ ## Agents
168
+
169
+ ### Core agents (always run)
170
+
171
+ - `ResourceAgent`: CPU/memory/process resource usage heuristics.
172
+ - `SystemAgent`: SIP/Gatekeeper/updates and other system posture checks.
173
+ - `PersistenceAgent`: LaunchAgents/LaunchDaemons/Login Items/crontab.
174
+ - `ProcessAgent`: suspicious process patterns (paths, elevation, obfuscation).
175
+ - `NetworkAgent`: network connections and listening ports; optional IP geolocation enrichment.
176
+ - `PermissionAgent`: privacy permission auditing.
177
+
178
+ ### Adaptive agents (only run when indicators are detected)
179
+
180
+ - `BlockchainAgent`: wallet processes/files, wallet-like browser extensions, mining indicators, and blockchain/DeFi network patterns.
181
+ - `DeFiSecurityAgent`: DeFi scam indicators (processes/download metadata/network) with privacy-protective behavior (no clipboard or browser-history content extraction).
182
+
183
+ ## Configuration
184
+
185
+ This project uses the `config` (node-config) package.
186
+
187
+ - Defaults ship in `config/default.json`.
188
+ - You can override settings by providing your own config directory in one of these ways:
189
+ - Create `./config/local.json` in the directory where you run `solid-cli`.
190
+ - Or set `NODE_CONFIG_DIR` to a custom config folder.
191
+
192
+ Common settings:
193
+
194
+ - `reports.outputDir`: report output directory (default `./reports`).
195
+ - `analysis.parallelExecution` and `analysis.maxParallelAgents`: speed vs. load tradeoff.
196
+ - `security.enableGeoLookup` and `security.geoLookupLimit`: IP geolocation enrichment behavior.
197
+ - `llm.mode`: prompt mode (`summary` / `full`).
198
+ - `llm.minHighRiskFindings`, `llm.minTotalFindings`, `llm.skipWhenBelowThreshold`: when AI analysis should run.
199
+
200
+ ## AI / LLM behavior (privacy-protected)
201
+
202
+ - **Provider auto-detection priority**: Claude → OpenAI → none.
203
+ - Before any LLM call, the CLI:
204
+ - builds a prompt from analysis results,
205
+ - runs a **sensitive pattern scan**,
206
+ - and **skips AI analysis** (and records details into report metadata) if sensitive patterns are detected.
207
+ - When AI analysis runs, request/response payloads are logged under `./logs/llm-requests/`.
208
+
209
+ ## Security Considerations
210
+
211
+ - **No Root Required**: checks run with user permissions.
212
+ - **Local-First**: analysis runs locally; AI is optional.
213
+ - **Read-only**: the tool does not modify system settings.
214
+ - **LLM Safety**: sensitive pattern detection can prevent accidental leakage of keys/tokens.
215
+
216
+ ## Troubleshooting
217
+
218
+ ### Permission prompts / incomplete results
219
+
220
+ Some checks may be limited without:
221
+ - **Full Disk Access** (e.g. some system databases)
222
+ - **Accessibility** (some process visibility)
223
+
224
+ ### PDF generation fails
225
+
226
+ PDF uses Puppeteer. If Chromium cannot launch:
227
+ - reinstall dependencies so Puppeteer can fetch Chromium, or
228
+ - set `PUPPETEER_EXECUTABLE_PATH` to a local Chrome/Chromium.
229
+
230
+ ## Development
231
+
232
+ ### Project Structure
233
+
234
+ ```text
235
+ solid-cli/
236
+ ├── config/
237
+ │ └── default.json # node-config defaults
238
+ ├── src/
239
+ │ ├── agents/ # analysis agents
240
+ │ ├── config/ConfigManager.js # config access/validation
241
+ │ ├── llm/LLMAnalyzer.js # LLM prompt building + safety checks
242
+ │ ├── logging/Logger.js # structured logging
243
+ │ ├── report/ # report generation (Handlebars + Puppeteer)
244
+ │ ├── utils/ # shell helpers, signatures, etc.
245
+ │ ├── Orchestrator.js # unified adaptive runner
246
+ │ └── index.js # CLI entry point
247
+ ├── reports/ # generated reports (gitignored typically)
248
+ ├── logs/ # generated logs (gitignored typically)
249
+ └── README.md
250
+ ```
251
+
252
+ ### Adding custom agents
253
+
254
+ 1. Create a new agent extending `BaseAgent` and implement `analyze()`.
255
+ 2. Register it in `src/Orchestrator.js` (core or conditional).
256
+
257
+ ## Publishing to npm (maintainers)
258
+
259
+ 1. Update `package.json` metadata (name/scope, version, repository, bugs, homepage).
260
+ 2. Clean artifacts: remove generated `logs/` and `reports/` before packing.
261
+ 3. Verify package contents: `npm pack --dry-run`.
262
+ 4. Smoke tests (non-interactive helpers):
263
+ - `node src/index.js --help`
264
+ - `node test-llm-choice.js`
265
+ - `node test-llm-blocking.js`
266
+ - `node test-llm-privacy.js`
267
+ - `node test-blockchain.js`
268
+ 5. Publish: `npm publish --access public`.
269
+
270
+ ## License
271
+
272
+ MIT License - see `LICENSE`.
273
+
274
+ ## Disclaimer
275
+
276
+ This tool is for legitimate security analysis and system auditing only. Users are responsible for compliance with applicable laws and regulations. The authors assume no liability for misuse.
@@ -0,0 +1,79 @@
1
+ {
2
+ "analysis": {
3
+ "defaultDepth": "comprehensive",
4
+ "adaptiveMode": true,
5
+ "blockchainDetection": true,
6
+ "deepForensicsThreshold": "medium",
7
+ "parallelExecution": true,
8
+ "maxParallelAgents": 3
9
+ },
10
+ "reports": {
11
+ "outputDir": "./reports",
12
+ "retentionDays": 90,
13
+ "defaultTemplate": "executive",
14
+ "defaultFormats": ["markdown", "pdf"],
15
+ "pdfOptions": {
16
+ "format": "A4",
17
+ "margin": "2cm",
18
+ "displayHeaderFooter": true,
19
+ "printBackground": true
20
+ },
21
+ "includeScreenshots": false,
22
+ "compressOldReports": true
23
+ },
24
+ "logging": {
25
+ "level": "info",
26
+ "consoleLevel": "warn",
27
+ "enableConsole": true,
28
+ "enableFiles": true,
29
+ "logDir": "./logs",
30
+ "maxFileSize": "20m",
31
+ "maxFiles": "14d",
32
+ "securityLogRetention": "30d"
33
+ },
34
+ "llm": {
35
+ "autoDetectProvider": true,
36
+ "enableLogging": true,
37
+ "logDir": "./logs/llm-requests",
38
+ "privacyLevel": "high",
39
+ "maxTokens": 4000,
40
+ "temperature": 0.1,
41
+ "mode": "full",
42
+ "minHighRiskFindings": 0,
43
+ "minTotalFindings": 0,
44
+ "skipWhenBelowThreshold": false
45
+ },
46
+ "privacy": {
47
+ "redactUserPaths": true,
48
+ "redactUsernames": true,
49
+ "redactIPs": false,
50
+ "preserveDomains": true,
51
+ "sanitizationLevel": "high"
52
+ },
53
+ "performance": {
54
+ "enableMetrics": true,
55
+ "slowQueryThreshold": 5000,
56
+ "memoryThreshold": 1024,
57
+ "enableProfiling": false
58
+ },
59
+ "security": {
60
+ "enableGeoLookup": true,
61
+ "geoLookupLimit": 10,
62
+ "trustedPaths": [
63
+ "/System",
64
+ "/usr/bin",
65
+ "/usr/sbin",
66
+ "/bin",
67
+ "/sbin",
68
+ "/Applications"
69
+ ],
70
+ "riskyPorts": [
71
+ 22, 23, 135, 139, 445, 1433, 3389, 5432, 6379, 27017, 8080, 8443
72
+ ]
73
+ },
74
+ "compliance": {
75
+ "frameworks": ["NIST CSF", "ISO 27001", "SOC 2"],
76
+ "enableMapping": true,
77
+ "reportCompliance": true
78
+ }
79
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@jishankai/solid-cli",
3
+ "version": "1.0.0",
4
+ "description": "MacOS System & Security Analysis Agent CLI with LLM-powered insights",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "bin": {
8
+ "solid-cli": "./src/index.js"
9
+ },
10
+ "files": [
11
+ "src",
12
+ "config/default.json",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "start": "node src/index.js",
18
+ "dev": "node --watch src/index.js"
19
+ },
20
+ "keywords": [
21
+ "macos",
22
+ "security",
23
+ "analysis",
24
+ "cli",
25
+ "agent",
26
+ "llm",
27
+ "auditing",
28
+ "forensics"
29
+ ],
30
+ "author": "Kai <jishankai@gmail.com>",
31
+ "license": "MIT",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/your-org/solid-cli.git"
35
+ },
36
+ "bugs": {
37
+ "url": "https://github.com/your-org/solid-cli/issues"
38
+ },
39
+ "homepage": "https://github.com/your-org/solid-cli#readme",
40
+ "dependencies": {
41
+ "@anthropic-ai/sdk": "^0.30.0",
42
+ "chalk": "^5.3.0",
43
+ "config": "^4.1.1",
44
+ "execa": "^9.5.2",
45
+ "handlebars": "^4.7.8",
46
+ "inquirer": "^12.2.0",
47
+ "joi": "^18.0.2",
48
+ "openai": "^4.77.3",
49
+ "ora": "^8.1.1",
50
+ "puppeteer": "^24.34.0",
51
+ "winston": "^3.19.0",
52
+ "winston-daily-rotate-file": "^5.0.0"
53
+ },
54
+ "engines": {
55
+ "node": ">=20.0.0"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ }
60
+ }