# Replace Mystery Binary .pcap Fixtures in Git & CI/CD With .frasm

> **FrameAssembly v3.2.2** · Operational Playbook (Sanitize PCAP & CI/CD) · Canonical URL: https://frameassembly-lang.dev/use-cases/cicd-pcap-regression-testing

Build deterministic gRPC, PostgreSQL v3.0, and MQTT QoS 1 captures on the fly in GitHub Actions, GitLab CI, or Rust integration tests.

- **Category:** Sanitize PCAP & CI/CD
- **Capture Filename:** `cicd_parser_suite.frasm` (22 Ethernet frames)
- **Protocols Exercised:** `tcp`, `http2`, `grpc`, `postgres`, `mqtt`

## Operational Problem

Every DPI, eBPF/XDP, service-mesh, or SIEM repository has a cursed `tests/fixtures/` folder stuffed with binary `.pcap` blobs nobody can review in a pull request or update without breaking TCP sequence numbers.

Binary `.pcap` files are miserable in Git: `git diff` just prints `Binary files differ`, security scanners flag unknown binary blobs, and changing a gRPC method name or SQL query string requires recapturing live microservices in Docker.

Checking in `.frasm` text files (`text/vnd.frameassembly`) gives pull-request reviewers line-by-line diffs while the rootless `frameassembly` CLI or Rust `frameassembly` crate compiles byte-identical `.pcap` / `.pcapng` fixtures in under 1 millisecond during CI.

## Scenario & Topology: Microservice & Telemetry Parser CI Suite (gRPC + PostgreSQL v3.0 + MQTT QoS 1)

- **Topology:** `App Gateway (10.90.1.10) <-> gRPC Mesh (:50051), PostgreSQL (:5432) & MQTT Broker (:1883)`

Twenty-two deterministic frames exercise three complex binary/framed Layer 7 dissectors in a single CI fixture: (1) TCP 50051 handshake + `http2 settings` + `grpc` `/ledger.Payments/Authorize` (`grpcstatus 0` OK followed by `grpcstatus 14` UNAVAILABLE); (2) TCP 5432 handshake + `postgres startup` -> `authok` -> `query` -> `errorresponse`; and (3) TCP 1883 handshake + `mqtt connect` -> `connack` -> `qos 1` retained `publish` -> `puback`.

## FrameAssembly Workflow

Compiles 22 multi-service frames (HTTP/2 + gRPC status trailers, PostgreSQL v3.0 wire frames, and OASIS MQTT QoS 1) with deterministic timestamps.

### Adapt It for Your Network

1. Commit `.frasm` specs alongside your Suricata rules, Zeek scripts, eBPF parsers, or Wireshark Lua dissectors in Git.
2. Compile to `.pcap` or nanosecond `.pcapng` inside CI via the `frameassembly` CLI or `cargo add --dev frameassembly`.
3. When an existing binary fixture needs updating, run `frameassembly reverse legacy.pcap fixture.frasm` once and delete the opaque blob.

## Runnable Capture Specification (`cicd_parser_suite.frasm`)

```frameassembly
host app_gw     { ip 10.90.1.10 }
host backend_sv { ip 10.90.2.50 }

flow grpc_mesh_fixture(c, s) {
    // 1. HTTP/2 + gRPC call succeeding (0) and failing over (14 UNAVAILABLE) on TCP 50051
    c -> s tcp syn srcport 55051 dstport 50051 win 65535 mss 1460 wait 1ms
    c <- s tcp syn ack win 65535 mss 1460 wait 1ms
    c -> s tcp ack wait 1ms
    c -> s http2 settings wait 1ms
    c -> s grpc service "ledger.Payments" method "Authorize" wait 2ms
    c <- s grpc grpcstatus 0 wait 2ms
    c -> s grpc service "ledger.Payments" method "Settle" wait 2ms
    c <- s grpc grpcstatus 14 wait 3ms
}

flow postgres_and_mqtt_fixtures(c, s) {
    // 2. PostgreSQL v3.0 Startup -> AuthOk -> SQL Query -> ErrorResponse on TCP 5432
    c -> s tcp syn srcport 55432 dstport 5432 win 65535 mss 1460 wait 1ms
    c <- s tcp syn ack win 65535 mss 1460 wait 1ms
    c -> s tcp ack wait 1ms
    c -> s postgres startup user "ci_runner" db "ledger" wait 1ms
    c <- s postgres authok wait 1ms
    c -> s postgres query sql "SELECT tx_id, amount_cents FROM transfers LIMIT 5;" wait 2ms
    c <- s postgres errorresponse wait 3ms

    // 3. OASIS MQTT v3.1.1 Connect -> ConnAck -> QoS 1 Publish -> PubAck on TCP 1883
    c -> s tcp syn srcport 51883 dstport 1883 win 65535 mss 1460 wait 1ms
    c <- s tcp syn ack win 65535 mss 1460 wait 1ms
    c -> s tcp ack wait 1ms
    c -> s mqtt connect clientid "ci-sensor-01" keepalive 30 wait 1ms
    c <- s mqtt connack returncode 0 wait 1ms
    c -> s mqtt publish topic "ci/line1/watts" qos 1 retain pktid 10 payload "{\"w\":412.5}" wait 1ms
    c <- s mqtt puback pktid 10 wait 1ms
}

compile {
    grpc_mesh_fixture(app_gw, backend_sv)
    postgres_and_mqtt_fixtures(app_gw, backend_sv)
}
```

## Equivalent CLI Commands

```bash
# 1. Compile deterministic .pcapng in CI/CD (under 1ms, zero root privileges)
frameassembly cicd_parser_suite.frasm cicd_parser_suite.pcapng

# 2. Assert decoded gRPC, PostgreSQL, and MQTT fields in automated tshark / Zeek checks
tshark -r cicd_parser_suite.pcapng -Y "grpc || pgsql || mqtt"

# 3. Or convert legacy binary Git fixtures into reviewable .frasm source once
frameassembly reverse legacy_fixture.pcap readable_fixture.frasm
```

## Protocol Reference Links

- [`tcp` — Transmission Control Protocol & RFC 7323 Options](https://frameassembly-lang.dev/docs/protocols/tcp) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/tcp.md))
- [`http2` — Hypertext Transfer Protocol Version 2 Binary Framing](https://frameassembly-lang.dev/docs/protocols/http2) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/http2.md))
- [`grpc` — gRPC Remote Procedure Calls over HTTP/2](https://frameassembly-lang.dev/docs/protocols/grpc) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/grpc.md))
- [`postgres` — PostgreSQL Frontend/Backend Wire Protocol v3.0](https://frameassembly-lang.dev/docs/protocols/postgres) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/postgres.md))
- [`mqtt` — Message Queuing Telemetry Transport (IoT & IIoT)](https://frameassembly-lang.dev/docs/protocols/mqtt) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/mqtt.md))
