diff --git a/doc/changelog.d/754.fixed.md b/doc/changelog.d/754.fixed.md new file mode 100644 index 000000000..5c22cb257 --- /dev/null +++ b/doc/changelog.d/754.fixed.md @@ -0,0 +1 @@ +Minor improvements in ``jinja`` auto escape and ``subprocess`` call \ No newline at end of file diff --git a/src/ansys_sphinx_theme/cheatsheet.py b/src/ansys_sphinx_theme/cheatsheet.py index 62826bee2..e9d600bcc 100644 --- a/src/ansys_sphinx_theme/cheatsheet.py +++ b/src/ansys_sphinx_theme/cheatsheet.py @@ -27,7 +27,10 @@ """ import pathlib -import subprocess + +# Excudind bandit rule B404 as we are using subprocess to run commands +# and we are handling the command execution securely. +import subprocess # nosec: B404 from typing import List, Optional from sphinx.application import Sphinx @@ -103,7 +106,10 @@ def run_quarto_command(command: List[str], cwd: str) -> None: """ command = ["quarto"] + command try: - result = subprocess.run(command, cwd=cwd, check=True, capture_output=True, text=True) + # Excluding bandit rule because subprocess is using quarto command + # and we are handling the command execution securely. + # The command is run in a controlled environment and not accepting user input. + result = subprocess.run(command, cwd=cwd, check=True, capture_output=True, text=True) # nosec: B603 if result.stdout: logger.info(result.stdout) diff --git a/src/ansys_sphinx_theme/latex/__init__.py b/src/ansys_sphinx_theme/latex/__init__.py index ea5e21ab1..bfe66cea3 100644 --- a/src/ansys_sphinx_theme/latex/__init__.py +++ b/src/ansys_sphinx_theme/latex/__init__.py @@ -64,7 +64,7 @@ def generate_preamble(title, watermark="watermark", date=None): line_statement_prefix="%%", line_comment_prefix="%#", trim_blocks=True, - autoescape=False, + autoescape=True, loader=jinja2.FileSystemLoader(COVER_TEX), ) template = latex_jinja_env.get_template(".") @@ -100,6 +100,6 @@ def generate_404( variables = dict( issue_page=issue_page, project_name=project_name, mail_id=mail_id, team_name=team_name ) - html_env = jinja2.Environment(loader=jinja2.FileSystemLoader(PAGE_404)) + html_env = jinja2.Environment(loader=jinja2.FileSystemLoader(PAGE_404), autoescape=True) template = html_env.get_template(".") return template.render(variables)