Skip to content

Commit 35bf046

Browse files
Merge pull request #62 from veracode/SDEVX-587
Dynamic variable + Ruby support
2 parents 44794e2 + f7fc4c2 commit 35bf046

File tree

4 files changed

+73
-8
lines changed

4 files changed

+73
-8
lines changed

.github/workflows/veracode-build-artifact-for-scanning.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,36 @@ on:
1515
event_name:
1616
required: true
1717
type: string
18+
build_runs_on:
19+
required: true
20+
type: string
21+
build_packager_image:
22+
required: true
23+
type: string
24+
build_predependency_command:
25+
required: true
26+
type: string
27+
ruby_version:
28+
required: true
29+
type: string
30+
bundle_version:
31+
required: true
32+
type: string
1833

1934
jobs:
2035
build:
21-
if: ${{ inputs.event_name == 'java-pipeline-scan' || inputs.event_name == 'java-policy-scan' || inputs.event_name == 'java-sandbox-scan' || inputs.event_name == 'unidentified-lang-pipeline-scan' || inputs.event_name == 'unidentified-lang-policy-scan' || inputs.event_name == 'unidentified-lang-sandbox-scan' || inputs.event_name == 'dot-net-pipeline-scan' || inputs.event_name == 'dot-net-policy-scan' || inputs.event_name == 'dot-net-sandbox-scan' || inputs.event_name == 'scala-pipeline-scan' || inputs.event_name == 'scala-policy-scan' || inputs.event_name == 'scala-sandbox-scan' || inputs.event_name == 'go-pipeline-scan' || inputs.event_name == 'go-policy-scan' || inputs.event_name == 'go-sandbox-scan' || inputs.event_name == 'source-code-pipeline-scan' || inputs.event_name == 'source-code-policy-scan' || inputs.event_name == 'source-code-sandbox-scan'}}
36+
if: ${{ inputs.event_name == 'java-pipeline-scan' || inputs.event_name == 'java-policy-scan' || inputs.event_name == 'java-sandbox-scan' || inputs.event_name == 'unidentified-lang-pipeline-scan' || inputs.event_name == 'unidentified-lang-policy-scan' || inputs.event_name == 'unidentified-lang-sandbox-scan' || inputs.event_name == 'dot-net-pipeline-scan' || inputs.event_name == 'dot-net-policy-scan' || inputs.event_name == 'dot-net-sandbox-scan' || inputs.event_name == 'scala-pipeline-scan' || inputs.event_name == 'scala-policy-scan' || inputs.event_name == 'scala-sandbox-scan' || inputs.event_name == 'go-pipeline-scan' || inputs.event_name == 'go-policy-scan' || inputs.event_name == 'go-sandbox-scan' || inputs.event_name == 'source-code-pipeline-scan' || inputs.event_name == 'source-code-policy-scan' || inputs.event_name == 'source-code-sandbox-scan' || inputs.event_name == 'ruby-pipeline-scan' || inputs.event_name == 'ruby-policy-scan' || inputs.event_name == 'ruby-sandbox-scan'}}
2237
uses: ./.github/workflows/veracode-default-build.yml
2338
with:
2439
repository: ${{ inputs.repository }}
2540
ref: ${{ inputs.ref }}
2641
token: ${{ inputs.token }}
42+
build_runs_on: ${{ inputs.build_runs_on }}
43+
build_packager_image: ${{ inputs.build_packager_image }}
44+
build_predependency_command: ${{ inputs.build_predependency_command }}
45+
ruby_version: ${{ inputs.ruby_version }}
46+
bundle_version: ${{ inputs.bundle_version }}
47+
event_name: ${{ inputs.event_name }}
2748

2849
build-tsql-package:
2950
if: ${{ inputs.event_name == 'tsql-pipeline-scan' || inputs.event_name == 'tsql-policy-scan' || inputs.event_name == 'tsql-sandbox-scan'}}

.github/workflows/veracode-code-analysis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ on:
2929
- java-policy-scan
3030
- unidentified-lang-pipeline-scan
3131
- unidentified-lang-policy-scan
32+
- ruby-pipeline-scan
33+
- ruby-policy-scan
3234

3335
jobs:
3436
register:
@@ -86,7 +88,11 @@ jobs:
8688
ref: ${{ github.event.client_payload.sha }}
8789
token: ${{ github.event.client_payload.token }}
8890
event_name: ${{ github.event.action }}
89-
91+
build_runs_on: ${{ github.event.client_payload.user_config.build_runs_on }}
92+
build_packager_image: ${{ github.event.client_payload.user_config.build_packager_image }}
93+
build_predependency_command: ${{ github.event.client_payload.user_config.build_predependency_command }}
94+
ruby_version: ${{ github.event.client_payload.user_config.ruby_version }}
95+
bundle_version: ${{ github.event.client_payload.user_config.bundle_version }}
9096

9197
pipeline_scan:
9298
# needs the build step before this job will start running

.github/workflows/veracode-default-build.yml

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,30 @@ on:
1111
token:
1212
required: true
1313
type: string
14+
event_name:
15+
required: true
16+
type: string
17+
build_runs_on:
18+
required: true
19+
type: string
20+
build_packager_image:
21+
required: true
22+
type: string
23+
build_predependency_command:
24+
required: true
25+
type: string
26+
ruby_version:
27+
required: true
28+
type: string
29+
bundle_version:
30+
required: true
31+
type: string
32+
1433
jobs:
1534
build:
16-
runs-on: ubuntu-latest
35+
runs-on: ${{ fromJSON(inputs.build_runs_on) }}
1736
container:
18-
image: veracode/scm-packaging:2.1.0
37+
image: ${{ inputs.build_packager_image }}
1938
env:
2039
VERACODE_API_KEY_ID: '${{ secrets.VERACODE_API_ID }}'
2140
VERACODE_API_KEY_SECRET: '${{ secrets.VERACODE_API_KEY }}'
@@ -32,19 +51,37 @@ jobs:
3251

3352
- name: Package the application
3453
id: application_package
54+
shell: bash
3555
env:
3656
VERACODE_API_KEY_ID: '${{ secrets.VERACODE_API_ID }}'
3757
VERACODE_API_KEY_SECRET: '${{ secrets.VERACODE_API_KEY }}'
3858
run: |
59+
if [[ ! -z "${{ inputs.build_predependency_command }}" ]]; then
60+
echo "Executing Pre-Build Dependency.."
61+
${{ inputs.build_predependency_command }}
62+
else
63+
echo "No Pre-Build Dependency provided."
64+
fi
65+
if [[ "${{ inputs.event_name }}" == *"ruby"* ]]; then
66+
source /etc/profile.d/rvm.sh
67+
rvm pkg install openssl
68+
rvm install ruby-${{ inputs.ruby_version }}
69+
fi
70+
working_path=`pwd`
71+
echo "working_dir=$working_path" >> "$GITHUB_OUTPUT"
3972
cd veracode-helper/helper/cli
4073
cliFile=$(ls -1 . | head -n 1)
4174
cliFileName=$(echo "$cliFile" | cut -c 1-$((${#cliFile}-7)))
4275
tar -zxvf $cliFile
4376
cd $cliFileName
4477
export PATH="veracode-helper/helper/cli/$cliFileName:$PATH"
45-
cd /__w/veracode/veracode
78+
cd $working_path
79+
if [[ "${{ inputs.event_name }}" == *"ruby"* ]]; then
80+
gem install bundler -v ${{ inputs.bundle_version }}
81+
gem install veracode
82+
bundle install
83+
fi
4684
veracode package --source . --output veracode-artifacts --trust
47-
zip veracode-artifact.zip veracode-artifacts/* -x .zip .tar .tar.gz .gz
4885
4986
- name: Package error
5087
if: failure() && steps.application_package.outcome == 'failure'
@@ -54,5 +91,5 @@ jobs:
5491
- uses: actions/upload-artifact@v4
5592
with:
5693
name: veracode-artifact
57-
path: /__w/veracode/veracode/veracode-artifacts/*
58-
if-no-files-found: error
94+
path: "${{ steps.application_package.outputs.working_dir }}/veracode-artifacts/*"
95+
if-no-files-found: error

.github/workflows/veracode-sandbox-scan.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ on:
1818
- dart-sandbox-scan
1919
- java-sandbox-scan
2020
- unidentified-lang-sandbox-scan
21+
- ruby-sandbox-scan
2122

2223
jobs:
2324
build:

0 commit comments

Comments
 (0)