Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Bandit to pre-commit. #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ repos:
hooks:
- id: mypy
args: ["--install-types", "--non-interactive", "--ignore-missing-imports"]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.10
hooks:
- id: bandit
args: [ "--skip", "B101" ]
exclude: |
(?x)^(
.*/.*_test\.py|
.*/.*test_.*\.py
)$
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Auto-generated System Security Plan (SSP)

[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)

<!--ts-->
* [Auto-generated System Security Plan (SSP)](#auto-generated-system-security-plan-ssp)
* [Overview](#overview)
Expand Down
1,072 changes: 610 additions & 462 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ sop = "tools.sop.sop:main"
makessp = "tools.makessp.makessp:main"
getconfig = "tools.helpers.config:check_config"

[[tool.mypy.overrides]]
[tool.mypy.overrides]
module = "yaml"
ignore_missing_imports = true
4 changes: 2 additions & 2 deletions tools/helpers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self):
if self.configuration.exists():
try:
with open(self.configuration, "r") as fp:
self.config = yaml.load(fp, Loader=yaml.FullLoader)
self.config = yaml.safe_load(fp)
except IOError:
print(f"Error loading {self.configuration.as_posix}.")
else:
Expand All @@ -32,7 +32,7 @@ def load_keys(self):
key = self.default_keys.get(filename.name, filename.stem)
self.config_files.append((filename.name, key))
with open(filename, "r") as fp:
self.config[key] = yaml.load(fp, Loader=yaml.FullLoader)
self.config[key] = yaml.safe_load(fp)

def check_config_values(self, file: str, key: str = "") -> str | dict:
if key:
Expand Down
2 changes: 1 addition & 1 deletion tools/helpers/secrender.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_template(template_path: str) -> jinja2.Template:
abs_path = os.path.abspath(template_path)
template_dir, template_file = os.path.split(abs_path)
template_loader = jinja2.FileSystemLoader(searchpath=template_dir)
template_env = jinja2.Environment(loader=template_loader)
template_env = jinja2.Environment(loader=template_loader, autoescape=True)
template = template_env.get_template(template_file)

return template
Expand Down
2 changes: 1 addition & 1 deletion tools/helpers/ssptoolkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def load_yaml_files(file_path: str | Path) -> dict:
load_file = Path(file_path) if isinstance(file_path, str) else file_path
try:
with open(load_file, "r") as fp:
project = yaml.load(fp, Loader=yaml.FullLoader)
project = yaml.safe_load(fp)
return project
except FileNotFoundError:
raise FileNotFoundError(
Expand Down