Skip to content

Commit

Permalink
feat(pipeline): upgrade dotnet version and handle exceptions in Domai…
Browse files Browse the repository at this point in the history
…nThreatFeedService

- Upgraded the dotnet version from '6.x' to '9.x' in the pipeline.yaml file.
- Updated TargetFramework from 'net6.0' to 'net9.0' in ES.ThreatFeed.csproj.
- Updated all package references to their latest versions in ES.ThreatFeed.csproj.
- Added exception handling for Uri creation in DomainThreatFeedService.cs to prevent crashes on invalid entries.

BREAKING CHANGE: The application now requires .NET 9.0 or higher to run.
  • Loading branch information
winromulus committed Nov 14, 2024
1 parent bb2e888 commit c12677c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: dotnet - setup
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.x'
dotnet-version: '9.x'

- name: dotnet - publish app
run: |
Expand Down
24 changes: 12 additions & 12 deletions src/ES.ThreatFeed/ES.ThreatFeed.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand All @@ -22,17 +22,17 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.2.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.0.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>

</Project>
13 changes: 10 additions & 3 deletions src/ES.ThreatFeed/Provider/DomainThreatFeedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,16 @@ IReadOnlyList<string> ParseHostsFileFormat(string rawContent)
if (!lineParts.Any()) continue;
var entry = lineParts.Last().ToLowerInvariant().Trim();

var uri = new Uri($"protocol://{entry}", UriKind.Absolute);
if (uri.IsLoopback) continue;
if (uri.HostNameType != UriHostNameType.Dns) continue;
try
{
var uri = new Uri($"protocol://{entry}", UriKind.Absolute);
if (uri.IsLoopback) continue;
if (uri.HostNameType != UriHostNameType.Dns) continue;
}
catch(Exception)
{
continue;
}


var entryParts = entry.Split(".", StringSplitOptions.RemoveEmptyEntries);
Expand Down

0 comments on commit c12677c

Please sign in to comment.