diff --git a/Dockerfile b/Dockerfile index e6dde27..019e121 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,11 @@ COPY pyproject.toml uv.lock ./ # Install dependencies into the system python environment. RUN uv sync --frozen --no-dev +# Create a non-root user for security +RUN useradd -m -u 1000 apod && \ + chown -R apod:apod /app +USER apod + # This makes 'gunicorn' and 'flask' available globally in the container ENV PATH="/app/.venv/bin:$PATH" diff --git a/apod/utility.py b/apod/utility.py index 0f81629..d0e8d50 100644 --- a/apod/utility.py +++ b/apod/utility.py @@ -357,8 +357,10 @@ def get_concepts(request, text, apikey): try: LOG.debug("Getting response") - response = json.loads(request.get(cbase, fields=params)) - clist = [concept["text"] for concept in response["concepts"]] + response = requests.get(cbase, params=params) + response.raise_for_status() + data = response.json() + clist = [concept["text"] for concept in data["concepts"]] return {k: v for k, v in zip(range(len(clist)), clist)} except Exception as ex: