Documentation ¶
Index ¶
- Variables
- type Analyses
- type Analysis
- type DB
- func (db *DB) AddCertToAndroidTruststore(id int64) error
- func (db *DB) AddCertToAppleTruststore(id int64) error
- func (db *DB) AddCertToMicrosoftTruststore(id int64) error
- func (db *DB) AddCertToMozillaTruststore(id int64) error
- func (db *DB) AddCertToUbuntuTruststore(id int64) error
- func (db *DB) CountDistinctCertsAddedLast24Hours() (count int64, err error)
- func (db *DB) CountDistinctCertsSeenLast24Hours() (count int64, err error)
- func (db *DB) CountLast24HoursScans() (hourlyStats []HourlyScansCount, err error)
- func (db *DB) CountPendingScans() (count int64, err error)
- func (db *DB) CountScansLast24Hours() (count int64, err error)
- func (db *DB) CountTableEntries() (scans, trusts, analyses, certificates int64, err error)
- func (db *DB) CountTargetsLast24Hours() (count, countDistinct int64, err error)
- func (db *DB) GetAllCertsInStore(store string) (out []certificate.Certificate, err error)
- func (db *DB) GetAnalysisByScan(id int64) ([]Analysis, error)
- func (db *DB) GetCACertsBySubject(subject certificate.Subject) (certs []*certificate.Certificate, err error)
- func (db *DB) GetCertByID(certID int64) (*certificate.Certificate, error)
- func (db *DB) GetCertBySHA1Fingerprint(sha1 string) (*certificate.Certificate, error)
- func (db *DB) GetCertIDBySHA1Fingerprint(sha1 string) (id int64, err error)
- func (db *DB) GetCertIDBySHA256Fingerprint(sha256 string) (id int64, err error)
- func (db *DB) GetCertIDFromTrust(trustID int64) (id int64, err error)
- func (db *DB) GetCertPaths(cert *certificate.Certificate) (paths certificate.Paths, err error)
- func (db *DB) GetCurrentTrustID(certID, issuerID int64) (int64, error)
- func (db *DB) GetCurrentTrustIDForCert(certID int64) (int64, error)
- func (db *DB) GetEECountForIssuerByID(certID int64) (count int64, err error)
- func (db *DB) GetLastScanTimeForTarget(target string) (int64, time.Time, error)
- func (db *DB) GetLatestStatisticsFromView() (stats Statistics, err error)
- func (db *DB) GetScanByID(id int64) (Scan, error)
- func (db *DB) GetValidationMapForCert(certID int64) (map[string]certificate.ValidationInfo, int64, error)
- func (db *DB) InsertCertificate(cert *certificate.Certificate) (int64, error)
- func (db *DB) InsertTrustToDB(cert certificate.Certificate, certID, parID int64) (int64, error)
- func (db *DB) InsertWorkerAnalysis(scanid int64, jsonRes []byte, workerName string) error
- func (db *DB) IsTrustValid(id int64) (bool, error)
- func (db *DB) NewScan(domain string, rplay int, jsonParams []byte) (Scan, error)
- func (db *DB) RegisterScanListener(dbname, user, password, hostport, sslmode string) <-chan int64
- func (db *DB) RemoveCACertFromTruststore(trustedCerts []string, tsName string) error
- func (db *DB) UpdateCertLastSeen(cert *certificate.Certificate) error
- func (db *DB) UpdateCertLastSeenByID(id int64) error
- func (db *DB) UpdateCertMarkAsRevoked(id int64, when time.Time) error
- func (db *DB) UpdateCertificate(cert *certificate.Certificate) error
- func (db *DB) UpdateCertificateRank(id, rank int64) error
- func (db *DB) UpdateCertsLastSeenByID(ids []int64) error
- func (db *DB) UpdateScanCompletionPercentage(id int64, p int) error
- func (db *DB) UpdateTrust(trustID int64, cert certificate.Certificate) (int64, error)
- type HourlyScansCount
- type Scan
- type Scannable
- type Statistics
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidCertStore = fmt.Errorf("Invalid certificate store provided")
Functions ¶
This section is empty.
Types ¶
type Analysis ¶
type Analysis struct { ID int64 `json:"id"` Analyzer string `json:"analyzer"` Result json.RawMessage `json:"result"` Success bool `json:"success"` }
type DB ¶
func RegisterConnection ¶
func (*DB) AddCertToAndroidTruststore ¶
func (*DB) AddCertToAppleTruststore ¶
func (*DB) AddCertToMicrosoftTruststore ¶
func (*DB) AddCertToMozillaTruststore ¶
func (*DB) AddCertToUbuntuTruststore ¶
func (*DB) CountDistinctCertsAddedLast24Hours ¶
CountDistinctCertsAddedLast24Hours returns the count of unique certificates added over the last 24 hours
func (*DB) CountDistinctCertsSeenLast24Hours ¶
CountDistinctCertsSeenLast24Hours returns the count of unique certificates seen over the last 24 hours
func (*DB) CountLast24HoursScans ¶
func (db *DB) CountLast24HoursScans() (hourlyStats []HourlyScansCount, err error)
CountLast24HoursScans returns a list of hourly scans count for the last 24 hours, sorted from most recent the oldest
func (*DB) CountPendingScans ¶
CountPendingScans returns the total number of scans that are pending in the queue
func (*DB) CountScansLast24Hours ¶
CountScansLast24Hours returns the count of scans over the last 24 hours
func (*DB) CountTableEntries ¶
CountTableEntries returns the estimated count of scans, trusts relationships, analyses and certificates stored in database. The count uses Postgres' own stats counter and is not guaranteed to be fully accurate.
func (*DB) CountTargetsLast24Hours ¶
CountTargetsLast24Hours returns the number of unique targets scanned over the last 24 hours
func (*DB) GetAllCertsInStore ¶
func (db *DB) GetAllCertsInStore(store string) (out []certificate.Certificate, err error)
func (*DB) GetCACertsBySubject ¶
func (db *DB) GetCACertsBySubject(subject certificate.Subject) (certs []*certificate.Certificate, err error)
GetCACertsBySubject returns a list of CA certificates that match a given subject
func (*DB) GetCertByID ¶
func (db *DB) GetCertByID(certID int64) (*certificate.Certificate, error)
GetCertByID fetches a certain certificate from the database. It returns a pointer to a Certificate struct and any errors that occur.
func (*DB) GetCertBySHA1Fingerprint ¶
func (db *DB) GetCertBySHA1Fingerprint(sha1 string) (*certificate.Certificate, error)
GetCertBySHA1Fingerprint fetches a certain certificate from the database. It returns a pointer to a Certificate struct and any errors that occur.
func (*DB) GetCertIDBySHA1Fingerprint ¶
GetCertIDWithSHA1Fingerprint fetches the database id of the certificate with the given SHA1 fingerprint. Returns the mentioned id and any errors that happen. It wraps the sql.ErrNoRows error in order to avoid passing not existing row errors to upper levels. In that case it returns -1 with no error.
func (*DB) GetCertIDBySHA256Fingerprint ¶
GetCertIDWithSHA256Fingerprint fetches the database id of the certificate with the given SHA256 fingerprint. Returns the mentioned id and any errors that happen. It wraps the sql.ErrNoRows error in order to avoid passing not existing row errors to upper levels. In that case it returns -1 with no error.
func (*DB) GetCertIDFromTrust ¶
GetCertIDFromTrust fetches the database id of the certificate in the trust relation with the given id. Returns the mentioned id and any errors that happen. It wraps the sql.ErrNoRows error in order to avoid passing not existing row errors to upper levels. In that case it returns -1 with no error.
func (*DB) GetCertPaths ¶
func (db *DB) GetCertPaths(cert *certificate.Certificate) (paths certificate.Paths, err error)
GetCertPaths returns the various certificates paths from the current cert to roots. It takes a certificate as argument that will be used as the start of the path.
func (*DB) GetCurrentTrustID ¶
func (*DB) GetCurrentTrustIDForCert ¶
func (*DB) GetEECountForIssuerByID ¶
GetEECountForIssuerByID gets the count of valid end entity certificates in the database that chain to the certificate with the specified ID
func (*DB) GetLastScanTimeForTarget ¶
GetLastScanTimeForTarget searches the database for the latest scan for a specific target. It returns both the scan timestamp and the id of the scan to enable the api to respond to clients with just one db query.
func (*DB) GetLatestStatisticsFromView ¶
func (db *DB) GetLatestStatisticsFromView() (stats Statistics, err error)
GetLatestStatisticsFromView retrieves the content of the `statistics` materialized view and returns it in a Statistics struct. The freshness of the data is not guaranteed, but if the materialized view is older than 5 minutes, an automatic refresh is kicked off *after* retrieving the data. In effect, unless you query the stats endpoint constantly, this will likely return data several minutes, if not a few hours old.
func (*DB) GetValidationMapForCert ¶
func (db *DB) GetValidationMapForCert(certID int64) (map[string]certificate.ValidationInfo, int64, error)
func (*DB) InsertCertificate ¶
func (db *DB) InsertCertificate(cert *certificate.Certificate) (int64, error)
InsertCertificate inserts a x509 certificate to the database. It takes as input a Certificate pointer. It returns the database ID of the inserted certificate ( -1 if an error occurs ) and an error, if it occurs.
func (*DB) InsertTrustToDB ¶
func (db *DB) InsertTrustToDB(cert certificate.Certificate, certID, parID int64) (int64, error)
func (*DB) InsertWorkerAnalysis ¶
func (*DB) IsTrustValid ¶
IsTrustValid returns the validity of the trust relationship for the given id. It returns a "valid" if any of the per truststore valitities is valid It returns a boolean that represent if trust is valid or not.
func (*DB) RegisterScanListener ¶
RegisterScanListener "subscribes" to the notifications published to the scan_listener notifier. It has as input the usual db attributes and returns an int64 channel which can be consumed for newly created scan id's.
func (*DB) RemoveCACertFromTruststore ¶
RemoveCACertFromTruststore takes a list of hashes from certs trusted by a given truststore and disables the trust of all certs not listed but trusted in DB
func (*DB) UpdateCertLastSeen ¶
func (db *DB) UpdateCertLastSeen(cert *certificate.Certificate) error
UpdateCertLastSeen updates the last_seen timestamp of the input certificate. Outputs an error if it occurs.
func (*DB) UpdateCertLastSeenByID ¶
UpdateCertLastSeenByID updates the last_seen timestamp of the certificate with the given id. Outputs an error if it occurs.
func (*DB) UpdateCertMarkAsRevoked ¶
func (*DB) UpdateCertificate ¶
func (db *DB) UpdateCertificate(cert *certificate.Certificate) error
UpdateCertificate updates a x509 certificate in the database. It takes as input a Certificate pointer, and returns an error
func (*DB) UpdateCertificateRank ¶
UpdateCertificateRank updates the rank integer of the input certificate.
func (*DB) UpdateCertsLastSeenByID ¶
UpdateCertsLastSeenByID updates the last_seen timestamp for certificates with the given id. Outputs an error if it occurs.
func (*DB) UpdateScanCompletionPercentage ¶
func (*DB) UpdateTrust ¶
func (db *DB) UpdateTrust(trustID int64, cert certificate.Certificate) (int64, error)
type HourlyScansCount ¶
HourlyScansCount represents the number of scans completed over one hour
type Scan ¶
type Scan struct { ID int64 `json:"id"` Timestamp time.Time `json:"timestamp"` Target string `json:"target"` Replay int `json:"replay"` //hours or days Has_tls bool `json:"has_tls"` Cert_id int64 `json:"cert_id"` Trust_id int64 `json:"trust_id"` Is_valid bool `json:"is_valid"` Validation_error string `json:"validation_error,omitempty"` ScanError string `json:"scan_error,omitempty"` Complperc int `json:"completion_perc"` Conn_info connection.Stored `json:"connection_info"` AnalysisResults Analyses `json:"analysis,omitempty"` Ack bool `json:"ack"` Attempts int `json:"attempts"` //number of retries AnalysisParams map[string]interface{} `json:"analysis_params"` }
type Statistics ¶
type Statistics struct { Scans int64 `json:"scans"` Trusts int64 `json:"trusts"` Analyses int64 `json:"analyses"` Certificates int64 `json:"certificates"` PendingScans int64 `json:"pendingScansCount"` Last24HoursScans []HourlyScansCount `json:"last24HoursScansCount"` TargetsLast24Hours int64 `json:"targetsLast24Hours"` DistinctTargetsLast24Hours int64 `json:"distinctTargetsLast24Hours"` DistinctCertsSeenLast24Hours int64 `json:"distinctCertsSeenLast24Hours"` DistinctCertsAddedLast24Hours int64 `json:"distinctCertsAddedLast24Hours"` ScansLast24Hours int64 `json:"scansLast24Hours"` }
Statistics is a set of counters maintained in the database