Skip to content

Commit adcae8e

Browse files
authored
SSC-139 Optional: Block builds on high severity vulnerabilities (#8)
* SSC-139 Optional: Block build on high severity vulnerabilities * Add DT_RESULTS_API_KEY secret to be able to access results API * Introduce a new filter for this use case * Add WARN_ON_SEVERITY configuration parameter * Upgrade node
1 parent 72d0cfb commit adcae8e

4 files changed

Lines changed: 723 additions & 235 deletions

File tree

README.md

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ https://www.datatheorem.com/products/mobile-secure
88

99
Enabling this integration requires a valid Data Theorem API key.
1010

11-
## Set your Data Theorem upload API key as a secret:
12-
To find your Data Theorem API key, connect to https://www.securetheorem.com/mobile/sdlc/api_access using your Data Theorem account.'
13-
Create an encrypted variable named `DT_UPLOAD_API_KEY` in your Github repository
11+
## Set your Data Theorem API keys as secrets:
12+
To find your Data Theorem API keys, go to https://www.securetheorem.com/devsecops/results_api_access using your Data Theorem account.
13+
14+
Create encrypted variables in your Github repository:
15+
- `DT_UPLOAD_API_KEY` - Required for uploading binaries
16+
- `DT_RESULTS_API_KEY` - Required when using vulnerability blocking (BLOCK_ON_SEVERITY) or warnings (WARN_ON_SEVERITY)
1417

1518
For more information, see [Github Encrypted secrets](https://docs.github.com/en/actions/reference/encrypted-secrets)
1619

@@ -32,6 +35,67 @@ At this time, comments, release id, external id, and platform variant parameters
3235

3336
If multiple files match the provided pattern, the same set of optional values will be sent with each file.
3437

38+
## Vulnerability Blocking and Warnings
39+
40+
The action supports automatic build blocking and vulnerability warnings based on security findings.
41+
42+
### `BLOCK_ON_SEVERITY`
43+
When `BLOCK_ON_SEVERITY` is specified, the action will:
44+
45+
1. Wait for the scan to complete (up to 5 minutes)
46+
2. Check for security findings at or above the specified severity level
47+
3. Block the build if any vulnerabilities are found at the minimum severity threshold
48+
49+
### `WARN_ON_SEVERITY`
50+
When `WARN_ON_SEVERITY` is specified, the action will:
51+
52+
1. Wait for the scan to complete (up to 5 minutes)
53+
2. Check for security findings at or above the specified severity level
54+
3. Print warning messages if vulnerabilities are found, but continue the build
55+
56+
**Important:** Both vulnerability blocking and warnings require a separate `DT_RESULTS_API_KEY` with results access permissions.
57+
58+
### Severity Levels
59+
- `HIGH`: Block on high severity vulnerabilities only
60+
- `MEDIUM`: Block on medium and high severity vulnerabilities
61+
- `LOW`: Block on all severity vulnerabilities (low, medium, high)
62+
63+
### Example with Vulnerability Blocking
64+
```yaml
65+
- name: Upload to Data Theorem with blocking if high or medium vulnerabilities are found
66+
uses: datatheorem/datatheorem-mobile-secure-action@v2.3.1
67+
with:
68+
UPLOAD_BINARY_PATH: "./app/build/outputs/apk/debug/app-debug.apk"
69+
DT_UPLOAD_API_KEY: ${{ secrets.DT_UPLOAD_API_KEY }}
70+
DT_RESULTS_API_KEY: ${{ secrets.DT_RESULTS_API_KEY }}
71+
BLOCK_ON_SEVERITY: "MEDIUM"
72+
```
73+
74+
### Example with Vulnerability Warnings
75+
```yaml
76+
- name: Upload to Data Theorem with warnings for high severity vulnerabilities
77+
uses: datatheorem/datatheorem-mobile-secure-action@v2.3.1
78+
with:
79+
UPLOAD_BINARY_PATH: "./app/build/outputs/apk/debug/app-debug.apk"
80+
DT_UPLOAD_API_KEY: ${{ secrets.DT_UPLOAD_API_KEY }}
81+
DT_RESULTS_API_KEY: ${{ secrets.DT_RESULTS_API_KEY }}
82+
WARN_ON_SEVERITY: "HIGH"
83+
```
84+
85+
### Example with Both Blocking and Warnings
86+
```yaml
87+
- name: Upload to Data Theorem with blocking on high and warnings on medium vulnerabilities
88+
uses: datatheorem/datatheorem-mobile-secure-action@v2.3.1
89+
with:
90+
UPLOAD_BINARY_PATH: "./app/build/outputs/apk/debug/app-debug.apk"
91+
DT_UPLOAD_API_KEY: ${{ secrets.DT_UPLOAD_API_KEY }}
92+
DT_RESULTS_API_KEY: ${{ secrets.DT_RESULTS_API_KEY }}
93+
BLOCK_ON_SEVERITY: "HIGH"
94+
WARN_ON_SEVERITY: "MEDIUM"
95+
```
96+
97+
**Note:** Both vulnerability blocking and warning features will cause the action to wait for scan completion before proceeding. This adds time to your build process but ensures security issues are caught before deployment.
98+
3599
## Sample usage
36100
37101
```yaml
@@ -46,22 +110,25 @@ jobs:
46110
name: Generate & Upload APK
47111
runs-on: ubuntu-20.04
48112
steps:
49-
- uses: actions/checkout@v2
50-
- name: set up JDK 1.8
51-
uses: actions/setup-java@v1
113+
- uses: actions/checkout@v4
114+
- name: set up JDK 17
115+
uses: actions/setup-java@v4
52116
with:
53-
java-version: 1.8
117+
java-version: 17
54118
- name: Build debug APK
55119
run: bash ./gradlew assembleDebug
56120
- name: Upload to Data Theorem
57-
uses: datatheorem/datatheorem-mobile-secure-action@v2.1.0
121+
uses: datatheorem/datatheorem-mobile-secure-action@v2.3.1
58122
with:
59123
UPLOAD_BINARY_PATH: "./app/build/outputs/apk/debug/app-debug.apk"
60124
DT_UPLOAD_API_KEY: ${{ secrets.DT_UPLOAD_API_KEY }}
125+
DT_RESULTS_API_KEY: ${{ secrets.DT_RESULTS_API_KEY }} # Required for vulnerability blocking
61126
USERNAME: "test_user"
62127
PASSWORD: ${{ secrets.DT_DAST_PASSWORD }}
63128
COMMENTS: "This is a pre-production build."
64129
RELEASE_ID: ${{ vars.GITHUB_RUN_NUMBER }}
65130
EXTERNAL_ID: "App_12230045"
131+
BLOCK_ON_SEVERITY: "HIGH" # Optional: Block build on high severity vulnerabilities
132+
WARN_ON_SEVERITY: "MEDIUM" # Optional: Warn on medium severity vulnerabilities
66133

67-
```
134+
```

action.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ inputs:
66
DT_UPLOAD_API_KEY:
77
description: 'Data Theorem upload API key'
88
required: true
9+
DT_RESULTS_API_KEY:
10+
description: 'Data Theorem results API key (required when BLOCK_ON_SEVERITY is used)'
11+
required: false
912
UPLOAD_BINARY_PATH:
1013
description: >
1114
Path to the app to upload.
@@ -49,8 +52,20 @@ inputs:
4952
description: >
5053
The external_id field represents your organization’s custom identifier for the app, if any.
5154
required: false
55+
BLOCK_ON_SEVERITY:
56+
description: >
57+
Block the build if vulnerabilities with the specified minimum severity are found.
58+
Valid values: HIGH, MEDIUM, LOW. If not specified, build will not be blocked.
59+
required: false
60+
WARN_ON_SEVERITY:
61+
description: >
62+
Print warning messages if vulnerabilities with the specified minimum severity are found.
63+
This is a softer version of BLOCK_ON_SEVERITY that doesn't fail the build.
64+
Valid values: HIGH, MEDIUM, LOW. If not specified, no warnings will be shown.
65+
This requires a Data Theorem Mobile Results API Key to be set.
66+
required: false
5267
runs:
53-
using: 'node16'
68+
using: 'node20'
5469
main: 'main.js'
5570
branding:
5671
color: 'blue'

0 commit comments

Comments
 (0)