Skip to content

Commit c164a3b

Browse files
add support for scan triggers (#12)
* add support for scan triggers * wrong logic * update default env vars when trigger
1 parent 74c2fb3 commit c164a3b

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

action.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ inputs:
3232
default: ""
3333
registry_module:
3434
description: "Module within the scanner registry to execute"
35-
required: true
35+
default: ""
3636
scanner_id:
3737
description: "Optional identifier to uniquely identify the scanner"
3838
default: ""
@@ -51,6 +51,9 @@ inputs:
5151
scan_main_timeout:
5252
description: "Maximum amount of time a main scan should complete in"
5353
default: ""
54+
trigger_id:
55+
description: "Boost API workflow trigger id"
56+
default: ""
5457
runs:
5558
using: "composite"
5659
steps:
@@ -73,3 +76,4 @@ runs:
7376
BOOST_SCAN_PATH: ${{ inputs.scan_path }}
7477
BOOST_SCANNER_ID: ${{ inputs.scanner_id }}
7578
BOOST_SCANNER_REGISTRY_MODULE: ${{ inputs.registry_module }}
79+
BOOST_TRIGGER_ID: ${{ inputs.trigger_id }}

lib/scan.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@ init.config ()
2020
{
2121
log.info "initializing configuration"
2222

23-
export BOOST_DIFF_SCAN_TIMEOUT=${BOOST_DIFF_SCAN_TIMEOUT:-${BOOST_SCAN_TIMEOUT:-}}
24-
2523
export BOOST_TMP_DIR=${BOOST_TMP_DIR:-${WORKSPACE_TMP:-${TMPDIR:-/tmp}}}
2624
export BOOST_EXE=${BOOST_EXE:-${BOOST_TMP_DIR}/boost-cli/latest}
2725

2826
export BOOST_CLI_URL=${BOOST_CLI_URL:-https://assets.build.boostsecurity.io}
2927
BOOST_CLI_URL=${BOOST_CLI_URL%*/}
3028
export BOOST_DOWNLOAD_URL=${BOOST_DOWNLOAD_URL:-${BOOST_CLI_URL}/boost-cli/get-boost-cli}
3129

32-
export BOOST_GIT_MAIN_BRANCH
33-
BOOST_GIT_MAIN_BRANCH=${BOOST_GIT_MAIN_BRANCH:-$(git.ls_remote)}
30+
if [ -z "${BOOST_TRIGGER_ID:-}" ]; then
31+
export BOOST_DIFF_SCAN_TIMEOUT=${BOOST_DIFF_SCAN_TIMEOUT:-${BOOST_SCAN_TIMEOUT:-}}
32+
33+
export BOOST_GIT_MAIN_BRANCH
34+
BOOST_GIT_MAIN_BRANCH=${BOOST_GIT_MAIN_BRANCH:-$(git.ls_remote)}
35+
fi
3436

3537
init.ci.config
3638
}
@@ -51,8 +53,13 @@ main.scan ()
5153
init.config
5254
init.cli
5355

54-
# shellcheck disable=SC2086
55-
exec ${BOOST_EXE} scan repo ${BOOST_CLI_ARGUMENTS:-}
56+
if [ -n "${BOOST_TRIGGER_ID:-}" ]; then
57+
# shellcheck disable=SC2086
58+
exec ${BOOST_EXE} scan trigger ${BOOST_CLI_ARGUMENTS:-}
59+
else
60+
# shellcheck disable=SC2086
61+
exec ${BOOST_EXE} scan repo ${BOOST_CLI_ARGUMENTS:-}
62+
fi
5663
}
5764

5865
if [ "${0}" = "${BASH_SOURCE[0]}" ]; then

0 commit comments

Comments
 (0)