2020-01-14 16:31:57 +01:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/google/uuid"
|
|
|
|
)
|
|
|
|
|
2020-01-16 12:06:03 +01:00
|
|
|
// Node defines the data we gather through the parsing. It should follow the
|
|
|
|
// Styx terminology
|
|
|
|
// (https://docs.google.com/document/d/1dIrh1Lp3KAjEMm8o2VzAmuV0Peu-jt9aAh1IHrjAroM/pub#h.xzbicbtscatx)
|
2020-01-14 16:31:57 +01:00
|
|
|
type Node struct {
|
2020-01-23 14:36:24 +01:00
|
|
|
ID string `json:"id"`
|
|
|
|
Type string `json:"type"`
|
2020-01-22 15:01:07 +01:00
|
|
|
Data CertStreamStruct `json:"data"`
|
2020-01-26 17:26:03 +01:00
|
|
|
Created string `json:"created"`
|
|
|
|
Modified string `json:"modified"`
|
2020-01-14 16:31:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Edge defines a relation between two nodes.
|
|
|
|
type Edge struct {
|
2020-01-16 12:06:03 +01:00
|
|
|
ID string `json:"id"`
|
2020-01-14 16:31:57 +01:00
|
|
|
NodeOneID uuid.UUID `json:"NodeOneID"`
|
|
|
|
// NodeTwoID uuid.UUID `json:NodeTwoID` to implement
|
2020-01-26 17:26:03 +01:00
|
|
|
Timestamp string `json:"Timestamp"`
|
2020-01-14 16:31:57 +01:00
|
|
|
}
|
|
|
|
|
2020-01-26 17:26:03 +01:00
|
|
|
// LeafCertExtensions extends the LeafCert object.
|
2020-01-14 16:31:57 +01:00
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
2020-01-26 17:27:20 +01:00
|
|
|
// LeafCertSubject is the subject of the LeafCert object.
|
2020-01-14 16:31:57 +01:00
|
|
|
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"`
|
|
|
|
}
|
|
|
|
|
2020-01-26 17:27:20 +01:00
|
|
|
// LeafCertStruct represents the LeafCert object.
|
2020-01-14 16:31:57 +01:00
|
|
|
type LeafCertStruct struct {
|
2020-01-22 15:01:07 +01:00
|
|
|
Subject LeafCertSubject `json:"subject"`
|
|
|
|
Extensions LeafCertExtensions `json:"extensions"`
|
|
|
|
NotBefore int `json:"not_before"`
|
|
|
|
NotAfter int `json:"not_after"`
|
|
|
|
SerialNumber string `json:"serial_number"`
|
|
|
|
Fingerprint string `json:"fingerprint"`
|
|
|
|
AsDer string `json:"as_der"`
|
|
|
|
AllDomains []string `json:"all_domains"`
|
2020-01-14 16:31:57 +01:00
|
|
|
}
|
|
|
|
|
2020-01-26 17:27:20 +01:00
|
|
|
// Source is the object ofr the URL and its name.
|
2020-01-14 16:31:57 +01:00
|
|
|
type Source struct {
|
|
|
|
URL string `json:"url"`
|
|
|
|
Name string `json:"name"`
|
|
|
|
}
|
|
|
|
|
2020-01-26 17:27:20 +01:00
|
|
|
// CertStreamData is the data contained in a CertStream payload.
|
2020-01-14 16:31:57 +01:00
|
|
|
type CertStreamData struct {
|
2020-01-22 15:01:07 +01:00
|
|
|
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"`
|
2020-01-14 16:31:57 +01:00
|
|
|
}
|
|
|
|
|
2020-01-26 17:27:20 +01:00
|
|
|
// CertStreamStruct reprensts a payload received from CertStream. It has a type
|
|
|
|
// and the content is stored in Data.
|
2020-01-14 16:31:57 +01:00
|
|
|
type CertStreamStruct struct {
|
2020-01-22 15:01:07 +01:00
|
|
|
MessageType string `json:"message_data"`
|
|
|
|
Data CertStreamData `json:"data"`
|
2020-01-14 16:31:57 +01:00
|
|
|
}
|
2020-01-26 17:27:20 +01:00
|
|
|
|
|
|
|
// PasteMeta is a set of descriptive information on a paste.
|
|
|
|
type PasteMeta struct {
|
|
|
|
ScrapeURL string `json:"scrape_url"`
|
|
|
|
FullURL string `json:"full_url"`
|
|
|
|
Date string `json:"date"`
|
|
|
|
Key string `json:"key"`
|
|
|
|
Size string `json:"size"`
|
|
|
|
Expire string `json:"expire"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Syntax string `json:"syntax"`
|
|
|
|
User string `json:"user"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// PasteFull extends PasteMeta by the actual content.
|
|
|
|
type PasteFull struct {
|
|
|
|
ScrapeURL string `json:"scrape_url"`
|
|
|
|
FullURL string `json:"full_url"`
|
|
|
|
Date string `json:"date"`
|
|
|
|
Key string `json:"key"`
|
|
|
|
Size string `json:"size"`
|
|
|
|
Expire string `json:"expire"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Syntax string `json:"syntax"`
|
|
|
|
User string `json:"user"`
|
|
|
|
Data string `json:"data"`
|
|
|
|
RFC3339 string `json:"time"`
|
|
|
|
}
|