feat(06-02): implement JSONFormatter with Unmask support

- Renders findings as 2-space indented JSON array
- Honors Options.Unmask for key field exposure
- Omits empty verify fields via json omitempty
- Registers under "json" in output registry
This commit is contained in:
salvacybersec
2026-04-05 23:31:12 +03:00
parent 2cb35d50ac
commit 164477136c
2 changed files with 74 additions and 3 deletions

View File

@@ -142,8 +142,12 @@ func TestJSONFormatter_Indented(t *testing.T) {
if err := (JSONFormatter{}).Format([]engine.Finding{f}, &buf, Options{}); err != nil {
t.Fatalf("Format returned error: %v", err)
}
// Expect 2-space indent on at least one property line.
if !strings.Contains(buf.String(), "\n \"provider\"") {
t.Errorf("output not indented with 2 spaces:\n%s", buf.String())
// Expect 2-space indent: array items at 2 spaces, nested fields at 4 spaces.
s := buf.String()
if !strings.Contains(s, "\n {") {
t.Errorf("array item not indented with 2 spaces:\n%s", s)
}
if !strings.Contains(s, "\n \"provider\"") {
t.Errorf("nested field not indented with 4 spaces:\n%s", s)
}
}