|
1 | 1 | # Deep Security Smart Check Scan Action |
2 | 2 |
|
3 | | -For scanning your images as part of your CI pipeline using [Deep Security Smart |
4 | | -Check][]. |
| 3 | +<img src="Trend-Micro-Logo.png"> |
5 | 4 |
|
6 | | -[deep security smart check]: https://www.trendmicro.com/smartcheck |
| 5 | +## Scan your containers with [Deep Security Smart Check](https://www.trendmicro.com/smartcheck). |
7 | 6 |
|
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). |
10 | 13 |
|
11 | 14 | ## Usage |
12 | 15 |
|
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 |
14 | 17 | Smart Check. |
15 | 18 |
|
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 }}' |
28 | 39 | ``` |
29 | 40 |
|
30 | 41 | ### Parameters |
@@ -56,7 +67,13 @@ be given with `DSSC_IMAGE_NAME`. |
56 | 67 | "username": "<user>", |
57 | 68 | "password": "<password>" |
58 | 69 | } |
| 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"}}' |
59 | 75 | ``` |
| 76 | + **PS.: ALWAYS use secrets to expose your credentials!** |
60 | 77 |
|
61 | 78 | See [creating a scan][] in the [Deep Security Smart Check API Reference][] |
62 | 79 | for additional registry credentials options. |
@@ -146,47 +163,84 @@ be given with `DSSC_IMAGE_NAME`. |
146 | 163 | } |
147 | 164 | ``` |
148 | 165 |
|
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>"}' |
190 | 244 | ``` |
191 | 245 |
|
192 | 246 | ## Pre-registry scanning |
@@ -219,4 +273,4 @@ save yourself some time!). |
219 | 273 | ## Support |
220 | 274 |
|
221 | 275 | 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. |
0 commit comments