SkillSecurityScanner
public final class SkillSecurityScanner
io/agentscope/harness/agent/skill/curator/SkillSecurityScanner.java:46–388技能 Security Scanner,让智能体以受控方式调用外部能力。位于 io.agentscope.harness.agent.skill.curator 包。核心成员包括 scan、scanSingleFile、shouldAllow。
Static-analysis scanner for SKILL.md and skill support files. Ported from hermes-agent's
tools/skills_guard.py regex library plus the trust-level × verdict install policy.
Detection categories (one or more regexes per category):
-
Category#EXFILTRATION— data exfiltration via curl/wget POST -
Category#INJECTION— prompt-injection markers in markdown -
Category#DESTRUCTIVE—rm -rf /,mkfs,dd of=/dev -
Category#PERSISTENCE— crontab / systemd / shell-rc tampering -
Category#NETWORK— listen sockets / reverse shells -
Category#OBFUSCATION— base64 → bash, eval $(curl …), etc.
The scan returns a Verdict (SAFE / CAUTION / DANGEROUS) plus the list of findings.
Callers (e.g. SkillManageTool, HarnessAgent.promoteSkill) consult
#shouldAllow(TrustLevel, Verdict) to map verdict + provenance to an install decision.
This is intentionally a Java-side approximation, not a security boundary. Skills always
run inside whatever sandbox the host configured (see ShellExecuteTool); the scanner
is here to catch the obvious mistakes during authoring, NOT to replace the sandbox.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Severity | 枚举enum | 定义严重程度相关取值的枚举。 A enum in io.agentscope.harness.agent.skill.curator that defines enum values used when components lets agents invoke external capabilities under control. |
Category | 枚举enum | 定义类别相关取值的枚举。 A enum in io.agentscope.harness.agent.skill.curator that defines enum values used when components lets agents invoke external capabilities under control. |
Verdict | 枚举enum | 定义Verdict相关取值的枚举。 A enum in io.agentscope.harness.agent.skill.curator that defines enum values used when components lets agents invoke external capabilities under control. |
TrustLevel | 枚举enum | 定义Trust 级别相关取值的枚举。 Where the skill came from. |
Finding | 记录record | 承载 Finding数据的记录类型。 A record in io.agentscope.harness.agent.skill.curator that carries data used when components lets agents invoke external capabilities under control. |
ScanResult | 记录record | 承载 Scan 结果数据的记录类型。 A record in io.agentscope.harness.agent.skill.curator that carries data used when components lets agents invoke external capabilities under control. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static ScanResult scan(String skillName, String skillMd, Map<String, String> resources)static | 执行 `scan` 方法。 Scan a complete skill: SKILL.md + every support file. |
public static ScanResult scanSingleFile(String relPath, String content)static | 执行 `scanSingleFile` 方法。 Scan a single file (used after `write_file` / `patch`). |
public static boolean shouldAllow(TrustLevel trust, Verdict verdict)static | 执行 `shouldAllow` 方法。 Map (trust × verdict) to an install decision. |
方法详情Method Detail
scan
public static ScanResult scan(String skillName, String skillMd, Map<String, String> resources)
执行 scan 方法。
Scan a complete skill: SKILL.md + every support file.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
skillName | String | 技能名称(类型 `String`)。The skill name. |
skillMd | String | 技能 Md(类型 `String`)。The skill md. |
resources | Map<String, String> | resources(类型 `Map`)。The resources. |
ScanResultio/agentscope/harness/agent/skill/curator/SkillSecurityScanner.java:262–277scanSingleFile
public static ScanResult scanSingleFile(String relPath, String content)
执行 scanSingleFile 方法。
Scan a single file (used after write_file / patch).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
relPath | String | rel 路径(类型 `String`)。The rel path. |
content | String | 内容(类型 `String`)。The content. |
ScanResultio/agentscope/harness/agent/skill/curator/SkillSecurityScanner.java:280–284shouldAllow
public static boolean shouldAllow(TrustLevel trust, Verdict verdict)
执行 shouldAllow 方法。
Map (trust × verdict) to an install decision.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
trust | TrustLevel | trust(类型 `TrustLevel`)。The trust. |
verdict | Verdict | verdict(类型 `Verdict`)。The verdict. |
booleanio/agentscope/harness/agent/skill/curator/SkillSecurityScanner.java:293–304嵌套类详情Nested Class Detail
Severity
public enum Severity定义严重程度相关取值的枚举。位于 io.agentscope.harness.agent.skill.curator 包。核心成员包括 LOW、MEDIUM、HIGH、CRITICAL。
A enum in io.agentscope.harness.agent.skill.curator that defines enum values used when components lets agents invoke external capabilities under control. Declared in io.agentscope.harness.agent.skill.curator.
Category
public enum Category定义类别相关取值的枚举。位于 io.agentscope.harness.agent.skill.curator 包。核心成员包括 EXFILTRATION、INJECTION、DESTRUCTIVE、PERSISTENCE、NETWORK、OBFUSCATION。
A enum in io.agentscope.harness.agent.skill.curator that defines enum values used when components lets agents invoke external capabilities under control. Declared in io.agentscope.harness.agent.skill.curator.
Verdict
public enum Verdict定义Verdict相关取值的枚举。位于 io.agentscope.harness.agent.skill.curator 包。核心成员包括 SAFE、CAUTION、DANGEROUS。
A enum in io.agentscope.harness.agent.skill.curator that defines enum values used when components lets agents invoke external capabilities under control. Declared in io.agentscope.harness.agent.skill.curator.
TrustLevel
public enum TrustLevel定义Trust 级别相关取值的枚举。位于 io.agentscope.harness.agent.skill.curator 包。核心成员包括 BUILTIN、TRUSTED、COMMUNITY、AGENT_CREATED。
Where the skill came from.
Finding
public record Finding( String patternId, Severity severity, Category category, String file, int line, String matchText, String description)承载 Finding数据的记录类型。位于 io.agentscope.harness.agent.skill.curator 包。核心成员包括 patternId、severity、category、file、line、matchText。
A record in io.agentscope.harness.agent.skill.curator that carries data used when components lets agents invoke external capabilities under control. Declared in io.agentscope.harness.agent.skill.curator.
ScanResult
public record ScanResult(Verdict verdict, List<Finding> findings, String reportText)承载 Scan 结果数据的记录类型。位于 io.agentscope.harness.agent.skill.curator 包。核心成员包括 verdict、findings、reportText。
A record in io.agentscope.harness.agent.skill.curator that carries data used when components lets agents invoke external capabilities under control. Declared in io.agentscope.harness.agent.skill.curator.