-
Notifications
You must be signed in to change notification settings - Fork 38
/
json-writer.yml
35 lines (34 loc) · 1.46 KB
/
json-writer.yml
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
rules:
- id: json-encoder-needs-type
patterns:
- pattern: |
$ENC := json.NewEncoder(($W: http.ResponseWriter))
...
$ENC.Encode(...)
- pattern-not: |
$ENC := json.NewEncoder(($W: http.ResponseWriter))
...
$W.Header().Set("=~/Content-Type/i", "=~/application/json/")
...
$ENC.Encode(...)
- pattern-not-inside: |
$W.Header().Set("=~/Content-Type/i", "=~/application/json/")
...
$ENC := json.NewEncoder($W)
...
$ENC.Encode(...)
- pattern-not: |
$ENC := json.NewEncoder(($W: http.ResponseWriter))
...
$W.Header().Add("=~/Content-Type/i", "=~/application/json/")
...
$ENC.Encode(...)
- pattern-not-inside: |
$W.Header().Add("=~/Content-Type/i", "=~/application/json/")
...
$ENC := json.NewEncoder($W)
...
$ENC.Encode(...)
message: "calling json.Encode() on an http.ResponseWriter will set Content-Type text/plain"
languages: [go]
severity: ERROR