fix: close release-gate defects in platform cfg, strict launch, and semantics
WHY - macOS/Windows failed to compile because `cfg!` left `linux::probe()` in the type-checked branch (E0433). - GitHub-hosted Linux can pass the strict probe and then fail the real launch with EAGAIN; the CLI test treated the inspect snapshot as a permanent promise. - The security matrix shared process-id-based scratch paths, so parallel `cargo test --workspace` made its own tests clobber each other. - Condition paragraphs silently ignored executable `Strong`/`Emph`, and condition parse spans included the code-span backticks. - The corpus had no native power/control-flow/inert fixtures and no independent generic Tool consumers. WHAT - Dispatch strict detection through `#[cfg]` functions; add a non-Linux compile/fail-closed regression test. - Split `linux::run` into an injectable probe/spawn seam; test probe-OK -> launch-EAGAIN returns LaunchFailed and never executes unrestricted. - Make the Linux CLI contract accept only (a) successful isolated run or (b) non-zero, diagnosed, fail-closed refusal with no project stdout. - Give each security test a unique project/outside path and compile the helper once. - Reject executable roles in a condition paragraph; map condition expressions from the literal bytes inside the backticks. - Add 10 AST, 8 semantic, 4 compile-negative and 2 runtime-negative fixtures for power, branch/loop conditions, source spans, inert prose/code fences and error boundaries. - Add `sample-view`/`sample-knowledge`/`sample-proof` independent Tool v1 packages and an end-to-end Analysis/Trace consumer test. - Add a locked path-dependency content-tamper test. TESTS - cargo fmt --all -- --check - cargo clippy --workspace --all-targets -- -D warnings - cargo test --workspace --locked - G-C VM lane (separate evidence commit/run) CI_URL - none from this host: the checkout has a Gitee remote and no GitHub credentials. Windows/macOS CI remains UNVERIFIED. BREAKING_CHANGE - An executable node in a list-item condition paragraph is now a hard `markdown.invalid_construct` error instead of being silently ignored. SECURITY_SCOPE - strict remains fail-closed; no downgrade, no new capability, L2 still rejected. G-C still requires the dedicated self-hosted lane for CI-signed evidence.
This commit is contained in:
1 parent
c9f01aa8fb
commit
d05f36fd26
65 files changed
+2134
-87
No files matched your search
@@ -19,6 +19,8 @@ use std::ffi::OsString;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::sync::OnceLock;
|
||||
use std::time::Duration;
|
||||
|
||||
use marqdo_sandbox::{launch_strict_capture, probe, StrictHostCommand, StrictOutcome};
|
||||
@@ -30,28 +32,36 @@ fn required() -> bool {
|
||||
== Some("1")
|
||||
}
|
||||
|
||||
/// Compile the escape helper exactly once even when the test binary runs its
|
||||
/// tests in parallel.
|
||||
fn helper() -> Option<PathBuf> {
|
||||
if let Ok(path) = std::env::var("MARQDO_SECURITY_HELPER") {
|
||||
let path = PathBuf::from(path);
|
||||
assert!(path.is_file(), "MARQDO_SECURITY_HELPER does not exist");
|
||||
return Some(path);
|
||||
}
|
||||
let source = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/security/escape_helper.c");
|
||||
let output = std::env::temp_dir().join(format!(
|
||||
"marqdo-escape-helper-{}{}",
|
||||
std::process::id(),
|
||||
std::env::consts::EXE_SUFFIX
|
||||
));
|
||||
let status = Command::new("cc")
|
||||
.args(["-O2", "-o"])
|
||||
.arg(&output)
|
||||
.arg(&source)
|
||||
.status()
|
||||
.ok()?;
|
||||
if !status.success() {
|
||||
return None;
|
||||
}
|
||||
Some(output)
|
||||
static HELPER: OnceLock<Option<PathBuf>> = OnceLock::new();
|
||||
HELPER
|
||||
.get_or_init(|| {
|
||||
if let Ok(path) = std::env::var("MARQDO_SECURITY_HELPER") {
|
||||
let path = PathBuf::from(path);
|
||||
assert!(path.is_file(), "MARQDO_SECURITY_HELPER does not exist");
|
||||
return Some(path);
|
||||
}
|
||||
let source =
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../tests/security/escape_helper.c");
|
||||
let output = std::env::temp_dir().join(format!(
|
||||
"marqdo-escape-helper-{}{}",
|
||||
std::process::id(),
|
||||
std::env::consts::EXE_SUFFIX
|
||||
));
|
||||
let status = Command::new("cc")
|
||||
.args(["-O2", "-o"])
|
||||
.arg(&output)
|
||||
.arg(&source)
|
||||
.status()
|
||||
.ok()?;
|
||||
if !status.success() {
|
||||
return None;
|
||||
}
|
||||
Some(output)
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
|
||||
fn setup() -> Option<(PathBuf, PathBuf, PathBuf)> {
|
||||
@@ -72,7 +82,12 @@ fn setup() -> Option<(PathBuf, PathBuf, PathBuf)> {
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let project = std::env::temp_dir().join(format!("marqdo-security-{}", std::process::id()));
|
||||
// `cargo test` runs these tests in parallel. The project and outside
|
||||
// paths must be unique per test or two tests can remove each other's
|
||||
// project between the supervisor mount and the assertion.
|
||||
static NEXT: AtomicU64 = AtomicU64::new(0);
|
||||
let id = NEXT.fetch_add(1, Ordering::Relaxed);
|
||||
let project = std::env::temp_dir().join(format!("marqdo-security-{}-{id}", std::process::id()));
|
||||
let _ = fs::remove_dir_all(&project);
|
||||
fs::create_dir_all(&project).expect("create security project");
|
||||
fs::write(project.join("allowed.txt"), "allowed\n").expect("write allowed file");
|
||||
@@ -81,7 +96,7 @@ fn setup() -> Option<(PathBuf, PathBuf, PathBuf)> {
|
||||
let home = std::env::var_os("HOME")
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| PathBuf::from("/home"));
|
||||
let outside = home.join(format!("marqdo-escape-{}", std::process::id()));
|
||||
let outside = home.join(format!("marqdo-escape-{}-{id}", std::process::id()));
|
||||
let _ = fs::remove_file(&outside);
|
||||
Some((helper, project, outside))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user