Skip to content

Add rule2pcap agent skill - #264

Open
whartond wants to merge 2 commits into
secureworks:masterfrom
whartond:rule2pcap
Open

whartond wants to merge 2 commits into
secureworks:masterfrom
whartond:rule2pcap

Conversation

@whartond

Copy link
Copy Markdown
Contributor

Adds rule2pcap, an Agent Skill (.agents/skills/rule2pcap/) that turns a Suricata rule into a realistic pcap that fires it. The agent researches the traffic behind the rule, builds the capture reproducibly, tests it through Dalton on every Suricata version available, and writes up what is confirmed versus invented.

  • SKILL.md: the workflow (preflight, decode, validate, research, build, lint, test, report)
  • scripts/: dalton_client.py (preflight / validate / test against the Dalton API, with an opt-in Docker fallback; an engine that never reads the pcap, because the job timed out or crashed or the engine stopped on a config error, is reported as not run and exits 2), rule_facts.py (decodes contents, buffers, roles and build-relevant notes), pcap_lint.py (flags broken or unrealistic packets)
  • templates/: Flowsynth, Scapy and TLS build scripts plus pcapkit.py helpers that work around Flowsynth 1.4 defects and give each host its OS's TCP options, windows and timestamps
  • references/: Suricata gotchas, Flowsynth notes, realism, research and write-up guides
  • evals/evals.json: nine eval prompts
  • README section, including a note that a pcap built from a rule checks the rule's syntax and structure but can't prove it detects the real threat (SKILL.md has the agent say so when asked for that); .gitignore entries, cryptography in the testing extras, ruff covers .agents/

The build venv pins flowsynth 1.4.1, scapy 2.8.0, ruamel.yaml 0.17.40 and cryptography 50.0.2 (checked on Python 3.10 to 3.14). Nothing is installed into the system Python.

Testing: new tests/test_rule2pcap_*.py; the full suite passes (185) apart from the existing test_flowsynth.py::test_pcap_compile_fs failure, which is unrelated. The templates rebuild byte-identically and fire on Suricata 7.0.17 and 8.0.6, through Dalton (normal and socket-control jobs) and the Docker runner. All nine evals passed end to end in independent runs, and the threshold, TLS and Suricata 8-keyword evals passed again after the review fixes. In a further blind run on 18 private training rules, every pcap fired on both engines, 17 of them on the first build.

Related: secureworks/flowsynth#29 fixes the Flowsynth defects the templates currently work around; the workarounds stay harmless with it.

Also fixes two README code blocks that didn't render (separate commit).

An Agent Skill that turns a Suricata rule into a realistic pcap that fires
it, verified through Dalton on each Suricata version. Includes helper
scripts (Dalton client, rule decoder, pcap linter), build templates,
reference notes, evals and tests, plus a README section.
@whartond
whartond marked this pull request as ready for review November 20, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant