Skip to content

Commit 82f137e

Browse files
authored
Added legacy scanner for Azure pipelines (#25)
1 parent 4d2e46b commit 82f137e

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Azure Pipelines Demo
2+
3+
In this demo we will use Azure Pipelines to build, scan and push a container image.
4+
5+
NOTE: This example uses the [legacy Sysdig scanning engine](https://docs.sysdig.com/en/docs/sysdig-secure/scanning/)
6+
7+
The workflow is as follows:
8+
9+
1. Build the container image and store it locally
10+
2. Run the `sysdiglabs/secure-inline-scan:2` container to perform the scan
11+
3. Push the container image to a remote registry
12+
13+
## Setup
14+
15+
### Variables
16+
17+
It is required to create a `secureApiKey` pipeline variable containing the Sysdig API token in order
18+
to be able to perform the scan. See [the official documentation](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/set-secret-variables)
19+
for instructions on how to do it, but basically:
20+
21+
* Edit the pipeline
22+
* Select "Variables"
23+
* Add a new `secureApiKey` variable with the proper content
24+
25+
### Registry access
26+
27+
It is required to create a Docker registry "Service Connections" to be able to push images to the registry.
28+
See [the official documentation](https://docs.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#docker-hub-or-others)
29+
for instructions on how to do it, but basically:
30+
31+
* Select Project settings > Service connections
32+
* Select + New service connection, select the "Docker Registry", and then select Next
33+
* Add the registry url, user & password and a Service connection name (in this example, the Service connection name is `containerRegistry`)
34+
35+
Then, modify the variables on the [azure-pipelines.yml](azure-pipelines.yml) file to fit your needs:
36+
37+
```
38+
containerRegistryConnection: containerRegistry
39+
imageName: "sysdiglabs/dummy-vuln-app"
40+
tags: "latest"
41+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
pool:
2+
vmImage: 'ubuntu-16.04'
3+
4+
variables:
5+
containerRegistryConnection: containerRegistry
6+
imageName: 'sysdiglabs/dummy-vuln-app'
7+
tags: |
8+
latest
9+
10+
steps:
11+
- task: Docker@2
12+
displayName: Build image
13+
inputs:
14+
repository: $(imageName)
15+
command: build
16+
tags: $(tags)
17+
18+
- bash: docker run --rm \
19+
-v /var/run/docker.sock:/var/run/docker.sock \
20+
quay.io/sysdig/secure-inline-scan:2 \
21+
--sysdig-token $(secureApiKey) \
22+
--storage-type docker-daemon \
23+
--storage-path /var/run/docker.sock \
24+
$(imageName):latest
25+
26+
- task: Docker@2
27+
inputs:
28+
command: 'login'
29+
containerRegistry: $(containerRegistryConnection)
30+
31+
- task: Docker@2
32+
inputs:
33+
command: 'push'
34+
tags: $(tags)
35+
containerRegistry: $(containerRegistryConnection)

0 commit comments

Comments
 (0)