@aiclude/security-skill 0.1.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 +201 -0
- package/SKILL.md +57 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.js +350 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# /security-scan - AIclude Security Vulnerability Scanner
|
|
2
|
+
|
|
3
|
+
AI Agent 시스템에서 사용하는 MCP Server 또는 Skill의 보안 취약점을 검사합니다.
|
|
4
|
+
기존 스캔 결과가 있으면 즉시 반환하고, 없으면 새로 등록하여 스캔을 수행합니다.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
# 이름으로 보안 검색 (권장 - 기존 스캔 결과 활용)
|
|
10
|
+
/security-scan --name <package-name> [options]
|
|
11
|
+
|
|
12
|
+
# 로컬 경로 직접 스캔
|
|
13
|
+
/security-scan <target-path> [options]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
- `--name`: 검색할 MCP 서버 또는 Skill 이름 (npm 패키지명, GitHub 레포 등)
|
|
19
|
+
- `target-path`: 스캔할 로컬 경로 (--name 대신 사용)
|
|
20
|
+
- `--type`: 대상 유형 (`mcp-server` | `skill`) - 자동 감지됨
|
|
21
|
+
- `--profile`: 샌드박스 프로필 (`strict` | `standard` | `permissive`)
|
|
22
|
+
- `--format`: 리포트 출력 형식 (`markdown` | `json`)
|
|
23
|
+
- `--engines`: 사용할 스캔 엔진 (쉼표 구분)
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
# MCP 서버 보안 검색
|
|
29
|
+
/security-scan --name @anthropic/mcp-server-fetch
|
|
30
|
+
|
|
31
|
+
# Skill 보안 검색
|
|
32
|
+
/security-scan --name my-awesome-skill --type skill
|
|
33
|
+
|
|
34
|
+
# 로컬 스캔
|
|
35
|
+
/security-scan ./my-mcp-server
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## What It Checks
|
|
39
|
+
|
|
40
|
+
- **Prompt Injection**: LLM 대상 프롬프트 인젝션 패턴
|
|
41
|
+
- **Tool Poisoning**: 도구 설명에 숨겨진 악성 지시문
|
|
42
|
+
- **Command Injection**: exec/spawn에 검증되지 않은 입력 사용
|
|
43
|
+
- **Supply Chain**: 의존성의 알려진 CVE 및 악성 패키지
|
|
44
|
+
- **Malware**: 백도어, 크립토마이너, 랜섬웨어 탐지
|
|
45
|
+
- **Permission Abuse**: 과도한 파일시스템/네트워크 권한
|
|
46
|
+
|
|
47
|
+
## Output
|
|
48
|
+
|
|
49
|
+
리포트에는 다음이 포함됩니다:
|
|
50
|
+
1. **위험 수준 요약** (CRITICAL / HIGH / MEDIUM / LOW / INFO)
|
|
51
|
+
2. **발견된 취약점 목록** (코드 위치, 설명, 심각도)
|
|
52
|
+
3. **사용 리스크 평가** (어떤 위험이 있는지)
|
|
53
|
+
4. **수정 권장사항** (각 취약점별 해결 방법)
|
|
54
|
+
|
|
55
|
+
## Web Dashboard
|
|
56
|
+
|
|
57
|
+
모든 스캔 결과는 https://vs.aiclude.com 에서 확인할 수 있습니다.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ReportFormat, ScanEngineId } from '@asvs/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Skill Handler
|
|
5
|
+
* Processes /security-scan skill invocations from Claude Code
|
|
6
|
+
* 로컬 경로 스캔 + 이름 기반 API 검색 모두 지원
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface SkillInvocation {
|
|
10
|
+
targetPath: string;
|
|
11
|
+
type?: "mcp-server" | "skill";
|
|
12
|
+
profile?: "strict" | "standard" | "permissive";
|
|
13
|
+
format?: ReportFormat;
|
|
14
|
+
engines?: ScanEngineId[];
|
|
15
|
+
}
|
|
16
|
+
/** API 기반 조회 요청 */
|
|
17
|
+
interface SkillLookupInvocation {
|
|
18
|
+
name: string;
|
|
19
|
+
type?: "mcp-server" | "skill";
|
|
20
|
+
description?: string;
|
|
21
|
+
repositoryUrl?: string;
|
|
22
|
+
npmPackage?: string;
|
|
23
|
+
}
|
|
24
|
+
declare class SkillHandler {
|
|
25
|
+
private scanner;
|
|
26
|
+
private reporter;
|
|
27
|
+
private apiBase;
|
|
28
|
+
constructor();
|
|
29
|
+
/** API 호출에 사용할 인증 헤더 생성 */
|
|
30
|
+
private createAuthHeaders;
|
|
31
|
+
/**
|
|
32
|
+
* API 기반 보안 스캔 조회/요청
|
|
33
|
+
* 기존 스캔 결과를 검색하고, 없으면 등록 후 스캔을 요청
|
|
34
|
+
*/
|
|
35
|
+
lookup(invocation: SkillLookupInvocation): Promise<string>;
|
|
36
|
+
/** Handle a /security-scan invocation (로컬 경로 스캔) */
|
|
37
|
+
handle(invocation: SkillInvocation): Promise<string>;
|
|
38
|
+
/** Auto-detect whether target is an MCP server or skill */
|
|
39
|
+
private detectTargetType;
|
|
40
|
+
/** Format the report output with detailed findings */
|
|
41
|
+
private formatOutput;
|
|
42
|
+
/** API에서 받은 상세 리포트를 마크다운으로 포맷 */
|
|
43
|
+
private formatApiReport;
|
|
44
|
+
/** 스캔 요약만 포맷 */
|
|
45
|
+
private formatScanSummary;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { SkillHandler, type SkillInvocation, type SkillLookupInvocation };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
// src/skill-handler.ts
|
|
2
|
+
import {
|
|
3
|
+
Scanner,
|
|
4
|
+
SastEngine,
|
|
5
|
+
ScaEngine,
|
|
6
|
+
ToolAnalyzerEngine,
|
|
7
|
+
MalwareDetectorEngine,
|
|
8
|
+
PermissionCheckerEngine,
|
|
9
|
+
DastEngine,
|
|
10
|
+
BehaviorMonitorEngine,
|
|
11
|
+
loadGlobalConfig,
|
|
12
|
+
RiskLevel,
|
|
13
|
+
validateScanPath
|
|
14
|
+
} from "@asvs/core";
|
|
15
|
+
import { ReportGenerator } from "@asvs/reporter";
|
|
16
|
+
import { existsSync } from "fs";
|
|
17
|
+
import { resolve } from "path";
|
|
18
|
+
import { createHmac } from "crypto";
|
|
19
|
+
var SkillHandler = class {
|
|
20
|
+
scanner;
|
|
21
|
+
reporter;
|
|
22
|
+
apiBase;
|
|
23
|
+
constructor() {
|
|
24
|
+
this.scanner = new Scanner();
|
|
25
|
+
this.reporter = new ReportGenerator();
|
|
26
|
+
this.apiBase = process.env["ASVS_API_URL"] ?? "https://vs-api.aiclude.com";
|
|
27
|
+
this.scanner.registerEngine(new SastEngine());
|
|
28
|
+
this.scanner.registerEngine(new ScaEngine());
|
|
29
|
+
this.scanner.registerEngine(new ToolAnalyzerEngine());
|
|
30
|
+
this.scanner.registerEngine(new MalwareDetectorEngine());
|
|
31
|
+
this.scanner.registerEngine(new PermissionCheckerEngine());
|
|
32
|
+
this.scanner.registerEngine(new DastEngine());
|
|
33
|
+
this.scanner.registerEngine(new BehaviorMonitorEngine());
|
|
34
|
+
}
|
|
35
|
+
/** API 호출에 사용할 인증 헤더 생성 */
|
|
36
|
+
createAuthHeaders(name) {
|
|
37
|
+
const secret = process.env["ASVS_SIGNING_SECRET"] ?? "asvs-default-signing-key-2026";
|
|
38
|
+
const timestamp = String(Date.now());
|
|
39
|
+
const payload = `skill:${name}:${timestamp}`;
|
|
40
|
+
const signature = createHmac("sha256", secret).update(payload).digest("hex");
|
|
41
|
+
return {
|
|
42
|
+
"Content-Type": "application/json",
|
|
43
|
+
"X-ASVS-Source": "skill",
|
|
44
|
+
"X-ASVS-Timestamp": timestamp,
|
|
45
|
+
"X-ASVS-Signature": signature
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* API 기반 보안 스캔 조회/요청
|
|
50
|
+
* 기존 스캔 결과를 검색하고, 없으면 등록 후 스캔을 요청
|
|
51
|
+
*/
|
|
52
|
+
async lookup(invocation) {
|
|
53
|
+
const apiUrl = `${this.apiBase}/api/v1/scan/lookup`;
|
|
54
|
+
const lookupRes = await fetch(apiUrl, {
|
|
55
|
+
method: "POST",
|
|
56
|
+
headers: this.createAuthHeaders(invocation.name),
|
|
57
|
+
body: JSON.stringify({
|
|
58
|
+
name: invocation.name,
|
|
59
|
+
type: invocation.type ?? "mcp-server",
|
|
60
|
+
description: invocation.description ?? "",
|
|
61
|
+
repositoryUrl: invocation.repositoryUrl ?? "",
|
|
62
|
+
npmPackage: invocation.npmPackage ?? "",
|
|
63
|
+
source: "skill"
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
const lookupData = await lookupRes.json();
|
|
67
|
+
if (lookupData["status"] === "found") {
|
|
68
|
+
const report = lookupData["report"];
|
|
69
|
+
const scan = lookupData["scan"];
|
|
70
|
+
const target = lookupData["target"];
|
|
71
|
+
if (report) {
|
|
72
|
+
return this.formatApiReport(report, target);
|
|
73
|
+
}
|
|
74
|
+
return this.formatScanSummary(target, scan);
|
|
75
|
+
}
|
|
76
|
+
if (lookupData["status"] === "scanning" || lookupData["status"] === "registered") {
|
|
77
|
+
const jobId = lookupData["jobId"];
|
|
78
|
+
const target = lookupData["target"];
|
|
79
|
+
const maxWait = 12e4;
|
|
80
|
+
const interval = 5e3;
|
|
81
|
+
const startTime = Date.now();
|
|
82
|
+
while (Date.now() - startTime < maxWait) {
|
|
83
|
+
await new Promise((r) => setTimeout(r, interval));
|
|
84
|
+
const statusRes = await fetch(`${this.apiBase}/api/v1/scan/status/${jobId}`, {
|
|
85
|
+
headers: this.createAuthHeaders(invocation.name)
|
|
86
|
+
});
|
|
87
|
+
const statusData = await statusRes.json();
|
|
88
|
+
if (statusData["status"] === "completed") {
|
|
89
|
+
const report = statusData["report"];
|
|
90
|
+
const scanResult = statusData["scan"];
|
|
91
|
+
const completedTarget = statusData["target"];
|
|
92
|
+
if (report) {
|
|
93
|
+
return this.formatApiReport(report, completedTarget);
|
|
94
|
+
}
|
|
95
|
+
return this.formatScanSummary(completedTarget, scanResult);
|
|
96
|
+
}
|
|
97
|
+
if (statusData["status"] === "failed") {
|
|
98
|
+
const job = statusData["job"];
|
|
99
|
+
throw new Error(`\uC2A4\uCE94 \uC2E4\uD328: ${job?.["error"] ?? "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return [
|
|
103
|
+
`# \uBCF4\uC548 \uC2A4\uCE94 \uC9C4\uD589 \uC911: ${invocation.name}`,
|
|
104
|
+
"",
|
|
105
|
+
`\uC2A4\uCE94\uC774 \uC544\uC9C1 \uC9C4\uD589 \uC911\uC785\uB2C8\uB2E4. \uC7A0\uC2DC \uD6C4 \uB2E4\uC2DC \uC2DC\uB3C4\uD558\uC138\uC694.`,
|
|
106
|
+
`Job ID: ${jobId}`,
|
|
107
|
+
`\uD0C0\uAC9F: ${target["canonicalName"] ?? invocation.name}`,
|
|
108
|
+
"",
|
|
109
|
+
`*\uC0C1\uC138 \uACB0\uACFC\uB294 https://vs.aiclude.com \uC5D0\uC11C \uD655\uC778\uD558\uC138\uC694*`
|
|
110
|
+
].join("\n");
|
|
111
|
+
}
|
|
112
|
+
return `API \uC751\uB2F5: ${JSON.stringify(lookupData, null, 2)}`;
|
|
113
|
+
}
|
|
114
|
+
/** Handle a /security-scan invocation (로컬 경로 스캔) */
|
|
115
|
+
async handle(invocation) {
|
|
116
|
+
const config = loadGlobalConfig();
|
|
117
|
+
const scanConfig = {
|
|
118
|
+
...config.defaultScanConfig,
|
|
119
|
+
...invocation.profile && { sandboxProfile: invocation.profile },
|
|
120
|
+
...invocation.engines && { engines: invocation.engines }
|
|
121
|
+
};
|
|
122
|
+
if (!scanConfig.engines.includes("malware-detector")) {
|
|
123
|
+
scanConfig.engines.push("malware-detector");
|
|
124
|
+
}
|
|
125
|
+
const targetPath = validateScanPath(invocation.targetPath);
|
|
126
|
+
const targetType = invocation.type ?? this.detectTargetType(targetPath);
|
|
127
|
+
const target = {
|
|
128
|
+
type: targetType,
|
|
129
|
+
name: targetPath.split("/").pop() ?? targetPath,
|
|
130
|
+
path: targetPath
|
|
131
|
+
};
|
|
132
|
+
const scanResult = await this.scanner.scan(target, scanConfig);
|
|
133
|
+
const format = invocation.format ?? "markdown";
|
|
134
|
+
const report = this.reporter.generate(scanResult, format);
|
|
135
|
+
return this.formatOutput(report, format, scanResult.engineResults.flatMap((r) => r.vulnerabilities));
|
|
136
|
+
}
|
|
137
|
+
/** Auto-detect whether target is an MCP server or skill */
|
|
138
|
+
detectTargetType(targetPath) {
|
|
139
|
+
if (existsSync(resolve(targetPath, "SKILL.md")) || targetPath.endsWith("SKILL.md") || targetPath.includes("/skill")) {
|
|
140
|
+
return "skill";
|
|
141
|
+
}
|
|
142
|
+
return "mcp-server";
|
|
143
|
+
}
|
|
144
|
+
/** Format the report output with detailed findings */
|
|
145
|
+
formatOutput(report, format, vulnerabilities) {
|
|
146
|
+
if (format === "json") {
|
|
147
|
+
return JSON.stringify(report, null, 2);
|
|
148
|
+
}
|
|
149
|
+
const lines = [];
|
|
150
|
+
const { summary } = report.scanResult;
|
|
151
|
+
const icon = summary.overallRiskLevel === RiskLevel.CRITICAL ? "[CRITICAL]" : summary.overallRiskLevel === RiskLevel.HIGH ? "[HIGH RISK]" : summary.overallRiskLevel === RiskLevel.MEDIUM ? "[MEDIUM RISK]" : summary.overallRiskLevel === RiskLevel.LOW ? "[LOW RISK]" : "[CLEAN]";
|
|
152
|
+
lines.push(`# ${icon} Security Scan Report: ${report.title}`);
|
|
153
|
+
lines.push("");
|
|
154
|
+
lines.push(`| Metric | Value |`);
|
|
155
|
+
lines.push(`|--------|-------|`);
|
|
156
|
+
lines.push(`| Scan Date | ${report.generatedAt} |`);
|
|
157
|
+
lines.push(`| Target | ${report.scanResult.target.path} |`);
|
|
158
|
+
lines.push(`| Target Type | ${report.scanResult.target.type} |`);
|
|
159
|
+
lines.push(`| Overall Risk | **${summary.overallRiskLevel}** |`);
|
|
160
|
+
lines.push(`| Risk Score | **${summary.overallScore}/100** |`);
|
|
161
|
+
lines.push(`| Total Findings | ${summary.totalVulnerabilities} |`);
|
|
162
|
+
lines.push(`| Scan Duration | ${report.scanResult.duration}ms |`);
|
|
163
|
+
lines.push("");
|
|
164
|
+
lines.push("## Severity Breakdown");
|
|
165
|
+
lines.push("");
|
|
166
|
+
lines.push(`| Severity | Count |`);
|
|
167
|
+
lines.push(`|----------|-------|`);
|
|
168
|
+
for (const [level, count] of Object.entries(summary.bySeverity)) {
|
|
169
|
+
if (count > 0) {
|
|
170
|
+
lines.push(`| **${level}** | ${count} |`);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
lines.push("");
|
|
174
|
+
if (vulnerabilities.length > 0) {
|
|
175
|
+
lines.push("## Detailed Findings");
|
|
176
|
+
lines.push("");
|
|
177
|
+
const sorted = [...vulnerabilities].sort((a, b) => {
|
|
178
|
+
const order = { CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3, INFO: 4 };
|
|
179
|
+
return (order[a.severity] ?? 5) - (order[b.severity] ?? 5);
|
|
180
|
+
});
|
|
181
|
+
const top = sorted.slice(0, 20);
|
|
182
|
+
for (let i = 0; i < top.length; i++) {
|
|
183
|
+
const v = top[i];
|
|
184
|
+
lines.push(`### ${i + 1}. [${v.severity}] ${v.title}`);
|
|
185
|
+
lines.push("");
|
|
186
|
+
lines.push(`- **ID**: ${v.id}`);
|
|
187
|
+
lines.push(`- **Category**: ${v.category}`);
|
|
188
|
+
lines.push(`- **Confidence**: ${Math.round(v.confidence * 100)}%`);
|
|
189
|
+
if (v.location) {
|
|
190
|
+
lines.push(`- **Location**: \`${v.location.file}:${v.location.line}\``);
|
|
191
|
+
}
|
|
192
|
+
lines.push(`- **Description**: ${v.description}`);
|
|
193
|
+
lines.push(`- **Remediation**: ${v.remediation}`);
|
|
194
|
+
if (v.cveIds?.length) {
|
|
195
|
+
lines.push(`- **CVE**: ${v.cveIds.join(", ")}`);
|
|
196
|
+
}
|
|
197
|
+
if (v.location?.snippet) {
|
|
198
|
+
lines.push("");
|
|
199
|
+
lines.push("```");
|
|
200
|
+
lines.push(v.location.snippet.substring(0, 300));
|
|
201
|
+
lines.push("```");
|
|
202
|
+
}
|
|
203
|
+
lines.push("");
|
|
204
|
+
}
|
|
205
|
+
if (sorted.length > 20) {
|
|
206
|
+
lines.push(`> ... and ${sorted.length - 20} more findings. Use \`--format json\` for the complete list.`);
|
|
207
|
+
lines.push("");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (report.risks.length > 0) {
|
|
211
|
+
lines.push("## Risk Assessment");
|
|
212
|
+
lines.push("");
|
|
213
|
+
for (const risk of report.risks) {
|
|
214
|
+
lines.push(`### [${risk.level}] ${risk.area}`);
|
|
215
|
+
lines.push(`- **Impact**: ${risk.impact}`);
|
|
216
|
+
lines.push(`- **Likelihood**: ${risk.likelihood}`);
|
|
217
|
+
lines.push(`- **Remediation**: ${risk.remediation}`);
|
|
218
|
+
lines.push("");
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (report.precautions.length > 0) {
|
|
222
|
+
lines.push("## Precautions & Warnings");
|
|
223
|
+
lines.push("");
|
|
224
|
+
for (const precaution of report.precautions) {
|
|
225
|
+
lines.push(`- ${precaution}`);
|
|
226
|
+
}
|
|
227
|
+
lines.push("");
|
|
228
|
+
}
|
|
229
|
+
return lines.join("\n");
|
|
230
|
+
}
|
|
231
|
+
// -----------------------------------------------------------------------
|
|
232
|
+
// API 리포트 포맷팅 헬퍼
|
|
233
|
+
// -----------------------------------------------------------------------
|
|
234
|
+
/** API에서 받은 상세 리포트를 마크다운으로 포맷 */
|
|
235
|
+
formatApiReport(report, target) {
|
|
236
|
+
const lines = [];
|
|
237
|
+
const scanResult = report["scanResult"];
|
|
238
|
+
const summary = scanResult?.["summary"];
|
|
239
|
+
const engineResults = scanResult?.["engineResults"] ?? [];
|
|
240
|
+
const risks = report["risks"] ?? [];
|
|
241
|
+
const precautions = report["precautions"] ?? [];
|
|
242
|
+
const riskLevel = summary?.["overallRiskLevel"] ?? target["riskLevel"] ?? "UNKNOWN";
|
|
243
|
+
const score = summary?.["overallScore"] ?? target["lastScore"] ?? 0;
|
|
244
|
+
const totalVulns = summary?.["totalVulnerabilities"] ?? 0;
|
|
245
|
+
const bySeverity = summary?.["bySeverity"] ?? {};
|
|
246
|
+
const targetName = target["canonicalName"] ?? target["displayName"] ?? "Unknown";
|
|
247
|
+
const targetType = target["type"] ?? "mcp-server";
|
|
248
|
+
const icon = riskLevel === "CRITICAL" ? "[CRITICAL]" : riskLevel === "HIGH" ? "[HIGH RISK]" : riskLevel === "MEDIUM" ? "[MEDIUM RISK]" : riskLevel === "LOW" ? "[LOW RISK]" : "[CLEAN]";
|
|
249
|
+
lines.push(`# ${icon} Security Scan Report: ${targetName}`);
|
|
250
|
+
lines.push("");
|
|
251
|
+
lines.push(`| Metric | Value |`);
|
|
252
|
+
lines.push(`|--------|-------|`);
|
|
253
|
+
lines.push(`| Target | ${targetName} |`);
|
|
254
|
+
lines.push(`| Type | ${targetType} |`);
|
|
255
|
+
lines.push(`| Overall Risk | **${riskLevel}** |`);
|
|
256
|
+
lines.push(`| Risk Score | **${score}/100** |`);
|
|
257
|
+
lines.push(`| Total Findings | ${totalVulns} |`);
|
|
258
|
+
lines.push(`| Scan Date | ${report["generatedAt"] ?? "N/A"} |`);
|
|
259
|
+
lines.push("");
|
|
260
|
+
lines.push("## Severity Breakdown");
|
|
261
|
+
lines.push("");
|
|
262
|
+
lines.push("| Severity | Count |");
|
|
263
|
+
lines.push("|----------|-------|");
|
|
264
|
+
for (const level of ["CRITICAL", "HIGH", "MEDIUM", "LOW", "INFO"]) {
|
|
265
|
+
const count = bySeverity[level] ?? 0;
|
|
266
|
+
if (count > 0) {
|
|
267
|
+
lines.push(`| **${level}** | ${count} |`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
lines.push("");
|
|
271
|
+
const allVulns = engineResults.flatMap(
|
|
272
|
+
(r) => r["vulnerabilities"] ?? []
|
|
273
|
+
);
|
|
274
|
+
if (allVulns.length > 0) {
|
|
275
|
+
lines.push("## Detailed Findings");
|
|
276
|
+
lines.push("");
|
|
277
|
+
const sorted = [...allVulns].sort((a, b) => {
|
|
278
|
+
const order = { CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3, INFO: 4 };
|
|
279
|
+
return (order[a["severity"]] ?? 5) - (order[b["severity"]] ?? 5);
|
|
280
|
+
});
|
|
281
|
+
const top = sorted.slice(0, 20);
|
|
282
|
+
for (let i = 0; i < top.length; i++) {
|
|
283
|
+
const v = top[i];
|
|
284
|
+
lines.push(`### ${i + 1}. [${v["severity"]}] ${v["title"]}`);
|
|
285
|
+
lines.push("");
|
|
286
|
+
lines.push(`- **Category**: ${v["category"]}`);
|
|
287
|
+
lines.push(`- **Confidence**: ${Math.round(v["confidence"] * 100)}%`);
|
|
288
|
+
const loc = v["location"];
|
|
289
|
+
if (loc) {
|
|
290
|
+
lines.push(`- **Location**: \`${loc["file"]}:${loc["line"]}\``);
|
|
291
|
+
}
|
|
292
|
+
lines.push(`- **Description**: ${v["description"]}`);
|
|
293
|
+
lines.push(`- **Remediation**: ${v["remediation"]}`);
|
|
294
|
+
lines.push("");
|
|
295
|
+
}
|
|
296
|
+
if (sorted.length > 20) {
|
|
297
|
+
lines.push(`> ... and ${sorted.length - 20} more findings.`);
|
|
298
|
+
lines.push("");
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (risks.length > 0) {
|
|
302
|
+
lines.push("## Risk Assessment");
|
|
303
|
+
lines.push("");
|
|
304
|
+
for (const risk of risks) {
|
|
305
|
+
lines.push(`### [${risk["level"]}] ${risk["area"]}`);
|
|
306
|
+
lines.push(`- **Impact**: ${risk["impact"]}`);
|
|
307
|
+
lines.push(`- **Remediation**: ${risk["remediation"]}`);
|
|
308
|
+
lines.push("");
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (precautions.length > 0) {
|
|
312
|
+
lines.push("## Precautions & Warnings");
|
|
313
|
+
lines.push("");
|
|
314
|
+
for (const p of precautions) {
|
|
315
|
+
lines.push(`- ${p}`);
|
|
316
|
+
}
|
|
317
|
+
lines.push("");
|
|
318
|
+
}
|
|
319
|
+
lines.push("---");
|
|
320
|
+
lines.push(`*Report ID: ${report["id"] ?? "N/A"}*`);
|
|
321
|
+
lines.push(`*Web Dashboard: https://vs.aiclude.com/targets*`);
|
|
322
|
+
return lines.join("\n");
|
|
323
|
+
}
|
|
324
|
+
/** 스캔 요약만 포맷 */
|
|
325
|
+
formatScanSummary(target, scan) {
|
|
326
|
+
const lines = [];
|
|
327
|
+
const targetName = target["canonicalName"] ?? target["displayName"] ?? "Unknown";
|
|
328
|
+
const riskLevel = scan["riskLevel"] ?? target["riskLevel"] ?? "UNKNOWN";
|
|
329
|
+
const score = scan["score"] ?? target["lastScore"] ?? 0;
|
|
330
|
+
lines.push(`# Security Scan Summary: ${targetName}`);
|
|
331
|
+
lines.push("");
|
|
332
|
+
lines.push(`| Metric | Value |`);
|
|
333
|
+
lines.push(`|--------|-------|`);
|
|
334
|
+
lines.push(`| Risk Level | **${riskLevel}** |`);
|
|
335
|
+
lines.push(`| Risk Score | **${score}/100** |`);
|
|
336
|
+
lines.push(`| Total Vulnerabilities | ${scan["totalVulnerabilities"] ?? 0} |`);
|
|
337
|
+
lines.push(`| CRITICAL | ${scan["criticalCount"] ?? 0} |`);
|
|
338
|
+
lines.push(`| HIGH | ${scan["highCount"] ?? 0} |`);
|
|
339
|
+
lines.push(`| MEDIUM | ${scan["mediumCount"] ?? 0} |`);
|
|
340
|
+
lines.push(`| LOW | ${scan["lowCount"] ?? 0} |`);
|
|
341
|
+
lines.push(`| INFO | ${scan["infoCount"] ?? 0} |`);
|
|
342
|
+
lines.push(`| Scanned At | ${scan["scannedAt"] ?? "N/A"} |`);
|
|
343
|
+
lines.push("");
|
|
344
|
+
lines.push(`*\uC0C1\uC138 \uB9AC\uD3EC\uD2B8\uB294 https://vs.aiclude.com \uC5D0\uC11C \uD655\uC778\uD558\uC138\uC694*`);
|
|
345
|
+
return lines.join("\n");
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
export {
|
|
349
|
+
SkillHandler
|
|
350
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aiclude/security-skill",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AIclude Security Vulnerability Scanner - Claude Code Skill for inline security scanning",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"claude-code",
|
|
16
|
+
"skill",
|
|
17
|
+
"security",
|
|
18
|
+
"vulnerability",
|
|
19
|
+
"scanner",
|
|
20
|
+
"ai-agent",
|
|
21
|
+
"mcp",
|
|
22
|
+
"aiclude",
|
|
23
|
+
"sast",
|
|
24
|
+
"sca",
|
|
25
|
+
"malware"
|
|
26
|
+
],
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"author": "AICLUDE Inc. <dev@aiclude.com>",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/aiclude/asvs"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://vs.aiclude.com",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/aiclude/asvs/issues"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20.0.0"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"SKILL.md",
|
|
46
|
+
"README.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@asvs/core": "0.1.0",
|
|
51
|
+
"@asvs/reporter": "0.1.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"tsup": "^8.0.0",
|
|
55
|
+
"typescript": "^5.5.0"
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
59
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
60
|
+
"test": "vitest run",
|
|
61
|
+
"clean": "rm -rf dist"
|
|
62
|
+
}
|
|
63
|
+
}
|