Restructure solution layout by module

This commit is contained in:
master
2025-10-28 15:10:40 +02:00
parent 95daa159c4
commit d870da18ce
4103 changed files with 192899 additions and 187024 deletions

View File

@@ -0,0 +1,76 @@
using System.Collections.Immutable;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace StellaOps.Concelier.RawModels;
public sealed record AdvisoryRawDocument(
[property: JsonPropertyName("tenant")] string Tenant,
[property: JsonPropertyName("source")] RawSourceMetadata Source,
[property: JsonPropertyName("upstream")] RawUpstreamMetadata Upstream,
[property: JsonPropertyName("content")] RawContent Content,
[property: JsonPropertyName("identifiers")] RawIdentifiers Identifiers,
[property: JsonPropertyName("linkset")] RawLinkset Linkset,
[property: JsonPropertyName("supersedes")] string? Supersedes = null)
{
public AdvisoryRawDocument WithSupersedes(string supersedes)
=> this with { Supersedes = supersedes };
}
public sealed record RawSourceMetadata(
[property: JsonPropertyName("vendor")] string Vendor,
[property: JsonPropertyName("connector")] string Connector,
[property: JsonPropertyName("version")] string ConnectorVersion,
[property: JsonPropertyName("stream")] string? Stream = null);
public sealed record RawUpstreamMetadata(
[property: JsonPropertyName("upstream_id")] string UpstreamId,
[property: JsonPropertyName("document_version")] string? DocumentVersion,
[property: JsonPropertyName("retrieved_at")] DateTimeOffset RetrievedAt,
[property: JsonPropertyName("content_hash")] string ContentHash,
[property: JsonPropertyName("signature")] RawSignatureMetadata Signature,
[property: JsonPropertyName("provenance")] ImmutableDictionary<string, string> Provenance);
public sealed record RawSignatureMetadata(
[property: JsonPropertyName("present")] bool Present,
[property: JsonPropertyName("format")] string? Format = null,
[property: JsonPropertyName("key_id")] string? KeyId = null,
[property: JsonPropertyName("sig")] string? Signature = null,
[property: JsonPropertyName("certificate")] string? Certificate = null,
[property: JsonPropertyName("digest")] string? Digest = null);
public sealed record RawContent(
[property: JsonPropertyName("format")] string Format,
[property: JsonPropertyName("spec_version")] string? SpecVersion,
[property: JsonPropertyName("raw")] JsonElement Raw,
[property: JsonPropertyName("encoding")] string? Encoding = null);
public sealed record RawIdentifiers(
[property: JsonPropertyName("aliases")] ImmutableArray<string> Aliases,
[property: JsonPropertyName("primary")] string PrimaryId);
public sealed record RawLinkset
{
[JsonPropertyName("aliases")]
public ImmutableArray<string> Aliases { get; init; } = ImmutableArray<string>.Empty;
[JsonPropertyName("purls")]
public ImmutableArray<string> PackageUrls { get; init; } = ImmutableArray<string>.Empty;
[JsonPropertyName("cpes")]
public ImmutableArray<string> Cpes { get; init; } = ImmutableArray<string>.Empty;
[JsonPropertyName("references")]
public ImmutableArray<RawReference> References { get; init; } = ImmutableArray<RawReference>.Empty;
[JsonPropertyName("reconciled_from")]
public ImmutableArray<string> ReconciledFrom { get; init; } = ImmutableArray<string>.Empty;
[JsonPropertyName("notes")]
public ImmutableDictionary<string, string> Notes { get; init; } = ImmutableDictionary<string, string>.Empty;
}
public sealed record RawReference(
[property: JsonPropertyName("type")] string Type,
[property: JsonPropertyName("url")] string Url,
[property: JsonPropertyName("source")] string? Source = null);

View File

@@ -0,0 +1,6 @@
namespace StellaOps.Concelier.RawModels;
public class Class1
{
}

View File

@@ -0,0 +1,12 @@
using System.Text.Json;
namespace StellaOps.Concelier.RawModels;
internal static class JsonElementExtensions
{
public static JsonElement CloneElement(this JsonElement element)
{
using var document = JsonDocument.Parse(element.GetRawText());
return document.RootElement.Clone();
}
}

View File

@@ -0,0 +1,39 @@
using System.Collections.Immutable;
using System.Text.Json;
namespace StellaOps.Concelier.RawModels;
public static class RawDocumentFactory
{
public static AdvisoryRawDocument CreateAdvisory(
string tenant,
RawSourceMetadata source,
RawUpstreamMetadata upstream,
RawContent content,
RawIdentifiers identifiers,
RawLinkset linkset,
string? supersedes = null)
{
var clonedContent = content with { Raw = Clone(content.Raw) };
return new AdvisoryRawDocument(tenant, source, upstream, clonedContent, identifiers, linkset, supersedes);
}
public static VexRawDocument CreateVex(
string tenant,
RawSourceMetadata source,
RawUpstreamMetadata upstream,
RawContent content,
RawLinkset linkset,
ImmutableArray<VexStatementSummary> statements,
string? supersedes = null)
{
var clonedContent = content with { Raw = Clone(content.Raw) };
return new VexRawDocument(tenant, source, upstream, clonedContent, linkset, statements, supersedes);
}
private static JsonElement Clone(JsonElement element)
{
using var document = JsonDocument.Parse(element.GetRawText());
return document.RootElement.Clone();
}
}

View File

@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MongoDB.Bson" Version="3.5.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,24 @@
using System.Collections.Immutable;
using System.Text.Json.Serialization;
namespace StellaOps.Concelier.RawModels;
public sealed record VexRawDocument(
[property: JsonPropertyName("tenant")] string Tenant,
[property: JsonPropertyName("source")] RawSourceMetadata Source,
[property: JsonPropertyName("upstream")] RawUpstreamMetadata Upstream,
[property: JsonPropertyName("content")] RawContent Content,
[property: JsonPropertyName("linkset")] RawLinkset Linkset,
[property: JsonPropertyName("statements")] ImmutableArray<VexStatementSummary> Statements,
[property: JsonPropertyName("supersedes")] string? Supersedes = null)
{
public VexRawDocument WithSupersedes(string supersedes)
=> this with { Supersedes = supersedes };
}
public sealed record VexStatementSummary(
[property: JsonPropertyName("advisory_ids")] ImmutableArray<string> AdvisoryIds,
[property: JsonPropertyName("products")] ImmutableArray<string> Products,
[property: JsonPropertyName("statuses")] ImmutableArray<string> Statuses,
[property: JsonPropertyName("justification")] string? Justification = null,
[property: JsonPropertyName("impact")] string? Impact = null);