bq

package
v0.0.0-...-72c2bb7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConfigInvalid when missing required fields.
	ErrConfigInvalid = errors.New("configuration was missing dataset name or table name")
)

Functions

func CTBigQueryResultToDomain

func CTBigQueryResultToDomain(certHash string, result *Result) *am.CTRecord

Types

type BigQuerier

type BigQuerier interface {
	Init(config, credentials []byte) error
	QueryETLD(ctx context.Context, from time.Time, etld string) (map[string]*am.CTRecord, error)
	QuerySubdomains(ctx context.Context, from time.Time, etld string) (map[string]*am.CTSubdomain, error)
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for querying BigQuery

func NewClient

func NewClient() *Client

NewClient creates a new BigQuery client

func (*Client) Init

func (c *Client) Init(config, credentials []byte) error

Init the BigQuery client by parsing config and calling initBQClient

func (*Client) QueryETLD

func (c *Client) QueryETLD(ctx context.Context, from time.Time, etld string) (map[string]*am.CTRecord, error)

QueryETLD and return all records from our bigquery table

func (*Client) QuerySubdomains

func (c *Client) QuerySubdomains(ctx context.Context, from time.Time, etld string) (map[string]*am.CTSubdomain, error)

QuerySubdomains just extracts the common name from the ct log data table.

type ClientConfig

type ClientConfig struct {
	ProjectID   string `json:"project_id"`
	DatasetName string `json:"dataset_name"`
	TableName   string `json:"table_name"`
}

ClientConfig of required fields

type ETLDResult

type ETLDResult struct {
	CertHash string  `bigquery:"certhash"`
	Result   *Result `bigquery:"result"`
}

ETLDResult containing ct record

type Result

type Result struct {
	Time               time.Time `bigquery:"time"`
	Server             string    `bigquery:"server"`
	Index              int64     `bigquery:"index"`
	SerialNumber       string    `bigquery:"serialnumber"`
	NotBefore          time.Time `bigquery:"notbefore"`
	NotAfter           time.Time `bigquery:"notafter"`
	Country            string    `bigquery:"country"`
	Organization       string    `bigquery:"organization"`
	OrganizationalUnit string    `bigquery:"organizationalunit"`
	CommonName         string    `bigquery:"commonname"`
	VerifiedDNSNames   string    `bigquery:"verifieddnsnames"`
	UnverifiedDNSNames string    `bigquery:"unverifieddnsnames"`
	IPAddresses        string    `bigquery:"ipaddresses"`
	EmailAddresses     string    `bigquery:"emailaddresses"`
	ETLD               string    `bigquery:"etld"`
}

Result of CT record

type SubdomainResult

type SubdomainResult struct {
	CommonName string `bigquery:"commonname"`
}

SubdomainResult is just so we can have bigquery struct tags.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL