Add research page with MCP write tools, longer hold for repeat offenders and svn/hg decoys
Build and deploy / build (push) Successful in 1m50s
Build and deploy / deploy (push) Successful in 21s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-17 18:27:35 +01:00
1 parent a25072e6fb
commit e88dc415f9
48 files changed
+1983 -57

No files matched your search

@@ -0,0 +1,44 @@
using System.Net;
using Flypaper.Core.Models;
using Flypaper.Storage.Entities;
using Flypaper.Storage.Queries;
using Flypaper.Tests.Mcp;
using Shouldly;
namespace Flypaper.Tests.Storage;
public sealed class RepeatOffenderLookupTests : IDisposable
{
private readonly McpTestData _data = new();
[Fact]
public async Task Finds_only_timeouts_of_the_same_ip_inside_the_window()
{
using (var db = _data.Factory.CreateDbContext())
{
Add(db, "203.0.113.50", hoursAgo: 48, TrapOutcome.Timeout);
Add(db, "203.0.113.51", hoursAgo: 2, TrapOutcome.ClientAborted);
Add(db, "2001:db8::7", hoursAgo: 3, TrapOutcome.Timeout);
Add(db, "203.0.113.52", hoursAgo: 24 * 30, TrapOutcome.Timeout);
db.SaveChanges();
}
var lookup = new RepeatOffenderLookup(_data.Factory);
var since = McpTestData.Now.UtcDateTime.AddDays(-7);
(await lookup.HasTimedOutSinceAsync(IPAddress.Parse("203.0.113.50"), since, default)).ShouldBeTrue();
(await lookup.HasTimedOutSinceAsync(IPAddress.Parse("2001:db8::7"), since, default)).ShouldBeTrue();
(await lookup.HasTimedOutSinceAsync(IPAddress.Parse("203.0.113.51"), since, default)).ShouldBeFalse();
(await lookup.HasTimedOutSinceAsync(IPAddress.Parse("203.0.113.52"), since, default)).ShouldBeFalse();
(await lookup.HasTimedOutSinceAsync(IPAddress.Parse("203.0.113.99"), since, default)).ShouldBeFalse();
}
private static void Add(Flypaper.Storage.FlypaperDbContext db, string ip, int hoursAgo, TrapOutcome outcome)
{
var started = McpTestData.Now.AddHours(-hoursAgo);
db.TrapEvents.Add(TrapEventEntity.From(new TrapEvent(
Guid.NewGuid(), TrapProtocol.Http, IPAddress.Parse(ip), "html-drip", started, started.AddSeconds(3600), 100, outcome, "GET /", null)));
}
public void Dispose() => _data.Dispose();
}