mirror of
https://github.com/SpecterOps/Nemesis
synced 2026-06-08 12:36:42 +00:00
Added GitHub action for NoseyParker
-Added GitHub action for NoseyParker
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
name: Build and Publish the noseyparker-scanner Docker Image
|
||||
|
||||
on:
|
||||
workflow_dispatch: # For manual triggering
|
||||
# push:
|
||||
# branches: [ "main" ]
|
||||
# # Trigger on changes to noseyparker-scanner files
|
||||
# paths:
|
||||
# - 'projects/noseyparker_scanner/**'
|
||||
# - '.github/workflows/noseyparker-scanner-build.yml'
|
||||
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_PREFIX: "specterops/nemesis" # ${{ github.repository }} causes issues as SpecterOps is not all lowercase
|
||||
PLATFORMS: linux/amd64,linux/arm64 # Added platforms (arm64 for Mac M1/M2/M3 and AWS images)
|
||||
|
||||
jobs:
|
||||
build-noseyparker-scanner:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
strategy:
|
||||
matrix:
|
||||
service:
|
||||
- name: noseyparker-scanner
|
||||
context: .
|
||||
dockerfile: ./projects/noseyparker_scanner/Dockerfile.nemesis
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
# Cache Rust dependencies before Docker build
|
||||
- name: Cache Rust dependencies
|
||||
uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
prefix-key: 'noseyparker-scanner'
|
||||
workdir: ./projects/noseyparker_scanner
|
||||
cache-on-failure: true
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata for ${{ matrix.service.name }} image
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ matrix.service.name }}
|
||||
tags: |
|
||||
type=sha,format=short
|
||||
type=ref,event=branch
|
||||
type=ref,event=pr
|
||||
type=raw,value=latest,enable={{is_default_branch}}
|
||||
type=raw,value=cache
|
||||
|
||||
- name: Build and push ${{ matrix.service.name }} image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: ${{ matrix.service.context }}
|
||||
file: ${{ matrix.service.dockerfile }}
|
||||
push: true
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
build-args: |
|
||||
BUILDKIT_INLINE_CACHE=1
|
||||
CARGO_INCREMENTAL=0
|
||||
CARGO_TERM_COLOR=always
|
||||
RUST_BACKTRACE=1
|
||||
# Enhanced multi-layer caching strategy
|
||||
cache-from: |
|
||||
type=gha,scope=noseyparker-scanner-${{ github.ref_name }}
|
||||
type=gha,scope=noseyparker-scanner-main
|
||||
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/noseyparker-scanner:cache
|
||||
cache-to: |
|
||||
type=gha,mode=max,scope=noseyparker-scanner-${{ github.ref_name }}
|
||||
type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/noseyparker-scanner:cache,mode=max
|
||||
|
||||
- name: Test built image
|
||||
run: |
|
||||
# Test that the image runs and shows version
|
||||
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/noseyparker-scanner:${{ steps.meta.outputs.version }} --help || true
|
||||
|
||||
# Optional: Security scan with Trivy
|
||||
- name: Run Trivy vulnerability scanner
|
||||
uses: aquasecurity/trivy-action@master
|
||||
with:
|
||||
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/noseyparker-scanner:${{ steps.meta.outputs.version }}
|
||||
format: 'sarif'
|
||||
output: 'trivy-results.sarif'
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload Trivy scan results to GitHub Security tab
|
||||
uses: github/codeql-action/upload-sarif@v3
|
||||
if: always()
|
||||
with:
|
||||
sarif_file: 'trivy-results.sarif'
|
||||
continue-on-error: true
|
||||
|
||||
# Clean up cache on successful build to prevent cache bloat
|
||||
- name: Cleanup old cache entries
|
||||
if: success()
|
||||
run: |
|
||||
# Clean up old GitHub Actions cache entries for this scope
|
||||
gh extension install actions/gh-actions-cache || true
|
||||
gh actions-cache delete "noseyparker-scanner-${{ github.ref_name }}-*" --confirm || true
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
continue-on-error: true
|
||||
Reference in New Issue
Block a user