Skip to content

Commit b43ec88

Browse files
committed
MNT: Add and review security checks
1 parent e3303e6 commit b43ec88

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,16 @@ extend-select = [
145145
"A",
146146
"I",
147147
"UP",
148+
"YTT",
149+
"S",
148150
"B",
149151
]
150152

151153
[tool.ruff.flake8-quotes]
152154
inline-quotes = "single"
153155

156+
[tool.ruff.extend-per-file-ignores]
157+
"*/test_*.py" = ["S101"]
158+
154159
[tool.ruff.format]
155160
quote-style = "single"

smriprep/cli/run.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ def build_workflow(opts, retval):
482482

483483
# Load base plugin_settings from file if --use-plugin
484484
if opts.use_plugin is not None:
485-
from yaml import load as loadyml
485+
from yaml import safe_load as loadyml
486486

487487
with open(opts.use_plugin) as f:
488488
plugin_settings = loadyml(f)
@@ -651,7 +651,7 @@ def build_workflow(opts, retval):
651651
str(log_dir / 'CITATION.html'),
652652
]
653653
try:
654-
check_call(cmd, timeout=10)
654+
check_call(cmd, timeout=10) # noqa: S603
655655
except (FileNotFoundError, CalledProcessError, TimeoutExpired):
656656
logger.warning('Could not generate CITATION.html file:\n%s', ' '.join(cmd))
657657

@@ -667,7 +667,7 @@ def build_workflow(opts, retval):
667667
str(log_dir / 'CITATION.tex'),
668668
]
669669
try:
670-
check_call(cmd, timeout=10)
670+
check_call(cmd, timeout=10) # noqa: S603
671671
except (FileNotFoundError, CalledProcessError, TimeoutExpired):
672672
logger.warning('Could not generate CITATION.tex file:\n%s', ' '.join(cmd))
673673
else:

smriprep/workflows/surfaces.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,8 @@ def _extract_fs_fields(filenames: str | list[str]) -> tuple[str, str]:
16111611
paths = [Path(fn) for fn in filenames]
16121612
sub_dir = paths[0].parent.parent
16131613
subjects_dir, subject_id = sub_dir.parent, sub_dir.name
1614-
assert all(path == subjects_dir / subject_id / 'surf' / path.name for path in paths)
1614+
if not all(path.parent.parent == sub_dir for path in paths):
1615+
raise ValueError(f'Expected surface files from one subject.\nReceived: {filenames}')
16151616
return str(subjects_dir), subject_id
16161617

16171618

0 commit comments

Comments
 (0)