Skip to content

Commit

Permalink
Security/fix vulnerabilities (#72)
Browse files Browse the repository at this point in the history
* Updated dependencies

Incl. openapi-python-client which required additional changes.
Incl. #29 Nox task for adding transitive dependencies into main pyproject.toml


* Fixed review findings
  • Loading branch information
ckunki authored Jul 4, 2024
1 parent 9b74483 commit 0612829
Show file tree
Hide file tree
Showing 19 changed files with 393 additions and 284 deletions.
8 changes: 8 additions & 0 deletions doc/changes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Unreleased

This release fixes vulnerabilities by updating dependencies.

## Security

* Fixed vulnerabilities by updating dependencies
* Vulnerability CVE-2024-21503 in transitive dependency via `exasol-toolbox` to `black` in versions below `24.3.0`

## Refactorings

* #68: Update to Python 3.10
* #70: Optimized logging
* n/a: Changed schedule checking if open api is outdated to 2 am
* #29: Enhanced nox task generate-api to add transitive dependencies into main `pyproject.toml`
4 changes: 0 additions & 4 deletions exasol/saas/client/openapi/models/connection_i_ps.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions exasol/saas/client/openapi/models/create_database.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions exasol/saas/client/openapi/models/database.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions exasol/saas/client/openapi/models/extension.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions exasol/saas/client/openapi/models/extension_detail.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions exasol/saas/client/openapi/models/file.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions exasol/saas/client/openapi/models/patch_user_databases.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions exasol/saas/client/openapi/models/update_database.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions exasol/saas/client/openapi/models/usage.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions exasol/saas/client/openapi/models/user.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 32 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import json
import os
import nox
import re
import requests
import shutil
import toml # type: ignore

from datetime import datetime, timezone
from typing import List
from pathlib import Path
from nox import Session
from noxconfig import PROJECT_CONFIG
Expand All @@ -15,6 +19,9 @@
# default actions to be run if nothing is explicitly specified with the -s option
nox.options.sessions = ["fix"]

# destination folder for the generated open api client code
DEST_DIR = "exasol/saas/client/openapi"


def _download_openapi_json() -> Path:
url = f"{SAAS_HOST}/openapi.json"
Expand All @@ -31,6 +38,20 @@ def _download_openapi_json() -> Path:
return file


def dependencies(filename: str) -> List[str]:
def unlimit_max(lib, version):
version_spec = re.sub(r",.*$", "", version)
return f"{lib}@{version_spec}"

with open(filename, "r") as stream:
_toml = toml.load(stream)
return [
unlimit_max(lib, version)
for lib, version in _toml["tool"]["poetry"]["dependencies"].items()
if lib != "python"
]


@nox.session(name="generate-api", python=False)
def generate_api(session: Session):
"""
Expand All @@ -43,16 +64,22 @@ def generate_api(session: Session):
https://docs.github.com/en/actions/learn-github-actions/variables.
#default-environment-variables.
"""
silent = "CI" not in os.environ
local_build = "CI" not in os.environ
filename = _download_openapi_json()
session.run(
"openapi-python-client",
"update",
"generate",
"--path", str(filename),
"--config", "openapi_config.yml",
silent=silent,
"--output-path", "tmp",
silent=local_build,
)
session.run("isort", "-q", "exasol/saas/client/openapi")
shutil.rmtree(DEST_DIR)
shutil.move("tmp/generated", DEST_DIR)
if local_build:
session.run("poetry", "add", *dependencies("tmp/pyproject.toml"))
shutil.rmtree("tmp")
session.run("isort", "-q", DEST_DIR)


@nox.session(name="check-api-outdated", python=False)
Expand All @@ -61,7 +88,7 @@ def check_api_outdated(session: Session):
Generate API and run git diff to verify if API is out-dated.
"""
generate_api(session)
session.run("git", "diff", "--exit-code", "exasol/saas/client/openapi")
session.run("git", "diff", "--exit-code", DEST_DIR)


@nox.session(name="get-project-short-tag", python=False)
Expand Down
2 changes: 1 addition & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "1.0",
"download": {
"source": "https://cloud.exasol.com/openapi.json",
"timestamp": "2024-06-06T11:49:51.200508+00:00"
"timestamp": "2024-07-03T14:36:30.377504+00:00"
}
},
"servers": [
Expand Down
3 changes: 1 addition & 2 deletions openapi_config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
project_name_override: "exasol"
package_name_override: saas/client/openapi
project_name_override: "generated"
post_hooks: []
Loading

0 comments on commit 0612829

Please sign in to comment.