forked from trailofbits/semgrep-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync-mutex-value-copied.yaml
38 lines (36 loc) · 985 Bytes
/
sync-mutex-value-copied.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
rules:
- id: sync-mutex-value-copied
message: >-
A `sync.Mutex` is copied in function `$FUNC` given that `$T` is value receiver.
As a result, the struct `$T` may not be locked as intended
languages: [go]
severity: ERROR
metadata:
category: security
cwe: "CWE-688: Function Call With Incorrect Variable or Reference as Argument"
subcategory: [vuln]
confidence: HIGH
likelihood: HIGH
impact: LOW
technology: [--no-technology--]
description: "Copying of `sync.Mutex` via value receivers"
references:
- https://go101.org/article/concurrent-common-mistakes.html
patterns:
- pattern-either:
- pattern: |
func ($T $TYPE) $FUNC(...){
...
$T.Lock()
...
}
- pattern: |
func ($T $TYPE) $FUNC(...){
...
$T.RLock()
...
}
- pattern-not: |
func ($T2 *$TYPE2) $FUNC(...){
...
}