4 Commits
Author SHA1 Message Date
TomandClaude Opus 5.5 7f8a3ae882 Prepare changelog for 0.5.2
Build and deploy / build (push) Successful in 1m41s
Release / image (push) Successful in 2m1s
Build and deploy / deploy (push) Successful in 23s
Release / release (push) Successful in 7s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:29:53 +01:00
TomandClaude Opus 5.5 cbd9830143 Group strategies by base type and rank them by median hold time
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:29:53 +01:00
TomandClaude Opus 5.5 d2cbab5d4b Prepare changelog for 0.5.1
Build and deploy / build (push) Successful in 1m41s
Release / image (push) Successful in 2m7s
Build and deploy / deploy (push) Successful in 22s
Release / release (push) Successful in 6s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:52:11 +01:00
TomandClaude Opus 5.5 0655af2699 Show plain German strategy names with explanations in the dashboard
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 18:52:11 +01:00
14 changed files with 527 additions and 33 deletions

No files matched your search

+26 -1
View File
@@ -6,6 +6,29 @@ All notable changes to Flypaper are documented in this file. The format follows
## [Unreleased]
## [0.5.2] - 2026-11-17
### Changed
- Dashboard, Top 10 „Strategien“: strategies are grouped by base type, so `html-drip` with any drip speed
is one row „Endlose Webseite“; the old name `drip` counts as the same. Only `head`, `link` and `repeat` stay
separate rows and show small badges („Schnellstart“, „Links“, „Wiederholer“). The drip parameters moved to the
tooltip and the expanded row.
- Columns are now catches, **median hold time per catch** and total. The bar and the default sort use the median
(rows with fewer than 5 catches are greyed out, marked „wenige Daten“ and listed last).
- Clicking a row filters the catch list on all variants of the group. The catch list, filter chip and
expanded row show name plus badges. Old `?strategie=` links still work.
## [0.5.1] - 2026-11-17
### Changed
- Dashboard: strategies are shown with a plain German name (e.g. „Link-Labyrinth“, „Gefälschte Zugangsdaten
(.env)“) instead of the technical abbreviation. Tooltip and expanded row (also on touch devices) explain what
the bot gets, spell out the suffixes (`50-500ms 1-1024B`, `head`, `link`, `repeat`) and show the technical name.
Used in the catch list, the Top 10 „Strategien“ tab, filter chips and the page „Erkenntnisse“. The search also
finds the German names. Unknown names are shown unchanged. Stored values and MCP results stay technical.
## [0.5.0] - 2026-11-17
### Fixed
@@ -174,7 +197,9 @@ First release.
- Unraid Docker template; when started as root, the container hands `/data` to its app user
and drops privileges.
[Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.5.0...main
[Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.5.2...main
[0.5.2]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.5.2
[0.5.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.5.1
[0.5.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.5.0
[0.4.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.4.0
[0.3.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.3.1
@@ -10,9 +10,11 @@ public sealed record DashboardData(
TimeSpan TotalHoldTime,
IReadOnlyList<TopEntry> TopIps,
IReadOnlyList<TopEntry> TopTargets,
IReadOnlyList<TopEntry> TopStrategies,
IReadOnlyList<StrategySample> StrategyCatches,
IReadOnlyList<TopEntry> TopCountries,
IReadOnlyList<TopEntry> TopProviders,
IReadOnlyDictionary<string, int> CatchesByCountry);
public sealed record TopEntry(string Key, int Count, TimeSpan HoldTime, string? Label = null);
public sealed record TopEntry(string Key, int Count, TimeSpan HoldTime, string? Label = null, TimeSpan? MedianHold = null);
public sealed record StrategySample(string Strategy, long DurationMs);
@@ -42,7 +42,7 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
TimeSpan.FromMilliseconds(await catches.SumAsync(e => e.DurationMs, ct)),
await TopAsync(catches.GroupBy(e => e.RemoteIp), ct),
await TopAsync(catches.Where(e => e.Target != null).GroupBy(e => e.Target!), ct),
await TopAsync(catches.GroupBy(e => e.Strategy), ct),
await catches.Select(e => new StrategySample(e.Strategy, e.DurationMs)).ToListAsync(ct),
countries
.Take(TopCount)
.Select(x => new TopEntry(x.Key, x.Count, TimeSpan.FromMilliseconds(x.DurationMs), x.Name))
@@ -107,14 +107,28 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
if (filter.Strategy is { } strategy)
{
events = events.Where(e => e.Strategy == strategy);
var bases = strategy.Bases;
events = events.Where(e => bases.Any(name => e.Strategy == name || EF.Functions.Like(e.Strategy, name + " %", "\\")));
foreach (var flag in strategy.With)
{
var pattern = $"% {flag} %";
events = events.Where(e => EF.Functions.Like(" " + e.Strategy + " ", pattern, "\\"));
}
foreach (var flag in strategy.Without)
{
var pattern = $"% {flag} %";
events = events.Where(e => !EF.Functions.Like(" " + e.Strategy + " ", pattern, "\\"));
}
}
if (!string.IsNullOrWhiteSpace(filter.Search))
{
var pattern = $"%{filter.Search.Trim().Replace("\\", "\\\\").Replace("%", "\\%").Replace("_", "\\_")}%";
var strategyNames = filter.SearchStrategies ?? [];
events = events.Where(e =>
EF.Functions.Like(e.RemoteIp, pattern, "\\")
|| strategyNames.Any(name => e.Strategy == name || EF.Functions.Like(e.Strategy, name + " %", "\\"))
|| EF.Functions.Like(e.Provider!, pattern, "\\")
|| EF.Functions.Like(e.Target!, pattern, "\\")
|| EF.Functions.Like(e.Strategy, pattern, "\\")
@@ -10,9 +10,10 @@ public sealed record RecentFilter(
long? Asn = null,
string? Ip = null,
string? Target = null,
string? Strategy = null,
StrategyMatch? Strategy = null,
string? Search = null,
int Limit = RecentFilter.DefaultLimit)
int Limit = RecentFilter.DefaultLimit,
IReadOnlyList<string>? SearchStrategies = null)
{
public const int DefaultLimit = 50;
public const int MaxLimit = 500;
@@ -21,3 +22,5 @@ public sealed record RecentFilter(
public sealed record RecentCatches(IReadOnlyList<TrapEventEntity> Items, int Total, IReadOnlyList<CountryOption> Countries);
public sealed record CountryOption(string Code, string? Name);
public sealed record StrategyMatch(IReadOnlyList<string> Bases, IReadOnlyList<string> With, IReadOnlyList<string> Without);
@@ -2,6 +2,7 @@ using System.Globalization;
using System.Net;
using Flypaper.Core.Models;
using Flypaper.Storage.Dashboard;
using Flypaper.Web.Components.Shared;
namespace Flypaper.Web.Components.Pages.Dashboard;
@@ -47,7 +48,7 @@ public sealed record DashboardFilter(
Asn(provider) is { } asn ? $"AS{asn.ToString(CultureInfo.InvariantCulture)}" : null,
IPAddress.TryParse(Clean(ip), out var address) ? address.ToString() : null,
Clean(ziel),
Clean(strategie),
Clean(strategie) is { } strategy ? StrategyNames.GroupKey(strategy) : null,
Clean(q),
parsedLimit);
}
@@ -70,7 +71,7 @@ public sealed record DashboardFilter(
Asn(Provider),
Ip,
Ziel,
Strategie,
StrategyNames.Group(Strategie),
Q,
Limit);
@@ -81,7 +81,7 @@
@foreach (var tab in tabs)
{
<div role="tabpanel" id="panel-@tab.Id" aria-labelledby="tab-@tab.Id" tabindex="0" hidden="@(tab != tabs[0])">
<TopTable KeyLabel="@tab.KeyLabel" Entries="tab.Entries" ShowFlags="tab.ShowFlags" KeyFormatter="tab.KeyFormatter" LabelFormatter="tab.LabelFormatter"
<TopTable KeyLabel="@tab.KeyLabel" Entries="tab.Entries" ShowFlags="tab.ShowFlags" KeyFormatter="tab.KeyFormatter" LabelFormatter="tab.LabelFormatter" TitleFormatter="tab.TitleFormatter" BadgesFormatter="tab.BadgesFormatter"
Href="entry => TopFilter(tab, entry).Href()" IsActive="entry => tab.Current(_filter) == entry.Key" />
</div>
}
@@ -178,6 +178,7 @@
var target = Formatting.Target(trapEvent.Target);
var duration = Formatting.Duration(TimeSpan.FromMilliseconds(trapEvent.DurationMs));
var bytes = Formatting.Number(trapEvent.BytesSent);
var strategy = StrategyNames.Describe(trapEvent.Strategy);
<tr id="f@(index)" data-expand="event:@trapEvent.Id" tabindex="0" aria-expanded="false" class="@(trapEvent.Outcome == TrapOutcome.Rejected ? "rejected" : null)">
<td class="c-time"><span class="c-date">@started.ToString("dd.MM.")&nbsp;</span>@started.ToString("HH:mm:ss")</td>
<td class="c-ip mono" title="@trapEvent.RemoteIp">@trapEvent.RemoteIp</td>
@@ -195,13 +196,28 @@
<td class="c-target mono" title="@target">
@target
<div class="extra extra-md">Provider: @(provider ?? "–")</div>
<div class="extra extra-md">Strategie: @trapEvent.Strategy</div>
<div class="extra extra-md">User-Agent: @(trapEvent.ClientInfo ?? "–")</div>
<div class="extra extra-all strategy-info">
<strong>@strategy.DisplayName</strong>
@foreach (var badge in strategy.Badges)
{
<span class="badge">@badge</span>
}
@if (strategy.Explanation is not null)
{
<div>@strategy.Explanation</div>
}
@foreach (var detail in strategy.Details)
{
<div>@detail</div>
}
<div class="mono">@strategy.Raw</div>
</div>
<div class="extra extra-all">Herkunft: @(trapEvent.CountryCode is { } code ? $"{Formatting.Flag(code)} {code} · {Origin(trapEvent)}" : "–")</div>
<div class="extra extra-sm">Dauer: @duration · Bytes: @bytes</div>
<div class="extra extra-xs">Datum: @started.ToString("dd.MM.yyyy") · Ausgang: @OutcomeLabel(trapEvent.Outcome)</div>
</td>
<td class="c-strategy mono" title="@trapEvent.Strategy">@trapEvent.Strategy</td>
<td class="c-strategy" title="@strategy.Tooltip">@strategy.DisplayName@foreach (var badge in strategy.Badges){<span class="badge">@badge</span>}</td>
<td class="c-agent" title="@trapEvent.ClientInfo">@trapEvent.ClientInfo</td>
<td class="c-duration num">@duration</td>
<td class="c-bytes num">@bytes</td>
@@ -260,7 +276,7 @@
{
_filter = DashboardFilter.Parse(Zeit, Ausgang, Land, Provider, Ip, Ziel, Strategie, Q, Limit);
_data = await Queries.GetAsync();
_recent = await Queries.GetRecentAsync(_filter.ToRecentFilter());
_recent = await Queries.GetRecentAsync(_filter.ToRecentFilter() with { SearchStrategies = StrategyNames.Matching(_filter.Q) });
_loadedAt = DateTime.Now;
}
@@ -270,7 +286,7 @@
new("providers", "Provider", "Provider", data.TopProviders, f => f.Provider, (f, key) => f with { Provider = key }),
new("ips", "IPs", "IP", data.TopIps, f => f.Ip, (f, key) => f with { Ip = key }),
new("targets", "Ziele", "Ziel", data.TopTargets, f => f.Ziel, (f, key) => f with { Ziel = key }, KeyFormatter: Formatting.Target),
new("strategies", "Strategien", "Strategie", data.TopStrategies, f => f.Strategie, (f, key) => f with { Strategie = key })
new("strategies", "Strategien", "Strategie", StrategyNames.Rank(data.StrategyCatches, 10), f => f.Strategie, (f, key) => f with { Strategie = key }, KeyFormatter: _ => "", LabelFormatter: (key, _) => StrategyNames.Display(key), TitleFormatter: key => StrategyNames.Describe(key).Tooltip, BadgesFormatter: key => StrategyNames.Describe(key).Badges)
];
private DashboardFilter TopFilter(TopTab tab, TopEntry entry) =>
@@ -314,7 +330,8 @@
if (_filter.Strategie is { } strategie)
{
yield return ($"Strategie: {strategie}", reset with { Strategie = null });
var badges = StrategyNames.Describe(strategie).Badges;
yield return ($"Strategie: {StrategyNames.Display(strategie)}{(badges.Count == 0 ? "" : $" ({string.Join(", ", badges)})")}", reset with { Strategie = null });
}
if (_filter.Q is { } q)
@@ -344,5 +361,7 @@
Func<DashboardFilter, string?, DashboardFilter> Set,
bool ShowFlags = false,
Func<string?, string?>? KeyFormatter = null,
Func<string?, string?, string?>? LabelFormatter = null);
Func<string?, string?, string?>? LabelFormatter = null,
Func<string?, string?>? TitleFormatter = null,
Func<string?, IReadOnlyList<string>>? BadgesFormatter = null);
}
@@ -1,25 +1,40 @@
@using System.Globalization
@using Flypaper.Storage.Dashboard
@using Flypaper.Web.Components.Shared
@{
var byMedian = Entries.Any(entry => entry.MedianHold is not null);
var barMax = byMedian
? Entries.Where(entry => entry.Count >= StrategyNames.MinCatches).Select(entry => entry.MedianHold!.Value.TotalMilliseconds).DefaultIfEmpty(0).Max()
: Entries.Count == 0 ? 0 : Entries[0].Count;
}
@if (Entries.Count == 0)
{
<p class="empty">Noch keine Einträge.</p>
}
else
{
<table class="top-table">
<table class="top-table @(byMedian ? "by-median" : null)">
<colgroup>
<col />
<col class="share" />
<col class="count" />
<col class="hold" />
@if (byMedian)
{
<col class="hold" />
}
<col class="hold sum" />
</colgroup>
<thead>
<tr>
<th>@KeyLabel</th>
<th><span class="sr-only">Anteil</span></th>
<th class="num">Fänge</th>
<th class="num">Haltezeit</th>
@if (byMedian)
{
<th class="num" title="Mittlere Haltezeit pro Fang (Median): Einzelne Dauerhalter verfälschen sie nicht">Median</th>
}
<th class="num sum">@(byMedian ? "Summe" : "Haltezeit")</th>
</tr>
</thead>
<tbody>
@@ -27,10 +42,18 @@ else
{
var key = KeyFormatter?.Invoke(entry.Key) ?? entry.Key;
var label = LabelFormatter is null ? entry.Label : LabelFormatter(entry.Key, entry.Label);
var share = (entry.Count * 100.0 / Entries[0].Count).ToString("0.#", CultureInfo.InvariantCulture);
var value = byMedian ? entry.MedianHold!.Value.TotalMilliseconds : entry.Count;
var share = (barMax == 0 ? 0 : Math.Min(100, value * 100.0 / barMax)).ToString("0.#", CultureInfo.InvariantCulture);
var sparse = byMedian && entry.Count < StrategyNames.MinCatches;
var badges = BadgesFormatter?.Invoke(entry.Key) ?? [];
var active = IsActive(entry);
var title = label is null ? key : $"{label} · {key}";
<tr data-href="@Href(entry)" class="@(active ? "active" : null)">
var title = TitleFormatter?.Invoke(entry.Key) ?? (label is null ? key : $"{label} · {key}");
if (sparse)
{
title += $"\nNur {entry.Count} {(entry.Count == 1 ? "Fang" : "Fänge")}: wenig aussagekräftig";
}
<tr data-href="@Href(entry)" class="@(active ? "active" : null) @(sparse ? "sparse" : null)">
<td class="clip" title="@title">
<a href="@Href(entry)" aria-current="@(active ? "true" : null)" title="@(active ? $"Filter {title} entfernen" : $"Fänge filtern: {title}")">
@if (ShowFlags)
@@ -40,7 +63,18 @@ else
@if (label is not null)
{
<span class="top-label">@label</span>
<span class="top-key mono">@key</span>
@foreach (var badge in badges)
{
<span class="badge">@badge</span>
}
@if (sparse)
{
<span class="badge sparse-note">wenige Daten</span>
}
@if (key.Length > 0)
{
<span class="top-key mono">@key</span>
}
}
else
{
@@ -50,11 +84,19 @@ else
</td>
<td><span class="share-bar" style="--share: @(share)%"></span></td>
<td class="num">@Formatting.Number(entry.Count)</td>
<td class="num">@Formatting.Duration(entry.HoldTime)</td>
@if (byMedian)
{
<td class="num">@Formatting.Duration(entry.MedianHold!.Value)</td>
}
<td class="num sum">@Formatting.Duration(entry.HoldTime)</td>
</tr>
}
</tbody>
</table>
@if (byMedian)
{
<p class="top-note">Balken = Median Haltezeit pro Fang. Unter @StrategyNames.MinCatches Fängen wenig aussagekräftig, diese Zeilen stehen am Ende.</p>
}
}
@code {
@@ -68,6 +110,10 @@ else
[Parameter] public Func<string?, string?, string?>? LabelFormatter { get; set; }
[Parameter] public Func<string?, string?>? TitleFormatter { get; set; }
[Parameter] public Func<string?, IReadOnlyList<string>>? BadgesFormatter { get; set; }
[Parameter, EditorRequired] public required Func<TopEntry, string> Href { get; set; }
[Parameter, EditorRequired] public required Func<TopEntry, bool> IsActive { get; set; }
@@ -44,7 +44,7 @@
<p class="lab-meta">
@foreach (var strategy in entry.StrategyList)
{
<code>@strategy</code>
<code title="@StrategyNames.Describe(strategy).Tooltip">@StrategyNames.Display(strategy)</code>
}
@if (entry.Commit is { } commit)
{
@@ -68,7 +68,7 @@
<SettingsField Label="Wiederholer erkennen" For="repeat-window" Unit="Tage" Hint="0 bis 365, 0 = aus. IPs mit einem Timeout in diesem Zeitraum gelten als Wiederholer" Errors="_errors" Key="@nameof(HoldMethodModel.RepeatWindowDays)">
<InputText id="repeat-window" @bind-Value="Model!.RepeatWindowDays" inputmode="numeric" />
</SettingsField>
<SettingsField Label="Haltedauer für Wiederholer" For="repeat-hold" Hint="d.hh:mm:ss, höchstens 7 Tage. Strategie bekommt den Zusatz repeat" Errors="_errors" Key="@nameof(HoldMethodModel.RepeatHoldDuration)">
<SettingsField Label="Haltedauer für Wiederholer" For="repeat-hold" Hint="d.hh:mm:ss, höchstens 7 Tage. Strategie bekommt den Zusatz repeat („Wiederholer“)" Errors="_errors" Key="@nameof(HoldMethodModel.RepeatHoldDuration)">
<InputText id="repeat-hold" @bind-Value="Model!.RepeatHoldDuration" />
</SettingsField>
</div>
@@ -0,0 +1,188 @@
using System.Globalization;
using System.Text.RegularExpressions;
using Flypaper.Storage.Dashboard;
namespace Flypaper.Web.Components.Shared;
public sealed record StrategyInfo(string Raw, string BaseName, string DisplayName, string? Explanation, IReadOnlyList<string> Details, IReadOnlyList<string> Flags)
{
public string GroupKey => string.Join(' ', [BaseName, .. Flags]);
public IReadOnlyList<string> Badges => Flags.Select(StrategyNames.BadgeLabel).ToList();
public string Tooltip
{
get
{
var lines = new List<string> { DisplayName };
if (Explanation is not null)
{
lines.Add(Explanation);
}
lines.AddRange(Details);
lines.Add($"Technisch: {Raw}");
return string.Join("\n", lines);
}
}
}
public static partial class StrategyNames
{
private static readonly Dictionary<string, (string Name, string Explanation)> Known = new(StringComparer.Ordinal)
{
["maze-drip"] = ("Link-Labyrinth", "Eine Webseite voller Links, die immer zu neuen, erfundenen Seiten führen. Der Bot folgt ihnen und verirrt sich, während alles nur tröpfchenweise ankommt."),
["index-drip"] = ("Gefälschtes Ordner-Listing", "Eine Dateiliste im Stil von „Index of /…“ mit erfundenen Ordnern und Dateien. Wer weiterklickt, landet im Link-Labyrinth."),
["html-drip"] = ("Endlose Webseite", "Eine gewöhnlich aussehende Webseite, die nie aufhört und nur Stück für Stück geliefert wird. Der Bot wartet auf das Ende, das nie kommt."),
["text-drip"] = ("Endloser Text", "Unendlicher Fließtext ohne Formatierung, der nur tröpfchenweise ankommt. Der Bot wartet auf das Ende, das nie kommt."),
["env-drip"] = ("Gefälschte Zugangsdaten (.env)", "Eine erfundene .env-Datei mit Passwörtern und Schlüsseln, die nie endet. Bots, die nach geleakten Zugangsdaten suchen, lesen sie bis zum Ende."),
["git-drip"] = ("Gefälschtes Git-Projekt", "Eine erfundene Git-Konfiguration, die wie die echte beginnt und nie endet. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
["svn-drip"] = ("Gefälschtes Subversion-Projekt", "Erfundene Dateien aus einem .svn-Ordner, die wie die echten beginnen und nie enden. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
["hg-drip"] = ("Gefälschtes Mercurial-Projekt", "Erfundene Dateien aus einem .hg-Ordner, die wie die echten beginnen und nie enden. Bots, die Quellcode abgreifen wollen, bleiben daran hängen."),
["json-drip"] = ("Gefälschte JSON-Datei", "Eine erfundene JSON-Datei, die nie endet. Bots, die Konfigurationen und Daten einsammeln, warten auf das Dateiende."),
["xml-drip"] = ("Gefälschte XML-Datei", "Eine erfundene XML-Datei, die nie endet. Bots, die Konfigurationen und Daten einsammeln, warten auf das Dateiende."),
["yaml-drip"] = ("Gefälschte YAML-Datei", "Eine erfundene YAML-Konfiguration, die nie endet. Bots, die Konfigurationen einsammeln, warten auf das Dateiende."),
["sql-drip"] = ("Gefälschter Datenbank-Export (SQL)", "Ein erfundener SQL-Dump mit endlos vielen Einträgen. Bots, die nach Datenbank-Backups suchen, laden ihn herunter, solange es geht."),
["hikvision-drip"] = ("Gefälschte Überwachungskamera (Hikvision)", "Die Antwort einer erfundenen Hikvision-Kamera, die nie endet. Bots, die nach angreifbaren Kameras suchen, warten auf die komplette Antwort."),
["wordpress-drip"] = ("Gefälschte WordPress-Anmeldung", "Eine erfundene WordPress-Anmeldeseite, die nie fertig geladen wird. Bots, die Passwörter durchprobieren, kommen nie zum Formular."),
["robots-static"] = ("robots.txt (Hinweis an brave Crawler)", "Die robots.txt wird sofort und vollständig geliefert. Sie verbietet alles, brave Crawler bleiben draußen. Es wird bewusst niemand festgehalten."),
["robots-bait"] = ("Köder aus der robots.txt", "Ein Pfad, der in der robots.txt als verboten steht, aber ins Link-Labyrinth führt. Wer dort landet, hat das Verbot gelesen und ignoriert. Er wird mindestens 24 Stunden festgehalten.")
};
private static readonly Dictionary<string, string> Aliases = new(StringComparer.Ordinal)
{
["drip"] = "html-drip"
};
private static readonly string[] VariantFlags = ["head", "link", "repeat"];
private static readonly HashSet<string> LinkedByDesign = new(StringComparer.Ordinal) { "maze-drip", "index-drip", "robots-bait" };
public const int MinCatches = 5;
public static string BadgeLabel(string flag) => flag switch
{
"head" => "Schnellstart",
"link" => "Links",
"repeat" => "Wiederholer",
_ => flag
};
public static StrategyInfo Describe(string? strategy)
{
var raw = strategy?.Trim() ?? "";
var tokens = raw.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (tokens.Length == 0)
{
return new StrategyInfo(raw, raw, raw, null, [], []);
}
var baseName = Aliases.GetValueOrDefault(tokens[0], tokens[0]);
var flags = VariantFlags
.Where(flag => tokens.Skip(1).Contains(flag) && !(flag == "link" && LinkedByDesign.Contains(baseName)))
.ToList();
var details = new List<string>();
if (baseName != tokens[0])
{
details.Add($"früherer Name von {Known[baseName].Name}");
}
for (var i = 1; i < tokens.Length; i++)
{
var token = tokens[i];
if (DelayPattern().Match(token) is { Success: true } delay
&& i + 1 < tokens.Length && SizePattern().Match(tokens[i + 1]) is { Success: true } chunk)
{
details.Add($"tröpfelt {Range(chunk.Groups[1].Value, chunk.Groups[2].Value)} Byte alle {Range(delay.Groups[1].Value, delay.Groups[2].Value)} ms");
i++;
}
else if (token is "head" or "link" && i + 1 < tokens.Length && SingleSizePattern().Match(tokens[i + 1]) is { Success: true } size)
{
var bytes = Number(size.Groups[1].Value);
details.Add(token == "head"
? $"schneller Start: die ersten {bytes} Byte sofort"
: $"alle {bytes} Byte ein Link");
i++;
}
else if (token is "head" or "link")
{
details.Add(token == "head" ? "schneller Start: erste Bytes sofort" : "enthält Links");
}
else if (token == "repeat")
{
details.Add("Wiederholer: darf länger festgehalten werden");
}
else
{
details.Add(token);
}
}
return Known.TryGetValue(baseName, out var known)
? new StrategyInfo(raw, baseName, known.Name, known.Explanation, details, flags)
: new StrategyInfo(raw, baseName, baseName, null, details, flags);
}
public static string Display(string? strategy) => Describe(strategy).DisplayName;
public static string GroupKey(string? strategy) => Describe(strategy).GroupKey;
public static StrategyMatch? Group(string? strategy)
{
var info = Describe(strategy);
if (info.BaseName.Length == 0)
{
return null;
}
var bases = Aliases.Where(pair => pair.Value == info.BaseName).Select(pair => pair.Key).Prepend(info.BaseName).ToList();
var variableFlags = VariantFlags.Where(flag => !(flag == "link" && LinkedByDesign.Contains(info.BaseName)));
return new StrategyMatch(bases, info.Flags, variableFlags.Except(info.Flags).ToList());
}
public static IReadOnlyList<TopEntry> Rank(IEnumerable<StrategySample> samples, int take)
{
var groups = samples
.GroupBy(sample => GroupKey(sample.Strategy))
.Select(group =>
{
var durations = group.Select(sample => sample.DurationMs).Order().ToList();
var middle = durations.Count / 2;
var median = durations.Count % 2 == 1 ? durations[middle] : (durations[middle - 1] + durations[middle]) / 2d;
return new TopEntry(group.Key, durations.Count, TimeSpan.FromMilliseconds(durations.Sum()), MedianHold: TimeSpan.FromMilliseconds(median));
});
return groups
.OrderBy(entry => entry.Count < MinCatches)
.ThenByDescending(entry => entry.MedianHold)
.ThenByDescending(entry => entry.Count)
.Take(take)
.ToList();
}
public static IReadOnlyList<string> Matching(string? search)
{
var term = search?.Trim();
if (string.IsNullOrEmpty(term))
{
return [];
}
var keys = Known.Where(pair => pair.Value.Name.Contains(term, StringComparison.CurrentCultureIgnoreCase)).Select(pair => pair.Key).ToList();
return [.. keys, .. Aliases.Where(pair => keys.Contains(pair.Value)).Select(pair => pair.Key)];
}
private static string Range(string min, string max) => min == max ? Number(min) : $"{Number(min)}–{Number(max)}";
private static string Number(string digits) => long.Parse(digits, CultureInfo.InvariantCulture).ToString("N0", Formatting.German);
[GeneratedRegex(@"^(\d+)-(\d+)ms$")]
private static partial Regex DelayPattern();
[GeneratedRegex(@"^(\d+)-(\d+)B$")]
private static partial Regex SizePattern();
[GeneratedRegex(@"^(\d+)B$")]
private static partial Regex SingleSizePattern();
}
+43
View File
@@ -266,6 +266,33 @@ code {
font-size: 12px;
}
.badge {
display: inline-block;
margin-left: 6px;
padding: 0 6px;
border-radius: 999px;
background: color-mix(in srgb, var(--text) 8%, transparent);
color: var(--muted);
font-size: 11px;
line-height: 17px;
white-space: nowrap;
vertical-align: 1px;
}
.top-table tr.sparse td {
opacity: 0.55;
}
.top-note {
margin: 8px 0 0;
color: var(--muted);
font-size: 12px;
}
.top-table.by-median .count {
width: 52px;
}
.top-table tr[data-href] {
cursor: pointer;
}
@@ -468,6 +495,10 @@ a.button:hover {
width: 190px;
}
.recent-table .strategy-info div {
margin-top: 2px;
}
.recent-table .extra {
display: none;
margin-top: 4px;
@@ -1013,6 +1044,18 @@ button.danger {
width: 84px;
}
.top-table.by-median .sum {
display: none;
}
.top-table.by-median .count {
width: 48px;
}
.top-table.by-median .clip {
white-space: normal;
}
.nav .brand {
margin-right: 4px;
font-size: 0;
@@ -1,4 +1,7 @@
using System.Net;
using Flypaper.Core.Models;
using Flypaper.Storage.Entities;
using Flypaper.Web.Components.Shared;
using Flypaper.Storage.Dashboard;
using Flypaper.Tests.Fakes;
using Flypaper.Tests.Mcp;
@@ -47,19 +50,42 @@ public sealed class RecentCatchesTests : IDisposable
[Fact]
public async Task Matches_strategy_exactly()
{
var recent = await _queries.GetRecentAsync(new RecentFilter(Strategy: "env-drip"));
var recent = await _queries.GetRecentAsync(new RecentFilter(Strategy: StrategyNames.Group("env-drip")));
recent.Total.ShouldBe(2);
recent.Items.ShouldAllBe(e => e.Strategy == "env-drip");
}
[Fact]
public async Task Dashboard_ranks_strategies_among_catches()
public async Task Dashboard_lists_strategy_durations_among_catches()
{
var data = await _queries.GetAsync();
data.TopStrategies.Select(s => (s.Key, s.Count)).ShouldBe([("html-drip", 4), ("env-drip", 1)]);
data.TopStrategies[1].HoldTime.ShouldBe(TimeSpan.FromHours(1));
data.StrategyCatches.Count.ShouldBe(5);
data.StrategyCatches.Count(s => s.Strategy == "env-drip").ShouldBe(1);
data.StrategyCatches.Single(s => s.Strategy == "env-drip").DurationMs.ShouldBe(3_600_000);
}
[Fact]
public async Task Strategy_group_matches_all_variants_of_the_base_type_and_its_old_name()
{
await using (var db = _data.Factory.CreateDbContext())
{
foreach (var strategy in new[] { "drip", "html-drip 50-500ms 1-640B", "html-drip 5-20ms 1-64B head 1024B", "html-drip 50-500ms 1-1024B repeat", "html-drip 50-500ms 1-64B head 1024B repeat" })
{
db.TrapEvents.Add(TrapEventEntity.From(new TrapEvent(Guid.NewGuid(), TrapProtocol.Http, IPAddress.Parse("192.0.2.1"), strategy, McpTestData.Now, McpTestData.Now, 0, TrapOutcome.ClientAborted, null, null)));
}
await db.SaveChangesAsync();
}
async Task<IReadOnlyList<string>> Find(string group) =>
(await _queries.GetRecentAsync(new RecentFilter(Strategy: StrategyNames.Group(group)))).Items.Select(e => e.Strategy).OrderBy(s => s).ToList();
(await Find("html-drip")).Where(s => s != "html-drip").ShouldBe(["drip", "html-drip 50-500ms 1-640B"]);
(await Find("html-drip head")).ShouldBe(["html-drip 5-20ms 1-64B head 1024B"]);
(await Find("html-drip repeat")).ShouldBe(["html-drip 50-500ms 1-1024B repeat"]);
(await Find("html-drip head repeat")).ShouldBe(["html-drip 50-500ms 1-64B head 1024B repeat"]);
}
[Theory]
@@ -76,6 +102,15 @@ public sealed class RecentCatchesTests : IDisposable
recent.Total.ShouldBe(expected);
}
[Fact]
public async Task Search_also_matches_strategy_base_names_from_display_names()
{
var recent = await _queries.GetRecentAsync(new RecentFilter(Search: "Zugangsdaten", SearchStrategies: ["env-drip"]));
recent.Total.ShouldBe(2);
recent.Items.ShouldAllBe(e => e.Strategy == "env-drip");
}
[Fact]
public async Task Returns_an_empty_result_when_nothing_matches()
{
@@ -13,7 +13,11 @@ public sealed class DashboardFilterTests
var filter = DashboardFilter.Parse("24h", "Abgelehnt", "hk", "as4134", " 203.0.113.9 ", "GET /.env", " env-drip ", " wp ", "100");
filter.ShouldBe(new DashboardFilter("24h", "abgelehnt", "HK", "AS4134", "203.0.113.9", "GET /.env", "env-drip", "wp", 100));
filter.ToRecentFilter().ShouldBe(new RecentFilter(TimeSpan.FromHours(24), TrapOutcome.Rejected, "HK", 4134, "203.0.113.9", "GET /.env", "env-drip", "wp", 100));
var recent = filter.ToRecentFilter();
recent.ShouldBe(new RecentFilter(TimeSpan.FromHours(24), TrapOutcome.Rejected, "HK", 4134, "203.0.113.9", "GET /.env", recent.Strategy, "wp", 100));
recent.Strategy!.Bases.ShouldBe(["env-drip"]);
recent.Strategy.With.ShouldBeEmpty();
recent.Strategy.Without.ShouldBe(["head", "link", "repeat"]);
}
[Theory]
@@ -44,8 +48,8 @@ public sealed class DashboardFilterTests
public void Builds_links_without_defaults_and_with_escaping()
{
new DashboardFilter().Href().ShouldBe("/#faenge");
new DashboardFilter(Land: "CN", Ziel: "GET example.com/a&b", Strategie: "html-drip 50-500ms 1-1024B", Limit: 100).Href("f50")
.ShouldBe("/?land=CN&ziel=GET%20example.com%2Fa%26b&strategie=html-drip%2050-500ms%201-1024B&limit=100#f50");
new DashboardFilter(Land: "CN", Ziel: "GET example.com/a&b", Strategie: "html-drip head", Limit: 100).Href("f50")
.ShouldBe("/?land=CN&ziel=GET%20example.com%2Fa%26b&strategie=html-drip%20head&limit=100#f50");
}
[Fact]
@@ -58,6 +62,13 @@ public sealed class DashboardFilterTests
.ShouldBe(filter);
}
[Theory]
[InlineData("html-drip 50-500ms 1-1024B", "html-drip")]
[InlineData("drip", "html-drip")]
[InlineData("html-drip 50-500ms 1-64B head 1024B", "html-drip head")]
public void Normalizes_strategy_links_to_the_group(string strategy, string expected) =>
DashboardFilter.Parse(null, null, null, null, null, null, strategy, null, null).Strategie.ShouldBe(expected);
[Fact]
public void Doubles_the_limit_up_to_the_maximum()
{
@@ -0,0 +1,107 @@
using Flypaper.Core.Strategies;
using Flypaper.Storage.Dashboard;
using Flypaper.Web.Components.Shared;
using Shouldly;
namespace Flypaper.Tests.Web;
public sealed class StrategyNamesTests
{
[Fact]
public void Describes_the_maze_with_all_suffixes()
{
var info = StrategyNames.Describe("maze-drip 50-500ms 1-1024B head 1024B link 160B repeat");
info.DisplayName.ShouldBe("Link-Labyrinth");
info.Explanation.ShouldNotBeNull();
info.Details.ShouldBe([
"tröpfelt 1–1.024 Byte alle 50–500 ms",
"schneller Start: die ersten 1.024 Byte sofort",
"alle 160 Byte ein Link",
"Wiederholer: darf länger festgehalten werden"
]);
info.Raw.ShouldBe("maze-drip 50-500ms 1-1024B head 1024B link 160B repeat");
info.Tooltip.ShouldContain("Technisch: maze-drip 50-500ms");
}
[Fact]
public void Shows_unknown_names_and_tokens_unchanged()
{
var info = StrategyNames.Describe("ufo-drip 5-9ms 1-2B odd");
info.DisplayName.ShouldBe("ufo-drip");
info.Explanation.ShouldBeNull();
info.Details.ShouldBe(["tröpfelt 1–2 Byte alle 5–9 ms", "odd"]);
}
[Theory]
[InlineData("robots-static")]
[InlineData("robots-bait 10-20ms 1-8B link 160B")]
public void Covers_robots_strategies(string strategy) =>
StrategyNames.Describe(strategy).Explanation.ShouldNotBeNull();
[Fact]
public void Covers_every_strategy_name_of_the_core()
{
string[] names =
[
MazeDripStrategy.PageName, MazeDripStrategy.ListingName, MazeDripStrategy.BaitName,
HtmlDripStrategy.StrategyName, TextDripStrategy.StrategyName, RobotsStaticStrategy.StrategyName,
.. FileContent.Profiles.Select(profile => profile.Name)
];
foreach (var name in names)
{
StrategyNames.Describe(name).Explanation.ShouldNotBeNull(name);
}
}
[Fact]
public void Finds_base_names_by_display_name()
{
StrategyNames.Matching(" gefälschtes git ").ShouldBe(["git-drip"]);
StrategyNames.Matching("zugangsdaten").ShouldBe(["env-drip"]);
StrategyNames.Matching("").ShouldBeEmpty();
StrategyNames.Matching("nichts").ShouldBeEmpty();
}
[Fact]
public void Groups_variants_by_base_type_and_shows_only_content_differences_as_badges()
{
StrategyNames.Describe("html-drip 50-500ms 1-1024B").GroupKey.ShouldBe("html-drip");
StrategyNames.Describe("html-drip 50-500ms 1-640B").GroupKey.ShouldBe("html-drip");
var variant = StrategyNames.Describe("html-drip 5-20ms 1-64B head 1024B repeat");
variant.GroupKey.ShouldBe("html-drip head repeat");
variant.Badges.ShouldBe(["Schnellstart", "Wiederholer"]);
StrategyNames.Describe("maze-drip 50-500ms 1-1024B head 1024B link 160B").Badges.ShouldBe(["Schnellstart"]);
}
[Fact]
public void Treats_drip_as_the_old_name_of_the_endless_page()
{
var info = StrategyNames.Describe("drip");
info.DisplayName.ShouldBe("Endlose Webseite");
info.GroupKey.ShouldBe("html-drip");
StrategyNames.Matching("endlose webseite").ShouldBe(["html-drip", "drip"]);
}
[Fact]
public void Ranks_groups_by_median_and_sinks_groups_with_few_catches()
{
var samples = new List<StrategySample>();
samples.AddRange(Enumerable.Repeat(new StrategySample("html-drip 50-500ms 1-1024B", 10_000), 3));
samples.AddRange(Enumerable.Repeat(new StrategySample("html-drip 50-500ms 1-640B", 20_000), 2));
samples.Add(new StrategySample("drip", 1_000_000));
samples.AddRange(Enumerable.Repeat(new StrategySample("env-drip 50-500ms 1-1024B", 30_000), 5));
samples.Add(new StrategySample("text-drip", 500_000_000));
var ranked = StrategyNames.Rank(samples, 10);
ranked.Select(r => r.Key).ShouldBe(["env-drip", "html-drip", "text-drip"]);
ranked[0].MedianHold.ShouldBe(TimeSpan.FromSeconds(30));
ranked[1].Count.ShouldBe(6);
ranked[1].MedianHold.ShouldBe(TimeSpan.FromSeconds(15));
ranked[1].HoldTime.ShouldBe(TimeSpan.FromMilliseconds(1_070_000));
}
}