Skip to content

Commit ef79ca7

Browse files
Add security-checks-pr workflow to satisfy ruleset requirement
The repository ruleset 'Protect Master branch - Misc repos' requires this workflow to pass before PRs can be merged. This workflow: - Recursively scans all apps in /apps/ for vulnerabilities using Trivy - Compares PR branch against master to detect new vulnerabilities - Posts security scan results as PR comments - Works with monorepo structure (finds package-lock.json in subdirectories) This unblocks PR merging which has been blocked since the ruleset was updated on 2025-12-12. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent c599b0e commit ef79ca7

1 file changed

Lines changed: 107 additions & 0 deletions

File tree

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Security Checks PR
2+
on:
3+
pull_request:
4+
branches: [master]
5+
workflow_dispatch:
6+
inputs:
7+
repository:
8+
description: Github repository name (without pipedrive/ prefix)
9+
type: string
10+
required: false
11+
pr_number:
12+
description: PR Number (To compare with the default branch)
13+
type: string
14+
required: false
15+
ignored_dependencies:
16+
description: Ignored Dependencies Array - [{"ignoreType":"vulnerability","ignoreSubject":"koa@2.13.4","justification":"AAAAAA","ignoredBy":"giookro"}]
17+
type: string
18+
required: false
19+
default: "[]"
20+
21+
jobs:
22+
# Do not change the name (key) of this job!
23+
# The name of this job is used in the ci-cd-system-check action
24+
# to exclude it from the list of checks that need to pass in pull requests.
25+
Security-Checks-PR:
26+
runs-on: eks-runner-secops-pr
27+
timeout-minutes: 30
28+
permissions:
29+
pull-requests: write
30+
contents: read
31+
env:
32+
# This is necessary to set true and false, otherwise, it sets pr_number as the env var value
33+
IS_MANUAL_RUN: ${{ (inputs.repository && inputs.pr_number) && true || false }}
34+
IS_PR_FROM_AUTOTUNER: ${{ github.event.pull_request.user.login == 'autotuner-bot[bot]' }}
35+
IS_PR_FROM_PRBOT: ${{ github.event.pull_request.user.login == 'pipedrive-backoffice-pr[bot]' }}
36+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
37+
IS_BLOCKER_VULNERABILITY: false
38+
IS_BLOCKER_INTERNAL_VULNERABILITY: false
39+
IS_BLOCKER_LICENSE: false
40+
steps:
41+
- name: Get Pipedrive GitHub Actions Bot Token
42+
uses: actions/create-github-app-token@v1
43+
id: get-workflow-token
44+
with:
45+
app-id: ${{ vars.PD_GHA_BOT_APPLICATION_ID }}
46+
private-key: ${{ secrets.PD_GHA_BOT_APPLICATION_PRIVATE_KEY_PEM }}
47+
owner: ${{ github.repository_owner }}
48+
49+
- name: Checkout repository (branch) (MANUAL RUN)
50+
if: ${{ env.IS_MANUAL_RUN == 'true' }}
51+
uses: actions/checkout@v4
52+
with:
53+
token: ${{ steps.get-workflow-token.outputs.token }}
54+
repository: pipedrive/${{ inputs.repository }}
55+
ref: refs/pull/${{ inputs.pr_number }}/head
56+
57+
- name: Checkout repository (branch)
58+
if: ${{ env.IS_MANUAL_RUN == 'false' }}
59+
uses: actions/checkout@v4
60+
61+
- name: Run Trivy vulnerability scan (branch)
62+
uses: pipedrive/gha-security-checks/actions/scan@master
63+
continue-on-error: true
64+
with:
65+
output_file_name: _trivy_report_branch.json
66+
raw_output_file_name: _trivy_report_raw_branch.json
67+
npm_token: ${{ secrets.NPM_TOKEN }}
68+
gha_access_token: ${{ steps.get-workflow-token.outputs.token }}
69+
70+
- name: Checkout repository (default) (MANUAL RUN)
71+
if: ${{ env.IS_MANUAL_RUN == 'true' }}
72+
uses: actions/checkout@v4
73+
with:
74+
token: ${{ steps.get-workflow-token.outputs.token }}
75+
repository: pipedrive/${{ inputs.repository }}
76+
ref: ${{ github.BASE_REF }}
77+
78+
- name: Checkout repository (default)
79+
uses: actions/checkout@v4
80+
if: ${{ env.IS_MANUAL_RUN == 'false' }}
81+
with:
82+
ref: ${{ github.BASE_REF }}
83+
84+
- name: Run Trivy vulnerability scan (default)
85+
uses: pipedrive/gha-security-checks/actions/scan@master
86+
continue-on-error: true
87+
with:
88+
output_file_name: _trivy_report_master.json
89+
npm_token: ${{ secrets.NPM_TOKEN }}
90+
gha_access_token: ${{ steps.get-workflow-token.outputs.token}}
91+
92+
- name: Post comment to PR
93+
uses: pipedrive/gha-security-checks/actions/pr-comment@master
94+
continue-on-error: true
95+
with:
96+
base_ref: ${{ github.BASE_REF }}
97+
base_report_file_name: _trivy_report_master.json
98+
branch_report_file_name: _trivy_report_branch.json
99+
raw_report_file_name: _trivy_report_raw_branch.json
100+
ignored_dependencies: ${{ inputs.ignored_dependencies }}
101+
is_manual_run: ${{ env.IS_MANUAL_RUN }}
102+
103+
- name: Block PR if necessary
104+
id: block-pr-if-necessary
105+
if: (env.IS_PR_FROM_AUTOTUNER != 'true' && env.IS_PR_FROM_PRBOT != 'true') && (env.IS_BLOCKER_VULNERABILITY == 'true' || env.IS_BLOCKER_LICENSE == 'true' || env.IS_BLOCKER_INTERNAL_VULNERABILITY == 'true')
106+
shell: bash
107+
run: exit 1

0 commit comments

Comments
 (0)