Make debug evidence opt-in and retain all candidates
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/diagnostics"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/redaction"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/reporting"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/schema"
|
||||
)
|
||||
|
||||
func TestStringRedactionPreservesSerializationAndDomainData(t *testing.T) {
|
||||
@@ -51,37 +51,26 @@ func TestStringRedactionPreservesSerializationAndDomainData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestReportWritersRedactStringsAndFailClosed(t *testing.T) {
|
||||
func TestDebugWritersRedactSourceAndNormalizedSnapshots(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
version := 2
|
||||
report := reporting.ProcessReport{ErrorMessage: "echo:2"}
|
||||
report.ReportMetadata.ConfigVersion = &version
|
||||
run, err := diagnostics.NewRunDirectory(dir, "always", "2")
|
||||
run, err := diagnostics.NewRunDirectory(dir, "run-test", "2")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
external := filepath.Join(dir, "external.json")
|
||||
if err := reporting.WriteProcessReport(external, report, "2"); err != nil {
|
||||
if err := run.WriteSourceTranscript(&schema.SourceTranscript{}, []byte(`{"segments":[{"text":"echo:2","id":2}]}`)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := run.WriteReport(report); err != nil {
|
||||
if err := run.WriteNormalizedTranscript(&schema.Transcript{Segments: []schema.Segment{{ID: 2, Text: "echo:2"}}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, path := range []string{external, filepath.Join(run.Path(), diagnostics.ArtifactReport)} {
|
||||
for _, path := range []string{filepath.Join(run.Path(), diagnostics.ArtifactSourceTranscript), filepath.Join(run.Path(), diagnostics.ArtifactNormalizedTranscript)} {
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var got reporting.ProcessReport
|
||||
if err := json.Unmarshal(raw, &got); err != nil {
|
||||
t.Fatal(err)
|
||||
if strings.Contains(string(raw), "echo:2") || !strings.Contains(string(raw), "echo:[REDACTED]") || !strings.Contains(string(raw), `"id": 2`) {
|
||||
t.Fatalf("snapshot: %s", raw)
|
||||
}
|
||||
if got.ErrorMessage != "echo:[REDACTED]" || got.ReportMetadata.ConfigVersion == nil || *got.ReportMetadata.ConfigVersion != 2 {
|
||||
t.Fatalf("report: %+v", got)
|
||||
}
|
||||
}
|
||||
if report.ErrorMessage != "echo:2" {
|
||||
t.Fatal("mutated input report")
|
||||
}
|
||||
if err := run.WriteJSONArtifact("invalid.json", map[string]any{"secret": "echo:2", "invalid": math.NaN()}); err == nil {
|
||||
t.Fatal("expected serialization failure")
|
||||
|
||||
Reference in New Issue
Block a user