From a355532881e39fb13e3efbc03f8fa71a4b22c700 Mon Sep 17 00:00:00 2001 From: mnovak Date: Fri, 4 Dec 2026 13:04:14 +0100 Subject: [PATCH] [repo] Mutation: host mutants M25-M51 (pairing, HTTP, RTSP, ANNOUNCE, DESCRIBE, ENet host and client session ids, control host, video and audio packetizers); a row may name several test binaries --- tools/mutation/mutate.py | 88 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/tools/mutation/mutate.py b/tools/mutation/mutate.py index f796d5e..2cad457 100644 --- a/tools/mutation/mutate.py +++ b/tools/mutation/mutate.py @@ -127,6 +127,91 @@ mut("M23", "OS randomness", "getrandom added as a dependency and used in src/ent "\n#[allow(dead_code)]\nfn os_fill(dest: &mut [u8]) {\n let _ = getrandom::fill(dest);\n}\n")]) +# ---- host side (Lumen, stream-v0.2.0, 2026-12-04). `test` may name several test binaries, space-separated. +HP = SRC + "host/pairing.rs" +mut("M25", "host pairing phase", "phase 4 accepted while phase 3 is expected (a skipped step)", "host_pairing session", + [(HP, "(HostPairingState::AwaitClientPairingSecret, PairPhase::ClientPairingSecret(value)) => {", + "(HostPairingState::AwaitClientPairingSecret | HostPairingState::AwaitServerChallengeResp, " + "PairPhase::ClientPairingSecret(value)) => {")]) +mut("M26", "host pairing proof", "the client's proof H_c is not compared (any PIN pairs)", "host_pairing", + [(HP, "if !ct_eq(&expected, &self.client_proof) {", "if false && !ct_eq(&expected, &self.client_proof) {")]) +mut("M27", "host pairing phase 5", "phase 5 accepts any HTTPS client certificate", "host_pairing", + [(HP, "if !ct_eq(client_cert_der, &pending.cert_der) {", "if false && !ct_eq(client_cert_der, &pending.cert_der) {")]) +HH = SRC + "host/http/mod.rs" +mut("M28", "host HTTP cap", "query parameter cap off by one (allows 33)", "host_http", + [(HH, 'cap("http query parameters", MAX_PARAMS, count)?;', 'cap("http query parameters", MAX_PARAMS + 1, count)?;')]) +mut("M29", "host HTTP body", "a GET with Content-Length other than 0 accepted", "host_http", + [(HH, 'if content_length || value != "0" {', "if content_length {")]) +mut("M30", "host HTTP answer", "PairStatus 1 over plain HTTP too", "host_http session", + [(SRC + "host/http/answer.rs", "let paired = scheme == Scheme::Https && client_paired;", + "let paired = client_paired;")]) +RS = SRC + "rtsp/server/mod.rs" +mut("M31", "RTSP order", "PLAY accepted before ANNOUNCE", "rtsp_server", + [(RS, 'self.expect(RtspServerState::Play, "PLAY after ANNOUNCE").map_err(|e| refuse(455, e))?;', + 'let _ = self.expect(RtspServerState::Play, "PLAY after ANNOUNCE");')]) +mut("M32", "RTSP order", "a second SETUP of the same stream accepted", "rtsp_server", + [(RS, " if *slot {\n", " if *slot && false {\n")]) +mut("M33", "RTSP session", "a Session header with another id accepted once issued", "rtsp_server", + [(RS, "Some(id) if !self.session_issued || id != self.session_id => {", "Some(id) if !self.session_issued => {")]) +mut("M34", "ANNOUNCE", "a known attribute given twice accepted (the first value kept)", "rtsp_server", + [(SRC + "rtsp/server/announce.rs", 'Some(Some(_)) => return Err(malformed("announce: an attribute given twice")),', + "Some(Some(_)) => {}")]) +mut("M35", "DESCRIBE", "the refPicInvalidation line written exactly when not offered", "rtsp_server session", + [(SRC + "rtsp/server/describe.rs", "if offer.reference_frame_invalidation {", + "if !offer.reference_frame_invalidation {")]) +EH = SRC + "enet/host.rs" +mut("M36", "ENet host ack", "pings acknowledged before the verify is acknowledged", "enet_host", + [(EH, " CommandBody::Ping | CommandBody::BandwidthLimit { .. } | CommandBody::ThrottleConfigure { .. } => {\n" + " if c.acknowledge && connected {", + " CommandBody::Ping | CommandBody::BandwidthLimit { .. } | CommandBody::ThrottleConfigure { .. } => {\n" + " if c.acknowledge {")]) +mut("M37", "ENet host ack", "a datagram without sent time goes on after an acknowledged command", "enet_host", + [(EH, "if wants_ack && sent_time.is_none() {", "if false && wants_ack && sent_time.is_none() {")]) +mut("M38", "ENet host session id", "host session ids taken from the wrong offered field", "enet_host", + [(EH, "let out_session = next_session(p.incoming_session_id, FRESH_SESSION);\n" + " let in_session = next_session(p.outgoing_session_id, FRESH_SESSION);", + "let out_session = next_session(p.outgoing_session_id, FRESH_SESSION);\n" + " let in_session = next_session(p.incoming_session_id, FRESH_SESSION);")]) +mut("M39", "ENet host session id", "the slot's previous session id not skipped", "enet_host", + [(EH, " if s == current {\n", " if false && s == current {\n")]) +mut("M40", "ENet client session id", "verify's session ids swapped again (the bug fixed for v0.2.0)", "enet", + [(SRC + "enet/mod.rs", "self.in_session = p.incoming_session_id & 0x3;\n self.out_session = p.outgoing_session_id & 0x3;", + "self.in_session = p.outgoing_session_id & 0x3;\n self.out_session = p.incoming_session_id & 0x3;")]) +CH = SRC + "control/host.rs" +mut("M41", "control host replay", "a repeated client sequence number accepted (< instead of <=)", "control_host", + [(CH, "if self.last_client_sequence.is_some_and(|last| sequence <= last) {", + "if self.last_client_sequence.is_some_and(|last| sequence < last) {")]) +mut("M42", "control host replay", "the client replay check removed", "control_host", + [(CH, "if self.last_client_sequence.is_some_and(|last| sequence <= last) {", + "if self.last_client_sequence.is_some_and(|last| sequence <= last && false) {")]) +mut("M43", "control host message", "extended termination code written little-endian", "control_host session", + [(CH, "framed(MessageType::TerminationExtended, &code.to_be_bytes())", + "framed(MessageType::TerminationExtended, &code.to_le_bytes())")]) +mut("M44", "control host stop", "a PERIODIC_PING does not move the stop deadline", "control_host session", + [(CH, "self.deadline = self.deadline.max(now.saturating_add(self.timeout));", "self.deadline = self.deadline.max(now);")]) +VP = SRC + "video/packetizer.rs" +mut("M45", "video parity order", "parity computed after the parity headers are written (headers become parity)", + "video_packetizer session", + [(VP, " ReedSolomon::new(k, m)?.encode(&mut shards)?;\n", ""), + (VP, " parity_packets += m as u64;", + " ReedSolomon::new(k, m)?.encode(&mut shards)?;\n parity_packets += m as u64;")]) +mut("M46", "video parity", "the client's minimum parity count ignored", "video_packetizer", + [(VP, "if m < usize::from(min) { usize::from(min) } else { m }", "if m < usize::from(min) { m } else { m }")]) +mut("M47", "video parity", "parity shard index written one too high", "video_packetizer", + [(VP, "let h = next_header(0, block, u16::try_from(k + j).unwrap_or(u16::MAX), b);", + "let h = next_header(0, block, u16::try_from(k + j + 1).unwrap_or(u16::MAX), b);")]) +mut("M48", "video nonce", "the GCM nonce counter does not advance per datagram (nonce reuse)", "video_packetizer", + [(VP, " nonce += 1;\n", " nonce += 0;\n")]) +mut("M49", "audio IV", "the host encrypts with the IV of the next sequence number", "audio_packetizer session", + [(SRC + "audio/mod.rs", "plaintext.len())?;\n let iv = self.iv(sequence)?;", + "plaintext.len())?;\n let iv = self.iv(sequence.wrapping_add(1))?;")]) +mut("M50", "audio IV", "IV counter written little-endian (both sides)", "media audio_packetizer", + [(SRC + "audio/mod.rs", "self.rikeyid.wrapping_add(u32::from(sequence)).to_be_bytes();", + "self.rikeyid.wrapping_add(u32::from(sequence)).to_le_bytes();")]) +mut("M51", "audio block start", "a first sequence number that is not a block start accepted", "audio_packetizer", + [(SRC + "audio/packetizer.rs", "if !config.first_sequence.is_multiple_of(4) {", "if false {")]) + + def sh(args, **kw): return subprocess.run(args, cwd=REPO, capture_output=True, text=True, encoding="utf-8", errors="replace", **kw) @@ -170,7 +255,8 @@ def main(): continue apply(m["edits"]) try: - cmd = f"cargo test -j 2 --offline --test {m['test']} -- --test-threads=2 2>&1 | Out-File -Encoding utf8 {QA}\\mut-{m['id']}.log" + tests = " ".join(f"--test {t}" for t in m["test"].split()) + cmd = f"cargo test -j 2 --offline --no-fail-fast {tests} -- --test-threads=2 2>&1 | Out-File -Encoding utf8 {QA}\\mut-{m['id']}.log" gated(cmd) log = open(os.path.join(QA, f"mut-{m['id']}.log"), encoding="utf-8-sig", errors="replace").read() finally: