-
Notifications
You must be signed in to change notification settings - Fork 1
Add unit tests for SsrfGuard #45
Copy link
Copy link
Open
Labels
.NETPull requests that update .NET codePull requests that update .NET codegood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Activity
Metadata
Metadata
Assignees
Labels
.NETPull requests that update .NET codePull requests that update .NET codegood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Summary
SsrfGuardhas no dedicated unit test file — only indirect coverage via integration tests.Add
Rasp.Core.Tests/Guard/SsrfGuardTests.cscovering both of its public entry points'block/audit/no-threat/no-op branches in isolation.
Background
Every
*DetectionEnginehas a dedicated test file; mostGuardclasses don't. This is oneof five identical-shaped issues — see
docs/good-first-issues-dotnet.mdfor the full listand the shared rationale (this is about naming concrete gaps, not chasing a coverage
percentage).
SsrfGuardhas two public methods to cover, unlike the other four guards inthis set, which have one.
Pattern to copy
Rasp.Core.Tests/Guard/SqlSinkGuardTaintTests.cs—NoOpRaspMetricsfake, a realRaspAlertBus,Options.Create(new RaspOptions {...}),NullLogger<T>.Instance.What to test
Both
AnalyzeUri(Uri? requestUri, context)andAnalyzeIp(IPAddress ip, context)(
src/Rasp.Core/Guard/SsrfGuard.cs), both gated byRaspOptions.BlockOnSsrfDetection:RaspAlertBus, no exception thrown.RaspSecurityExceptionthrown, alert still pushed before the throw.nullURI forAnalyzeUri,nullIP forAnalyzeIp— neither reaches the engine or calls_metrics.RecordInspection.