77 workflow_dispatch :
88 inputs :
99 commit_sha :
10- description : ' The full commit id to build'
10+ description : ' The full 40-character commit id to build'
1111 required : true
1212
13+ # Restrict the default GITHUB_TOKEN so a compromised step cannot write to the
14+ # repo. github-script only needs checks:write to publish the status check.
15+ permissions :
16+ contents : read
17+ checks : write
18+
1319jobs :
20+ # Reject anything that is not a full 40-hex commit SHA before it can reach
21+ # `actions/checkout` or `mvn`. Prevents ref/expression injection via the
22+ # workflow_dispatch input. The value is read from the environment (never
23+ # interpolated inline into the shell) so the check itself is injection-safe.
24+ validate-input :
25+ runs-on : ubuntu-latest
26+ permissions : {}
27+ steps :
28+ - name : Validate commit_sha
29+ env :
30+ COMMIT_SHA : ${{ github.event.inputs.commit_sha }}
31+ run : |
32+ if [[ ! "$COMMIT_SHA" =~ ^[0-9a-f]{40}$ ]]; then
33+ echo "::error::commit_sha must be a full 40-character lowercase hex commit SHA"
34+ exit 1
35+ fi
36+
1437 comment-run :
38+ needs : validate-input
1539 runs-on : ${{ matrix.os }}
1640 strategy :
1741 fail-fast : false
@@ -20,14 +44,12 @@ jobs:
2044 java : [ '8', '11', '17' ]
2145 os : [ 'macos-latest', 'windows-latest', 'ubuntu-latest' ]
2246 name : Java-selenium Repo ${{ matrix.Java }} - ${{ matrix.os }} Sample
23- env :
24- BROWSERSTACK_USERNAME : ${{ secrets.BROWSERSTACK_USERNAME }}
25- BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
2647
2748 steps :
28- - uses : actions/checkout@v3
49+ - uses : actions/checkout@a37ce9120846195fa4ece8f58b268e6043cb2f26 # v3.7.0
2950 with :
3051 ref : ${{ github.event.inputs.commit_sha }}
52+ persist-credentials : false
3153 - uses : actions/github-script@98814c53be79b1d30f795b907e553d8679345975
3254 id : status-check-in-progress
3355 env :
@@ -48,19 +70,28 @@ jobs:
4870 console.log('Failed to create check run')
4971 }
5072 - name : Set up Java
51- uses : actions/setup-java@v3
73+ uses : actions/setup-java@e9fbacdec3bb3b6036605a3e6f7995d66773a8c6 # v3.14.2
5274 with :
5375 distribution : ' temurin'
5476 java-version : ${{ matrix.java }}
5577 - name : Run mvn test
78+ env :
79+ BROWSERSTACK_USERNAME : ${{ secrets.BROWSERSTACK_USERNAME }}
80+ BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
5681 run : |
5782 mvn compile
5883 mvn test
5984 - name : Run mvn profile sample-local-test
85+ env :
86+ BROWSERSTACK_USERNAME : ${{ secrets.BROWSERSTACK_USERNAME }}
87+ BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
6088 run : |
6189 mvn compile
6290 mvn test -P sample-local-test
6391 - name : Run mvn profile sample-test
92+ env :
93+ BROWSERSTACK_USERNAME : ${{ secrets.BROWSERSTACK_USERNAME }}
94+ BROWSERSTACK_ACCESS_KEY : ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
6495 run : |
6596 mvn compile
6697 mvn test -P sample-test
0 commit comments