Go SDK for parsing and converting Gemara documents.
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.
go get github.com/gemaraproj/go-gemaraThe oscalexport command-line tool converts Gemara documents to OSCAL format.
make buildThis builds binaries to ./bin/ directory.
./bin/oscalexport catalog ./path/to/catalog.yaml --output ./catalog.json./bin/oscalexport guidance ./path/to/guidance.yaml \
--catalog-output ./guidance.json \
--profile-output ./profile.jsonpackage 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)
}
}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)
}
}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)
}
}make build# Run all tests
make test
# Run tests with coverage
make testcov
# Check coverage threshold
make coverage-checkmake lintLicensed under the Apache License, Version 2.0. See LICENSE for details.