Skip to content

Commit

Permalink
Upgrade to Python 3.11 (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
gruebel authored Oct 22, 2023
1 parent 9c5cce3 commit 97d6045
Show file tree
Hide file tree
Showing 12 changed files with 989 additions and 88 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ on:
permissions: read-all

env:
MIN_PYTHON_VERSION: "3.10"
MIN_PYTHON_VERSION: "3.11"

jobs:
lint:
uses: bridgecrewio/gha-reusable-workflows/.github/workflows/pre-commit.yaml@main
with:
python-version: "3.10" # can't leverage env vars here
python-version: "3.11" # can't leverage env vars here
mypy:
uses: bridgecrewio/gha-reusable-workflows/.github/workflows/mypy.yaml@main
with:
python-version: "3.10" # can't leverage env vars here
python-version: "3.11" # can't leverage env vars here

unit-tests:
timeout-minutes: 5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
permissions: read-all

env:
PYTHON_VERSION: "3.10"
PYTHON_VERSION: "3.11"

jobs:
update-checkov:
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-json
- id: check-toml
Expand All @@ -11,11 +11,11 @@ repos:
args: ["--django"]
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.10.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.206
rev: v0.1.0
hooks:
- id: ruff
args:
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM python:3.10-slim
FROM python:3.11-slim

# mention "admissionController" as the source of integration to bridgecrew.cloud
ENV BC_SOURCE=admissionController
ENV PIP_ENV_VERSION="2022.11.25"
ENV PIP_ENV_VERSION="2023.7.23"
ENV RUN_IN_DOCKER=True

RUN set -eux; \
Expand All @@ -16,10 +16,10 @@ WORKDIR /app
COPY Pipfile Pipfile.lock ./

RUN set -eux; \
pip install pipenv==${PIP_ENV_VERSION}; \
pip install --no-deps pipenv==${PIP_ENV_VERSION}; \
pipenv requirements > requirements.txt; \
pip install -r requirements.txt --no-deps; \
rm -f requirements.txt; \
rm -f requirements.txt Pipfile Pipfile.lock; \
pip uninstall -y pipenv

COPY wsgi.py ./
Expand Down
10 changes: 5 additions & 5 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ name = "pypi"

[packages]
checkov = "==2.5.17"
flask = "==2.2.2"
flask-apscheduler = "==1.12.4"
python-dotenv = "==0.21.0"
gunicorn = "==20.1.0"
flask = "==2.3.3"
flask-apscheduler = "==1.13.0"
python-dotenv = "==1.0.0"
gunicorn = "==21.2.0"

[dev-packages]
mypy = "*"
Expand All @@ -18,4 +18,4 @@ pytest-mock = "*"
types-pyyaml = "*"

[requires]
python_version = "3.10"
python_version = "3.11"
1,013 changes: 953 additions & 60 deletions Pipfile.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion app/checkov_whorf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import os.path
from typing import TYPE_CHECKING, Literal

import yaml
Expand All @@ -12,6 +13,7 @@
from logging import Logger

from checkov.common.output.baseline import Baseline
from checkov.common.output.report import Report
from checkov.common.runners.runner_registry import RunnerRegistry


Expand All @@ -24,18 +26,20 @@ def __init__(self, logger: Logger, argv: list[str]) -> None:
def upload_results(
self,
root_folder: str,
absolute_root_folder: str,
files: list[str] | None = None,
excluded_paths: list[str] | None = None,
included_paths: list[str] | None = None,
git_configuration_folders: list[str] | None = None,
sca_supported_ir_report: Report | None = None,
) -> None:
# don't upload results with every run
return

def upload_results_periodically(self, root_folder: str) -> None:
"""Used to upload results on a periodic basis"""

super().upload_results(root_folder=root_folder)
super().upload_results(root_folder=root_folder, absolute_root_folder=os.path.abspath(root_folder))

def print_results(
self,
Expand Down
2 changes: 1 addition & 1 deletion app/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO").upper()

CHECKOV_CONFIG_PATH = Path("config/.checkov.yaml")
MANIFEST_ROOT_PATH = Path("/tmp")
MANIFEST_ROOT_PATH = Path("/tmp") # noqa: S108
WHORF_CONFIG_PATH = Path("config/whorf.yaml")

DEFAULT_CHECKOV_ARGS = ["--framework", "kubernetes", "--repo-id", "k8s_ac/cluster"]
Expand Down
4 changes: 2 additions & 2 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def to_dict(obj: Any) -> Any:
if val is not None:
result[v] = to_dict(val)
return result
elif type(obj) == list:
elif isinstance(obj, list):
return [to_dict(x) for x in obj]
elif type(obj) == datetime:
elif isinstance(obj, datetime):
return str(obj)
else:
return obj
Expand Down
9 changes: 4 additions & 5 deletions app/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ def process_failed_checks(ckv_whorf: CheckovWhorf, uid: str, obj_kind_name: str)
try:
for report in ckv_whorf.scan_reports:
for check in report.failed_checks:
if check.check_id in ckv_whorf.config.hard_fail_on:
hard_fails[check.check_id] = f"\n Description: {check.check_name}"
if check.guideline:
hard_fails[check.check_id] += f"\n Guidance: {check.guideline}"
elif check.bc_check_id in ckv_whorf.config.hard_fail_on:
if (
check.check_id in ckv_whorf.config.hard_fail_on
or check.bc_check_id in ckv_whorf.config.hard_fail_on
):
hard_fails[check.check_id] = f"\n Description: {check.check_name}"
if check.guideline:
hard_fails[check.check_id] += f"\n Guidance: {check.guideline}"
Expand Down
5 changes: 3 additions & 2 deletions extra_stubs/flask_apscheduler/scheduler.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Callable, Any, ParamSpec, TypeVar, overload
from collections.abc import Callable
from typing import Any, ParamSpec, TypeVar, overload

from apscheduler.schedulers.base import BaseScheduler # type:ignore[import]
from apscheduler.schedulers.base import BaseScheduler # type:ignore[import-untyped]
from flask import Flask

_F = TypeVar("_F", bound=Callable[..., Any])
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ select = [
ignore = ["ARG002", "E501"]
per-file-ignores = { "tests/**/*" = ["S101"] }

target-version = "py310"
exclude = [
"extra_stubs",
]

target-version = "py311"

0 comments on commit 97d6045

Please sign in to comment.