fix(cli): normalize strict failures to one JSON document
ci/woodpecker/push/woodpecker Pipeline was successful
CI / fmt + clippy + test (Linux x86_64) (push) Canceled after 0s
CI / schema instance validation + consumers (push) Canceled after 0s
CI / runtime contract (macos-latest) (push) Canceled after 0s
CI / runtime contract (windows-latest) (push) Canceled after 0s
CI / release candidate artifact (macos-latest) (push) Canceled after 0s
CI / release candidate artifact (ubuntu-latest) (push) Canceled after 0s
ci/woodpecker/push/woodpecker Pipeline was successful
CI / fmt + clippy + test (Linux x86_64) (push) Canceled after 0s
CI / schema instance validation + consumers (push) Canceled after 0s
CI / runtime contract (macos-latest) (push) Canceled after 0s
CI / runtime contract (windows-latest) (push) Canceled after 0s
CI / release candidate artifact (macos-latest) (push) Canceled after 0s
CI / release candidate artifact (ubuntu-latest) (push) Canceled after 0s
Capture the strict child through launch_strict_capture and classify the outcome before writing anything. In --json mode a control-plane failure now emits exactly one error document with a stable code instead of forwarding bubblewrap stderr and leaving stdout empty; a verified child's valid JSON is forwarded unchanged with its own exit code. Empty, partial or non-JSON child output becomes strict.child_invalid. Route the remaining run --json error paths (mode, grants, missing entry, trace) through the same contract, classify sandbox launch failures with StrictFailureKind so probe/spawn/timeout/resource failures stay distinguishable, and add deterministic routing tests plus forged-marker CLI coverage. Document the decision in ADR-0053 and spec/security.md 1.2. This is step 2 of the CI/security RFC (B02/B03).
This commit is contained in:
1 parent
f4a404bae9
commit
f817cceb3b
9 files changed
+634
-103
No files matched your search
@@ -52,17 +52,13 @@ pub fn execute(
|
||||
let mode = match settings.sandbox_mode() {
|
||||
Ok(mode) => mode,
|
||||
Err(error) => {
|
||||
eprintln!("error: {error}");
|
||||
emit_error(json, command_name, "cli.invalid_mode", &error);
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
if mode == SandboxMode::Strict {
|
||||
if let Err(error) = settings.strict_preflight() {
|
||||
if json {
|
||||
output::print_json(&json!({"success": false, "error": error}));
|
||||
} else {
|
||||
eprintln!("error: {error}");
|
||||
}
|
||||
emit_error(json, command_name, "strict.unsupported_grant", &error);
|
||||
return 2;
|
||||
}
|
||||
match marqdo_sandbox::inspect_strict_child() {
|
||||
@@ -72,42 +68,35 @@ pub fn execute(
|
||||
Ok(StrictChildState::NotChild) => {
|
||||
let platform = PlatformCapabilities::detect();
|
||||
if let Err(error) = marqdo_sandbox::enforce(mode, &platform) {
|
||||
if json {
|
||||
output::print_json(&json!({"success": false, "error": error.to_string()}));
|
||||
} else {
|
||||
eprintln!("error: {error}");
|
||||
}
|
||||
emit_error(json, command_name, error.code(), &error.to_string());
|
||||
return 1;
|
||||
}
|
||||
return launch_strict_process(&project.root, file, settings);
|
||||
return launch_strict_process(&project.root, file, settings, json, command_name);
|
||||
}
|
||||
// A marker without a verified identity is never trusted, and the
|
||||
// platform-neutral inspection keeps Linux-only symbols out of this
|
||||
// module so macOS/Windows builds compile.
|
||||
Err(reason) => {
|
||||
let message = format!("strict isolation verification failed: {reason}");
|
||||
if json {
|
||||
output::print_json(&json!({"success": false, "error": message}));
|
||||
} else {
|
||||
eprintln!("error: {message}");
|
||||
}
|
||||
emit_error(json, command_name, "strict.identity_invalid", &message);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
let platform = PlatformCapabilities::detect();
|
||||
if let Err(error) = marqdo_sandbox::enforce(mode, &platform) {
|
||||
if json {
|
||||
output::print_json(&json!({"success": false, "error": error.to_string()}));
|
||||
} else {
|
||||
eprintln!("error: {error}");
|
||||
}
|
||||
emit_error(
|
||||
json,
|
||||
command_name,
|
||||
"sandbox.unavailable",
|
||||
&error.to_string(),
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
let capabilities = match settings.capabilities() {
|
||||
Ok(capabilities) => capabilities,
|
||||
Err(error) => {
|
||||
eprintln!("error: {error}");
|
||||
emit_error(json, command_name, "cli.invalid_grants", &error);
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
@@ -193,17 +182,22 @@ pub fn execute(
|
||||
let function_name = function.unwrap_or("main").to_string();
|
||||
let entry_module = &project.program.modules[&project.entry];
|
||||
if entry_module.function(&function_name).is_none() {
|
||||
if function.is_none() {
|
||||
eprintln!(
|
||||
"error[sem.no_entry_function]: {} has no callable `main`; declare an Exec H2 \
|
||||
(`## @exec main`) or pass an explicit function name",
|
||||
let message = if function.is_none() {
|
||||
format!(
|
||||
"{} has no callable `main`; declare an Exec H2 (`## @exec main`) or pass an \
|
||||
explicit function name",
|
||||
project.entry_file().path.display()
|
||||
);
|
||||
)
|
||||
} else {
|
||||
eprintln!(
|
||||
"error: no function named `{function_name}` in {}",
|
||||
format!(
|
||||
"no function named `{function_name}` in {}",
|
||||
project.entry_file().path.display()
|
||||
);
|
||||
)
|
||||
};
|
||||
if json {
|
||||
emit_error(true, command_name, "sem.no_entry_function", &message);
|
||||
} else {
|
||||
eprintln!("error[sem.no_entry_function]: {message}");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -234,7 +228,7 @@ pub fn execute(
|
||||
};
|
||||
let entry = format!("{}::{}", project.entry, function_name);
|
||||
if let Err(error) = crate::trace::write(&project, &host, &entry, status, path) {
|
||||
eprintln!("error: {error}");
|
||||
emit_error(json, command_name, "cli.trace_failed", &error);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user