File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ rules :
2+ - id : relaxed-permissions
3+ patterns :
4+ - pattern : |
5+ {
6+ "role": "All",
7+ ...
8+ }
9+ message : |
10+ Avoid using "All" role. It's available to every user, including website user.
11+ languages : [json]
12+ severity : WARNING
Original file line number Diff line number Diff line change 11def function_name (input ):
22 # ruleid: frappe-codeinjection-eval
33 eval (input )
4-
5- # ok: frappe-codeinjection-eval
6- eval ("1 + 1" )
Original file line number Diff line number Diff line change 1+ rules :
2+ - id : frappe-codeinjection-eval
3+ patterns :
4+ - pattern-either :
5+ - pattern : eval(...)
6+ - pattern : exec(...)
7+ - pattern : safe_exec(...)
8+ - pattern : safe_eval(...)
9+ message : |
10+ Detected the use of functions that can be dangerous if used to evaluate
11+ dynamic content. This code should be manually audited by security team.
12+ languages : [python]
13+ severity : ERROR
14+
15+ - id : frappe-ssti
16+ patterns :
17+ - pattern : render_template($ARG, ...)
18+ message : |
19+ Detected the use of render_template, make sure $ARG comes from trusted
20+ source. This code should be audited by security team.
21+ languages : [python]
22+ severity : ERROR
Original file line number Diff line number Diff line change 1+ rules :
2+ - id : frappe-sql-format-injection
3+ languages : [python]
4+ severity : INFO
5+ message : >-
6+ Detected use of '.format()' or f-string in a Frappe SQL call.
7+ This can lead to SQL injection. Use parameterized queries instead.
8+ patterns :
9+ - pattern-either :
10+ - pattern : frappe.db.sql("...".format(...), ...)
11+ - pattern : frappe.db.sql(f"...", ...)
12+ - pattern : frappe.db.multisql("...".format(...), ...)
13+ - pattern : frappe.db.multisql(f"...", ...)
14+ # Matches cases where the string is formatted beforehand
15+ - pattern : |
16+ $QUERY = "...".format(...)
17+ ...
18+ frappe.db.sql($QUERY, ...)
19+ - pattern : |
20+ $QUERY = f"..."
21+ ...
22+ frappe.db.sql($QUERY, ...)
Original file line number Diff line number Diff line change 1+ from typing import Any
2+ import frappe
3+
4+
5+
6+ # ruleid: missing-argument-type-hint
7+ @frappe .whitelist ()
8+ def function_name (inject , abc ):
9+ pass
10+
11+ # ok: missing-argument-type-hint
12+ @frappe .whitelist ()
13+ def function_name (inject : str , abc : str ):
14+ pass
15+
16+ # ok: missing-argument-type-hint
17+ @frappe .whitelist ()
18+ def function_name ():
19+ pass
20+
21+ # ok: missing-argument-type-hint
22+ @frappe .whitelist ()
23+ def function_name (abc : Any ):
24+ pass
25+
26+
27+ # ruleid: missing-argument-type-hint
28+ @frappe .whitelist ()
29+ def function_name (inject , abc : str ): # only one typed
30+ pass
Original file line number Diff line number Diff line change 1+ rules :
2+ - id : missing-argument-type-hint
3+ languages : [python]
4+ severity : WARNING
5+ patterns :
6+ - pattern : |
7+ @frappe.whitelist(...)
8+ def $FUNC(..., $ARG, ...): ...
9+ - pattern-not : |
10+ @frappe.whitelist(...)
11+ def $FUNC(..., $ARG: $TYPE, ...): ...
12+ - metavariable-regex :
13+ metavariable : $ARG
14+ # Exclude 'self' and 'cls' as they typically don't take hints
15+ regex : ^(?!self$|cls$).*$
16+ message : " The argument '$ARG' in function '$FUNC' is missing a type hint."
17+ - id : guest-whitelisted-method
18+ languages : [python]
19+ severity : WARNING
20+ patterns :
21+ - pattern : |
22+ @frappe.whitelist(..., allow_guest=True, ...)
23+ def $FUNC(...): ...
24+ message : " Whitelisted method that's accesible to guest should be manually reviewed by security team."
You can’t perform that action at this time.
0 commit comments