Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down
22 changes: 11 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 /
Expand Down
9 changes: 8 additions & 1 deletion middleware/http_session/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

from middleware.utils.tracer import traced

USER_AGENT = "FAIRagro-Harvester/1.0 (harvestmaster@fairagro.net)"


class HttpSessionConfig(NamedTuple):
"""
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions middleware/http_session/test/test_http_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
75 changes: 38 additions & 37 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Loading