Skip to content

Commit 6d704dd

Browse files
committed
feat(python): add initial support for Python
1 parent 739cfd4 commit 6d704dd

27 files changed

+2362
-1
lines changed

.envrc.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ export GOOGLE_MAX_ATTEMPT="5"
77
export BEARER_EXECUTABLE_PATH="./bearer"
88
export GITHUB_WORKSPACE="/path/to/bearer/project"
99
export SCAN_DIR=/Users/username/OWASP
10+
export BEARER_DISABLE_VERSION_CHECK=true
1011
export BEARER_DISABLE_DEFAULT_RULES=true
1112
export BEARER_EXTERNAL_RULE_DIR=$PWD/../bearer-rules/rules
1213
export BEARER_FORCE=true
14+
export BEARER_IGNORE_GIT=true
1315
export BEARER_PHP_ENABLED=true
1416
export BEARER_GOLANG_ENABLED=true
15-
export BEARER_IGNORE_GIT=true
17+
export BEARER_PYTHON_ENABLED=true

internal/commands/process/settings/rules.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ var (
3333
func GetSupportedRuleLanguages() map[string]bool {
3434
phpSupported := os.Getenv("BEARER_PHP_ENABLED") == "true"
3535
goSupported := os.Getenv("BEARER_GOLANG_ENABLED") == "true"
36+
pythonSupported := os.Getenv("BEARER_PYTHON_ENABLED") == "true"
3637

3738
return map[string]bool{
39+
"python": pythonSupported,
3840
"php": phpSupported,
3941
"go": goSupported,
4042
"java": true,

internal/commands/process/settings/settings.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ func (rule *Rule) Language() string {
298298
return "Go"
299299
case "php":
300300
return "PHP"
301+
case "python":
302+
return "Python"
301303
default:
302304
return rule.Languages[0]
303305
}
Lines changed: 350 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,350 @@
1+
high:
2+
- rule:
3+
cwe_ids:
4+
- "42"
5+
id: scope_test
6+
title: Test detection filter scopes
7+
description: Test detection filter scopes
8+
documentation_url: ""
9+
line_number: 1
10+
full_filename: scope.py
11+
filename: scope.py
12+
source:
13+
location:
14+
start: 1
15+
end: 1
16+
column:
17+
start: 1
18+
end: 37
19+
sink:
20+
location:
21+
start: 1
22+
end: 1
23+
column:
24+
start: 1
25+
end: 37
26+
content: scopeCursor(request.GET.get('oops'))
27+
parent_line_number: 1
28+
snippet: scopeCursor(request.GET.get('oops'))
29+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_0
30+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_0
31+
- rule:
32+
cwe_ids:
33+
- "42"
34+
id: scope_test
35+
title: Test detection filter scopes
36+
description: Test detection filter scopes
37+
documentation_url: ""
38+
line_number: 3
39+
full_filename: scope.py
40+
filename: scope.py
41+
source:
42+
location:
43+
start: 3
44+
end: 3
45+
column:
46+
start: 1
47+
end: 49
48+
sink:
49+
location:
50+
start: 3
51+
end: 3
52+
column:
53+
start: 1
54+
end: 49
55+
content: scopeCursor(request.GET.get('oops') if x else y)
56+
parent_line_number: 3
57+
snippet: scopeCursor(request.GET.get('oops') if x else y)
58+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_1
59+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_1
60+
- rule:
61+
cwe_ids:
62+
- "42"
63+
id: scope_test
64+
title: Test detection filter scopes
65+
description: Test detection filter scopes
66+
documentation_url: ""
67+
line_number: 5
68+
full_filename: scope.py
69+
filename: scope.py
70+
source:
71+
location:
72+
start: 5
73+
end: 5
74+
column:
75+
start: 1
76+
end: 42
77+
sink:
78+
location:
79+
start: 5
80+
end: 5
81+
column:
82+
start: 1
83+
end: 42
84+
content: scopeCursor(request.GET.get('oops') or y)
85+
parent_line_number: 5
86+
snippet: scopeCursor(request.GET.get('oops') or y)
87+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_2
88+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_2
89+
- rule:
90+
cwe_ids:
91+
- "42"
92+
id: scope_test
93+
title: Test detection filter scopes
94+
description: Test detection filter scopes
95+
documentation_url: ""
96+
line_number: 7
97+
full_filename: scope.py
98+
filename: scope.py
99+
source:
100+
location:
101+
start: 7
102+
end: 7
103+
column:
104+
start: 1
105+
end: 37
106+
sink:
107+
location:
108+
start: 7
109+
end: 7
110+
column:
111+
start: 1
112+
end: 37
113+
content: scopeNested(request.GET.get('oops'))
114+
parent_line_number: 7
115+
snippet: scopeNested(request.GET.get('oops'))
116+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_3
117+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_3
118+
- rule:
119+
cwe_ids:
120+
- "42"
121+
id: scope_test
122+
title: Test detection filter scopes
123+
description: Test detection filter scopes
124+
documentation_url: ""
125+
line_number: 8
126+
full_filename: scope.py
127+
filename: scope.py
128+
source:
129+
location:
130+
start: 8
131+
end: 8
132+
column:
133+
start: 1
134+
end: 41
135+
sink:
136+
location:
137+
start: 8
138+
end: 8
139+
column:
140+
start: 1
141+
end: 41
142+
content: scopeNested(x + request.GET.get('oops'))
143+
parent_line_number: 8
144+
snippet: scopeNested(x + request.GET.get('oops'))
145+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_4
146+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_4
147+
- rule:
148+
cwe_ids:
149+
- "42"
150+
id: scope_test
151+
title: Test detection filter scopes
152+
description: Test detection filter scopes
153+
documentation_url: ""
154+
line_number: 9
155+
full_filename: scope.py
156+
filename: scope.py
157+
source:
158+
location:
159+
start: 9
160+
end: 9
161+
column:
162+
start: 1
163+
end: 49
164+
sink:
165+
location:
166+
start: 9
167+
end: 9
168+
column:
169+
start: 1
170+
end: 49
171+
content: scopeNested(request.GET.get('oops') if x else y)
172+
parent_line_number: 9
173+
snippet: scopeNested(request.GET.get('oops') if x else y)
174+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_5
175+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_5
176+
- rule:
177+
cwe_ids:
178+
- "42"
179+
id: scope_test
180+
title: Test detection filter scopes
181+
description: Test detection filter scopes
182+
documentation_url: ""
183+
line_number: 10
184+
full_filename: scope.py
185+
filename: scope.py
186+
source:
187+
location:
188+
start: 10
189+
end: 10
190+
column:
191+
start: 1
192+
end: 49
193+
sink:
194+
location:
195+
start: 10
196+
end: 10
197+
column:
198+
start: 1
199+
end: 49
200+
content: scopeNested(x if request.GET.get('oops') else y)
201+
parent_line_number: 10
202+
snippet: scopeNested(x if request.GET.get('oops') else y)
203+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_6
204+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_6
205+
- rule:
206+
cwe_ids:
207+
- "42"
208+
id: scope_test
209+
title: Test detection filter scopes
210+
description: Test detection filter scopes
211+
documentation_url: ""
212+
line_number: 11
213+
full_filename: scope.py
214+
filename: scope.py
215+
source:
216+
location:
217+
start: 11
218+
end: 11
219+
column:
220+
start: 1
221+
end: 42
222+
sink:
223+
location:
224+
start: 11
225+
end: 11
226+
column:
227+
start: 1
228+
end: 42
229+
content: scopeNested(request.GET.get('oops') or y)
230+
parent_line_number: 11
231+
snippet: scopeNested(request.GET.get('oops') or y)
232+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_7
233+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_7
234+
- rule:
235+
cwe_ids:
236+
- "42"
237+
id: scope_test
238+
title: Test detection filter scopes
239+
description: Test detection filter scopes
240+
documentation_url: ""
241+
line_number: 13
242+
full_filename: scope.py
243+
filename: scope.py
244+
source:
245+
location:
246+
start: 13
247+
end: 13
248+
column:
249+
start: 1
250+
end: 37
251+
sink:
252+
location:
253+
start: 13
254+
end: 13
255+
column:
256+
start: 1
257+
end: 37
258+
content: scopeResult(request.GET.get('oops'))
259+
parent_line_number: 13
260+
snippet: scopeResult(request.GET.get('oops'))
261+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_8
262+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_8
263+
- rule:
264+
cwe_ids:
265+
- "42"
266+
id: scope_test
267+
title: Test detection filter scopes
268+
description: Test detection filter scopes
269+
documentation_url: ""
270+
line_number: 14
271+
full_filename: scope.py
272+
filename: scope.py
273+
source:
274+
location:
275+
start: 14
276+
end: 14
277+
column:
278+
start: 1
279+
end: 41
280+
sink:
281+
location:
282+
start: 14
283+
end: 14
284+
column:
285+
start: 1
286+
end: 41
287+
content: scopeResult(x + request.GET.get('oops'))
288+
parent_line_number: 14
289+
snippet: scopeResult(x + request.GET.get('oops'))
290+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_9
291+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_9
292+
- rule:
293+
cwe_ids:
294+
- "42"
295+
id: scope_test
296+
title: Test detection filter scopes
297+
description: Test detection filter scopes
298+
documentation_url: ""
299+
line_number: 15
300+
full_filename: scope.py
301+
filename: scope.py
302+
source:
303+
location:
304+
start: 15
305+
end: 15
306+
column:
307+
start: 1
308+
end: 49
309+
sink:
310+
location:
311+
start: 15
312+
end: 15
313+
column:
314+
start: 1
315+
end: 49
316+
content: scopeResult(request.GET.get('oops') if x else y)
317+
parent_line_number: 15
318+
snippet: scopeResult(request.GET.get('oops') if x else y)
319+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_10
320+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_10
321+
- rule:
322+
cwe_ids:
323+
- "42"
324+
id: scope_test
325+
title: Test detection filter scopes
326+
description: Test detection filter scopes
327+
documentation_url: ""
328+
line_number: 17
329+
full_filename: scope.py
330+
filename: scope.py
331+
source:
332+
location:
333+
start: 17
334+
end: 17
335+
column:
336+
start: 1
337+
end: 42
338+
sink:
339+
location:
340+
start: 17
341+
end: 17
342+
column:
343+
start: 1
344+
end: 42
345+
content: scopeResult(request.GET.get('oops') or y)
346+
parent_line_number: 17
347+
snippet: scopeResult(request.GET.get('oops') or y)
348+
fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_11
349+
old_fingerprint: bf75ffc19e7352a46ad95a1ad74cedb9_11
350+

0 commit comments

Comments
 (0)