Skip to content

code analysis

code analysis #151

# CodeQL Code Scanning
# Analyses your code for security vulnerabilities and coding errors.
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository. You may wish to alter this file to override
# the set of languages analyzed, or to provide custom queries or build logic.
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/about-code-scanning
name: code analysis
on:
push:
branches: [main]
paths:
- '**.cs'
- '**.csproj'
pull_request:
# The branches below must be a subset of the branches above
branches: [main]
paths:
- '**.cs'
- '**.csproj'
schedule:
- cron: '0 7 * * 1'
workflow_dispatch:
inputs:
reason:
description: 'The reason for running a build?'
required: true
default: 'Manual build'
env:
DOTNET_VERSION: '8.0.x' # set this to the dot net version to use
jobs:
analyze:
name: analyze
runs-on: ubuntu-latest
permissions:
security-events: write
strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['csharp']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
steps:
- name: Checkout repository
uses: actions/checkout@main
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
- name: 'Print manual build reason'
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@main
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Autobuild
uses: github/codeql-action/autobuild@v1
#- name: Install dependencies
# run: |
# dotnet restore ./src/HaveIBeenPwned.Client.Abstractions/HaveIBeenPwned.Client.Abstractions.csproj
# dotnet restore ./src/HaveIBeenPwned.Client/HaveIBeenPwned.Client.csproj
# dotnet restore ./src/HaveIBeenPwned.Client.PollyExtensions/HaveIBeenPwned.Client.PollyExtensions.csproj
#- name: Build
# run: |
# dotnet build ./src/HaveIBeenPwned.Client.Abstractions/HaveIBeenPwned.Client.Abstractions.csproj --configuration Release --no-restore
# dotnet build ./src/HaveIBeenPwned.Client/HaveIBeenPwned.Client.csproj --configuration Release --no-restore
# dotnet build ./src/HaveIBeenPwned.Client.PollyExtensions/HaveIBeenPwned.Client.PollyExtensions.csproj --configuration Release --no-restore
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@main