Skip to content

ocsf/ocsf-models-java

Repository files navigation

ocsf-models-java

Java model classes generated from the Open Cybersecurity Schema Framework (OCSF) JSON Schema, along with fluent builder support for all generated types.


Overview

This project generates Java POJOs from the OCSF JSON Schema definitions and publishes them as two separate Maven artifacts:

Module Artifact Description
models io.ocsf.schema.models:models Jackson-annotated POJOs for every OCSF event class and object
builders io.ocsf.schema.models:builders Fluent builder classes for every model type (via Sundrio)

Prerequisites

  • Java 11+
  • Gradle (use ./gradlew)

Building

# Build all modules
./gradlew build

# Build only the models module
./gradlew :models:build

# Build only the builders module
./gradlew :builders:build

Publishing

Both modules are configured with the maven-publish plugin and publish a standard Maven artifact from the Java component.

To use locally run:

./gradlew publishToMavenLocal

Usage

Add the models and builders artifact for fluent builder support:

// build.gradle.kts
dependencies {
    implementation("io.ocsf.schema.models:models:1.8.0-SNAPSHOT")
    implementation("io.ocsf.schema.models:builders:1.8.0-SNAPSHOT")
}
import io.ocsf.schema.models.builders.AuthenticationBuilder;

Authentication event = new AuthenticationBuilder()
    .withUser(user)
    .withSeverityId(2)
    .withTime(System.currentTimeMillis())
    .build();

Updating the Schema

The schemas bundled in models/src/main/resources/schema/ are fetched from the live OCSF API. To update them to the latest version, run:

./.github/scripts/update-schema.sh

This script requires curl, jq, and yq.

About

Java POJOs compatible with the OCSF Schema.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages