Enhance risk API documentation and error handling
- Updated API documentation for risk endpoints to include optional caching headers and error catalog references. - Added a new error catalog JSON file to standardize error responses. - Improved explainability documentation with sample outputs for console and CLI. - Added SHA256 checksums for new sample files related to explainability. - Refined AocGuard tests to utilize a helper method for generating test JSON, improving readability and maintainability. - Updated runbook references to ensure consistency in sprint documentation. - Introduced stub implementations for MongoDB storage interfaces and options, laying groundwork for future development. - Disabled analytics in Angular CLI configuration for privacy considerations.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
namespace StellaOps.Concelier.Storage.Mongo.Documents;
|
||||
|
||||
/// <summary>
|
||||
/// Stub record for document storage. (Placeholder for full implementation)
|
||||
/// </summary>
|
||||
public sealed record DocumentRecord
|
||||
{
|
||||
public string Id { get; init; } = string.Empty;
|
||||
public string TenantId { get; init; } = string.Empty;
|
||||
public string Source { get; init; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace StellaOps.Concelier.Storage.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// Stub interface for document storage. (Placeholder for full implementation)
|
||||
/// </summary>
|
||||
public interface IDocumentStore
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace StellaOps.Concelier.Storage.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// Stub interface for source state repository. (Placeholder for full implementation)
|
||||
/// </summary>
|
||||
public interface ISourceStateRepository
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace StellaOps.Concelier.Storage.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// Stub options for MongoDB storage. (Placeholder for full implementation)
|
||||
/// </summary>
|
||||
public sealed class MongoStorageOptions
|
||||
{
|
||||
public string ConnectionString { get; set; } = string.Empty;
|
||||
public string DatabaseName { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<LangVersion>preview</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../StellaOps.Concelier.RawModels/StellaOps.Concelier.RawModels.csproj" />
|
||||
<ProjectReference Include="../StellaOps.Concelier.Models/StellaOps.Concelier.Models.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -243,23 +243,7 @@ public sealed class AdvisorySchemaValidatorTests
|
||||
public void AocGuard_DetectsAllForbiddenFields(string forbiddenField)
|
||||
{
|
||||
var guard = new AocWriteGuard();
|
||||
var json = $$"""
|
||||
{
|
||||
"tenant": "test",
|
||||
"{{forbiddenField}}": "forbidden_value",
|
||||
"source": {"vendor": "test", "connector": "test", "version": "1.0"},
|
||||
"upstream": {
|
||||
"upstream_id": "CVE-2024-0001",
|
||||
"content_hash": "sha256:abc",
|
||||
"retrieved_at": "2024-01-01T00:00:00Z",
|
||||
"signature": {"present": false},
|
||||
"provenance": {}
|
||||
},
|
||||
"content": {"format": "OSV", "raw": {}},
|
||||
"identifiers": {"aliases": [], "primary": "CVE-2024-0001"},
|
||||
"linkset": {}
|
||||
}
|
||||
""";
|
||||
var json = GetTestJsonWithField(forbiddenField, "forbidden_value");
|
||||
using var jsonDoc = JsonDocument.Parse(json);
|
||||
|
||||
var result = guard.Validate(jsonDoc.RootElement, GuardOptions);
|
||||
@@ -277,10 +261,25 @@ public sealed class AdvisorySchemaValidatorTests
|
||||
public void AocGuard_DetectsAllDerivedFields(string derivedField)
|
||||
{
|
||||
var guard = new AocWriteGuard();
|
||||
var json = $$"""
|
||||
var json = GetTestJsonWithField(derivedField, "derived_value");
|
||||
using var jsonDoc = JsonDocument.Parse(json);
|
||||
|
||||
var result = guard.Validate(jsonDoc.RootElement, GuardOptions);
|
||||
|
||||
Assert.False(result.IsValid);
|
||||
// Derived fields (effective_*) trigger both ForbiddenField and DerivedFindingDetected
|
||||
// if they're in the forbidden list, otherwise just DerivedFindingDetected
|
||||
Assert.Contains(result.Violations, v =>
|
||||
v.Code == AocViolationCode.DerivedFindingDetected &&
|
||||
v.ErrorCode == "ERR_AOC_006");
|
||||
}
|
||||
|
||||
private static string GetTestJsonWithField(string fieldName, string fieldValue)
|
||||
{
|
||||
return """
|
||||
{
|
||||
"tenant": "test",
|
||||
"{{derivedField}}": "derived_value",
|
||||
"FIELD_NAME_PLACEHOLDER": "FIELD_VALUE_PLACEHOLDER",
|
||||
"source": {"vendor": "test", "connector": "test", "version": "1.0"},
|
||||
"upstream": {
|
||||
"upstream_id": "CVE-2024-0001",
|
||||
@@ -293,16 +292,6 @@ public sealed class AdvisorySchemaValidatorTests
|
||||
"identifiers": {"aliases": [], "primary": "CVE-2024-0001"},
|
||||
"linkset": {}
|
||||
}
|
||||
""";
|
||||
using var jsonDoc = JsonDocument.Parse(json);
|
||||
|
||||
var result = guard.Validate(jsonDoc.RootElement, GuardOptions);
|
||||
|
||||
Assert.False(result.IsValid);
|
||||
// Derived fields (effective_*) trigger both ForbiddenField and DerivedFindingDetected
|
||||
// if they're in the forbidden list, otherwise just DerivedFindingDetected
|
||||
Assert.Contains(result.Violations, v =>
|
||||
v.Code == AocViolationCode.DerivedFindingDetected &&
|
||||
v.ErrorCode == "ERR_AOC_006");
|
||||
""".Replace("FIELD_NAME_PLACEHOLDER", fieldName).Replace("FIELD_VALUE_PLACEHOLDER", fieldValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
<!-- Disable Concelier Testing infra which requires Storage.Mongo -->
|
||||
<UseConcelierTestInfra>false</UseConcelierTestInfra>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.Concelier.Core/StellaOps.Concelier.Core.csproj" />
|
||||
@@ -15,11 +13,7 @@
|
||||
<ProjectReference Include="../../__Libraries/StellaOps.Concelier.Models/StellaOps.Concelier.Models.csproj" />
|
||||
<ProjectReference Include="../../../__Libraries/StellaOps.Ingestion.Telemetry/StellaOps.Ingestion.Telemetry.csproj" />
|
||||
<ProjectReference Include="../../../Aoc/__Libraries/StellaOps.Aoc/StellaOps.Aoc.csproj" />
|
||||
<!-- Test packages (manually added since UseConcelierTestInfra=false) -->
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
|
||||
<!-- Test packages inherited from Directory.Build.props -->
|
||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user