-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ability to run and import Debricked scans into SSC (closes #41
- Loading branch information
Showing
40 changed files
with
752 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,21 @@ inputs: | |
description: 'Run a SAST scan, takes either true or false (default)' | ||
default: 'false' | ||
required: false | ||
debricked-sca-scan: | ||
description: 'Run a Debricked Software Composition Analysis, takes either true or false (default)' | ||
default: 'false' | ||
required: false | ||
runs: | ||
using: composite | ||
steps: | ||
- uses: fortify/github-action/[email protected] | ||
if: inputs['sast-scan']=='true' && env.FOD_URL | ||
if: inputs['sast-scan']=='true' && env.FOD_URL | ||
- uses: fortify/github-action/[email protected] | ||
if: inputs['sast-scan']=='true' && env.SSC_URL | ||
if: inputs['sast-scan']=='true' && env.SSC_URL | ||
env: | ||
DO_DEBRICKED_SCAN: inputs['debricked-sca-scan'] | ||
- uses: fortify/github-action/[email protected] | ||
if: inputs['sast-scan']=='false' && inputs['debricked-sca-scan']=='true' && env.SSC_URL | ||
|
||
branding: | ||
icon: 'shield' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
This action performs a Debricked Software Composition Analysis (SCA) scan, consisting of the following steps: | ||
|
||
* Login to Fortify SSC | ||
* Run Debricked scan | ||
* Publish Debricked scan results to Fortify SSC | ||
* Optionally wait for SSC artifact processing to complete | ||
|
||
Before running this action, please ensure that the appropriate application version has been created on SSC. Future versions of this action may add support for automating application version creation. | ||
|
||
Note that this action is explicitly meant for Debricked/SSC integration. If you wish to run a Debricked scan without publishing the results to SSC, please see the [Debricked GitHub Integration documentation](https://portal.debricked.com/integrations-48/integration-with-github-214#github-actions) | ||
|
||
{{include:action-prerequisites.md}} | ||
|
||
Apart from the general action prerequisites listed above, this specific action also requires the [Fortify SSC Parser Plugin for Debricked results](https://github.com/fortify/fortify-ssc-parser-debricked-cyclonedx) to be installed on Fortify SSC, to allow for SSC to accept and process the Debricked scan results submitted by this action. | ||
|
||
### Action environment variable inputs | ||
|
||
{{include:env-ssc-debricked-scan.md}} | ||
|
||
{{include:env-setup.md}} | ||
|
||
### Sample usage | ||
|
||
The sample workflow below demonstrates how to configure the action for running a Debricked scan and publishing the results to Fortify SSC. | ||
|
||
```yaml | ||
steps: | ||
- name: Check out source code | ||
uses: actions/checkout@v4 | ||
- name: Run Debricked Scan | ||
uses: fortify/github-action/ssc-debricked-scan@{{var:action-major-version}} | ||
env: | ||
{{include:nocomments.env-ssc-debricked-scan-sample.md}} | ||
{{include:nocomments.env-setup-sample.md}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{include:env-ssc-connection.md}} | ||
|
||
{{include:env-ssc-login.md}} | ||
|
||
**`DEBRICKED_TOKEN`** - REQUIRED | ||
See the [Generate access token](https://docs.debricked.com/product/administration/generate-access-token) section in the Debricked documentation for details on how to generate this token. | ||
|
||
{{include:env-ssc-appversion.md}} | ||
|
||
**`DO_WAIT`** - OPTIONAL | ||
By default, this action will complete immediately after Debricked scan results have been uploaded to SSC. To have the workflow wait until the Debricked results have been processed by SSC (potentially failing if the results cannot be successfully processed), set the `DO_WAIT` environment variable to `true`. | ||
|
||
For consistency with other actions, `DO_WAIT` is implied if `DO_EXPORT` is set to `true`, but since GitHub doesn't support importing Software Composition Analysis results, Debricked results will not be published to GitHub even if `DO_EXPORT` is set to `true`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
{{include:env-ssc-connection.md}} | ||
|
||
**`EXTRA_SSC_LOGIN_OPTS`** - OPTIONAL | ||
Extra SSC login options, for example for disabling SSL checks or changing connection time-outs; see [`fcli ssc session login` documentation]({{var:fcli-doc-base-url}}/manpage/fcli-ssc-session-login.html). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
{{include:nocomments.env-ssc-connection-sample.md}} | ||
SC_SAST_TOKEN: ${{secrets.CLIENT_AUTH_TOKEN}} | ||
# EXTRA_SC_SAST_LOGIN_OPTS: --socket-timeout=60s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
{{include:nocomments.env-ssc-connection-sample.md}} | ||
{{include:nocomments.env-ssc-login-sample.md}} | ||
{{include:nocomments.env-sc-sast-login-sample.md}} | ||
{{include:nocomments.env-ssc-appversion-sample.md}} | ||
{{include:nocomments.env-package-sample.md}} | ||
SC_SAST_SENSOR_VERSION: 23.2 | ||
# DO_DEBRICKED_SCAN: true # Or debricked-sca-scan input on top-level action | ||
# DEBRICKED_TOKEN: ${{secrets.DEBRICKED_TOKEN}} | ||
# DO_WAIT: true | ||
# DO_EXPORT: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{{include:nocomments.env-ssc-connection-sample.md}} | ||
{{include:nocomments.env-ssc-login-sample.md}} | ||
{{include:nocomments.env-ssc-appversion-sample.md}} | ||
DEBRICKED_TOKEN: ${{secrets.DEBRICKED_TOKEN}} | ||
# DO_WAIT: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# EXTRA_SSC_LOGIN_OPTS: --socket-timeout=60s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
doc-resources/templates/ssc-debricked-scan/README.template.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# fortify/github-action/ssc-debricked-scan@{{var:action-major-version}} | ||
|
||
{{include:p.marketing-intro.md}} | ||
|
||
{{include:action-ssc-debricked-scan.md}} | ||
|
||
{{include:h2.support.md}} | ||
|
||
--- | ||
|
||
*[This document was auto-generated; do not edit by hand](https://github.com/fortify/shared-doc-resources/blob/main/USAGE.md)* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,8 @@ runs: | |
- uses: fortify/github-action/internal/[email protected] | ||
if: ${{ !env._FOD_LOGGED_IN }} | ||
with: | ||
cwd: ${{ github.action_path }} | ||
script: ./fod-login.sh | ||
post: ./fod-logout.sh | ||
script: fod-login.sh | ||
post: fod-logout.sh | ||
|
||
branding: | ||
icon: 'shield' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# fortify/github-action/internal/run-script | ||
|
||
This action can run any of the scripts located in the `scripts` directory of this action, including the ability to run post-job scripts, for example to handle session logout. | ||
|
||
```yaml | ||
- uses: fortify/github-action/internal/run-script@v1 | ||
with: | ||
script: <script name> | ||
post: <post-job script name> | ||
``` | ||
Originally, the idea was to have these scripts located in each individual action directory, for example having `ssc-login.sh` and `ssc-logout.sh` scripts located in the `internal/ssc-login` directory. However, this proved to be difficult/impossible: | ||
|
||
- As scripts need to be run using `bash` (also on Windows), we need to convert `${{github.action_path}}` (which may include drive letter and backslashes on Windows) to `bash` format; an example of how this can be done is shown in `action.yml`. | ||
- GitHub lazily evaluates action inputs when running the post-job actions, but doesn't re-run any steps used to generate those inputs. | ||
|
||
So, suppose we'd generate a `BASH_ACTION_PATH` environment variable that contains `${{github.action_path}}` in `bash` format, we'd expect to be able to use something like: | ||
|
||
```yaml | ||
- uses: fortify/github-action/internal/run-script/[email protected] | ||
with: | ||
script: ${{ env.BASH_ACTION_PATH }}/ssc-login.sh | ||
post: ${{ env.BASH_ACTION_PATH }}/ssc-logout.sh | ||
``` | ||
|
||
This works fine for `script:`, but the `post:` script would use whatever the value of `BASH_ACTION_PATH` is during post-job execution. So, if we'd run both `ssc-login` and `sc-sast-login` actions, the post-job action would try to run `..../internal/sc-sast-login/ssc-logout.sh`, which would fail because of the incorrect directory name. | ||
|
||
Several work-arounds were tried, but failed. Only way that this would likely work is to have the calling action pass something like a static action id, which would then be used by this action to set a `POST_<id>_SCRIPT=${{inputs.POST}}` environment variable. During post-job execution, we wouldn't look at any actual inputs, but instead just execute the script identified in the `POST_<id>_SCRIPT` environment variable. | ||
|
||
Apart from hosting the scripts together with the action that executes them, another advantage of such an id is that we can also provide out-of-the-box support for run-once actions, like the various `login` actions; this is currently handled by setting an environment variable in the `*-login.sh` and `*-logout.sh` scripts. As we may also have scripts that may need to be run multiple times, we should control this through a `run-once: true|false` input. | ||
|
||
Disadvantage, apart from slightly more complex implementation, is that each caller of this `run-script` action would also need to provide the value of `${{ github.action_path }}` as an input to this action, in order to have this action determine appropriate script location. | ||
|
||
|
Oops, something went wrong.