Files
git.stella-ops.org/src/Aoc/__Analyzers/StellaOps.Aoc.Analyzers

StellaOps.Aoc.Analyzers

Roslyn source analyzers for enforcing AOC (Append-Only Contracts) during compile time.

Rules

Rule ID Category Severity Description
AOC0001 AOC Error Forbidden field write detected - fields like severity, cvss, etc.
AOC0002 AOC Error Derived field write detected - effective_* prefixed fields
AOC0003 AOC Warning Unguarded database write - writes without IAocGuard.Validate()

Forbidden Fields

The following fields must not be written during ingestion:

  • severity
  • cvss
  • cvss_vector
  • effective_status
  • effective_range
  • merged_from
  • consensus_provider
  • reachability
  • asset_criticality
  • risk_score

Additionally, any field prefixed with effective_ is considered derived and forbidden.

Usage

Reference this analyzer in your project:

<ItemGroup>
  <ProjectReference Include="..\..\..\Aoc\__Analyzers\StellaOps.Aoc.Analyzers\StellaOps.Aoc.Analyzers.csproj"
                    OutputItemType="Analyzer"
                    ReferenceOutputAssembly="false" />
</ItemGroup>

Or add as a NuGet package once published.

Suppression

To suppress a specific diagnostic:

#pragma warning disable AOC0001
// Code that intentionally writes forbidden field
#pragma warning restore AOC0001

Or use [SuppressMessage] attribute:

[SuppressMessage("AOC", "AOC0001", Justification = "Legitimate use case")]