Ocsf.Schema 1.9.0

dotnet add package Ocsf.Schema --version 1.9.0
                    
NuGet\Install-Package Ocsf.Schema -Version 1.9.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ocsf.Schema" Version="1.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ocsf.Schema" Version="1.9.0" />
                    
Directory.Packages.props
<PackageReference Include="Ocsf.Schema" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ocsf.Schema --version 1.9.0
                    
#r "nuget: Ocsf.Schema, 1.9.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ocsf.Schema@1.9.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ocsf.Schema&version=1.9.0
                    
Install as a Cake Addin
#tool nuget:?package=Ocsf.Schema&version=1.9.0
                    
Install as a Cake Tool

Ocsf.Schema

Strongly-typed C# classes for the Open Cybersecurity Schema Framework (OCSF) v1.9.0.

This package provides:

  • 84 event classes (ProcessActivity, DnsActivity, Authentication, and more)
  • 177 object types (Process, Device, User, File, Actor, and more)
  • 124 enums (SeverityId, StatusId, per-event ActivityId values, and more)
  • Platform extensions for Windows, Linux, and macOS
  • System.Text.Json serialization with [JsonPropertyName] on every property
  • Constraint validation via OcsfValidator

Getting Started

using System.Text.Json;
using Ocsf.Schema;
using Ocsf.Schema.Events;
using Ocsf.Schema.Objects;

// Create an event
var evt = new ProcessActivity
{
    Time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
    SeverityId = 1,
    CategoryUid = 1,
    ClassUid = 107,
    TypeUid = 100701,
    ActivityId = 1, // Launch
    Process = new Process
    {
        Pid = 1234,
        Name = "notepad.exe"
    },
    Metadata = new Metadata { Version = "1.9.0-dev" }
};

// Serialize — null fields are omitted, property names are snake_case
var options = OcsfSerializerOptions.Create();
string json = JsonSerializer.Serialize(evt, options);

// Deserialize
var deserialized = JsonSerializer.Deserialize<ProcessActivity>(json, options);

Polymorphic Deserialization

Use OcsfEventRegistry to resolve a concrete event type from class_uid:

using var doc = JsonDocument.Parse(json);
int classUid = doc.RootElement.GetProperty("class_uid").GetInt32();
Type? eventType = OcsfEventRegistry.GetEventType(classUid);

if (eventType is not null)
{
    object? evt = JsonSerializer.Deserialize(json, eventType, options);
}

Validation

Objects with at_least_one constraints can be validated at runtime:

var actor = new Actor(); // no user, process, or app_name set
IReadOnlyList<string> errors = OcsfValidator.Validate(actor);
// errors[0]: "At least one of [process, user, ...] must be set on Actor."

Design

  • All types are records with init properties — immutable by default, supports with expressions
  • Concrete types are sealed; base/category types are abstract
  • All properties are nullable — validation is a separate concern
  • Targets netstandard2.0 for maximum compatibility (.NET Framework 4.6.1+, .NET Core 2.0+, .NET 5+)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.9.0 125 3/20/2026