-
Notifications
You must be signed in to change notification settings - Fork 33
/
invalid-usage-of-modified-variable.yaml
61 lines (59 loc) · 1.52 KB
/
invalid-usage-of-modified-variable.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
rules:
- id: invalid-usage-of-modified-variable
message: >-
Variable `$X` is likely modified and later used on error. In some cases this could result
in panics due to a nil dereference
languages: [go]
severity: WARNING
metadata:
category: security
cwe: "CWE-665: Improper Initialization"
subcategory: [audit]
confidence: HIGH
likelihood: MEDIUM
impact: MEDIUM
technology: [--no-technology--]
description: "Possible unintentional assignment when an error occurs"
references:
- https://blog.trailofbits.com/2019/11/07/attacking-go-vr-ttps/
patterns:
- pattern: |
..., $X, ..., $ERR = ...
if $ERR != nil {
...
<... $X.$Y ...>
}
- pattern-not: |
..., $X, ..., $ERR = ...
if $ERR != nil {
...
$X, ... = ...
...
<... $X.$Y ...>
}
- pattern-not: |
..., $X, ..., $ERR = ...
if $ERR != nil {
...
$X = ...
...
<... $X.$Y ...>
}
- pattern-not: |
..., $X, ..., $ERR = ...
if $ERR != nil {
...
if $X != nil {
<... $X.$Y ...>
}
...
}
- pattern-not: |
..., $X, ..., $ERR := ...
if $ERR != nil {
...
if $X != nil && <... $X.$Y ...> {
...
}
...
}