Commit Graph
26 Commits
Author SHA1 Message Date
haelyra 2d1e64b359 Merge reviewed PR #3673
# Conflicts:
#	skills/skill-comply/prompts/scenario_generator.md
#	skills/skill-comply/scripts/runner.py
2026-11-05 23:38:56 -05:00
haelyra 6d7d4920c8 fix: close final integration security and portability gaps 2026-10-29 12:57:39 -07:00
Wen a14e43f6c6 fix(skill-comply): find the tar archive after other option values in old-style clusters
In `tar xCf . bad.tar` GNU tar gives each value-taking letter the next argument in order, so C takes `.` and f takes `bad.tar`. The parser gave f the first argument, checked `.` (not a file) and let an unchecked archive write under .git. Old-style clusters now map value letters to arguments in order, and a short cluster gives its first value letter the rest of the cluster or the next argument, as getopt does.
2026-10-27 16:52:41 -03:00
Wen 1d10720b44 fix(skill-comply): check the archive operand, not selected members, before extraction 2026-10-27 16:52:41 -03:00
Wen 15819040cf fix(skill-comply): stop setup commands from planting git hooks
Greptile found three ways a generated setup could still place an
executable hook in the sandbox repository, which a later accepted
`git commit` then runs on the host:

- git init --template=<dir> (any unvetted git option)
- option values attached to the flag: cp --target-directory=.git,
  cp -t.git, tar --directory=.git
- archive members: tar -xf / unzip of an archive holding
  .git/hooks/pre-commit

Fixes:
- allowlist options per git subcommand; --template, --separate-git-dir,
  -c, --exec-path and the rest are refused
- treat every suffix of an option argument as a possible attached value
  and apply the in-sandbox / no-.git path check to it
- before tar -x or unzip, open every existing file argument with
  tarfile/zipfile and refuse unknown formats, links, special files and
  members that are absolute, contain .., or have a .git component;
  refuse unzip wildcards and run setup with stdin=/dev/null
- run setup git commands with -c core.hooksPath=/dev/null as defense
  in depth

Each sequence has a real-execution test in tests/test_invariant_runner.py
that fails on the previous head and passes now.

Signed-off-by: Wen <jwcastillo@gmail.com>
2026-10-27 16:52:40 -03:00
Wen e40a6c30da fix(skill-comply): block setup-command allowlist bypasses and use a per-user sandbox base
setup_commands are YAML from `claude -p`, generated from the skill under
test, and run on the host. The executable allowlist (cf59d0d28) passed
any arguments to the allowed tools, so several of them still ran
arbitrary code or reached outside the sandbox:

  git -c 'alias.x=!sh ...' x, git config core.* / alias.*
  tar --to-command, --checkpoint-action, --use-compress-program, -I
  npm/pip install with lifecycle scripts or setup.py, npm exec/run
  cp ~/.ssh/id_ed25519 ., mv src /elsewhere, cp x .git/hooks/...

Keep every allowed tool but limit it to file-creating uses:
- git: subcommand first (no -c/-C/--config-env), a short subcommand
  allowlist, and `git config` only for user.name/user.email/
  init.defaultBranch/commit.gpgsign
- tar: allowlisted flags and long options only, no host:file archives
- npm: `init -y`, or install/ci of registry names with --ignore-scripts
- pip: install of registry names, wheels only, into <sandbox>/.pip-packages
- every path argument must resolve inside the sandbox and outside its .git

The sandbox base moves from the shared /tmp/skill-comply-sandbox to a
per-user <tempdir>/skill-comply-sandbox-<uid>, created 0700, and is
rejected when another user owns it. The scenario prompt now asks for
sandbox-relative paths instead of the old absolute base.

Signed-off-by: Wen <jwcastillo@gmail.com>
2026-10-27 16:52:38 -03:00
Alfredo Revilla b85445735e fix(skill-comply): harden sandbox setup after review
- baseline commit ignores global gpgsign and hooks; git failures during
  sandbox setup raise instead of leaving a repo with no HEAD or origin/HEAD
- local origin defaults to the branch that is pushed, so a setup command
  that switches branches no longer breaks origin/HEAD
- gh stub lives in a per-scenario dir and fails on unsupported subcommands
- files: validated (mapping of str to str); paths under .git are rejected
- --fixtures keeps symlinks as links and skips .git
- --max-turns and --timeout must be positive; a timeout logs a warning
- SKILL.md documents the new flags and the sandbox
2026-10-22 20:43:20 -05:00
Alfredo Revilla 95b301d649 fix(skill-comply): create the resources a scenario needs in its sandbox
Scenario prompts named files (plans, configs) that were never created, so
agents halted and the report measured the broken setup, not the skill.

- scenarios carry a files: mapping (path -> content); --fixtures DIR copies
  a directory into each sandbox
- each sandbox gets a baseline commit, a local bare origin with origin/HEAD
  set, and a stub gh on PATH that fakes PR creation (no network)
- --max-turns and --timeout flags; a timeout keeps the partial trace
  instead of aborting the run
2026-10-22 20:40:47 -05:00
haelyra 63daf0e89d fix(skill-comply): send Unicode Claude prompts through stdin 2026-10-20 18:40:59 -04:00
Eneko Ruiz 1d20bed37f fix: treat optional-only specs as compliant
(cherry picked from commit ed6799f33c)
2026-10-20 17:41:10 -04:00
Eneko Ruiz 429737572a fix: use UTF-8 throughout skill compliance workflows
RED: seven Unicode regressions reproduced under Windows cp1252 and Linux ASCII with UTF-8 mode disabled. GREEN: Windows 91 passed with 5 platform skips; Linux ASCII 96 passed. Nine offline Unicode cases cover file, temporary YAML, prompt and all four CLI capture boundaries without model calls. Changed functions have 84.7% line coverage, each exceeds 80%; all 13 changed IO sites execute. Pi/catalog parity checks pass.
(cherry picked from commit 642cb0d512)
2026-10-20 17:41:00 -04:00
Eneko Ruiz 99b6a9bb8f fix: reject lossy classifier tool-call indices
RED: 6 failures proved booleans and fractional indices could invent evidence. GREEN: 49 targeted tests; full skill-comply suites pass on Windows (88 passed, 5 platform skips) and Linux (93 passed). Parser coverage 100%; exact integer floats and numeric strings remain supported. Pi/catalog checks pass.
(cherry picked from commit 6dde588860)
2026-10-20 17:40:59 -04:00
haelyra d0f5632287 fix: reject linked sandbox bases before scenario cleanup 2026-10-11 19:59:01 -04:00
haelyra cfeb773d96 fix: reject constant grader output and classify overflow errors 2026-10-11 17:32:22 -04:00
haelyra b71b832bf0 fix: reject malformed classifier values before reporting 2026-10-11 16:42:17 -04:00
haelyra ae4bc283ae fix: preserve classifier parse failures through compliance grading 2026-10-11 16:02:31 -04:00
drakeo338 7b34638500 fix: raise on unparseable skill-comply classifier output
_parse_classification returned {} for garbage or non-dict output, so a failed classification looked like zero matched steps and graded as non-compliant. Raise ClassifierParseError (a RuntimeError, like the non-zero-rc path) instead.
2026-10-11 19:21:15 +00:00
Eneko Ruiz c76d0e173a fix: reject the shared base as a scenario sandbox 2026-10-11 16:23:26 +02:00
Lukas 8b951d3bf6 fix(skill-comply): stop a failed step supplying evidence downstream (#3109)
* fix(skill-comply): stop a failed step supplying evidence downstream

`_check_temporal_order` fell back to the raw classifier output whenever
the referenced step was absent from `resolved`. A step only enters
`resolved` once it passes, so "failed" and "not graded yet" were the
same thing to that lookup, and a dependant could pass on an event
belonging to a prerequisite that had failed its own ordering check.

With three steps C, A (before C) and B (after A) and events C@T0,
A@T1, B@T2, A fails and B passed on A's classified event: 2/3 instead
of 1/3. It compounds down a chain, so one failed prerequisite could
leave a five-step workflow reading 4/5.

The grader now tracks which steps have been graded at all. A referenced
step that was graded and is missing from `resolved` failed, and its
events are refused with a reason that says so. A step not graded yet is
a forward reference to a step declared later, and the fallback stays as
it was: that is what makes an out-of-order declaration work, and the
existing regression for it goes red if the fallback is removed instead.

`before_step` deliberately keeps the old fallback. The two fail in
opposite directions: an `after_step` fallback can only turn a failure
into a pass, a `before_step` one can only turn a pass into a failure,
so dropping it would relax a constraint because some other step failed.

* fix(skill-comply): revoke a pass that rested on a later-failing prerequisite

Review of #3109 found the mirror image of the case that PR fixes. `graded`
only catches a prerequisite that had already failed when its dependant was
graded. A step declared *before* its `after_step` is graded against the
classifier's raw events for a step that has not run yet — the fallback that
makes an out-of-order declaration work — and nothing revisited it once that
step went on to fail its own checks.

Add a pass after grading that demotes any detected step whose `after_step`
ended up failing, repeated to a fixed point: one demotion can invalidate
whatever depended on it, in either declaration order. Demotion only removes
passes, so it terminates. `compliance_rate` is computed from the demoted
results.

Also from review: build `graded` and the chain test's step list as new
objects rather than mutating (AGENTS.md immutability rule), and annotate the
injected mocks in the tests this PR owns.
2026-09-21 14:39:20 -04:00
haelyra 30c41a9bde fix: close truth and portability review gaps 2026-08-29 14:55:14 -04:00
haelyra d08331f14e fix(skill-comply): harden home path redaction 2026-08-29 14:55:13 -04:00
cyre 2242e4d99d fix(skill-comply): redact operator home path from compliance reports
_parse_stream_json() persisted raw tool_input/tool_response content into
ObservationEvents that grade() scores and generate_report() writes to
results/<skill>.md -- a report meant to be shared and reviewed.

--add-dir restricts the agent's additional accessible directory to the
sandbox (SANDBOX_BASE = /tmp/skill-comply-sandbox), but that doesn't stop
the agent's own tool calls (a Bash command using ~ expansion, a scenario
setup_commands entry referencing a dotfile) from emitting the operator's
home directory into tool_input/tool_response -- which then lands
verbatim, truncated but not sanitized, in the written report.

Adds _redact_home_path(), pure stdlib (Path.home()), applied to both
input_str and output_str before they're stored on the ObservationEvent.
Scoped deliberately to the home directory only -- grade() needs real
tool-call semantics for LLM-based compliance classification, so
truncating/stripping content the way a pure logging hook could isn't an
option here; only the operator-identifying path component needs to go.

New TestParseStreamJsonRedactsHomePath class in
skills/skill-comply/tests/test_runner.py (3 tests) -- full file now
10/10 passing, up from 7/7. Confirmed tests/test_invariant_runner.py (the
sandbox-execution security tests from #2149) still passes clean, 4/4.

Fixes #2730
2026-08-29 14:55:13 -04:00
OrbisAI SecurityandClaude Sonnet 4.6 cf59d0d283 fix: sanitize subprocess call in runner.py (#2149)
* fix: V-001 security vulnerability

Automated security fix generated by OrbisAI Security

* fix: sanitize subprocess call in runner.py

The runner

* fix: address PR review comments on V-001 allowlist and test coverage

Remove dangerous interpreters (python, python3, node, curl, wget) from
ALLOWED_SETUP_EXECUTABLES — they can execute arbitrary code via argument
flags and are not needed for sandbox setup. Rewrite test_invariant_runner
to call _setup_sandbox directly instead of spawning runner.py as a
subprocess (which had no __main__ entrypoint and never exercised the fix).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-15 13:49:45 -04:00
Affaan Mustafa b39d2244cf docs: salvage focused stale PR contributions
- add Vite and Redis pattern skills from closed stale PRs

- add frontend-slides support assets

- port skill-comply runner fixes and LLM prompt/provider regressions

- harden agent frontmatter validation and sync catalog counts
2026-05-11 05:31:12 -04:00
Affaan Mustafa 0fcb43ea90 fix(grader): handle forward after_step references 2026-04-12 23:36:16 -07:00
ShimoandClaude Opus 4.6 a2e465c74d feat(skills): add skill-comply — automated behavioral compliance measurement (#724)
* feat(skills): add skill-comply — automated behavioral compliance measurement

Automated compliance measurement for skills, rules, and agent definitions.
Generates behavioral specs, runs scenarios at 3 strictness levels,
classifies tool calls via LLM, and produces self-contained reports.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(skill-comply): address bot review feedback

- AGENTS.md: fix stale skill count (115 → 117) in project structure
- run.py: replace remaining print() with logger, add zero-division guard,
  create parent dirs for --output path
- runner.py: add returncode check for claude subprocess, clarify
  relative_to path traversal validation
- parser.py: use is_file() instead of exists(), catch KeyError for
  missing trace fields, add file check in parse_spec
- classifier.py: log warnings on malformed classification output,
  guard against non-dict JSON responses
- grader.py: filter negative indices from LLM classification

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 21:51:49 -07:00