Skip to content

Commit 4b12368

Browse files
committed
Update to net5.0
1 parent 58b9ce4 commit 4b12368

File tree

8 files changed

+66
-27
lines changed

8 files changed

+66
-27
lines changed

.github/workflows/dotnetcore.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: .NET Core
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
imagewizard:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v1
15+
- name: Setup .NET Core
16+
uses: actions/setup-dotnet@v1
17+
with:
18+
dotnet-version: 5.0.100
19+
- name: Build with dotnet
20+
run: dotnet build --configuration Release "./src"
21+
- name: Run unit tests
22+
run: dotnet test "./src"
23+
- name: Create the package
24+
run: dotnet pack --configuration Release "./src"
25+
- name: Publish "AspNetCore.Honeypot" to nuget
26+
run: dotnet nuget push "./src/AspNetCore.Honeypot/bin/Release/*.nupkg" -s "https://api.nuget.org/v3/index.json" -k ${{secrets.NUGET_API_KEY}}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
4+
<TargetFramework>net5.0</TargetFramework>
65
<Authors>usercode</Authors>
76
<Description>Simple honeypot implementation for ASP.NET Core to detect bot posts.</Description>
87
<PackageProjectUrl>https://github.com/usercode/AspNetCore.Honeypot</PackageProjectUrl>
98
<PackageTags>asp.net; honeypot</PackageTags>
10-
<AssemblyVersion>1.0.3.0</AssemblyVersion>
11-
<FileVersion>1.0.3.0</FileVersion>
12-
<Version>1.0.3</Version>
9+
<Version>1.0.5</Version>
1310
</PropertyGroup>
1411

1512
<ItemGroup>
16-
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.1.1" />
17-
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.1.1" />
18-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.1.1" />
19-
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.1.1" />
20-
<PackageReference Include="Microsoft.AspNetCore.Razor" Version="2.1.1" />
13+
<FrameworkReference Include="Microsoft.AspnetCore.App" />
2114
</ItemGroup>
22-
15+
2316
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30711.63
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore.Honeypot", "AspNetCore.Honeypot.csproj", "{D5FD3F6F-BB1C-4A48-A6D2-DCD1362AEE0B}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{D5FD3F6F-BB1C-4A48-A6D2-DCD1362AEE0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{D5FD3F6F-BB1C-4A48-A6D2-DCD1362AEE0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{D5FD3F6F-BB1C-4A48-A6D2-DCD1362AEE0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{D5FD3F6F-BB1C-4A48-A6D2-DCD1362AEE0B}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {56BAC939-FE07-47B4-B891-1CA7CCCB6971}
24+
EndGlobalSection
25+
EndGlobal

src/AspNetCore.Honeypot/Extensions.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,5 @@ public static bool IsHoneypotTrapped(this HttpContext httpContext)
3636
{
3737
return new HoneypotService().IsTrapped(httpContext);
3838
}
39-
40-
//public static void UseHoneypot(this IHtmlHelper htmlHelper)
41-
//{
42-
43-
//}
4439
}
4540
}

src/AspNetCore.Honeypot/HoneypotAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override void OnActionExecuting(ActionExecutingContext context)
4040
{
4141
base.OnActionExecuting(context);
4242

43-
bool isTrapped = new HoneypotService().IsTrapped(context.HttpContext);
43+
bool isTrapped = context.HttpContext.IsHoneypotTrapped();
4444

4545
if(isTrapped == true)
4646
{

src/AspNetCore.Honeypot/HoneypotService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace AspNetCore.Honeypot
1313
/// </summary>
1414
class HoneypotService
1515
{
16-
public const String HttpContextItemName = "AspNetCore.Honeypot.IsHoneypotTrapped";
16+
public const string HttpContextItemName = "AspNetCore.Honeypot.IsHoneypotTrapped";
1717

1818
public HoneypotService()
1919
{
@@ -27,12 +27,12 @@ public HoneypotService()
2727
/// <returns></returns>
2828
public bool IsTrapped(HttpContext httpContext)
2929
{
30-
if (httpContext.Items.TryGetValue(HttpContextItemName, out Object value) == false)
30+
if (httpContext.Items.TryGetValue(HttpContextItemName, out object value) == false)
3131
{
3232
HoneypotSettings settings = httpContext.RequestServices.GetRequiredService<HoneypotSettings>();
3333

3434
bool trapped = httpContext.Request.Form
35-
.Any(x => settings.IsFieldName(x.Key) && x.Value.Any(v => String.IsNullOrEmpty(v) == false));
35+
.Any(x => settings.IsFieldName(x.Key) && x.Value.Any(v => string.IsNullOrEmpty(v) == false));
3636

3737
httpContext.Items.Add(HttpContextItemName, trapped);
3838

src/AspNetCore.Honeypot/HoneypotSettings.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ public HoneypotSettings()
1515

1616
}
1717

18-
public HoneypotSettings(String prefix)
18+
public HoneypotSettings(string prefix)
1919
{
2020
Prefix = prefix;
2121
}
2222

2323
/// <summary>
2424
/// Prefix
2525
/// </summary>
26-
public String Prefix { get; set; }
26+
public string Prefix { get; set; }
2727

28-
internal bool IsFieldName(String name)
28+
internal bool IsFieldName(string name)
2929
{
3030
return name.StartsWith($"{Prefix}");
3131
}
3232

33-
internal String GetFieldName(String name)
33+
internal string GetFieldName(string name)
3434
{
3535
return $"{Prefix}{name}";
3636
}
3737

38-
internal String GetTimeFieldName()
38+
internal string GetTimeFieldName()
3939
{
4040
return $"{Prefix}_time";
4141
}

src/AspNetCore.Honeypot/HoneypotTagHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ public HoneypotTagHelper(HoneypotSettings settings)
2424
/// <summary>
2525
/// Name
2626
/// </summary>
27-
public String Name { get; set; }
27+
public string Name { get; set; }
2828

2929
public override void Process(TagHelperContext context, TagHelperOutput output)
3030
{
3131
base.Process(context, output);
3232

3333
output.TagName = "div";
3434

35-
String fieldName = Settings.GetFieldName(Name);
35+
string fieldName = Settings.GetFieldName(Name);
3636

3737
TagBuilder input = new TagBuilder("input");
3838
input.MergeAttribute("name", fieldName);

0 commit comments

Comments
 (0)