evidence

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package evidence writes local integration/e2e evidence for Pinax test runs.

证据目录结构由 integration evidence runner 写入,供 QA、review 和 closeout 使用。本包把核心写入逻辑从 main 中抽离,让测试可以直接验证:

  1. 成功和失败都会生成完整证据目录;
  2. 失败时保留原始退出码,不吞 stderr;
  3. 证据文件不含 token、Authorization header、raw provider payload、绝对路径 等敏感串——所有写入 stdout/stderr/command/env 的内容都经过 Redact 处理。

Index

Constants

View Source
const EnvSchemaVersion = "yeisme.integration_test_env.v1"

EnvSchemaVersion 是 env.json 的稳定 schema 版本。

View Source
const Layer = "integration-evidence"

Layer 标识证据来源的测试层。

View Source
const Project = "cli/pinax"

Project 标识证据归属的子项目。

View Source
const SchemaVersion = "yeisme.integration_test_evidence.v1"

SchemaVersion 是 evidence summary 的稳定 schema 版本。

Variables

This section is empty.

Functions

func Redact

func Redact(input string) string

Redact 对一段文本执行脱敏:替换 Authorization/Bearer、token/secret/password 键值对、CLI 密钥旗标值,以及绝对路径。返回脱敏后的文本。这是证据写入前的 必经关卡。

Types

type Config

type Config struct {
	// RunID 是本次运行的唯一标识,用作证据子目录名。
	RunID string
	// ParentDir 是存放运行子目录的父目录,例如 temp/integration-test-runs。
	ParentDir string
	// Command 是要执行并采集证据的命令。
	Command []string
	// PassThroughStdout/Stderr 不为 nil 时,命令原始(未脱敏)输出同时写到
	// 对应 writer;证据文件始终写入脱敏后的版本。
	PassThroughStdout io.Writer
	PassThroughStderr io.Writer
	// ExtraChecks 是写入 summary.json checks 字段的额外键。
	ExtraChecks map[string]any
	// PassStatus lets a newer evidence profile use the standard "passed"
	// spelling without changing existing Pinax profiles that historically emit
	// "success".
	PassStatus string
	// Layer overrides the legacy default for component/system canaries.
	Layer string
}

Config 控制 Run 的行为。

type Redaction

type Redaction struct {
	Applied          bool     `json:"applied"`
	SchemaVersion    string   `json:"schema_version"`
	ScannedSurfaces  []string `json:"scanned_surfaces"`
	ForbiddenClasses []string `json:"forbidden_classes"`
	PathRedacted     bool     `json:"path_redacted"`
}

Redaction 描述本次证据写入应用的脱敏策略,写入 summary.redaction。

type Result

type Result struct {
	ExitCode int
	RunDir   string
	Summary  Summary
}

Result 描述一次证据运行的结果。

func Run

func Run(cfg Config) (Result, error)

Run 执行 cfg.Command,把 stdout/stderr/env/summary 写入证据目录,并返回退出码。 成功和失败都会写完整证据;失败时保留原始退出码。所有证据文件都经过 Redact 脱敏,确保不泄露 token、secret 或绝对路径。

type Summary

type Summary struct {
	SchemaVersion string
	Project       string
	Layer         string
	RunID         string
	Status        string
	ExitCode      int
	FinishedAt    string
	Checks        map[string]any
	Redaction     Redaction
}

Summary 是 summary.json 的公开表示,供测试断言使用。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL