You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/13-rhacs-pipeline/_index.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,7 +127,7 @@ Remember how we edited the pipeline directly in yaml before? OpenShift comes wit
127
127
{{% /notice %}}
128
128
129
129
- Hover your mouse over **build** task and click the **+** at the right side side of it, to add a task
130
-
- This will open a task selector where you can choose to add your **rox-image-check**
130
+
- This will open a task selector where you can choose to your **rox-image-check** and double-click to add it to the pipeline
131
131
- To add the required parameters from the pipeline for the task, click the **rox-image-check** task.
132
132
- A form with the parameters will open, fill it in:
133
133
@@ -159,7 +159,6 @@ The last step is to enforce the System Policy. If the policy is violated the pip
159
159
160
160
- Edit your custom **System Policy** in **ACS Portal** and set **Response Method** to **Inform and enforce** and then switch on **Build** and **Deploy** below.
161
161
- Run the pipeline again, first with **Version** `java-old-image` and then with **Version** `openjdk-17-ubi8` (default)
162
-
- When running the Pipeline with new parameters you need to enter `master` as **GIT_REVISION** !
163
162
- Expected results:
164
163
- We are sure you know by now what to expect!
165
164
- The pipeline should fail with the old image version and succeed with the latest image version!
Copy file name to clipboardExpand all lines: content/14-advanced-pipeline/_index.md
+41-20Lines changed: 41 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,24 +5,29 @@ weight = 31
5
5
6
6
## Optimizing our DevSecOps Pipeline
7
7
8
-
In the chapter before we created a Pipeline which builds, checks and deploys our image, if the image passes all ACS checks. But what should happen, if the image doesn't pass the ACS check? It doesn't seems to be a good idea to save an unsafe image in the internal OpenShift registry.
9
-
So lets modify our pipeline to an advanced one, which deletes an image, if it doesn't pass the ACS checks.
8
+
In the chapter before we created a Pipeline which builds, checks and deploys our image, if the image passes all ACS checks. But what should happen, if the image doesn't pass the ACS check? It doesn't seems to be a good idea to keep an unsafe image in the internal OpenShift registry.
9
+
So lets modify our pipeline to a more advanced one, which deletes an image, if it doesn't pass the ACS checks.
10
10
11
11
### Adding a Package Level Vulnerability
12
-
Before we adjust our pipeline let's add another vulnerability to our Deployment. So far we had a system library security issue but let's image a developer tried to add (hopefully by mistake) a vulnerable Java library to his/her application. How about we pick one of the most infamous current ones such as the **Log4Shell** vulnerability? But don't worry ACS already ships with a policy for that and has your back.
12
+
13
+
Before we adjust our pipeline let's add another vulnerability to our Deployment. So far we had a system library security issue but let's imagine a developer tried to add (hopefully by mistake) a vulnerable Java library to his/her application. How about we pick one of the most infamous current ones such as the **Log4Shell** vulnerability? But don't worry ACS already ships with a policy for that and has your back.
13
14
14
15
{{% notice tip %}}
15
-
Quarkus doesn't use the log4J library for logging so is not affected by it. Although it is a bit contrived we will still force it to include the library just to trigger our policy. If you want to find out more about this particular vulnerability have look [here](https://www.wired.com/story/log4j-log4shell/)
16
+
Quarkus doesn't use the log4J library for logging so is not affected by it. Although it is a bit contrived we will still force it to include the library just to trigger our policy. If you want to find out more about this particular vulnerability have look [here](https://www.wired.com/story/log4j-log4shell/)
16
17
{{% /notice %}}
17
18
18
19
To add this library to you Quarkus app
20
+
19
21
- Go to your `quarkus-build-options` repo in `Gitea`
20
22
- Edit the `pom.xml` file to include the new dependency
21
23
- Find the line
24
+
22
25
```xml
23
26
<!-- Add dependency here -->
24
27
```
28
+
25
29
and after that paste
30
+
26
31
```xml
27
32
<!-- Add dependency here -->
28
33
<dependency>
@@ -36,37 +41,48 @@ and after that paste
36
41
<version>2.9.1</version>
37
42
</dependency>
38
43
```
44
+
39
45
- Commit
40
46
- Edit the `src/main/java/org/acme/GreetingResource.java` file to use the new dependency (otherwise Quarkus will just optimize it away)
There you go. That developer has just introduced a ticking timebomb into the application. Let's see how far he will get with that.
74
+
- Commit
63
75
76
+
There you go. That developer has just introduced a ticking timebomb into the application. Let's see how far he will get with that.
64
77
65
78
### ACS Prerequisites
79
+
66
80
So there is a major security vulnerability in our code. ACS would detect the deployment because the System Policy `Log4Shell: log4j Remote Code Execution vulnerability` is enabled but won't stop it, because the Policy is not set to enforce.
81
+
67
82
## Modify Log4Shell Policy
68
83
69
-
So first of all in the **ACS Portal** follow these steps:
84
+
So first of all in the **ACS Portal** follow these steps:
85
+
70
86
- Navigate to **Platform Configuration > System Policies**
71
87
- Search for `Log4Shell` and click on the Policy.
72
88
- Click **Edit** at the upper right
@@ -75,20 +91,20 @@ Remember setting up image scanning with `roxctl` in our first pipeline? We use `
75
91
76
92
- Remove the current categorie and add `Workshop`
77
93
- Now hit next until you are at the enforcement tab
78
-
- Enable both `Build` and `Deploy` enforcement by setting them to **On**
94
+
- Enable both `Build` and `Deploy` enforcement by setting them to **On**
79
95
- Save the policy
80
96
81
-
ACS is now able to detect and enforce the vulnerability. It is time now to implement your advanced Pipeline.
97
+
ACS is now able to detect and enforce the vulnerability. It is time now to implement your advanced Pipeline.
82
98
83
99
### Let's go: Create our advanced Pipeline
84
100
85
-
In the **OpenShift Web Console**:
101
+
In the **OpenShift Web Console**:
86
102
87
103
- Make sure you are in the `workshop-int` Project
88
104
- Navigate to **Pipelines > Pipelines**
89
105
- On the right click **Create > Pipeline**
90
106
- Switch to **YAML view**
91
-
- Replace the YAML with this making sure to update your two `Gitea` Repo URL's (Specifically replace the {YOUR_CLUSTER_HOSTNAME}):
107
+
- Replace the YAML with this making sure to update your two `Gitea` Repo URL's (Specifically replace the {YOUR_CLUSTER_HOSTNAME}):
92
108
93
109
```yaml
94
110
apiVersion: tekton.dev/v1beta1
@@ -102,7 +118,7 @@ spec:
102
118
- name: delete-image
103
119
params:
104
120
- name: SCRIPT
105
-
value: 'oc tag -d workshop-int/workshop:dev -n workshop-int'
121
+
value: "oc tag -d workshop-int/workshop:dev -n workshop-int"
106
122
- name: VERSION
107
123
value: latest
108
124
taskRef:
@@ -169,7 +185,7 @@ spec:
169
185
- name: revision
170
186
value: $(params.GIT_REVISION)
171
187
- name: deleteExisting
172
-
value: 'true'
188
+
value: "true"
173
189
taskRef:
174
190
kind: ClusterTask
175
191
name: git-clone
@@ -181,7 +197,7 @@ spec:
181
197
- name: IMAGE
182
198
value: $(params.IMAGE_NAME)
183
199
- name: TLSVERIFY
184
-
value: 'false'
200
+
value: "false"
185
201
- name: PATH_CONTEXT
186
202
value: $(params.PATH_CONTEXT)
187
203
- name: VERSION
@@ -222,7 +238,7 @@ spec:
222
238
- name: tag-checked-image
223
239
params:
224
240
- name: SCRIPT
225
-
value: 'oc tag workshop:dev workshop:latest'
241
+
value: "oc tag workshop:dev workshop:latest"
226
242
- name: VERSION
227
243
value: latest
228
244
runAfter:
@@ -233,7 +249,7 @@ spec:
233
249
- name: remove-dev-tag
234
250
params:
235
251
- name: SCRIPT
236
-
value: 'oc tag -d workshop:dev'
252
+
value: "oc tag -d workshop:dev"
237
253
- name: VERSION
238
254
value: latest
239
255
runAfter:
@@ -244,6 +260,7 @@ spec:
244
260
workspaces:
245
261
- name: workspace
246
262
```
263
+
247
264
- Click **Create**
248
265
249
266
As you can see in the Pipeline visualization the flow is now a bit different. Lets see what has changed:
@@ -255,24 +272,29 @@ As you can see in the Pipeline visualization the flow is now a bit different. Le
255
272
- The last three steps stays the same as before
256
273
257
274
{{< figure src="../images/pipeline-adv.png?width=50pc&classes=border,shadow" title="Click image to enlarge" >}}
275
+
258
276
### Test the advanced Pipeline
259
277
260
-
Go ahead and start your newly created advanced Pipeline.
261
-
Navigate to:
278
+
Go ahead and start your newly created advanced Pipeline.
279
+
Navigate to:
280
+
262
281
- **Pipelines -> Pipelines**
263
282
- Click on **workshop-advanced**
264
283
- In the top right corner click **Actions** -> **Start**
265
284
- In the **Start Pipeline** window at the bottom set **workspace** to **PersistentVolumeClaim**
266
285
- Set the **Select a PVC** drop-down to a PVC
267
286
- Start the Pipeline
268
287
269
-
See what happens and maybe play around with it and start again. Have fun!
288
+
See what happens and maybe play around with it and start again. Have fun!
270
289
271
290
### Fix the Vulnerability
291
+
272
292
If by now the developer that introduced the log4jShell vulnerability has not realized that he/she "broke the build" you can tell him/her to update their dependency to a safe version.
273
293
274
294
Go to your `quarkus-build-options` repo in `Gitea` again
295
+
275
296
- Edit the `pom.xml` file update dependency to a safe version like this
297
+
276
298
```xml
277
299
<!-- Add dependency here -->
278
300
<dependency>
@@ -286,4 +308,3 @@ Go to your `quarkus-build-options` repo in `Gitea` again
Copy file name to clipboardExpand all lines: content/4-outer-loop/_index.md
+26-24Lines changed: 26 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,9 @@ Now that you have seen how a developer can quickly start to code using modern cl
10
10
To create and run the build pipeline you'll use OpenShift Pipelines based on project Tekton. The first step is to install it:
11
11
12
12
- Install the `Red hat OpenShift Pipelines` Operator from OperatorHub with default settings
13
-
{{% notice warning %}}
14
-
Since the Piplines assets are installed asynchronously it is possible that the `Pipline Templates` are not yet setup when proceeding immedately to the next step. So now is good time to grab a coffee.
15
-
{{% /notice %}}
13
+
{{% notice warning %}}
14
+
Since the Piplines assets are installed asynchronously it is possible that the `Pipline Templates` are not yet setup when proceeding immedately to the next step. So now is good time to grab a coffee.
15
+
{{% /notice %}}
16
16
17
17
## Create App Deployment and Build Pipeline
18
18
@@ -22,20 +22,21 @@ After installing the Operator create a new deployment of your game-changing appl
22
22
- Switch to the **OpenShift Developer Console**
23
23
- Click the **+Add** menu entry to the left and choose **Import from Git**
24
24
- As **Git Repo URL** enter the clone URL for the `quarkus-build-options` repo in your your `Gitea` instance (There might be a warning about the repo url that you can ignore)
25
+
- Click **Show advanced Git options** and for **Git reference** enter `master`
25
26
- As **Import Strategy** select **Builder Image**
26
-
- As **Builder Image** select **Java** and **openjdk-11-el7** / **Red Hat OpenJDK 11 (RHEL 7)**
27
+
- As **Builder Image** select **Java** and **openjdk-11-el7** / **Red Hat OpenJDK 11 (RHEL 7)**
27
28
- As **Application Name** enter **workshop-app**
28
-
- As **Name** enter **workshop**
29
+
- As **Name** enter **workshop**
29
30
- Check **Add pipeline**
30
31
31
32
{{% notice warning %}}
32
-
If you don't have the checkbox **Add pipeline** and get the message `There are no pipeline templates available for Java and Deployment combination` in the next step then just give it few more minutes and reload the page.
33
+
If you don't have the checkbox **Add pipeline** and get the message `There are no pipeline templates available for Java and Deployment combination` in the next step then just give it few more minutes and reload the page.
33
34
{{% /notice %}}
34
35
35
36
- Click **Create**
36
37
- In the main menu left, click on **Pipelines** and observe how the Tekton Pipeline is created and run.
37
38
38
-
## Create an ImageStream Tag with an Old Image Version
39
+
## Create an ImageStream Tag with an Old Image Version
39
40
40
41
Now your build pipeline has been set up and is ready. There is one more step in preparation of the security part of this workshop. We need a way to build and deploy from an older image with some security issues in it. For this we will add another ImageStream `Tag` in the default `Java` ImageStream that points to an older version with a known issue in it.
41
42
@@ -45,27 +46,28 @@ Now your build pipeline has been set up and is ready. There is one more step in
45
46
- Be careful to keep the needed indentation!
46
47
47
48
```yaml
48
-
- name: java-old-image
49
-
annotations:
50
-
description: Build and run Java applications using Maven and OpenJDK 8.
51
-
iconClass: icon-rh-openjdk
52
-
openshift.io/display-name: Red Hat OpenJDK 8 (UBI 8)
This will add a tag `java-old-image` that points to an older version of the RHEL Java image. The image and security vulnerabilities can be inspected in the Red Hat Software Catalog here:
0 commit comments