@panguard-ai/panguard-skill-auditor 1.2.3 → 1.3.1
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.
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Analyzes what tools and permissions a skill requires based on its instructions.
|
|
6
6
|
* 根據技能指令分析其需要的工具和權限。
|
|
7
|
+
*
|
|
8
|
+
* v1.4: Runs patterns against prose only (code blocks + negation sections stripped)
|
|
9
|
+
* to avoid false positives from documentation examples.
|
|
7
10
|
*/
|
|
8
11
|
import type { SkillManifest, CheckResult } from '../types.js';
|
|
9
12
|
export declare function checkPermissions(manifest: SkillManifest): CheckResult;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-check.d.ts","sourceRoot":"","sources":["../../src/checks/permission-check.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"permission-check.d.ts","sourceRoot":"","sources":["../../src/checks/permission-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAgB,WAAW,EAAE,MAAM,aAAa,CAAC;AAkG5E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,WAAW,CAuDrE"}
|
|
@@ -4,11 +4,16 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Analyzes what tools and permissions a skill requires based on its instructions.
|
|
6
6
|
* 根據技能指令分析其需要的工具和權限。
|
|
7
|
+
*
|
|
8
|
+
* v1.4: Runs patterns against prose only (code blocks + negation sections stripped)
|
|
9
|
+
* to avoid false positives from documentation examples.
|
|
7
10
|
*/
|
|
11
|
+
import { prepareContent } from '@panguard-ai/scan-core';
|
|
8
12
|
const TOOL_PATTERNS = [
|
|
9
13
|
{
|
|
10
14
|
name: 'Bash/Shell',
|
|
11
|
-
|
|
15
|
+
// Only match explicit shell execution intent, not mere mention of "terminal"
|
|
16
|
+
regex: /\b(bash\s+-[ci]|sh\s+-c|execute.*command|run.*command|shell\s+command|spawn\s+shell)\b/i,
|
|
12
17
|
risk: 'high',
|
|
13
18
|
reason: 'Can execute arbitrary system commands',
|
|
14
19
|
},
|
|
@@ -20,33 +25,42 @@ const TOOL_PATTERNS = [
|
|
|
20
25
|
},
|
|
21
26
|
{
|
|
22
27
|
name: 'File Read',
|
|
23
|
-
regex: /\b(read.*file|
|
|
28
|
+
regex: /\b(read.*file|open.*file|load.*from)\b/i,
|
|
24
29
|
risk: 'low',
|
|
25
30
|
reason: 'Can read files from disk',
|
|
26
31
|
},
|
|
27
32
|
{
|
|
28
33
|
name: 'Network/HTTP',
|
|
29
|
-
regex: /\b(
|
|
34
|
+
regex: /\b(http\s+request|api\s+call|download|upload)\b/i,
|
|
30
35
|
risk: 'medium',
|
|
31
36
|
reason: 'Can make network requests',
|
|
32
37
|
},
|
|
33
38
|
{
|
|
34
39
|
name: 'Browser',
|
|
35
|
-
regex: /\b(
|
|
40
|
+
regex: /\b(open.*url|navigate.*to|web.*scrape|playwright|puppeteer|headless\s+browser)\b/i,
|
|
36
41
|
risk: 'medium',
|
|
37
42
|
reason: 'Can open URLs and interact with web pages',
|
|
38
43
|
},
|
|
39
44
|
{
|
|
40
45
|
name: 'Database',
|
|
41
|
-
|
|
46
|
+
// Only match explicit DB operations, not generic words like "update" or "query"
|
|
47
|
+
regex: /\b(SELECT\s+.*\s+FROM|INSERT\s+INTO|CREATE\s+TABLE|DROP\s+TABLE|ALTER\s+TABLE|db\.(query|execute|run)|mongodb|postgres(?:ql)?|mysql|sqlite|supabase|prisma|drizzle)\b/i,
|
|
42
48
|
risk: 'high',
|
|
43
49
|
reason: 'Can access and modify database contents',
|
|
44
50
|
},
|
|
45
51
|
{
|
|
46
52
|
name: 'Credentials',
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
53
|
+
// Only match credential theft/access patterns, not mere mention of "token" or "auth"
|
|
54
|
+
regex: /\b(steal\s+.*(?:key|token|credential)|harvest\s+.*(?:password|secret)|exfiltrate\s+.*(?:credential|token)|dump\s+.*(?:password|secret))\b/i,
|
|
55
|
+
risk: 'high',
|
|
56
|
+
reason: 'Attempts to steal or exfiltrate credentials',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'Credential Handling',
|
|
60
|
+
// Separate lower-risk pattern for skills that legitimately handle credentials
|
|
61
|
+
regex: /\b(api[_\s]?key|password|secret[_\s]?key|credential)\b/i,
|
|
62
|
+
risk: 'low',
|
|
63
|
+
reason: 'Handles credentials (verify they are used appropriately)',
|
|
50
64
|
},
|
|
51
65
|
{
|
|
52
66
|
name: 'SSH/Keys',
|
|
@@ -74,33 +88,24 @@ const TOOL_PATTERNS = [
|
|
|
74
88
|
},
|
|
75
89
|
{
|
|
76
90
|
name: 'Clipboard',
|
|
77
|
-
regex: /\b(pbpaste|pbcopy|xclip|xsel
|
|
91
|
+
regex: /\b(pbpaste|pbcopy|xclip|xsel)\b/i,
|
|
78
92
|
risk: 'medium',
|
|
79
93
|
reason: 'Can access or modify clipboard contents',
|
|
80
94
|
},
|
|
81
95
|
];
|
|
82
96
|
export function checkPermissions(manifest) {
|
|
83
97
|
const findings = [];
|
|
84
|
-
const
|
|
98
|
+
const { prose } = prepareContent(manifest.instructions);
|
|
85
99
|
const detectedTools = [];
|
|
86
100
|
for (const pattern of TOOL_PATTERNS) {
|
|
87
|
-
if (pattern.regex.test(
|
|
101
|
+
if (pattern.regex.test(prose)) {
|
|
88
102
|
detectedTools.push({ name: pattern.name, risk: pattern.risk });
|
|
89
|
-
if (pattern.risk
|
|
90
|
-
findings.push({
|
|
91
|
-
id: `perm-${pattern.name.toLowerCase().replace(/[^a-z]/g, '-')}`,
|
|
92
|
-
title: `Skill uses ${pattern.name} (${pattern.risk} risk)`,
|
|
93
|
-
description: pattern.reason,
|
|
94
|
-
severity: 'high',
|
|
95
|
-
category: 'permission',
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
else if (pattern.risk === 'medium') {
|
|
103
|
+
if (pattern.risk !== 'low') {
|
|
99
104
|
findings.push({
|
|
100
105
|
id: `perm-${pattern.name.toLowerCase().replace(/[^a-z]/g, '-')}`,
|
|
101
106
|
title: `Skill uses ${pattern.name} (${pattern.risk} risk)`,
|
|
102
107
|
description: pattern.reason,
|
|
103
|
-
severity: 'medium',
|
|
108
|
+
severity: pattern.risk === 'high' ? 'high' : 'medium',
|
|
104
109
|
category: 'permission',
|
|
105
110
|
});
|
|
106
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission-check.js","sourceRoot":"","sources":["../../src/checks/permission-check.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"permission-check.js","sourceRoot":"","sources":["../../src/checks/permission-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AASxD,MAAM,aAAa,GAAkB;IACnC;QACE,IAAI,EAAE,YAAY;QAClB,6EAA6E;QAC7E,KAAK,EAAE,yFAAyF;QAChG,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,uCAAuC;KAChD;IACD;QACE,IAAI,EAAE,YAAY;QAClB,KAAK,EAAE,0DAA0D;QACjE,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,0BAA0B;KACnC;IACD;QACE,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,yCAAyC;QAChD,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,0BAA0B;KACnC;IACD;QACE,IAAI,EAAE,cAAc;QACpB,KAAK,EAAE,kDAAkD;QACzD,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,2BAA2B;KACpC;IACD;QACE,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,mFAAmF;QAC1F,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,2CAA2C;KACpD;IACD;QACE,IAAI,EAAE,UAAU;QAChB,gFAAgF;QAChF,KAAK,EACH,wKAAwK;QAC1K,IAAI,EA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AG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;IAEnD,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,KAAK,GACT,aAAa,CAAC,MAAM,GAAG,CAAC;QACtB,CAAC,CAAC,qBAAqB,SAAS,EAAE;QAClC,CAAC,CAAC,6CAA6C,CAAC;IAEpD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panguard-ai/panguard-skill-auditor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"js-yaml": "^4.1.0",
|
|
33
|
-
"@panguard-ai/scan-core": "
|
|
34
|
-
"@panguard-ai/
|
|
35
|
-
"@panguard-ai/
|
|
36
|
-
"@panguard-ai/
|
|
33
|
+
"@panguard-ai/scan-core": "1.3.1",
|
|
34
|
+
"@panguard-ai/atr": "1.3.0",
|
|
35
|
+
"@panguard-ai/core": "1.3.0",
|
|
36
|
+
"@panguard-ai/panguard-scan": "1.3.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/js-yaml": "^4.0.9",
|