Skip to content

Commit e34e8dd

Browse files
authored
Extend the G117 rule to cover other types of serialization such as yaml/xml/toml (#1529)
Signed-off-by: Cosmin Cojocar <cosmin@cojocar.ch>
1 parent b940702 commit e34e8dd

6 files changed

Lines changed: 417 additions & 51 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ directory you can supply `./...` as the input argument.
195195
- G114: Use of net/http serve function that has no support for setting timeouts
196196
- G115: Potential integer overflow when converting between integer types
197197
- G116: Detect Trojan Source attacks using bidirectional Unicode control characters
198-
- G117: Potential exposure of secrets in values marshaled by encoding/json
198+
- G117: Potential exposure of secrets in values marshaled by JSON/YAML/XML/TOML
199199
- G118: Context propagation failure leading to goroutine/resource leaks
200200
- G119: Unsafe redirect policy may propagate sensitive headers
201201
- G120: Unbounded form parsing in HTTP handlers can cause memory exhaustion

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
cloud.google.com/go v0.121.2 // indirect
2525
cloud.google.com/go/auth v0.16.5 // indirect
2626
cloud.google.com/go/compute/metadata v0.8.0 // indirect
27+
github.com/BurntSushi/toml v1.5.0 // indirect
2728
github.com/Masterminds/semver/v3 v3.4.0 // indirect
2829
github.com/davecgh/go-spew v1.1.1 // indirect
2930
github.com/felixge/httpsnoop v1.0.4 // indirect
@@ -36,6 +37,7 @@ require (
3637
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
3738
github.com/googleapis/gax-go/v2 v2.15.0 // indirect
3839
github.com/gorilla/websocket v1.5.3 // indirect
40+
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
3941
github.com/pmezard/go-difflib v1.0.0 // indirect
4042
github.com/stretchr/objx v0.5.2 // indirect
4143
github.com/tidwall/gjson v1.18.0 // indirect

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
4040
contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc=
4141
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
4242
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
43+
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
44+
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
4345
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
4446
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
4547
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
@@ -315,6 +317,8 @@ github.com/openai/openai-go/v3 v3.22.0 h1:6MEoNoV8sbjOVmXdvhmuX3BjVbVdcExbVyGixi
315317
github.com/openai/openai-go/v3 v3.22.0/go.mod h1:cdufnVK14cWcT9qA1rRtrXx4FTRsgbDPW7Ia7SS5cZo=
316318
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
317319
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
320+
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
321+
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
318322
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
319323
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
320324
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

rules/rulelist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func Generate(trackSuppressions bool, filters ...RuleFilter) RuleList {
7777
{"G112", "Detect ReadHeaderTimeout not configured as a potential risk", NewSlowloris},
7878
{"G114", "Use of net/http serve function that has no support for setting timeouts", NewHTTPServeWithoutTimeouts},
7979
{"G116", "Detect Trojan Source attacks using bidirectional Unicode characters", NewTrojanSource},
80-
{"G117", "Potential exposure of secrets via JSON marshaling", NewSecretSerialization},
80+
{"G117", "Potential exposure of secrets via JSON/YAML/XML/TOML marshaling", NewSecretSerialization},
8181

8282
// injection
8383
{"G201", "SQL query construction using format string", NewSQLStrFormat},

0 commit comments

Comments
 (0)