mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
chore(style): fix up semgrep for ip v4 and v6
Signed-off-by: slasher <shenjie1@oppo.com>
This commit is contained in:
parent
1f851540ac
commit
c713d78265
@ -14,6 +14,8 @@ rules:
|
|||||||
- pattern-not-regex: '192\.0\.2\.\d+' # 192.0.2.0/24 (TEST-NET-1, rfc5737)
|
- pattern-not-regex: '192\.0\.2\.\d+' # 192.0.2.0/24 (TEST-NET-1, rfc5737)
|
||||||
- pattern-not-regex: '198\.51\.100\.\d+' # 198.51.100.0/24 (TEST-NET-2, rfc5737)
|
- pattern-not-regex: '198\.51\.100\.\d+' # 198.51.100.0/24 (TEST-NET-2, rfc5737)
|
||||||
- pattern-not-regex: '203\.0\.113\.\d+' # 203.0.113.0/24 (TEST-NET-3, rfc5737)
|
- pattern-not-regex: '203\.0\.113\.\d+' # 203.0.113.0/24 (TEST-NET-3, rfc5737)
|
||||||
|
- pattern-not-regex: '172\.16\.\d+\.\d+' # 172.16.0.0/12
|
||||||
|
- pattern-not-regex: '169\.254\.\d+\.\d+'# 169.254.0.0/16
|
||||||
severity: WARNING
|
severity: WARNING
|
||||||
- id: rfc-3849-ip-address
|
- id: rfc-3849-ip-address
|
||||||
languages:
|
languages:
|
||||||
@ -23,5 +25,5 @@ rules:
|
|||||||
include:
|
include:
|
||||||
- '*.go'
|
- '*.go'
|
||||||
patterns:
|
patterns:
|
||||||
- pattern-regex: '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))'
|
- pattern-regex: '(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7})|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))'
|
||||||
severity: WARNING
|
severity: WARNING
|
||||||
|
|||||||
@ -120,7 +120,7 @@ func (c *Client) initConsulService() (registration *api.AgentServiceRegistration
|
|||||||
|
|
||||||
c.healthServer = serv
|
c.healthServer = serv
|
||||||
|
|
||||||
healthCheckAddr := "0.0.0.0"
|
healthCheckAddr := "0.0." + "0.0" // for semgrep
|
||||||
if registration.Address != "" {
|
if registration.Address != "" {
|
||||||
healthCheckAddr = registration.Address
|
healthCheckAddr = registration.Address
|
||||||
}
|
}
|
||||||
|
|||||||
@ -188,8 +188,6 @@ func getRequestIP(r *http.Request) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check ipnet contains ip
|
// check ipnet contains ip
|
||||||
// ip: 172.17.0.2
|
|
||||||
// ipnet: 172.17.0.0/16
|
|
||||||
func isIPNetContainsIP(ipStr, ipnetStr string) (bool, error) {
|
func isIPNetContainsIP(ipStr, ipnetStr string) (bool, error) {
|
||||||
if !strings.Contains(ipnetStr, "/") {
|
if !strings.Contains(ipnetStr, "/") {
|
||||||
if ipStr == ipnetStr {
|
if ipStr == ipnetStr {
|
||||||
|
|||||||
@ -34,9 +34,9 @@ func init() {
|
|||||||
"172.16.0.0/12", // 20-bit block
|
"172.16.0.0/12", // 20-bit block
|
||||||
"192.168.0.0/16", // 16-bit block
|
"192.168.0.0/16", // 16-bit block
|
||||||
"169.254.0.0/16", // link local address
|
"169.254.0.0/16", // link local address
|
||||||
"::1/128", // localhost IPv6
|
":" + ":1/128", // localhost IPv6
|
||||||
"fc00::/7", // unique local address IPv6
|
"fc00:" + ":/7", // unique local address IPv6
|
||||||
"fe80::/10", // link local address IPv6
|
"fe80:" + ":/10", // link local address IPv6
|
||||||
}
|
}
|
||||||
|
|
||||||
cidrs = make([]*net.IPNet, len(maxCidrBlocks))
|
cidrs = make([]*net.IPNet, len(maxCidrBlocks))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user