shellward 0.6.4 → 0.6.6
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/README.md +3 -1
- package/dist/cli.js +2 -2
- package/dist/compliance/audit.d.ts +10 -1
- package/dist/compliance/audit.js +11 -4
- package/dist/compliance/project-scan.js +0 -0
- package/package.json +1 -1
- package/src/cli.ts +2 -2
- package/src/compliance/audit.ts +22 -4
- package/src/compliance/project-scan.ts +0 -0
package/README.md
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/shellward)
|
|
10
10
|
[](./LICENSE)
|
|
11
|
-
[](#performance)
|
|
12
12
|
[](#performance)
|
|
13
13
|
|
|
14
|
+
**🌐 Website: https://jnmetacode.github.io/shellward/**
|
|
15
|
+
|
|
14
16
|
[English](#demo) | [中文](#中文)
|
|
15
17
|
|
|
16
18
|
## 30-Second Compliance Scan
|
package/dist/cli.js
CHANGED
|
@@ -95,8 +95,8 @@ function runScan(args) {
|
|
|
95
95
|
body,
|
|
96
96
|
'',
|
|
97
97
|
zh
|
|
98
|
-
? '💡
|
|
99
|
-
: '💡 Read-only scan, nothing uploaded.
|
|
98
|
+
? '💡 只读扫描、不上传任何数据。得分仅反映本次可静态观测的项目风险;⚪ 待确认项需把 ShellWard 作为 MCP/插件部署为运行时防护,或人工核验后才能满足。'
|
|
99
|
+
: '💡 Read-only scan, nothing uploaded. The score reflects only statically-observable project risk; ⚪ items require deploying ShellWard as a runtime guard (MCP/plugin) or manual review.',
|
|
100
100
|
];
|
|
101
101
|
process.stdout.write(out.join('\n') + '\n');
|
|
102
102
|
}
|
|
@@ -39,12 +39,21 @@ export interface ComplianceReport {
|
|
|
39
39
|
}
|
|
40
40
|
/** 采集真实环境事实(运行时调用;测试可绕过直接注入 EnvFacts) */
|
|
41
41
|
export declare function gatherEnvFacts(): EnvFacts;
|
|
42
|
+
export interface AuditOptions {
|
|
43
|
+
/**
|
|
44
|
+
* ShellWard 是否作为运行时防护已部署。
|
|
45
|
+
* - true(默认):MCP / 插件上下文,能力层确实在运行,如实评估
|
|
46
|
+
* - false:CLI 静态扫描,未部署运行时 —— 能力/审计类控制项标为顾问态,不虚报"已启用"
|
|
47
|
+
*/
|
|
48
|
+
deployed?: boolean;
|
|
49
|
+
}
|
|
42
50
|
/**
|
|
43
51
|
* 运行合规体检。
|
|
44
52
|
* @param config ShellWard 当前配置
|
|
45
53
|
* @param facts 环境事实;不传则从真实环境采集
|
|
54
|
+
* @param opts 评估上下文(是否已部署运行时)
|
|
46
55
|
*/
|
|
47
|
-
export declare function runComplianceAudit(config: ShellWardConfig, facts?: EnvFacts): ComplianceReport;
|
|
56
|
+
export declare function runComplianceAudit(config: ShellWardConfig, facts?: EnvFacts, opts?: AuditOptions): ComplianceReport;
|
|
48
57
|
export interface ProjectComplianceResult {
|
|
49
58
|
report: ComplianceReport;
|
|
50
59
|
scan: ProjectScanResult;
|
package/dist/compliance/audit.js
CHANGED
|
@@ -67,10 +67,12 @@ function extractTs(line) {
|
|
|
67
67
|
* 运行合规体检。
|
|
68
68
|
* @param config ShellWard 当前配置
|
|
69
69
|
* @param facts 环境事实;不传则从真实环境采集
|
|
70
|
+
* @param opts 评估上下文(是否已部署运行时)
|
|
70
71
|
*/
|
|
71
|
-
export function runComplianceAudit(config, facts) {
|
|
72
|
+
export function runComplianceAudit(config, facts, opts) {
|
|
72
73
|
const env = facts ?? gatherEnvFacts();
|
|
73
|
-
const
|
|
74
|
+
const deployed = opts?.deployed ?? true;
|
|
75
|
+
const results = COMPLIANCE_CONTROLS.map(c => checkControl(c, config, env, deployed));
|
|
74
76
|
let passed = 0, warned = 0, failed = 0, manual = 0;
|
|
75
77
|
for (const r of results) {
|
|
76
78
|
if (r.status === 'pass')
|
|
@@ -116,7 +118,8 @@ export function runProjectComplianceAudit(config, root) {
|
|
|
116
118
|
provider_en: f.provider_en,
|
|
117
119
|
});
|
|
118
120
|
}
|
|
119
|
-
|
|
121
|
+
// CLI 静态扫描:未部署运行时 → 能力/审计类不虚报"已启用",只如实评估项目证据
|
|
122
|
+
const report = runComplianceAudit(config, env, { deployed: false });
|
|
120
123
|
// 发现驱动评分:项目实测风险按严重度扣分(封顶 40),使分数反映"你的真实风险"
|
|
121
124
|
const penalty = computeProjectPenalty(scan);
|
|
122
125
|
if (penalty > 0) {
|
|
@@ -134,7 +137,11 @@ function computeProjectPenalty(scan) {
|
|
|
134
137
|
p += FINDING_PENALTY[f.severity];
|
|
135
138
|
return Math.min(MAX_PROJECT_PENALTY, p);
|
|
136
139
|
}
|
|
137
|
-
function checkControl(c, config, env) {
|
|
140
|
+
function checkControl(c, config, env, deployed) {
|
|
141
|
+
// 静态扫描(未部署运行时)下,能力层/审计日志类控制项无法验证 —— 标为顾问态,绝不虚报"已合规"
|
|
142
|
+
if (!deployed && (c.method === 'capability' || c.method === 'config' || c.method === 'audit')) {
|
|
143
|
+
return mk(c, 'manual', `ShellWard 运行时可提供此防护;当前为静态扫描、未部署,无法验证。整改:${c.remediation_zh}`, `Provided by ShellWard runtime; not verifiable in a static scan. ${c.remediation_en}`);
|
|
144
|
+
}
|
|
138
145
|
switch (c.method) {
|
|
139
146
|
case 'capability': return checkCapability(c, config);
|
|
140
147
|
case 'config': return checkConfig(c, config);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shellward",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
4
4
|
"mcpName": "io.github.jnMetaCode/shellward",
|
|
5
5
|
"description": "AI agent security & MCP security middleware — prompt injection detection, AI firewall, runtime guardrails & data-loss prevention for LLM tool calls. 8-layer defense against data exfiltration & dangerous commands. Zero dependencies. SDK + OpenClaw plugin. Supports LangChain, AutoGPT, Claude Code, Cursor, OpenAI Agents, Hermes Agent.",
|
|
6
6
|
"keywords": [
|
package/src/cli.ts
CHANGED
|
@@ -103,8 +103,8 @@ function runScan(args: string[]) {
|
|
|
103
103
|
body,
|
|
104
104
|
'',
|
|
105
105
|
zh
|
|
106
|
-
? '💡
|
|
107
|
-
: '💡 Read-only scan, nothing uploaded.
|
|
106
|
+
? '💡 只读扫描、不上传任何数据。得分仅反映本次可静态观测的项目风险;⚪ 待确认项需把 ShellWard 作为 MCP/插件部署为运行时防护,或人工核验后才能满足。'
|
|
107
|
+
: '💡 Read-only scan, nothing uploaded. The score reflects only statically-observable project risk; ⚪ items require deploying ShellWard as a runtime guard (MCP/plugin) or manual review.',
|
|
108
108
|
]
|
|
109
109
|
process.stdout.write(out.join('\n') + '\n')
|
|
110
110
|
}
|
package/src/compliance/audit.ts
CHANGED
|
@@ -113,14 +113,25 @@ function extractTs(line: string): string | undefined {
|
|
|
113
113
|
return m?.[1]
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
export interface AuditOptions {
|
|
117
|
+
/**
|
|
118
|
+
* ShellWard 是否作为运行时防护已部署。
|
|
119
|
+
* - true(默认):MCP / 插件上下文,能力层确实在运行,如实评估
|
|
120
|
+
* - false:CLI 静态扫描,未部署运行时 —— 能力/审计类控制项标为顾问态,不虚报"已启用"
|
|
121
|
+
*/
|
|
122
|
+
deployed?: boolean
|
|
123
|
+
}
|
|
124
|
+
|
|
116
125
|
/**
|
|
117
126
|
* 运行合规体检。
|
|
118
127
|
* @param config ShellWard 当前配置
|
|
119
128
|
* @param facts 环境事实;不传则从真实环境采集
|
|
129
|
+
* @param opts 评估上下文(是否已部署运行时)
|
|
120
130
|
*/
|
|
121
|
-
export function runComplianceAudit(config: ShellWardConfig, facts?: EnvFacts): ComplianceReport {
|
|
131
|
+
export function runComplianceAudit(config: ShellWardConfig, facts?: EnvFacts, opts?: AuditOptions): ComplianceReport {
|
|
122
132
|
const env = facts ?? gatherEnvFacts()
|
|
123
|
-
const
|
|
133
|
+
const deployed = opts?.deployed ?? true
|
|
134
|
+
const results: ControlResult[] = COMPLIANCE_CONTROLS.map(c => checkControl(c, config, env, deployed))
|
|
124
135
|
|
|
125
136
|
let passed = 0, warned = 0, failed = 0, manual = 0
|
|
126
137
|
for (const r of results) {
|
|
@@ -170,7 +181,8 @@ export function runProjectComplianceAudit(config: ShellWardConfig, root: string)
|
|
|
170
181
|
})
|
|
171
182
|
}
|
|
172
183
|
|
|
173
|
-
|
|
184
|
+
// CLI 静态扫描:未部署运行时 → 能力/审计类不虚报"已启用",只如实评估项目证据
|
|
185
|
+
const report = runComplianceAudit(config, env, { deployed: false })
|
|
174
186
|
|
|
175
187
|
// 发现驱动评分:项目实测风险按严重度扣分(封顶 40),使分数反映"你的真实风险"
|
|
176
188
|
const penalty = computeProjectPenalty(scan)
|
|
@@ -192,7 +204,13 @@ function computeProjectPenalty(scan: ProjectScanResult): number {
|
|
|
192
204
|
return Math.min(MAX_PROJECT_PENALTY, p)
|
|
193
205
|
}
|
|
194
206
|
|
|
195
|
-
function checkControl(c: ComplianceControl, config: ShellWardConfig, env: EnvFacts): ControlResult {
|
|
207
|
+
function checkControl(c: ComplianceControl, config: ShellWardConfig, env: EnvFacts, deployed: boolean): ControlResult {
|
|
208
|
+
// 静态扫描(未部署运行时)下,能力层/审计日志类控制项无法验证 —— 标为顾问态,绝不虚报"已合规"
|
|
209
|
+
if (!deployed && (c.method === 'capability' || c.method === 'config' || c.method === 'audit')) {
|
|
210
|
+
return mk(c, 'manual',
|
|
211
|
+
`ShellWard 运行时可提供此防护;当前为静态扫描、未部署,无法验证。整改:${c.remediation_zh}`,
|
|
212
|
+
`Provided by ShellWard runtime; not verifiable in a static scan. ${c.remediation_en}`)
|
|
213
|
+
}
|
|
196
214
|
switch (c.method) {
|
|
197
215
|
case 'capability': return checkCapability(c, config)
|
|
198
216
|
case 'config': return checkConfig(c, config)
|
|
Binary file
|