Skip to content

Commit

Permalink
chore: Improve package action
Browse files Browse the repository at this point in the history
fix: Add `DO_PACKAGE_DEBUG` setting to enable debug logging and publish package.zip & logs as job artifacts
  • Loading branch information
rsenden committed Jan 14, 2025
1 parent 3318a1a commit ed7a2bd
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 36 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The standard workflow provided by this GitHub Action allows for running a Static
# SETUP_ACTION: https://scm.my.org/shared-repos/fcli-actions/setup.yaml
# SETUP_EXTRA_OPTS: --copy-from "${{ github.repository }}:${{ github.event.repository.default_branch }}"
# SC_CLIENT_VERSION: 24.2
# DO_PACKAGE_DEBUG: true
# PACKAGE_EXTRA_OPTS: -oss -bt mvn
# FOD_SAST_SCAN_EXTRA_OPTS:
# DO_WAIT: true
Expand Down Expand Up @@ -107,6 +108,7 @@ This section lists the environment variables that can be specified in the `env:`
| FOD_RELEASE | Fortify on Demand release to use with this action. This can be specified either as a numeric release id, `<app-name>:<release-name>` (for non-microservices applications) or `<app-name>:<microservice-name>:<release-name>` (for microservices applications). Default value is based on repository and branch name, for example `myOrg/myRepo:myBranch`. Note that you'll need to explicitly configure `FOD_RELEASE` for microservices applications, as the default value lacks a microservice name. |
|DO_SETUP<br/>SETUP_ACTION<br/>SETUP_EXTRA_OPTS|If `DO_SETUP` is set to `true` (implied if any of the other two `SETUP_*` variables are set), the application and/or release will be automatically created if they do not yet exist and static scan settings will be configured if not configured already, using the fcli-provided [`setup-release`](https://fortify.github.io/fcli/v2.11.1/fod-actions.html#_setup_release) or, if specified, the custom fcli action specified through `SETUP_ACTION`. Extra options for the fcli action can be passed through the `SETUP_EXTRA_OPTS` environment variable. Depending on your Git workflow, it is recommended to have each newly created release copy state from the release representing your default branch by passing `--copy-from "${{ github.repository }}:${{ github.event.repository.default_branch }}"` through `SETUP_EXTRA_OPTS`. To allow the GitHub Action to create new applications, you must (also) provide the `--app-owner <user>` option through `SETUP_EXTRA_OPTS` if authenticating with client credentials. Note that if setup is enabled, `FOD_RELEASE` must be configured with a qualified release name; you cannot use release id. Please see the [Fcli Actions](#fortify-on-demand-fcli-actions) section below for more details.|
| SC_CLIENT_VERSION | By default, this action uses ScanCentral Client 24.4.0 for packaging. This environment variable allows for overriding the ScanCentral Client version used for packaging. |
|DO_PACKAGE_DEBUG| If set to true, this will enable the `-debug` option on the `scancentral` command, and store both ScanCentral logs and the `package.zip` file as job artifacts.|
|PACKAGE_EXTRA_OPTS<br/>EXTRA_PACKAGE_OPTS| By default, this action runs `scancentral package -o package.zip` to package application source code. Use `PACKAGE_EXTRA_OPTS` to specify additional packaging options, for example `PACKAGE_EXTRA_OPTS: -bt mvn -bf <custom build file>`. See [Command-line options for the package command](https://www.microfocus.com/documentation/fortify-software-security-center/2440/SC_SAST_Help_24.4.0/index.htm#cli/package-cmd.htm) for more information on available options. Note that `EXTRA_PACKAGE_OPTS` is deprecated; please use `PACKAGE_EXTRA_OPTS`.|
|FOD_SAST_SCAN_EXTRA_OPTS<br/>EXTRA_FOD_SAST_SCAN_OPTS|Extra SAST scan options; see [`fcli fod sast-scan start` documentation](https://fortify.github.io/fcli/v2.11.1//manpage/fcli-fod-sast-scan-start.html). Note that `EXTRA_FOD_SAST_SCAN_OPTS` is deprecated; please use `FOD_SAST_SCAN_EXTRA_OPTS`.|
| DO_WAIT | By default, this action will not wait until scans have been completed. To have the workflow wait until all scans have been completed, set the `DO_WAIT` environment variable to `true`. Note that some other environment variables imply `DO_WAIT`, for example when exporting vulnerability data or generating job summaries. This behavior is documented in the applicable environment variable descriptions. |
Expand Down Expand Up @@ -199,6 +201,7 @@ The standard workflow provided by this GitHub Action allows for running a static
# SETUP_ACTION: https://scm.my.org/shared-repos/fcli-actions/setup.yaml
# SETUP_EXTRA_OPTS: --on-unsigned=ignore
# SC_CLIENT_VERSION: 24.2
# DO_PACKAGE_DEBUG: true
# PACKAGE_EXTRA_OPTS: -oss -bt mvn
SC_SAST_SENSOR_VERSION: 24.4.0
# EXTRA_SC_SAST_SCAN_OPTS:
Expand Down Expand Up @@ -243,6 +246,7 @@ This section lists the environment variables that can be specified in the `env:`
|SSC_APPVERSION|Fortify SSC application version to use with this action. This can be specified either as a numeric application version id, or by providing application and version name in the format `<app-name>:<version-name>`. Default value is based on repository and branch name, for example `myOrg/myRepo:myBranch`.|
|DO_SETUP<br/>SETUP_ACTION<br/>SETUP_EXTRA_OPTS|If `DO_SETUP` is set to `true` (implied if any of the other two `SETUP_*` variables are set), the SSC application version will be automatically created if they do not yet exist, using the fcli-provided [`setup-appversion`](https://fortify.github.io/fcli/v2.11.1/ssc-actions.html#_setup_appversion) or, if specified, the custom fcli action specified through `SETUP_ACTION`. Extra options for the fcli action can be passed through the `SETUP_EXTRA_OPTS` environment variable, for example to copy state from an existing application version using the `--copy-from` option, or to allow an unsigned custom action to be used. Note that if setup is enabled, `SSC_APPVERSION` must be configured with a qualified application version name; you cannot use application version id. Please see the [SSC Fcli Actions](#ssc-fcli-actions) section below for more details.|
| SC_CLIENT_VERSION | By default, this action uses ScanCentral Client 24.4.0 for packaging. This environment variable allows for overriding the ScanCentral Client version used for packaging. |
|DO_PACKAGE_DEBUG| If set to true, this will enable the `-debug` option on the `scancentral` command, and store both ScanCentral logs and the `package.zip` file as job artifacts.|
|PACKAGE_EXTRA_OPTS<br/>EXTRA_PACKAGE_OPTS| By default, this action runs `scancentral package -o package.zip` to package application source code. Use `PACKAGE_EXTRA_OPTS` to specify additional packaging options, for example `PACKAGE_EXTRA_OPTS: -bt mvn -bf <custom build file>`. See [Command-line options for the package command](https://www.microfocus.com/documentation/fortify-software-security-center/2440/SC_SAST_Help_24.4.0/index.htm#cli/package-cmd.htm) for more information on available options. Note that `EXTRA_PACKAGE_OPTS` is deprecated; please use `PACKAGE_EXTRA_OPTS`.|
|**SC_SAST_SENSOR_VERSION**|Version of the ScanCentral SAST sensor on which the scan should be performed; see [`fcli sc-sast scan start` documentation](https://fortify.github.io/fcli/v2.11.1//manpage/fcli-sc-sast-scan-start.html) for details.|
|SC_SAST_SCAN_EXTRA_OPTS<br/>EXTRA_SC_SAST_SCAN_OPTS|Extra ScanCentral SAST scan options; see [`fcli sc-sast scan start` documentation](https://fortify.github.io/fcli/v2.11.1//manpage/fcli-sc-sast-scan-start.html). Note that `EXTRA_SC_SAST_SCAN_OPTS` is deprecated; please use `SC_SAST_SCAN_EXTRA_OPTS`.|
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ inputs:
runs:
using: composite
steps:
- uses: fortify/github-action/fod-sast-scan@main
- uses: fortify/github-action/fod-sast-scan@feat-package-debug
if: inputs['sast-scan']=='true' && env.FOD_URL
env:
DO_DEBRICKED_SCAN: ${{ inputs['debricked-sca-scan'] }}
- uses: fortify/github-action/sc-sast-scan@main
- uses: fortify/github-action/sc-sast-scan@feat-package-debug
if: inputs['sast-scan']=='true' && env.SSC_URL
env:
DO_DEBRICKED_SCAN: ${{ inputs['debricked-sca-scan'] }}
- uses: fortify/github-action/ssc-debricked-scan@main
- uses: fortify/github-action/ssc-debricked-scan@feat-package-debug
if: inputs['sast-scan']=='false' && inputs['debricked-sca-scan']=='true' && env.SSC_URL

branding:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
|DO_PACKAGE_DEBUG| If set to true, this will enable the `-debug` option on the `scancentral` command, and store both ScanCentral logs and the `package.zip` file as job artifacts.|
|PACKAGE_EXTRA_OPTS<br/>EXTRA_PACKAGE_OPTS| By default, this action runs `scancentral package -o package.zip` to package application source code. Use `PACKAGE_EXTRA_OPTS` to specify additional packaging options, for example `PACKAGE_EXTRA_OPTS: -bt mvn -bf <custom build file>`. See [Command-line options for the package command]({{var:sc-client-doc-base-url}}#cli/package-cmd.htm) for more information on available options. Note that `EXTRA_PACKAGE_OPTS` is deprecated; please use `PACKAGE_EXTRA_OPTS`.|
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# DO_PACKAGE_DEBUG: true
# PACKAGE_EXTRA_OPTS: -oss -bt mvn
8 changes: 4 additions & 4 deletions fod-export/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ author: 'Fortify'
runs:
using: composite
steps:
- uses: fortify/github-action/internal/set-fod-var-defaults@main
- uses: fortify/github-action/setup@main
- uses: fortify/github-action/internal/set-fod-var-defaults@feat-package-debug
- uses: fortify/github-action/setup@feat-package-debug
with:
export-path: false
fcli: action-default
- uses: fortify/github-action/internal/fod-login@main
- uses: fortify/github-action/internal/run-script@main
- uses: fortify/github-action/internal/fod-login@feat-package-debug
- uses: fortify/github-action/internal/run-script@feat-package-debug
with:
script: export.sh
env:
Expand Down
2 changes: 2 additions & 0 deletions fod-sast-scan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The sample workflow below demonstrates how to configure the action for running a
# SETUP_ACTION: https://scm.my.org/shared-repos/fcli-actions/setup.yaml
# SETUP_EXTRA_OPTS: --copy-from "${{ github.repository }}:${{ github.event.repository.default_branch }}"
# SC_CLIENT_VERSION: 24.2
# DO_PACKAGE_DEBUG: true
# PACKAGE_EXTRA_OPTS: -oss -bt mvn
# FOD_SAST_SCAN_EXTRA_OPTS:
# DO_DEBRICKED_SCAN: true
Expand Down Expand Up @@ -98,6 +99,7 @@ This section lists the environment variables that can be specified in the `env:`
| FOD_RELEASE | Fortify on Demand release to use with this action. This can be specified either as a numeric release id, `<app-name>:<release-name>` (for non-microservices applications) or `<app-name>:<microservice-name>:<release-name>` (for microservices applications). Default value is based on repository and branch name, for example `myOrg/myRepo:myBranch`. Note that you'll need to explicitly configure `FOD_RELEASE` for microservices applications, as the default value lacks a microservice name. |
|DO_SETUP<br/>SETUP_ACTION<br/>SETUP_EXTRA_OPTS|If `DO_SETUP` is set to `true` (implied if any of the other two `SETUP_*` variables are set), the application and/or release will be automatically created if they do not yet exist and static scan settings will be configured if not configured already, using the fcli-provided [`setup-release`](https://fortify.github.io/fcli/v2.11.1/fod-actions.html#_setup_release) or, if specified, the custom fcli action specified through `SETUP_ACTION`. Extra options for the fcli action can be passed through the `SETUP_EXTRA_OPTS` environment variable. Depending on your Git workflow, it is recommended to have each newly created release copy state from the release representing your default branch by passing `--copy-from "${{ github.repository }}:${{ github.event.repository.default_branch }}"` through `SETUP_EXTRA_OPTS`. To allow the GitHub Action to create new applications, you must (also) provide the `--app-owner <user>` option through `SETUP_EXTRA_OPTS` if authenticating with client credentials. Note that if setup is enabled, `FOD_RELEASE` must be configured with a qualified release name; you cannot use release id. Please see the [Fcli Actions](#fortify-on-demand-fcli-actions) section below for more details.|
| SC_CLIENT_VERSION | By default, this action uses ScanCentral Client 24.4.0 for packaging. This environment variable allows for overriding the ScanCentral Client version used for packaging. |
|DO_PACKAGE_DEBUG| If set to true, this will enable the `-debug` option on the `scancentral` command, and store both ScanCentral logs and the `package.zip` file as job artifacts.|
|PACKAGE_EXTRA_OPTS<br/>EXTRA_PACKAGE_OPTS| By default, this action runs `scancentral package -o package.zip` to package application source code. Use `PACKAGE_EXTRA_OPTS` to specify additional packaging options, for example `PACKAGE_EXTRA_OPTS: -bt mvn -bf <custom build file>`. See [Command-line options for the package command](https://www.microfocus.com/documentation/fortify-software-security-center/2440/SC_SAST_Help_24.4.0/index.htm#cli/package-cmd.htm) for more information on available options. Note that `EXTRA_PACKAGE_OPTS` is deprecated; please use `PACKAGE_EXTRA_OPTS`.|
|FOD_SAST_SCAN_EXTRA_OPTS<br/>EXTRA_FOD_SAST_SCAN_OPTS|Extra SAST scan options; see [`fcli fod sast-scan start` documentation](https://fortify.github.io/fcli/v2.11.1//manpage/fcli-fod-sast-scan-start.html). Note that `EXTRA_FOD_SAST_SCAN_OPTS` is deprecated; please use `FOD_SAST_SCAN_EXTRA_OPTS`.|
|DO_DEBRICKED_SCAN|Configure the static scan to also run an open-source scan. Depending on Fortify on Demand configuration, this may be either a Debricked or a Sonatype scan. Effectively, this adds dependency data to the scan payload, and enables the open-source scan setting in the Fortify on Demand scan configuration. Note that any existing scan configuration will not be updated, so if the scan has already been configured in Fortify on Demand, an open-source scan will only be performed if previously enabled in the existing scan configuration.|
Expand Down
12 changes: 6 additions & 6 deletions fod-sast-scan/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ author: 'Fortify'
runs:
using: composite
steps:
- uses: fortify/github-action/internal/set-fod-var-defaults@main
- uses: fortify/github-action/setup@main
- uses: fortify/github-action/internal/set-fod-var-defaults@feat-package-debug
- uses: fortify/github-action/setup@feat-package-debug
with:
export-path: false
fcli: action-default
- uses: fortify/github-action/internal/fod-login@main
- uses: fortify/github-action/package@main
- uses: fortify/github-action/internal/run-script@main
- uses: fortify/github-action/internal/fod-login@feat-package-debug
- uses: fortify/github-action/package@feat-package-debug
- uses: fortify/github-action/internal/run-script@feat-package-debug
with:
script: fod-scan.sh
env:
DO_SAST_SCAN: true # Not used for now
GITHUB_TOKEN: ${{ github.token }}
- if: env.DO_EXPORT == 'true'
uses: fortify/github-action/fod-export@main
uses: fortify/github-action/fod-export@feat-package-debug

branding:
icon: 'shield'
Expand Down
2 changes: 1 addition & 1 deletion internal/fod-login/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ runs:
# If not run before: check preconditions, run fcli login command, and run
# post-job fcli logout command.
# Note that the calling action/workflow is responsible for installing fcli
- uses: fortify/github-action/internal/run-script@main
- uses: fortify/github-action/internal/run-script@feat-package-debug
if: ${{ !env._FOD_LOGGED_IN }}
with:
script: fod-login.sh
Expand Down
2 changes: 1 addition & 1 deletion internal/run-script/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runs:
- run: echo "TEMP_DIR=$(pwd)" >> $GITHUB_ENV
shell: bash
working-directory: ${{ runner.temp }}
- uses: fortify/github-action/internal/run-script/js@main
- uses: fortify/github-action/internal/run-script/js@feat-package-debug
with:
dir: ${{ env._RUN_SCRIPTS_DIR }}
script: ${{ inputs.script }}
Expand Down
6 changes: 5 additions & 1 deletion internal/run-script/scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
requireScanCentralClient
checkRequirements

run "PACKAGE" "${SC_CLIENT_CMD}" package -o package.zip __expand:EXTRA_PACKAGE_OPTS __expand:PACKAGE_EXTRA_OPTS
if [[ "${DO_PACKAGE_DEBUG}" == "true" ]]; then
_SC_CLIENT_DEBUG_OPT=-debug
fi

run "PACKAGE" "${SC_CLIENT_CMD}" ${_SC_CLIENT_DEBUG_OPT} package -o package.zip __expand:EXTRA_PACKAGE_OPTS __expand:PACKAGE_EXTRA_OPTS
printRunSummary
failOnError
2 changes: 1 addition & 1 deletion internal/sc-sast-login/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:
# If not run before: check preconditions, run fcli login command, and run
# post-job fcli logout command.
# Note that the calling action/workflow is responsible for installing fcli
- uses: fortify/github-action/internal/run-script@main
- uses: fortify/github-action/internal/run-script@feat-package-debug
if: ${{ !env._SC_SAST_LOGGED_IN }}
with:
script: sc-sast-login.sh
Expand Down
2 changes: 1 addition & 1 deletion internal/ssc-login/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ runs:
# If not run before: check preconditions, run fcli login command, and run
# post-job fcli logout command.
# Note that the calling action/workflow is responsible for installing fcli
- uses: fortify/github-action/internal/run-script@main
- uses: fortify/github-action/internal/run-script@feat-package-debug
if: ${{ !env._SSC_LOGGED_IN }}
with:
script: ssc-login.sh
Expand Down
2 changes: 2 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ The sample workflow below demonstrates how to configure the action packaging app
uses: fortify/github-action/package@v1
env:
# SC_CLIENT_VERSION: 24.2
# DO_PACKAGE_DEBUG: true
# PACKAGE_EXTRA_OPTS: -oss -bt mvn
# TOOL_DEFINITIONS: https://ftfy.mycompany.com/tool-definitions/v1/tool-definitions.yaml.zip
```
Expand All @@ -57,6 +58,7 @@ This section lists the environment variables that can be specified in the `env:`
| Environment variable | Description |
| :--- | :--- |
| SC_CLIENT_VERSION | By default, this action uses ScanCentral Client 24.4.0 for packaging. This environment variable allows for overriding the ScanCentral Client version used for packaging. |
|DO_PACKAGE_DEBUG| If set to true, this will enable the `-debug` option on the `scancentral` command, and store both ScanCentral logs and the `package.zip` file as job artifacts.|
|PACKAGE_EXTRA_OPTS<br/>EXTRA_PACKAGE_OPTS| By default, this action runs `scancentral package -o package.zip` to package application source code. Use `PACKAGE_EXTRA_OPTS` to specify additional packaging options, for example `PACKAGE_EXTRA_OPTS: -bt mvn -bf <custom build file>`. See [Command-line options for the package command](https://www.microfocus.com/documentation/fortify-software-security-center/2440/SC_SAST_Help_24.4.0/index.htm#cli/package-cmd.htm) for more information on available options. Note that `EXTRA_PACKAGE_OPTS` is deprecated; please use `PACKAGE_EXTRA_OPTS`.|
| TOOL_DEFINITIONS | Fortify tool definitions are used by this GitHub Action to determine available versions, download location and other details of various Fortify-related tools, as required for action execution. By default, the Fortify-provided tool definitions hosted at https://github.com/fortify/tool-definitions/releases/tag/v1 will be used.<br/><br/>This environment variable allows for overriding the default tool definitions, pointing to either a URL or local (workspace) file. For example, if GitHub workflows are not allowed to download tools from their public internet locations, customers may host the tool installation bundles on an internal server, together with a customized tool definitions bundle that lists the alternative download URLs. |

Expand Down
Loading

0 comments on commit ed7a2bd

Please sign in to comment.