vulndbreqs

package
v0.0.0-...-25a572b Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package vulndbreqs supports recording the daily count of requests to the Vulnerability Database.

Index

Constants

View Source
const (
	// Vuln DB requests live in their own dataset that doesn't vary.
	DatasetName             = "vulndb"
	RequestCountTableName   = "requests"
	IPRequestCountTableName = "ip-requests"
)

Variables

This section is empty.

Functions

func ComputeAndStore

func ComputeAndStore(ctx context.Context, vulndbBucketProjectID string, client *bigquery.Client, hmacKey []byte) error

ComputeAndStore computes Vuln DB request counts from the last date we have data for, and writes them to BigQuery.

func ComputeAndStoreDate

func ComputeAndStoreDate(ctx context.Context, vulndbBucketProjectID string, client *bigquery.Client, hmacKey []byte, date civil.Date) error

ComputeAndStoreDate computes the request counts for the given date and writes them to BigQuery. It does so even if there is already stored information for that date.

Types

type IPRequestCount

type IPRequestCount struct {
	CreatedAt time.Time  `bigquery:"created_at"`
	Date      civil.Date `bigquery:"date"` // year-month-day without a timezone
	IP        string     `bigquery:"ip"`   // obfuscated IP address
	Count     int        `bigquery:"count"`
}

IPRequestCount holds the number of requests for a single IP on a date.

func Compute

func Compute(ctx context.Context, vulndbBucketProjectID string, date civil.Date, hmacKey []byte) ([]*IPRequestCount, error)

Compute computes counts for all vuln DB requests on the given date. It returns request counts grouped by obfuscated IP address.

func (*IPRequestCount) SetUploadTime

func (r *IPRequestCount) SetUploadTime(t time.Time)

SetUploadTime is used by Client.Upload.

type RequestCount

type RequestCount struct {
	CreatedAt time.Time  `bigquery:"created_at"`
	Date      civil.Date `bigquery:"date"` // year-month-day without a timezone
	Count     int        `bigquery:"count"`
}

RequestCount holds the number of requests made on a date.

func ReadRequestCountsFromBigQuery

func ReadRequestCountsFromBigQuery(ctx context.Context, client *bigquery.Client) (_ []*RequestCount, err error)

ReadRequestCountsFromBigQuery returns daily counts for requests to the vuln DB, most recent first.

func (*RequestCount) SetUploadTime

func (r *RequestCount) SetUploadTime(t time.Time)

SetUploadTime is used by Client.Upload.

Jump to

Keyboard shortcuts

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