Add Flypaper solution skeleton with HTTP tarpit, SQLite event log and tests
This commit is contained in:
1 parent
20314268c6
commit
f9161f48e7
55 files changed
+1331
No files matched your search
@@ -0,0 +1,41 @@
|
||||
using Flypaper.Http;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Shouldly;
|
||||
|
||||
namespace Flypaper.Tests;
|
||||
|
||||
public sealed class TrapMatcherTests
|
||||
{
|
||||
private readonly TrapMatcher _matcher = new(Options.Create(new HttpTrapOptions
|
||||
{
|
||||
KnownHosts = ["example.com", "*.example.org"],
|
||||
TrapPaths = ["/.env", "/.git/*", "/wp-login.php"]
|
||||
}));
|
||||
|
||||
[Theory]
|
||||
[InlineData("example.com", "/")]
|
||||
[InlineData("EXAMPLE.com", "/index.html")]
|
||||
[InlineData("app.example.org", "/api/items")]
|
||||
[InlineData("example.com", "/.envelope")]
|
||||
[InlineData("example.com", "/.git")]
|
||||
public void Lets_normal_requests_pass(string host, string path) =>
|
||||
_matcher.Match(host, path).ShouldBe(TrapMatch.None);
|
||||
|
||||
[Theory]
|
||||
[InlineData("example.com", "/.env")]
|
||||
[InlineData("example.com", "/.ENV")]
|
||||
[InlineData("example.com", "/.env/")]
|
||||
[InlineData("example.com", "/.git/config")]
|
||||
[InlineData("app.example.org", "/wp-login.php")]
|
||||
public void Traps_configured_paths(string host, string path) =>
|
||||
_matcher.Match(host, path).ShouldBe(TrapMatch.TrapPath);
|
||||
|
||||
[Theory]
|
||||
[InlineData("unknown.net", "/")]
|
||||
[InlineData("203.0.113.7", "/")]
|
||||
[InlineData("example.org", "/")]
|
||||
[InlineData("", "/")]
|
||||
[InlineData(null, "/")]
|
||||
public void Traps_unknown_hosts(string? host, string path) =>
|
||||
_matcher.Match(host, path).ShouldBe(TrapMatch.UnknownHost);
|
||||
}
|
||||
Reference in new issue
Block a user