Skip to content

Commit

Permalink
[Add] GH action: codeql, Build & Test & SonarQube; fixes #277
Browse files Browse the repository at this point in the history
[Remove] appveyor
  • Loading branch information
samatrhea committed Nov 19, 2023
1 parent 08b934e commit ceaa428
Show file tree
Hide file tree
Showing 20 changed files with 225 additions and 142 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/CodeQuality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build & Test & SonarQube

on:
push:
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: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- name: Restore dependencies
run: dotnet restore COMET-WebServices.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:"RHEAGROUP_CDP4-COMET-WebServices-Community-Edition" /o:"rheagroup" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="./CoverageResults/coverage.opencover.xml"
- name: Build
run: dotnet build COMET-WebServices.sln --no-restore /p:ContinuousIntegrationBuild=true

- name: Run Tests and Compute Coverage
run: dotnet test COMET-WebServices.sln --no-restore --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutput="../CoverageResults/" /p:MergeWith="../CoverageResults/coverage.json" /p:CoverletOutputFormat=\"opencover,json\"

- 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-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "CodeQL Analysis"

on:
push:
branches:
- '**'
tags-ignore:
- '*'
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@v3
with:
dotnet-version: 8.0.x

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

- name: Install dependencies
run: dotnet restore COMET-WebServices.sln

- name: Build
run: dotnet build COMET-WebServices.sln --no-restore

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
39 changes: 39 additions & 0 deletions CDP4Authentication.Tests/CDP4Authentication.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Company>RHEA System S.A.</Company>
<Title>CDP4Authentication.Tests</Title>
<Description>CDP4-COMET Data-Model Object Relational Mapping</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam Gerené, Alex Vorobiev, Alexander van Delft</Authors>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.69" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit.Console" Version="3.16.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CDP4Authentication\CDP4Authentication.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace CDP4Orm.Tests
namespace CDP4Authentication.Tests
{
using System;

Expand Down
2 changes: 1 addition & 1 deletion CDP4Authentication/CDP4Authentication.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Version>8.0.0</Version>
<Description>CDP4-COMET Library to support the implementation of authentication</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander</Authors>
<Authors>Sam Gerené, Alex Vorobiev, Alexander van Delft</Authors>
<RepositoryUrl>https://github.com/RHEAGROUP/CDP4-SDK-Community-Edition.git</RepositoryUrl>
<Configurations>Debug;Release</Configurations>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Version>8.0.0</Version>
<Description>CDP4-COMET Database authentication</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander</Authors>
<Authors>Sam Gerené, Alex Vorobiev, Alexander van Delft</Authors>
<Configurations>Debug;Release</Configurations>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<LangVersion>latest</LangVersion>
Expand Down
12 changes: 10 additions & 2 deletions CDP4Orm.Tests/CDP4Orm.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Title>CDP4Orm-CE.Tests</Title>
<Description>CDP4-COMET Data-Model Object Relational Mapping</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander</Authors>
<Authors>Sam Gerené, Alex Vorobiev, Alexander van Delft</Authors>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand All @@ -20,10 +20,18 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CDP4Authentication\CDP4Authentication.csproj" />
<ProjectReference Include="..\CDP4Orm\CDP4Orm.csproj" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion CDP4Orm/CDP4Orm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Version>8.0.0</Version>
<Description>CDP4-COMET Data-Model Object Relational Mapping</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander</Authors>
<Authors>Sam Gerené, Alex Vorobiev, Alexander van Delft</Authors>
<Configurations>Debug;Release</Configurations>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<LangVersion>latest</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<TargetFramework>net8.0</TargetFramework>
<Company>RHEA System S.A.</Company>
<Title>CDP4WspDatabaseAuthentication.Tests</Title>
<Description>CDP4-COMET WSP Database authentication Tests</Description>
<Description>CDP4-COMET WSP Database authentication Tests</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander</Authors>
<Authors>Sam Gerené, Alex Vorobiev, Alexander van Delft</Authors>
<Configurations>Debug;Release</Configurations>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand All @@ -19,12 +19,19 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\CDP4Authentication\CDP4Authentication.csproj" />
<ProjectReference Include="..\CDP4Orm\CDP4Orm.csproj" />
<ProjectReference Include="..\CDP4WSPDatabaseAuthentication\CDP4WspDatabaseAuthentication.csproj" />
<ProjectReference Include="..\CDP4WspDatabaseAuthentication\CDP4WspDatabaseAuthentication.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ namespace CDP4WspDatabaseAuthentication.Tests

using NUnit.Framework;


[TestFixture]
public class EncryptionUtilsTestFixture
public class WspEncryptionUtilsTestFixture
{
[Test]
public void VerifyThatWspPasswordCompareWorks()
Expand All @@ -38,14 +39,14 @@ public void VerifyThatWspPasswordCompareWorks()
var salt = EncryptionUtils.GenerateRandomSaltString();
var serverSalt = EncryptionUtils.GenerateRandomSaltString();

var encryptedPassword = CDP4WspDatabaseAuthentication.EncryptionUtils.BuildWspSaltedString(password,
var encryptedPassword = WspEncryptionUtils.BuildWspSaltedString(password,
salt, serverSalt);

const string passwordToTest = "pass";
const string wrongPasswordToTest = "pass1";

Assert.IsTrue(CDP4WspDatabaseAuthentication.EncryptionUtils.CompareWspSaltedString(passwordToTest, encryptedPassword, salt, serverSalt));
Assert.IsFalse(CDP4WspDatabaseAuthentication.EncryptionUtils.CompareWspSaltedString(wrongPasswordToTest, encryptedPassword, salt, serverSalt));
Assert.IsTrue(WspEncryptionUtils.CompareWspSaltedString(passwordToTest, encryptedPassword, salt, serverSalt));
Assert.IsFalse(WspEncryptionUtils.CompareWspSaltedString(wrongPasswordToTest, encryptedPassword, salt, serverSalt));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Version>8.0.0</Version>
<Description>CDP4-COMET WSP Database authentication</Description>
<Copyright>Copyright © RHEA System S.A.</Copyright>
<Authors>Sam, Merlin, Alex, Naron, Alexander</Authors>
<Authors>Sam Gerené, Alex Vorobiev, Alexander van Delft</Authors>
<Configurations>Debug;Release</Configurations>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<LangVersion>latest</LangVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private bool ValidatePassword(string password, AuthenticationPerson person)

foreach (var serverSalt in serverSalts)
{
result = EncryptionUtils.CompareWspSaltedString(password, person.Password, person.Salt, serverSalt);
result = WspEncryptionUtils.CompareWspSaltedString(password, person.Password, person.Salt, serverSalt);

if (result)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="EncryptionUtils.cs" company="RHEA System S.A.">
// <copyright file="WspEncryptionUtils.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2023 RHEA System S.A.
//
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="EncryptionUtils.cs" company="RHEA System S.A.">
// <copyright file="WspEncryptionUtils.cs" company="RHEA System S.A.">
// Copyright (c) 2015-2023 RHEA System S.A.
//
// Author: Sam Gerené, Alex Vorobiev, Alexander van Delft, Nathanael Smiechowski, Antoine Théate
Expand Down Expand Up @@ -31,7 +31,7 @@ namespace CDP4WspDatabaseAuthentication
/// <summary>
/// Provides static helper methods to help with encryption
/// </summary>
public static class EncryptionUtils
public static class WspEncryptionUtils
{
/// <summary>
/// Compares the input string with an encrypted string. (WSP specific)
Expand Down
Loading

0 comments on commit ceaa428

Please sign in to comment.