Skip to content

Merge pull request #58 from Terre8055/anotherdevelop #70

Merge pull request #58 from Terre8055/anotherdevelop

Merge pull request #58 from Terre8055/anotherdevelop #70

Workflow file for this run

name: AWS Trivy Scan
on:
push:
branches:
- develop
permissions:
id-token: write
contents: read
jobs:
scan:
name: AWS Scan
runs-on: ubuntu-20.04
steps:
- name: Send Slack Message - Generating Report
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
run: |
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"Generating Trivy Report :robot_face:\"}" ${{ secrets.SLACK_WEBHOOK}}
- name: Checkout code
uses: actions/checkout@v3
- name: Set up date environment variable
run: echo "TIMESTAMP=$(date +%Y%m%d)" >> $GITHUB_ENV
- name: Install Trivy
run: |
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.52.1
sudo apt-get update && sudo apt-get install -y jq
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1.7.0
with:
role-to-assume: arn:aws:iam::590183661216:role/GitHubAction-AssumeRoleWithAction
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: us-east-1
- name: Run Trivy vulnerability scanner
run: |
TRIVY_OUTPUT=trivy_report_${{env.TIMESTAMP}}.json
trivy aws --region us-east-1 --format json --output ${TRIVY_OUTPUT} --severity MEDIUM
ls -l ${TRIVY_OUTPUT}
- name: Upload Trivy report to S3
run: |
TRIVY_OUTPUT=trivy_report_${{env.TIMESTAMP}}.json
aws s3 cp ${TRIVY_OUTPUT} s3://github-actions-s3-v1/trivy_reports/${TRIVY_OUTPUT}
- name: Run Trivy and save report
id: run_trivy
run: |
trivy aws --region us-east-1 --format table > trivy_report.txt
echo "TRIVY_REPORT_PATH=trivy_report${{env.TIMESTAMP}}.txt" >> $GITHUB_ENV
- name: Slack Notification
run: |
pip3 install slack_sdk
python3 slackmessenger.py
- name: Cleanup
if: always()
run: |
TIMESTAMP=$(date +%Y%m%d)
TRIVY_OUTPUT=trivy_report_${TIMESTAMP}.json
rm -f ${TRIVY_OUTPUT} file.txt