Skip to content

CodeQL Security Analysis #88

CodeQL Security Analysis

CodeQL Security Analysis #88

name: "CodeQL Security Analysis"
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
schedule:
# Run weekly on Monday at 4 AM UTC
- cron: "0 4 * * 1"
permissions:
actions: read
contents: read
security-events: write
jobs:
analyze:
name: Analyze C# Code
# Removed: if: github.event.repository.private == false
# That condition caused the job to be permanently skipped on private repos.
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
language: ["csharp"]
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup .NET
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
with:
dotnet-version: 8.0.x
- name: Cache NuGet packages
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Initialize CodeQL
uses: github/codeql-action/init@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality
- name: Build solution
run: dotnet build CompanyManagementSystem.sln --configuration Release --no-restore || dotnet build CompanyManagementSystem.sln --configuration Release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@0d579ffd059c29b07949a3cce3983f0780820c98 # v4.32.6
with:
category: "/language:${{ matrix.language }}"
# FIX: Disable SARIF upload to GitHub's code-scanning API.
# This repo is private without GitHub Advanced Security, so the upload
# endpoint returns "Code scanning is not enabled" and fails the job.
# The scan itself completes successfully — disabling upload lets the
# job pass while preserving full analysis coverage.
# To re-enable: remove this line and enable Code Scanning at
# Settings → Code security → Code scanning (requires GHAS).
upload: false