Remove trap paths and known hosts: catch everything on the trap port
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b9f2b0443c
commit
9a56fc5b48
31 files changed
+335
-462
No files matched your search
@@ -5,24 +5,15 @@ namespace Flypaper.Tests.Core;
|
||||
|
||||
public sealed class RuntimeSettingsParserTests
|
||||
{
|
||||
private static readonly RuntimeSettingsInput Valid = new(
|
||||
"/.env\n/wp-admin/*\r\n /xmlrpc.php \n/.env",
|
||||
"200",
|
||||
"5",
|
||||
"00:30:00",
|
||||
"example.com\n*.example.org",
|
||||
"90",
|
||||
true);
|
||||
private static readonly RuntimeSettingsInput Valid = new("200", "5", "00:30:00", "90", true);
|
||||
|
||||
[Fact]
|
||||
public void Parses_valid_input_and_normalizes_lists()
|
||||
public void Parses_valid_input()
|
||||
{
|
||||
var result = RuntimeSettingsParser.Parse(Valid);
|
||||
|
||||
result.Errors.ShouldBeEmpty();
|
||||
var settings = result.Settings.ShouldNotBeNull();
|
||||
settings.TrapPaths.ShouldBe(["/.env", "/wp-admin/*", "/xmlrpc.php"]);
|
||||
settings.ExtraKnownHosts.ShouldBe(["example.com", "*.example.org"]);
|
||||
settings.MaxConnections.ShouldBe(200);
|
||||
settings.MaxConnectionsPerIp.ShouldBe(5);
|
||||
settings.MaxHoldDuration.ShouldBe(TimeSpan.FromMinutes(30));
|
||||
@@ -54,38 +45,6 @@ public sealed class RuntimeSettingsParserTests
|
||||
settings.ToConfiguration()[SettingKeys.IgnorePrivateNetworks].ShouldBe("false");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Accepts_empty_lists()
|
||||
{
|
||||
var result = RuntimeSettingsParser.Parse(Valid with { TrapPaths = "", ExtraKnownHosts = null });
|
||||
|
||||
result.Settings.ShouldNotBeNull().TrapPaths.ShouldBeEmpty();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("env")]
|
||||
[InlineData("/with space")]
|
||||
[InlineData("/a*b")]
|
||||
public void Rejects_invalid_trap_paths(string path)
|
||||
{
|
||||
var result = RuntimeSettingsParser.Parse(Valid with { TrapPaths = $"/ok\n{path}" });
|
||||
|
||||
result.Settings.ShouldBeNull();
|
||||
result.Errors.Keys.ShouldBe([nameof(RuntimeSettingsInput.TrapPaths)]);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("https://example.com")]
|
||||
[InlineData("example.com/path")]
|
||||
[InlineData("example.com:8080")]
|
||||
[InlineData("-bad.com")]
|
||||
public void Rejects_invalid_hosts(string host)
|
||||
{
|
||||
var result = RuntimeSettingsParser.Parse(Valid with { ExtraKnownHosts = host });
|
||||
|
||||
result.Errors.ShouldContainKey(nameof(RuntimeSettingsInput.ExtraKnownHosts));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("10")]
|
||||
[InlineData("abc")]
|
||||
|
||||
Reference in new issue
Block a user