You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the input data is too large for the target type log an error and set
the target data to 0.
The added checking should remove the need for te #nosec G115 comment but
is seems the nested dnstap struct is causing issues for gosec, see the
linked issue comment for details.
qp:=int32(*dt.Message.QueryPort) // #nosec G115 -- QueryPort is defined as 16-bit number and is used in parquet field with type=INT32, convertedType=UINT_16
1754
-
sd.SourcePort=&qp
1753
+
if*dt.Message.QueryPort>math.MaxInt32 {
1754
+
edm.log.Error("dt.Message.QueryPort is too large for int32, setting port 0")
1755
+
varqpint32
1756
+
sd.SourcePort=&qp
1757
+
} else {
1758
+
qp:=int32(*dt.Message.QueryPort) // #nosec G115 -- QueryPort is defined as 16-bit number and is used in parquet field with type=INT32, convertedType=UINT_16, https://github.com/securego/gosec/issues/1212#issuecomment-2739574884
1759
+
sd.SourcePort=&qp
1760
+
}
1755
1761
}
1756
1762
1757
1763
ifdt.Message.ResponsePort!=nil {
1758
-
rp:=int32(*dt.Message.ResponsePort) // #nosec G115 -- ResponsePort is defined as 16-bit number and is used in parquet field with type=INT32, convertedType=UINT_16
1759
-
sd.DestPort=&rp
1764
+
if*dt.Message.ResponsePort>math.MaxInt32 {
1765
+
edm.log.Error("dt.Message.ResponsePort is too large for int32, setting port 0")
1766
+
varrpint32
1767
+
sd.DestPort=&rp
1768
+
} else {
1769
+
rp:=int32(*dt.Message.ResponsePort) // #nosec G115 -- ResponsePort is defined as 16-bit number and is used in parquet field with type=INT32, convertedType=UINT_16, https://github.com/securego/gosec/issues/1212#issuecomment-2739574884
t=time.Unix(int64(*dt.Message.QueryTimeSec), int64(*dt.Message.QueryTimeNsec)).UTC() // #nosec G115 -- Overflowing the int64 would result in interesting timestamps but not much else
2065
+
if*dt.Message.QueryTimeSec>math.MaxInt64 {
2066
+
edm.log.Error("dt.Message.QueryTimeSec is too large for int64, setting time to 0")
2067
+
*dt.Message.QueryTimeSec=0
2068
+
*dt.Message.QueryTimeNsec=0
2069
+
}
2070
+
t=time.Unix(int64(*dt.Message.QueryTimeSec), int64(*dt.Message.QueryTimeNsec)).UTC() // #nosec G115 -- Will be zeroed out above if too large, https://github.com/securego/gosec/issues/1212#issuecomment-2739574884
t=time.Unix(int64(*dt.Message.ResponseTimeSec), int64(*dt.Message.ResponseTimeNsec)).UTC() // #nosec G115 -- Overflowing the int64 would result in interesting timestamps but not much else
2077
+
if*dt.Message.ResponseTimeSec>math.MaxInt64 {
2078
+
edm.log.Error("dt.Message.ResponseTimeSec is too large for int64, setting time to 0")
2079
+
*dt.Message.ResponseTimeSec=0
2080
+
*dt.Message.ResponseTimeNsec=0
2081
+
}
2082
+
t=time.Unix(int64(*dt.Message.ResponseTimeSec), int64(*dt.Message.ResponseTimeNsec)).UTC() // #nosec G115 -- Will be zeroed out above if too large, https://github.com/securego/gosec/issues/1212#issuecomment-2739574884
0 commit comments