diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index db19645..4ff9399 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -15,7 +15,7 @@ "version": "3.12" }, "ghcr.io/mpriscella/features/sops:1": { - "version": "v3.7.3" + "version": "v3.13.3" }, "ghcr.io/eitsupi/devcontainer-features/jq-likes:2": { "jqVersion": "os-provided", @@ -33,10 +33,10 @@ "destination_dir": "/usr/local/bin" }, "ghcr.io/itsmechlark/features/trivy:1": { - "version": "0.53" + "version": "0.72.0" }, "ghcr.io/robbert229/devcontainer-features/postgresql-client:1": { - "version": "15" + "version": "18" }, "ghcr.io/schlich/cst-devcontainer-feature/container-structure-test:1": { "addAlias": true diff --git a/Dockerfile b/Dockerfile index 6effeb8..494838e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use secure Wolfi base image (without Python installed) -FROM cgr.dev/chainguard/wolfi-base@sha256:1c56f3ceb1c9929611a1cc7ab7a5fde1ec5df87add282029cd1596b8eae5af67 AS builder +FROM cgr.dev/chainguard/wolfi-base@sha256:003627df3c1e1bba0c4116afcddb314aca9594ee2328c7e876a8081a6c988b2e AS builder # Do not cache the Python bytecode (aka don't create__pycache__ folders) ENV PYTHONDONTWRITEBYTECODE=1 # Do not buffer stdout/stderr @@ -8,10 +8,10 @@ ENV PYTHONUNBUFFERED=1 WORKDIR /middleware # Install python and needed build tools RUN apk add --no-cache \ - python-3.12=3.12.12-r4 \ - py3.12-pip=26.0.1-r0 \ - python-3.12-dev=3.12.12-r4 \ - jq=1.8.1-r3 \ + python-3.12=3.12.13-r10 \ + py3.12-pip=26.1.2-r1 \ + python-3.12-dev=3.12.13-r10 \ + jq=1.8.2-r0 \ build-base=1-r9 # Set the user to nonroot. It's defined in the Wolfi base image with the user id 65532 USER nonroot @@ -23,7 +23,7 @@ RUN pip install --no-cache-dir -r requirements.txt --user # Actually we would like to use the Wolfi python image for the runtime as it contains even less software (e.g. no shell) # and thus a smaller attack surface. Unfortunately the Wolfi project only features the current development versions of # images for free. The older but stable python 3.11 is not available. -FROM cgr.dev/chainguard/wolfi-base@sha256:1c56f3ceb1c9929611a1cc7ab7a5fde1ec5df87add282029cd1596b8eae5af67 +FROM cgr.dev/chainguard/wolfi-base@sha256:003627df3c1e1bba0c4116afcddb314aca9594ee2328c7e876a8081a6c988b2e # Set the working directory in the container # copy python packages from builder stage COPY --from=builder /home/nonroot/.local /home/nonroot/.local @@ -38,11 +38,11 @@ COPY entrypoint.sh /entrypoint.sh # Create output directory (mountpoint) # and set permissions of the middleware folder RUN apk add --no-cache \ - python-3.12=3.12.12-r4 \ - py3.12-setuptools=82.0.0-r0 \ - git=2.53.0-r0 \ - jq=1.8.1-r3 \ - openssh-client=10.2_p1-r3 && \ + python-3.12=3.12.13-r10 \ + py3.12-setuptools=83.0.0-r0 \ + git=2.55.0-r4 \ + jq=1.8.2-r0 \ + openssh-client=10.4_p1-r1 && \ chown -R nonroot:nonroot /middleware /test && \ chmod +x /entrypoint.sh WORKDIR / diff --git a/middleware/http_session/__init__.py b/middleware/http_session/__init__.py index 97be873..f79f0dc 100644 --- a/middleware/http_session/__init__.py +++ b/middleware/http_session/__init__.py @@ -16,6 +16,8 @@ from middleware.utils.tracer import traced +USER_AGENT = "FAIRagro-Harvester/1.0 (harvestmaster@fairagro.net)" + class HttpSessionConfig(NamedTuple): """ @@ -78,7 +80,12 @@ def __init__(self, config: HttpSessionConfig) -> None: total=None, sock_read=config.receive_timeout, sock_connect=config.connect_timeout) - super().__init__(connector=connector, timeout=timeout, raise_for_status=True) + super().__init__( + connector=connector, + timeout=timeout, + raise_for_status=True, + headers={"User-Agent": USER_AGENT}, + ) except Exception as e: raise HttpSessionArgumentError( "Could not create HttpSession object") from e diff --git a/middleware/http_session/test/test_http_session.py b/middleware/http_session/test/test_http_session.py index 91ed2d2..3030c8f 100644 --- a/middleware/http_session/test/test_http_session.py +++ b/middleware/http_session/test/test_http_session.py @@ -22,6 +22,9 @@ class TestHttpSession(unittest.IsolatedAsyncioTestCase): async def asyncSetUp(self): self.session = HttpSession(config=MagicMock()) + async def asyncTearDown(self): + await self.session.close() + @patch("middleware.http_session.trace.get_tracer") @patch("middleware.http_session.chardet.detect", return_value={"encoding": "utf-8"}) @patch("middleware.http_session.HttpSession.get") diff --git a/requirements.txt b/requirements.txt index 643f334..efa0232 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,57 +1,58 @@ aiofiles==25.1.0 -aiohappyeyeballs==2.6.1 -aiohttp==3.13.3 +aiohappyeyeballs==2.7.1 +aiohttp==3.14.3 aiosignal==1.4.0 -attrs==25.4.0 +attrs==26.1.0 backoff==2.2.1 -beautifulsoup4==4.14.3 -certifi==2026.1.4 -chardet==5.2.0 -charset-normalizer==3.4.4 +beautifulsoup4==4.15.0 +certifi==2026.7.22 +chardet==7.4.3 +charset-normalizer==3.4.9 Deprecated==1.3.1 extruct==0.18.0 frozenlist==1.8.0 gitdb==4.0.12 -GitPython==3.1.46 -googleapis-common-protos==1.72.0 +GitPython==3.1.57 +googleapis-common-protos==1.75.0 +# Cap below 1.80: grpcio 1.80–1.83 regresses subprocess.Popen (grpc/grpc#42062) grpcio==1.78.0 html5lib==1.1 html_text==0.7.1 -idna==3.11 -importlib_metadata==8.7.1 +idna==3.18 +importlib_metadata==9.0.0 isodate==0.7.2 jstyleson==0.0.2 -lxml==6.0.2 -lxml_html_clean==0.4.3 +lxml==6.1.1 +lxml_html_clean==0.4.5 mf2py==2.0.1 multidict==6.7.1 -opentelemetry-api==1.39.1 -opentelemetry-exporter-otlp-proto-common==1.39.1 -opentelemetry-exporter-otlp-proto-grpc==1.39.1 -opentelemetry-instrumentation==0.60b1 -opentelemetry-instrumentation-aiohttp-client==0.60b1 -opentelemetry-instrumentation-requests==0.60b1 -opentelemetry-instrumentation-urllib==0.60b1 -opentelemetry-proto==1.39.1 -opentelemetry-sdk==1.39.1 -opentelemetry-semantic-conventions==0.60b1 -opentelemetry-util-http==0.60b1 -packaging==26.0 -propcache==0.4.1 -protobuf==6.33.5 +opentelemetry-api==1.44.0 +opentelemetry-exporter-otlp-proto-common==1.44.0 +opentelemetry-exporter-otlp-proto-grpc==1.44.0 +opentelemetry-instrumentation==0.65b0 +opentelemetry-instrumentation-aiohttp-client==0.65b0 +opentelemetry-instrumentation-requests==0.65b0 +opentelemetry-instrumentation-urllib==0.65b0 +opentelemetry-proto==1.44.0 +opentelemetry-sdk==1.44.0 +opentelemetry-semantic-conventions==0.65b0 +opentelemetry-util-http==0.65b0 +packaging==26.2 +propcache==0.5.2 +protobuf==7.35.1 pyparsing==3.3.2 pyRdfa3==3.6.5 -pytz==2025.2 +pytz==2026.3.post1 PyYAML==6.0.3 rdflib==7.6.0 -requests==2.32.5 +requests==2.34.2 six==1.17.0 -smmap==5.0.2 -soupsieve==2.8.3 -typing_extensions==4.15.0 -urllib3==2.6.3 -w3lib==2.4.0 +smmap==5.0.3 +soupsieve==2.9.1 +typing_extensions==4.16.0 +urllib3==2.7.0 +w3lib==2.4.1 webencodings==0.5.1 -wrapt==1.17.3 -yarl==1.22.0 -zipp==3.23.0 +wrapt==2.2.2 +yarl==1.24.5 +zipp==4.1.0