diff --git a/build/simple/Dockerfile b/build/simple/Dockerfile index 3205b7f9..da3a25df 100644 --- a/build/simple/Dockerfile +++ b/build/simple/Dockerfile @@ -13,7 +13,7 @@ # limitations under the License. -FROM python:3.11.4-slim as base +FROM python:3.11.14-slim as base ARG ENV ARG PIP_DISABLE_PIP_VERSION_CHECK=1 @@ -26,4 +26,12 @@ COPY simple/ . COPY build/simple/run.sh . RUN pip3 install -r /workspace/requirements.txt -CMD ./run.sh \ No newline at end of file + +RUN pip3 install --upgrade \ + pip \ + setuptools \ + "wheel==0.46.2" \ + "urllib3==2.6.3" \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +CMD ./run.sh diff --git a/simple/requirements.txt b/simple/requirements.txt index a06f59fe..866ded34 100644 --- a/simple/requirements.txt +++ b/simple/requirements.txt @@ -15,9 +15,9 @@ numpy==1.25.2 pandas==2.1.0 parameterized==0.9.0 platformdirs==3.10.0 -protobuf==4.25.3 +protobuf==6.33.5 PyLD==2.0.4 -PyMySQL==1.1.0 +PyMySQL==1.1.1 python-dateutil==2.8.2 pytest==7.4.2 PyYAML==6.0.1 diff --git a/simple/util/dc_client.py b/simple/util/dc_client.py index 231faac6..918ab50f 100644 --- a/simple/util/dc_client.py +++ b/simple/util/dc_client.py @@ -70,9 +70,35 @@ def get_api_root(): return os.environ.get(_API_ROOT_ENV, _DEFAULT_API_ROOT) +def mask_key(key: str, show: int = 5, max_visible_percent: float = 0.3) -> str: + """Masks a key for logging purposes, showing only parts of it. + + Args: + key: The string key to mask. + show: The number of characters to show from each end of the key. + max_visible_percent: The maximum percentage of the key's length that can be + visible from both ends combined. + + Returns: + A masked string of the key. + """ + if not key: + return "" + + length = len(key) + max_visible = int(length * max_visible_percent) + visible_each_side = min(show, max_visible // 2) + + if visible_each_side < 1 or length <= visible_each_side * 2: + return "*" * length + + middle = "*" * (length - visible_each_side * 2) + return f"{key[:visible_each_side]}{middle}{key[-visible_each_side:]}" + + if _DEBUG: logging.info("DC API Root: %s", get_api_root()) - logging.info("DC API Key: %s", get_api_key()) + logging.info("DC API Key: %s", mask_key(get_api_key())) os.makedirs(_DEBUG_FOLDER, exist_ok=True)