BREAKING(report): migrate to new json schema (#1265)

This commit is contained in:
Teppei Fukuda
2021-10-04 16:22:24 +09:00
committed by GitHub
parent da905108b4
commit b37f682ee2
51 changed files with 131927 additions and 130069 deletions

View File

@@ -4,11 +4,8 @@ import (
"encoding/json"
"fmt"
"io"
"os"
"golang.org/x/xerrors"
"github.com/aquasecurity/trivy/pkg/log"
)
// JSONWriter implements result Writer
@@ -18,15 +15,7 @@ type JSONWriter struct {
// Write writes the results in JSON format
func (jw JSONWriter) Write(report Report) error {
var v interface{} = report
if os.Getenv("TRIVY_NEW_JSON_SCHEMA") == "" {
// After migrating to the new JSON schema, TRIVY_NEW_JSON_SCHEMA will be removed.
log.Logger.Warnf("DEPRECATED: the current JSON schema is deprecated, check %s for more information.",
"https://github.com/aquasecurity/trivy/discussions/1050")
v = report.Results
}
output, err := json.MarshalIndent(v, "", " ")
output, err := json.MarshalIndent(report, "", " ")
if err != nil {
return xerrors.Errorf("failed to marshal json: %w", err)
}