diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a52c68a..f6353ce 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 8e70ca6..65ebf55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,6 +19,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", ] @@ -73,7 +74,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"] 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( 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 =