XARF Libraries
Official, published libraries for implementing XARF in your applications. All four official libraries implement XARF spec v4.2.0 and support the seven categories: messaging, connection, content, infrastructure, copyright, vulnerability, and reputation.
Official Libraries
Python
xarf (Python)
StableParse, validate, and generate XARF v4 reports with Pydantic v2 models and schema-driven validation.
- Functional API:
parse,create_report,create_evidence - Schema-driven validation against the official XARF v4.2.0 JSON schemas
- Pydantic v2 discriminated-union models for all 7 categories
- Structured errors, warnings, and missing-optional info (
ParseResult) - Automatic v3 detection and conversion to v4
- Evidence helper with base64 encoding, hashing, and size
JavaScript / TypeScript
@xarf/xarf (JavaScript/TypeScript)
StableParse, validate, and generate XARF v4 reports in Node.js with full TypeScript types.
- Functional API:
parse,createReport,createEvidence - Schema-driven validation against the bundled XARF v4.2.0 JSON schemas
- Full TypeScript support with discriminated-union types for all 7 categories
- Structured results with
errors,warnings, andinfo - Automatic v3 detection and conversion (plus
isXARFv3/convertV3toV4helpers) - Schemas bundled at build time โ zero filesystem/network dependency
Go
xarf-go (Go)
StableParse, validate, and generate XARF v4 reports with type-safe Go structs.
- Package-level
Parse,CreateReport,CreateEvidencemirroring the JS API - Typed API:
NewParser(strict),NewValidator(),NewGenerator() - Schema-driven validation against the embedded XARF v4.2.0 schemas
- Type-safe structs for all 7 category reports
- Third-party reporting via separate
reporter/senderfields - Automatic v3 detection and conversion; zero runtime dependencies
C# / .NET
Xarf (C#/.NET)
StableParse, validate, and generate XARF v4 reports on .NET with schema-driven validation.
- Static
XarfApi.Parse,XarfApi.CreateReport,XarfApi.CreateEvidencemirroring the JS API - Schema-driven validation against the embedded XARF v4.2.0 schemas
- Result objects with
Errors,Warnings, andInfo(no throw on validation failure) - Legacy typed
Parser/Generator/Validatorretained for compatibility - All 7 categories; automatic v3 detection and conversion
- Runs on .NET 8/9/10, and .NET 6/7, Core 3.x, Mono/Xamarin/Unity via
netstandard2.1(not .NET Framework 4.x)
Quick Start
Choose your language and get started in minutes. Each example uses the real, published API.
# Install
pip install xarf
# Parse and validate a report
from xarf import parse
result = parse({
"xarf_version": "4.2.0",
"report_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"timestamp": "2024-01-15T10:30:00Z",
"reporter": {
"org": "Security Team",
"contact": "[email protected]",
"domain": "example.com",
},
"sender": {
"org": "Security Team",
"contact": "[email protected]",
"domain": "example.com",
},
"source_identifier": "192.0.2.100",
"category": "connection",
"type": "ddos",
"evidence_source": "honeypot",
"destination_ip": "203.0.113.10",
"protocol": "tcp",
})
if not result.errors:
print(result.report.category) # 'connection'
else:
for e in result.errors:
print(f"{e.field}: {e.message}")// Install
npm install @xarf/xarf
// Parse and validate a report
import { parse } from '@xarf/xarf';
const { report, errors, warnings } = parse({
xarf_version: '4.2.0',
report_id: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
timestamp: '2024-01-15T10:30:00Z',
reporter: {
org: 'Security Team',
contact: '[email protected]',
domain: 'example.com',
},
sender: {
org: 'Security Team',
contact: '[email protected]',
domain: 'example.com',
},
source_identifier: '192.0.2.100',
category: 'connection',
type: 'ddos',
evidence_source: 'honeypot',
destination_ip: '203.0.113.10',
protocol: 'tcp',
});
if (errors.length === 0) {
console.log(report.category); // 'connection'
} else {
console.log('Validation errors:', errors);
}// Install
// go get github.com/xarf/xarf-go
package main
import (
"fmt"
"log"
"github.com/xarf/xarf-go"
)
func main() {
data := []byte(`{
"xarf_version": "4.2.0",
"report_id": "550e8400-e29b-41d4-a716-446655440000",
"timestamp": "2024-01-15T10:30:00Z",
"reporter": {
"org": "Security Team",
"contact": "[email protected]",
"domain": "example.com"
},
"sender": {
"org": "Security Team",
"contact": "[email protected]",
"domain": "example.com"
},
"source_identifier": "192.0.2.100",
"category": "connection",
"type": "ddos",
"evidence_source": "honeypot",
"destination_ip": "203.0.113.10",
"protocol": "tcp"
}`)
// Parse returns a result with errors/warnings; an error is only
// returned for malformed JSON or oversized input.
result, err := xarf.Parse(data, nil)
if err != nil {
log.Fatal(err)
}
if len(result.Errors) == 0 {
fmt.Println("Report is valid!")
} else {
fmt.Println("Validation errors:", result.Errors)
}
}// Install
// dotnet add package Xarf
using Xarf;
var json = @"{
""xarf_version"": ""4.2.0"",
""report_id"": ""550e8400-e29b-41d4-a716-446655440000"",
""timestamp"": ""2024-01-15T10:30:00Z"",
""reporter"": {
""org"": ""Security Team"",
""contact"": ""[email protected]"",
""domain"": ""example.com""
},
""sender"": {
""org"": ""Security Team"",
""contact"": ""[email protected]"",
""domain"": ""example.com""
},
""source_identifier"": ""192.0.2.100"",
""category"": ""connection"",
""type"": ""ddos"",
""evidence_source"": ""honeypot"",
""destination_ip"": ""203.0.113.10"",
""protocol"": ""tcp""
}";
// Parse returns a result; only malformed JSON / oversized input throws.
ParseResult result = XarfApi.Parse(json);
if (result.Errors.Count == 0)
{
Console.WriteLine("Report is valid!");
}
else
{
foreach (var error in result.Errors)
Console.WriteLine($" - {error}");
}Library Features Comparison
All four official libraries implement XARF v4.2.0 with schema-driven validation and v3 backward compatibility.
| Feature | Python | JavaScript | Go | C# |
|---|---|---|---|---|
| Status | Stable (1.0.0) | Stable (1.1.0) | Stable (1.1.0) | Stable (1.1.0) |
| License | MIT | MIT | Apache-2.0 | MIT |
Functional API (parse/createReport/createEvidence) |
โ | โ | โ | โ |
| Typed API | โ (Pydantic v2) | โ (TS types) | โ (NewParser/NewValidator/NewGenerator) |
โ (Parser/Generator/Validator) |
| Schema-driven validation (v4.2.0) | โ | โ | โ | โ |
| All 7 categories | โ | โ | โ | โ |
| v3 โ v4 conversion | โ | โ | โ | โ |
| Evidence helper (base64 + hash + size) | โ | โ | โ | โ |
| Published registry | PyPI | npm | pkg.go.dev | NuGet |
Legend: โ Available
Community & Contributing
We welcome community libraries and contributions for additional languages and frameworks.
Looking to contribute?
A Perl implementation (xarf-perl) is in development and not yet published to CPAN โ contributions are welcome. We'd also love help with other languages:
- Perl (in development)
- Ruby
- PHP
- Rust
- Swift
- Kotlin
Need Help?
- Implementation Guide - Integration guide
- GitHub Discussions - Ask questions
- GitHub Issues - Report bugs