Skip to content

Commit 2144ca4

Browse files
committed
rule: has_perm misuse
1 parent 8ad4f23 commit 2144ca4

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

rules/code_quality.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,24 @@ rules:
2424
get_doc(dict(k=v)) is same as get_doc(k=v)
2525
languages: [python]
2626
severity: WARNING
27+
28+
- id: unchecked-frappe-permission-call
29+
languages:
30+
- python
31+
message: >-
32+
Found a call to `frappe.has_permission` where the return value is ignored.
33+
Unless `throw=True` is passed, this function only returns a boolean and
34+
does not enforce security on its own.
35+
severity: ERROR
36+
patterns:
37+
- pattern: frappe.has_permission(...)
38+
- pattern-not: frappe.has_permission(..., throw=True, ...)
39+
- pattern-not: frappe.has_permission(..., throw=$SOMETHING, ...)
40+
- pattern-not-inside: $VAR = frappe.has_permission(...)
41+
- pattern-not-inside: "return ..."
42+
- pattern-not-inside: "if <... frappe.has_permission(...) ...> : ..."
43+
- pattern-not-inside: "$PRED_TRUE if frappe.has_permission(...) else $PRED_FALSE"
44+
- pattern-not-inside: assert frappe.has_permission(...)
45+
paths:
46+
exclude:
47+
- "**/test_*.py"

0 commit comments

Comments
 (0)