OCSF
Since Camel 4.18
The OCSF Data Format uses the Jackson library to marshal and unmarshal security events following the Open Cybersecurity Schema Framework (OCSF) specification.
OCSF is an open-source standard for cybersecurity event logging and data normalization. It provides a vendor-neutral schema for security events, enabling interoperability between different security tools and platforms.
Supported OCSF Event Classes
This data format includes POJOs for 34 OCSF event classes and 68 reusable object types. Key event classes include:
Findings (Category 2):
-
DetectionFinding- Alerts from SIEM, EDR, XDR tools (class_uid: 2004) -
SecurityFinding,VulnerabilityFinding,ComplianceFinding,IncidentFinding
System Activity (Category 1):
-
FileActivity,ProcessActivity,KernelActivity,MemoryActivity,ModuleActivity,ScheduledJobActivity
Network Activity (Category 4):
-
NetworkActivity,HttpActivity,DnsActivity,DhcpActivity,RdpActivity,SmbActivity,SshActivity,FtpActivity,EmailActivity,NtpActivity
IAM (Category 3):
-
Authentication,AuthorizeSession,AccountChange,GroupManagement,UserAccess,EntityManagement
Application Activity (Category 6):
-
ApiActivity,DatastoreActivity,WebResourcesActivity,ScanActivity
Remediation (Category 7):
-
RemediationActivity
All event classes extend OcsfEvent which provides common attributes like time, severity_id, class_uid, and metadata.
Usage
Unmarshalling to a Specific Event Class
from("kafka:security-events")
.unmarshal().ocsf(DetectionFinding.class)
.to("direct:process"); Using with AWS Security Hub
AWS Security Hub now outputs findings in OCSF format. You can use this data format to process those findings:
from("aws-securityhub:findings")
.unmarshal().ocsf(DetectionFinding.class)
.choice()
.when(simple("${body.severityId} >= 4"))
.to("direct:high-severity")
.otherwise()
.to("direct:normal-severity"); OCSF Options
The OCSF dataformat supports 9 options, which are listed below.
| Name | Default | Java Type | Description |
|---|---|---|---|
| Lookup and use the existing ObjectMapper with the given id when using Jackson. | ||
|
| Whether to lookup and use default Jackson ObjectMapper from the registry. | |
| Class name of the OCSF event type to use when unmarshalling. Defaults to OcsfEvent. | ||
| Refers to a custom collection type to lookup in the registry to use. This option should rarely be used, but allows to use different collection types than java.util.Collection based as default. | ||
|
| To unmarshal to a List of OCSF events. | |
|
| If enabled then the unmarshal type can be specified via the CamelOcsfUnmarshalType header. This should only be enabled when desired to be used. | |
|
| To enable pretty printing output nicely formatted. Is by default false. | |
| Set of features to enable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma. | ||
| Set of features to disable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma. |
Using OCSF in Spring DSL
You can use the OCSF data format directly in Spring XML:
<route>
<from uri="kafka:security-events"/>
<unmarshal>
<ocsf unmarshalType="org.apache.camel.dataformat.ocsf.model.DetectionFinding"/>
</unmarshal>
<to uri="direct:process"/>
</route> Or define a reusable data format:
<dataFormats>
<ocsf id="ocsfDetection" unmarshalType="org.apache.camel.dataformat.ocsf.model.DetectionFinding"/>
</dataFormats>
<route>
<from uri="kafka:security-events"/>
<unmarshal ref="ocsfDetection"/>
<to uri="direct:process"/>
</route> OCSF Event Categories
OCSF defines the following event categories:
| Category ID | Name | Description |
|---|---|---|
1 | System Activity | Process, file system, kernel events |
2 | Findings | Security findings, vulnerabilities, compliance |
3 | IAM | Authentication, authorization, account changes |
4 | Network Activity | HTTP, DNS, SSH, network traffic |
5 | Discovery | Device inventory, configuration state |
6 | Application Activity | API activity, web resources, scans |
7 | Remediation | Remediation activities |
Example: Creating a Detection Finding
DetectionFinding finding = new DetectionFinding();
finding.setActivityId(1); // Create
finding.setSeverityId(4); // High
finding.setTime(System.currentTimeMillis());
finding.setMessage("Suspicious activity detected");
FindingInfo info = new FindingInfo();
info.setTitle("Malware Detection");
info.setDesc("Potential malware detected on endpoint");
finding.setFindingInfo(info);
from("direct:start")
.setBody(constant(finding))
.marshal().ocsf()
.to("splunk-hec:..."); Dependencies
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ocsf</artifactId>
<version>x.x.x</version>
</dependency> Generated Model Classes
The component includes generated Java POJOs for OCSF events and objects in the package org.apache.camel.dataformat.ocsf.model.
Event Classes
| Class | Category | Description |
|---|---|---|
| Base | Base class with common attributes (time, severity_id, class_uid, metadata) |
| Findings | Alerts from SIEM, EDR, XDR, threat detection tools |
| Findings | General security findings |
| Findings | Vulnerability scan results |
| Findings | Compliance check results |
| Findings | Security incidents |
| System | File system operations |
| System | Process creation, termination, injection |
| System | Kernel-level events |
| System | Memory operations |
| System | Module/library loading |
| System | Scheduled task events |
| System | Kernel extension events |
| Network | Network connections and traffic |
| Network | HTTP request/response events |
| Network | DNS queries and responses |
| Network | DHCP events |
| Network | Remote Desktop Protocol events |
| Network | SMB/CIFS file sharing events |
| Network | SSH session events |
| Network | FTP transfer events |
| Network | Email events |
| Network | NTP synchronization events |
| Network | Network file operations |
| IAM | Login/logout events |
| IAM | Session authorization |
| IAM | Account modifications |
| IAM | Group membership changes |
| IAM | User access events |
| IAM | Entity lifecycle events |
| Application | API calls |
| Application | Database operations |
| Application | Web resource access |
| Application | Security scans |
| Remediation | Remediation actions |
Object Classes
Reusable objects used within event classes:
-
Actor,User,Group,Account- Identity objects -
Device,Endpoint,NetworkEndpoint- Device and endpoint objects -
Process,File,Module,Kernel- System objects -
Attack,Tactic,Technique,SubTechnique- MITRE ATT&CK objects -
FindingInfo,Remediation,Vulnerability,Malware- Security finding objects -
Cloud,Container,Image- Cloud and container objects -
Metadata,Product,Observable,Enrichment- Metadata objects -
Certificate,Tls,Fingerprint- Cryptographic objects -
HttpRequest,HttpResponse,DnsQuery,Url- Network protocol objects -
Location,Organization,Service- Context objects -
Cve,Cvss,Cwe,Epss- Vulnerability reference objects
Updating OCSF Schema Version
The Java POJOs in this component are generated from JSON Schema files using the jsonschema2pojo Maven plugin. The classes are generated at build time to target/generated-sources/jsonschema2pojo and included in the released JAR. A Python script is provided to regenerate the JSON schemas from the official OCSF specification when a new version is released.
Generating Schemas and Java Classes
To update the OCSF model classes to a new version:
-
Run the schema generation script from the
src/main/scriptdirectory:cd src/main/script python3 generate-ocsf-schemas.py --version 1.7.0 --output ../resources/schema --clean -
Build and test to verify the changes (Java classes are generated automatically during build):
mvn clean test -
Commit the updated JSON schema files.
Script Options
The script supports the following options:
| Option | Default | Description |
|---|---|---|
| 1.7.0 | OCSF schema version to generate |
| ../resources/schema | Output directory for schema files |
| false | Remove existing schema files before generating |
| false | Generate all available event classes (not just the default list) |
| false | Generate all available objects (not just the default list) |
Schema Generation Details
The script generates:
-
OcsfEvent.json - Base event class with common attributes (time, severity, class_uid, etc.)
-
Object schemas - Reusable OCSF objects (Attack, FindingInfo, Device, User, etc.)
-
Event class schemas - Event classes that extend OcsfEvent (DetectionFinding, Authentication, etc.)
The generated schemas use:
-
JSON Schema Draft-07 format
-
File-based
$refreferences (e.g.,"$ref": "Attack.json") -
javaTypeannotations for explicit Java class naming -
allOfpattern for event class inheritance from OcsfEvent -
additionalProperties: truefor forward compatibility
Spring Boot Auto-Configuration
When using ocsf with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-ocsf-starter</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency> The component supports 10 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
If enabled then the unmarshal type can be specified via the CamelOcsfUnmarshalType header. This should only be enabled when desired to be used. | false | Boolean | |
Refers to a custom collection type to lookup in the registry to use. This option should rarely be used, but allows to use different collection types than java.util.Collection based as default. | String | ||
Set of features to disable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma. | String | ||
Set of features to enable on the Jackson com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that matches a enum from com.fasterxml.jackson.databind.SerializationFeature, com.fasterxml.jackson.databind.DeserializationFeature, or com.fasterxml.jackson.databind.MapperFeature Multiple features can be separated by comma. | String | ||
Whether to enable auto configuration of the ocsf data format. This is enabled by default. | Boolean | ||
Lookup and use the existing ObjectMapper with the given id when using Jackson. | String | ||
To enable pretty printing output nicely formatted. Is by default false. | false | Boolean | |
Class name of the OCSF event type to use when unmarshalling. Defaults to OcsfEvent. | String | ||
Whether to lookup and use default Jackson ObjectMapper from the registry. | true | Boolean | |
To unmarshal to a List of OCSF events. | false | Boolean |