Skip to content

Commit 9af2799

Browse files
authored
Fixes issue with JSON renderer (#281)
* Fixes issue with JSON renderer * Adds test cases
1 parent fa454aa commit 9af2799

File tree

10 files changed

+123
-68
lines changed

10 files changed

+123
-68
lines changed

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"program": "${workspaceFolder}/main.go",
1313
"args": [
1414
"--debug=true",
15-
"--output=json,stdout,html",
15+
"--output=json-file,stdout,html",
1616
"--severity=high",
1717
"scan",
1818
"./_TESTDATA_/sbom/railsgoat.cyclonedx.json"

cmd/root.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func Execute() {
6464

6565
func init() {
6666
rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "displays debug level log messages.")
67-
rootCmd.PersistentFlags().StringVar(&output, "output", "stdout", "how bomber should output findings (json, html, ai, md, stdout)")
67+
rootCmd.PersistentFlags().StringVar(&output, "output", "stdout", "how bomber should output findings (json, json-file, html, ai, md, stdout)")
6868
}
6969

7070
func checkForNewVersion(currentVersion string) {

go.mod

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
module github.com/devops-kung-fu/bomber
22

3-
go 1.22.7
3+
go 1.22.10
4+
5+
toolchain go1.23.2
46

57
require (
6-
github.com/CycloneDX/cyclonedx-go v0.9.1
8+
github.com/CycloneDX/cyclonedx-go v0.9.2
79
github.com/briandowns/spinner v1.23.1
810
github.com/devops-kung-fu/common v0.2.6
9-
github.com/go-resty/resty/v2 v2.15.2
10-
github.com/gomarkdown/markdown v0.0.0-20240730141124-034f12af3bf6
11+
github.com/go-resty/resty/v2 v2.16.2
12+
github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62
1113
github.com/google/go-github v17.0.0+incompatible
12-
github.com/google/osv-scanner v1.8.5
14+
github.com/google/osv-scanner v1.9.2
1315
github.com/gookit/color v1.5.4
1416
github.com/jarcoal/httpmock v1.3.1
15-
github.com/jedib0t/go-pretty/v6 v6.5.9
17+
github.com/jedib0t/go-pretty/v6 v6.6.5
1618
github.com/microcosm-cc/bluemonday v1.0.27
1719
github.com/package-url/packageurl-go v0.1.3
1820
github.com/remeh/sizedwaitgroup v1.0.0
19-
github.com/sashabaranov/go-openai v1.30.3
21+
github.com/sashabaranov/go-openai v1.36.1
2022
github.com/spf13/afero v1.11.0
2123
github.com/spf13/cobra v1.8.1
22-
github.com/stretchr/testify v1.9.0
24+
github.com/stretchr/testify v1.10.0
2325
)
2426

2527
require (
2628
github.com/BurntSushi/toml v1.4.0 // indirect
2729
github.com/aymerick/douceur v0.2.0 // indirect
2830
github.com/davecgh/go-spew v1.1.1 // indirect
29-
github.com/fatih/color v1.17.0 // indirect
31+
github.com/fatih/color v1.18.0 // indirect
3032
github.com/google/go-querystring v1.1.0 // indirect
3133
github.com/gorilla/css v1.0.1 // indirect
3234
github.com/inconshreveable/mousetrap v1.1.0 // indirect
@@ -37,12 +39,12 @@ require (
3739
github.com/rivo/uniseg v0.4.7 // indirect
3840
github.com/spf13/pflag v1.0.5 // indirect
3941
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
40-
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
41-
golang.org/x/mod v0.21.0 // indirect
42-
golang.org/x/net v0.29.0 // indirect
43-
golang.org/x/sync v0.8.0 // indirect
44-
golang.org/x/sys v0.25.0 // indirect
45-
golang.org/x/term v0.24.0 // indirect
46-
golang.org/x/text v0.18.0 // indirect
42+
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
43+
golang.org/x/mod v0.22.0 // indirect
44+
golang.org/x/net v0.34.0 // indirect
45+
golang.org/x/sync v0.10.0 // indirect
46+
golang.org/x/sys v0.29.0 // indirect
47+
golang.org/x/term v0.28.0 // indirect
48+
golang.org/x/text v0.21.0 // indirect
4749
gopkg.in/yaml.v3 v3.0.1 // indirect
4850
)

go.sum

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
22
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
3-
github.com/CycloneDX/cyclonedx-go v0.9.1 h1:yffaWOZsv77oTJa/SdVZYdgAgFioCeycBUKkqS2qzQM=
4-
github.com/CycloneDX/cyclonedx-go v0.9.1/go.mod h1:NE/EWvzELOFlG6+ljX/QeMlVt9VKcTwu8u0ccsACEsw=
3+
github.com/CycloneDX/cyclonedx-go v0.9.2 h1:688QHn2X/5nRezKe2ueIVCt+NRqf7fl3AVQk+vaFcIo=
4+
github.com/CycloneDX/cyclonedx-go v0.9.2/go.mod h1:vcK6pKgO1WanCdd61qx4bFnSsDJQ6SbM2ZuMIgq86Jg=
55
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
66
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
77
github.com/bradleyjkemp/cupaloy/v2 v2.8.0 h1:any4BmKE+jGIaMpnU8YgH/I2LPiLBufr6oMMlVBbn9M=
@@ -13,27 +13,27 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
1313
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1414
github.com/devops-kung-fu/common v0.2.6 h1:HNL9suXELXHiSg7Ze0VinNkbngrBjovKYWPOckuarKc=
1515
github.com/devops-kung-fu/common v0.2.6/go.mod h1:ZLp6W5ewDWxmx45KF/Oj3IfJ3EhRALBkcfqLQnz23OU=
16-
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
17-
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
16+
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
17+
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
1818
github.com/gkampitakis/ciinfo v0.3.0 h1:gWZlOC2+RYYttL0hBqcoQhM7h1qNkVqvRCV1fOvpAv8=
1919
github.com/gkampitakis/ciinfo v0.3.0/go.mod h1:1NIwaOcFChN4fa/B0hEBdAb6npDlFL8Bwx4dfRLRqAo=
2020
github.com/gkampitakis/go-diff v1.3.2 h1:Qyn0J9XJSDTgnsgHRdz9Zp24RaJeKMUHg2+PDZZdC4M=
2121
github.com/gkampitakis/go-diff v1.3.2/go.mod h1:LLgOrpqleQe26cte8s36HTWcTmMEur6OPYerdAAS9tk=
2222
github.com/gkampitakis/go-snaps v0.5.7 h1:uVGjHR4t4pPHU944udMx7VKHpwepZXmvDMF+yDmI0rg=
2323
github.com/gkampitakis/go-snaps v0.5.7/go.mod h1:ZABkO14uCuVxBHAXAfKG+bqNz+aa1bGPAg8jkI0Nk8Y=
24-
github.com/go-resty/resty/v2 v2.15.2 h1:wLGqKU9l9tOIa2RyePoyu4ZUnDkUWfp2LZ0u6fMXExc=
25-
github.com/go-resty/resty/v2 v2.15.2/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
26-
github.com/gomarkdown/markdown v0.0.0-20240730141124-034f12af3bf6 h1:ZPy+2XJ8u0bB3sNFi+I72gMEMS7MTg7aZCCXPOjV8iw=
27-
github.com/gomarkdown/markdown v0.0.0-20240730141124-034f12af3bf6/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
24+
github.com/go-resty/resty/v2 v2.16.2 h1:CpRqTjIzq/rweXUt9+GxzzQdlkqMdt8Lm/fuK/CAbAg=
25+
github.com/go-resty/resty/v2 v2.16.2/go.mod h1:0fHAoK7JoBy/Ch36N8VFeMsK7xQOHhvWaC3iOktwmIU=
26+
github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62 h1:pbAFUZisjG4s6sxvRJvf2N7vhpCvx2Oxb3PmS6pDO1g=
27+
github.com/gomarkdown/markdown v0.0.0-20241205020045-f7e15b2f3e62/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
2828
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
2929
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
3030
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
3131
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
3232
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
3333
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
3434
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
35-
github.com/google/osv-scanner v1.8.5 h1:zKg12vmj2A0FZ0fscTjVpKVeDhLICVlAOsLe0HZtyXU=
36-
github.com/google/osv-scanner v1.8.5/go.mod h1:0bW4oZy6yIVAZpv+JAMu5gvFIJM9DrQS/RcwGfFCeLA=
35+
github.com/google/osv-scanner v1.9.2 h1:N5Arl9SA75afbjmX8mKURgOIaKyuK3NUjCaxDlj1KHI=
36+
github.com/google/osv-scanner v1.9.2/go.mod h1:ZTL8Dp9z/7Jr9kkQSOGqo8z6Csqt83qMIr58aZVx+pM=
3737
github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0=
3838
github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w=
3939
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
@@ -42,8 +42,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
4242
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
4343
github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww=
4444
github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg=
45-
github.com/jedib0t/go-pretty/v6 v6.5.9 h1:ACteMBRrrmm1gMsXe9PSTOClQ63IXDUt03H5U+UV8OU=
46-
github.com/jedib0t/go-pretty/v6 v6.5.9/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
45+
github.com/jedib0t/go-pretty/v6 v6.6.5 h1:9PgMJOVBedpgYLI56jQRJYqngxYAAzfEUua+3NgSqAo=
46+
github.com/jedib0t/go-pretty/v6 v6.6.5/go.mod h1:Uq/HrbhuFty5WSVNfjpQQe47x16RwVGXIveNGEyGtHs=
4747
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
4848
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
4949
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -77,20 +77,20 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc
7777
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
7878
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
7979
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
80-
github.com/sashabaranov/go-openai v1.30.3 h1:TEdRP3otRXX2A7vLoU+kI5XpoSo7VUUlM/rEttUqgek=
81-
github.com/sashabaranov/go-openai v1.30.3/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
80+
github.com/sashabaranov/go-openai v1.36.1 h1:EVfRXwIlW2rUzpx6vR+aeIKCK/xylSrVYAx1TMTSX3g=
81+
github.com/sashabaranov/go-openai v1.36.1/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
8282
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
8383
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
8484
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
8585
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
8686
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
8787
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
88-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
89-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
90-
github.com/terminalstatic/go-xsd-validate v0.1.5 h1:RqpJnf6HGE2CB/lZB1A8BYguk8uRtcvYAPLCF15qguo=
91-
github.com/terminalstatic/go-xsd-validate v0.1.5/go.mod h1:18lsvYFofBflqCrvo1umpABZ99+GneNTw2kEEc8UPJw=
92-
github.com/tidwall/gjson v1.17.3 h1:bwWLZU7icoKRG+C+0PNwIKC6FCJO/Q3p2pZvuP0jN94=
93-
github.com/tidwall/gjson v1.17.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
88+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
89+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
90+
github.com/terminalstatic/go-xsd-validate v0.1.6 h1:TenYeQ3eY631qNi1/cTmLH/s2slHPRKTTHT+XSHkepo=
91+
github.com/terminalstatic/go-xsd-validate v0.1.6/go.mod h1:18lsvYFofBflqCrvo1umpABZ99+GneNTw2kEEc8UPJw=
92+
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
93+
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
9494
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
9595
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
9696
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
@@ -105,22 +105,22 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17
105105
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
106106
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
107107
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
108-
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk=
109-
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY=
110-
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
111-
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
112-
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
113-
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
114-
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
115-
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
108+
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA=
109+
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
110+
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
111+
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
112+
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
113+
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
114+
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
115+
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
116116
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
117117
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
118-
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
119-
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
120-
golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
121-
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
122-
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
123-
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
118+
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
119+
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
120+
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
121+
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
122+
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
123+
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
124124
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
125125
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
126126
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

providers/gad/gad.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func init() {
2929
// Provider represents the OSSIndex provider
3030
type Provider struct{}
3131

32+
// SupportedEcosystems returns a list of ecosystems supported by the Github Advisory Database
3233
func (Provider) SupportedEcosystems() []string {
3334
return []string{
3435
"github-actions",
@@ -39,7 +40,6 @@ func (Provider) SupportedEcosystems() []string {
3940
"npm",
4041
"nuget",
4142
"pypi",
42-
"pypi",
4343
"rubygems",
4444
"cargo",
4545
}

providers/gad/gad_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gad
22

33
import (
4+
"reflect"
45
"testing"
56

67
"github.com/stretchr/testify/assert"
@@ -11,3 +12,21 @@ func TestInfo(t *testing.T) {
1112
info := provider.Info()
1213
assert.Equal(t, "GitHub Advisory Database (https://github.com/advisories)", info)
1314
}
15+
16+
func TestProvider_SupportedEcosystems(t *testing.T) {
17+
provider := Provider{}
18+
expectedEcosystems := []string{
19+
"github-actions",
20+
"composer",
21+
"erlang",
22+
"golang",
23+
"maven",
24+
"npm",
25+
"nuget",
26+
"pypi",
27+
"rubygems",
28+
"cargo",
29+
}
30+
actualEcosystems := provider.SupportedEcosystems()
31+
assert.True(t, reflect.DeepEqual(expectedEcosystems, actualEcosystems), "Expected %v but got %v", expectedEcosystems, actualEcosystems)
32+
}

renderers/json/json.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
// Package json contains functionality to render output in json format
21
package json
32

43
import (
54
"encoding/json"
5+
"fmt"
66
"log"
7-
"os"
87

9-
"github.com/devops-kung-fu/bomber/lib"
108
"github.com/devops-kung-fu/bomber/models"
11-
"github.com/devops-kung-fu/common/util"
129
)
1310

1411
// Renderer contains methods to render to JSON format
1512
type Renderer struct{}
1613

1714
// Render outputs json to STDOUT
1815
func (Renderer) Render(results models.Results) error {
19-
b, _ := json.MarshalIndent(results, "", "\t")
20-
filename := lib.GenerateFilename("json")
21-
util.PrintInfo("Writing JSON output:", filename)
22-
if err := os.WriteFile(filename, b, 0666); err != nil {
23-
log.Fatal(err)
16+
b, err := json.MarshalIndent(results, "", "\t")
17+
if err != nil {
18+
log.Println(err)
19+
return err
2420
}
21+
22+
fmt.Println(string(b))
2523
return nil
2624
}

renderers/jsonfile/jsonfile.go

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Package json contains functionality to render output in json format
2+
package jsonfile
3+
4+
import (
5+
"encoding/json"
6+
"log"
7+
"os"
8+
9+
"github.com/devops-kung-fu/common/util"
10+
11+
"github.com/devops-kung-fu/bomber/lib"
12+
"github.com/devops-kung-fu/bomber/models"
13+
)
14+
15+
// Renderer contains methods to render to JSON format
16+
type Renderer struct{}
17+
18+
// Render outputs json to STDOUT
19+
func (Renderer) Render(results models.Results) error {
20+
b, _ := json.MarshalIndent(results, "", "\t")
21+
filename := lib.GenerateFilename("json")
22+
util.PrintInfo("Writing JSON output:", filename)
23+
if err := os.WriteFile(filename, b, 0666); err != nil {
24+
log.Fatal(err)
25+
}
26+
return nil
27+
}

renderers/rendererfactory.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99
"github.com/devops-kung-fu/bomber/renderers/ai"
1010
"github.com/devops-kung-fu/bomber/renderers/html"
1111
"github.com/devops-kung-fu/bomber/renderers/json"
12+
"github.com/devops-kung-fu/bomber/renderers/jsonfile"
13+
"github.com/devops-kung-fu/bomber/renderers/md"
1214
"github.com/devops-kung-fu/bomber/renderers/stdout"
13-
"github.com/devops-kung-fu/bomber/renderers/md"
1415
)
1516

1617
// NewRenderer will return a Renderer interface for the requested output
@@ -21,12 +22,14 @@ func NewRenderer(output string) (renderers []models.Renderer, err error) {
2122
renderers = append(renderers, stdout.Renderer{})
2223
case "json":
2324
renderers = append(renderers, json.Renderer{})
25+
case "json-file":
26+
renderers = append(renderers, jsonfile.Renderer{})
2427
case "html":
2528
renderers = append(renderers, html.Renderer{})
2629
case "ai":
2730
renderers = append(renderers, ai.Renderer{})
28-
case "md":
29-
renderers = append(renderers, md.Renderer{})
31+
case "md":
32+
renderers = append(renderers, md.Renderer{})
3033
default:
3134
err = fmt.Errorf("%s is not a valid output type", s)
3235
}

renderers/rendererfactory_test.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/devops-kung-fu/bomber/renderers/ai"
99
"github.com/devops-kung-fu/bomber/renderers/html"
1010
"github.com/devops-kung-fu/bomber/renderers/json"
11+
"github.com/devops-kung-fu/bomber/renderers/jsonfile"
1112
"github.com/devops-kung-fu/bomber/renderers/md"
1213
"github.com/devops-kung-fu/bomber/renderers/stdout"
1314
)
@@ -29,12 +30,17 @@ func TestNewRenderer(t *testing.T) {
2930
assert.NoError(t, err)
3031
assert.IsType(t, ai.Renderer{}, renderers[0])
3132

32-
renderers, err = NewRenderer("stdout,json,html")
33+
renderers, err = NewRenderer("json-file")
34+
assert.NoError(t, err)
35+
assert.IsType(t, jsonfile.Renderer{}, renderers[0])
36+
37+
renderers, err = NewRenderer("stdout,json-file,html,json")
3338
assert.NoError(t, err)
3439
assert.IsType(t, stdout.Renderer{}, renderers[0])
35-
assert.IsType(t, json.Renderer{}, renderers[1])
40+
assert.IsType(t, jsonfile.Renderer{}, renderers[1])
3641
assert.IsType(t, html.Renderer{}, renderers[2])
37-
assert.Len(t, renderers, 3)
42+
assert.IsType(t, json.Renderer{}, renderers[3])
43+
assert.Len(t, renderers, 4)
3844

3945
renderers, err = NewRenderer("md")
4046
assert.NoError(t, err)

0 commit comments

Comments
 (0)