feat: Initialize Zastava Webhook service with TLS and Authority authentication
- Added Program.cs to set up the web application with Serilog for logging, health check endpoints, and a placeholder admission endpoint. - Configured Kestrel server to use TLS 1.3 and handle client certificates appropriately. - Created StellaOps.Zastava.Webhook.csproj with necessary dependencies including Serilog and Polly. - Documented tasks in TASKS.md for the Zastava Webhook project, outlining current work and exit criteria for each task.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
using StellaOps.Scanner.Core.Contracts;
|
||||
|
||||
namespace StellaOps.Scanner.Analyzers.Lang;
|
||||
|
||||
public sealed class LanguageAnalyzerResult
|
||||
{
|
||||
private readonly ImmutableArray<LanguageComponentRecord> _components;
|
||||
|
||||
internal LanguageAnalyzerResult(IEnumerable<LanguageComponentRecord> components)
|
||||
{
|
||||
_components = components
|
||||
.OrderBy(static record => record.ComponentKey, StringComparer.Ordinal)
|
||||
.ThenBy(static record => record.AnalyzerId, StringComparer.Ordinal)
|
||||
.ToImmutableArray();
|
||||
}
|
||||
|
||||
public IReadOnlyList<LanguageComponentRecord> Components => _components;
|
||||
|
||||
public ImmutableArray<ComponentRecord> ToComponentRecords(string analyzerId, string? layerDigest = null)
|
||||
=> LanguageComponentMapper.ToComponentRecords(analyzerId, _components, layerDigest);
|
||||
|
||||
public LayerComponentFragment ToLayerFragment(string analyzerId, string? layerDigest = null)
|
||||
=> LanguageComponentMapper.ToLayerFragment(analyzerId, _components, layerDigest);
|
||||
|
||||
public IReadOnlyList<LanguageComponentSnapshot> ToSnapshots()
|
||||
=> _components.Select(static component => component.ToSnapshot()).ToImmutableArray();
|
||||
|
||||
public string ToJson(bool indent = true)
|
||||
{
|
||||
var snapshots = ToSnapshots();
|
||||
var options = Internal.LanguageAnalyzerJson.CreateDefault(indent);
|
||||
return JsonSerializer.Serialize(snapshots, options);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class LanguageAnalyzerResultBuilder
|
||||
{
|
||||
private readonly Dictionary<string, LanguageComponentRecord> _records = new(StringComparer.Ordinal);
|
||||
private readonly object _sync = new();
|
||||
|
||||
public void Add(LanguageComponentRecord record)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(record);
|
||||
|
||||
lock (_sync)
|
||||
{
|
||||
if (_records.TryGetValue(record.ComponentKey, out var existing))
|
||||
{
|
||||
existing.Merge(record);
|
||||
return;
|
||||
}
|
||||
|
||||
_records[record.ComponentKey] = record;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRange(IEnumerable<LanguageComponentRecord> records)
|
||||
{
|
||||
foreach (var record in records ?? Array.Empty<LanguageComponentRecord>())
|
||||
{
|
||||
Add(record);
|
||||
}
|
||||
}
|
||||
|
||||
public LanguageAnalyzerResult Build()
|
||||
{
|
||||
lock (_sync)
|
||||
{
|
||||
return new LanguageAnalyzerResult(_records.Values.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class LanguageComponentWriter
|
||||
{
|
||||
private readonly LanguageAnalyzerResultBuilder _builder;
|
||||
|
||||
internal LanguageComponentWriter(LanguageAnalyzerResultBuilder builder)
|
||||
{
|
||||
_builder = builder ?? throw new ArgumentNullException(nameof(builder));
|
||||
}
|
||||
|
||||
public void Add(LanguageComponentRecord record)
|
||||
=> _builder.Add(record);
|
||||
|
||||
public void AddRange(IEnumerable<LanguageComponentRecord> records)
|
||||
=> _builder.AddRange(records);
|
||||
|
||||
public void AddFromPurl(
|
||||
string analyzerId,
|
||||
string purl,
|
||||
string name,
|
||||
string? version,
|
||||
string type,
|
||||
IEnumerable<KeyValuePair<string, string?>>? metadata = null,
|
||||
IEnumerable<LanguageComponentEvidence>? evidence = null,
|
||||
bool usedByEntrypoint = false)
|
||||
=> Add(LanguageComponentRecord.FromPurl(analyzerId, purl, name, version, type, metadata, evidence, usedByEntrypoint));
|
||||
|
||||
public void AddFromExplicitKey(
|
||||
string analyzerId,
|
||||
string componentKey,
|
||||
string? purl,
|
||||
string name,
|
||||
string? version,
|
||||
string type,
|
||||
IEnumerable<KeyValuePair<string, string?>>? metadata = null,
|
||||
IEnumerable<LanguageComponentEvidence>? evidence = null,
|
||||
bool usedByEntrypoint = false)
|
||||
=> Add(LanguageComponentRecord.FromExplicitKey(analyzerId, componentKey, purl, name, version, type, metadata, evidence, usedByEntrypoint));
|
||||
}
|
||||
Reference in New Issue
Block a user