Skip to content

Commit 9763946

Browse files
committed
Pipeline default value fix
1 parent a73564d commit 9763946

File tree

3 files changed

+68
-46
lines changed

3 files changed

+68
-46
lines changed

content/13-rhacs-pipeline/_index.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Remember how we edited the pipeline directly in yaml before? OpenShift comes wit
127127
{{% /notice %}}
128128

129129
- 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
131131
- To add the required parameters from the pipeline for the task, click the **rox-image-check** task.
132132
- A form with the parameters will open, fill it in:
133133

@@ -159,7 +159,6 @@ The last step is to enforce the System Policy. If the policy is violated the pip
159159

160160
- Edit your custom **System Policy** in **ACS Portal** and set **Response Method** to **Inform and enforce** and then switch on **Build** and **Deploy** below.
161161
- 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** !
163162
- Expected results:
164163
- We are sure you know by now what to expect!
165164
- The pipeline should fail with the old image version and succeed with the latest image version!

content/14-advanced-pipeline/_index.md

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,29 @@ weight = 31
55

66
## Optimizing our DevSecOps Pipeline
77

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.
1010

1111
### 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.
1314

1415
{{% 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/)
1617
{{% /notice %}}
1718

1819
To add this library to you Quarkus app
20+
1921
- Go to your `quarkus-build-options` repo in `Gitea`
2022
- Edit the `pom.xml` file to include the new dependency
2123
- Find the line
24+
2225
```xml
2326
<!-- Add dependency here -->
2427
```
28+
2529
and after that paste
30+
2631
```xml
2732
<!-- Add dependency here -->
2833
<dependency>
@@ -36,37 +41,48 @@ and after that paste
3641
<version>2.9.1</version>
3742
</dependency>
3843
```
44+
3945
- Commit
4046
- Edit the `src/main/java/org/acme/GreetingResource.java` file to use the new dependency (otherwise Quarkus will just optimize it away)
4147
- Find the line
48+
4249
```java
4350
// Add import here
4451
```
52+
4553
and after that paste
54+
4655
```java
4756
// Add import here
4857
import org.apache.logging.log4j.Logger;
4958
import org.apache.logging.log4j.LogManager;
5059
```
60+
5161
- Find the line
62+
5263
```java
5364
// Add Logger instantiation here
5465
```
66+
5567
and after that paste
68+
5669
```java
5770
// Add Logger instantiation here
5871
private Logger logger = LogManager.getLogger(GreetingResource.class.getName());
5972
```
60-
- Commit
6173

62-
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
6375

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.
6477

6578
### ACS Prerequisites
79+
6680
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+
6782
## Modify Log4Shell Policy
6883

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+
7086
- Navigate to **Platform Configuration > System Policies**
7187
- Search for `Log4Shell` and click on the Policy.
7288
- Click **Edit** at the upper right
@@ -75,20 +91,20 @@ Remember setting up image scanning with `roxctl` in our first pipeline? We use `
7591

7692
- Remove the current categorie and add `Workshop`
7793
- 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**
7995
- Save the policy
8096

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.
8298

8399
### Let's go: Create our advanced Pipeline
84100

85-
In the **OpenShift Web Console**:
101+
In the **OpenShift Web Console**:
86102

87103
- Make sure you are in the `workshop-int` Project
88104
- Navigate to **Pipelines > Pipelines**
89105
- On the right click **Create > Pipeline**
90106
- 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}):
92108

93109
```yaml
94110
apiVersion: tekton.dev/v1beta1
@@ -102,7 +118,7 @@ spec:
102118
- name: delete-image
103119
params:
104120
- 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"
106122
- name: VERSION
107123
value: latest
108124
taskRef:
@@ -169,7 +185,7 @@ spec:
169185
- name: revision
170186
value: $(params.GIT_REVISION)
171187
- name: deleteExisting
172-
value: 'true'
188+
value: "true"
173189
taskRef:
174190
kind: ClusterTask
175191
name: git-clone
@@ -181,7 +197,7 @@ spec:
181197
- name: IMAGE
182198
value: $(params.IMAGE_NAME)
183199
- name: TLSVERIFY
184-
value: 'false'
200+
value: "false"
185201
- name: PATH_CONTEXT
186202
value: $(params.PATH_CONTEXT)
187203
- name: VERSION
@@ -222,7 +238,7 @@ spec:
222238
- name: tag-checked-image
223239
params:
224240
- name: SCRIPT
225-
value: 'oc tag workshop:dev workshop:latest'
241+
value: "oc tag workshop:dev workshop:latest"
226242
- name: VERSION
227243
value: latest
228244
runAfter:
@@ -233,7 +249,7 @@ spec:
233249
- name: remove-dev-tag
234250
params:
235251
- name: SCRIPT
236-
value: 'oc tag -d workshop:dev'
252+
value: "oc tag -d workshop:dev"
237253
- name: VERSION
238254
value: latest
239255
runAfter:
@@ -244,6 +260,7 @@ spec:
244260
workspaces:
245261
- name: workspace
246262
```
263+
247264
- Click **Create**
248265
249266
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
255272
- The last three steps stays the same as before
256273

257274
{{< figure src="../images/pipeline-adv.png?width=50pc&classes=border,shadow" title="Click image to enlarge" >}}
275+
258276
### Test the advanced Pipeline
259277

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+
262281
- **Pipelines -> Pipelines**
263282
- Click on **workshop-advanced**
264283
- In the top right corner click **Actions** -> **Start**
265284
- In the **Start Pipeline** window at the bottom set **workspace** to **PersistentVolumeClaim**
266285
- Set the **Select a PVC** drop-down to a PVC
267286
- Start the Pipeline
268287

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!
270289

271290
### Fix the Vulnerability
291+
272292
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.
273293

274294
Go to your `quarkus-build-options` repo in `Gitea` again
295+
275296
- Edit the `pom.xml` file update dependency to a safe version like this
297+
276298
```xml
277299
<!-- Add dependency here -->
278300
<dependency>
@@ -286,4 +308,3 @@ Go to your `quarkus-build-options` repo in `Gitea` again
286308
<version>2.17.1</version>
287309
</dependency>
288310
```
289-

content/4-outer-loop/_index.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Now that you have seen how a developer can quickly start to code using modern cl
1010
To create and run the build pipeline you'll use OpenShift Pipelines based on project Tekton. The first step is to install it:
1111

1212
- 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 %}}
1616

1717
## Create App Deployment and Build Pipeline
1818

@@ -22,20 +22,21 @@ After installing the Operator create a new deployment of your game-changing appl
2222
- Switch to the **OpenShift Developer Console**
2323
- Click the **+Add** menu entry to the left and choose **Import from Git**
2424
- 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`
2526
- 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)**
2728
- As **Application Name** enter **workshop-app**
28-
- As **Name** enter **workshop**
29+
- As **Name** enter **workshop**
2930
- Check **Add pipeline**
3031

3132
{{% 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.
3334
{{% /notice %}}
3435

3536
- Click **Create**
3637
- In the main menu left, click on **Pipelines** and observe how the Tekton Pipeline is created and run.
3738

38-
## Create an ImageStream Tag with an Old Image Version
39+
## Create an ImageStream Tag with an Old Image Version
3940

4041
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.
4142

@@ -45,27 +46,28 @@ Now your build pipeline has been set up and is ready. There is one more step in
4546
- Be careful to keep the needed indentation!
4647

4748
```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)
53-
sampleContextDir: undertow-servlet
54-
sampleRepo: 'https://github.com/jboss-openshift/openshift-quickstarts'
55-
supports: 'java:8,java'
56-
tags: 'builder,java,openjdk'
57-
version: '8'
58-
from:
59-
kind: DockerImage
60-
name: 'registry.redhat.io/openjdk/openjdk-11-rhel7:1.10-1'
61-
generation: 4
62-
importPolicy: {}
63-
referencePolicy:
64-
type: Local
49+
- name: java-old-image
50+
annotations:
51+
description: Build and run Java applications using Maven and OpenJDK 8.
52+
iconClass: icon-rh-openjdk
53+
openshift.io/display-name: Red Hat OpenJDK 8 (UBI 8)
54+
sampleContextDir: undertow-servlet
55+
sampleRepo: "https://github.com/jboss-openshift/openshift-quickstarts"
56+
supports: "java:8,java"
57+
tags: "builder,java,openjdk"
58+
version: "8"
59+
from:
60+
kind: DockerImage
61+
name: "registry.redhat.io/openjdk/openjdk-11-rhel7:1.10-1"
62+
generation: 4
63+
importPolicy: {}
64+
referencePolicy:
65+
type: Local
6566
```
6667
6768
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:
6869
https://catalog.redhat.com/software/containers/openjdk/openjdk-11-rhel7/5bf57185dd19c775cddc4ce5?tag=1.10-1&push_date=1629294893000&container-tabs=security
70+
6971
- Have a look at version `1.10-1`
7072

7173
We will use this tag to test our security setup in a later chapter.

0 commit comments

Comments
 (0)