Repository navigation
docs: README — reverse-proxy Apache devant le honeypot HTTP (archi + … #69
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - prod | |
| - preprod | |
| - staging | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Lint Python code | |
| uses: astral-sh/ruff-action@v3 | |
| - name: Lint Dockerfiles | |
| uses: hadolint/hadolint-action@v3.3.0 | |
| with: | |
| recursive: true | |
| - name: Bandit | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - run: pip install bandit | |
| - run: bandit -r honeypots/ pipeline/ dashboard/ -ll -ii | |
| # Tests unitaires PAR COMPOSANT. Les honeypots embarquent des modules à plat | |
| # (config.py, events.py, server.py, detection.py) avec des noms IDENTIQUES | |
| # entre ssh et ftp : les lancer dans le même process pytest provoque des | |
| # collisions de modules top-level. On exécute donc chaque suite isolément, | |
| # dans son propre dossier — exactement comme l'image Docker les importe | |
| # (WORKDIR /app, `python server.py`). L'attacker tourne depuis la racine | |
| # (son module local `logging.py` masquerait la stdlib autrement). | |
| test: | |
| needs: lint | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - name: honeypot-ssh | |
| dir: honeypots/ssh | |
| target: tests/ | |
| - name: honeypot-ftp | |
| dir: honeypots/ftp | |
| target: tests/ | |
| - name: honeypot-http | |
| dir: honeypots/http | |
| target: tests/ | |
| - name: analyzer | |
| dir: analyzer | |
| target: tests/ | |
| - name: attacker | |
| dir: . | |
| target: attacker/tests/ | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install test deps (${{ matrix.name }}) | |
| working-directory: ${{ matrix.dir }} | |
| run: | | |
| python -m pip install --upgrade pip | |
| if [ -f requirements-dev.txt ]; then | |
| pip install -r requirements-dev.txt | |
| else | |
| pip install pytest | |
| fi | |
| - name: pytest (${{ matrix.name }}) | |
| working-directory: ${{ matrix.dir }} | |
| # `python -m pytest` met le cwd sur sys.path => imports à plat OK, | |
| # comme en conteneur. Pas de pytest.ini racine (collecte globale = collisions). | |
| run: python -m pytest ${{ matrix.target }} -q | |
| # Valide que les secrets d'enrichissement sont montes et fonctionnels | |
| # (AbuseIPDB, GreyNoise) sans monter la stack. | |
| enrich: | |
| needs: lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - run: pip install -r analyzer/requirements.txt | |
| - name: Enrichissement live (valide les secrets) | |
| env: | |
| ABUSEIPDB_API_KEY: ${{ secrets.ABUSEIPDB_API_KEY }} | |
| GREYNOISE_API_KEY: ${{ secrets.GREYNOISE_API_KEY }} | |
| run: | | |
| python - <<'PY' | |
| import json | |
| from analyzer.enrichers.abuseipdb import AbuseIPDBEnricher | |
| from analyzer.enrichers.greynoise import GreyNoiseEnricher | |
| ip = "71.6.199.23" # scanner Shodan : exerce les 2 enrichers | |
| abuse = AbuseIPDBEnricher().enrich(ip) | |
| gn = GreyNoiseEnricher().enrich(ip) | |
| print(json.dumps({"abuse": abuse, "greynoise": gn}, indent=2)) | |
| assert abuse["abuse_score"] > 0, "AbuseIPDB=0 (ABUSEIPDB_API_KEY ?)" | |
| assert gn["greynoise_classification"] not in ("", "unknown"), "GreyNoise vide (GREYNOISE_API_KEY ?)" | |
| print("OK: 2 enrichers alimentes par les secrets") | |
| PY | |
| build: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - image: honeypot-ftp | |
| context: ./honeypots/ftp | |
| - image: honeypot-http | |
| context: ./honeypots/http | |
| - image: honeypot-proxy | |
| context: ./honeypots/proxy | |
| - image: honeypot-ssh | |
| context: ./honeypots/ssh | |
| - image: honeybot | |
| context: ./attacker | |
| - image: honeypot-analyzer | |
| context: . | |
| dockerfile: analyzer/Dockerfile | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Docker meta | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: | | |
| qualite863/${{ matrix.image }} | |
| tags: | | |
| type=ref,event=branch | |
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/prod' || github.ref == 'refs/heads/main' }} | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=sha | |
| - name: Login Docker | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Set up Buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Build and push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: ${{ matrix.context }} | |
| file: ${{ matrix.dockerfile || format('{0}/Dockerfile', matrix.context) }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha,scope=${{ matrix.image }} | |
| cache-to: type=gha,mode=max,scope=${{ matrix.image }} | |
| scan: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - image: honeypot-ftp | |
| - image: honeypot-http | |
| - image: honeypot-ssh | |
| - image: honeybot | |
| - image: honeypot-analyzer | |
| steps: | |
| # Login requis : honeypot-analyzer est un repo Docker Hub privé. | |
| - name: Login Docker | |
| uses: docker/login-action@v4 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: "qualite863/${{ matrix.image }}:latest" | |
| format: "table" | |
| exit-code: 1 | |
| ignore-unfixed: true | |
| severity: "CRITICAL,HIGH" | |
| release: | |
| needs: [test, scan] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/prod' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - name: Install semantic-release | |
| run: npm install -g semantic-release @semantic-release/changelog @semantic-release/git @semantic-release/exec | |
| - name: Debug environment | |
| run: | | |
| echo "Current branch: ${GITHUB_REF#refs/heads/}" | |
| echo "Repository: $GITHUB_REPOSITORY" | |
| cat .releaserc | |
| - name: Run semantic-release | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npx semantic-release || echo "Semantic release completed" |