Skip to content

gemaraproj/go-gemara

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

go-gemara

Go Reference License Go Version CI Go Report Card

Go SDK for parsing and converting Gemara documents.

Overview

This repository provides Go types and utilities for working with Gemara documents. The Go types are generated from CUE schemas published in the Gemara CUE module (github.com/gemaraproj/gemara@v0) available in the CUE Central Registry.

Installation

go get github.com/gemaraproj/go-gemara

Usage

CLI Tool

The oscalexport command-line tool converts Gemara documents to OSCAL format.

Building the CLI

make build

This builds binaries to ./bin/ directory.

Converting a Control Catalog

./bin/oscalexport catalog ./path/to/catalog.yaml --output ./catalog.json

Converting a Guidance Catalog

./bin/oscalexport guidance ./path/to/guidance.yaml \
    --catalog-output ./guidance.json \
    --profile-output ./profile.json

Library Usage

Loading Gemara Documents

package main

import (
    "github.com/gemaraproj/go-gemara"
)

func main() {
    // Load a Guidance Catalog
    var guidance gemara.GuidanceCatalog
    if err := guidance.LoadFile("file:///path/to/guidance.yaml"); err != nil {
        panic(err)
    }
    
    // Load a Control Catalog
    catalog := &gemara.ControlCatalog{}
    if err := catalog.LoadFile("file:///path/to/catalog.yaml"); err != nil {
        panic(err)
    }
}

Converting to OSCAL

package main

import (
    "github.com/gemaraproj/go-gemara"
    "github.com/gemaraproj/go-gemara/gemaraconv"
)

func main() {
    // Convert Control Catalog to OSCAL
    catalog := &gemara.ControlCatalog{}
    if err := catalog.LoadFile("file:///path/to/catalog.yaml"); err != nil {
        panic(err)
    }
    
    oscalCatalog, err := gemaraconv.ControlCatalog(catalog).ToOSCAL()
    if err != nil {
        panic(err)
    }
    
    // Convert Guidance Catalog to OSCAL
    var guidance gemara.GuidanceCatalog
    if err := guidance.LoadFile("file:///path/to/guidance.yaml"); err != nil {
        panic(err)
    }
    
    oscalCatalog, oscalProfile, err := gemaraconv.GuidanceCatalog(&guidance).ToOSCAL("relative/path/to/catalog.json")
    if err != nil {
        panic(err)
    }
}

Converting to SARIF

package main

import (
    "github.com/gemaraproj/go-gemara"
    "github.com/gemaraproj/go-gemara/gemaraconv"
)

func main() {
    // Load Control Catalog (required for SARIF conversion)
    catalog := &gemara.ControlCatalog{}
    if err := catalog.LoadFile("file:///path/to/catalog.yaml"); err != nil {
        panic(err)
    }
    
    // Convert EvaluationLog to SARIF
    evaluationLog := &gemara.EvaluationLog{
        // ... populate evaluation log ...
    }
    
    sarifBytes, err := gemaraconv.EvaluationLog(evaluationLog).ToSARIF("file:///path/to/artifact.md", catalog)
    if err != nil {
        panic(err)
    }
}

Development

Building

make build

Testing

# Run all tests
make test

# Run tests with coverage
make testcov

# Check coverage threshold
make coverage-check

Linting

make lint

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

About

Go SDK for parsing Gemara documents.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors