Home / Documentation / XARF Libraries

Official and community XARF libraries for multiple programming languages

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)

Stable

Parse, validate, and generate XARF v4 reports with Pydantic v2 models and schema-driven validation.

๐Ÿ“ฆ PyPI: pip install xarf ๐Ÿท๏ธ v1.0.0 ยท MIT ยท Python 3 (Pydantic v2) ๐Ÿ“š Documentation โญ GitHub ๐Ÿ”— PyPI
Features:
  • 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)

Stable

Parse, validate, and generate XARF v4 reports in Node.js with full TypeScript types.

๐Ÿ“ฆ npm: npm install @xarf/xarf ๐Ÿท๏ธ v1.1.0 ยท MIT ยท Node.js 18+ ๐Ÿ“š Documentation โญ GitHub ๐Ÿ”— npm
Features:
  • 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, and info
  • Automatic v3 detection and conversion (plus isXARFv3/convertV3toV4 helpers)
  • Schemas bundled at build time โ€” zero filesystem/network dependency

Go

xarf-go (Go)

Stable

Parse, validate, and generate XARF v4 reports with type-safe Go structs.

๐Ÿ“ฆ go get github.com/xarf/xarf-go ๐Ÿท๏ธ v1.1.0 ยท Apache-2.0 ยท Go 1.21+ ๐Ÿ“š Documentation โญ GitHub ๐Ÿ”— pkg.go.dev
Features:
  • Package-level Parse, CreateReport, CreateEvidence mirroring 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/sender fields
  • Automatic v3 detection and conversion; zero runtime dependencies

C# / .NET

Xarf (C#/.NET)

Stable

Parse, validate, and generate XARF v4 reports on .NET with schema-driven validation.

๐Ÿ“ฆ NuGet: dotnet add package Xarf ๐Ÿท๏ธ v1.1.0 ยท MIT ยท netstandard2.1 + net8.0 (.NET 8/9/10) ๐Ÿ“š Documentation โญ GitHub ๐Ÿ”— NuGet
Features:
  • Static XarfApi.Parse, XarfApi.CreateReport, XarfApi.CreateEvidence mirroring the JS API
  • Schema-driven validation against the embedded XARF v4.2.0 schemas
  • Result objects with Errors, Warnings, and Info (no throw on validation failure)
  • Legacy typed Parser/Generator/Validator retained 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}")

โ†’ Full Python Documentation

// 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);
}

โ†’ Full JavaScript Documentation

// 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)
    }
}

โ†’ Full Go Documentation

// 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}");
}

โ†’ Full C# Documentation


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

Contribution Guide


Need Help?