@@ -3,8 +3,10 @@ package main
33
44import (
55 "bufio"
6+ "bytes"
67 "context"
78 "encoding/csv"
9+ "encoding/json"
810 "errors"
911 "flag"
1012 "fmt"
@@ -75,11 +77,6 @@ type AdvisoryInfo struct {
7577
7678type Advisories map [string ]* AdvisoryInfo
7779
78- var marshaler = protojson.MarshalOptions {
79- Multiline : true , // Enables multiline output
80- Indent : " " , // Specifies the indentation string (e.g., two spaces)
81- }
82-
8380func createCodenameToVersion () (map [string ]string , error ) {
8481 client := & http.Client {Timeout : 30 * time .Second }
8582 resp , err := client .Get ("https://debian.pages.debian.net/distro-info-data/debian.csv" )
@@ -551,12 +548,16 @@ func run(webwmlRepo, securityTrackerRepo, outputDir, outputBucket string, upload
551548 }
552549
553550 for _ , vuln := range vulns {
554- b , err := marshaler .Marshal (vuln )
551+ b , err := protojson .Marshal (vuln )
555552 if err != nil {
556553 logger .Error ("Failed to marshal vulnerability" , "id" , vuln .GetId (), "err" , err )
557554 continue
558555 }
559-
556+ var buf bytes.Buffer
557+ if err := json .Indent (& buf , b , "" , " " ); err != nil {
558+ logger .Error ("Failed to indent vulnerability" , "id" , vuln .GetId (), "err" , err )
559+ continue
560+ }
560561 outPath := filepath .Join (advOutputDir , vuln .GetId ()+ ".json" )
561562 //nolint:gosec // 0644 is fine for public vulnerability data
562563 if err := os .WriteFile (outPath , b , 0644 ); err != nil {
0 commit comments