From df7a992c40760e394df6e1639e55fd06b925818e Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Mon, 3 Jun 2024 14:03:16 +0200 Subject: [PATCH] feat: Add ssc-scan action, supporting both SC-SAST & Debricked --- internal/fod-login/action.yml | 4 +-- internal/run-script-js/main.js | 24 ------------- internal/run-script/README.md | 34 +++++++++++++++++++ internal/run-script/action.yml | 15 +++----- .../js}/action.yml | 11 ++---- internal/run-script/js/main.js | 3 ++ .../js}/package-lock.json | 0 internal/run-script/js/post.js | 3 ++ internal/run-script/js/util.js | 12 +++++++ .../run-script/{util => scripts}/common.sh | 7 +++- .../scripts}/fod-login.sh | 3 +- .../scripts}/fod-logout.sh | 3 +- .../scripts}/sc-sast-login.sh | 3 +- .../scripts}/sc-sast-logout.sh | 3 +- .../scripts}/ssc-login.sh | 3 +- .../scripts}/ssc-logout.sh | 3 +- internal/run-script/scripts/ssc-scan.sh | 33 ++++++++++++++++++ internal/sc-sast-login/action.yml | 4 +-- internal/ssc-login/action.yml | 4 +-- ssc-scan/action.yml | 25 ++++++++++++++ 20 files changed, 140 insertions(+), 57 deletions(-) delete mode 100644 internal/run-script-js/main.js create mode 100644 internal/run-script/README.md rename internal/{run-script-js => run-script/js}/action.yml (55%) create mode 100644 internal/run-script/js/main.js rename internal/{run-script-js => 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 rename internal/run-script/{util => scripts}/common.sh (80%) rename internal/{fod-login => run-script/scripts}/fod-login.sh (84%) rename internal/{fod-login => run-script/scripts}/fod-logout.sh (70%) rename internal/{sc-sast-login => run-script/scripts}/sc-sast-login.sh (72%) rename internal/{sc-sast-login => run-script/scripts}/sc-sast-logout.sh (64%) rename internal/{ssc-login => run-script/scripts}/ssc-login.sh (80%) rename internal/{ssc-login => run-script/scripts}/ssc-logout.sh (85%) create mode 100755 internal/run-script/scripts/ssc-scan.sh create mode 100644 ssc-scan/action.yml diff --git a/internal/fod-login/action.yml b/internal/fod-login/action.yml index 82a3275..4e8963d 100644 --- a/internal/fod-login/action.yml +++ b/internal/fod-login/action.yml @@ -11,8 +11,8 @@ runs: if: ${{ !env._FOD_LOGGED_IN }} with: dir: ${{ 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-js/main.js b/internal/run-script-js/main.js deleted file mode 100644 index 57d111c..0000000 --- a/internal/run-script-js/main.js +++ /dev/null @@ -1,24 +0,0 @@ -const { spawn } = require("child_process"); -const { appendFileSync } = require("fs"); -const { EOL } = require("os"); - -function run(script) { - if ( script ) { - const dir = process.env.INPUT_DIR; - const utilDir = process.env.INPUT_UTIL; - const subprocess = spawn(`bash -c -o pipefail -v 'export UTIL_DIR=${utilDir}; ${dir}/${script}'`, - { stdio: "inherit", shell: true }); - subprocess.on("exit", (exitCode) => { - process.exitCode = exitCode; - }); - } -} - -const key = process.env.INPUT_KEY.toUpperCase(); - -if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step? - run(process.env.INPUT_POST); -} else { // Otherwise, this is the main step - appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`); - run(process.env.INPUT_SCRIPT); -} diff --git a/internal/run-script/README.md b/internal/run-script/README.md new file mode 100644 index 0000000..cfd3537 --- /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: