Skip to content

Security Scan by @sbaerlocher #70

Security Scan by @sbaerlocher

Security Scan by @sbaerlocher #70

---
name: Nightly Security Scan
run-name: |
Security Scan by @${{ github.actor }}
on:
schedule:
- cron: "0 2 * * *" # Daily 02:00 UTC (public repo — Actions minutes are free)
workflow_dispatch:
permissions:
contents: read
security-events: write
actions: read
pull-requests: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: action-playbook-test
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
codeql:
needs: prepare
uses: arillso/.github/.github/workflows/security-code.yml@2026-08-17
with:
languages: '["go"]'
go-version: ${{ needs.prepare.outputs.go_version }}
prepare:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
ansible_version: ${{ steps.get_version.outputs.version }}
go_version: ${{ steps.get_version.outputs.go }}
cache_key: ${{ steps.cache_key.outputs.key }}
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Extract versions
id: get_version
run: |
GO_VERSION=$(grep '^go ' go.mod | cut -d' ' -f2)
ANSIBLE_VERSION=$(grep 'FROM arillso/ansible:' Dockerfile | cut -d':' -f2 | cut -d'@' -f1)
echo "version=${ANSIBLE_VERSION}" >> "$GITHUB_OUTPUT"
echo "go=${GO_VERSION}" >> "$GITHUB_OUTPUT"
- name: Generate cache key
id: cache_key
run: |
echo "key=comprehensive-test-${{ hashFiles('Dockerfile', 'go.mod', 'go.sum', 'main.go') }}" >> "$GITHUB_OUTPUT"
build-test-image:
runs-on: ubuntu-latest
needs: prepare
timeout-minutes: 15
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
- name: Build test image
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
push: false
load: true
tags: ${{ env.IMAGE_NAME }}:test
cache-from: type=gha,scope=${{ needs.prepare.outputs.cache_key }}
cache-to: type=gha,mode=max,scope=${{ needs.prepare.outputs.cache_key }}
security-test:
runs-on: ubuntu-latest
needs: [prepare, build-test-image]
timeout-minutes: 20
steps:
- name: Checkout Code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
- name: Build test image for security scan
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
push: false
load: true
tags: ${{ env.IMAGE_NAME }}:test
cache-from: type=gha,scope=${{ needs.prepare.outputs.cache_key }}
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: ${{ env.IMAGE_NAME }}:test
format: sarif
output: trivy-results.sarif
severity: CRITICAL,HIGH
continue-on-error: true
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4
if: always() && hashFiles('trivy-results.sarif') != ''
with:
sarif_file: trivy-results.sarif
- name: Test action functionality
run: |
mkdir -p test-results
echo "Testing action binary functionality"
docker run --rm ${{ env.IMAGE_NAME }}:test --help | tee test-results/help-output.log
echo "Testing action with invalid parameters"
docker run --rm ${{ env.IMAGE_NAME }}:test \
--playbook /dev/null --inventory /dev/null || echo "Expected failure with invalid parameters"
- name: Upload security test results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
if: always()
with:
name: security-test-results
path: test-results/
retention-days: 30