Skip to content

Latest commit

 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cap

Go Reference License

A Go implementation of OASIS Common Alerting Protocol Version 1.2 and the Canadian Profile (CAP-CP).

Go 1.27 or newer is required.

The package provides XML parsing and encoding, JSON encoding, CAP 1.2 validation, CAP-CP 1.0 single-message validation, geometry helpers, XML Signature parsing, and enveloped signature verification.

Usage

package main

import (
	"fmt"
	"os"

	"github.com/tannerryan/cap"
)

func main() {
	contents, err := os.ReadFile("alert.xml")
	if err != nil {
		panic(err)
	}
	alert, err := cap.ParseCAP(contents)
	if err != nil {
		panic(err)
	}
	if err := alert.Validate().Err(); err != nil {
		panic(err)
	}
	for _, info := range alert.Info {
		fmt.Println(info.Headline)
	}
}

ParseCAP checks XML syntax, namespaces, dates, and code values. Call Validate for semantic CAP checks. Use ValidateCAPCP for the Canadian profile, MarshalCAP to encode an alert, and VerifySignature with trusted certificate roots to check a signed message. Validation returns errors for broken rules and warnings for recommendations. CAP-CP validation does not download its separately managed event and location lists or message history.

Development

Install the development tools with make deps, then run make check.

License

This project is available under the BSD 2-Clause License.

About

Package cap is the Go implementation of OASIS Common Alerting Protocol Version 1.2 (CAP) + Canadian Profile (CAP-CP).

Topics

Resources

Stars

5 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages