Skip to content

Commit 06dafaa

Browse files
security: harden release workflow and declare workflow_call secrets (#487)
* security: harden release workflow and declare workflow_call secrets - Replace actions/checkout v4.3.1 with v6.0.3 and switch from PERSONAL_ACCESS_TOKEN to GITHUB_TOKEN - Fix script injection in Download CLI, Tag, Update POM, Build artifactId, and Publish steps by moving inputs to env vars - Replace deprecated ::set-output with $GITHUB_OUTPUT in Tag step - Update actions/setup-java v4.3.0 to v5.2.0 - Add explicit secrets declaration for workflow_call (MAVEN_GPG_PASSPHRASE, MAVEN_GPG_PRIVATE_KEY, OSSRH_TOKEN, OSSRH_USERNAME) - Fix broken shell conditional in Build artifactId property step * chore(gha): harden GitHub Actions workflows security * chore(gha): disable nightly trigger and remove pr-labeler workflow * chore(gha): configure echo mirror for Maven dependency resolution
1 parent 6661e60 commit 06dafaa

8 files changed

Lines changed: 96 additions & 68 deletions

File tree

.github/workflows/auto-merge-pr.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Checkmarx One Scan
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
schedule:
9+
- cron: "00 7 * * *" # Every day at 07:00
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
cx-scan:
16+
name: Checkmarx One Scan
17+
permissions:
18+
contents: read
19+
runs-on: cx-public-ubuntu-x64
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
23+
- name: Checkmarx One CLI Action
24+
uses: checkmarx/ast-github-action@ef93013c95adc60160bc22060875e90800d3ecfc #v.2.3.19
25+
with:
26+
base_uri: ${{ secrets.AST_RND_SCANS_BASE_URI }}
27+
cx_tenant: ${{ secrets.AST_RND_SCANS_TENANT }}
28+
cx_client_id: ${{ secrets.AST_RND_SCANS_CLIENT_ID }}
29+
cx_client_secret: ${{ secrets.AST_RND_SCANS_CLIENT_SECRET }}
30+
additional_params: --tags sypher --threshold "sca-critical=1;sca-high=1;sca-medium=1;sca-low=1;sast-critical=1;sast-high=1;sast-medium=1;sast-low=1;iac-security-critical=1;iac-security-high=1;iac-security-medium=1;iac-security-low=1"

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ name: AST Java Wrapper CI
22

33
on: [ pull_request ]
44

5+
permissions:
6+
contents: read
7+
58
jobs:
69
integration-tests:
10+
permissions:
11+
contents: read
712
runs-on: cx-public-ubuntu-x64
813
steps:
914
- name: Checkout
1015
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
1116
with:
12-
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
17+
token: ${{ secrets.GITHUB_TOKEN }}
1318
lfs: true
1419

1520
- name: Install Git LFS
@@ -27,6 +32,10 @@ jobs:
2732
distribution: 'temurin'
2833
java-version: '11'
2934

35+
- name: Configure echo mirror for dependency resolution
36+
run: |
37+
sed -i 's|</settings>|<mirrors><mirror><id>echo</id><mirrorOf>central</mirrorOf><url>https://maven.echohq.com</url></mirror></mirrors></settings>|' ~/.m2/settings.xml
38+
3039
- name: Check existence of cx-linux binary
3140
run: |
3241
if [ ! -f "src/main/resources/cx-linux" ]; then

.github/workflows/manual-tag.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ jobs:
1919
- name: Checkout
2020
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
2121
with:
22-
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
22+
token: ${{ secrets.GITHUB_TOKEN }}
2323
- name: Tag
24+
env:
25+
INPUT_TAG: ${{ github.event.inputs.tag }}
26+
PR_NUMBER: ${{ github.event.pull_request.number }}
27+
PR_TITLE: ${{ github.event.pull_request.title }}
2428
run: |
25-
echo ${{ github.event.inputs.tag }}
26-
echo "NEXT_VERSION=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
27-
tag=${{ github.event.inputs.tag }}
28-
message='${{ github.event.inputs.tag }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}'
29+
echo "$INPUT_TAG"
30+
echo "NEXT_VERSION=$INPUT_TAG" >> $GITHUB_ENV
31+
message="$INPUT_TAG: PR #$PR_NUMBER $PR_TITLE"
2932
git config user.name "${GITHUB_ACTOR}"
3033
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
31-
git tag -a "${tag}" -m "${message}"
32-
git push origin "${tag}"
34+
git tag -a "$INPUT_TAG" -m "$message"
35+
git push origin "$INPUT_TAG"

.github/workflows/nightly.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: Nightly Release
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
workflow_dispatch: # push disabled — re-enable when nightly is ready
5+
# push:
6+
# branches:
7+
# - main
78

89
permissions:
910
contents: read
@@ -22,9 +23,13 @@ jobs:
2223
2324
nightly:
2425
needs: delete_tag
25-
uses: Checkmarx/ast-cli-java-wrapper/.github/workflows/release.yml@main
26+
uses: ./.github/workflows/release.yml
2627
with:
2728
tag: "1.0.0-SNAPSHOT"
2829
dev: true
2930
cliTag: "2.0.0-nightly"
30-
secrets: inherit
31+
secrets:
32+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
33+
MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
34+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
35+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}

.github/workflows/pr-label.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ on:
4141
required: false
4242
default: false
4343
type: boolean
44+
secrets:
45+
MAVEN_GPG_PASSPHRASE:
46+
required: true
47+
MAVEN_GPG_PRIVATE_KEY:
48+
required: true
49+
OSSRH_TOKEN:
50+
required: true
51+
OSSRH_USERNAME:
52+
required: true
4453

4554
permissions:
4655
contents: read
@@ -56,16 +65,18 @@ jobs:
5665
TAG_NAME: ${{ steps.set_tag_name.outputs.TAG_NAME }}
5766
steps:
5867
- name: Checkout
59-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
68+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
6069
with:
61-
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
70+
token: ${{ secrets.GITHUB_TOKEN }}
6271
lfs: true
6372

6473
- name: Download CLI
6574
if: inputs.cliTag
75+
env:
76+
INPUT_CLI_TAG: ${{ inputs.cliTag }}
6677
run: |
6778
chmod +x ./.github/scripts/update_cli.sh
68-
./.github/scripts/update_cli.sh ${{ inputs.cliTag }}
79+
./.github/scripts/update_cli.sh "$INPUT_CLI_TAG"
6980
7081
- name: Extract CLI version
7182
id: extract_cli_version
@@ -92,19 +103,19 @@ jobs:
92103
93104
- name: Tag
94105
id: set_tag_name
106+
env:
107+
INPUT_TAG: ${{ inputs.tag }}
95108
run: |
96-
echo ${{ inputs.tag }}
97-
tag=${{ inputs.tag }}
98-
echo "RELEASE_VERSION=${{ inputs.tag }}" >> $GITHUB_ENV
99-
message='${{ inputs.tag }}'
109+
echo "$INPUT_TAG"
110+
echo "RELEASE_VERSION=$INPUT_TAG" >> $GITHUB_ENV
100111
git config user.name "${GITHUB_ACTOR}"
101112
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
102-
git tag -a "${tag}" -m "${message}"
103-
git push origin "${tag}"
104-
echo "TAG_NAME=${{ inputs.tag }}" >> $GITHUB_OUTPUT
113+
git tag -a "$INPUT_TAG" -m "$INPUT_TAG"
114+
git push origin "$INPUT_TAG"
115+
echo "TAG_NAME=$INPUT_TAG" >> $GITHUB_OUTPUT
105116
106117
- name: Set up Maven Central Repository
107-
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
118+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
108119
with:
109120
java-version: '11'
110121
distribution: 'temurin'
@@ -114,20 +125,27 @@ jobs:
114125
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
115126
gpg-passphrase: MAVEN_GPG_PASSPHRASE
116127

128+
- name: Configure echo mirror for dependency resolution
129+
run: |
130+
sed -i 's|</settings>|<mirrors><mirror><id>echo</id><mirrorOf>central</mirrorOf><url>https://maven.echohq.com</url></mirror></mirrors></settings>|' ~/.m2/settings.xml
131+
117132
- name: Update the POM version.
118-
run: mvn -B versions:set -DnewVersion='${{ env.RELEASE_VERSION }}' --file pom.xml -DskipTests
133+
run: mvn -B versions:set -DnewVersion="$RELEASE_VERSION" --file pom.xml -DskipTests
119134

120135
- name: Build artifactId property
136+
env:
137+
INPUT_DEV: ${{ inputs.dev }}
138+
INPUT_TAG: ${{ inputs.tag }}
121139
run: |
122140
prop=''
123-
if [ ${{ inputs.dev }} = true ] && ![ "${{ inputs.tag }}" = "1.0.0-SNAPSHOT" ]; then
141+
if [ "$INPUT_DEV" = "true" ] && [ "$INPUT_TAG" != "1.0.0-SNAPSHOT" ]; then
124142
prop='-Dast.wrapper.id=ast-cli-java-wrapper-dev'
125143
fi
126144
echo "AID_PROP=${prop}" >> $GITHUB_ENV
127145
128146
- name: Publish package
129147
if: inputs.publish == true
130-
run: mvn --batch-mode deploy -DskipTests ${{ env.AID_PROP }}
148+
run: mvn --batch-mode deploy -DskipTests $AID_PROP
131149
env:
132150
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
133151
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}

.github/workflows/update-cli.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ jobs:
3838
RELEASE_TAG: ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
3939
run: |
4040
# Update current release
41-
echo ${{ steps.checkmarx-ast-cli.outputs.release_tag }} > checkmarx-ast-cli.version
41+
echo "$RELEASE_TAG" > checkmarx-ast-cli.version
4242
4343
- name: Download latest cli and update branch
4444
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
45+
env:
46+
RELEASE_TAG: ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
4547
run: |
4648
# Update binaries
4749
chmod +x ./.github/scripts/update_cli.sh
48-
./.github/scripts/update_cli.sh ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
50+
./.github/scripts/update_cli.sh "$RELEASE_TAG"
4951
5052
- name: Track large files with Git LFS
5153
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag

0 commit comments

Comments
 (0)