Skip to content

Commit

Permalink
[Add] Github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
samatstariongroup committed Oct 20, 2024
1 parent 94f6b12 commit 5545354
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 27 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/CodeQuality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build & Test & SonarQube

on:
push:
branches:
- '**'
tags-ignore:
- 'web-*'
pull_request:
types: [opened, synchronize, reopened]

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
overwrite-settings: false

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore EcoreNettoWebsite.sln

- name: Sonarqube Begin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet tool install --global dotnet-sonarscanner
dotnet sonarscanner begin /k:"STARIONGROUP_EcoreNettoWebsite" /o:"stariongroup" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="./CoverageResults/coverage.opencover.xml"
- name: Build
run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true

- name: Test with the dotnet CLI
run: dotnet test --no-build --verbosity normal --filter /p:CollectCoverage=true /p:CoverletOutput=../CoverageResults/ /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat=\"opencover,json\" -m:1

- name: Sonarqube end
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

49 changes: 49 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "CodeQL"

on:
push:
branches:
- '**'
tags-ignore:
- 'web-*'
pull_request:
schedule:
- cron: '42 2 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'csharp' ]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Install dependencies
run: dotnet restore EcoreNettoWebsite.sln

- name: Build
run: dotnet build EcoreNettoWebsite.sln --no-restore

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
47 changes: 47 additions & 0 deletions .github/workflows/nuget-reference-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "nuget package reference check"

on:
push:
pull_request:
schedule:
- cron: '0 8 * * *'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
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: Setup .NET Environment
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x

- name: Restore dependencies
run: dotnet restore EcoreNettoWebsite.sln

- name: Build
run: dotnet build EcoreNettoWebsite.sln --no-restore /p:ContinuousIntegrationBuild=true

- name: Checking NuGet vulnerabilites
run: |
set -e
dotnet list EcoreNettoWebsite.sln package --outdated --include-transitive
dotnet list EcoreNettoWebsite.sln package --deprecated --include-transitive
dotnet list EcoreNettoWebsite.sln package --vulnerable --include-transitive 2>&1 | tee vulnerabilities.log
echo "Analyze dotnet list package command log output..."
if grep -q -i "\bcritical\b\|\bhigh\b\|\bmoderate\b\|\blow\b" vulnerabilities.log; then
echo "Security Vulnerabilities found"
exit 1
else
echo "No Security Vulnerabilities found"
exit 0
fi
43 changes: 43 additions & 0 deletions .github/workflows/semgrep.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Semgrep OWASP Top Ten

on:
push:
branches:
- '**'
tags-ignore:
- '*'
pull_request:
schedule:
- cron: '42 2 * * 3'

jobs:

semgrep-full:
runs-on: ubuntu-latest
container:
image: semgrep/semgrep

steps:

- name: clone application source code
uses: actions/checkout@v4
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: full scan
run: |
semgrep scan --config "https://semgrep.dev/p/owasp-top-ten" --sarif --output=semgrep-sast.sarif --metrics=off
- name: save report as pipeline artifact
uses: actions/upload-artifact@v4
with:
name: semgrep-sast.sarif
path: semgrep-sast.sarif

- name: publish code scanning alerts
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: semgrep-sast.sarif
category: semgrep
27 changes: 0 additions & 27 deletions EcoreNettoWebSite..sln.DotSettings

This file was deleted.

0 comments on commit 5545354

Please sign in to comment.