From 803c661a607a5c4ef3452f8c0ed1d2dc12600e4f Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Tue, 4 Jun 2024 07:54:33 +0200 Subject: [PATCH] feat: Add ability to run and import Debricked scans into SSC (closes #41) --- README.md | 49 +++++++++++++++---- action.yml | 10 +++- doc-resources/env-sc-sast-login.md | 2 - doc-resources/env-sc-sast-scan.md | 9 ++++ doc-resources/env-ssc-login.md | 2 - doc-resources/repo-readme.md | 5 +- internal/fod-login/action.yml | 5 +- internal/run-script/README.md | 34 +++++++++++++ internal/run-script/action.yml | 31 +++++++----- internal/run-script/js/action.yml | 19 +++++++ internal/run-script/js/main.js | 3 ++ .../run-script/{ => js}/package-lock.json | 0 internal/run-script/js/post.js | 3 ++ internal/run-script/js/util.js | 12 +++++ internal/run-script/main.js | 22 --------- .../scripts/common.sh} | 11 ++--- .../scripts}/fod-login.sh | 14 ++---- internal/run-script/scripts/fod-logout.sh | 8 +++ .../scripts/sc-sast-and-debricked-scan.sh | 33 +++++++++++++ .../scripts}/sc-sast-login.sh | 14 ++---- internal/run-script/scripts/sc-sast-logout.sh | 8 +++ .../scripts}/ssc-login.sh | 14 ++---- .../scripts}/ssc-logout.sh | 14 ++---- internal/sc-sast-login/action.yml | 5 +- internal/sc-sast-login/sc-sast-logout.sh | 16 ------ internal/ssc-login/action.yml | 5 +- sc-sast-scan/README.md | 22 +++++++-- sc-sast-scan/action.yml | 12 ++--- 28 files changed, 246 insertions(+), 136 deletions(-) create mode 100644 internal/run-script/README.md create mode 100644 internal/run-script/js/action.yml create mode 100644 internal/run-script/js/main.js rename internal/run-script/{ => js}/package-lock.json (100%) create mode 100644 internal/run-script/js/post.js create mode 100644 internal/run-script/js/util.js delete mode 100644 internal/run-script/main.js rename internal/{fod-login/fod-logout.sh => run-script/scripts/common.sh} (52%) mode change 100755 => 100644 rename internal/{fod-login => run-script/scripts}/fod-login.sh (64%) create mode 100755 internal/run-script/scripts/fod-logout.sh create mode 100755 internal/run-script/scripts/sc-sast-and-debricked-scan.sh rename internal/{sc-sast-login => run-script/scripts}/sc-sast-login.sh (50%) create mode 100755 internal/run-script/scripts/sc-sast-logout.sh rename internal/{ssc-login => run-script/scripts}/ssc-login.sh (58%) rename internal/{ssc-login => run-script/scripts}/ssc-logout.sh (58%) delete mode 100755 internal/sc-sast-login/sc-sast-logout.sh diff --git a/README.md b/README.md index 96075d0..77281c9 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,10 @@ This action assumes the standard software packages as provided by GitHub-hosted **`sast-scan`** - OPTIONAL When set to true, the action will run a SAST scan on either Fortify on Demand (if the `FOD_URL` environment variable has been specified), or on ScanCentral SAST (if the `SSC_URL` environment variable has been specified). This includes packaging the source code, running the scan, and optionally reporting SAST scan results back into GitHub. -If not specified or when set to false, no SAST scan will be performed. For now, this means that the action will complete without doing any work. Future versions of this action may provide additional inputs, for example allowing you to run a dynamic application security testing (DAST) scan instead of a SAST scan. +If not specified or when set to false, no SAST scan will be performed. For now, this means that the action will complete without doing any work. Future versions of this action may provide additional inputs, for example allowing you to run a dynamic application security testing (DAST) scan instead of a SAST scan, or to run a Debricked-only scan (see below). + +**`debricked-sca-scan`** - OPTIONAL +(Not applicable to Fortify on Demand) When set to true, the action will run a Debricked Software Composition Analysis (SCA) scan. This is only effective when `sast-scan` is also set to `true` and the `SSC_URL` environment variable has been specified, in which case both a ScanCentral SAST scan and Debricked scan will be performed and published to SSC. ### Action environment variable inputs @@ -158,10 +161,6 @@ This environment variable allows for overriding the default tool definitions, po - - - - **`SSC_URL`** - REQUIRED @@ -176,6 +175,18 @@ Required when authenticating with SSC user credentials. + + + +**`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](https://fortify.github.io/fcli/v2.3.0//manpage/fcli-ssc-session-login.html). + + + + + + + **`SC_SAST_TOKEN`** - REQUIRED Required: ScanCentral SAST Client Authentication Token for authenticating with ScanCentral SAST Controller. @@ -185,6 +196,12 @@ Extra ScanCentral SAST login options, for example for disabling SSL checks or ch +**`DO_DEBRICKED_SCAN`** - OPTIONAL +If set to `true`, this action will run both ScanCentral SAST and Debricked Software Composition Analysis (SCA) scans and publish both results to SSC. This is equivalent to setting the `debricked-sca-scan` input on the top-level `fortify/github-action` action. + +**`DEBRICKED_TOKEN`** - REQUIRED* +Required when performing a Debricked Software Composition Analysis scan; 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. + @@ -742,10 +759,6 @@ This action assumes the standard software packages as provided by GitHub-hosted - - - - **`SSC_URL`** - REQUIRED @@ -760,6 +773,18 @@ Required when authenticating with SSC user credentials. + + + +**`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](https://fortify.github.io/fcli/v2.3.0//manpage/fcli-ssc-session-login.html). + + + + + + + **`SC_SAST_TOKEN`** - REQUIRED Required: ScanCentral SAST Client Authentication Token for authenticating with ScanCentral SAST Controller. @@ -769,6 +794,12 @@ Extra ScanCentral SAST login options, for example for disabling SSL checks or ch +**`DO_DEBRICKED_SCAN`** - OPTIONAL +If set to `true`, this action will run both ScanCentral SAST and Debricked Software Composition Analysis (SCA) scans and publish both results to SSC. This is equivalent to setting the `debricked-sca-scan` input on the top-level `fortify/github-action` action. + +**`DEBRICKED_TOKEN`** - REQUIRED* +Required when performing a Debricked Software Composition Analysis scan; 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. + diff --git a/action.yml b/action.yml index 038a169..ae118d4 100644 --- a/action.yml +++ b/action.yml @@ -6,13 +6,19 @@ 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/fod-sast-scan@feat-1.3.0 - if: inputs['sast-scan']=='true' && env.FOD_URL + if: inputs['sast-scan']=='true' && env.FOD_URL - uses: fortify/github-action/sc-sast-scan@feat-1.3.0 - if: inputs['sast-scan']=='true' && env.SSC_URL + if: inputs['sast-scan']=='true' && env.SSC_URL + env: + DO_DEBRICKED_SCAN: inputs['debricked-sca-scan'] branding: icon: 'shield' diff --git a/doc-resources/env-sc-sast-login.md b/doc-resources/env-sc-sast-login.md index 527caff..3f93b91 100644 --- a/doc-resources/env-sc-sast-login.md +++ b/doc-resources/env-sc-sast-login.md @@ -1,5 +1,3 @@ -{{include:env-ssc-connection.md}} - **`SC_SAST_TOKEN`** - REQUIRED Required: ScanCentral SAST Client Authentication Token for authenticating with ScanCentral SAST Controller. diff --git a/doc-resources/env-sc-sast-scan.md b/doc-resources/env-sc-sast-scan.md index 693169d..6a6455a 100644 --- a/doc-resources/env-sc-sast-scan.md +++ b/doc-resources/env-sc-sast-scan.md @@ -1,6 +1,15 @@ +{{include:env-ssc-connection.md}} + +{{include:env-ssc-login.md}} {{include:env-sc-sast-login.md}} +**`DO_DEBRICKED_SCAN`** - OPTIONAL +If set to `true`, this action will run both ScanCentral SAST and Debricked Software Composition Analysis (SCA) scans and publish both results to SSC. This is equivalent to setting the `debricked-sca-scan` input on the top-level `fortify/github-action` action. + +**`DEBRICKED_TOKEN`** - REQUIRED* +Required when performing a Debricked Software Composition Analysis scan; 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}} {{include:env-package.md}} diff --git a/doc-resources/env-ssc-login.md b/doc-resources/env-ssc-login.md index f93dba5..89e4eea 100644 --- a/doc-resources/env-ssc-login.md +++ b/doc-resources/env-ssc-login.md @@ -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). \ No newline at end of file diff --git a/doc-resources/repo-readme.md b/doc-resources/repo-readme.md index 6d42ae9..63c1322 100644 --- a/doc-resources/repo-readme.md +++ b/doc-resources/repo-readme.md @@ -39,7 +39,10 @@ The primary `fortify/github-action` action currently allows for running SAST sca **`sast-scan`** - OPTIONAL When set to true, the action will run a SAST scan on either Fortify on Demand (if the `FOD_URL` environment variable has been specified), or on ScanCentral SAST (if the `SSC_URL` environment variable has been specified). This includes packaging the source code, running the scan, and optionally reporting SAST scan results back into GitHub. -If not specified or when set to false, no SAST scan will be performed. For now, this means that the action will complete without doing any work. Future versions of this action may provide additional inputs, for example allowing you to run a dynamic application security testing (DAST) scan instead of a SAST scan. +If not specified or when set to false, no SAST scan will be performed. For now, this means that the action will complete without doing any work. Future versions of this action may provide additional inputs, for example allowing you to run a dynamic application security testing (DAST) scan instead of a SAST scan, or to run a Debricked-only scan (see below). + +**`debricked-sca-scan`** - OPTIONAL +(Not applicable to Fortify on Demand) When set to true, the action will run a Debricked Software Composition Analysis (SCA) scan. This is only effective when `sast-scan` is also set to `true` and the `SSC_URL` environment variable has been specified, in which case both a ScanCentral SAST scan and Debricked scan will be performed and published to SSC. ### Action environment variable inputs diff --git a/internal/fod-login/action.yml b/internal/fod-login/action.yml index 96282f3..fe6a9e6 100644 --- a/internal/fod-login/action.yml +++ b/internal/fod-login/action.yml @@ -10,9 +10,8 @@ runs: - uses: fortify/github-action/internal/run-script@feat-1.3.0 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' diff --git a/internal/run-script/README.md b/internal/run-script/README.md new file mode 100644 index 0000000..751bf10 --- /dev/null +++ b/internal/run-script/README.md @@ -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: