diff --git a/.github/workflows/static-analysis-gate.yml b/.github/workflows/static-analysis-gate.yml index 8414a119..88b6d1d4 100644 --- a/.github/workflows/static-analysis-gate.yml +++ b/.github/workflows/static-analysis-gate.yml @@ -18,11 +18,15 @@ env: # panic-attack runs ahead of the standards-vetted 410a8f8 (hypatia-scan-reusable # default) because that commit cannot report complete coverage for this tree: # 190 config/markup inputs were "unsupported", so --fail-on-incomplete exited 2 - # before any finding was counted. f2a6a70 includes the coverage repair - # (panic-attack#258: 913/913 inputs here) and Patch Bridge schema 0.3.0 - # (vulnerability_data), which the qualifier below checks. + # before any finding was counted. The pin includes the coverage repair + # (panic-attack#258: every input here is analyzed) and Patch Bridge schema + # 0.3.0 (vulnerability_data), which the qualifier below checks. It also + # includes line-anchored Lean and Isabelle `sorry` findings + # (panic-attack#278). Without them the scanner cannot apply the inline + # `panic-attack: accepted` markers on the 2 detector fixtures under + # tests/corpus_fixtures/, and reports both as Critical. HYPATIA_REF: 82396d81677b11d17c7a0dede5bf0efcf768d5a1 - PANIC_ATTACK_REF: f2a6a70eaec0cb02331e3264e05f185b5faab0f7 + PANIC_ATTACK_REF: 55ffcc9a240e937edd968487af15ab45c6f0522f SCAN_EXPECTED_SHA: ${{ github.event.pull_request.head.sha || github.sha }} jobs: panic-attack-assail: diff --git a/src/rust/provers/chuffed.rs b/src/rust/provers/chuffed.rs index 35d30d3a..362edaea 100644 --- a/src/rust/provers/chuffed.rs +++ b/src/rust/provers/chuffed.rs @@ -241,7 +241,8 @@ mod tests { crate::provers::test_fixture::write_executable( &executable, &format!("#!/bin/sh\n[ \"$#\" -eq 1 ] && [ \"$1\" = '--help' ] || exit 64\n{script}\n"), - ); + ) + .unwrap(); let backend = ChuffedBackend::new(ProverConfig { executable, timeout, diff --git a/src/rust/provers/faial.rs b/src/rust/provers/faial.rs index d4e8cb41..f17ae251 100644 --- a/src/rust/provers/faial.rs +++ b/src/rust/provers/faial.rs @@ -362,7 +362,8 @@ mod tests { &format!( "#!/bin/sh\n[ \"$#\" -eq 1 ] && [ \"$1\" = '--version' ] || exit 64\n{script}\n" ), - ); + ) + .unwrap(); let backend = FaialBackend::new(ProverConfig { executable, timeout, diff --git a/src/rust/provers/gpuverify.rs b/src/rust/provers/gpuverify.rs index 2a8c4bf0..273af37e 100644 --- a/src/rust/provers/gpuverify.rs +++ b/src/rust/provers/gpuverify.rs @@ -396,7 +396,8 @@ mod tests { &format!( "#!/bin/sh\n[ \"$#\" -eq 1 ] && [ \"$1\" = '--version' ] || exit 64\n{script}\n" ), - ); + ) + .unwrap(); let backend = GpuVerifyBackend::new(ProverConfig { executable, timeout, diff --git a/src/rust/provers/test_fixture.rs b/src/rust/provers/test_fixture.rs index c148a3bf..5d381216 100644 --- a/src/rust/provers/test_fixture.rs +++ b/src/rust/provers/test_fixture.rs @@ -19,24 +19,31 @@ use std::os::unix::fs::{OpenOptionsExt, PermissionsExt}; use std::path::Path; use std::time::Duration; +/// Name the step in a failed fixture write, so a test failure says which one. +fn step(what: &'static str) -> impl FnOnce(std::io::Error) -> std::io::Error { + move |error| std::io::Error::new(error.kind(), format!("{what}: {error}")) +} + /// Write `contents` to `path` as an owner-executable script and wait until the /// kernel will execute it. The script must exit without side effects when /// called with a single unexpected argument. -pub(crate) fn write_executable(path: &Path, contents: &str) { +/// +/// An error names the step that failed. The calling test decides how to fail. +pub(crate) fn write_executable(path: &Path, contents: &str) -> std::io::Result<()> { { let mut file = std::fs::OpenOptions::new() .write(true) .create_new(true) .mode(0o700) .open(path) - .expect("create fixture executable"); + .map_err(step("create fixture executable"))?; file.write_all(contents.as_bytes()) - .expect("write fixture executable"); + .map_err(step("write fixture executable"))?; } // The creation mode is filtered by the umask; set it explicitly so the // fixture is executable whatever umask the test runner inherited. std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o700)) - .expect("make fixture executable"); + .map_err(step("make fixture executable"))?; for _ in 0..200 { match std::process::Command::new(path) .arg("--echidna-fixture-ready") @@ -48,9 +55,12 @@ pub(crate) fn write_executable(path: &Path, contents: &str) { Err(error) if error.kind() == ErrorKind::ExecutableFileBusy => { std::thread::sleep(Duration::from_millis(10)); }, - Err(error) => panic!("fixture executable cannot run: {error}"), - Ok(_) => return, + Err(error) => return Err(step("fixture executable cannot run")(error)), + Ok(_) => return Ok(()), } } - panic!("fixture executable stayed busy (ETXTBSY) for 2 s"); + Err(std::io::Error::new( + ErrorKind::ExecutableFileBusy, + "fixture executable stayed busy (ETXTBSY) for 2 s", + )) } diff --git a/src/rust/provers/version_probe.rs b/src/rust/provers/version_probe.rs index 0410de7c..adee17ec 100644 --- a/src/rust/provers/version_probe.rs +++ b/src/rust/provers/version_probe.rs @@ -59,7 +59,8 @@ mod tests { &format!( "#!/bin/sh\n[ \"$#\" -eq 1 ] && [ \"$1\" = '--version' ] || exit 64\n{script}\n" ), - ); + ) + .unwrap(); let config = ProverConfig { executable, timeout, diff --git a/src/rust/server/session.rs b/src/rust/server/session.rs index 9891e3b6..d1b8257b 100644 --- a/src/rust/server/session.rs +++ b/src/rust/server/session.rs @@ -90,17 +90,17 @@ pub(super) async fn apply_tactic_handler( let mut session = session_arc.lock().await; // Ensure we have a state - if session.state.is_none() { + let Some(proof_state) = session.state.as_ref() else { return Err(AppError::BadRequest( "No proof loaded in session".to_string(), )); - } + }; + let goals_before = proof_state.goals.len(); // Parse tactic (simplified) let tactic = parse_tactic_from_json(&req.tactic)?; // Apply tactic - let proof_state = session.state.as_ref().unwrap(); let result = session .prover .apply_tactic(proof_state, &tactic) @@ -110,26 +110,30 @@ pub(super) async fn apply_tactic_handler( match result { TacticResult::Success(new_state) => { let complete = new_state.is_complete(); + let goals_remaining = new_state.goals.len(); session.state = Some(new_state); session.history.push(req.tactic.clone()); Ok(Json(ApplyTacticResponse { success: true, complete, - goals_remaining: session.state.as_ref().unwrap().goals.len(), + goals_remaining, message: "Tactic applied successfully".to_string(), })) }, + // A failed tactic leaves the proof state as it was. TacticResult::Error(msg) => Ok(Json(ApplyTacticResponse { success: false, complete: false, - goals_remaining: session.state.as_ref().unwrap().goals.len(), + goals_remaining: goals_before, message: msg, })), TacticResult::QED => { - session.state.as_mut().unwrap().goals.clear(); + if let Some(proof_state) = session.state.as_mut() { + proof_state.goals.clear(); + } Ok(Json(ApplyTacticResponse { success: true,