Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
b125c2c
Pillow runs on the latest version.
kiiru4reals Feb 10, 2024
ced8d33
Added 0.0.0.0 and localhost to allowed hosts
kiiru4reals Feb 10, 2024
61f2ac8
first commit
kiiru4reals Feb 10, 2024
05d9b72
first commit
kiiru4reals Feb 10, 2024
f7a30b6
Merge pull request #1 from kiiru4reals/docker-implementation
kiiru4reals Feb 10, 2024
c1edd16
CircleCI Commit
kiiru4reals Feb 13, 2024
b95fb6e
Merge pull request #2 from kiiru4reals/circleci-project-setup
kiiru4reals Feb 13, 2024
c8347b8
Implemented circleci build
kiiru4reals Feb 13, 2024
fbd0f7c
Amended python version
kiiru4reals Feb 13, 2024
2b2cce5
Redid build step
kiiru4reals Feb 13, 2024
a2de54d
Updated python version
kiiru4reals Feb 13, 2024
73b38ae
Changed to pyhon 3.11
kiiru4reals Feb 13, 2024
5a4cc8a
revert to python 3.6
kiiru4reals Feb 13, 2024
072f6ea
Added snyk security workflow
kiiru4reals Feb 14, 2024
e02f0c7
Removed hyphen on uses on line 37
kiiru4reals Feb 14, 2024
0c85e0b
Fixed indentation issue
kiiru4reals Feb 14, 2024
15757a4
Added hyphen on uses line 37
kiiru4reals Feb 14, 2024
d1cffcd
Added uses on line 36
kiiru4reals Feb 14, 2024
5205d4d
Added true statement on the Snyk code test
kiiru4reals Feb 14, 2024
26ec2ca
Authenticate with snyk
kiiru4reals Feb 14, 2024
758d090
fixed indentation issue
kiiru4reals Feb 14, 2024
0032882
Added debug flag to see issues on open source monitoring.
kiiru4reals Feb 14, 2024
702f4ca
get python dependencies
kiiru4reals Feb 14, 2024
45104f6
remove debug flag on open source monitor
kiiru4reals Feb 14, 2024
fff3d90
Removed IaC implementation
kiiru4reals Feb 14, 2024
6d120c9
Changed image name
kiiru4reals Feb 14, 2024
6c20417
Changed container name
kiiru4reals Feb 14, 2024
a9bff2f
Merge pull request #4 from kiiru4reals/snyk-security-implementation
kiiru4reals Apr 6, 2024
5b7f876
Merge pull request #3 from kiiru4reals/circleci-build
kiiru4reals Apr 6, 2024
1c5c27f
Docker image scan using Docker scout
kiiru4reals May 4, 2024
ed5ed67
removed snyk container step
kiiru4reals May 4, 2024
51c7547
provide recommendations to fix vulnerabilities
kiiru4reals May 4, 2024
dd0fe23
fix typo for recommendations
kiiru4reals May 4, 2024
46545c2
Update recommendations
kiiru4reals May 4, 2024
ac78e41
removed image name
kiiru4reals May 4, 2024
12d1b11
changed spelling for recommendations
kiiru4reals May 4, 2024
9216c4b
Changed base image from 3.11.4 to 3.11.8 slim
kiiru4reals May 4, 2024
d6968f1
Merge pull request #7 from kiiru4reals/update-docker-version
kiiru4reals May 4, 2024
aa1d188
change docker image to 3.12.2 from 3.11.8 slim
kiiru4reals May 4, 2024
b3b2590
Merge pull request #8 from kiiru4reals/update-docker-version
kiiru4reals May 4, 2024
656f095
Merge pull request #6 from kiiru4reals/migrate-from-snyk-container-to…
kiiru4reals May 4, 2024
4dedc3f
Changed image version from 3.12.2-slim to 3.12-slim-bookworm
kiiru4reals May 4, 2024
1fa4614
Merge pull request #9 from kiiru4reals/security-update-change-docker-…
kiiru4reals May 4, 2024
ceea830
Add workflow for OWASP ZAP baseline scan
kiiru4reals May 4, 2024
b7647c5
removed --rm flag
kiiru4reals May 4, 2024
0f41378
removed --rm flag
kiiru4reals May 4, 2024
f19f1d2
Merge pull request #10 from kiiru4reals/setup-dast-baseline-scan
kiiru4reals May 4, 2024
37ff9d1
first commit
kiiru4reals May 4, 2024
5126adf
Merge pull request #12 from kiiru4reals/build-and-push-to-docker-hub
kiiru4reals May 4, 2024
fa2b36b
GCP infrastructure setup
kiiru4reals May 11, 2024
4900c68
Refactored code to make trigger to make it look nice.
kiiru4reals May 11, 2024
e3ff523
Changed terraform directory
kiiru4reals May 11, 2024
baf431c
refactor shell script location
kiiru4reals May 11, 2024
b75f4d7
Merge pull request #13 from kiiru4reals/deploy-to-cloud-run
kiiru4reals May 11, 2024
e26e053
updated config to match master configs
kiiru4reals May 11, 2024
648ee78
Merge pull request #14 from kiiru4reals/update-chatroom-setup
kiiru4reals May 11, 2024
c9eec81
Added chatroom.kiirumaina.com to allowed hosts
kiiru4reals May 11, 2024
1c1f1a2
Merge pull request #15 from kiiru4reals/add-chatroom-to-allowed-hosts
kiiru4reals May 11, 2024
ec41088
Add git-leaks pre-commit hook
kiiru4reals Dec 26, 2024
0114d7a
Add venv to gitignore
kiiru4reals Dec 26, 2024
89fc392
Merge pull request #16 from kiiru4reals:setup-pre-commit-hooks
kiiru4reals Dec 26, 2024
6dc353b
Get commit SHA and pin artifact
kiiru4reals Mar 14, 2025
2652b96
Merge pull request #18 from kiiru4reals:implement-artifact-pinning
kiiru4reals Mar 14, 2025
86b90ea
Add tags attribute twice
kiiru4reals Mar 14, 2025
557552c
Merge pull request #19 from kiiru4reals:implement-artifact-pinning
kiiru4reals Mar 14, 2025
95e084d
Removing extra tag attribute and made it a list on the first tag attr…
kiiru4reals Mar 14, 2025
579989a
Merge pull request #20 from kiiru4reals:implement-artifact-pinning
kiiru4reals Mar 14, 2025
16e6774
Generate SBOM on Docker security scan
kiiru4reals Mar 14, 2025
1b0ac8c
Add buildx for caching
kiiru4reals Mar 14, 2025
659bcf0
Added context and Dockerfile
kiiru4reals Mar 14, 2025
530a63e
Added tag
kiiru4reals Mar 14, 2025
e31231b
Made image name to be a tag
kiiru4reals Mar 14, 2025
ab3477b
Remove checkout action as it is redundant.
kiiru4reals Mar 14, 2025
397c298
Undo checkout repo
kiiru4reals Mar 14, 2025
94a56bd
Change how image is labelled to reference Docker documentation
kiiru4reals Mar 14, 2025
cb455b5
Add image name
kiiru4reals Mar 14, 2025
f7f0fda
fix image name on CVE step
kiiru4reals Mar 14, 2025
dac8f21
Build docker image twice to use scout
kiiru4reals Mar 14, 2025
1471071
Merge pull request #21 from kiiru4reals:add-sbom-to-build-and-pr
kiiru4reals Mar 14, 2025
29062bc
Made SBOM to be only production for efficiency
kiiru4reals Mar 14, 2025
2aa3a99
Merge pull request #22 from kiiru4reals:limit-sbom-to-production-buil…
kiiru4reals Mar 14, 2025
05cad49
bumped asgiref from 3.4.1 to 3.6.0, django from 3.2.7 to>=4.2 ,<5.0 …
kiiru4reals Aug 23, 2025
6a95e6d
capitalized AS for conformance
kiiru4reals Aug 23, 2025
c11ae15
Added traefik labels and network
kiiru4reals Aug 23, 2025
e3b4c16
updated .dockerignore
kiiru4reals Aug 23, 2025
4a3f98d
Remove duplicate port entry and added entrypoint
kiiru4reals Aug 24, 2025
aa14d3f
Added test domain for local environment
kiiru4reals Aug 24, 2025
cc5cd01
Added running with Docker.
kiiru4reals Aug 24, 2025
ee206c4
Merge pull request #23 from kiiru4reals:add-traefik-as-a-load-balancer
kiiru4reals Aug 24, 2025
55b1f09
Enforce https on docker container
kiiru4reals Aug 27, 2025
da830a8
updated domain name for local environment
kiiru4reals Aug 27, 2025
33e7c5b
Merge pull request #25 from kiiru4reals:updated-docker-to-accept-only…
kiiru4reals Aug 27, 2025
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
21 changes: 21 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2
jobs:
build:
docker:
- image: circleci/python:3.6
steps:
- checkout
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
- run:
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- "venv"
- store_artifacts:
path: test-reports/
destination: python_app
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/go/build-context-dockerignore/

**/.DS_Store
**/__pycache__
**/.venv
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose.y*ml
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
37 changes: 37 additions & 0 deletions .github/workflows/build-and-push-to-docker-hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Build and push image to Docker Hub

on:
push:
branches:
- master

jobs:
build-and-push-image-to-docker-hub:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Buildx
uses: docker/setup-buildx-action@v3

- name: Authenticate to Docker Hub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PAT }}

- name: Get commit SHA # This retrieves a shortened version of the commit SHA and stores is as an environment variable
run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Build and push image to Docker hub
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
sbom: true # Enable SBOM
push: true
tags: | # Second tag makes it easy to pull the image to deployment environment
${{ secrets.DOCKER_USERNAME }}/chat-room:${{env.COMMIT_SHA}}
${{secrets.DOCKER_USERNAME}}/chat-room:latest
38 changes: 38 additions & 0 deletions .github/workflows/container-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Docker scout CVE scan

on:
pull_request:
branches:
- master

jobs:
scan-docker-image-for-vulnerabilities:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Buildx
uses: docker/setup-buildx-action@v3

- name: Authenticate to Docker hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PAT }}

- name: Build image (Dirty way to do scout)
run: docker build -t chat-room .

- name: Check for CVEs on Docker scout
uses: docker/scout-action@v1
with:
command: cves
image: chat-room:latest
ignore-unchanged: true
only-severities: critical,high

- name: Provide recommendations
uses: docker/scout-action@v1
with:
command: recommendations
4 changes: 4 additions & 0 deletions .github/workflows/shell_scripts/decrypt_service_account.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
file_name=${GITHUB_WORKSPACE}/terraform/key.json.gpg

gpg --quiet --batch --yes --decrypt --passphrase="$GCP_SERVICE_ACCOUNT_PASSPHRASE" --output ${GITHUB_WORKSPACE}/terraform/key.json $file_name
80 changes: 80 additions & 0 deletions .github/workflows/snyk-security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# A sample workflow which sets up Snyk to analyze the full Snyk platform (Snyk Open Source, Snyk Code,
# Snyk Container and Snyk Infrastructure as Code)
# The setup installs the Snyk CLI - for more details on the possible commands
# check https://docs.snyk.io/snyk-cli/cli-reference
# The results of Snyk Code are then uploaded to GitHub Security Code Scanning
#
# In order to use the Snyk Action you will need to have a Snyk API token.
# More details in https://github.com/snyk/actions#getting-your-snyk-token
# or you can signup for free at https://snyk.io/login
#
# For more examples, including how to limit scans to only high-severity issues
# and fail PR checks, see https://github.com/snyk/actions/

name: Snyk Security

on:
pull_request:
branches: ["master"]

permissions:
contents: read

jobs:
snyk:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Snyk CLI to check for security issues
# Snyk can be used to break the build when it detects security issues.
# In this case we want to upload the SAST issues to GitHub Code Scanning
uses: snyk/actions/setup@806182742461562b67788a64410098c9d9b96adb

# For Snyk Open Source, you must first set up the development environment for your application's dependencies
# For example for Node
#- uses: actions/setup-node@v3
# with:
# node-version: 16
- uses: actions/setup-python@v2
with:
python-version: 3.11



env:
# This is where you will need to introduce the Snyk API token created with your Snyk account
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
- name: Authenticate with Snyk
run: snyk auth ${{ secrets.SNYK_TOKEN }}

# Runs Snyk Code (SAST) analysis and uploads result into GitHub.
# Use || true to not fail the pipeline
- name: Snyk Code test
run: snyk code test --sarif > snyk-code.sarif || true

- name: Get python dependencies
run: pip install -r requirements.txt

# Runs Snyk Open Source (SCA) analysis and uploads result to Snyk.
- name: Snyk Open Source monitor
run: snyk monitor --all-projects

# Runs Snyk Infrastructure as Code (IaC) analysis and uploads result to Snyk.
# Use || true to not fail the pipeline.
# - name: Snyk IaC test and report
# run: snyk iac test --report || true

# Push the Snyk Code results into GitHub Code Scanning tab
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: snyk-code.sarif
47 changes: 47 additions & 0 deletions .github/workflows/test-gcp-infra-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: GCP tests

on:
pull_request:
branches:
- master

jobs:
run-gcp-tests:
runs-on: ubuntu-latest


steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.7.5

- name: Initialize Terraform
env:
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
run: terraform -chdir=${GITHUB_WORKSPACE}/terraform init -backend-config="access_key=$AWS_ACCESS_KEY" -backend-config="secret_key=$AWS_SECRET_KEY"

- name: Check formatting
run: terraform -chdir=${GITHUB_WORKSPACE}/terraform fmt -check

- name: Check for bugs
run: terraform -chdir=${GITHUB_WORKSPACE}/terraform validate

- name: Decrypt service account key
env:
GCP_SERVICE_ACCOUNT_PASSPHRASE: ${{ secrets.GCP_SERVICE_ACCOUNT_PASSPHRASE }}
run: |
chmod +x ${GITHUB_WORKSPACE}/.github/workflows/shell_scripts/decrypt_service_account.sh
bash ${GITHUB_WORKSPACE}/.github/workflows/shell_scripts/decrypt_service_account.sh

- name: Does your configuration make sense?
env:
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
run: |
terraform -chdir=${GITHUB_WORKSPACE}/terraform plan \
-var path_to_gcp_service_account="${GITHUB_WORKSPACE}/terraform/key.json" \
-var project_id=$GCP_PROJECT_ID
24 changes: 24 additions & 0 deletions .github/workflows/zap-baseline-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Perform ZAP baseline scan (Dynamic Application Security Testing)

on:
pull_request:
branches: ["master"]
jobs:
perform-baseline-scan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Build docker image
run: docker build -t chat-room:latest .

- name: Run docker image
run: docker run -dp 8000:8000 chat-room:latest

- name: Set up OWASP ZAP baseline scan
uses: zaproxy/[email protected]
with:
target: 'http://localhost:8000'


1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
chat-room-env/
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.22.0
hooks:
- id: gitleaks
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# syntax=docker/dockerfile:1

# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/go/dockerfile-reference/

ARG PYTHON_VERSION=3.12
FROM python:${PYTHON_VERSION}-slim-bookworm AS base

# Prevents Python from writing pyc files.
ENV PYTHONDONTWRITEBYTECODE=1

# Keeps Python from buffering stdout and stderr to avoid situations where
# the application crashes without emitting any logs due to buffering.
ENV PYTHONUNBUFFERED=1

WORKDIR /app

# Create a non-privileged user that the app will run under.
# See https://docs.docker.com/go/dockerfile-user-best-practices/
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/nonexistent" \
--shell "/sbin/nologin" \
--no-create-home \
--uid "${UID}" \
appuser

# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
# Leverage a bind mount to requirements.txt to avoid having to copy them into
# into this layer.
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=bind,source=requirements.txt,target=requirements.txt \
python -m pip install -r requirements.txt

# Switch to the non-privileged user to run the application.
USER appuser

# Copy the source code into the container.
COPY . .

# Expose the port that the application listens on.
EXPOSE 8001

# Run the application.
CMD python manage.py runserver 0.0.0.0:8000
22 changes: 22 additions & 0 deletions README.Docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Building and running your application

When you're ready, start your application by running:
`docker compose up --build`.

Your application will be available at http://localhost:8000.

### Deploying your application to the cloud

First, build your image, e.g.: `docker build -t myapp .`.
If your cloud uses a different CPU architecture than your development
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
you'll want to build the image for that platform, e.g.:
`docker build --platform=linux/amd64 -t myapp .`.

Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.

Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
docs for more detail on building and pushing.

### References
* [Docker's Python guide](https://docs.docker.com/language/python/)
Loading