Skip to content

Commit 7e0901c

Browse files
chore(gha): harden GitHub Actions workflows security
1 parent b797b32 commit 7e0901c

7 files changed

Lines changed: 63 additions & 38 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: 6 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

.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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ jobs:
2222
2323
nightly:
2424
needs: delete_tag
25-
uses: Checkmarx/ast-cli-java-wrapper/.github/workflows/release.yml@main
25+
uses: ./.github/workflows/release.yml
2626
with:
2727
tag: "1.0.0-SNAPSHOT"
2828
dev: true
2929
cliTag: "2.0.0-nightly"
30-
secrets: inherit
30+
secrets:
31+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
32+
MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
33+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
34+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}

.github/workflows/pr-label.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ permissions:
99
jobs:
1010
pr-labeler:
1111
permissions:
12-
pull-requests: write # for TimonVS/pr-labeler-action to add labels in PR
12+
pull-requests: write
1313
runs-on: cx-public-ubuntu-x64
1414
steps:
15-
- uses: TimonVS/pr-labeler-action@f9c084306ce8b3f488a8f3ee1ccedc6da131d1af #v5
16-
with:
17-
configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value
18-
env:
19-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
# - uses: TimonVS/pr-labeler-action@f9c084306ce8b3f488a8f3ee1ccedc6da131d1af #v5
16+
# with:
17+
# configuration-path: .github/pr-labeler.yml
18+
# env:
19+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
- run: echo "pr-labeler disabled"

.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)