diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ee43a7e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:2.7.18-stretch + +WORKDIR /usr/src/app +COPY . . +RUN make install +RUN python manage.py migrate +RUN python manage.py seed + +CMD [ "python", "manage.py", "runserver", "0.0.0.0:8000" ] diff --git a/Dockerfile-Contrast b/Dockerfile-Contrast new file mode 100644 index 00000000..f0b6d5b1 --- /dev/null +++ b/Dockerfile-Contrast @@ -0,0 +1,13 @@ +FROM python:2.7.18-stretch + +WORKDIR /usr/src/app + +COPY contrast_security.yaml /etc/contrast/contrast_security.yaml +COPY . . +RUN sed -i.bk "s/#'contrast/'contrast/g" pygoat/settings.py +RUN pip install contrast-agent +RUN make install +RUN python manage.py migrate +RUN python manage.py seed + +CMD [ "python", "manage.py", "runserver", "0.0.0.0:8000" ] diff --git a/README.md b/README.md index d0ecf5f5..be870641 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,31 @@ If you want to setup DjanGoat with a PostgreSQL database, checkout the PostgreSQ $ git checkout postgresql-database ``` The PostgreSQL branch has modified documentation and tests. +### Docker +To run DjanGoat in Docker use the following command to build +``` + $ docker build -t djangoat . +``` +To run execute the following +``` + $ docker run -p8000:8000 djangoat +``` +The Web ui will then be accessible via +http://localhost:8000 + +**username** : admin@metacorp.com +**password** : admin1234 +#### Docker and Contrast +To enable Contrast Protect. first edit contrast_security.yaml with your agent credentials. +Then build the Docker image using Dockerfile-Contrast. +``` + $ docker build -f Dockerfile-Contrast -t djangoat-contrast . +``` +To run execute the following +``` + $ docker run -p8000:8000 djangoat-contrast +``` + ### Testing To run tests, simply run: diff --git a/contrast_security.yaml b/contrast_security.yaml new file mode 100644 index 00000000..26832076 --- /dev/null +++ b/contrast_security.yaml @@ -0,0 +1,14 @@ +api: + url: https://eval.contrastsecurity.com/Contrast/ + service_key: + api_key: + user_name: + + agent: + logger: + path: /tmp/contrast_agent.log + level: INFO + + security_logger: + path: /tmp/security.log + level: INFO diff --git a/pygoat/settings.py b/pygoat/settings.py index 610f01c7..d710f714 100644 --- a/pygoat/settings.py +++ b/pygoat/settings.py @@ -40,6 +40,7 @@ ] MIDDLEWARE = [ + #'contrast.agent.middlewares.django_middleware.DjangoMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware',