Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 0a24788

Browse files
gregtGitHub Enterprise
authored andcommitted
Github Actions Update (#34)
* Github Actions Update * add GCP example, format input descriptions consistently in action.yml * adjust findings threshold Co-authored-by: felipecosta09 <githubfelipecosta@outlook.com> * additional comments and documentation
1 parent 1ccc3a4 commit 0a24788

3 files changed

Lines changed: 178 additions & 60 deletions

File tree

README.md

Lines changed: 114 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
# Deep Security Smart Check Scan Action
22

3-
For scanning your images as part of your CI pipeline using [Deep Security Smart
4-
Check][].
3+
<img src="Trend-Micro-Logo.png">
54

6-
[deep security smart check]: https://www.trendmicro.com/smartcheck
5+
## Scan your containers with [Deep Security Smart Check](https://www.trendmicro.com/smartcheck).
76

8-
This tool is used by the Deep Security Smart Check plugin for Jenkins and can
9-
also be used as a [GitHub Action](https://github.com/features/actions).
7+
This project was built by the [Deep Security Smart Check](trendmicro.com/smartcheck) team to help you to scan your containers in your CI/CD pipeline, you can use as a standalone Docker container published in the [Dockerhub](https://hub.docker.com/r/deepsecurity/smartcheck-scan-action) to scan your images. This tool is also used by the [Deep Security Smart Check plugin for Jenkins](https://plugins.jenkins.io/deepsecurity-smartcheck/) and the GitHub Action, that wraps the container published in Dockerhub.
8+
9+
## Requirements
10+
11+
* Have an [Deep Security Smart Check](https://www.trendmicro.com/smartcheck) deployed. [Sign up for free trial now](https://www.trendmicro.com/product_trials/download/index/us/168) if it's not already the case!
12+
* A container image to scan in any [supported Docker Registry](https://deep-security.github.io/smartcheck-docs/admin_docs/admin.html#supported-registries).
1013

1114
## Usage
1215

13-
Add an Action in your `main.workflow` file to scan your image with Deep Security
16+
Add an Action in your `.github/workflow` yml file to scan your image with Deep Security
1417
Smart Check.
1518

16-
```main.workflow
17-
action "Scan with Deep Security Smart Check" {
18-
needs = "Push image to GCR"
19-
uses = "docker://deepsecurity/smartcheck-scan-action"
20-
secrets = [
21-
"DSSC_SMARTCHECK_HOST",
22-
"DSSC_SMARTCHECK_USER",
23-
"DSSC_SMARTCHECK_PASSWORD",
24-
"DSSC_IMAGE_PULL_AUTH"
25-
]
26-
args = ["--image-name registry.example.com/my-project/my-image"]
27-
}
19+
```yml
20+
- name: Deep Security Smart Check
21+
uses: deepsecurity/Deep-Security-Smart-Check@version*
22+
with:
23+
# Mandatory
24+
DSSC_IMAGE_NAME: registryhost/myimage
25+
DSSC_SMARTCHECK_HOST: smartcheck.example.com
26+
DSSC_SMARTCHECK_USER: admin
27+
DSSC_SMARTCHECK_PASSWORD: 12345
28+
DSSC_IMAGE_PULL_AUTH: {"username":"<user>","password":"<password>"}
29+
30+
# Optional
31+
DSSC_INSECURE_SKIP_TLS_VERIFY: true
32+
DSSC_INSECURE_SKIP_REGISTRY_TLS_VERIFY: true
33+
DSSC_PREREGISTRY_SCAN: false
34+
DSSC_PREREGISTRY_HOST: pre-registryhost.com
35+
DSSC_PREREGISTRY_USER: admin
36+
DSSC_PREREGISTRY_PASSWORD: 12345
37+
DSSC_RESULTS_FILE: /results.json
38+
DSSC_FINDINGS_THRESHOLD: '{"malware": 100, "vulnerabilities": { "defcon1": 100, "critical": 100, "high": 100 }, "contents": { "defcon1": 100, "critical": 100, "high": 100 }, "checklists": { "defcon1": 100, "critical": 100, "high": 100 }}'
2839
```
2940
3041
### Parameters
@@ -56,7 +67,13 @@ be given with `DSSC_IMAGE_NAME`.
5667
"username": "<user>",
5768
"password": "<password>"
5869
}
70+
```
71+
- If you're using AWS, you can use this example below:
72+
73+
```json
74+
'{"aws":{"region":"us-east-1","accessKeyID":"$AWS_ACCESS_KEY_ID","secretAccessKey":"$AWS_SECRET_ACCESS_KEY"}}'
5975
```
76+
**PS.: ALWAYS use secrets to expose your credentials!**
6077

6178
See [creating a scan][] in the [Deep Security Smart Check API Reference][]
6279
for additional registry credentials options.
@@ -146,47 +163,84 @@ be given with `DSSC_IMAGE_NAME`.
146163
}
147164
```
148165

149-
## Example Workflow
150-
151-
```main.workflow
152-
workflow "Push image" {
153-
on = "push"
154-
resolves = "Scan with Deep Security Smart Check"
155-
}
156-
157-
action "Build image" {
158-
uses = "docker://docker:stable"
159-
args = ["build", "-t", "registry.example.com/my-project/my-image", "."]
160-
}
161-
162-
action "Docker Login" {
163-
uses = "actions/docker/login@master"
164-
env = {
165-
DOCKER_REGISTRY_URL = "registry.example.com"
166-
}
167-
secrets = [
168-
"DOCKER_USERNAME",
169-
"DOCKER_PASSWORD"
170-
]
171-
}
172-
173-
action "Push image" {
174-
needs = ["Build image", "Docker Login"]
175-
uses = "actions/docker/cli@master"
176-
args = "push registry.example.com/my-project/my-image"
177-
}
178-
179-
action "Scan with Deep Security Smart Check" {
180-
needs = "Push image"
181-
uses = "docker://deepsecurity/smartcheck-scan-action"
182-
secrets = [
183-
"DSSC_SMARTCHECK_HOST",
184-
"DSSC_SMARTCHECK_USER",
185-
"DSSC_SMARTCHECK_PASSWORD",
186-
"DSSC_IMAGE_PULL_AUTH"
187-
]
188-
args = ["--image-name registry.example.com/my-project/my-image"]
189-
}
166+
## Example Workflow Using Github Actions
167+
168+
```yml
169+
name: Deep Security Smart Check
170+
171+
on:
172+
push:
173+
branches:
174+
- master
175+
176+
jobs:
177+
SmartCheck-Scan-Action:
178+
runs-on: ubuntu-latest
179+
steps:
180+
181+
# AWS Example:
182+
- name: Deep Security Smart Check Scan ECR
183+
uses: deepsecurity/Deep-Security-Smart-Check@version*
184+
with:
185+
DSSC_IMAGE_NAME: myECRrepo/myimage
186+
DSSC_SMARTCHECK_HOST: ${{ secrets.DSSC_SMARTCHECK_HOST }}
187+
DSSC_SMARTCHECK_USER: ${{ secrets.DSSC_SMARTCHECK_USER }}
188+
DSSC_SMARTCHECK_PASSWORD: ${{ secrets.DSSC_SMARTCHECK_PASSWORD }}
189+
# You will need to generate an access key and secret for your AWS user
190+
DSSC_IMAGE_PULL_AUTH: '{"aws":{"region":"us-east-1","accessKeyID":"$AWS_ACCESS_KEY_ID","secretAccessKey":"$AWS_SECRET_ACCESS_KEY"}}'
191+
DSSC_FINDINGS_THRESHOLD: '{"malware": 100, "vulnerabilities": { "defcon1": 100, "critical": 100, "high": 100 }, "contents": { "defcon1": 100, "critical": 100, "high": 100 }, "checklists": { "defcon1": 100, "critical": 100, "high": 100 }}'
192+
DSSC_INSECURE_SKIP_TLS_VERIFY: true
193+
DSSC_INSECURE_SKIP_REGISTRY_TLS_VERIFY: true
194+
195+
# Azure Example:
196+
- name: Deep Security Smart Check Scan ACR
197+
uses: deepsecurity/Deep-Security-Smart-Check@version*
198+
with:
199+
DSSC_IMAGE_NAME: myrepo.azurecr.io/myimage
200+
DSSC_SMARTCHECK_HOST: ${{ secrets.DSSC_SMARTCHECK_HOST }}
201+
DSSC_SMARTCHECK_USER: ${{ secrets.DSSC_SMARTCHECK_USER }}
202+
DSSC_SMARTCHECK_PASSWORD: ${{ secrets.DSSC_SMARTCHECK_PASSWORD }}
203+
DSSC_IMAGE_PULL_AUTH: '{"username": "${{ secrets.ACR_USER }}","password": "${{ secrets.ACR_PASSWORD }}"}'
204+
DSSC_FINDINGS_THRESHOLD: '{"malware": 100, "vulnerabilities": { "defcon1": 100, "critical": 100, "high": 100 }, "contents": { "defcon1": 100, "critical": 100, "high": 100 }, "checklists": { "defcon1": 100, "critical": 100, "high": 100 }}' DSSC_INSECURE_SKIP_TLS_VERIFY: true
205+
DSSC_INSECURE_SKIP_REGISTRY_TLS_VERIFY: true
206+
207+
- name: Cloud One Container Security Scan GCR
208+
uses: felipecosta09/Deep-Security-Smart-Check-Scan-Action@version*
209+
with:
210+
DSSC_IMAGE_NAME: region.gcr.io/projectname/myimage
211+
DSSC_SMARTCHECK_HOST: ${{ secrets.DSSC_SMARTCHECK_HOST }}
212+
DSSC_SMARTCHECK_USER: ${{ secrets.DSSC_SMARTCHECK_USER }}
213+
DSSC_SMARTCHECK_PASSWORD: ${{ secrets.DSSC_SMARTCHECK_PASSWORD }}
214+
# You will need to generate a JSON service account key in GCP and save it as a secret
215+
DSSC_IMAGE_PULL_AUTH: '{"username": "_json_token", "password": "${{ secrets.GCP_JSON_KEY }}"}'
216+
DSSC_FINDINGS_THRESHOLD: '{"malware": 100, "vulnerabilities": { "defcon1": 100, "critical": 100, "high": 100 }, "contents": { "defcon1": 100, "critical": 100, "high": 100 }, "checklists": { "defcon1": 100, "critical": 100, "high": 100 }}' DSSC_INSECURE_SKIP_TLS_VERIFY: true
217+
DSSC_INSECURE_SKIP_REGISTRY_TLS_VERIFY: true
218+
```
219+
The example above demonstrates how to add a Smartcheck Scan action as a step in your Github Worflow. This can be used to scan an image from a container registry in either Google Container Registry, Microsoft Azure Container Registry or Amazon Elastic Container Registry.
220+
221+
For Google Container Registry and Microsoft Azure Container Registry, the `username` and `password` required for `DSSC_IMAGE_PULL_AUTH` are the same as the docker login credentials you would use to authenticate to a registry in the provided platform:
222+
- [Google Cloud Platform](https://cloud.google.com/container-registry/docs/advanced-authentication#json-key)
223+
- [Microsoft Azure Web Services](https://docs.microsoft.com/en-us/azure/container-registry/container-registry-authentication)
224+
225+
To authenticate to an Amazon Elastic Container Registry the `DSSC_IMAGE_PULL_AUTH` should be formatted to match the `credentials.aws` object specified in the [Smartcheck API Documentation to create a Scan](https://deep-security.github.io/smartcheck-docs/api/index.html#operation/createScan).
226+
227+
## Example Workflow Running a Docker Container
228+
229+
```yml
230+
name: Deep Security Smart Check Pipeline Example
231+
232+
on:
233+
push:
234+
branches:
235+
- master
236+
237+
jobs:
238+
SmartCheck-Scan-Action:
239+
runs-on: ubuntu-latest
240+
steps:
241+
- name: Deep Security Smart Check
242+
run: |
243+
docker run deepsecurity/smartcheck-scan-action --image-name registryhost/myimage --smartcheck-host=smartcheck.example.com --smartcheck-user=admin --smartcheck-password=12345 --image-pull-auth='{"username":"<user>","password":"<password>"}'
190244
```
191245

192246
## Pre-registry scanning
@@ -219,4 +273,4 @@ save yourself some time!).
219273
## Support
220274

221275
Official support from Trend Micro is not available. Individual contributors may
222-
be Trend Micro employees, but are not official support.
276+
be Trend Micro employees, but are not official support.

Trend-Micro-Logo.png

14.4 KB
Loading

action.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: "Deep Security Smart Check"
2+
description: "Scan container images with Deep Security Smart Check."
3+
inputs:
4+
DSSC_IMAGE_NAME:
5+
description: "(MANDATORY) Container repository, eg registryhost/myimage."
6+
required: true
7+
DSSC_SMARTCHECK_HOST:
8+
description: "(MANDATORY) Deep Security Smart Check url, eg smartcheck.example.com"
9+
required: true
10+
DSSC_SMARTCHECK_USER:
11+
description: "(MANDATORY) Deep Security Smart Check username, eg admin."
12+
required: true
13+
DSSC_SMARTCHECK_PASSWORD:
14+
description: (MANDATORY) Deep Security Smart Check password, eg 12345.
15+
required: true
16+
DSSC_IMAGE_PULL_AUTH:
17+
description: (MANDATORY) Container registry credentials in a json format, eg '{"username":"<user>","password":"<password>"}' or {"aws":{"region":"us-east-1","accessKeyID":"'AWS_ACCESS_KEY_ID'","secretAccessKey":"'AWS_SECRET_ACCESS_KEY'"}}'
18+
required: true
19+
DSSC_INSECURE_SKIP_TLS_VERIFY:
20+
description: (OPTIONAL) If the client should ignore certificate errors when connecting to Deep Security Smart Check. You may want to set this if you've configured a self signed cert. eg true
21+
required: false
22+
default: "true"
23+
DSSC_INSECURE_SKIP_REGISTRY_TLS_VERIFY:
24+
description: (OPTIONAL) If Deep Security Smart Check should ignore certificate errors from the image registry. eg true
25+
required: false
26+
default: "true"
27+
DSSC_PREREGISTRY_SCAN:
28+
description: (OPTIONAL) Specify this option to trigger a "pre-registry scan", which pushes the image to a temporary registry on the scan system.
29+
required: false
30+
DSSC_PREREGISTRY_HOST:
31+
description: (OPTIONAL) The hostname of the temporary registry. Defaults to the smartcheck-host on port 5000.
32+
required: false
33+
DSSC_PREREGISTRY_USER:
34+
description: (OPTIONAL) The username to authenticate with the temporary registry.
35+
required: false
36+
DSSC_PREREGISTRY_PASSWORD:
37+
description: (OPTIONAL) The password to authenticate with the temporary registry.
38+
required: false
39+
DSSC_RESULTS_FILE:
40+
description: (OPTIONAL) The path to write the scan results to. If not provided, the scan results will be written to stdout.
41+
required: false
42+
DSSC_FINDINGS_THRESHOLD:
43+
description: (OPTIONAL) A JSON object that can be used to fail this step if an image contains findings that exceed the threshold.
44+
required: false
45+
branding:
46+
icon: "check"
47+
color: "red"
48+
runs:
49+
using: "docker"
50+
image: "docker://deepsecurity/smartcheck-scan-action:latest"
51+
env:
52+
DSSC_IMAGE_NAME: ${{ inputs.DSSC_IMAGE_NAME }}
53+
DSSC_SMARTCHECK_HOST: ${{ inputs.DSSC_SMARTCHECK_HOST }}
54+
DSSC_SMARTCHECK_USER: ${{ inputs.DSSC_SMARTCHECK_USER }}
55+
DSSC_SMARTCHECK_PASSWORD: ${{ inputs.DSSC_SMARTCHECK_PASSWORD }}
56+
DSSC_IMAGE_PULL_AUTH: ${{ inputs.DSSC_IMAGE_PULL_AUTH }}
57+
DSSC_INSECURE_SKIP_TLS_VERIFY: ${{ inputs.DSSC_INSECURE_SKIP_TLS_VERIFY }}
58+
DSSC_INSECURE_SKIP_REGISTRY_TLS_VERIFY: ${{ inputs.DSSC_INSECURE_SKIP_REGISTRY_TLS_VERIFY }}
59+
DSSC_PREREGISTRY_SCAN: ${{ inputs.DSSC_PREREGISTRY_SCAN }}
60+
DSSC_PREREGISTRY_HOST: ${{ inputs.DSSC_PREREGISTRY_HOST }}
61+
DSSC_PREREGISTRY_USER: ${{ inputs.DSSC_PREREGISTRY_USER }}
62+
DSSC_PREREGISTRY_PASSWORD: ${{ inputs.DSSC_PREREGISTRY_PASSWORD }}
63+
DSSC_RESULTS_FILE: ${{ inputs.DSSC_RESULTS_FILE }}
64+
DSSC_FINDINGS_THRESHOLD: ${{ inputs.DSSC_FINDINGS_THRESHOLD }}

0 commit comments

Comments
 (0)