Skip to content

Commit fd3c605

Browse files
committed
[Ramki] Update support for Dependency Track 4.0
Signed-off-by: Ramakrishnan Kandasamy <[email protected]>
1 parent 709565d commit fd3c605

File tree

4 files changed

+83
-54
lines changed

4 files changed

+83
-54
lines changed

DEPENDENCY_TRACK.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Installation Steps for Dependency Track
2+
3+
- Setup helm repo
4+
5+
```s
6+
helm repo add evryfs-oss https://evryfs.github.io/helm-charts/
7+
8+
helm repo update
9+
```
10+
11+
- Create a file with below contents - values.yaml
12+
13+
```yaml
14+
ingress:
15+
enabled: true
16+
tls:
17+
enabled: false
18+
secretName: ""
19+
annotations:
20+
kubernetes.io/ingress.class: nginx
21+
## allow large bom.xml uploads:
22+
nginx.ingress.kubernetes.io/proxy-body-size: 10m
23+
host: minikube.local
24+
```
25+
26+
- Install Dependendency Track helm chart with custom values.yaml
27+
28+
```s
29+
kubectl create ns dependency-track
30+
31+
helm upgrade dependency-track evryfs-oss/dependency-track --namespace dependency-track -f ./values.yaml
32+
```
33+
34+
- Run command `minikube ip`
35+
```s
36+
$ minikube ip
37+
192.168.64.40
38+
$
39+
```
40+
- Add a entry for in /etc/hosts file for the ip and ingress host name
41+
42+
```s
43+
sudo vi /etc/hosts
44+
#Add the below line
45+
192.168.64.40 minikube.local
46+
```
47+
48+
Note: Replace the ip with the actual minikube ip from above step.
49+
50+
- Access Dependency track with below name.
51+
52+
```s
53+
open http://minikube.local
54+
```
55+
56+
Note: The default password for dependency track is admin/admin

Jenkinsfile

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pipeline {
5555
post {
5656
always {
5757
archiveArtifacts allowEmptyArchive: true, artifacts: 'target/dependency-check-report.html', fingerprint: true, onlyIfSuccessful: true
58+
// dependencyCheckPublisher pattern: 'report.xml'
5859
}
5960
}
6061
}
@@ -91,7 +92,7 @@ pipeline {
9192
}
9293
post {
9394
success {
94-
dependencyTrackPublisher artifact: 'target/bom.xml', projectId: '9110e2e4-bc2e-47b7-9967-ade239b0edf5', synchronous: false
95+
dependencyTrackPublisher projectName: 'sample-spring-app', projectVersion: '0.0.1', artifact: 'target/bom.xml', autoCreateProjects: true, synchronous: true
9596
archiveArtifacts allowEmptyArchive: true, artifacts: 'target/bom.xml', fingerprint: true, onlyIfSuccessful: true
9697
}
9798
}
@@ -100,7 +101,7 @@ pipeline {
100101
}
101102
stage('Package') {
102103
steps {
103-
container('docker-cmds') {
104+
container('docker-tools') {
104105
sh 'ls -al'
105106
sh 'docker build . -t sample-app'
106107
}
@@ -110,30 +111,22 @@ pipeline {
110111
parallel {
111112
stage('Image Scan') {
112113
steps {
113-
container('docker-cmds') {
114-
sh '''#!/bin/sh
115-
apk add --update-cache --upgrade curl rpm
116-
export TRIVY_VERSION="0.8.0"
117-
echo $TRIVY_VERSION
118-
wget https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz
119-
tar zxvf trivy_${TRIVY_VERSION}_Linux-64bit.tar.gz
120-
mv trivy /usr/local/bin
121-
trivy --cache-dir /tmp/trivycache/ sample-app:latest
122-
'''
114+
container('docker-tools') {
115+
sh 'grype sample-app:latest'
123116
}
124117
}
125118
}
126119
stage('Image Hardening') {
127120
steps {
128-
container('dockle') {
121+
container('docker-tools') {
129122
sh 'dockle sample-app:latest'
130123
}
131124
}
132125
}
133126
stage('K8s Hardening') {
134127
steps {
135-
container('docker-cmds') {
136-
sh 'docker run -i kubesec/kubesec:512c5e0 scan /dev/stdin < pod.yaml'
128+
container('docker-tools') {
129+
sh 'kubesec scan pod.yaml'
137130
}
138131
}
139132
}
@@ -154,7 +147,7 @@ pipeline {
154147
}
155148
stage('DAST') {
156149
steps {
157-
container('docker-cmds') {
150+
container('docker-tools') {
158151
sh 'docker run -t owasp/zap2docker-stable zap-baseline.py -t https://www.zaproxy.org/ || exit 0'
159152
}
160153
}

README.md

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,33 @@ Sample spring application with Jenkins pipeline script to demonstrate secure pip
44

55
## Pre Requesites
66

7-
- minikube v1.13.0 - [Refer here for installation](https://kubernetes.io/docs/tasks/tools/install-minikube/)
8-
- helm v3.3.1 - [Refer here for installation](https://helm.sh/docs/intro/install/)
7+
- minikube v1.18.1 - [Refer here for installation](https://kubernetes.io/docs/tasks/tools/install-minikube/)
8+
- helm v3.5.3 - [Refer here for installation](https://helm.sh/docs/intro/install/)
99

1010
## Setup Setps
1111

1212
### Minikube setup
1313

1414
- Setup minikube
1515
```s
16-
minikube start --nodes=1 --cpus=4 --memory 8192 --disk-size=35g --embed-certs=true
16+
minikube start --nodes=1 --cpus=4 --memory 8192 --disk-size=35g --embed-certs=true --driver=hyperkit
1717
```
1818

1919
### Jenkins setup
2020

2121
- Stup Jenkins server
2222

2323
```s
24-
helm repo add jenkinsci https://charts.jenkins.io
24+
helm repo add jenkins https://charts.jenkins.io
2525
helm repo update
26-
helm install jenkins jenkinsci/jenkins
26+
helm install jenkins jenkins/jenkins
27+
```
28+
29+
- Wait for the jenkins pod to start
30+
- Get admin user password of Jenkins
31+
32+
```s
33+
kubectl exec --namespace default -it svc/jenkins -c jenkins -- /bin/cat /run/secrets/chart-admin-password && echo
2734
```
2835

2936
**Note:** Make a note of the password
@@ -43,36 +50,17 @@ Sample spring application with Jenkins pipeline script to demonstrate secure pip
4350

4451
### Dependency Track setup
4552

46-
- Setup Dependency Track server
47-
48-
```s
49-
helm repo add evryfs-oss https://evryfs.github.io/helm-charts/
50-
51-
helm repo update
52-
53-
kubectl create ns dependency-track
54-
55-
helm install dependency-track evryfs-oss/dependency-track --namespace dependency-track
56-
57-
kubectl port-forward svc/dependency-track 8081:80 -n dependency-track
58-
open http://localhost:8081
59-
```
53+
- Refer [Dependency Track v4 Installation Guide](DEPENDENCY_TRACK.md)
6054

6155
**Note:** dependency-track will take some time to start (~1hr on low end Mac)
6256

6357
### Link Jenkins and Dependency Track
6458

65-
- Login to Dependency track -> Administration -> Access Management -> Teams -> Click on Automation -> Copy the API Keys
66-
67-
- Login to Jenkins -> Manage Jenkins -> Configure System -> Scroll to bottom -> Configure the Dependency-Track URL and API key -> Save
68-
69-
- Login to Dependency track -> Projects -> Create Project -> Fill Name and save -> Copy the UUID of the project from the URL
70-
71-
- Update the UUID in the Jenkinsfile in the Depedency Track upload section
59+
- Login to Dependency track -> Administration -> Access Management -> Teams -> Click on Automation -> Copy the API Keys -> Also add the Permissions - PROJECT_CREATION_UPLOAD, POLICY_VIOLATION_ANALYSIS, VULNERABILITY_ANALYSIS
7260

73-
Hint: URL (if you have followed the exact steps) http://dependency-track.dependency-track.svc.cluster.local
61+
- Login to Jenkins -> Manage Jenkins -> Configure System -> Scroll to bottom -> Configure the Dependency-Track URL and API key -> Also enable Auto Create Projects -> Test Connection -> Save
7462

75-
**Note:** This UUID step is not required ideally, Projects will get created automatically - Looks like some open issue
63+
Hint: URL (if you have followed the exact steps) http://dependency-track-apiserver.dependency-track.svc.cluster.local
7664

7765
### New Jenkins Pipeline
7866

build-agent.yaml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ spec:
1313
volumeMounts:
1414
- name: m2
1515
mountPath: /root/.m2/
16-
- name: docker-cmds
17-
image: docker:stable-git
16+
- name: docker-tools
17+
image: rmkanda/docker-tools:latest
1818
command:
1919
- cat
2020
tty: true
@@ -33,14 +33,6 @@ spec:
3333
command:
3434
- cat
3535
tty: true
36-
- name: dockle
37-
image: rmkanda/dockle
38-
command:
39-
- cat
40-
tty: true
41-
volumeMounts:
42-
- mountPath: /var/run
43-
name: docker-sock
4436
volumes:
4537
- name: m2
4638
hostPath:

0 commit comments

Comments
 (0)