Skip to content

Feature branch test for PR vulnerability #1

Feature branch test for PR vulnerability

Feature branch test for PR vulnerability #1

Workflow file for this run

name: "CodeQL"
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: '40 12 * * 0'
jobs:
analyze:
name: Analyze
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
- name: Check for Vulnerabilities
run: |
if [ -e codeql-results/codeql-results.sarif ]; then
echo "Checking for vulnerabilities..."
if grep -q 'critical-vulnerability' codeql-results/codeql-results.sarif; then
echo "Critical vulnerabilities found!"
echo "Vulnerabilities found. Merging is disabled."
echo "::set-output name=status::failure"
fi
fi
working-directory: ${{ github.workspace }}
- name: Prevent Merge
if: steps.set-status.outputs.status == 'failure'
run: |
echo "Preventing merging due to vulnerabilities..."
# You can use GitHub API, branch protection, or any other method to prevent merging here.
# Example: Use GitHub API to protect the branch
GITHUB_TOKEN=$GITHUB_TOKEN node your-script-to-protect-branch.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: ${{ github.workspace }}