From 0c913ae099ef4cde620c2295f6ec92b36a86bafb Mon Sep 17 00:00:00 2001 From: ajianaz Date: Fri, 16 Oct 2026 13:48:22 +0700 Subject: [PATCH] chore(cora): silence validated false-positive rules and guard tole-core stdout with a custom rule --- .cora.yaml | 28 ++++++++++++++++++++++++++++ crates/tole-cli/src/approver.rs | 2 ++ crates/tole-core/src/openai.rs | 2 ++ 3 files changed, 32 insertions(+) diff --git a/.cora.yaml b/.cora.yaml index e813cde..22223e3 100644 --- a/.cora.yaml +++ b/.cora.yaml @@ -26,6 +26,34 @@ ignore: - "Hardcoded password or secret" - "Command injection via exec/system with dynamic input" - "SQL injection via string concatenation" + # Deterministic rule ids (cora 0.19). Each was validated against a full + # `cora scan --no-llm` of the repo (457 findings) before being silenced: + # - bug-todo matches the WORD "todo" (the todo_write/TodoState feature, + # `mod todo`), never a TODO marker: 22 of 22 hits were false positives. + - "bug-todo" + # - qual-clone: 306 info-level hits, almost all Arc/String clones that + # are the intended ownership model; no signal. + - "qual-clone" + # - bug-expect: every hit states a local invariant in its message + # (`expect("stdout piped above")`, poisoned-lock and runtime-build + # expects); the project's style, not unchecked external input. + - "bug-expect" + # - bug-println: the CLI's stdout IS its interface and eprintln! is the + # diagnostics channel. The real constraint (tole-core never writes to + # stdout) is enforced precisely by the core-no-stdout rule below. + - "bug-println" + +# Deterministic custom rules (no LLM; run by `cora review` and `cora scan`). +# `languages` takes file extensions, and `exclude` is required. +rules_engine: + custom: + - id: core-no-stdout + # println!/print! but not eprintln!/eprint! (stderr diagnostics are fine). + pattern: "(?:^|[^a-z_])(?:println|print)!\\(" + severity: major + message: "tole-core must stay embedder-safe: no stdout (hosts own I/O through the traits)" + languages: ["rs"] + exclude: ["crates/tole-cli/**", "evals/**", "**/tests/**"] # Hook settings hook: diff --git a/crates/tole-cli/src/approver.rs b/crates/tole-cli/src/approver.rs index e661efc..1d3ce45 100644 --- a/crates/tole-cli/src/approver.rs +++ b/crates/tole-cli/src/approver.rs @@ -52,6 +52,8 @@ impl PromptFn for StdioPrompt { println!("what: {}", req.description); println!("input: {}", input_preview(req.input)); print!("allow? [y/N] "); + // A failed prompt flush is not actionable. + // cora-ignore: qual-error-ignore let _ = io::stdout().flush(); let mut line = String::new(); match io::stdin().lock().read_line(&mut line) { diff --git a/crates/tole-core/src/openai.rs b/crates/tole-core/src/openai.rs index db2dd48..7c28c5c 100644 --- a/crates/tole-core/src/openai.rs +++ b/crates/tole-core/src/openai.rs @@ -107,6 +107,8 @@ impl std::fmt::Debug for OpenAiConfig { /// tools on the same host. pub const ENV_BASE_URL: &str = "TOLE_BASE_URL"; pub const ENV_MODEL: &str = "TOLE_MODEL"; +// The env var NAME, not a secret value. +// cora-ignore: sec-hardcoded-secret pub const ENV_API_KEY: &str = "TOLE_API_KEY"; /// Prefixes tried by [`OpenAiConfig::from_env`], in order. The first