Skip to content
This repository was archived by the owner on Nov 17, 2024. It is now read-only.

Commit 0cc7f23

Browse files
authoredSep 16, 2024
Merge pull request #6 from cdapio/sec-vuln-fix-develop
[Security Vulnerability] Run build with unit tests without elevated permissions
2 parents 86eec23 + 067278e commit 0cc7f23

File tree

3 files changed

+70
-68
lines changed

3 files changed

+70
-68
lines changed
 

‎.github/workflows/build-report.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright © 2024 Cask Data, Inc.
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
3+
# use this file except in compliance with the License. You may obtain a copy of
4+
# the License at
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
# Unless required by applicable law or agreed to in writing, software
7+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
8+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
9+
# License for the specific language governing permissions and limitations under
10+
# the License.
11+
12+
# This workflow will build a Java project with Maven
13+
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
14+
# Note: Any changes to this workflow would be used only after merging into develop
15+
name: Build Unit Tests Report
16+
17+
on:
18+
workflow_run:
19+
workflows:
20+
- Build with unit tests
21+
types:
22+
- completed
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
28+
if: ${{ github.event.workflow_run.conclusion != 'skipped' }}
29+
30+
steps:
31+
# Pinned 1.0.0 version
32+
- uses: marocchino/action-workflow_run-status@54b6e87d6cb552fc5f36dbe9a722a6048725917a
33+
34+
- name: Download artifact
35+
uses: actions/download-artifact@v4
36+
with:
37+
github-token: ${{ secrets.GITHUB_TOKEN }}
38+
run-id: ${{ github.event.workflow_run.id }}
39+
path: artifacts/
40+
41+
- name: Surefire Report
42+
# Pinned 3.5.2 version
43+
uses: mikepenz/action-junit-report@16a9560bd02f11e7e3bf6b3e2ef6bba6c9d07c32
44+
if: always()
45+
with:
46+
report_paths: '**/target/surefire-reports/TEST-*.xml'
47+
github_token: ${{ secrets.GITHUB_TOKEN }}
48+
detailed_summary: true
49+
commit: ${{ github.event.workflow_run.head_sha }}
50+
check_name: Build Test Report
51+

‎.github/workflows/build.yml

+19-21
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,28 @@
1515
name: Build with unit tests
1616

1717
on:
18-
workflow_run:
19-
workflows:
20-
- Trigger build
21-
types:
22-
- completed
18+
push:
19+
branches: [ develop, release/** ]
20+
pull_request:
21+
branches: [ develop, release/** ]
22+
types: [opened, synchronize, reopened, labeled]
2323

2424
jobs:
2525
build:
2626
runs-on: k8s-runner-build
2727

28-
if: ${{ github.event.workflow_run.conclusion != 'skipped' }}
29-
28+
# We allow builds:
29+
# 1) When it's a merge into a branch
30+
# 2) For PRs that are labeled as build and
31+
# - It's a code change
32+
# - A build label was just added
33+
# A bit complex, but prevents builds when other labels are manipulated
34+
if: >
35+
github.event_name == 'push'
36+
|| (contains(github.event.pull_request.labels.*.name, 'build')
37+
&& (github.event.action != 'labeled' || github.event.label.name == 'build')
38+
)
3039
steps:
31-
# Pinned 1.0.0 version
32-
- uses: haya14busa/action-workflow_run-status@967ed83efa565c257675ed70cfe5231f062ddd94
3340
- uses: actions/checkout@v3
3441
with:
3542
ref: ${{ github.event.workflow_run.head_sha }}
@@ -44,23 +51,14 @@ jobs:
4451
- name: Build with Maven
4552
run: mvn clean test -fae -T 2 -B -V -DcloudBuild -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=25
4653
- name: Archive build artifacts
47-
uses: actions/upload-artifact@v2.2.2
54+
uses: actions/upload-artifact@v4
4855
if: always()
4956
with:
50-
name: Build debug files
57+
name: reports-${{ github.run_id }}
5158
path: |
5259
**/target/rat.txt
5360
**/target/surefire-reports/*
54-
- name: Surefire Report
55-
# Pinned 3.5.2 version
56-
uses: mikepenz/action-junit-report@16a9560bd02f11e7e3bf6b3e2ef6bba6c9d07c32
57-
if: always()
58-
with:
59-
report_paths: '**/target/surefire-reports/TEST-*.xml'
60-
github_token: ${{ secrets.GITHUB_TOKEN }}
61-
detailed_summary: true
62-
commit: ${{ github.event.workflow_run.head_sha }}
63-
check_name: Test Report
61+
6462
- name: Checkstyle report
6563
uses: tivv/checkstyle-github-action@fcf8ffb7c6a5c110bbc5dafb84aca54caf359b80
6664
if: always()

‎.github/workflows/trigger.yml

-47
This file was deleted.

0 commit comments

Comments
 (0)