Skip to content

Commit

Permalink
Merge pull request #760 from Blazam-App/v1-Nightly
Browse files Browse the repository at this point in the history
V1.2.5 Update
  • Loading branch information
jacobsen9026 authored Jan 15, 2025
2 parents 9b9ffe6 + 0fa1715 commit 9b193d1
Show file tree
Hide file tree
Showing 4,437 changed files with 2,717 additions and 392,149 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
55 changes: 55 additions & 0 deletions .github/workflows/analyze-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: SonarQube
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
runs-on: windows-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Cache SonarQube Cloud packages
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarQube Cloud scanner
id: cache-sonar-scanner
uses: actions/cache@v4
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarQube Cloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Install Coverlet
shell: powershell
run: |
dotnet tool install --global coverlet.console
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Blazam-App_BLAZAM" /o:"blazam-app" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.scanner.scanAll=false /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=.\coverage.opencover.xml
dotnet build
coverlet .\BLAZAM.Tests\bin\Debug\net8.0\BLAZAM.Tests.dll -t "dotnet" -a "test --filter FullyQualifiedName~BLAZAM.Tests --no-build" -f=opencover --merge-with=".\coverage.opencover.xml"
coverlet .\BLAZAMCommon.Tests\bin\Debug\net8.0\BLAZAMCommon.Tests.dll -t "dotnet" -a "test --filter FullyQualifiedName~BLAZAMCommon.Tests --no-build" -f=opencover --merge-with=".\coverage.opencover.xml"
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
11 changes: 10 additions & 1 deletion BLAZAM.Tests/BLAZAM.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,18 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="6.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
18 changes: 9 additions & 9 deletions BLAZAM.Tests/Jobs/JobTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ private IJob TestJob
{
get
{
IJob job = new Job("Test Job");
IJob job2 = new Job("Nested Job");
IJobStep step1 = new JobStep("Regular Step Passes", (step) => { Task.Delay(200).Wait(); return true; });
IJobStep step2 = new JobStep("Regular Step Fails", (step) => { Task.Delay(200).Wait(); return false; });
IJobStep step3 = new JobStep("Regular Step Throws", (step) => { Task.Delay(200).Wait(); throw new ApplicationException("Test exception"); return false; });
IJobStep step4 = new JobStep("Nested Step Passes", (step) => { Task.Delay(200).Wait(); return true; });
IJobStep step5 = new JobStep("Nested Step Fails", (step) => { Task.Delay(200).Wait(); return false; });
IJobStep step6 = new JobStep("Nested Step Throws", (step) => { Task.Delay(200).Wait(); throw new ApplicationException("Test exception"); return false; });
var job = new Job("Test Job");
var job2 = new Job("Nested Job");
var step1 = new JobStep("Regular Step Passes", (step) => { Task.Delay(200).Wait(); return true; });
var step2 = new JobStep("Regular Step Fails", (step) => { Task.Delay(200).Wait(); return false; });
var step3 = new JobStep("Regular Step Throws", (step) => { Task.Delay(200).Wait(); throw new ApplicationException("Test exception"); return false; });
var step4 = new JobStep("Nested Step Passes", (step) => { Task.Delay(200).Wait(); return true; });
var step5 = new JobStep("Nested Step Fails", (step) => { Task.Delay(200).Wait(); return false; });
var step6 = new JobStep("Nested Step Throws", (step) => { Task.Delay(200).Wait(); throw new ApplicationException("Test exception"); return false; });

job.Steps.Add(step1);
job.Steps.Add(step2);
job.Steps.Add(step3);
job2.Steps.Add(step4);
job2.Steps.Add(step5);
job2.Steps.Add(step6);
job.Steps.Add((IJobStep)job2);
job.Steps.Add(job2);
return job;
}
}
Expand Down
2 changes: 1 addition & 1 deletion BLAZAM.Tests/Updates/VersionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace BLAZAM.Tests.Updates
{

public class VersionTests
{
private ApplicationVersion basicLow = new ApplicationVersion("0.5.1");
Expand Down
7 changes: 0 additions & 7 deletions BLAZAM/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
@inject IApplicationUserStateService userStateService
@inject ICurrentUserStateService currentUser

@{
var dsad = 3;
}
<CascadingAuthenticationState>

<ErrorBoundary>
Expand All @@ -26,10 +23,6 @@
}
else
{
@if (context != null)
{

}
<p>You are not authorized to access this resource.</p>
}
</NotAuthorized>
Expand Down
18 changes: 4 additions & 14 deletions BLAZAM/BLAZAM.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ServerGarbageCollection>false</ServerGarbageCollection>
<AssemblyVersion>1.2.4</AssemblyVersion>
<Version>2024.12.31.0054</Version>
<AssemblyVersion>1.2.5</AssemblyVersion>
<Version>2025.01.14.2330</Version>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<RootNamespace>BLAZAM</RootNamespace>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
Expand Down Expand Up @@ -76,8 +76,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="7.2.0" />
<PackageReference Include="System.DirectoryServices" Version="9.0.0" />

<PackageReference Include="System.DirectoryServices.AccountManagement" Version="9.0.0" />
Expand All @@ -93,7 +93,6 @@
<ProjectReference Include="..\BLAZAMJobs\BLAZAMJobs.csproj" />
<ProjectReference Include="..\BLAZAMLocalization\BLAZAMLocalization.csproj" />
<ProjectReference Include="..\BLAZAMLoggers\BLAZAMLogger.csproj" />
<ProjectReference Include="..\BLAZAMNav\BLAZAMNav.csproj" />
<ProjectReference Include="..\BLAZAMNotifications\BLAZAMNotifications.csproj" />
<ProjectReference Include="..\BLAZAMServices\BLAZAMServices.csproj" />
<ProjectReference Include="..\BLAZAMSession\BLAZAMSession.csproj" />
Expand All @@ -107,12 +106,6 @@
</Content>
</ItemGroup>

<ItemGroup>
<None Include="..\BLAZAMGui\UI\Dashboard\WidgetContainer.razor" Link="WidgetContainer.razor" />
<None Include="..\BLAZAMGui\UI\Dashboard\Widgets\DirectoryEntryTooltipPopover.razor" Link="DirectoryEntryTooltipPopover.razor" />
<None Include="..\BLAZAMGui\UI\Modals\GoogleAuthenticatorInput.razor" Link="GoogleAuthenticatorInput.razor" />
</ItemGroup>

<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
Expand All @@ -128,9 +121,6 @@
<Content Update="wwwroot\favicon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\jira\feature-request.html">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions BLAZAM/Helpers/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace BLAZAM.Helpers
{
/// <summary>
/// Provides extension methods for templat creation
/// </summary>
public static class Helpers
{
/// <summary>
Expand All @@ -27,8 +30,6 @@ public static IADUser GenerateTemplateUser(this DirectoryTemplate template, NewU

newUser.SamAccountName = template.GenerateUsername(newUserName);
newUser.DisplayName = displayName;
//newUser.SetPassword(template.GeneratePassword().ToSecureString(),false);
//newUser.CanonicalName = template.GenerateDisplayName(newUserName);
newUser.StagePasswordChange(template.GeneratePassword(newUserName).ToSecureString());
if (template.EffectiveRequirePasswordChange == true)
newUser.StageRequirePasswordChange(true);
Expand All @@ -50,6 +51,6 @@ public static IADUser GenerateTemplateUser(this DirectoryTemplate template, NewU
});
return newUser;
}

}
}
9 changes: 1 addition & 8 deletions BLAZAM/Middleware/ApplicationStatusRedirectMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ public async Task InvokeAsync(HttpContext context, IUserDatabaseFactory factory)
SendTo(context, "/oops");

}
//if (!ApplicationInfo.installationCompleted)
//{
// SendTo(context, "/install");
//}
break;
case ServiceConnectionState.Down:
SendTo(context, "/oops");
Expand Down Expand Up @@ -75,10 +71,7 @@ private void SendTo(HttpContext context, string uri)

private bool InIgnoreList(string intendedUri)
{
foreach (var uri in _uriIgnoreList)
{
if (intendedUri.StartsWith(uri)) return true;
}
if (_uriIgnoreList.Any(x => intendedUri.StartsWith(x))) return true;
return false;
}
}
Expand Down
15 changes: 10 additions & 5 deletions BLAZAM/Middleware/HttpsRedirectionMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@ namespace BLAZAM.Server.Middleware
public class HttpsRedirectionMiddleware
{
private readonly RequestDelegate _next;
private readonly ConnMonitor _monitor;
private readonly ApplicationInfo _applicationInfo;

/// <summary>
/// Creates a new HTTPS redirect middleware to ensure users are using a secure connection
/// </summary>
/// <param name="next"></param>
/// <param name="applicationInfo"></param>
public HttpsRedirectionMiddleware(
RequestDelegate next,
ConnMonitor monitor,
ApplicationInfo applicationInfo)
{
_next = next;
_monitor = monitor;
_applicationInfo = applicationInfo;
}

/// <summary>
/// Checks the database cache for a true ForceHTTPS and if so an request is HTTP redirect to HTTPS
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public async Task InvokeAsync(HttpContext context)
{
bool forceHttps;
Expand Down
1 change: 0 additions & 1 deletion BLAZAM/Pages/API/Auth/KeepAlive.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public IActionResult OnGet()
response.Add("expired", "false");
return new JsonResult(response);

//return new OkResult();

}

Expand Down
11 changes: 5 additions & 6 deletions BLAZAM/Pages/API/v1/ApiController.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using BLAZAM.ActiveDirectory.Interfaces;
using BLAZAM.Common.Data;
using BLAZAM.Database.Context;
using BLAZAM.Services.Audit;
using BLAZAM.Session.Interfaces;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using BLAZAM.Services.Audit;
using BLAZAM.Session.Interfaces;
using System.Security.Claims;

namespace BLAZAM.Pages.API.v1
{
Expand All @@ -19,9 +19,9 @@ namespace BLAZAM.Pages.API.v1
[ApiController]
[Produces("application/json")]
[Route("api/v1/[controller]")]
public class ApiController : Controller
public class ApiController : ControllerBase
{
private DateTime _startTime = DateTime.Now;
private readonly DateTime _startTime = DateTime.Now;

/// <summary>
/// A string dictionary that contains the base of the response.
Expand All @@ -47,7 +47,6 @@ public class ApiController : Controller

public ApiController(IApplicationUserStateService applicationUserStateService, AuditLogger audit, IUserDatabaseFactory appDatabaseFactory, IHttpContextAccessor httpContextAccessor, IActiveDirectoryContextFactory adFactory)
{
//User = httpContextAccessor.HttpContext.User;
AuditLogger = audit;
UserStateService = applicationUserStateService;
CurrentUserState = UserStateService.CurrentUserState;
Expand Down
8 changes: 7 additions & 1 deletion BLAZAM/Pages/API/v1/Search.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using BLAZAM.Services.Audit;
using BLAZAM.Session.Interfaces;
using Microsoft.AspNetCore.Mvc;
using System.Text.RegularExpressions;

namespace BLAZAM.Pages.API.v1
{
Expand Down Expand Up @@ -35,11 +36,16 @@ public Search(IApplicationUserStateService applicationUserStateService, AuditLog
[HttpGet]
public IActionResult OnGet([FromQuery] string query)
{
// restrict the username and password to letters only
if (!Regex.IsMatch(query, "^[a-zA-Z]+$"))
{
return BadRequest();
}
ADSearch search = new ADSearch(Directory);
search.GeneralSearchTerm = query;
var data = search.Search();
var data2 = data.Where(de => de.CanRead).ToList();
var data3 = data2.Select(de => de.CanonicalName).ToList();
var data3 = data2.Select(de => de.CanonicalName).ToList();
return FormatData(data3);
}
}
Expand Down
Loading

0 comments on commit 9b193d1

Please sign in to comment.