Commit graph

165 commits

Author SHA1 Message Date
Aarol D'Souza
77af2d53d6
fix(system console): allow read-only queries in system console (#36652)
* fix(system console): allow read-only queries in system console

* fix(security): make transactions strictly read only for console and scripts

* test: remove test to reflect ban on cte's for security

* fix: Only enable read only mode for SQL query

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2026-02-05 11:39:10 +00:00
Akhil Narang
835fcbd849
chore: use our copy of protected_inplacevar
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-10-03 00:13:55 +05:30
Raffael Meyer
b7b34196bc
fix(Server Script): open docs URL in new tab (#33982) 2025-09-15 10:53:52 +00:00
Akhil Narang
9a94e73489
feat: add in support for _inplacevar_ (#31921)
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-08-01 13:50:43 +05:30
Venkatesh M
96e0f49df4 fix: handle None session.data in maintenance mode (fixes #33258)
- Add null check for session.data in safe_exec.py
- Add null check for session.data in base_template_page.py
- Prevents AttributeError when session.data is None during maintenance mode
2025-07-19 16:02:57 +00:00
Ankush Menat
b94b6ec939 perf!: Compute safe exceptions only once 2025-07-19 19:29:27 +05:30
Ankush Menat
38365beb52 perf: Compute safe utils only once
300us -> 60us for this silly change LOL!
2025-07-19 18:49:24 +05:30
Ankush Menat
17a1244585 perf: Always use cached config for checking safe_exec
It expires in 1min anyway
2025-07-19 18:14:04 +05:30
Ankush Menat
bddc89544d perf: Cache safe_exec compilation 2025-07-19 18:04:29 +05:30
Sagar Vora
2e5c8bea03 feat: frappe.utils.orjson_dumps 2025-06-26 17:37:51 +05:30
Sagar Vora
cb0d06455b chore: use frappe._dev_server instead of local.dev_server 2025-06-17 12:03:08 +05:30
Soham Kulkarni
6305e848b4
fix(safe_exec): add get_content_hash (#32265)
* fix(safe_exec): add get_content_hash

* fix: replace exposed function with sha256

* fix: rename function to sha256_hash and make it consistent
2025-04-27 13:37:25 +05:30
Sagar Vora
29c318964b
Revert "perf!: faster frappedict getattr" 2025-03-12 18:35:33 +05:30
Sagar Vora
5be83f7df8
Revert "fix: add __slots__ to NamespaceDict" 2025-03-12 18:34:17 +05:30
Sagar Vora
a5dd24ebe9 fix: add __slots__ to NamespaceDict 2025-03-12 14:05:27 +05:30
Sagar Vora
c592f323ff fix: restore dict.__getattribute__ for NamespaceDict 2025-03-12 13:28:12 +05:30
Ankush Menat
766cb64d55
perf!: Cache site configs in memory for 60 seconds (#28869)
This is middle ground between caching it completely and requiring a
restart/signal to reload vs always reloading it.

I don't know any use cases that can break from this, nowhere in code
configs should be expected to reload instantly.

This change is only applied to requests for now
2024-12-27 16:21:14 +00:00
Akhil Narang
84ef6ec677
refactor: fixup with ruff 0.8.1
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-04 13:18:04 +05:30
David Arnold
8b1180ba27
refactor: server script autocompletion to be more generic (#28180) 2024-10-19 12:56:24 +00:00
Raffael Meyer
b91cacdd18
feat!: enhance Language to become more of a Locale (#27178) 2024-09-21 16:02:58 +02:00
David
d50e579317
feat(utm): make data helper more useful 2024-09-12 00:08:11 +02:00
vishnu
b41083561e feat: Add get_month function to return current or specific month as a string 2024-08-17 14:11:00 +00:00
Kevin Shenk
12f193231d
refactor: enable website utils in safe_exec (#25365)
Frappe Builder uses safe_exec to fetch dynamic data, and there are a few functions in website utilities which would be nice to have on that end, get_html_content_based_on_type especially. I added a few others which seemed useful and safe as well.
2024-03-27 15:26:28 +05:30
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Hussain Nagaria
0b95e8fcc2 chore: get_year_ending to safe_exec 2023-12-17 15:35:55 +05:30
Hussain Nagaria
51a03c52f1 docs: safe_exec get_hooks 2023-12-16 22:13:55 +05:30
Sagar Vora
8cc4fc349a chore: improve condition to avoid re-initializing flag 2023-12-11 10:53:04 +05:30
Corentin Flr
4b367245eb
Merge pull request from GHSA-v3vh-7qx4-f582 2023-12-11 10:40:27 +05:30
Ankush Menat
57699a54b1
fix: Show server script name in traceback (#23676)
* fix: Show server script name in traceback

* chore: typo

Co-authored-by: Sagar Vora <sagar@resilient.tech>

---------

Co-authored-by: Sagar Vora <sagar@resilient.tech>
2023-12-08 15:01:13 +05:30
tonspar
fae3685b03
feat: Patch and Delete Request to integration utils (#23525)
* Update utils.py

Adding the patch and delete request

* Update safe_exec.py

Adding the patch and delete request from integration utils.
2023-12-01 10:25:43 +05:30
Akhil Narang
eb45da3913
feat: Allow usage of print() within safe_exec() (#23084)
* feat(safe_exec): allow usage of `print()`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* refactor(system_console): update description to mention `print()` instead of `log()`

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* feat: unconditionally add debug logs to response if present

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* chore(safe_exec): add in a test for running `print()` within safe_exec

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* fix(safe_exec): ignore warning

RestrictedPython warns us if we call `print()` don't use their `printed` variable

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* feat: store debug logs from scheduled jobs

Signed-off-by: Akhil Narang <me@akhilnarang.dev>

* fix: avoid ignoring warnings, disabled in prod anyway

* chore: remove unnecessary logging

This can be moved to level 2 when required

---------

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-11-20 12:45:41 +05:30
Ankush Menat
e152ebc0a3 chore: typo 2023-09-18 20:16:27 +05:30
gavin
c3efddd380
fix: Allow DB Callback Managers in Safe Exec (#22302) 2023-09-05 10:38:14 +05:30
Ankush Menat
e9585e9ce6 fix: remove validation on text code
These can overvalidate e.g. "Frappe information technology" contains "format".

Restricted python anyways validates these attr access at runtime, so no
need to validate this on code.
2023-08-31 11:03:28 +05:30
Ankush Menat
1390b972a8 fix(DX): let users know that server scripts are disabled 2023-08-23 14:49:05 +05:30
Ankush Menat
6e0b522ae3 refactor!: Disable server scripts by default
- Move the config to bench level and not site level because, server
  script "threat model" requires consent from a bench owner and not
  individual site.
- While this is a breaking change which people may not like, we believe
  it's essential to improve security model of Frappe.
2023-08-23 14:49:05 +05:30
Ankush Menat
8ddde056a0 fix: dont allow NamedExpr in safe_eval 2023-08-21 12:42:21 +05:30
Ankush Menat
eede56d5df fix: dont allow writes to live objects 2023-08-21 12:04:55 +05:30
Ankush Menat
f449262050 fix: allow dict access and unpacks 2023-08-21 11:59:53 +05:30
Ankush Menat
14b62d7ff1 fix: correct getattr implementation for safe_eval 2023-08-21 11:59:53 +05:30
Ankush Menat
3531f58b54 refactor: unify safe_exec and safe_eval code
A lot of duplication was present for this code.
2023-08-21 11:59:53 +05:30
Ankush Menat
4d5a945861
refactor: reduce duplication in unsafe attr checks (#22033) 2023-08-13 18:23:41 +05:30
Ankush Menat
ce1355dab8
fix: block format attributes (#22028) 2023-08-12 22:12:30 +05:30
Michelle Alva
fd2efdb0e1
chore: whitelisted typo (#21930) 2023-08-05 20:15:55 +05:30
Ankush Menat
7ee85758b1
fix(console): dont commit when exception is raised and unconditionally check query (#21850)
* fix(console): unconditionally check query type

* fix(console): don't commit when exception occurs
2023-07-28 18:07:08 +05:30
Nabin Hait
94ccdd628a fix: added get_quarter_ending function in safe_exec 2023-06-22 16:18:52 +05:30
Ankush Menat
3005e66e45 refactor!: Drop previously deprecated code 2023-06-13 16:00:43 +05:30
Raffael Meyer
036e1c94cd
feat!: remove deprecated timezone utils (#20255) 2023-03-06 19:56:57 +05:30