Add unit tests for SBOM ingestion and transformation
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
- Implement `SbomIngestServiceCollectionExtensionsTests` to verify the SBOM ingestion pipeline exports snapshots correctly. - Create `SbomIngestTransformerTests` to ensure the transformation produces expected nodes and edges, including deduplication of license nodes and normalization of timestamps. - Add `SbomSnapshotExporterTests` to test the export functionality for manifest, adjacency, nodes, and edges. - Introduce `VexOverlayTransformerTests` to validate the transformation of VEX nodes and edges. - Set up project file for the test project with necessary dependencies and configurations. - Include JSON fixture files for testing purposes.
This commit is contained in:
44
src/Graph/StellaOps.Graph.Indexer/Schema/Base32Crockford.cs
Normal file
44
src/Graph/StellaOps.Graph.Indexer/Schema/Base32Crockford.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Text;
|
||||
|
||||
namespace StellaOps.Graph.Indexer.Schema;
|
||||
|
||||
/// <summary>
|
||||
/// Base32 encoder using the Crockford alphabet (0-9A-HJKMNPQRSTVWXYZ).
|
||||
/// </summary>
|
||||
internal static class Base32Crockford
|
||||
{
|
||||
private const string Alphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
|
||||
|
||||
public static string Encode(ReadOnlySpan<byte> data)
|
||||
{
|
||||
if (data.IsEmpty)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var output = new StringBuilder((data.Length * 8 + 4) / 5);
|
||||
var buffer = 0;
|
||||
var bitsLeft = 0;
|
||||
|
||||
foreach (var b in data)
|
||||
{
|
||||
buffer = (buffer << 8) | b;
|
||||
bitsLeft += 8;
|
||||
|
||||
while (bitsLeft >= 5)
|
||||
{
|
||||
bitsLeft -= 5;
|
||||
var index = (buffer >> bitsLeft) & 0x1F;
|
||||
output.Append(Alphabet[index]);
|
||||
}
|
||||
}
|
||||
|
||||
if (bitsLeft > 0)
|
||||
{
|
||||
var index = (buffer << (5 - bitsLeft)) & 0x1F;
|
||||
output.Append(Alphabet[index]);
|
||||
}
|
||||
|
||||
return output.ToString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user