-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefer-in-loop.yaml
43 lines (43 loc) · 1.03 KB
/
defer-in-loop.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
rules:
- id: defer-in-loop
message: Risk of resource exhaustion due to the use of defer inside a loop
languages:
- go
severity: INFO
metadata:
cwe:
- "CWE-404: Improper Resource Shutdown or Release"
category: security
subcategory:
- vuln
confidence: MEDIUM
likelihood: MEDIUM
impact: LOW
technology:
- go
description: Resource leak due improper use of `defer`
references:
- https://blog.learngoprogramming.com/gotchas-of-defer-in-go-1-8d070894cb01
patterns:
- pattern-inside: |
for ... {
...
}
- pattern: |
defer $X(...)
- pattern-not-inside: |
go func(...) {
...
}(...)
- pattern-not-inside: |
func(...) {
...
}
- pattern-not-inside: |
$G.Go(func(...) $RET {
...
})
- pattern-not-inside: |
func(...) $RET {
...
}(...)