Commit Graph
7 Commits
Author SHA1 Message Date
cflmy 512b9f5f1d ci(security): fail the lane when evidence generation fails
CI / fmt + clippy + test (Linux x86_64) (push) Waiting to run
CI / schema instance validation + consumers (push) Waiting to run
CI / runtime contract (macos-latest) (push) Waiting to run
CI / runtime contract (windows-latest) (push) Waiting to run
Linux strict security lane (G-C) / strict isolation escape matrix (push) Waiting to run
ci/woodpecker/push/woodpecker Pipeline was successful
A green lane without a strict-evidence.json must not count as a gate. The EXIT
trap now turns a generator failure into a lane failure. The self-hosted
workflow exports the archive path in the run step (env written by GITHUB_ENV is
not guaranteed in the env expression context), records the pinned image digest
as an input, and verifies schema/outcome/tested_sha/non-root before uploading.
Also define SOURCE_SHA before the VM overlay commands.
2026-11-21 17:41:23 +08:00
cflmy 990e984ab6 ci(security): bind the G-C lane to one SHA and emit evidence
CI / fmt + clippy + test (Linux x86_64) (push) Waiting to run
CI / schema instance validation + consumers (push) Waiting to run
CI / runtime contract (macos-latest) (push) Waiting to run
CI / runtime contract (windows-latest) (push) Waiting to run
Linux strict security lane (G-C) / strict isolation escape matrix (push) Waiting to run
ci/woodpecker/push/woodpecker Pipeline was successful
Add tools/ci/strict-evidence.py, which records only measured host/source
facts: tested SHA (git-verified when a checkout exists), source archive
digest, kernel, bwrap/rustc/cargo, uid, cgroup2, runner kind and outcome. The
lane now writes this document on every exit path, refuses a root-only PASS,
and covers the strict @knowledge-inert and forged-marker JSON contracts in
addition to the existing 7/7 adversarial matrix and positive CLI checks.

Rework security-linux.yml to run on trusted master pushes or an explicit
source_sha, bind the checkout to the tested SHA, create a git archive for the
digest, avoid PR execution and upload the evidence artifact. This is step 4 of
the CI/security RFC (B04/B09/B10); the runner must still be an ephemeral VM.
2026-11-21 17:14:43 +08:00
cflmy e029853e32 feat(lang): implement RFC-LANG-0002 unified semantics (breaking)
One Markdown-to-program mapping, no version selector or legacy mapper.

Frontend/runtime:
- resolve @exec/@knowledge heading declarations with nearest-ancestor
  inheritance; only an Exec H2 is callable; add UnitKind::Knowledge and
  sem.* diagnostics (mode marker, unit name, exec-without-function,
  payload nesting/empty, syntax, control stack, params position,
  version directive, inferred-signature lint)
- extract Strong/Emph/inline Code as one-statement carriers, refuse
  nested carriers, and honour heading segment boundaries so an if/while
  cannot be closed across a heading
- lower if/else/while/end to the existing Branch/Loop/Return IR with a
  compile-time control stack; keep payload-relative source spans through
  expression parsing and rewrite them onto the file
- accept params(...) only as the first direct Exec H2 payload; keep the
  existing free-variable inference and named-only rule for inferred
  signatures; fix duplicate-mode/else/end and Knowledge-body inertness
- reject marqdo_semantics/syntax front matter directives

Data and tests:
- migrate stdlib/**/*.mq.md, regenerate stdlib.json digest
- migrate examples and the full semantics/negative/runtime corpus to
  the only current syntax; expected values/runtime codes preserved
- migrate Rust-embedded .mq.md fixtures, init template, CLI help and
  security-lane fixtures

Verified: cargo fmt --check, cargo clippy -D warnings and
cargo test --workspace --locked (green).
2026-11-21 12:26:46 +08:00
cflmy 70d916d698 test(security): assert strict refuses TCP resources and --allow-net
- G-C lane now runs a .mq.md TCP resource open under strict and requires
  permission.denied, and rejects the --allow-net grant at the strict flag
  boundary.
- Complements the existing file-resource refusal and host TCP strict test.
2026-11-20 23:21:09 +08:00
cflmy 1d87f98539 fix(strict): bind the bundled stdlib and verify strict resources
- Strict child now gets the verified stdlib tree read-only at
  /run/marqdo-stdlib with MARQDO_STDLIB_DIR set, so Compat-C 打印 works under
  strict without exposing a host path (ADR-0021 update).
- Add a strict-lane negative: resource.open(file) is refused with
  permission.denied; hello/factorial/multi-module and --json still pass.
- StrictHostCommand gains stdlib_dir; CLI discovers the bundle and sandbox
  binds it; sandbox tests constructors updated.

Evidence: G-C lane PASS on the disposable Ubuntu 26.04 VM (7/7 adversarial
matrix, positive CLI, strict language-resource refusal, forged marker), plus
fmt/clippy/423 local tests.
2026-11-20 22:57:49 +08:00
cflmy f075c967f2 fix(security): honor CARGO_TARGET_DIR in the G-C lane
The lane hard-coded target/debug/marqdo, so a reproducible run from a clean
git archive with an external CARGO_TARGET_DIR built the binary and then
reported a false missing-binary failure.

TESTS: bash -n tests/security/run-lane.sh; G-C lane on a clean archive.
CI_URL: none from this host (Gitee remote, no GitHub credentials).
SECURITY_SCOPE: unchanged; the lane still requires an ordinary user and 7/7.
2026-11-20 15:42:47 +08:00
cflmy b6fc18233d feat(sandbox): implement probe-gated Linux strict isolation (ADR-0021)
Strict mode now re-executes the CLI inside a Bubblewrap supervisor with
user/mount/PID/net/UTS/IPC namespaces, no-new-privs, all capabilities dropped,
a read-only /project, private /proc and /dev, rlimits, output capture and
wall-clock process-group cleanup. The child verifies PID 1, NoNewPrivs, empty
CapEff, an unshared uid map and loopback-only networking before project code.

- PlatformCapabilities::detect runs a real bwrap probe; no probe, no strict
- strict L1 supports pure Marqdo + Math; Foreign/ABI/worker/kernel/grants/trace
  are rejected with exit 2 before sandboxing
- forged MARQDO_STRICT_ACTIVE is rejected; missing bwrap fails closed
- add adversarial helper, 7-test escape/resource matrix, seeded security lane
  script and self-hosted security workflow
- executed G-C lane as uid 1000 in a disposable Ubuntu 26.04 VM: 7/7 PASS
  plus positive CLI and refusal matrix; evidence in docs/evidence
- ADR-0021, spec/security.md, STATUS/COMPATIBILITY/README/CHANGELOG updated;
  ADR-0019 remains for non-Linux/fail-closed rules
2026-11-20 15:01:49 +08:00