Skip to content

Commit

Permalink
add ruff bandit linting
Browse files Browse the repository at this point in the history
fixes #50
  • Loading branch information
relud committed Mar 1, 2024
1 parent d19f45b commit 6b4d3e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ src = ["src", "tests"]
target-version = "py38"

[tool.ruff.lint]
# Enable pycodestyle (E), pyflakes (F), and bugbear (B) rules
select = ["E", "F", "B"]
# Enable pycodestyle (E), pyflakes (F), bugbear (B), and bandit (S) rules
select = ["E", "F", "B", "S"]

ignore = ["E501"]

[tool.ruff.lint.flake8-quotes]
docstring-quotes = "double"

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S101"]
"src/license-check.py" = ["S603", "S607"]
"src/release.py" = ["S310", "S603", "S607"]


[tool.release]
github_user = "willkg"
Expand Down
5 changes: 4 additions & 1 deletion src/service-status.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ def fetch(url, is_json=True):
errors if it's not valid JSON.
"""
fp = urlopen(url, timeout=5)
if not url.startswith(("http:", "https:")):
raise ValueError("URL must start with 'http:' or 'https:'")
# NOTE(willkg): ruff S310 can't determine whether we've validated the url or not
fp = urlopen(url, timeout=5) # noqa: S310
data = fp.read()
if is_json:
return json.loads(data)
Expand Down

0 comments on commit 6b4d3e9

Please sign in to comment.