aboutsummaryrefslogtreecommitdiff
path: root/src/smp/__init__.py
diff options
context:
space:
mode:
authorQrius <[email protected]>2025-05-06 14:22:33 +0200
committerQrius <[email protected]>2025-05-06 14:23:04 +0200
commit77e73d70a9b81a7bbd8e49be52612fc62a9f9502 (patch)
treec816ff6a30dee18e2c701cfd83c3e9104e73e333 /src/smp/__init__.py
parent68f3e45b0c9570e4bdf01147f606f04bda6be310 (diff)
downloadskaldpress-77e73d70a9b81a7bbd8e49be52612fc62a9f9502.tar.gz
skaldpress-77e73d70a9b81a7bbd8e49be52612fc62a9f9502.zip
Disable unsafe code execution by default
Diffstat (limited to 'src/smp/__init__.py')
-rw-r--r--src/smp/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/smp/__init__.py b/src/smp/__init__.py
index f7cb937..2cdf2fe 100644
--- a/src/smp/__init__.py
+++ b/src/smp/__init__.py
@@ -42,6 +42,13 @@ def main():
help="Prefix builtins with smp_",
)
parser.add_argument(
+ "-U",
+ "--unsafe",
+ default=False,
+ action="store_true",
+ help="Allow unsafe code execution",
+ )
+ parser.add_argument(
"file", nargs="?", default=None, help='Input file or "-" for stdin'
)
args = parser.parse_args()
@@ -50,6 +57,8 @@ def main():
macro_processor_state = smp.macro_processor.MacroProcessorState()
prefix = "smp_" if args.prefix_builtins else ""
macro_processor = macro_processor_state.macro_processor(prefix=prefix)
+ if args.unsafe:
+ macro_processor.unsafe_code_execution = True
for key, value in args.D.items():
macro_processor.define_macro(key, value)