Refactor JSON structures for reachability cases in reachbench-2025
- Updated symbols.json for rust-axum-header-parsing-TBD to include case_id and schema_version, removing unnecessary components. - Modified vex.openvex.json for rust-axum-header-parsing-TBD to change author and role, and updated vulnerability status. - Simplified attestation.dsse.json for wordpress-core-CVE-2022-21661-sqli to remove unnecessary fields and added payloadType. - Adjusted callgraph.framework.json and callgraph.static.json for wordpress-core-CVE-2022-21661-sqli to include empty nodes and edges with updated schema_version. - Enhanced manifest.json for wordpress-core-CVE-2022-21661-sqli to include case_id and files with checksums, and updated schema_version. - Updated reachgraph.truth.json for wordpress-core-CVE-2022-21661-sqli to reflect empty paths and added case_id. - Modified sbom.cdx.json and sbom.spdx.json for wordpress-core-CVE-2022-21661-sqli to include metadata and updated specVersion. - Refined symbols.json for wordpress-core-CVE-2022-21661-sqli to include case_id and schema_version, with an empty symbols array. - Updated vex.openvex.json for wordpress-core-CVE-2022-21661-sqli to change author and role, and updated vulnerability status. - Adjusted unreachable cases for wordpress-core-CVE-2022-21661-sqli to reflect similar structural changes as reachable cases.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System.Text.Json;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
using System.Security.Cryptography;
|
||||
using System.Linq;
|
||||
|
||||
namespace StellaOps.Reachability.FixtureTests;
|
||||
|
||||
@@ -88,6 +90,8 @@ public class ReachbenchFixtureTests
|
||||
using var truthDoc = JsonDocument.Parse(truthStream);
|
||||
truthDoc.RootElement.GetProperty("schema_version").GetString().Should().NotBeNullOrEmpty();
|
||||
truthDoc.RootElement.GetProperty("paths").ValueKind.Should().Be(JsonValueKind.Array);
|
||||
|
||||
VerifyManifestHashes(caseId, variantPath, requiredFiles);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -109,6 +113,13 @@ public class ReachbenchFixtureTests
|
||||
variant.TryGetProperty("evidence", out var evidence).Should().BeTrue($"{caseId}:{variantKey} should define evidence");
|
||||
evidence.TryGetProperty("paths", out var pathsProp).Should().BeTrue();
|
||||
pathsProp.ValueKind.Should().Be(JsonValueKind.Array);
|
||||
|
||||
var truthPath = Path.Combine(variantPath, "reachgraph.truth.json");
|
||||
using var truthStream = File.OpenRead(truthPath);
|
||||
using var truthDoc = JsonDocument.Parse(truthStream);
|
||||
var paths = truthDoc.RootElement.GetProperty("paths");
|
||||
|
||||
paths.ValueKind.Should().Be(JsonValueKind.Array);
|
||||
}
|
||||
|
||||
private static string LocateRepoRoot()
|
||||
@@ -126,4 +137,23 @@ public class ReachbenchFixtureTests
|
||||
|
||||
throw new InvalidOperationException("Cannot locate repository root (missing Directory.Build.props).");
|
||||
}
|
||||
|
||||
private static void VerifyManifestHashes(string caseId, string variantPath, IEnumerable<string> requiredFiles)
|
||||
{
|
||||
var manifestPath = Path.Combine(variantPath, "manifest.json");
|
||||
using var manifestStream = File.OpenRead(manifestPath);
|
||||
using var manifestDoc = JsonDocument.Parse(manifestStream);
|
||||
var files = manifestDoc.RootElement.GetProperty("files");
|
||||
|
||||
foreach (var file in requiredFiles.Where(f => f != "manifest.json"))
|
||||
{
|
||||
files.TryGetProperty(file, out var hashProp).Should().BeTrue($"{caseId}:{variantPath} manifest missing hash for {file}");
|
||||
var expectedHash = hashProp.GetString();
|
||||
expectedHash.Should().NotBeNullOrEmpty($"{caseId}:{variantPath} hash missing for {file}");
|
||||
|
||||
var path = Path.Combine(variantPath, file);
|
||||
var actualHash = BitConverter.ToString(SHA256.HashData(File.ReadAllBytes(path))).Replace("-", "").ToLowerInvariant();
|
||||
actualHash.Should().Be(expectedHash, $"{caseId}:{variantPath} hash mismatch for {file}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user