From d71b78e21c3be1764c0d7bf53682aa92cecc6531 Mon Sep 17 00:00:00 2001 From: bunny-therapist Date: Fri, 30 Jun 2023 17:48:39 +0200 Subject: [PATCH 1/3] Support Python 3.12 --- .github/workflows/ci.yaml | 2 +- pyproject.toml | 1 + tox.ini | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 495bcca..6d1473e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ jobs: build: strategy: matrix: - python_version: ["3.8", "3.9", "3.10", "3.11"] + python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"] runs-on: "ubuntu-latest" steps: - uses: actions/checkout@v3 diff --git a/pyproject.toml b/pyproject.toml index 47906d5..fdf43b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Topic :: Security", "License :: OSI Approved :: Apache Software License", ] diff --git a/tox.ini b/tox.ini index fc18d01..c0c2a14 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38,py39,py310,py311 +envlist = py38,py39,py310,py311,py312 isolated_build = True minversion = 4.0.0 @@ -9,6 +9,7 @@ python = 3.9: py39 3.10: py310 3.11: py311 + 3.12: py312 [testenv] deps = From d3f232d6394b0b2ad64e2e8165fbf692d531fe89 Mon Sep 17 00:00:00 2001 From: avikstroem Date: Fri, 13 Oct 2023 17:12:15 +0200 Subject: [PATCH 2/3] Logger updates --- .../github_security_advisory.py | 21 +++++++++++-------- src/security_constraints/main.py | 4 ++-- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/security_constraints/github_security_advisory.py b/src/security_constraints/github_security_advisory.py index ed2903a..9b905d6 100644 --- a/src/security_constraints/github_security_advisory.py +++ b/src/security_constraints/github_security_advisory.py @@ -125,7 +125,6 @@ def get_vulnerabilities( after = json_data["securityVulnerabilities"]["pageInfo"]["endCursor"] except KeyError as missing_key: error_msg = f"Key {missing_key} not found in: {json_response}" - LOGGER.error(error_msg) raise FetchVulnerabilitiesError(error_msg) from None return vulnerabilities @@ -138,6 +137,8 @@ def _do_graphql_request( severities=",".join(sorted([str(severity) for severity in severities])), additional=f'after:"{after}"' if after is not None else "", ) + LOGGER.debug("GraphQL query: %s", query) + LOGGER.debug("Sending request to %s", self.URL) response: requests.Response = self._session.post( url=self.URL, headers={"Authorization": f"bearer {self._token}"}, @@ -151,15 +152,17 @@ def _do_graphql_request( f"Unexpected json data format in response: {json_content}" ) except requests.HTTPError as error: - LOGGER.error( - "HTTP error (status %s) received from URL %s: %s", - response.status_code, - self.URL, - error, + error_msg = ( + "HTTP error (status {status}) received from URL {url}: {err}".format( + status=response.status_code, + url=self.URL, + err=error, + ) ) - raise FetchVulnerabilitiesError from error + raise FetchVulnerabilitiesError(error_msg) from error except requests.JSONDecodeError as error: - LOGGER.error("Could not decode json data in response: %s", response.text) - raise FetchVulnerabilitiesError from error + error_msg = f"Could not decode json data in response: {response.text}" + raise FetchVulnerabilitiesError(error_msg) from error else: + LOGGER.debug("Request to %s was successful", self.URL) return json_content diff --git a/src/security_constraints/main.py b/src/security_constraints/main.py index cb7cfe3..12eaa7b 100644 --- a/src/security_constraints/main.py +++ b/src/security_constraints/main.py @@ -277,8 +277,8 @@ def main() -> int: output.write( f"{format_constraints_file_line(constraints, vulnerability)}\n" ) - except SecurityConstraintsError as error: - LOGGER.error(error) + except SecurityConstraintsError: + LOGGER.exception("Program exited with an exception.") return 1 except Exception as error: LOGGER.critical( From dbf6a76de08f7a189009ef77e0ce52448b5dc171 Mon Sep 17 00:00:00 2001 From: avikstroem Date: Fri, 13 Oct 2023 17:15:24 +0200 Subject: [PATCH 3/3] Update mypy config for deprecated flag --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fdf43b8..b07dd43 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ disallow_untyped_decorators = true no_implicit_optional = true no_implicit_reexport = true strict_equality = true -strict_concatenate = true +extra_checks = true [tool.ruff] src = ["src", "test"]