Skip to content

Commit

Permalink
Merge pull request #225 from chaen/bandit
Browse files Browse the repository at this point in the history
test: bandit CI
  • Loading branch information
chrisburr authored Apr 3, 2024
2 parents 9b86d04 + 52f5ef1 commit 01fb8e3
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def make_release(version, commit_hash, release_notes=""):
"prerelease": Version(version).is_prerelease,
},
headers=headers,
timeout=60,
)
r.raise_for_status()
release_data = r.json()
Expand All @@ -41,6 +42,7 @@ def make_release(version, commit_hash, release_notes=""):
"draft": False,
},
headers=headers,
timeout=60,
)
r.raise_for_status()
release_data = r.json()
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
![DiracX tests](https://github.com/DIRACGrid/diracx/actions/workflows/main.yml/badge.svg?branch=main)
![Legacy tests](https://github.com/DIRACGrid/diracx/actions/workflows/integration.yml/badge.svg?branch=main)
![security: bandit](https://github.com/DIRACGrid/diracx/actions/workflows/main.yml/badge.svg?branch=main)

# DiracX Prototype

Expand Down
2 changes: 1 addition & 1 deletion containers/client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ghcr.io/diracgrid/diracx/client-base

ARG EXTRA_PACKAGES_TO_INSTALL

RUN --mount=type=bind,source=.,target=/bindmount DIRACX_CUSTOM_SOURCE_PREFIXES=/bindmount /entrypoint.sh bash -ec "pip install --no-deps ${EXTRA_PACKAGES_TO_INSTALL} && pip check"
RUN --mount=type=bind,source=.,target=/bindmount DIRACX_CUSTOM_SOURCE_PREFIXES=/bindmount /entrypoint.sh bash -ec "pip install --no-deps ${EXTRA_PACKAGES_TO_INSTALL} && echo 'Running pip check' && pip check"

# In many clusters the container is ran as a random uid for security reasons.
# If we mark the conda directory as group 0 and give it group write permissions
Expand Down
2 changes: 1 addition & 1 deletion containers/services/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ghcr.io/diracgrid/diracx/services-base

ARG EXTRA_PACKAGES_TO_INSTALL

RUN --mount=type=bind,source=.,target=/bindmount DIRACX_CUSTOM_SOURCE_PREFIXES=/bindmount /entrypoint.sh bash -ec "pip install --no-deps ${EXTRA_PACKAGES_TO_INSTALL} && pip check"
RUN --mount=type=bind,source=.,target=/bindmount DIRACX_CUSTOM_SOURCE_PREFIXES=/bindmount /entrypoint.sh bash -ec "pip install --no-deps ${EXTRA_PACKAGES_TO_INSTALL} && echo 'Running pip check' && pip check"

# In many clusters the container is ran as a random uid for security reasons.
# If we mark the conda directory as group 0 and give it group write permissions
Expand Down
3 changes: 2 additions & 1 deletion diracx-cli/src/diracx/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ async def logout():
# Revoke refresh token
try:
await api.auth.revoke_refresh_token(credentials["refresh_token"])
except Exception:
except Exception as e:
print(f"Error revoking the refresh token {e!r}")
pass

# Remove credentials
Expand Down
2 changes: 1 addition & 1 deletion diracx-routers/src/diracx/routers/auth/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class GrantType(StrEnum):

authorization_code = "authorization_code"
device_code = "urn:ietf:params:oauth:grant-type:device_code"
refresh_token = "refresh_token"
refresh_token = "refresh_token" # noqa: S105 # False positive of Bandit about hard coded password


class ScopeInfoDict(TypedDict):
Expand Down
71 changes: 45 additions & 26 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,19 @@ description = "Client installation for users of DiracX installations"
readme = "README.md"
requires-python = ">=3.10"
keywords = []
license = {text = "GPL-3.0-only"}
license = { text = "GPL-3.0-only" }
classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Topic :: System :: Distributed Computing",
]
dependencies = [
"diracx-api",
"diracx-cli",
"diracx-client",
"diracx-core",
]
dependencies = ["diracx-api", "diracx-cli", "diracx-client", "diracx-core"]
dynamic = ["version"]

[project.optional-dependencies]
testing = [
"diracx-testing",
]
testing = ["diracx-testing"]

[tool.setuptools]
packages = []
Expand All @@ -35,27 +28,51 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]

[tool.ruff]
select = [
"E", # pycodestyle errrors
"F", # pyflakes
"B", # flake8-bugbear
"I", # isort
"PLE", # pylint errors
# "UP", # pyUpgrade
"FLY", # flynt
"DTZ", # flake8-datetimez
]
ignore = ["B905", "B008", "B006"]
line-length = 120
src = ["diracx-*/src", "diracx-*/tests"]
exclude = ["diracx-client/src/diracx/client/"]


[tool.ruff.lint]
select = [
"E", # pycodestyle errrors
"F", # pyflakes
"B", # flake8-bugbear
"I", # isort
"PLE", # pylint errors
# "UP", # pyUpgrade
"FLY", # flynt
"DTZ", # flake8-datetimez
"S", # flake8-bandit
]

ignore = [
"B905",
"B008",
"B006",
"S101", # bandit: use of assert https://docs.astral.sh/ruff/rules/assert/
]


[tool.ruff.lint.per-file-ignores]
# Ignore Bandit security checks in the test directories
"diracx-testing/*" = ["S"]
"diracx-*/tests/*" = ["S"]

[tool.ruff.lint.flake8-bugbear]
# Allow default arguments like, e.g., `data: List[str] = fastapi.Query(None)`.
extend-immutable-calls = [
"fastapi.Depends",
"fastapi.Query",
"fastapi.Path",
"fastapi.Body",
"fastapi.Header",
]


[tool.isort]
profile = "black"

[tool.ruff.flake8-bugbear]
# Allow default arguments like, e.g., `data: List[str] = fastapi.Query(None)`.
extend-immutable-calls = ["fastapi.Depends", "fastapi.Query", "fastapi.Path", "fastapi.Body", "fastapi.Header"]

[tool.mypy]
files = [
Expand Down Expand Up @@ -100,8 +117,10 @@ testpaths = [
]
addopts = [
"-v",
"--cov=diracx", "--cov-report=term-missing",
"-pdiracx.testing", "-pdiracx.testing.osdb",
"--cov=diracx",
"--cov-report=term-missing",
"-pdiracx.testing",
"-pdiracx.testing.osdb",
"--import-mode=importlib",
]
asyncio_mode = "auto"
Expand Down

0 comments on commit 01fb8e3

Please sign in to comment.