Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/static-analysis-gate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion src/rust/provers/chuffed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/rust/provers/faial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion src/rust/provers/gpuverify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 17 additions & 7 deletions src/rust/provers/test_fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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",
))
}
3 changes: 2 additions & 1 deletion src/rust/provers/version_probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 10 additions & 6 deletions src/rust/server/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down