Repository navigation
feat(runner): hybrid seccomp backend with structured syscall policy - #4
Conversation
Install a Linux seccomp-BPF allow/trace filter before execve when SyscallBackend is set to hybrid. Keep ptrace as the default backend and retain ptrace checks for bootstrap and migration coverage.
Introduce SyscallPolicyConfig (Allow/Deny/Trace/Audit) as a Phase 2 compatibility layer over the legacy AllowedCalls/AdditionCalls/OneTimeCalls. The runner now normalizes both sources into an EffectiveSyscallPolicy, then compiles it into backend inputs: ptrace consumes a callPolicySpec, seccomp consumes final ALLOW/TRACE syscall lists. Hybrid mode switches to event-only ptrace resume (PTRACE_CONT) so ordinary seccomp ALLOW calls no longer produce syscall enter/exit stops; Trace/Audit calls are routed through SECCOMP_RET_TRACE for ptrace handling and named audit logging. Ownership is enforced fail-loud: a syscall cannot belong to more than one of OneTimeCalls, runtime allowlist, Trace, or Audit, and Deny only subtracts from the allowlist. Hybrid startup protocol reserves write/close/exit/exit_group, which cannot be placed in Deny/Trace/Audit/ OneTimeCalls. Seccomp filter generation now rejects BPF instruction limit overflow.
Add tests/syscall-policy-deny-hybrid covering Deny overriding an inherited AdditionCalls allow, and tests/syscall-policy-trace-audit-hybrid covering Trace and Audit end-to-end with seccomp audit log assertion. Wire both into makefile testall and update tests/README.md.
Document the SyscallPolicy Allow/Deny/Trace/Audit compatibility layer, event-only hybrid resume, ownership fail-loud semantics, startup protocol reservations, and the two new hybrid integration cases.
|
Warning Review limit reached
Next review available in: 41 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough本次变更为 runner 引入 hybrid syscall 过滤后端:新增 SyscallPolicy(Allow/Deny/Trace/Audit)配置模型与归一化/编译逻辑,Linux 下新增 seccomp-BPF 过滤器生成与安装(seccomp_linux.go),ptrace 与 seccomp 事件协同处理及审计日志,并同步更新架构/迁移文档与新增三组 hybrid 集成测试。 ChangesHybrid Syscall 过滤主线
Estimated code review effort: 4 (Complex) | ~75 minutes Sequence Diagram(s)sequenceDiagram
participant Parent
participant Child
participant TracerDetect
Child->>Child: PTRACE_TRACEME + stopForPtraceOptions
Parent->>Parent: waitForTraceeStop
Parent->>Child: SetPtraceOptions(traceSeccomp)
Parent->>Child: ContinueWithMode
Child->>Child: installSeccompFilter (prctl)
Child->>Child: execve
Parent->>Parent: verifyStartupSeccompEvent
loop 运行期
Child->>TracerDetect: seccomp/ptrace 事件 stop
TracerDetect->>TracerDetect: checkSeccompTrace / checkSyscall
TracerDetect->>TracerDetect: auditSyscall (若 ShouldAudit)
TracerDetect->>Child: ContinueWithMode
end
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The spec is already consulted by the caller via shouldSyncSeccompTracee; the function body only runs the ptrace sync flow and never reads spec.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (6)
runner/seccomp_linux.go (1)
190-196: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win用标准库排序替换手写插入排序。
sortUint32手动实现了插入排序,建议改用标准库sort.Slice(或 Go 1.21+ 的slices.Sort),减少自造轮子、提升可读性。♻️ 建议重构
-func sortUint32(values []uint32) { - for i := 1; i < len(values); i++ { - for j := i; j > 0 && values[j-1] > values[j]; j-- { - values[j-1], values[j] = values[j], values[j-1] - } - } -} +func sortUint32(values []uint32) { + sort.Slice(values, func(i, j int) bool { return values[i] < values[j] }) +}需要在 import 中添加
"sort"(或使用"slices"包的slices.Sort,需确认项目最低 Go 版本 ≥ 1.21)。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@runner/seccomp_linux.go` around lines 190 - 196, The sortUint32 helper currently uses a hand-written insertion sort; replace it with the standard library sorter for clearer, less error-prone code. Update sortUint32 to use sort.Slice (or slices.Sort if the project targets Go 1.21+), and add the corresponding import in the same file while keeping the function’s behavior unchanged.tests/clone-syscall-phase-hybrid/makefile (1)
1-17: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win把这些命令型目标声明为
.PHONY。
default/compile/test/assert/clean都不是文件产物,不加.PHONY时,一旦目录里出现同名文件,make可能直接跳过测试或清理流程。🔧 建议修正
+.PHONY: default compile test assert clean default: compile test assert clean🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/clone-syscall-phase-hybrid/makefile` around lines 1 - 17, Declare the non-file targets in this Makefile as .PHONY so make never skips them when same-named files exist. Update the rules for default, compile, test, assert, and clean to be marked phony, keeping their current behavior in place while ensuring the target names remain command-only entry points.Source: Linters/SAST tools
runner/syscall_policy.go (1)
65-70: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win
compileSyscallPolicy未内联执行 hybrid 专属校验,存在隐式耦合风险。
compileSyscallPolicy只调用了通用的validateSyscallPolicy(),并未根据后端类型调用validateHybridSyscallPolicy;该校验目前仅在config.go的Validate()中、且仅当backend == syscallBackendHybrid时才触发。当前风险被LoadConfig()内部调用Validate()的事实所缓解(config_linux_test.go 中的TestValidateRejectsHybridDenyOfStartupProtocolCalls证实了这一点),但compileSyscallPolicy作为策略编译的唯一入口,如果未来有调用方(或单测,如本文件TestCompileSyscallPolicyProducesBackendInputs)在未经过Validate()的TaskConfig上直接调用它,hybrid 模式下 Deny/Trace/Audit 对保留调用(write/close/exit/exit_group)的"fail-loud"保证会被静默绕过——compile()仍会无条件把这些调用塞入SeccompAllowedCalls。建议让compileSyscallPolicy自身根据tc.effectiveSyscallBackend()决定是否执行validateHybridSyscallPolicy,使其不依赖调用顺序即可保持不变量。♻️ 建议的修复
func (tc *TaskConfig) compileSyscallPolicy() (compiledSyscallPolicy, error) { if err := tc.validateSyscallPolicy(); err != nil { return compiledSyscallPolicy{}, err } + if tc.effectiveSyscallBackend() == syscallBackendHybrid { + if err := validateHybridSyscallPolicy(tc.effectiveSyscallPolicy()); err != nil { + return compiledSyscallPolicy{}, err + } + } return tc.effectiveSyscallPolicy().compile(), nil }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@runner/syscall_policy.go` around lines 65 - 70, compileSyscallPolicy currently only runs validateSyscallPolicy and can bypass hybrid-specific protection when called on an unvalidated TaskConfig. Update compileSyscallPolicy to check tc.effectiveSyscallBackend() and invoke validateHybridSyscallPolicy for syscallBackendHybrid before calling effectiveSyscallPolicy().compile(), so the hybrid deny/trace/audit invariants are enforced inside this entrypoint instead of depending on Validate() being called first.runner/config.go (1)
100-117: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winNoNewPrivs 检查顺序先于平台校验,非 Linux 场景下报错信息具有误导性。
当
backend == hybrid且NoNewPrivs == false且运行在非 Linux 平台时(参考config_darwin.go的validateSyscallBackendForPlatform),当前顺序会先返回"syscallBackend hybrid requires NoNewPrivs",掩盖了真正的问题——hybrid 后端在该平台根本不受支持。建议先做平台校验,再做NoNewPrivs校验,避免误导用户"设置 NoNewPrivs 即可解决"。🩹 建议的修复
- if backend == syscallBackendHybrid && !tc.NoNewPrivs { - return errors.New("syscallBackend hybrid requires NoNewPrivs") - } if err := validateSyscallBackendForPlatform(backend); err != nil { return err } + if backend == syscallBackendHybrid && !tc.NoNewPrivs { + return errors.New("syscallBackend hybrid requires NoNewPrivs") + } if backend == syscallBackendHybrid {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@runner/config.go` around lines 100 - 117, The validation order in config validation is wrong: the NoNewPrivs check for syscallBackendHybrid runs before platform support is verified, so on non-Linux platforms it returns a misleading error. In the config validation path around effectiveSyscallBackend, validateSyscallBackendForPlatform, and the hybrid backend branch, move the platform-specific check ahead of the hybrid NoNewPrivs check so unsupported platforms fail with the correct error first, then keep the NoNewPrivs requirement for platforms where hybrid is valid.runner/exec.go (1)
135-142: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win与 92-101 处的 SetPtraceOptions+ContinueWithMode 组合重复,可抽取 helper。
初次设置(Line 94-101)与子进程 attach 后重设(Line 135-142)的逻辑结构完全一致(仅日志文案不同),建议抽成一个小函数以减少重复、避免后续两处修改不同步。
♻️ 建议重构
+func (task *RunningTask) armPtrace(process *Process, traceSeccomp bool, resumeMode traceResumeMode, context string) bool { + if err := process.SetPtraceOptions(traceSeccomp); err != nil { + log.Infof("PtraceSetOptions(%s): err %v", context, err) + task.Result.RetCode = RUNTIME_ERROR + process.Kill() + task.parseRunningInfo() + return false + } + return process.ContinueWithMode(resumeMode, 0) +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@runner/exec.go` around lines 135 - 142, The SetPtraceOptions + ContinueWithMode sequence is duplicated in the initial setup and the child-attach path. Extract the repeated logic in exec.go into a small helper around process.SetPtraceOptions and process.ContinueWithMode, keeping the caller-specific log message as an argument. Update both call sites to use the helper so the behavior stays identical while avoiding divergence between the two blocks.runner/tracer_linux_test.go (1)
82-199: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win建议补充针对"纯 Trace"(非 Allow、非 OneTime)系统调用的
checkSeccompTrace用例。现有用例覆盖了
OneTimeCalls(TestCheckSeccompTraceRejectsConsumedExecveBeforeEnter、TestCheckSeccompTraceConsumesPolicyAtEventStop)以及AllowedCalls + AuditCalls组合(TestCheckSeccompTraceLogsAuditCall),但没有用例验证:系统调用仅存在于Trace列表(既不在Allow也不在OneTime)时,checkSeccompTrace是否仍返回syscallCheckOK。结合上面在tracer_linux.go中提出的跨文件契约疑问,建议补充这一用例,以在单测层面锁定 Trace 语义的正确性。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@runner/tracer_linux_test.go` around lines 82 - 199, Add a test for “trace-only” syscall handling in checkSeccompTrace: the current TracerDetect coverage verifies OneTimeCalls and AllowedCalls+AuditCalls, but not a syscall that appears only in the Trace list. Extend the tracer_linux_test.go suite with a case around TracerDetect.checkSeccompTrace and makeCallPolicy(callPolicySpec) asserting that a trace-only syscall returns syscallCheckOK and does not get consumed or rejected, using the existing RegisterTracee, setCallPolicy, and ptraceGetRegs test pattern.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@runner/process_linux.go`:
- Line 11: The syscallStopSignal declaration has a redundant type conversion:
syscall.SIGTRAP | 0x80 already yields a syscall.Signal, so remove the outer
syscall.Signal(...) cast to satisfy unconvert. Update the constant in
process_linux.go at syscallStopSignal and keep the expression as a plain bitwise
OR result.
In `@runner/seccomp_linux.go`:
- Around line 1-14: The import block in seccomp_linux.go is not
goimports-compliant and is causing the golangci-lint check to fail. Reformat the
imports in that file using goimports so the standard/library and third-party
groups are ordered correctly and any unused imports are removed, then verify the
package still builds cleanly.
In `@tests/syscall-policy-trace-audit-hybrid/makefile`:
- Around line 10-12: The assert target currently validates only the pass result
and the getppid audit log, so the getpid trace path in the hybrid seccomp flow
is not being checked. Update the assert rule to also verify a seccomp trace
output for getpid, using the existing runner.log checks alongside the current
grep assertions, so the trace branch in the syscall policy test is explicitly
exercised.
---
Nitpick comments:
In `@runner/config.go`:
- Around line 100-117: The validation order in config validation is wrong: the
NoNewPrivs check for syscallBackendHybrid runs before platform support is
verified, so on non-Linux platforms it returns a misleading error. In the config
validation path around effectiveSyscallBackend,
validateSyscallBackendForPlatform, and the hybrid backend branch, move the
platform-specific check ahead of the hybrid NoNewPrivs check so unsupported
platforms fail with the correct error first, then keep the NoNewPrivs
requirement for platforms where hybrid is valid.
In `@runner/exec.go`:
- Around line 135-142: The SetPtraceOptions + ContinueWithMode sequence is
duplicated in the initial setup and the child-attach path. Extract the repeated
logic in exec.go into a small helper around process.SetPtraceOptions and
process.ContinueWithMode, keeping the caller-specific log message as an
argument. Update both call sites to use the helper so the behavior stays
identical while avoiding divergence between the two blocks.
In `@runner/seccomp_linux.go`:
- Around line 190-196: The sortUint32 helper currently uses a hand-written
insertion sort; replace it with the standard library sorter for clearer, less
error-prone code. Update sortUint32 to use sort.Slice (or slices.Sort if the
project targets Go 1.21+), and add the corresponding import in the same file
while keeping the function’s behavior unchanged.
In `@runner/syscall_policy.go`:
- Around line 65-70: compileSyscallPolicy currently only runs
validateSyscallPolicy and can bypass hybrid-specific protection when called on
an unvalidated TaskConfig. Update compileSyscallPolicy to check
tc.effectiveSyscallBackend() and invoke validateHybridSyscallPolicy for
syscallBackendHybrid before calling effectiveSyscallPolicy().compile(), so the
hybrid deny/trace/audit invariants are enforced inside this entrypoint instead
of depending on Validate() being called first.
In `@runner/tracer_linux_test.go`:
- Around line 82-199: Add a test for “trace-only” syscall handling in
checkSeccompTrace: the current TracerDetect coverage verifies OneTimeCalls and
AllowedCalls+AuditCalls, but not a syscall that appears only in the Trace list.
Extend the tracer_linux_test.go suite with a case around
TracerDetect.checkSeccompTrace and makeCallPolicy(callPolicySpec) asserting that
a trace-only syscall returns syscallCheckOK and does not get consumed or
rejected, using the existing RegisterTracee, setCallPolicy, and ptraceGetRegs
test pattern.
In `@tests/clone-syscall-phase-hybrid/makefile`:
- Around line 1-17: Declare the non-file targets in this Makefile as .PHONY so
make never skips them when same-named files exist. Update the rules for default,
compile, test, assert, and clean to be marked phony, keeping their current
behavior in place while ensuring the target names remain command-only entry
points.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: febd1d7e-8355-42f8-8959-d8127ce9d0df
📒 Files selected for processing (40)
.gitignoredocs/README.mddocs/architecture.mddocs/runner/syscalls.mddocs/seccomp-bpf-migration.mdmakefilerunner/README.mdrunner/config.gorunner/config_darwin.gorunner/config_linux.gorunner/config_linux_test.gorunner/config_test.gorunner/exec.gorunner/exec_linux.gorunner/exec_linux_test.gorunner/process.gorunner/process_darwin.gorunner/process_linux.gorunner/process_linux_test.gorunner/sec.gorunner/seccomp_linux.gorunner/seccomp_linux_test.gorunner/syscall_policy.gorunner/syscall_policy_test.gorunner/tracer.gorunner/tracer_darwin.gorunner/tracer_linux.gorunner/tracer_linux_test.gorunner/tracer_regs_linux_amd64_test.gorunner/tracer_regs_linux_arm64_test.gotests/README.mdtests/clone-syscall-phase-hybrid/case.jsontests/clone-syscall-phase-hybrid/main.ctests/clone-syscall-phase-hybrid/makefiletests/syscall-policy-deny-hybrid/case.jsontests/syscall-policy-deny-hybrid/main.ctests/syscall-policy-deny-hybrid/makefiletests/syscall-policy-trace-audit-hybrid/case.jsontests/syscall-policy-trace-audit-hybrid/main.ctests/syscall-policy-trace-audit-hybrid/makefile
| "golang.org/x/sys/unix" | ||
| ) | ||
|
|
||
| const syscallStopSignal = syscall.Signal(syscall.SIGTRAP | 0x80) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# 确认 syscall.SIGTRAP 的类型以及 unconvert 是否在 lint 配置中启用
rg -nP 'SIGTRAP\s+Signal' $(go env GOROOT 2>/dev/null)/src/syscall 2>/dev/null
fd -t f -e yml -e yaml '\.golangci' -H | xargs -r rg -n 'unconvert' 2>/dev/nullRepository: hustoj/runner
Length of output: 184
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- relevant source ---'
grep -nR "type Signal" "$(go env GOROOT)/src/syscall" | head -20
grep -nR "SIGTRAP" "$(go env GOROOT)/src/syscall" | head -20
echo '--- repo file context ---'
cat -n runner/process_linux.go | sed -n '1,30p'
echo '--- lint config references ---'
fd -t f -e yml -e yaml -e toml -e json -H . . | xargs -r rg -n "unconvert|golangci"
echo '--- type probe via go toolchain ---'
cat > /tmp/typeprobe.go <<'PY'
package main
import (
"fmt"
"go/parser"
"go/token"
"go/types"
"os"
"path/filepath"
)
func main() {
src := `package p
import "syscall"
const x = syscall.Signal(syscall.SIGTRAP | 0x80)
const y = syscall.SIGTRAP | 0x80
`
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "p.go", src, 0)
if err != nil { panic(err) }
conf := types.Config{
Importer: types.DefaultImportPathToName,
Error: func(err error) { fmt.Fprintln(os.Stderr, err) },
}
_ = conf
_ = f
_ = filepath.Separator
fmt.Println("go/types probe placeholder")
}
PY
echo '--- go env ---'
go env GOROOT GOVERSIONRepository: hustoj/runner
Length of output: 3448
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- GOROOT definitions ---'
GOROOT="$(go env GOROOT)"
grep -RIn "type Signal" "$GOROOT/src/syscall" | head -20
grep -RIn "SIGTRAP" "$GOROOT/src/syscall" | head -20
echo '--- repo context ---'
cat -n runner/process_linux.go | sed -n '1,25p'
echo '--- lint config ---'
fd -t f -e yml -e yaml -e toml -e json -H . . | xargs -r rg -n "unconvert|golangci"
echo '--- type-check expression ---'
cat > /tmp/typeprobe.go <<'EOF'
package main
import (
"fmt"
"go/ast"
"go/importer"
"go/parser"
"go/token"
"go/types"
"os"
)
func main() {
src := `package p
import "syscall"
const x = syscall.Signal(syscall.SIGTRAP | 0x80)
const y = syscall.SIGTRAP | 0x80
`
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, "p.go", src, 0)
if err != nil {
panic(err)
}
info := &types.Info{
Types: make(map[ast.Expr]types.TypeAndValue),
Defs: make(map[*ast.Ident]types.Object),
Uses: make(map[*ast.Ident]types.Object),
}
conf := types.Config{Importer: importer.Default(), Error: func(err error) { fmt.Fprintln(os.Stderr, err) }}
_, err = conf.Check("p", fset, []*ast.File{f}, info)
if err != nil {
fmt.Fprintln(os.Stderr, "type-check error:", err)
os.Exit(1)
}
ast.Inspect(f, func(n ast.Node) bool {
e, ok := n.(ast.Expr)
if !ok {
return true
}
pos := fset.Position(e.Pos())
if pos.Line == 3 || pos.Line == 4 {
fmt.Printf("%s: %T => %s\n", pos, e, info.Types[e].Type)
}
return true
})
}
EOF
go run /tmp/typeprobe.goRepository: hustoj/runner
Length of output: 3910
移除多余的类型转换
外层 syscall.Signal(...) 是冗余的,syscall.SIGTRAP | 0x80 的结果已经是 syscall.Signal,会触发 unconvert。
🧰 Tools
🪛 golangci-lint (2.12.2)
[error] 11-11: unnecessary conversion
(unconvert)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@runner/process_linux.go` at line 11, The syscallStopSignal declaration has a
redundant type conversion: syscall.SIGTRAP | 0x80 already yields a
syscall.Signal, so remove the outer syscall.Signal(...) cast to satisfy
unconvert. Update the constant in process_linux.go at syscallStopSignal and keep
the expression as a plain bitwise OR result.
Source: Linters/SAST tools
| //go:build linux | ||
|
|
||
| package runner | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "runtime" | ||
| "syscall" | ||
| "unsafe" | ||
|
|
||
| "github.com/hustoj/runner/sec" | ||
| "golang.org/x/sys/unix" | ||
| ) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
修复 goimports 格式问题。
golangci-lint 报告该文件导入块存在格式问题(goimports 检查失败),会导致 CI lint 阶段失败。建议在本地运行 goimports -w runner/seccomp_linux.go 后重新提交。
🧰 Tools
🪛 golangci-lint (2.12.2)
[error] 12-12: File is not properly formatted
(goimports)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@runner/seccomp_linux.go` around lines 1 - 14, The import block in
seccomp_linux.go is not goimports-compliant and is causing the golangci-lint
check to fail. Reformat the imports in that file using goimports so the
standard/library and third-party groups are ordered correctly and any unused
imports are removed, then verify the package still builds cleanly.
Source: Linters/SAST tools
| assert: | ||
| @grep -q "passed!" test.log | ||
| @grep -q "audit syscall source=seccomp.*getppid" runner.log |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
补上 getpid 的 trace 断言。
当前只校验了 passed! 和 getppid 的审计日志,Trace: ["getpid"] 对应的 seccomp trace 路径并没有被验证;如果 trace 事件处理回退成“静默放行”,这个用例仍可能通过。建议再断言一条 getpid 的 seccomp trace 输出,确保 hybrid 的 trace 分支真的被覆盖。
🛠️ 建议补丁
assert:
`@grep` -q "passed!" test.log
+ `@grep` -q "seccomp trace event.*getpid" runner.log
`@grep` -q "audit syscall source=seccomp.*getppid" runner.log📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| assert: | |
| @grep -q "passed!" test.log | |
| @grep -q "audit syscall source=seccomp.*getppid" runner.log | |
| assert: | |
| `@grep` -q "passed!" test.log | |
| `@grep` -q "seccomp trace event.*getpid" runner.log | |
| `@grep` -q "audit syscall source=seccomp.*getppid" runner.log |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/syscall-policy-trace-audit-hybrid/makefile` around lines 10 - 12, The
assert target currently validates only the pass result and the getppid audit
log, so the getpid trace path in the hybrid seccomp flow is not being checked.
Update the assert rule to also verify a seccomp trace output for getpid, using
the existing runner.log checks alongside the current grep assertions, so the
trace branch in the syscall policy test is explicitly exercised.
Summary
为 runner 引入 seccomp-BPF hybrid syscall 后端,并叠加 Phase 2 结构化
SyscallPolicy兼容层,逐步把 syscall 过滤下沉到内核态,同时保留 ptrace 对启动边界、生命周期和按名单审计的职责。Phase 1:hybrid seccomp 后端(054a6b5、f8a342d)
runner/seccomp_linux.go:在 Linux child 完成沙箱与ptrace(TRACEME)后、execve前安装 seccomp-BPF 过滤器;runtime allowlist 走SECCOMP_RET_ALLOW,OneTimeCalls走SECCOMP_RET_TRACE交 ptrace 审批。exec_linux.go增加 hybrid child 启动阶段;process_linux.go打开PTRACE_O_TRACESECCOMP;tracer_linux.go处理PTRACE_EVENT_SECCOMP。tests/clone-syscall-phase-hybrid集成用例并接入make testall。Phase 2:结构化 SyscallPolicy + event-only resume(16bcbbf、8603ead、320d692、23d362b)
runner/syscall_policy.go:SyscallPolicyConfig{Allow,Deny,Trace,Audit}作为兼容层,与 legacyAllowedCalls/AdditionCalls/OneTimeCalls归一为EffectiveSyscallPolicy,再编译成 ptrace 与 seccomp 各自消费的后端输入。PTRACE_CONT),普通ALLOW调用不再产生 syscall enter/exit stop;Trace/Audit通过SECCOMP_RET_TRACE路由到 ptrace 并输出 audit 日志。OneTimeCalls、runtime allowlist、Trace、Audit;Deny只对 allowlist 做减法,不能与OneTimeCalls/Trace/Audit重叠。write/close/exit/exit_group,禁止放入Deny/Trace/Audit/OneTimeCalls。tests/syscall-policy-deny-hybrid、tests/syscall-policy-trace-audit-hybrid集成用例并接入make testall。docs/architecture.md、docs/runner/syscalls.md、docs/seccomp-bpf-migration.md。.gitignore修正.workflows/→.workflow/并忽略.pi-subagents/。影响平台
ContinueWithMode等 panic 占位与跨平台构建,不参与 hybrid 运行。安全行为变更
SyscallBackend: "hybrid"路径,普通禁止 syscall 在内核态执行前被KILL_PROCESS拒绝,不再依赖 ptrace enter/exit 相位。OneTimeCalls与AllowedCalls/AdditionCalls重叠会退化为永久 allow,现改为配置加载阶段直接报错。Deny/Trace/Audit/OneTimeCalls。Test plan
go build ./...go vet ./runner/ ./sec/go test ./runner/ ./sec/(含新增 syscall_policy / seccomp / tracer / process 单测)sudo -E env PATH="$PATH" make testall(含 23 个集成 case,REMOTE_TESTALL_WITH_PATH:0)Summary by CodeRabbit
新功能
文档