# Zero-Binary `.pcap` Fixtures in Git & CI/CD (Suricata, Zeek & pytest)

> **FrameAssembly v3.2.2** · Workflow Guide 09 · Canonical URL: https://frameassembly-lang.dev/docs/ci-cd-pcap-testing

Stop committing mystery `test_case_final_v3.pcap` blobs to Git. Check in diffable `.frasm` text and build identical `.pcap` or `.pcapng` fixtures on the fly in CI.

## Key Takeaways

- Binary `.pcap` files in Git show `Binary files differ` in pull requests and frequently hide unredacted customer IPs or stale checksums.
- Checking `.frasm` files into `tests/fixtures/` makes every IP, TCP flag, VLAN tag, and Layer 7 payload line-by-line reviewable in `git diff`.
- `frameassembly` compiles a typical test fixture in under 2 milliseconds with zero `sudo`, zero Npcap, and zero Python dependency resolution.

## 1. Why Binary `.pcap` Fixtures Rot in Repositories

Every detection engineering, firewall automation, or protocol parser repository eventually grows a `tests/pcaps/` folder full of opaque binary blobs nobody dares touch. When a pull request updates `cve_2026_probe.pcap`, reviewers cannot see whether the author changed one HTTP header or accidentally leaked a production subnet.

Storing `.frasm` source files in Git instead turns packet captures into ordinary code reviews. Reviewers read exact `->` and `<-` lines in GitHub or GitLab diffs, and CI compiles byte-identical `.pcap` files during the test job.

### `tests_http_sqli_fixture.frasm`

```frameassembly
// Reviewable Git fixture for WAF / Suricata rule SID:2099001
host scanner { ip 198.51.100.44 }
host app_waf { ip 10.30.0.80 }

compile {
    scanner -> app_waf tcp syn srcport 54120 dstport 80 win 65535 mss 1460 wait 1ms
    scanner <- app_waf tcp syn ack win 65535 mss 1460 wait 1ms
    scanner -> app_waf tcp ack wait 1ms
    scanner -> app_waf http get uri "/search?q=%27%20OR%201%3D1--" hosthdr "shop.example.test" useragent "ci-regression/1.0" wait 2ms
    scanner <- app_waf http status 403 reason "Forbidden" contenttype "application/json" body "{\"blocked\":true}"
}
```

## 2. GitHub Actions Pipeline: `.frasm` -> Suricata, Zeek & `tshark`

Because `frameassembly` is a single static binary that needs zero root capabilities (`CAP_NET_RAW`), it runs cleanly inside unprivileged Docker containers and standard GitHub Actions runners:

```bash
# Quick local pre-commit check: validate every .frasm file without writing disk artifacts
for f in tests/fixtures/*.frasm; do frameassembly show "$f" > /dev/null; done
```

### .github/workflows/packet-regression.yml

```yaml
name: Detection & Dissector Regression
on: [push, pull_request]

jobs:
  suricata-and-tshark:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install FrameAssembly + tshark + Suricata
        run: |
          curl -fsSL https://raw.githubusercontent.com/SteveWinschel/FrameAssembly/main/install.sh | sh
          echo "$HOME/.local/bin" >> "$GITHUB_PATH"
          sudo apt-get update && sudo apt-get install -y tshark suricata jq

      - name: Compile .frasm fixtures and verify alerts
        run: |
          for f in tests/fixtures/*.frasm; do
            frameassembly "$f" "${f%.frasm}.pcap"
          done
          suricata -r tests/fixtures/tests_http_sqli_fixture.pcap -S rules/local.rules -l ./suricata-logs
          jq -e 'select(.event_type == "alert" and .alert.signature_id == 2099001)' ./suricata-logs/eve.json
```

## 3. Ephemeral `.pcap` Fixtures in `pytest` (Python) & `cargo test` (Rust)

Testing a Python dissector, Go collector, or Rust DPI library? Compile `.frasm` strings into `tmp_path` during `pytest` (or directly in RAM via `cargo add --dev frameassembly`) so tests stay fast and self-contained:

### tests/test_dns_parser.py (pytest + subprocess)

```python
import subprocess
from pathlib import Path

def compile_frasm(tmp_path: Path, name: str, frasm_src: str) -> Path:
    frasm_file = tmp_path / f"{name}.frasm"
    pcap_file = tmp_path / f"{name}.pcapng"
    frasm_file.write_text(frasm_src, encoding="utf-8")
    subprocess.run(["frameassembly", str(frasm_file), str(pcap_file)], check=True)
    return pcap_file

def test_dns_nxdomain_wire_parse(tmp_path: Path) -> None:
    pcap = compile_frasm(
        tmp_path,
        "nxdomain",
        """
        host c { ip 10.0.0.10 }
        host s { ip 10.0.0.53 }
        compile {
            c -> s dns query txid 0x3100 qname "missing.corp.test" qtype "A" wait 2ms
            c <- s dns response txid 0x3100 rcode 3 qname "missing.corp.test" qtype "A"
        }
        """,
    )
    out = subprocess.check_output(
        ["tshark", "-r", str(pcap), "-Y", "dns.flags.rcode == 3", "-T", "fields", "-e", "dns.qry.name"],
        text=True,
    ).strip()
    assert out == "missing.corp.test"
```

> **Migrating Existing Binary `.pcap` Tests in One Loop:** Run `for p in tests/pcaps/*.pcap; do frameassembly reverse "$p" "${p%.pcap}.frasm"; done` to convert legacy binary captures into human-readable `.frasm` fixtures.
