Skip to content

Commit fe6c024

Browse files
Mark repo as safe from bandit
I audited this repo for bandit issues; didn't end up making any changes to the code, but did make a few comments to note bandit checks that were disabled. Also excluded the `scripts` directory from bandit checks, as those are not run in production, only locally during testing.
1 parent f87e879 commit fe6c024

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

docassemble/ALWeaver/interview_generator.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ def _is_private_or_local(hostname: str) -> bool:
371371
url,
372372
headers={"User-Agent": "ALWeaver/1.0 (+docassemble)"},
373373
)
374-
with urlopen(req, timeout=10) as response:
374+
# url checked for SSRF above, so marking as audited for bandit
375+
with urlopen(req, timeout=10) as response: # nosec B310
375376
content_type = str(response.headers.get("Content-Type", "") or "").lower()
376377
if content_type and (
377378
"text/html" not in content_type
@@ -5109,7 +5110,10 @@ def _render_interview_yaml(
51095110
output_mako_text = mako_handle.read()
51105111

51115112
template_text = output_defs_text + "\n" + output_mako_text
5112-
template = mako.template.Template(template_text, input_encoding="utf-8")
5113+
# This mako template is making a docassemble YAML, so it's not directly at risk of XSS injection.
5114+
template = mako.template.Template(
5115+
template_text, input_encoding="utf-8"
5116+
) # nosec B702
51135117

51145118
if screen_reordered is None:
51155119
# The interview order block needs both the authored question screens and any

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[tool.bandit]
2+
exclude_dirs = ["scripts", "venv", ".venv"]
3+
14
[tool.black]
25
extend-exclude = '(__init__.py|setup.py)'
36

0 commit comments

Comments
 (0)