Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(impl):[TRI-1569] container scan last image in docker hub #488

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/trivy-docker-hub-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: "Trivy vulnerability scanner for Docker Hub Image"
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

Check notice

Code scanning / KICS

IAM Access Analyzer Not Enabled

'AWS::AccessAnalyzer::Analyzer' is undefined

on:
push:
branches: [ "main" ]
schedule:
- cron: "0 0 * * *"

workflow_dispatch:
inputs:
branch:
description: "Branch to use"
required: true
default: "main"
type: string

env:
IMAGE_NAMESPACE: 'tractusx'
IMAGE_NAME: "irs-api"

jobs:
image-scan:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Cache maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build with Maven
run: |
mvn -B clean install

# Build action for docker hub registry
- name: Build image from Dockerfile - Docker Hub
if: ${{ github.repository == 'eclipse-tractusx/item-relationship-service' }}
run: |
docker build -t ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:latest .

# Build action for docker hub registry
- name: Run Trivy vulnerability scanner - Docker Hub
if: ${{ github.repository == 'eclipse-tractusx/item-relationship-service' }}
uses: aquasecurity/trivy-action@master
with:
image-ref: "${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}"
format: "sarif"
output: "trivy-results-irs.sarif"
exit-code: "1"
hide-progress: false
severity: "CRITICAL,HIGH"

- name: Upload Trivy scan results to GitHub Security tab
if: always()
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results-irs.sarif"