Repository navigation
Merge pull request #22 from mathiscapart/improve-attack-many-service #48
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 | |
| # Valide que les 3 secrets d'enrichissement sont montes et fonctionnels | |
| # (GeoIP via license MaxMind, 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: Bases GeoLite2 (City + ASN) | |
| env: | |
| MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }} | |
| run: | | |
| mkdir -p data/geoip | |
| for ed in GeoLite2-City GeoLite2-ASN; do | |
| tmp=$(mktemp -d) | |
| curl -sSL "https://download.maxmind.com/app/geoip_download?edition_id=$ed&license_key=${MAXMIND_LICENSE_KEY}&suffix=tar.gz" -o "$tmp/$ed.tar.gz" | |
| tar -xzf "$tmp/$ed.tar.gz" -C "$tmp" | |
| find "$tmp" -name "$ed.mmdb" -exec mv {} "data/geoip/$ed.mmdb" \; | |
| done | |
| - name: Enrichissement live (valide les 3 secrets) | |
| env: | |
| ABUSEIPDB_API_KEY: ${{ secrets.ABUSEIPDB_API_KEY }} | |
| GREYNOISE_API_KEY: ${{ secrets.GREYNOISE_API_KEY }} | |
| GEOIP_CITY_DB: data/geoip/GeoLite2-City.mmdb | |
| GEOIP_ASN_DB: data/geoip/GeoLite2-ASN.mmdb | |
| run: | | |
| python - <<'PY' | |
| import json | |
| from analyzer.enrichers.geoip import GeoIPEnricher | |
| from analyzer.enrichers.abuseipdb import AbuseIPDBEnricher | |
| from analyzer.enrichers.greynoise import GreyNoiseEnricher | |
| ip = "71.6.199.23" # scanner Shodan : exerce les 3 enrichers | |
| geo = GeoIPEnricher().enrich(ip) | |
| abuse = AbuseIPDBEnricher().enrich(ip) | |
| gn = GreyNoiseEnricher().enrich(ip) | |
| print(json.dumps({"geoip": geo, "abuse": abuse, "greynoise": gn}, indent=2)) | |
| assert geo["country_code"], "GeoIP vide (MAXMIND_LICENSE_KEY ?)" | |
| assert abuse["abuse_score"] > 0, "AbuseIPDB=0 (ABUSEIPDB_API_KEY ?)" | |
| assert gn["greynoise_classification"] not in ("", "unknown"), "GreyNoise vide (GREYNOISE_API_KEY ?)" | |
| print("OK: 3 enrichers alimentes par les secrets") | |
| PY | |
| build: | |
| needs: lint | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - image: honeypot-ftp | |
| context: ./honeypots/ftp | |
| - image: honeypot-http | |
| context: ./honeypots/http | |
| - 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 }} | |
| build-args: ${{ matrix.image == 'honeypot-analyzer' && format('MAXMIND_LICENSE_KEY={0}', secrets.MAXMIND_LICENSE_KEY) || '' }} | |
| 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" |