|
| 1 | +name: 'Security Review' |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - synchronize |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: '${{ github.workflow }}-review-${{ github.event.pull_request.number }}' |
| 11 | + cancel-in-progress: true |
| 12 | + |
| 13 | +defaults: |
| 14 | + run: |
| 15 | + shell: 'bash' |
| 16 | + |
| 17 | +jobs: |
| 18 | + review: |
| 19 | + # 89942104 is the user id for the angular robot account. |
| 20 | + if: | |
| 21 | + ( |
| 22 | + github.event_name == 'pull_request' && |
| 23 | + github.event.pull_request.user.id == '89942104' |
| 24 | + ) |
| 25 | + runs-on: 'ubuntu-latest' |
| 26 | + timeout-minutes: 15 |
| 27 | + permissions: |
| 28 | + contents: 'read' |
| 29 | + id-token: 'write' |
| 30 | + pull-requests: 'write' |
| 31 | + steps: |
| 32 | + - name: 'Acknowledge request' |
| 33 | + env: |
| 34 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 35 | + ISSUE_NUMBER: '${{ github.event.pull_request.number }}' |
| 36 | + MESSAGE: |- |
| 37 | + Beginning seecurity review for the pull request. Track the progres [in the logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details. |
| 38 | + REPOSITORY: '${{ github.repository }}' |
| 39 | + run: |- |
| 40 | + gh issue comment "${ISSUE_NUMBER}" \ |
| 41 | + --body "${MESSAGE}" \ |
| 42 | + --repo "${REPOSITORY}" |
| 43 | +
|
| 44 | + - name: 'Checkout repository' |
| 45 | + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 |
| 46 | + |
| 47 | + - name: 'Run Gemini security analysis review' |
| 48 | + uses: 'google-github-actions/run-gemini-cli@f7db4b6f82ad0c3725cf4c98bdd93af80e22b4dc' # v0.1.14 |
| 49 | + id: 'gemini_security_analysis' |
| 50 | + env: |
| 51 | + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' |
| 52 | + ISSUE_TITLE: '${{ github.event.pull_request.title }}' |
| 53 | + ISSUE_BODY: '${{ github.event.pull_request.body }}' |
| 54 | + PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number }}' |
| 55 | + REPOSITORY: '${{ github.repository }}' |
| 56 | + with: |
| 57 | + gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}' |
| 58 | + gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}' |
| 59 | + gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}' |
| 60 | + gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}' |
| 61 | + gemini_api_key: '${{ secrets.SECURITY_REVIEWER }}' |
| 62 | + gemini_cli_version: '${{ vars.GEMINI_CLI_VERSION }}' |
| 63 | + gemini_debug: '${{ fromJSON(vars.DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}' |
| 64 | + gemini_model: '${{ vars.GEMINI_MODEL }}' |
| 65 | + google_api_key: '${{ secrets.GOOGLE_API_KEY }}' |
| 66 | + use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}' |
| 67 | + use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' |
| 68 | + upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' |
| 69 | + extensions: | |
| 70 | + [ |
| 71 | + "https://github.com/gemini-cli-extensions/security.git" |
| 72 | + ] |
| 73 | + settings: |- |
| 74 | + { |
| 75 | + "model": { |
| 76 | + "maxSessionTurns": 100 |
| 77 | + }, |
| 78 | + "telemetry": { |
| 79 | + "enabled": true, |
| 80 | + "target": "local", |
| 81 | + "outfile": ".gemini/telemetry.log" |
| 82 | + }, |
| 83 | + "mcpServers": { |
| 84 | + "github": { |
| 85 | + "command": "docker", |
| 86 | + "args": [ |
| 87 | + "run", |
| 88 | + "-i", |
| 89 | + "--rm", |
| 90 | + "-e", |
| 91 | + "GITHUB_PERSONAL_ACCESS_TOKEN", |
| 92 | + "ghcr.io/github/github-mcp-server:v0.18.0" |
| 93 | + ], |
| 94 | + "includeTools": [ |
| 95 | + "add_comment_to_pending_review", |
| 96 | + "create_pending_pull_request_review", |
| 97 | + "pull_request_read", |
| 98 | + "submit_pending_pull_request_review" |
| 99 | + ], |
| 100 | + "env": { |
| 101 | + "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" |
| 102 | + } |
| 103 | + } |
| 104 | + }, |
| 105 | + "tools": { |
| 106 | + "core": [ |
| 107 | + "run_shell_command(cat)", |
| 108 | + "run_shell_command(echo)", |
| 109 | + "run_shell_command(grep)", |
| 110 | + "run_shell_command(head)", |
| 111 | + "run_shell_command(tail)" |
| 112 | + ] |
| 113 | + } |
| 114 | + } |
| 115 | + prompt: '/security:analyze-github-pr' |
0 commit comments