-
Notifications
You must be signed in to change notification settings - Fork 11
144 lines (131 loc) · 4.01 KB
/
Copy pathdevsecops.yml
File metadata and controls
144 lines (131 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: Build and Test Java App with Security Scans
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
name: Build and Test Java Application
environment: Staging
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: |
mvn -B verify sonar:sonar \
-Dsonar.projectKey=samplejavaapp \
-Dsonar.organization=samplejavaapp \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=$SONAR_TOKEN
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# TruffleHog-Secret-Scan:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - name: TruffleHog
# uses: trufflesecurity/trufflehog@main
# with:
# path: ./
# base: development # ${{ github.event.repository.default_branch }}
# head: HEAD
# extra_args: --debug #--only-verified
dependency-check:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install npm dependencies
run: npm install
- name: Depcheck
uses: dependency-check/Dependency-Check_Action@main
id: Depcheck
with:
project: '${{ github.event.repository.name }}_${{ github.ref_name }}'
path: '.'
format: 'HTML'
out: 'reports'
args: >
--failOnCVSS 7
--enableRetired
- name: Upload Test results
uses: actions/upload-artifact@master
with:
name: Depcheck report
path: ${{github.workspace}}/reports
- name: Upload Test results
if: always()
uses: actions/upload-artifact@master
with:
name: Depcheck_Report_${{ github.event.repository.name }}_${{ github.ref_name }}
path: ${{github.workspace}}/reports
approval:
needs: dependency-check
runs-on: ubuntu-latest
environment: dependency-review # This is the environment that requires approval
steps:
- name: Wait for Approval
run: echo "This job waits for approval in the 'dependency-review' environment."
# security:
# runs-on: ubuntu-latest
# needs: build
# name: Security Scan and Analysis
# environment: Staging
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Run Snyk to check for vulnerabilities
# uses: snyk/actions/maven@master
# continue-on-error: true
# env:
# SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
Docker:
needs: approval
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Build
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: learndevops083/myjava-app:${{ github.sha }}
Trivy:
runs-on: ubuntu-latest
needs: Docker
steps:
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'learndevops083/myjava-app:${{ github.sha }}'
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'