@@ -5,19 +5,10 @@ permissions:
55 contents : read # we only need to checkout code
66 actions : read # to query workflows/runs
77 pull-requests : write # to comment on or label PRs
8- security-events : write # to upload the scan results
98
109on :
11- # pull_request_target allows secrets to be read from fork PRs.
12- # DO NOT build or run checked out code from this job.
13- #
14- # Please note: Due to how this job is run, any changes to this
15- # job will only take affect when merged to main.
16- #
17- # From https://michaelheap.com/access-secrets-from-forks/
18- # Also see https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
19- pull_request_target :
20- types : [opened, synchronize, reopened]
10+ pull_request :
11+ branches : [ '**' ]
2112 push :
2213 branches : [ 'main' ]
2314concurrency :
@@ -28,94 +19,30 @@ jobs:
2819 permissions :
2920 contents : read
3021 pull-requests : write
31- statuses : write
3222 security-events : write
3323
3424 runs-on : ubuntu-latest
3525
3626 steps :
37- - name : Check access
38- if : ${{ github.event.pull_request.author_association != 'COLLABORATOR' && github.event.pull_request.author_association != 'OWNER' && github.event.pull_request.author_association != 'MEMBER' }}
39- run : |
40- echo "This job needs re-running by someone with collaboration permissions."
41- exit 1
42-
43- # This is dangerous without the first access check
4427 - name : Checkout
45- uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
46- with :
47- # Yes we do need to specify head explicitly here (read github article)
48- ref : ${{ github.event.pull_request.head.sha }}
49-
50- - name : Install dependencies
51- run : |
52- python3 -m pip install --upgrade pip
53- python3 -m pip install beautifulsoup4 requests
54-
55- - name : Scrape Checkmarx status
56- run : |
57- cat <<'EOF' > scrape_checkmarx.py
58- import requests
59- from bs4 import BeautifulSoup
60-
61- # URL of the status page
62- url = "https://eu2-status.ast.checkmarx.net/"
63-
64- try:
65- # Send a GET request to fetch the HTML content
66- response = requests.get(url)
67- response.raise_for_status() # Check for request errors
68-
69- # Parse the HTML content
70- soup = BeautifulSoup(response.text, 'html.parser')
28+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
7129
72- # Locate the status element based on its HTML structure
73- status_element = soup.find('aside', class_='operational state-bar')
74-
75- # Check if the status is operational
76- if status_element and 'Operating Normally' in status_element.text:
77- print("The status is operational with status")
78- print(status_element.text)
79- else:
80- print("The status is not operational.")
81- except requests.exceptions.RequestException as e:
82- print(f"An error occurred: {e}")
83- EOF
84- python3 scrape_checkmarx.py
85-
86- - name : Check Checkmarx One server health
87- run : |
88- response=$(curl -s -o /dev/null -w "%{http_code}" https://ind-status.ast.checkmarx.net/)
89- if [ "$response" != "200" ]; then
90- echo "Checkmarx One server is down. Proceeding without breaking the build."
91- exit 0 # Do not fail the build
92- else
93- echo "Checkmarx One server is healthy. Proceeding with scan."
94- fi
95-
96- - name : Checkmarx One CLI Action
97- uses : checkmarx/ast-github-action@ef313c2c19e03e90ae35e795724fb1d20830dc33 # 2.3.26
30+ # TODO: Remove this checkout step once upload-sarif-github-action repo is made public
31+ # Currently required because GitHub Actions can't directly reference private repos
32+ - name : Checkout Upload action repository
33+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
9834 with :
99- cx_tenant : ${{ secrets.CX_TENANT }}
100- base_uri : https://eu-2.ast.checkmarx.net/
101- cx_client_id : ${{ secrets.CX_CLIENT_ID }}
102- cx_client_secret : ${{ secrets.CX_CLIENT_SECRET_EU }}
103- additional_params : >
104- --report-format sarif
105- --scs-repo-url https://github.com/midnightntwrk/midnight-node-docker
106- --scs-repo-token ${{ secrets.MIDNIGHTCI_REPO }}
107- - name : Filter out repo level issues that github can't handle
108- run : |
109- mv ./cx_result.sarif ./cx_result.sarif.orig
110- jq '.runs |= map(.results |= map(.locations |= map(if .physicalLocation.artifactLocation.uri == "" then .physicalLocation.artifactLocation.uri = "file:/README.md" else . end)))' cx_result.sarif.orig > cx_result.sarif
111-
112- - uses : actions/upload-artifact@v4
113- with :
114- name : cx_result-sarif
115- path : cx_result.sarif
116-
117- # Upload results to github
118- - name : Upload SARIF file
119- uses : github/codeql-action/upload-sarif@7273f08caa1dcf2c2837f362f1982de0ab4dc344 # v3.29.2
35+ repository : midnightntwrk/upload-sarif-github-action
36+ ref : 8202d2182e4c0ebec293f9d9140c3378a2afe16e
37+ path : upload-sarif-github-action
38+ token : ${{ secrets.MIDNIGHTCI_REPO }}
39+
40+ # Once public, can simplify to: uses: midnightntwrk/upload-sarif-github-action/checkmarx-scan@8202d2182e4c0ebec293f9d9140c3378a2afe16e
41+ - name : Checkmarx Full Scan
42+ uses : ./upload-sarif-github-action/checkmarx-scan
12043 with :
121- sarif_file : cx_result.sarif
44+ cx-client-id : ${{ secrets.CX_CLIENT_ID }}
45+ cx-client-secret : ${{ secrets.CX_CLIENT_SECRET_EU }}
46+ cx-tenant : ${{ secrets.CX_TENANT }}
47+ scs-repo-token : ${{ secrets.MIDNIGHTCI_REPO }}
48+ upload-to-github : ' true'
0 commit comments