save progress
This commit is contained in:
@@ -2,6 +2,7 @@ using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using StellaOps.Cryptography;
|
||||
using StellaOps.Scanner.Reachability;
|
||||
using StellaOps.Scanner.Reachability.Gates;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Scanner.Reachability.Tests;
|
||||
@@ -63,4 +64,48 @@ public class RichGraphWriterTests
|
||||
Assert.Contains("\"code_block_hash\":\"sha256:blockhash\"", json);
|
||||
Assert.Contains("\"symbol\":{\"mangled\":\"_Zssl_read\",\"demangled\":\"ssl_read\",\"source\":\"DWARF\",\"confidence\":0.9}", json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WritesGatesOnEdgesWhenPresent()
|
||||
{
|
||||
var writer = new RichGraphWriter(CryptoHashFactory.CreateDefault());
|
||||
using var temp = new TempDir();
|
||||
|
||||
var union = new ReachabilityUnionGraph(
|
||||
Nodes: new[]
|
||||
{
|
||||
new ReachabilityUnionNode("sym:dotnet:B", "dotnet", "method", "B"),
|
||||
new ReachabilityUnionNode("sym:dotnet:A", "dotnet", "method", "A")
|
||||
},
|
||||
Edges: new[]
|
||||
{
|
||||
new ReachabilityUnionEdge("sym:dotnet:A", "sym:dotnet:B", "call", "high")
|
||||
});
|
||||
|
||||
var rich = RichGraphBuilder.FromUnion(union, "test-analyzer", "1.0.0");
|
||||
var gate = new DetectedGate
|
||||
{
|
||||
Type = GateType.AuthRequired,
|
||||
Detail = "Auth required: ASP.NET Core Authorize attribute",
|
||||
GuardSymbol = "sym:dotnet:B",
|
||||
Confidence = 0.95,
|
||||
DetectionMethod = "annotation:\\[Authorize\\]"
|
||||
};
|
||||
|
||||
rich = rich with
|
||||
{
|
||||
Edges = new[]
|
||||
{
|
||||
rich.Edges[0] with { Gates = new[] { gate }, GateMultiplierBps = 3000 }
|
||||
}
|
||||
};
|
||||
|
||||
var result = await writer.WriteAsync(rich, temp.Path, "analysis-gates");
|
||||
var json = await File.ReadAllTextAsync(result.GraphPath);
|
||||
|
||||
Assert.Contains("\"gate_multiplier_bps\":3000", json);
|
||||
Assert.Contains("\"gates\":[", json);
|
||||
Assert.Contains("\"type\":\"authRequired\"", json);
|
||||
Assert.Contains("\"guard_symbol\":\"sym:dotnet:B\"", json);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user