From b2730233a1b59a4f9f9cce7486afb1d3d4fd4db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=AA=20Ph=C6=B0=C6=A1ng=20Hi=E1=BA=BFu?= Date: Sun, 26 May 2024 11:37:35 +0700 Subject: [PATCH] Add CI/CD workflow for Docker image builds --- .dockerignore | 106 +++++++++++++++++++++++++++++++++++ .github/pull.yml | 5 ++ .github/workflows/manual.yml | 89 +++++++++++++++++++++++++++++ Dockerfile | 5 ++ Dockerfile-alpine | 5 ++ Dockerfile-tor | 13 +++++ entrypoint.sh | 5 ++ 7 files changed, 228 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/pull.yml create mode 100644 .github/workflows/manual.yml create mode 100644 Dockerfile create mode 100644 Dockerfile-alpine create mode 100644 Dockerfile-tor create mode 100644 entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..8c07e0764be --- /dev/null +++ b/.dockerignore @@ -0,0 +1,106 @@ +# Python generated files +*.pyc +__pycache__/ +*.pyo +*.pyd + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile.json +.pyhistory +.ipython/IPythonHistory.sqlite + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, it is recommended to omit it: +# "This file can be locked to specific versions (including build numbers) of dependencies." +# The recommendation is to commit this file if and only if Pipfile.lock is intended to be ignored. +# .venv +# env/ +# venv/ +# ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/.github/pull.yml b/.github/pull.yml new file mode 100644 index 00000000000..56ce410f3ec --- /dev/null +++ b/.github/pull.yml @@ -0,0 +1,5 @@ +version: "1" +rules: + - base: master + upstream: sqlmapproject:master + mergeMethod: rebase diff --git a/.github/workflows/manual.yml b/.github/workflows/manual.yml new file mode 100644 index 00000000000..9228f8ea238 --- /dev/null +++ b/.github/workflows/manual.yml @@ -0,0 +1,89 @@ +name: CI to Docker hub + +on: + push: + branches: + - master + - 'upstream-master' + pull_request: + branches: + - 'upstream-master' + pull_request_review_comment: + types: [created, edited] + + +permissions: read-all + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: master + + - name: Checkout + uses: actions/checkout@v4 + with: + repository: 'sqlmapproject/sqlmap' + ref: master + path: 'sqlmap' + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Run shell + run: |- + ls -la; + pwd + cp Dockerfile ./sqlmap/ + cp Dockerfile-alpine ./sqlmap/ + cp Dockerfile-tor ./sqlmap/ + cp entrypoint.sh ./sqlmap/ + + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v6 + with: + context: ./sqlmap/ + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/sqlmap:latest + platforms: linux/amd64,linux/arm64 + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + - name: Build and push + id: docker_build_alpine + uses: docker/build-push-action@v6 + with: + context: ./sqlmap/ + file: ./Dockerfile-alpine + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/sqlmap:latest-alpine + platforms: linux/amd64,linux/arm64 + + - name: Image digest + run: echo ${{ steps.docker_build_alpine.outputs.digest }} + + - name: Build and push + id: docker_build_tor + uses: docker/build-push-action@v6 + with: + context: ./sqlmap/ + file: ./Dockerfile-tor + push: true + tags: ${{ secrets.DOCKER_HUB_USERNAME }}/sqlmap:latest-tor + + - name: Image digest + run: echo ${{ steps.docker_build_tor.outputs.digest }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..2a14a264a6e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM python:3 +COPY . sqlmap-dev +RUN apt update && apt install -y tor +ENTRYPOINT ["python","sqlmap-dev/sqlmap.py"] +CMD ["-h"] \ No newline at end of file diff --git a/Dockerfile-alpine b/Dockerfile-alpine new file mode 100644 index 00000000000..f0e7a5924dd --- /dev/null +++ b/Dockerfile-alpine @@ -0,0 +1,5 @@ +FROM python:3-alpine +COPY . sqlmap-dev +RUN apk update && apk add tor +ENTRYPOINT ["python3","sqlmap-dev/sqlmap.py"] +CMD ["-h"] diff --git a/Dockerfile-tor b/Dockerfile-tor new file mode 100644 index 00000000000..25d958e1c17 --- /dev/null +++ b/Dockerfile-tor @@ -0,0 +1,13 @@ +FROM python:3 +ARG DEBIAN_FRONTEND=noninteractive +COPY . /sqlmap-dev +RUN apt clean; apt update; apt install -y tor systemd; \ + # sed -i 's/#SocksPort.*/SocksPort 0.0.0.0:9050/g' /etc/tor/torrc; \ + sed -i 's/#CookieAuthentication 1/CookieAuthentication 0/g' /etc/tor/torrc; \ + sed -i 's/#CookieAuthFileGroupReadable 1/CookieAuthFileGroupReadable 0/g' /etc/tor/torrc; \ + sed -i 's/#RunAsDaemon 1/RunAsDaemon 1/g' /etc/tor/torrc; \ + /etc/init.d/tor restart + +WORKDIR /sqlmap-dev +ENTRYPOINT ["bash", "/sqlmap-dev/entrypoint.sh"] +CMD ["-h"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 00000000000..b0273cd795b --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/env bash + +/etc/init.d/tor start + +python ./sqlmap.py $@ \ No newline at end of file