File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed
Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 11package enrich
22
33import (
4- "encoding/json"
54 "encoding/xml"
65 "errors"
76 "fmt"
@@ -27,7 +26,7 @@ import (
2726 "github.com/jfrog/jfrog-client-go/utils/io/fileutils"
2827 "github.com/jfrog/jfrog-client-go/utils/log"
2928 "github.com/jfrog/jfrog-client-go/xray/services"
30- orderedJson "gitlab .com/c0b /go-ordered-json"
29+ orderedJson "github .com/virtuald /go-ordered-json"
3130)
3231
3332type FileContext func (string ) parallel.TaskFunc
@@ -76,8 +75,8 @@ func AppendVulnsToJson(cmdResults *results.SecurityCommandResults) error {
7675 if err != nil {
7776 return fmt .Errorf ("error reading file: %s" , err .Error ())
7877 }
79- data := orderedJson .NewOrderedMap ()
80- err = json .Unmarshal (fileContent , & data )
78+ var data orderedJson.OrderedObject
79+ err = orderedJson .Unmarshal (fileContent , & data )
8180 if err != nil {
8281 return fmt .Errorf ("error parsing JSON: %s" , err .Error ())
8382 }
@@ -94,7 +93,7 @@ func AppendVulnsToJson(cmdResults *results.SecurityCommandResults) error {
9493 vulnerabilities = append (vulnerabilities , vulnerability )
9594 }
9695 }
97- data . Set ( "vulnerabilities" , vulnerabilities )
96+ data = append ( data , orderedJson. Member { Key : "vulnerabilities" , Value : vulnerabilities } )
9897 return output .PrintJson (data )
9998}
10099
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ require (
1616 github.com/owenrumney/go-sarif/v2 v2.3.0
1717 github.com/stretchr/testify v1.9.0
1818 github.com/urfave/cli v1.22.16
19+ github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74
1920 golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f
2021 golang.org/x/sync v0.9.0
2122 golang.org/x/text v0.20.0
@@ -97,7 +98,6 @@ require (
9798 github.com/xanzy/ssh-agent v0.3.3 // indirect
9899 github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
99100 github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
100- gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a // indirect
101101 go.uber.org/atomic v1.9.0 // indirect
102102 go.uber.org/multierr v1.9.0 // indirect
103103 golang.org/x/crypto v0.29.0 // indirect
Original file line number Diff line number Diff line change @@ -257,6 +257,8 @@ github.com/urfave/cli v1.22.16 h1:MH0k6uJxdwdeWQTwhSO42Pwr4YLrNLwBtg1MRgTqPdQ=
257257github.com/urfave/cli v1.22.16 /go.mod h1:EeJR6BKodywf4zciqrdw6hpCPk68JO9z5LazXZMn5Po =
258258github.com/vbauerster/mpb/v8 v8.8.3 h1:dTOByGoqwaTJYPubhVz3lO5O6MK553XVgUo33LdnNsQ =
259259github.com/vbauerster/mpb/v8 v8.8.3 /go.mod h1:JfCCrtcMsJwP6ZwMn9e5LMnNyp3TVNpUWWkN+nd4EWk =
260+ github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 h1:JwtAtbp7r/7QSyGz8mKUbYJBg2+6Cd7OjM8o/GNOcVo =
261+ github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 /go.mod h1:RmMWU37GKR2s6pgrIEB4ixgpVCt/cf7dnJv3fuH1J1c =
260262github.com/vmihailenco/msgpack/v4 v4.3.12 /go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4 =
261263github.com/vmihailenco/tagparser v0.1.1 /go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI =
262264github.com/xanzy/go-gitlab v0.110.0 h1:hsFIFp01v/0D0sdUXoZfRk6CROzZbHQplk6NzKSFKhc =
@@ -275,8 +277,6 @@ github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHg
275277github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 /go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs =
276278github.com/yuin/goldmark v1.4.13 /go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY =
277279github.com/zclconf/go-cty v1.10.0 /go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk =
278- gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a h1:DxppxFKRqJ8WD6oJ3+ZXKDY0iMONQDl5UTg2aTyHh8k =
279- gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a /go.mod h1:NREvu3a57BaK0R1+ztrEzHWiZAihohNLQ6trPxlIqZI =
280280go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE =
281281go.uber.org/atomic v1.9.0 /go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc =
282282go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI =
Original file line number Diff line number Diff line change 66 "encoding/hex"
77 "encoding/json"
88 "fmt"
9+ orderedJson "github.com/virtuald/go-ordered-json"
910 "os"
1011 "path/filepath"
1112 "strings"
@@ -112,7 +113,7 @@ func UniqueUnion[T comparable](arr []T, elements ...T) []T {
112113
113114func GetAsJsonBytes (output interface {}, escapeValues , indent bool ) (results []byte , err error ) {
114115 if escapeValues {
115- if results , err = json .Marshal (output ); errorutils .CheckError (err ) != nil {
116+ if results , err = orderedJson .Marshal (output ); errorutils .CheckError (err ) != nil {
116117 return
117118 }
118119 } else {
You can’t perform that action at this time.
0 commit comments