Add explanation rules for catches, editable over MCP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4086fa3da3
commit
2437880013
37 files changed
+1867
-37
No files matched your search
@@ -3,6 +3,7 @@ using Flypaper.Core.Models;
|
||||
using Flypaper.Storage.Entities;
|
||||
using Flypaper.Web.Components.Shared;
|
||||
using Flypaper.Storage.Dashboard;
|
||||
using Flypaper.Storage.Explanations;
|
||||
using Flypaper.Tests.Fakes;
|
||||
using Flypaper.Tests.Mcp;
|
||||
using Shouldly;
|
||||
@@ -13,8 +14,9 @@ public sealed class RecentCatchesTests : IDisposable
|
||||
{
|
||||
private readonly McpTestData _data = new();
|
||||
private readonly DashboardQueries _queries;
|
||||
private readonly ExplanationRuleStore _rules;
|
||||
|
||||
public RecentCatchesTests() => _queries = new DashboardQueries(_data.Factory, new FixedTimeProvider(McpTestData.Now));
|
||||
public RecentCatchesTests() => _queries = new DashboardQueries(_data.Factory, new FixedTimeProvider(McpTestData.Now), _rules = new ExplanationRuleStore(_data.Factory, new FixedTimeProvider(McpTestData.Now)));
|
||||
|
||||
[Fact]
|
||||
public async Task Without_filters_returns_all_events_newest_first()
|
||||
@@ -47,6 +49,19 @@ public sealed class RecentCatchesTests : IDisposable
|
||||
recent.Total.ShouldBe(expected);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Unexplained_filter_keeps_only_targets_without_an_enabled_target_rule()
|
||||
{
|
||||
(await _queries.GetRecentAsync(new RecentFilter(Unexplained: true))).Total.ShouldBe(6);
|
||||
|
||||
await _rules.CreateAsync(new ExplanationRuleInput(ExplanationKind.Target, @"^/\.env$", "Sucht nach Zugangsdaten."), "test");
|
||||
var recent = await _queries.GetRecentAsync(new RecentFilter(Unexplained: true));
|
||||
|
||||
recent.Total.ShouldBe(4);
|
||||
recent.Items.Select(e => e.Target).ShouldNotContain("GET /.env");
|
||||
recent.Items.Select(e => e.StartedAt).ShouldBeInOrder(SortDirection.Descending);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Matches_strategy_exactly()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user