Class SkillSecurityScanner

java.lang.Object
io.agentscope.harness.agent.skill.curator.SkillSecurityScanner

public final class SkillSecurityScanner extends Object
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):

The scan returns a SkillSecurityScanner.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.

  • Method Details

    • scan

      public static SkillSecurityScanner.ScanResult scan(String skillName, String skillMd, Map<String,String> resources)
      Scan a complete skill: SKILL.md + every support file. resources is a map of relative path → content (matching AgentSkill.getResources()). Returns the most severe verdict across all files.
    • scanSingleFile

      public static SkillSecurityScanner.ScanResult scanSingleFile(String relPath, String content)
      Scan a single file (used after write_file / patch).
    • shouldAllow

      public static boolean shouldAllow(SkillSecurityScanner.TrustLevel trust, SkillSecurityScanner.Verdict verdict)
      Map (trust × verdict) to an install decision. Mirrors hermes tools/skills_guard.py::INSTALL_POLICY.
      Returns:
      true if writing the skill should proceed; false if it must be blocked / rolled back.