Skip to content

Commit

Permalink
keep original file order
Browse files Browse the repository at this point in the history
  • Loading branch information
barv-jfrog committed Dec 3, 2024
1 parent fc3c156 commit c0b2fe3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions commands/enrich/enrich.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/xml"
"errors"
"fmt"
"github.com/jfrog/jfrog-cli-security/utils/results/output"
"os"
"os/exec"
"path/filepath"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/jfrog/jfrog-cli-security/commands/enrich/enrichgraph"
"github.com/jfrog/jfrog-cli-security/utils"
"github.com/jfrog/jfrog-cli-security/utils/results"
"github.com/jfrog/jfrog-cli-security/utils/results/output"
"github.com/jfrog/jfrog-cli-security/utils/techutils"
"github.com/jfrog/jfrog-cli-security/utils/xray"
"github.com/jfrog/jfrog-client-go/artifactory/services/fspatterns"
Expand All @@ -27,6 +27,7 @@ import (
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"github.com/jfrog/jfrog-client-go/xray/services"
orderedJson "gitlab.com/c0b/go-ordered-json"
)

type FileContext func(string) parallel.TaskFunc
Expand Down Expand Up @@ -75,7 +76,7 @@ func AppendVulnsToJson(cmdResults *results.SecurityCommandResults) error {
if err != nil {
return fmt.Errorf("error reading file: %s", err.Error())
}
var data map[string]interface{}
data := orderedJson.NewOrderedMap()
err = json.Unmarshal(fileContent, &data)
if err != nil {
return fmt.Errorf("error parsing JSON: %s", err.Error())
Expand All @@ -93,7 +94,7 @@ func AppendVulnsToJson(cmdResults *results.SecurityCommandResults) error {
vulnerabilities = append(vulnerabilities, vulnerability)
}
}
data["vulnerabilities"] = vulnerabilities
data.Set("vulnerabilities", vulnerabilities)
return output.PrintJson(data)
}

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ require (
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.29.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 h1:QldyIu/L63oPpyvQmHg
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a h1:DxppxFKRqJ8WD6oJ3+ZXKDY0iMONQDl5UTg2aTyHh8k=
gitlab.com/c0b/go-ordered-json v0.0.0-20201030195603-febf46534d5a/go.mod h1:NREvu3a57BaK0R1+ztrEzHWiZAihohNLQ6trPxlIqZI=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
Expand Down

0 comments on commit c0b2fe3

Please sign in to comment.