FROM mono:6.12

# mono:6.12 is based on Debian Buster, which has moved to archive.debian.org.
RUN sed -i \
        -e 's|deb.debian.org/debian|archive.debian.org/debian|g' \
        -e 's|deb.debian.org/debian-security|archive.debian.org/debian-security|g' \
        -e '/buster-updates/d' \
        /etc/apt/sources.list \
    && apt-get -o Acquire::Check-Valid-Until=false update \
    && apt-get install --no-install-recommends -y mono-xsp4 python3 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Lab secret: readable by the worker, never served by the application.
RUN printf 'flag{cve_2026_131914_mono_lab}\n' > /flag.txt

COPY web/ /app/
COPY Meridian/ /src/Meridian/
COPY LabAntiCsrf.cs /src/LabAntiCsrf.cs

# The proof runner is the same file used from the host, copied in so that
# `docker compose run proof` works without duplicating any logic.
COPY cve-2026-131914-poc/poc.py /tools/poc.py

# The app assembly and the intentionally vulnerable module live in bin/.
RUN mkdir -p /app/bin \
    && mcs -target:library \
        -out:/app/bin/Meridian.Core.dll \
        -r:System.Web \
        -r:System.Core \
        /src/Meridian/Core.cs \
    && mcs -target:library \
        -out:/app/bin/LabAntiCsrf.dll \
        -r:System.Web \
        -r:System \
        /src/LabAntiCsrf.cs \
    && rm -rf /src

EXPOSE 8080

CMD ["xsp4", "--root", "/app", "--address", "0.0.0.0", "--port", "8080", "--nonstop"]
