AS AgentScopeAPI 手册 / API Reference

SkillSecurityScanner

public final class SkillSecurityScanner
源码Source 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)
static

执行 scan 方法。

Scan a complete skill: SKILL.md + every support file.

参数Parameters
名称Name类型Type说明Description
skillNameString技能名称(类型 `String`)。The skill name.
skillMdString技能 Md(类型 `String`)。The skill md.
resourcesMap<String, String>resources(类型 `Map`)。The resources.
返回Returns ScanResult
返回ScanResult。Returns scan result.
源码Source io/agentscope/harness/agent/skill/curator/SkillSecurityScanner.java:262–277

scanSingleFile

public static ScanResult scanSingleFile(String relPath, String content)
static

执行 scanSingleFile 方法。

Scan a single file (used after write_file / patch).

参数Parameters
名称Name类型Type说明Description
relPathStringrel 路径(类型 `String`)。The rel path.
contentString内容(类型 `String`)。The content.
返回Returns ScanResult
返回ScanResult。Returns scan result.
源码Source io/agentscope/harness/agent/skill/curator/SkillSecurityScanner.java:280–284

shouldAllow

public static boolean shouldAllow(TrustLevel trust, Verdict verdict)
static

执行 shouldAllow 方法。

Map (trust × verdict) to an install decision.

参数Parameters
名称Name类型Type说明Description
trustTrustLeveltrust(类型 `TrustLevel`)。The trust.
verdictVerdictverdict(类型 `Verdict`)。The verdict.
返回Returns boolean
返回布尔值,表示判断结果。`true` if writing the skill should proceed; `false` if it must be blocked / rolled back.
源码Source io/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.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.