asterscanner 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/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # asterscanner
2
+
3
+ Security scanner for AI agent skills. Provides pattern-based security scanning and scoring for skill packages before they are published to the [ask](https://joinasterism.com) registry.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install asterscanner
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { scan } from "asterscanner";
15
+
16
+ const content = `
17
+ # My Skill
18
+
19
+ Instructions for my skill...
20
+ `;
21
+
22
+ const result = scan(content);
23
+ console.log(`Score: ${result.score}/100`);
24
+ console.log(`Passed: ${result.passed}`);
25
+ console.log(`Issues: ${result.issues.length}`);
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ### Basic Scanning
31
+
32
+ ```typescript
33
+ import { Scanner, createScanner, scan } from "asterscanner";
34
+
35
+ // Quick function
36
+ const result = scan(content);
37
+
38
+ // Or create a reusable scanner instance
39
+ const scanner = createScanner();
40
+ const result = scanner.scan(content);
41
+
42
+ // Check if content passes
43
+ if (scanner.passes(content)) {
44
+ console.log("Content is safe!");
45
+ }
46
+ ```
47
+
48
+ ### Custom Options
49
+
50
+ ```typescript
51
+ import { Scanner } from "asterscanner";
52
+
53
+ const scanner = new Scanner({
54
+ // Minimum score to pass (default: 50)
55
+ minScore: 70,
56
+
57
+ // Categories to scan (default: all)
58
+ categories: ["secrets", "code_execution"],
59
+
60
+ // Severity levels to include (default: all)
61
+ severities: ["critical", "high"],
62
+
63
+ // Custom patterns
64
+ customPatterns: [
65
+ {
66
+ id: "custom-pattern",
67
+ pattern: /FORBIDDEN_WORD/gi,
68
+ type: "custom_issue",
69
+ category: "secrets",
70
+ severity: "high",
71
+ message: "Forbidden word detected",
72
+ },
73
+ ],
74
+ });
75
+ ```
76
+
77
+ ### Scan Result
78
+
79
+ ```typescript
80
+ interface ScanResult {
81
+ // Security score (0-100)
82
+ score: number;
83
+
84
+ // Pass/fail status
85
+ passed: boolean;
86
+
87
+ // List of detected issues
88
+ issues: SecurityIssue[];
89
+
90
+ // Counts by severity
91
+ summary: {
92
+ critical: number;
93
+ high: number;
94
+ medium: number;
95
+ low: number;
96
+ info: number;
97
+ total: number;
98
+ };
99
+
100
+ // Scan metadata
101
+ metadata: {
102
+ scannedAt: string;
103
+ contentLength: number;
104
+ lineCount: number;
105
+ scanDurationMs: number;
106
+ };
107
+ }
108
+ ```
109
+
110
+ ### Security Issue
111
+
112
+ ```typescript
113
+ interface SecurityIssue {
114
+ patternId: string;
115
+ type: string;
116
+ category: PatternCategory;
117
+ severity: Severity;
118
+ message: string;
119
+ line: number;
120
+ column?: number;
121
+ match: string;
122
+ recommendation?: string;
123
+ }
124
+ ```
125
+
126
+ ## Security Patterns
127
+
128
+ The scanner detects the following categories of issues:
129
+
130
+ ### Secrets
131
+
132
+ - Hardcoded API keys
133
+ - Hardcoded passwords
134
+ - Tokens and secrets
135
+ - AWS access keys
136
+ - Private keys
137
+ - GitHub tokens
138
+
139
+ ### Code Execution
140
+
141
+ - `eval()` usage
142
+ - `new Function()` constructor
143
+ - Command injection
144
+ - curl/wget pipe to shell
145
+
146
+ ### File System
147
+
148
+ - Dangerous `rm -rf` commands
149
+ - chmod 777 permissions
150
+ - Filesystem formatting
151
+ - Direct device writes
152
+
153
+ ### Credentials
154
+
155
+ - /etc/passwd access
156
+ - /etc/shadow access
157
+ - SSH directory access
158
+ - AWS credentials access
159
+ - Kubernetes config access
160
+
161
+ ### Network
162
+
163
+ - Listening on all interfaces
164
+ - Disabled SSL verification
165
+ - Hardcoded authentication
166
+
167
+ ### System
168
+
169
+ - Privilege escalation
170
+ - NOPASSWD sudo
171
+ - Cron modification
172
+ - Firewall changes
173
+
174
+ ## Scoring
175
+
176
+ | Severity | Deduction |
177
+ | -------- | --------- |
178
+ | Critical | -25 |
179
+ | High | -15 |
180
+ | Medium | -10 |
181
+ | Low | -5 |
182
+ | Info | 0 |
183
+
184
+ Score starts at 100 and cannot go below 0.
185
+
186
+ ### Score Ratings
187
+
188
+ | Score | Rating |
189
+ | ------ | --------- |
190
+ | 90-100 | Excellent |
191
+ | 70-89 | Good |
192
+ | 50-69 | Fair |
193
+ | 25-49 | Poor |
194
+ | 0-24 | Critical |
195
+
196
+ ## API
197
+
198
+ ### `scan(content: string, options?: ScanOptions): ScanResult`
199
+
200
+ Quick function to scan content.
201
+
202
+ ### `createScanner(options?: ScanOptions): Scanner`
203
+
204
+ Create a new Scanner instance.
205
+
206
+ ### `class Scanner`
207
+
208
+ - `scan(content: string): ScanResult` - Scan content
209
+ - `passes(content: string): boolean` - Quick pass/fail check
210
+ - `getOptions(): ScanOptions` - Get current options
211
+ - `getPatterns(): SecurityPattern[]` - Get active patterns
212
+
213
+ ### `calculateScore(issues: SecurityIssue[]): number`
214
+
215
+ Calculate security score from issues.
216
+
217
+ ### `SECURITY_PATTERNS: SecurityPattern[]`
218
+
219
+ Array of built-in security patterns.
220
+
221
+ ## Development
222
+
223
+ ```bash
224
+ # Install dependencies
225
+ pnpm install
226
+
227
+ # Build
228
+ pnpm build
229
+
230
+ # Run tests
231
+ pnpm test
232
+
233
+ # Watch mode
234
+ pnpm test:watch
235
+
236
+ # Coverage
237
+ pnpm test:coverage
238
+ ```
239
+
240
+ ## License
241
+
242
+ MIT
@@ -0,0 +1,15 @@
1
+ /**
2
+ * asterscanner - Security Scanner for AI Agent Skills
3
+ *
4
+ * Provides pattern-based security scanning and scoring
5
+ * for skill packages before they are published.
6
+ */
7
+ export { Scanner, createScanner, scan } from "./scanner.js";
8
+ export { SECURITY_PATTERNS, PATTERN_CATEGORY_DESCRIPTIONS } from "./patterns.js";
9
+ export { calculateScore, SEVERITY_WEIGHTS } from "./scoring.js";
10
+ export type { SecurityIssue, ScanResult, ScanOptions, SecurityPattern, Severity, PatternCategory, } from "./types.js";
11
+ export { validateManifest, parseSkillFrontmatter, isValidParameterType, isValidCapability, validateAnthropicName, validateAnthropicDescription, parseSkillDirectory, convertLegacySkill, } from "./skill-schema.js";
12
+ export type { AnthropicSkillMetadata, SkillFile, SkillDirectory, LoadLevel, ProgressiveContent, AskSkillExtensions, ParameterType, SkillParameter, SkillContract, ContractExample, SkillCapability, CapabilityDeclaration, SkillReference, SkillComposition, SkillTestCase, SkillTestSuite, SkillVariant, SkillManifest, } from "./skill-schema.js";
13
+ export { SkillTestRunner, validateTests, calculateCoverage, formatTestResults, } from "./skill-tester.js";
14
+ export type { TestResult, TestSuiteResult, TestRunnerOptions, TestExecutor, } from "./skill-tester.js";
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChE,YAAY,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,eAAe,EACf,QAAQ,EACR,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EAEjB,qBAAqB,EACrB,4BAA4B,EAE5B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAEV,sBAAsB,EACtB,SAAS,EACT,cAAc,EACd,SAAS,EACT,kBAAkB,EAElB,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,aAAa,EACb,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,aAAa,GACd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,GACb,MAAM,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * asterscanner - Security Scanner for AI Agent Skills
3
+ *
4
+ * Provides pattern-based security scanning and scoring
5
+ * for skill packages before they are published.
6
+ */
7
+ export { Scanner, createScanner, scan } from "./scanner.js";
8
+ export { SECURITY_PATTERNS, PATTERN_CATEGORY_DESCRIPTIONS } from "./patterns.js";
9
+ export { calculateScore, SEVERITY_WEIGHTS } from "./scoring.js";
10
+ // Skill Schema types and utilities
11
+ export { validateManifest, parseSkillFrontmatter, isValidParameterType, isValidCapability,
12
+ // Anthropic spec validators
13
+ validateAnthropicName, validateAnthropicDescription,
14
+ // Directory-based skill utilities
15
+ parseSkillDirectory, convertLegacySkill, } from "./skill-schema.js";
16
+ // Skill Testing framework
17
+ export { SkillTestRunner, validateTests, calculateCoverage, formatTestResults, } from "./skill-tester.js";
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,6BAA6B,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUhE,mCAAmC;AACnC,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB;AACjB,4BAA4B;AAC5B,qBAAqB,EACrB,4BAA4B;AAC5B,kCAAkC;AAClC,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAwB3B,0BAA0B;AAC1B,OAAO,EACL,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { SecurityPattern, PatternCategory } from "./types.js";
2
+ /**
3
+ * Pattern category descriptions
4
+ */
5
+ export declare const PATTERN_CATEGORY_DESCRIPTIONS: Record<PatternCategory, string>;
6
+ /**
7
+ * Security patterns for skill content scanning
8
+ */
9
+ export declare const SECURITY_PATTERNS: SecurityPattern[];
10
+ /**
11
+ * Get patterns filtered by category
12
+ */
13
+ export declare function getPatternsByCategory(category: PatternCategory): SecurityPattern[];
14
+ /**
15
+ * Get patterns filtered by severity
16
+ */
17
+ export declare function getPatternsBySeverity(severity: SecurityPattern["severity"]): SecurityPattern[];
18
+ //# sourceMappingURL=patterns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAOzE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,eAAe,EAsS9C,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,eAAe,GACxB,eAAe,EAAE,CAEnB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,GACpC,eAAe,EAAE,CAEnB"}
@@ -0,0 +1,314 @@
1
+ /**
2
+ * Pattern category descriptions
3
+ */
4
+ export const PATTERN_CATEGORY_DESCRIPTIONS = {
5
+ secrets: "Hardcoded secrets and credentials",
6
+ code_execution: "Dangerous code execution patterns",
7
+ file_system: "Dangerous file system operations",
8
+ network: "Suspicious network access",
9
+ credentials: "Credential file access",
10
+ system: "System-level operations",
11
+ };
12
+ /**
13
+ * Security patterns for skill content scanning
14
+ */
15
+ export const SECURITY_PATTERNS = [
16
+ // === SECRETS ===
17
+ {
18
+ id: "secret-api-key",
19
+ pattern: /(?:api[_-]?key|apikey)\s*[:=]\s*['"][a-zA-Z0-9_\-]{16,}['"]/gi,
20
+ type: "hardcoded_secret",
21
+ category: "secrets",
22
+ severity: "critical",
23
+ message: "Hardcoded API key detected",
24
+ recommendation: "Use environment variables instead of hardcoded keys",
25
+ },
26
+ {
27
+ id: "secret-password",
28
+ pattern: /(?:password|passwd|pwd)\s*[:=]\s*['"][^'"]{4,}['"]/gi,
29
+ type: "hardcoded_secret",
30
+ category: "secrets",
31
+ severity: "critical",
32
+ message: "Hardcoded password detected",
33
+ recommendation: "Use environment variables or secure credential storage",
34
+ },
35
+ {
36
+ id: "secret-token",
37
+ pattern: /(?:secret|token|auth)\s*[:=]\s*['"][a-zA-Z0-9_\-]{8,}['"]/gi,
38
+ type: "hardcoded_secret",
39
+ category: "secrets",
40
+ severity: "critical",
41
+ message: "Hardcoded secret or token detected",
42
+ recommendation: "Use environment variables instead",
43
+ },
44
+ {
45
+ id: "secret-aws-key",
46
+ pattern: /AKIA[0-9A-Z]{16}/g,
47
+ type: "aws_access_key",
48
+ category: "secrets",
49
+ severity: "critical",
50
+ message: "AWS Access Key ID detected",
51
+ recommendation: "Remove AWS credentials and use IAM roles or environment variables",
52
+ },
53
+ {
54
+ id: "secret-private-key",
55
+ pattern: /-----BEGIN (?:RSA |DSA |EC |OPENSSH )?PRIVATE KEY-----/g,
56
+ type: "private_key",
57
+ category: "secrets",
58
+ severity: "critical",
59
+ message: "Private key detected",
60
+ recommendation: "Never include private keys in skill content",
61
+ },
62
+ {
63
+ id: "secret-github-token",
64
+ pattern: /gh[pousr]_[A-Za-z0-9_]{36,}/g,
65
+ type: "github_token",
66
+ category: "secrets",
67
+ severity: "critical",
68
+ message: "GitHub token detected",
69
+ recommendation: "Remove GitHub token and use secure credential storage",
70
+ },
71
+ // === CODE EXECUTION ===
72
+ {
73
+ id: "exec-eval",
74
+ pattern: /\beval\s*\(/gi,
75
+ type: "dangerous_eval",
76
+ category: "code_execution",
77
+ severity: "high",
78
+ message: "Use of eval() can execute arbitrary code",
79
+ recommendation: "Avoid eval() - use safer alternatives like JSON.parse()",
80
+ },
81
+ {
82
+ id: "exec-function-constructor",
83
+ pattern: /new\s+Function\s*\(/gi,
84
+ type: "dangerous_function",
85
+ category: "code_execution",
86
+ severity: "high",
87
+ message: "Function constructor can execute arbitrary code",
88
+ recommendation: "Avoid dynamic function creation",
89
+ },
90
+ {
91
+ id: "exec-shell-injection",
92
+ pattern: /\bexec\s*\(\s*['"`].*\$\{?/gi,
93
+ type: "command_injection",
94
+ category: "code_execution",
95
+ severity: "critical",
96
+ message: "Potential command injection vulnerability",
97
+ recommendation: "Sanitize all inputs before shell execution",
98
+ },
99
+ {
100
+ id: "exec-curl-pipe",
101
+ pattern: /curl\s+[^\|]*\|\s*(?:bash|sh|python|perl|ruby)/gi,
102
+ type: "remote_code_execution",
103
+ category: "code_execution",
104
+ severity: "critical",
105
+ message: "Remote code execution via curl pipe to shell",
106
+ recommendation: "Download files first and verify before execution",
107
+ },
108
+ {
109
+ id: "exec-wget-pipe",
110
+ pattern: /wget\s+[^\|]*\|\s*(?:bash|sh|python|perl|ruby)/gi,
111
+ type: "remote_code_execution",
112
+ category: "code_execution",
113
+ severity: "critical",
114
+ message: "Remote code execution via wget pipe to shell",
115
+ recommendation: "Download files first and verify before execution",
116
+ },
117
+ // === FILE SYSTEM ===
118
+ {
119
+ id: "fs-rm-rf-root",
120
+ pattern: /rm\s+-rf\s+\/(?!\w)/gi,
121
+ type: "dangerous_deletion",
122
+ category: "file_system",
123
+ severity: "critical",
124
+ message: "Dangerous recursive deletion of root filesystem",
125
+ recommendation: "Never delete from root - use specific paths",
126
+ },
127
+ {
128
+ id: "fs-rm-rf-home",
129
+ pattern: /rm\s+-rf\s+~\//gi,
130
+ type: "dangerous_deletion",
131
+ category: "file_system",
132
+ severity: "critical",
133
+ message: "Dangerous recursive deletion of home directory",
134
+ recommendation: "Be specific about what to delete",
135
+ },
136
+ {
137
+ id: "fs-rm-rf-path",
138
+ pattern: /rm\s+-rf\s+\/(?:var|usr|etc|home|opt|tmp)/gi,
139
+ type: "dangerous_deletion",
140
+ category: "file_system",
141
+ severity: "critical",
142
+ message: "Dangerous recursive deletion of system directory",
143
+ recommendation: "Avoid deleting system directories",
144
+ },
145
+ {
146
+ id: "fs-chmod-777",
147
+ pattern: /chmod\s+777/gi,
148
+ type: "insecure_permissions",
149
+ category: "file_system",
150
+ severity: "medium",
151
+ message: "Setting world-writable permissions (777)",
152
+ recommendation: "Use more restrictive permissions",
153
+ },
154
+ {
155
+ id: "fs-mkfs",
156
+ pattern: /mkfs\s+/gi,
157
+ type: "dangerous_format",
158
+ category: "file_system",
159
+ severity: "critical",
160
+ message: "Filesystem formatting command detected",
161
+ recommendation: "Avoid filesystem formatting operations",
162
+ },
163
+ {
164
+ id: "fs-dd-if",
165
+ pattern: /dd\s+if=.*of=\/dev\//gi,
166
+ type: "dangerous_write",
167
+ category: "file_system",
168
+ severity: "critical",
169
+ message: "Direct device write detected",
170
+ recommendation: "Avoid writing directly to device files",
171
+ },
172
+ // === SENSITIVE FILES ===
173
+ {
174
+ id: "file-etc-passwd",
175
+ pattern: /\/etc\/passwd/gi,
176
+ type: "sensitive_file_access",
177
+ category: "credentials",
178
+ severity: "high",
179
+ message: "Accessing /etc/passwd",
180
+ recommendation: "Avoid accessing system password file",
181
+ },
182
+ {
183
+ id: "file-etc-shadow",
184
+ pattern: /\/etc\/shadow/gi,
185
+ type: "sensitive_file_access",
186
+ category: "credentials",
187
+ severity: "critical",
188
+ message: "Accessing /etc/shadow",
189
+ recommendation: "Never access shadow password file",
190
+ },
191
+ {
192
+ id: "file-etc-sudoers",
193
+ pattern: /\/etc\/sudoers/gi,
194
+ type: "sensitive_file_access",
195
+ category: "credentials",
196
+ severity: "critical",
197
+ message: "Accessing sudoers file",
198
+ recommendation: "Avoid modifying sudo configuration",
199
+ },
200
+ {
201
+ id: "file-ssh-dir",
202
+ pattern: /\.ssh\//gi,
203
+ type: "credential_file_access",
204
+ category: "credentials",
205
+ severity: "high",
206
+ message: "Accessing SSH directory",
207
+ recommendation: "Avoid accessing SSH credentials",
208
+ },
209
+ {
210
+ id: "file-aws-dir",
211
+ pattern: /\.aws\//gi,
212
+ type: "credential_file_access",
213
+ category: "credentials",
214
+ severity: "high",
215
+ message: "Accessing AWS credentials directory",
216
+ recommendation: "Use IAM roles instead of stored credentials",
217
+ },
218
+ {
219
+ id: "file-kube-dir",
220
+ pattern: /\.kube\//gi,
221
+ type: "credential_file_access",
222
+ category: "credentials",
223
+ severity: "high",
224
+ message: "Accessing Kubernetes config directory",
225
+ recommendation: "Avoid accessing kubeconfig directly",
226
+ },
227
+ {
228
+ id: "file-env",
229
+ pattern: /cat\s+.*\.env/gi,
230
+ type: "env_file_access",
231
+ category: "credentials",
232
+ severity: "medium",
233
+ message: "Reading .env file contents",
234
+ recommendation: "Avoid exposing environment files",
235
+ },
236
+ // === NETWORK ===
237
+ {
238
+ id: "net-listen-all",
239
+ pattern: /listen\s*\(\s*['"]0\.0\.0\.0['"]/gi,
240
+ type: "network_exposure",
241
+ category: "network",
242
+ severity: "medium",
243
+ message: "Listening on all network interfaces",
244
+ recommendation: "Bind to specific interfaces when possible",
245
+ },
246
+ {
247
+ id: "net-disable-ssl",
248
+ pattern: /(?:ssl|tls)_?verify\s*[:=]\s*(?:false|0)/gi,
249
+ type: "insecure_ssl",
250
+ category: "network",
251
+ severity: "high",
252
+ message: "SSL/TLS verification disabled",
253
+ recommendation: "Always verify SSL certificates",
254
+ },
255
+ {
256
+ id: "net-http-basic-auth",
257
+ pattern: /Authorization:\s*Basic\s+[A-Za-z0-9+\/=]+/gi,
258
+ type: "exposed_credentials",
259
+ category: "network",
260
+ severity: "high",
261
+ message: "Hardcoded Basic authentication header",
262
+ recommendation: "Use environment variables for authentication",
263
+ },
264
+ // === SYSTEM ===
265
+ {
266
+ id: "sys-setuid",
267
+ pattern: /setuid\s*\(0\)/gi,
268
+ type: "privilege_escalation",
269
+ category: "system",
270
+ severity: "critical",
271
+ message: "Setting process UID to root",
272
+ recommendation: "Avoid privilege escalation",
273
+ },
274
+ {
275
+ id: "sys-sudo-nopasswd",
276
+ pattern: /NOPASSWD/gi,
277
+ type: "sudo_bypass",
278
+ category: "system",
279
+ severity: "high",
280
+ message: "NOPASSWD sudo configuration",
281
+ recommendation: "Require password for sudo commands",
282
+ },
283
+ {
284
+ id: "sys-cron-write",
285
+ pattern: /\/etc\/cron/gi,
286
+ type: "cron_modification",
287
+ category: "system",
288
+ severity: "medium",
289
+ message: "Accessing cron configuration",
290
+ recommendation: "Avoid modifying system cron jobs",
291
+ },
292
+ {
293
+ id: "sys-iptables",
294
+ pattern: /iptables\s+-[A-Z]/gi,
295
+ type: "firewall_modification",
296
+ category: "system",
297
+ severity: "medium",
298
+ message: "Modifying firewall rules",
299
+ recommendation: "Document any required firewall changes",
300
+ },
301
+ ];
302
+ /**
303
+ * Get patterns filtered by category
304
+ */
305
+ export function getPatternsByCategory(category) {
306
+ return SECURITY_PATTERNS.filter((p) => p.category === category);
307
+ }
308
+ /**
309
+ * Get patterns filtered by severity
310
+ */
311
+ export function getPatternsBySeverity(severity) {
312
+ return SECURITY_PATTERNS.filter((p) => p.severity === severity);
313
+ }
314
+ //# sourceMappingURL=patterns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patterns.js","sourceRoot":"","sources":["../src/patterns.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAoC;IAC5E,OAAO,EAAE,mCAAmC;IAC5C,cAAc,EAAE,mCAAmC;IACnD,WAAW,EAAE,kCAAkC;IAC/C,OAAO,EAAE,2BAA2B;IACpC,WAAW,EAAE,wBAAwB;IACrC,MAAM,EAAE,yBAAyB;CAClC,CAAC;AAEF;;GAEG;AACH,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AyB;IAEzB,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAqC;IAErC,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { ScanResult, ScanOptions, SecurityPattern } from "./types.js";
2
+ /**
3
+ * Security scanner for skill content
4
+ */
5
+ export declare class Scanner {
6
+ private options;
7
+ private patterns;
8
+ constructor(options?: ScanOptions);
9
+ /**
10
+ * Build the list of patterns to use based on options
11
+ */
12
+ private buildPatternList;
13
+ /**
14
+ * Sanitize matched content for display (truncate and mask sensitive parts)
15
+ */
16
+ private sanitizeMatch;
17
+ /**
18
+ * Scan a single line for security issues
19
+ */
20
+ private scanLine;
21
+ /**
22
+ * Scan content for security issues
23
+ */
24
+ scan(content: string): ScanResult;
25
+ /**
26
+ * Quick check if content passes security requirements
27
+ */
28
+ passes(content: string): boolean;
29
+ /**
30
+ * Get the current options
31
+ */
32
+ getOptions(): Required<ScanOptions>;
33
+ /**
34
+ * Get the active patterns
35
+ */
36
+ getPatterns(): SecurityPattern[];
37
+ }
38
+ /**
39
+ * Create a new scanner instance
40
+ */
41
+ export declare function createScanner(options?: ScanOptions): Scanner;
42
+ /**
43
+ * Quick scan function for simple use cases
44
+ */
45
+ export declare function scan(content: string, options?: ScanOptions): ScanResult;
46
+ //# sourceMappingURL=scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,UAAU,EACV,WAAW,EACX,eAAe,EAGhB,MAAM,YAAY,CAAC;AAapB;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,QAAQ,CAAoB;gBAExB,OAAO,GAAE,WAAgB;IAKrC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAYxB;;OAEG;IACH,OAAO,CAAC,aAAa;IAerB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAkChB;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU;IAoDjC;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACH,UAAU,IAAI,QAAQ,CAAC,WAAW,CAAC;IAInC;;OAEG;IACH,WAAW,IAAI,eAAe,EAAE;CAGjC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAE5D;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,UAAU,CAEvE"}