styx/models/types.go
Christopher Talib 6eaae99668 Extracting structures from CertStream
This work builds an extractor for the data in the CertStream in order to
save it. It builds itself from the previous work, so extensions and
flags can be added to the structures. The work in `utils` is basically a
big extractor for the data taking advantage of the JSONq library.

Currently, there is not refactoring and the "chains" are not saved
because they need additionnal computation which will come in a later
commit.
2020-01-15 14:36:53 +01:00

73 lines
2.1 KiB
Go

package models
import (
"time"
"github.com/google/uuid"
)
// Node defines the data we gather through the parsing.
type Node struct {
ID uuid.UUID
Flag string `json:"flag"`
Data CertStreamStruct `json:"data"`
}
// Edge defines a relation between two nodes.
type Edge struct {
ID uuid.UUID
NodeOneID uuid.UUID `json:"NodeOneID"`
// NodeTwoID uuid.UUID `json:NodeTwoID` to implement
Timestamp time.Time `json:"Timestamp"`
}
type LeafCertExtensions struct {
KeyUsage string `json:"keyUsage"`
ExtendedKeyUsage string `json:"extendedKeyUsage"`
BasicConstrains string `json:"basicConstrains"`
SubjectKeyIdentifier string `json:"subjectKeyIdentifier"`
AuthorityInfoAccess string `json:"authorityInfoAccess"`
SubjectAltName string `json:"subjectAltName"`
CertificatePolicies string `json:"certificatePolicies"`
}
type LeafCertSubject struct {
Aggregated string `json:"aggregated"`
C string `json:"C"`
ST string `json:"ST"`
L string `json:"L"`
O string `json:"O"`
OU string `json:"OU"`
CN string `json:"CN"`
}
type LeafCertStruct struct {
Subject *LeafCertSubject `json:"subject"`
Extensions *LeafCertExtensions `json:"extensions"`
NotBefore string `json:"not_before"`
NotAfter string `json:"not_after"`
SerialNumber string `json:"serial_number"`
Fingerprint string `json:"fingerprint"`
AsDer string `json:"as_der"`
AllDomains []string `json:"all_domains"`
}
type Source struct {
URL string `json:"url"`
Name string `json:"name"`
}
type CertStreamData struct {
UpdateType string `json:"update_type"`
LeafCert *LeafCertStruct `json:"leaf_cert"`
Chain []*LeafCertStruct `json:"chain"`
CertIndex int `json:"cert_index"`
Seen int `json:"seen"`
Source *Source `json:"source"`
}
type CertStreamStruct struct {
MessageType string `json:"message_data"`
Data *CertStreamData `json:"data"`
}