repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
bitrise-io/bitrise
tools/tools.go
IsBuiltInFlagTypeKey
func IsBuiltInFlagTypeKey(env string) bool { switch string(env) { case configs.IsSecretFilteringKey, configs.CIModeEnvKey, configs.PRModeEnvKey, configs.DebugModeEnvKey, configs.LogLevelEnvKey, configs.PullRequestIDEnvKey: return true default: return false } }
go
func IsBuiltInFlagTypeKey(env string) bool { switch string(env) { case configs.IsSecretFilteringKey, configs.CIModeEnvKey, configs.PRModeEnvKey, configs.DebugModeEnvKey, configs.LogLevelEnvKey, configs.PullRequestIDEnvKey: return true default: return false } }
[ "func", "IsBuiltInFlagTypeKey", "(", "env", "string", ")", "bool", "{", "switch", "string", "(", "env", ")", "{", "case", "configs", ".", "IsSecretFilteringKey", ",", "configs", ".", "CIModeEnvKey", ",", "configs", ".", "PRModeEnvKey", ",", "configs", ".", "...
// IsBuiltInFlagTypeKey returns true if the env key is a built-in flag type env key
[ "IsBuiltInFlagTypeKey", "returns", "true", "if", "the", "env", "key", "is", "a", "built", "-", "in", "flag", "type", "env", "key" ]
2ec917b478fe766c026ba3e78954db0f6b3954d4
https://github.com/bitrise-io/bitrise/blob/2ec917b478fe766c026ba3e78954db0f6b3954d4/tools/tools.go#L432-L444
train
mozilla/tls-observatory
database/certificate.go
UpdateCertificateRank
func (db *DB) UpdateCertificateRank(id, rank int64) error { _, err := db.Exec("UPDATE certificates SET cisco_umbrella_rank=$1 WHERE id=$2", rank, id) return err }
go
func (db *DB) UpdateCertificateRank(id, rank int64) error { _, err := db.Exec("UPDATE certificates SET cisco_umbrella_rank=$1 WHERE id=$2", rank, id) return err }
[ "func", "(", "db", "*", "DB", ")", "UpdateCertificateRank", "(", "id", ",", "rank", "int64", ")", "error", "{", "_", ",", "err", ":=", "db", ".", "Exec", "(", "\"", "\"", ",", "rank", ",", "id", ")", "\n", "return", "err", "\n", "}" ]
// UpdateCertificateRank updates the rank integer of the input certificate.
[ "UpdateCertificateRank", "updates", "the", "rank", "integer", "of", "the", "input", "certificate", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L350-L353
train
mozilla/tls-observatory
database/certificate.go
UpdateCertLastSeen
func (db *DB) UpdateCertLastSeen(cert *certificate.Certificate) error { _, err := db.Exec("UPDATE certificates SET last_seen=$1 WHERE sha1_fingerprint=$2", cert.LastSeenTimestamp, cert.Hashes.SHA1) return err }
go
func (db *DB) UpdateCertLastSeen(cert *certificate.Certificate) error { _, err := db.Exec("UPDATE certificates SET last_seen=$1 WHERE sha1_fingerprint=$2", cert.LastSeenTimestamp, cert.Hashes.SHA1) return err }
[ "func", "(", "db", "*", "DB", ")", "UpdateCertLastSeen", "(", "cert", "*", "certificate", ".", "Certificate", ")", "error", "{", "_", ",", "err", ":=", "db", ".", "Exec", "(", "\"", "\"", ",", "cert", ".", "LastSeenTimestamp", ",", "cert", ".", "Hash...
// UpdateCertLastSeen updates the last_seen timestamp of the input certificate. // Outputs an error if it occurs.
[ "UpdateCertLastSeen", "updates", "the", "last_seen", "timestamp", "of", "the", "input", "certificate", ".", "Outputs", "an", "error", "if", "it", "occurs", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L357-L361
train
mozilla/tls-observatory
database/certificate.go
UpdateCertLastSeenByID
func (db *DB) UpdateCertLastSeenByID(id int64) error { _, err := db.Exec("UPDATE certificates SET last_seen=$1 WHERE id=$2", time.Now(), id) return err }
go
func (db *DB) UpdateCertLastSeenByID(id int64) error { _, err := db.Exec("UPDATE certificates SET last_seen=$1 WHERE id=$2", time.Now(), id) return err }
[ "func", "(", "db", "*", "DB", ")", "UpdateCertLastSeenByID", "(", "id", "int64", ")", "error", "{", "_", ",", "err", ":=", "db", ".", "Exec", "(", "\"", "\"", ",", "time", ".", "Now", "(", ")", ",", "id", ")", "\n", "return", "err", "\n", "}" ]
// UpdateCertLastSeenWithID updates the last_seen timestamp of the certificate with the given id. // Outputs an error if it occurs.
[ "UpdateCertLastSeenWithID", "updates", "the", "last_seen", "timestamp", "of", "the", "certificate", "with", "the", "given", "id", ".", "Outputs", "an", "error", "if", "it", "occurs", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L365-L368
train
mozilla/tls-observatory
database/certificate.go
RemoveCACertFromTruststore
func (db *DB) RemoveCACertFromTruststore(trustedCerts []string, tsName string) error { if len(trustedCerts) == 0 { return errors.New("Cannot work with empty list of trusted certs") } tsVariable := "" switch tsName { case certificate.Ubuntu_TS_name: tsVariable = "in_ubuntu_root_store" case certificate.Mozilla_TS_name: tsVariable = "in_mozilla_root_store" case certificate.Microsoft_TS_name: tsVariable = "in_microsoft_root_store" case certificate.Apple_TS_name: tsVariable = "in_apple_root_store" case certificate.Android_TS_name: tsVariable = "in_android_root_store" default: return errors.New(fmt.Sprintf("Cannot update DB, %s does not represent a valid truststore name.", tsName)) } var fps string for _, fp := range trustedCerts { if len(fps) > 1 { fps += "," } fps += "'" + fp + "'" } q := fmt.Sprintf(`UPDATE certificates SET %s='false', last_seen=NOW() WHERE %s='true' AND sha256_fingerprint NOT IN (%s)`, tsVariable, tsVariable, fps) _, err := db.Exec(q) return err }
go
func (db *DB) RemoveCACertFromTruststore(trustedCerts []string, tsName string) error { if len(trustedCerts) == 0 { return errors.New("Cannot work with empty list of trusted certs") } tsVariable := "" switch tsName { case certificate.Ubuntu_TS_name: tsVariable = "in_ubuntu_root_store" case certificate.Mozilla_TS_name: tsVariable = "in_mozilla_root_store" case certificate.Microsoft_TS_name: tsVariable = "in_microsoft_root_store" case certificate.Apple_TS_name: tsVariable = "in_apple_root_store" case certificate.Android_TS_name: tsVariable = "in_android_root_store" default: return errors.New(fmt.Sprintf("Cannot update DB, %s does not represent a valid truststore name.", tsName)) } var fps string for _, fp := range trustedCerts { if len(fps) > 1 { fps += "," } fps += "'" + fp + "'" } q := fmt.Sprintf(`UPDATE certificates SET %s='false', last_seen=NOW() WHERE %s='true' AND sha256_fingerprint NOT IN (%s)`, tsVariable, tsVariable, fps) _, err := db.Exec(q) return err }
[ "func", "(", "db", "*", "DB", ")", "RemoveCACertFromTruststore", "(", "trustedCerts", "[", "]", "string", ",", "tsName", "string", ")", "error", "{", "if", "len", "(", "trustedCerts", ")", "==", "0", "{", "return", "errors", ".", "New", "(", "\"", "\""...
// 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
[ "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" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L402-L432
train
mozilla/tls-observatory
database/certificate.go
GetCertIDBySHA1Fingerprint
func (db *DB) GetCertIDBySHA1Fingerprint(sha1 string) (id int64, err error) { id = -1 err = db.QueryRow(`SELECT id FROM certificates WHERE sha1_fingerprint=upper($1) ORDER BY id ASC LIMIT 1`, sha1).Scan(&id) if err == sql.ErrNoRows { return -1, nil } return }
go
func (db *DB) GetCertIDBySHA1Fingerprint(sha1 string) (id int64, err error) { id = -1 err = db.QueryRow(`SELECT id FROM certificates WHERE sha1_fingerprint=upper($1) ORDER BY id ASC LIMIT 1`, sha1).Scan(&id) if err == sql.ErrNoRows { return -1, nil } return }
[ "func", "(", "db", "*", "DB", ")", "GetCertIDBySHA1Fingerprint", "(", "sha1", "string", ")", "(", "id", "int64", ",", "err", "error", ")", "{", "id", "=", "-", "1", "\n", "err", "=", "db", ".", "QueryRow", "(", "`SELECT id\n\t\t\t\t FROM certificates\n\t\t...
// 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.
[ "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", ...
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L438-L449
train
mozilla/tls-observatory
database/certificate.go
GetCertIDBySHA256Fingerprint
func (db *DB) GetCertIDBySHA256Fingerprint(sha256 string) (id int64, err error) { id = -1 err = db.QueryRow(`SELECT id FROM certificates WHERE sha256_fingerprint=upper($1) ORDER BY id ASC LIMIT 1`, strings.ToUpper(sha256)).Scan(&id) if err == sql.ErrNoRows { return -1, nil } return }
go
func (db *DB) GetCertIDBySHA256Fingerprint(sha256 string) (id int64, err error) { id = -1 err = db.QueryRow(`SELECT id FROM certificates WHERE sha256_fingerprint=upper($1) ORDER BY id ASC LIMIT 1`, strings.ToUpper(sha256)).Scan(&id) if err == sql.ErrNoRows { return -1, nil } return }
[ "func", "(", "db", "*", "DB", ")", "GetCertIDBySHA256Fingerprint", "(", "sha256", "string", ")", "(", "id", "int64", ",", "err", "error", ")", "{", "id", "=", "-", "1", "\n", "err", "=", "db", ".", "QueryRow", "(", "`SELECT id\n\t\t\t\t FROM certificates\n...
// 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.
[ "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...
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L455-L466
train
mozilla/tls-observatory
database/certificate.go
GetCertIDFromTrust
func (db *DB) GetCertIDFromTrust(trustID int64) (id int64, err error) { id = -1 err = db.QueryRow("SELECT cert_id FROM trust WHERE id=$1", trustID).Scan(&id) if err == sql.ErrNoRows { return -1, nil } return }
go
func (db *DB) GetCertIDFromTrust(trustID int64) (id int64, err error) { id = -1 err = db.QueryRow("SELECT cert_id FROM trust WHERE id=$1", trustID).Scan(&id) if err == sql.ErrNoRows { return -1, nil } return }
[ "func", "(", "db", "*", "DB", ")", "GetCertIDFromTrust", "(", "trustID", "int64", ")", "(", "id", "int64", ",", "err", "error", ")", "{", "id", "=", "-", "1", "\n", "err", "=", "db", ".", "QueryRow", "(", "\"", "\"", ",", "trustID", ")", ".", "...
// 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.
[ "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...
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L472-L479
train
mozilla/tls-observatory
database/certificate.go
GetCertByID
func (db *DB) GetCertByID(certID int64) (*certificate.Certificate, error) { row := db.QueryRow(`SELECT `+strings.Join(allCertificateColumns, ", ")+` FROM certificates WHERE id=$1`, certID) cert, err := db.scanCert(row) return &cert, err }
go
func (db *DB) GetCertByID(certID int64) (*certificate.Certificate, error) { row := db.QueryRow(`SELECT `+strings.Join(allCertificateColumns, ", ")+` FROM certificates WHERE id=$1`, certID) cert, err := db.scanCert(row) return &cert, err }
[ "func", "(", "db", "*", "DB", ")", "GetCertByID", "(", "certID", "int64", ")", "(", "*", "certificate", ".", "Certificate", ",", "error", ")", "{", "row", ":=", "db", ".", "QueryRow", "(", "`SELECT `", "+", "strings", ".", "Join", "(", "allCertificateC...
// GetCertByID fetches a certain certificate from the database. // It returns a pointer to a Certificate struct and any errors that occur.
[ "GetCertByID", "fetches", "a", "certain", "certificate", "from", "the", "database", ".", "It", "returns", "a", "pointer", "to", "a", "Certificate", "struct", "and", "any", "errors", "that", "occur", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L580-L586
train
mozilla/tls-observatory
database/certificate.go
GetEECountForIssuerByID
func (db *DB) GetEECountForIssuerByID(certID int64) (count int64, err error) { count = -1 err = db.QueryRow(` WITH RECURSIVE issued_by(cert_id, issuer_id) AS ( SELECT DISTINCT cert_id, issuer_id FROM trust WHERE issuer_id = $1 AND cert_id != issuer_id UNION ALL SELECT trust.cert_id, trust.issuer_id FROM trust JOIN issued_by ON (trust.issuer_id = issued_by.cert_id) ) SELECT count(id) FROM certificates WHERE id IN ( SELECT DISTINCT cert_id FROM issued_by ) AND is_ca = false AND not_valid_after > NOW() AND not_valid_before < NOW()`, certID).Scan(&count) return }
go
func (db *DB) GetEECountForIssuerByID(certID int64) (count int64, err error) { count = -1 err = db.QueryRow(` WITH RECURSIVE issued_by(cert_id, issuer_id) AS ( SELECT DISTINCT cert_id, issuer_id FROM trust WHERE issuer_id = $1 AND cert_id != issuer_id UNION ALL SELECT trust.cert_id, trust.issuer_id FROM trust JOIN issued_by ON (trust.issuer_id = issued_by.cert_id) ) SELECT count(id) FROM certificates WHERE id IN ( SELECT DISTINCT cert_id FROM issued_by ) AND is_ca = false AND not_valid_after > NOW() AND not_valid_before < NOW()`, certID).Scan(&count) return }
[ "func", "(", "db", "*", "DB", ")", "GetEECountForIssuerByID", "(", "certID", "int64", ")", "(", "count", "int64", ",", "err", "error", ")", "{", "count", "=", "-", "1", "\n", "err", "=", "db", ".", "QueryRow", "(", "`\nWITH RECURSIVE issued_by(cert_id, iss...
// GetEECountForIssuerByID gets the count of valid end entity certificates in the // database that chain to the certificate with the specified ID
[ "GetEECountForIssuerByID", "gets", "the", "count", "of", "valid", "end", "entity", "certificates", "in", "the", "database", "that", "chain", "to", "the", "certificate", "with", "the", "specified", "ID" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L619-L639
train
mozilla/tls-observatory
database/certificate.go
GetCertBySHA1Fingerprint
func (db *DB) GetCertBySHA1Fingerprint(sha1 string) (*certificate.Certificate, error) { var id int64 = -1 cert := &certificate.Certificate{} err := db.QueryRow(`SELECT id FROM certificates WHERE sha1_fingerprint=$1`, sha1).Scan(&id) if err == sql.ErrNoRows { return cert, err } return db.GetCertByID(id) }
go
func (db *DB) GetCertBySHA1Fingerprint(sha1 string) (*certificate.Certificate, error) { var id int64 = -1 cert := &certificate.Certificate{} err := db.QueryRow(`SELECT id FROM certificates WHERE sha1_fingerprint=$1`, sha1).Scan(&id) if err == sql.ErrNoRows { return cert, err } return db.GetCertByID(id) }
[ "func", "(", "db", "*", "DB", ")", "GetCertBySHA1Fingerprint", "(", "sha1", "string", ")", "(", "*", "certificate", ".", "Certificate", ",", "error", ")", "{", "var", "id", "int64", "=", "-", "1", "\n", "cert", ":=", "&", "certificate", ".", "Certifica...
// GetCertBySHA1Fingerprint fetches a certain certificate from the database. // It returns a pointer to a Certificate struct and any errors that occur.
[ "GetCertBySHA1Fingerprint", "fetches", "a", "certain", "certificate", "from", "the", "database", ".", "It", "returns", "a", "pointer", "to", "a", "Certificate", "struct", "and", "any", "errors", "that", "occur", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L643-L651
train
mozilla/tls-observatory
database/certificate.go
GetCACertsBySubject
func (db *DB) GetCACertsBySubject(subject certificate.Subject) (certs []*certificate.Certificate, err error) { // we must remove the ID before looking for the cert in database subject.ID = 0 subjectJson, err := json.Marshal(subject) if err != nil { return } rows, err := db.Query(`SELECT `+strings.Join(allCertificateColumns, ", ")+` FROM certificates WHERE is_ca='true' AND subject=$1`, subjectJson) if rows != nil { defer rows.Close() } if err == sql.ErrNoRows { return } if err != nil && err != sql.ErrNoRows { err = fmt.Errorf("Error while getting certificates by subject: '%v'", err) return } for rows.Next() { var ( cert certificate.Certificate ) cert, err = db.scanCert(rows) if err != nil { return } certs = append(certs, &cert) } if err := rows.Err(); err != nil { err = fmt.Errorf("Failed to complete database query: '%v'", err) } return }
go
func (db *DB) GetCACertsBySubject(subject certificate.Subject) (certs []*certificate.Certificate, err error) { // we must remove the ID before looking for the cert in database subject.ID = 0 subjectJson, err := json.Marshal(subject) if err != nil { return } rows, err := db.Query(`SELECT `+strings.Join(allCertificateColumns, ", ")+` FROM certificates WHERE is_ca='true' AND subject=$1`, subjectJson) if rows != nil { defer rows.Close() } if err == sql.ErrNoRows { return } if err != nil && err != sql.ErrNoRows { err = fmt.Errorf("Error while getting certificates by subject: '%v'", err) return } for rows.Next() { var ( cert certificate.Certificate ) cert, err = db.scanCert(rows) if err != nil { return } certs = append(certs, &cert) } if err := rows.Err(); err != nil { err = fmt.Errorf("Failed to complete database query: '%v'", err) } return }
[ "func", "(", "db", "*", "DB", ")", "GetCACertsBySubject", "(", "subject", "certificate", ".", "Subject", ")", "(", "certs", "[", "]", "*", "certificate", ".", "Certificate", ",", "err", "error", ")", "{", "// we must remove the ID before looking for the cert in da...
// GetCACertsBySubject returns a list of CA certificates that match a given subject
[ "GetCACertsBySubject", "returns", "a", "list", "of", "CA", "certificates", "that", "match", "a", "given", "subject" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L654-L687
train
mozilla/tls-observatory
database/certificate.go
GetCertPaths
func (db *DB) GetCertPaths(cert *certificate.Certificate) (paths certificate.Paths, err error) { // check if we have a path in the cache if paths, ok := db.paths.Get(cert.Issuer.String()); ok { // the end-entity in the cache is likely another cert, so replace // it with the current one newpaths := paths.(certificate.Paths) newpaths.Cert = cert return newpaths, nil } // nothing in the cache, go to the database, recursively var ancestors []string paths, err = db.getCertPaths(cert, ancestors) if err != nil { return } // add the path into the cache db.paths.Add(cert.Issuer.String(), paths) return }
go
func (db *DB) GetCertPaths(cert *certificate.Certificate) (paths certificate.Paths, err error) { // check if we have a path in the cache if paths, ok := db.paths.Get(cert.Issuer.String()); ok { // the end-entity in the cache is likely another cert, so replace // it with the current one newpaths := paths.(certificate.Paths) newpaths.Cert = cert return newpaths, nil } // nothing in the cache, go to the database, recursively var ancestors []string paths, err = db.getCertPaths(cert, ancestors) if err != nil { return } // add the path into the cache db.paths.Add(cert.Issuer.String(), paths) return }
[ "func", "(", "db", "*", "DB", ")", "GetCertPaths", "(", "cert", "*", "certificate", ".", "Certificate", ")", "(", "paths", "certificate", ".", "Paths", ",", "err", "error", ")", "{", "// check if we have a path in the cache", "if", "paths", ",", "ok", ":=", ...
// 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.
[ "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", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L819-L837
train
mozilla/tls-observatory
database/certificate.go
IsTrustValid
func (db *DB) IsTrustValid(id int64) (bool, error) { row := db.QueryRow(`SELECT trusted_ubuntu OR trusted_mozilla OR trusted_microsoft OR trusted_apple OR trusted_android FROM trust WHERE id=$1`, id) isValid := false err := row.Scan(&isValid) return isValid, err }
go
func (db *DB) IsTrustValid(id int64) (bool, error) { row := db.QueryRow(`SELECT trusted_ubuntu OR trusted_mozilla OR trusted_microsoft OR trusted_apple OR trusted_android FROM trust WHERE id=$1`, id) isValid := false err := row.Scan(&isValid) return isValid, err }
[ "func", "(", "db", "*", "DB", ")", "IsTrustValid", "(", "id", "int64", ")", "(", "bool", ",", "error", ")", "{", "row", ":=", "db", ".", "QueryRow", "(", "`SELECT trusted_ubuntu OR\n\t\t\t\t trusted_mozilla OR\n\t\t\t\t trusted_microsoft OR\n\t\t\t\t trusted_apple...
// 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.
[ "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", ...
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/certificate.go#L896-L906
train
mozilla/tls-observatory
worker/symantecDistrust/symantecDistrust.go
evalPaths
func evalPaths(paths certificate.Paths) (distrust bool, reasons []string) { // assume distrust and change that if we find a trusted path distrust = true x509Cert, _ := paths.Cert.ToX509() spkihash := certificate.SPKISHA256(x509Cert) if evalBlacklist(spkihash) { reason := fmt.Sprintf("path uses a blacklisted cert: %s (id=%d)", paths.Cert.Subject.String(), paths.Cert.ID) if !alreadyPresent(reason, reasons) { reasons = append(reasons, reason) } return } if len(paths.Parents) == 0 { // if is not directly distrusted and doesn't have any parent, set distrust to false distrust = false return } for _, parent := range paths.Parents { theirDistrust, theirReasons := evalPaths(parent) for _, theirReason := range theirReasons { if !alreadyPresent(theirReason, reasons) { reasons = append(reasons, theirReason) } } if theirDistrust { // if the parent is distrusted, check if the current cert is whitelisted, // and if so, override the distrust decision if evalWhitelist(spkihash) { distrust = false reason := fmt.Sprintf("whitelisted intermediate %s (id=%d) override blacklisting of %d", paths.Cert.Subject.String(), paths.Cert.ID, parent.Cert.ID) if !alreadyPresent(reason, reasons) { reasons = append(reasons, reason) } } } else { // when the parent is a root that is not blacklisted, but it isn't trusted by mozilla, // then flag the chain as distrusted anyway if parent.Cert.CA && len(parent.Parents) == 0 && !parent.Cert.ValidationInfo["Mozilla"].IsValid { reason := fmt.Sprintf("path uses a root not trusted by Mozilla: %s (id=%d)", parent.Cert.Subject.String(), parent.Cert.ID) if !alreadyPresent(reason, reasons) { reasons = append(reasons, reason) } } else { distrust = false } } } return }
go
func evalPaths(paths certificate.Paths) (distrust bool, reasons []string) { // assume distrust and change that if we find a trusted path distrust = true x509Cert, _ := paths.Cert.ToX509() spkihash := certificate.SPKISHA256(x509Cert) if evalBlacklist(spkihash) { reason := fmt.Sprintf("path uses a blacklisted cert: %s (id=%d)", paths.Cert.Subject.String(), paths.Cert.ID) if !alreadyPresent(reason, reasons) { reasons = append(reasons, reason) } return } if len(paths.Parents) == 0 { // if is not directly distrusted and doesn't have any parent, set distrust to false distrust = false return } for _, parent := range paths.Parents { theirDistrust, theirReasons := evalPaths(parent) for _, theirReason := range theirReasons { if !alreadyPresent(theirReason, reasons) { reasons = append(reasons, theirReason) } } if theirDistrust { // if the parent is distrusted, check if the current cert is whitelisted, // and if so, override the distrust decision if evalWhitelist(spkihash) { distrust = false reason := fmt.Sprintf("whitelisted intermediate %s (id=%d) override blacklisting of %d", paths.Cert.Subject.String(), paths.Cert.ID, parent.Cert.ID) if !alreadyPresent(reason, reasons) { reasons = append(reasons, reason) } } } else { // when the parent is a root that is not blacklisted, but it isn't trusted by mozilla, // then flag the chain as distrusted anyway if parent.Cert.CA && len(parent.Parents) == 0 && !parent.Cert.ValidationInfo["Mozilla"].IsValid { reason := fmt.Sprintf("path uses a root not trusted by Mozilla: %s (id=%d)", parent.Cert.Subject.String(), parent.Cert.ID) if !alreadyPresent(reason, reasons) { reasons = append(reasons, reason) } } else { distrust = false } } } return }
[ "func", "evalPaths", "(", "paths", "certificate", ".", "Paths", ")", "(", "distrust", "bool", ",", "reasons", "[", "]", "string", ")", "{", "// assume distrust and change that if we find a trusted path", "distrust", "=", "true", "\n", "x509Cert", ",", "_", ":=", ...
// evalPaths recursively processes certificate paths and checks each entity // against the list of blacklisted symantec certs
[ "evalPaths", "recursively", "processes", "certificate", "paths", "and", "checks", "each", "entity", "against", "the", "list", "of", "blacklisted", "symantec", "certs" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/symantecDistrust/symantecDistrust.go#L215-L265
train
mozilla/tls-observatory
worker/symantecDistrust/symantecDistrust.go
evalBlacklist
func evalBlacklist(spkihash string) bool { for _, blacklisted := range blacklist { if strings.ToUpper(spkihash) == strings.ToUpper(blacklisted) { return true } } return false }
go
func evalBlacklist(spkihash string) bool { for _, blacklisted := range blacklist { if strings.ToUpper(spkihash) == strings.ToUpper(blacklisted) { return true } } return false }
[ "func", "evalBlacklist", "(", "spkihash", "string", ")", "bool", "{", "for", "_", ",", "blacklisted", ":=", "range", "blacklist", "{", "if", "strings", ".", "ToUpper", "(", "spkihash", ")", "==", "strings", ".", "ToUpper", "(", "blacklisted", ")", "{", "...
// check if the SPKI hash of a cert is blacklisted
[ "check", "if", "the", "SPKI", "hash", "of", "a", "cert", "is", "blacklisted" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/symantecDistrust/symantecDistrust.go#L268-L275
train
mozilla/tls-observatory
worker/symantecDistrust/symantecDistrust.go
evalWhitelist
func evalWhitelist(spkihash string) bool { for _, whitelisted := range whitelist { if strings.ToUpper(spkihash) == strings.ToUpper(whitelisted) { return true } } return false }
go
func evalWhitelist(spkihash string) bool { for _, whitelisted := range whitelist { if strings.ToUpper(spkihash) == strings.ToUpper(whitelisted) { return true } } return false }
[ "func", "evalWhitelist", "(", "spkihash", "string", ")", "bool", "{", "for", "_", ",", "whitelisted", ":=", "range", "whitelist", "{", "if", "strings", ".", "ToUpper", "(", "spkihash", ")", "==", "strings", ".", "ToUpper", "(", "whitelisted", ")", "{", "...
// check if the SPKI hash of a cert matches the ones in the whitelist. // here we use the spki because CAs might create more certs from those whitelisted keys
[ "check", "if", "the", "SPKI", "hash", "of", "a", "cert", "matches", "the", "ones", "in", "the", "whitelist", ".", "here", "we", "use", "the", "spki", "because", "CAs", "might", "create", "more", "certs", "from", "those", "whitelisted", "keys" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/symantecDistrust/symantecDistrust.go#L279-L286
train
mozilla/tls-observatory
worker/mozillaGradingWorker/keyexchangeGrading.go
gradeKeyX
func gradeKeyX(connInfo connection.Stored) (categoryResults, error) { res := categoryResults{} best := float64(0) worst := float64(15360) for _, cs := range connInfo.CipherSuite { pubkeylength := getBitsForPubKey(cs) bits := pubkeylength // if we do not have a Kx algorithm the public key length is enough if cs.PFS != "None" { kxlength := getBitsForKeyExchange(cs.PFS) bits = math.Min(pubkeylength, kxlength) } if bits < worst { worst = bits } if bits > best { best = bits } } res.Grade = getKxScoreFromBits((best + worst) / 2) return res, nil }
go
func gradeKeyX(connInfo connection.Stored) (categoryResults, error) { res := categoryResults{} best := float64(0) worst := float64(15360) for _, cs := range connInfo.CipherSuite { pubkeylength := getBitsForPubKey(cs) bits := pubkeylength // if we do not have a Kx algorithm the public key length is enough if cs.PFS != "None" { kxlength := getBitsForKeyExchange(cs.PFS) bits = math.Min(pubkeylength, kxlength) } if bits < worst { worst = bits } if bits > best { best = bits } } res.Grade = getKxScoreFromBits((best + worst) / 2) return res, nil }
[ "func", "gradeKeyX", "(", "connInfo", "connection", ".", "Stored", ")", "(", "categoryResults", ",", "error", ")", "{", "res", ":=", "categoryResults", "{", "}", "\n\n", "best", ":=", "float64", "(", "0", ")", "\n", "worst", ":=", "float64", "(", "15360"...
//gradeKeyX uses the simple SSLLabs method to grade the key Exchange characteristics //of the connection
[ "gradeKeyX", "uses", "the", "simple", "SSLLabs", "method", "to", "grade", "the", "key", "Exchange", "characteristics", "of", "the", "connection" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/mozillaGradingWorker/keyexchangeGrading.go#L24-L53
train
mozilla/tls-observatory
certificate/certificate.go
GetBooleanValidity
func (c Certificate) GetBooleanValidity() (trusted_ubuntu, trusted_mozilla, trusted_microsoft, trusted_apple, trusted_android bool) { //check Ubuntu validation info valInfo, ok := c.ValidationInfo[Ubuntu_TS_name] if !ok { trusted_ubuntu = false } else { trusted_ubuntu = valInfo.IsValid } //check Mozilla validation info valInfo, ok = c.ValidationInfo[Mozilla_TS_name] if !ok { trusted_mozilla = false } else { trusted_mozilla = valInfo.IsValid } //check Microsoft validation info valInfo, ok = c.ValidationInfo[Microsoft_TS_name] if !ok { trusted_microsoft = false } else { trusted_microsoft = valInfo.IsValid } //check Apple validation info valInfo, ok = c.ValidationInfo[Apple_TS_name] if !ok { trusted_apple = false } else { trusted_apple = valInfo.IsValid } //check Android validation info valInfo, ok = c.ValidationInfo[Android_TS_name] if !ok { trusted_android = false } else { trusted_android = valInfo.IsValid } return }
go
func (c Certificate) GetBooleanValidity() (trusted_ubuntu, trusted_mozilla, trusted_microsoft, trusted_apple, trusted_android bool) { //check Ubuntu validation info valInfo, ok := c.ValidationInfo[Ubuntu_TS_name] if !ok { trusted_ubuntu = false } else { trusted_ubuntu = valInfo.IsValid } //check Mozilla validation info valInfo, ok = c.ValidationInfo[Mozilla_TS_name] if !ok { trusted_mozilla = false } else { trusted_mozilla = valInfo.IsValid } //check Microsoft validation info valInfo, ok = c.ValidationInfo[Microsoft_TS_name] if !ok { trusted_microsoft = false } else { trusted_microsoft = valInfo.IsValid } //check Apple validation info valInfo, ok = c.ValidationInfo[Apple_TS_name] if !ok { trusted_apple = false } else { trusted_apple = valInfo.IsValid } //check Android validation info valInfo, ok = c.ValidationInfo[Android_TS_name] if !ok { trusted_android = false } else { trusted_android = valInfo.IsValid } return }
[ "func", "(", "c", "Certificate", ")", "GetBooleanValidity", "(", ")", "(", "trusted_ubuntu", ",", "trusted_mozilla", ",", "trusted_microsoft", ",", "trusted_apple", ",", "trusted_android", "bool", ")", "{", "//check Ubuntu validation info", "valInfo", ",", "ok", ":=...
//GetBooleanValidity converts the validation info map to DB booleans
[ "GetBooleanValidity", "converts", "the", "validation", "info", "map", "to", "DB", "booleans" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/certificate/certificate.go#L256-L303
train
mozilla/tls-observatory
certificate/certificate.go
GetValidityMap
func GetValidityMap(trusted_ubuntu, trusted_mozilla, trusted_microsoft, trusted_apple, trusted_android bool) map[string]ValidationInfo { vUbuntu := ValidationInfo{IsValid: trusted_ubuntu} vMozilla := ValidationInfo{IsValid: trusted_mozilla} vMicrosoft := ValidationInfo{IsValid: trusted_microsoft} vApple := ValidationInfo{IsValid: trusted_apple} vAndroid := ValidationInfo{IsValid: trusted_android} m := make(map[string]ValidationInfo) m[Ubuntu_TS_name] = vUbuntu m[Mozilla_TS_name] = vMozilla m[Microsoft_TS_name] = vMicrosoft m[Apple_TS_name] = vApple m[Android_TS_name] = vAndroid return m }
go
func GetValidityMap(trusted_ubuntu, trusted_mozilla, trusted_microsoft, trusted_apple, trusted_android bool) map[string]ValidationInfo { vUbuntu := ValidationInfo{IsValid: trusted_ubuntu} vMozilla := ValidationInfo{IsValid: trusted_mozilla} vMicrosoft := ValidationInfo{IsValid: trusted_microsoft} vApple := ValidationInfo{IsValid: trusted_apple} vAndroid := ValidationInfo{IsValid: trusted_android} m := make(map[string]ValidationInfo) m[Ubuntu_TS_name] = vUbuntu m[Mozilla_TS_name] = vMozilla m[Microsoft_TS_name] = vMicrosoft m[Apple_TS_name] = vApple m[Android_TS_name] = vAndroid return m }
[ "func", "GetValidityMap", "(", "trusted_ubuntu", ",", "trusted_mozilla", ",", "trusted_microsoft", ",", "trusted_apple", ",", "trusted_android", "bool", ")", "map", "[", "string", "]", "ValidationInfo", "{", "vUbuntu", ":=", "ValidationInfo", "{", "IsValid", ":", ...
// GetValidityMap converts boolean validity variables to a validity map.
[ "GetValidityMap", "converts", "boolean", "validity", "variables", "to", "a", "validity", "map", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/certificate/certificate.go#L306-L324
train
mozilla/tls-observatory
certificate/certificate.go
CertToStored
func CertToStored(cert *x509.Certificate, parentSignature, domain, ip string, TSName string, valInfo *ValidationInfo) Certificate { var ( err error stored = Certificate{} ) // initialize []string to never store them as null stored.ParentSignature = make([]string, 0) stored.IPs = make([]string, 0) stored.Version = cert.Version // If there's an error, we just store the zero value ("") serial, _ := GetHexASN1Serial(cert) stored.Serial = serial stored.SignatureAlgorithm = SignatureAlgorithm[cert.SignatureAlgorithm] stored.Key, err = getPublicKeyInfo(cert) if err != nil { log.Printf("Failed to retrieve public key information: %v. Continuing anyway.", err) } stored.Issuer.Country = cert.Issuer.Country stored.Issuer.Organisation = cert.Issuer.Organization stored.Issuer.OrgUnit = cert.Issuer.OrganizationalUnit stored.Issuer.CommonName = cert.Issuer.CommonName stored.Subject.Country = cert.Subject.Country stored.Subject.Organisation = cert.Subject.Organization stored.Subject.OrgUnit = cert.Subject.OrganizationalUnit stored.Subject.CommonName = cert.Subject.CommonName stored.Validity.NotBefore = cert.NotBefore.UTC() stored.Validity.NotAfter = cert.NotAfter.UTC() stored.X509v3Extensions = getCertExtensions(cert) stored.MozillaPolicyV2_5 = getMozillaPolicyV2_5(cert) //below check tries to hack around the basic constraints extension //not being available in versions < 3. //Only the IsCa variable is set, as setting X509v3BasicConstraints //messes up the validation procedure. if cert.Version < 3 { stored.CA = cert.IsCA } else { if cert.BasicConstraintsValid { stored.X509v3BasicConstraints = "Critical" stored.CA = cert.IsCA } else { stored.X509v3BasicConstraints = "" stored.CA = false } } t := time.Now().UTC() stored.FirstSeenTimestamp = t stored.LastSeenTimestamp = t stored.ParentSignature = append(stored.ParentSignature, parentSignature) if !cert.IsCA { stored.ScanTarget = domain stored.IPs = append(stored.IPs, ip) } stored.ValidationInfo = make(map[string]ValidationInfo) stored.ValidationInfo[TSName] = *valInfo stored.Hashes.MD5 = MD5Hash(cert.Raw) stored.Hashes.SHA1 = SHA1Hash(cert.Raw) stored.Hashes.SHA256 = SHA256Hash(cert.Raw) stored.Hashes.SPKISHA256 = SPKISHA256(cert) stored.Hashes.SubjectSPKISHA256 = SubjectSPKISHA256(cert) stored.Hashes.PKPSHA256 = PKPSHA256Hash(cert) stored.Raw = base64.StdEncoding.EncodeToString(cert.Raw) stored.CiscoUmbrellaRank = Default_Cisco_Umbrella_Rank return stored }
go
func CertToStored(cert *x509.Certificate, parentSignature, domain, ip string, TSName string, valInfo *ValidationInfo) Certificate { var ( err error stored = Certificate{} ) // initialize []string to never store them as null stored.ParentSignature = make([]string, 0) stored.IPs = make([]string, 0) stored.Version = cert.Version // If there's an error, we just store the zero value ("") serial, _ := GetHexASN1Serial(cert) stored.Serial = serial stored.SignatureAlgorithm = SignatureAlgorithm[cert.SignatureAlgorithm] stored.Key, err = getPublicKeyInfo(cert) if err != nil { log.Printf("Failed to retrieve public key information: %v. Continuing anyway.", err) } stored.Issuer.Country = cert.Issuer.Country stored.Issuer.Organisation = cert.Issuer.Organization stored.Issuer.OrgUnit = cert.Issuer.OrganizationalUnit stored.Issuer.CommonName = cert.Issuer.CommonName stored.Subject.Country = cert.Subject.Country stored.Subject.Organisation = cert.Subject.Organization stored.Subject.OrgUnit = cert.Subject.OrganizationalUnit stored.Subject.CommonName = cert.Subject.CommonName stored.Validity.NotBefore = cert.NotBefore.UTC() stored.Validity.NotAfter = cert.NotAfter.UTC() stored.X509v3Extensions = getCertExtensions(cert) stored.MozillaPolicyV2_5 = getMozillaPolicyV2_5(cert) //below check tries to hack around the basic constraints extension //not being available in versions < 3. //Only the IsCa variable is set, as setting X509v3BasicConstraints //messes up the validation procedure. if cert.Version < 3 { stored.CA = cert.IsCA } else { if cert.BasicConstraintsValid { stored.X509v3BasicConstraints = "Critical" stored.CA = cert.IsCA } else { stored.X509v3BasicConstraints = "" stored.CA = false } } t := time.Now().UTC() stored.FirstSeenTimestamp = t stored.LastSeenTimestamp = t stored.ParentSignature = append(stored.ParentSignature, parentSignature) if !cert.IsCA { stored.ScanTarget = domain stored.IPs = append(stored.IPs, ip) } stored.ValidationInfo = make(map[string]ValidationInfo) stored.ValidationInfo[TSName] = *valInfo stored.Hashes.MD5 = MD5Hash(cert.Raw) stored.Hashes.SHA1 = SHA1Hash(cert.Raw) stored.Hashes.SHA256 = SHA256Hash(cert.Raw) stored.Hashes.SPKISHA256 = SPKISHA256(cert) stored.Hashes.SubjectSPKISHA256 = SubjectSPKISHA256(cert) stored.Hashes.PKPSHA256 = PKPSHA256Hash(cert) stored.Raw = base64.StdEncoding.EncodeToString(cert.Raw) stored.CiscoUmbrellaRank = Default_Cisco_Umbrella_Rank return stored }
[ "func", "CertToStored", "(", "cert", "*", "x509", ".", "Certificate", ",", "parentSignature", ",", "domain", ",", "ip", "string", ",", "TSName", "string", ",", "valInfo", "*", "ValidationInfo", ")", "Certificate", "{", "var", "(", "err", "error", "\n", "st...
//certtoStored returns a Certificate struct created from a X509.Certificate
[ "certtoStored", "returns", "a", "Certificate", "struct", "created", "from", "a", "X509", ".", "Certificate" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/certificate/certificate.go#L509-L590
train
mozilla/tls-observatory
certificate/certificate.go
printRawCertExtensions
func printRawCertExtensions(cert *x509.Certificate) { for i, extension := range cert.Extensions { var numbers string for num, num2 := range extension.Id { numbers = numbers + " " + "[" + strconv.Itoa(num) + " " + strconv.Itoa(num2) + "]" } fmt.Println("//", strconv.Itoa(i), ": {", numbers, "}", string(extension.Value)) } }
go
func printRawCertExtensions(cert *x509.Certificate) { for i, extension := range cert.Extensions { var numbers string for num, num2 := range extension.Id { numbers = numbers + " " + "[" + strconv.Itoa(num) + " " + strconv.Itoa(num2) + "]" } fmt.Println("//", strconv.Itoa(i), ": {", numbers, "}", string(extension.Value)) } }
[ "func", "printRawCertExtensions", "(", "cert", "*", "x509", ".", "Certificate", ")", "{", "for", "i", ",", "extension", ":=", "range", "cert", ".", "Extensions", "{", "var", "numbers", "string", "\n", "for", "num", ",", "num2", ":=", "range", "extension", ...
//printRawCertExtensions Print raw extension info //for debugging purposes
[ "printRawCertExtensions", "Print", "raw", "extension", "info", "for", "debugging", "purposes" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/certificate/certificate.go#L603-L616
train
mozilla/tls-observatory
certificate/certificate.go
IsSelfSigned
func (c Certificate) IsSelfSigned() bool { if c.Subject.CommonName != c.Issuer.CommonName || len(c.Subject.Organisation) != len(c.Issuer.Organisation) || len(c.Subject.OrgUnit) != len(c.Issuer.OrgUnit) || len(c.Subject.Country) != len(c.Issuer.Country) { return false } for i, _ := range c.Subject.Organisation { if c.Subject.Organisation[i] != c.Issuer.Organisation[i] { return false } } for i, _ := range c.Subject.OrgUnit { if c.Subject.OrgUnit[i] != c.Issuer.OrgUnit[i] { return false } } for i, _ := range c.Subject.Country { if c.Subject.Country[i] != c.Issuer.Country[i] { return false } } return true }
go
func (c Certificate) IsSelfSigned() bool { if c.Subject.CommonName != c.Issuer.CommonName || len(c.Subject.Organisation) != len(c.Issuer.Organisation) || len(c.Subject.OrgUnit) != len(c.Issuer.OrgUnit) || len(c.Subject.Country) != len(c.Issuer.Country) { return false } for i, _ := range c.Subject.Organisation { if c.Subject.Organisation[i] != c.Issuer.Organisation[i] { return false } } for i, _ := range c.Subject.OrgUnit { if c.Subject.OrgUnit[i] != c.Issuer.OrgUnit[i] { return false } } for i, _ := range c.Subject.Country { if c.Subject.Country[i] != c.Issuer.Country[i] { return false } } return true }
[ "func", "(", "c", "Certificate", ")", "IsSelfSigned", "(", ")", "bool", "{", "if", "c", ".", "Subject", ".", "CommonName", "!=", "c", ".", "Issuer", ".", "CommonName", "||", "len", "(", "c", ".", "Subject", ".", "Organisation", ")", "!=", "len", "(",...
// IsSelfSigned return true if the subject and issuer fields of a certificate // are identical
[ "IsSelfSigned", "return", "true", "if", "the", "subject", "and", "issuer", "fields", "of", "a", "certificate", "are", "identical" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/certificate/certificate.go#L639-L662
train
mozilla/tls-observatory
database/messaging.go
RegisterScanListener
func (db *DB) RegisterScanListener(dbname, user, password, hostport, sslmode string) <-chan int64 { log := logger.GetLogger() reportProblem := func(ev pq.ListenerEventType, err error) { if err != nil { log.WithFields(logrus.Fields{ "error": err.Error(), }).Error("Listener Error") } } listenerChan := make(chan int64) listenerName := "scan_listener" userPass := url.UserPassword(user, password) url := fmt.Sprintf("postgres://%s@%s/%s?sslmode=%s", userPass.String(), hostport, dbname, sslmode) go func() { listener := pq.NewListener(url, 100*time.Millisecond, 10*time.Second, reportProblem) err := listener.Listen(listenerName) if err != nil { log.WithFields(logrus.Fields{ "listener": listenerName, "error": err.Error(), }).Error("could not listen for notification") close(listenerChan) return } for m := range listener.Notify { sid := m.Extra if !db.acquireScan(sid) { // skip this scan if we didn't acquire it continue } // scan was acquired, inform the scanner to launch it id, err := strconv.ParseInt(string(sid), 10, 64) if err != nil { log.WithFields(logrus.Fields{ "scan_id": sid, "error": err.Error(), }).Error("could not decode acquired notification") } listenerChan <- id log.WithFields(logrus.Fields{ "scan_id": id, }).Debug("Acquired notification.") } }() // Launch a goroutine that relaunches scans that have not yet been processed go func() { for { // don't requeue scans more than 3 times _, err := db.Exec(`UPDATE scans SET ack = false, timestamp = NOW() WHERE completion_perc = 0 AND attempts < 3 AND ack = true AND timestamp < NOW() - INTERVAL '10 minute'`) if err != nil { log.WithFields(logrus.Fields{ "error": err, }).Error("Could not run zero completion update query") } _, err = db.Exec(fmt.Sprintf(`SELECT pg_notify('%s', ''||id ) FROM scans WHERE ack=false ORDER BY id ASC LIMIT 1000`, listenerName)) if err != nil { log.WithFields(logrus.Fields{ "error": err, }).Error("Could not run unacknowledged scans periodic check.") } time.Sleep(3 * time.Minute) } }() return listenerChan }
go
func (db *DB) RegisterScanListener(dbname, user, password, hostport, sslmode string) <-chan int64 { log := logger.GetLogger() reportProblem := func(ev pq.ListenerEventType, err error) { if err != nil { log.WithFields(logrus.Fields{ "error": err.Error(), }).Error("Listener Error") } } listenerChan := make(chan int64) listenerName := "scan_listener" userPass := url.UserPassword(user, password) url := fmt.Sprintf("postgres://%s@%s/%s?sslmode=%s", userPass.String(), hostport, dbname, sslmode) go func() { listener := pq.NewListener(url, 100*time.Millisecond, 10*time.Second, reportProblem) err := listener.Listen(listenerName) if err != nil { log.WithFields(logrus.Fields{ "listener": listenerName, "error": err.Error(), }).Error("could not listen for notification") close(listenerChan) return } for m := range listener.Notify { sid := m.Extra if !db.acquireScan(sid) { // skip this scan if we didn't acquire it continue } // scan was acquired, inform the scanner to launch it id, err := strconv.ParseInt(string(sid), 10, 64) if err != nil { log.WithFields(logrus.Fields{ "scan_id": sid, "error": err.Error(), }).Error("could not decode acquired notification") } listenerChan <- id log.WithFields(logrus.Fields{ "scan_id": id, }).Debug("Acquired notification.") } }() // Launch a goroutine that relaunches scans that have not yet been processed go func() { for { // don't requeue scans more than 3 times _, err := db.Exec(`UPDATE scans SET ack = false, timestamp = NOW() WHERE completion_perc = 0 AND attempts < 3 AND ack = true AND timestamp < NOW() - INTERVAL '10 minute'`) if err != nil { log.WithFields(logrus.Fields{ "error": err, }).Error("Could not run zero completion update query") } _, err = db.Exec(fmt.Sprintf(`SELECT pg_notify('%s', ''||id ) FROM scans WHERE ack=false ORDER BY id ASC LIMIT 1000`, listenerName)) if err != nil { log.WithFields(logrus.Fields{ "error": err, }).Error("Could not run unacknowledged scans periodic check.") } time.Sleep(3 * time.Minute) } }() return listenerChan }
[ "func", "(", "db", "*", "DB", ")", "RegisterScanListener", "(", "dbname", ",", "user", ",", "password", ",", "hostport", ",", "sslmode", "string", ")", "<-", "chan", "int64", "{", "log", ":=", "logger", ".", "GetLogger", "(", ")", "\n\n", "reportProblem"...
// 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.
[ "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", "con...
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/messaging.go#L18-L98
train
mozilla/tls-observatory
database/messaging.go
acquireScan
func (db *DB) acquireScan(id string) bool { tx, err := db.Begin() if err != nil { return false } // `ack` is a mutex in the database that each scanner will try to select // for update. if a scanner succeeds, it will return true, otherwise it // will return false. row := tx.QueryRow("SELECT ack FROM scans WHERE id=$1 FOR UPDATE", id) ack := false err = row.Scan(&ack) if err != nil { tx.Rollback() return false } if ack { // if ack was true in db, that means another job already acked this // scan so we drop the lock and return false tx.Rollback() return false } // otherwise, ack is false and we acquire it to run the scan // if anything fails along the way, we drop the lock by rolling back _, err = tx.Exec("UPDATE scans SET ack=true WHERE id=$1", id) if err != nil { tx.Rollback() return false } err = tx.Commit() if err != nil { tx.Rollback() return false } return true }
go
func (db *DB) acquireScan(id string) bool { tx, err := db.Begin() if err != nil { return false } // `ack` is a mutex in the database that each scanner will try to select // for update. if a scanner succeeds, it will return true, otherwise it // will return false. row := tx.QueryRow("SELECT ack FROM scans WHERE id=$1 FOR UPDATE", id) ack := false err = row.Scan(&ack) if err != nil { tx.Rollback() return false } if ack { // if ack was true in db, that means another job already acked this // scan so we drop the lock and return false tx.Rollback() return false } // otherwise, ack is false and we acquire it to run the scan // if anything fails along the way, we drop the lock by rolling back _, err = tx.Exec("UPDATE scans SET ack=true WHERE id=$1", id) if err != nil { tx.Rollback() return false } err = tx.Commit() if err != nil { tx.Rollback() return false } return true }
[ "func", "(", "db", "*", "DB", ")", "acquireScan", "(", "id", "string", ")", "bool", "{", "tx", ",", "err", ":=", "db", ".", "Begin", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "// `ack` is a mutex in the databa...
// acquireScan provides a way to limit to one the number of scanners // evaluating a given target, but setting a `ack` boolean to true when a // scanner picks up a scan
[ "acquireScan", "provides", "a", "way", "to", "limit", "to", "one", "the", "number", "of", "scanners", "evaluating", "a", "given", "target", "but", "setting", "a", "ack", "boolean", "to", "true", "when", "a", "scanner", "picks", "up", "a", "scan" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/messaging.go#L103-L137
train
mozilla/tls-observatory
database/stats.go
CountTableEntries
func (db *DB) CountTableEntries() (scans, trusts, analyses, certificates int64, err error) { err = db.QueryRow(`SELECT reltuples::INTEGER FROM pg_class WHERE relname='scans'`).Scan(&scans) if err != nil { return } err = db.QueryRow(`SELECT reltuples::INTEGER FROM pg_class WHERE relname='trust'`).Scan(&trusts) if err != nil { return } err = db.QueryRow(`SELECT reltuples::INTEGER FROM pg_class WHERE relname='analysis'`).Scan(&analyses) if err != nil { return } err = db.QueryRow(`SELECT reltuples::INTEGER FROM pg_class WHERE relname='certificates'`).Scan(&certificates) if err != nil { return } return }
go
func (db *DB) CountTableEntries() (scans, trusts, analyses, certificates int64, err error) { err = db.QueryRow(`SELECT reltuples::INTEGER FROM pg_class WHERE relname='scans'`).Scan(&scans) if err != nil { return } err = db.QueryRow(`SELECT reltuples::INTEGER FROM pg_class WHERE relname='trust'`).Scan(&trusts) if err != nil { return } err = db.QueryRow(`SELECT reltuples::INTEGER FROM pg_class WHERE relname='analysis'`).Scan(&analyses) if err != nil { return } err = db.QueryRow(`SELECT reltuples::INTEGER FROM pg_class WHERE relname='certificates'`).Scan(&certificates) if err != nil { return } return }
[ "func", "(", "db", "*", "DB", ")", "CountTableEntries", "(", ")", "(", "scans", ",", "trusts", ",", "analyses", ",", "certificates", "int64", ",", "err", "error", ")", "{", "err", "=", "db", ".", "QueryRow", "(", "`SELECT reltuples::INTEGER FROM pg_class WHE...
// 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.
[ "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", "guarantee...
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/stats.go#L43-L61
train
mozilla/tls-observatory
database/stats.go
CountPendingScans
func (db *DB) CountPendingScans() (count int64, err error) { err = db.QueryRow(`SELECT COUNT(*) FROM scans WHERE completion_perc = 0 AND attempts < 3 AND ack = false`).Scan(&count) return }
go
func (db *DB) CountPendingScans() (count int64, err error) { err = db.QueryRow(`SELECT COUNT(*) FROM scans WHERE completion_perc = 0 AND attempts < 3 AND ack = false`).Scan(&count) return }
[ "func", "(", "db", "*", "DB", ")", "CountPendingScans", "(", ")", "(", "count", "int64", ",", "err", "error", ")", "{", "err", "=", "db", ".", "QueryRow", "(", "`SELECT COUNT(*) FROM scans\n\t\t\t\t WHERE completion_perc = 0\n\t\t\t\t AND attempts < 3 AND ack = false`...
// CountPendingScans returns the total number of scans that are pending in the queue
[ "CountPendingScans", "returns", "the", "total", "number", "of", "scans", "that", "are", "pending", "in", "the", "queue" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/stats.go#L64-L69
train
mozilla/tls-observatory
database/stats.go
CountLast24HoursScans
func (db *DB) CountLast24HoursScans() (hourlyStats []HourlyScansCount, err error) { rows, err := db.Query(`SELECT DATE_TRUNC('hour', "timestamp") AS hour, COUNT(*) FROM scans WHERE timestamp > NOW() - INTERVAL '24 hours' AND ack=true AND completion_perc=100 GROUP BY DATE_TRUNC('hour', "timestamp") ORDER BY 1 DESC`) if err != nil { return } for rows.Next() { var hsc HourlyScansCount err = rows.Scan(&hsc.Hour, &hsc.Count) if err != nil { return } hourlyStats = append(hourlyStats, hsc) } return }
go
func (db *DB) CountLast24HoursScans() (hourlyStats []HourlyScansCount, err error) { rows, err := db.Query(`SELECT DATE_TRUNC('hour', "timestamp") AS hour, COUNT(*) FROM scans WHERE timestamp > NOW() - INTERVAL '24 hours' AND ack=true AND completion_perc=100 GROUP BY DATE_TRUNC('hour', "timestamp") ORDER BY 1 DESC`) if err != nil { return } for rows.Next() { var hsc HourlyScansCount err = rows.Scan(&hsc.Hour, &hsc.Count) if err != nil { return } hourlyStats = append(hourlyStats, hsc) } return }
[ "func", "(", "db", "*", "DB", ")", "CountLast24HoursScans", "(", ")", "(", "hourlyStats", "[", "]", "HourlyScansCount", ",", "err", "error", ")", "{", "rows", ",", "err", ":=", "db", ".", "Query", "(", "`SELECT DATE_TRUNC('hour', \"timestamp\") AS hour, COUNT(*)...
// CountLast24HoursScans returns a list of hourly scans count for the last 24 hours, sorted // from most recent the oldest
[ "CountLast24HoursScans", "returns", "a", "list", "of", "hourly", "scans", "count", "for", "the", "last", "24", "hours", "sorted", "from", "most", "recent", "the", "oldest" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/stats.go#L79-L96
train
mozilla/tls-observatory
database/stats.go
CountTargetsLast24Hours
func (db *DB) CountTargetsLast24Hours() (count, countDistinct int64, err error) { err = db.QueryRow(`SELECT COUNT(target), COUNT(DISTINCT(target)) FROM scans WHERE timestamp > NOW() - INTERVAL '24 hours' AND ack=true AND completion_perc=100`).Scan(&count, &countDistinct) return }
go
func (db *DB) CountTargetsLast24Hours() (count, countDistinct int64, err error) { err = db.QueryRow(`SELECT COUNT(target), COUNT(DISTINCT(target)) FROM scans WHERE timestamp > NOW() - INTERVAL '24 hours' AND ack=true AND completion_perc=100`).Scan(&count, &countDistinct) return }
[ "func", "(", "db", "*", "DB", ")", "CountTargetsLast24Hours", "(", ")", "(", "count", ",", "countDistinct", "int64", ",", "err", "error", ")", "{", "err", "=", "db", ".", "QueryRow", "(", "`SELECT COUNT(target), COUNT(DISTINCT(target))\n\t\t\t\t FROM scans\n\t\t\t\...
// CountTargetsLast24Hours returns the number of unique targets scanned over the last 24 hours
[ "CountTargetsLast24Hours", "returns", "the", "number", "of", "unique", "targets", "scanned", "over", "the", "last", "24", "hours" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/stats.go#L99-L106
train
mozilla/tls-observatory
tlsobs-scanner/analyser.go
isChainValid
func isChainValid(endEntity *x509.Certificate, intermediates []*x509.Certificate, truststore *certificate.TrustStore, domain, IP string, certmap map[string]certificate.Certificate) bool { valInfo := &certificate.ValidationInfo{ IsValid: true, } // build a CA verification pool from the list of cacerts interPool := x509.NewCertPool() for _, entity := range intermediates { interPool.AddCert(entity) } // get a list of domains this certificate is supposedly valid for // if the end entity is a CA, use its common name dnsName := domain if endEntity.IsCA { dnsName = endEntity.Subject.CommonName } // configure the verification logic to use the current trustore opts := x509.VerifyOptions{ DNSName: dnsName, Intermediates: interPool, Roots: truststore.Certs, } // Verify attempts to build all the path between the end entity and the // root in the truststore that validate the certificate // If no valid path is found, err is not nil and the certificate is not trusted chains, err := endEntity.Verify(opts) if err == nil { // the end entity is trusted, we need to go through each // chain of trust and store them in database for i, chain := range chains { log.WithFields(logrus.Fields{ "trust chain no": i, "path len": len(chain), }).Debug("domain: " + domain) // loop through each certificate in the chain and for _, cert := range chain { parentSignature := "" parentCert := getFirstParent(cert, chain) if parentCert != nil { parentSignature = certificate.SHA256Hash(parentCert.Raw) } else { log.Println("could not retrieve parent for " + dnsName) } updateCert(cert, parentSignature, domain, IP, truststore.Name, valInfo, certmap) } } return true } // the certificate is not trusted. // we store the cert in DB with its validation error if len(chains) > 0 { log.WithFields(logrus.Fields{ "domain": domain, }).Warning("Got validation error but chains are populated") } valInfo.ValidationError = err.Error() valInfo.IsValid = false parentSignature := "" c := getFirstParent(endEntity, intermediates) if c != nil { parentSignature = certificate.SHA256Hash(c.Raw) } else { log.WithFields(logrus.Fields{ "domain": domain, "servercert": certificate.SHA256Hash(endEntity.Raw), }).Info("Could not get parent") } updateCert(endEntity, parentSignature, domain, IP, truststore.Name, valInfo, certmap) return false }
go
func isChainValid(endEntity *x509.Certificate, intermediates []*x509.Certificate, truststore *certificate.TrustStore, domain, IP string, certmap map[string]certificate.Certificate) bool { valInfo := &certificate.ValidationInfo{ IsValid: true, } // build a CA verification pool from the list of cacerts interPool := x509.NewCertPool() for _, entity := range intermediates { interPool.AddCert(entity) } // get a list of domains this certificate is supposedly valid for // if the end entity is a CA, use its common name dnsName := domain if endEntity.IsCA { dnsName = endEntity.Subject.CommonName } // configure the verification logic to use the current trustore opts := x509.VerifyOptions{ DNSName: dnsName, Intermediates: interPool, Roots: truststore.Certs, } // Verify attempts to build all the path between the end entity and the // root in the truststore that validate the certificate // If no valid path is found, err is not nil and the certificate is not trusted chains, err := endEntity.Verify(opts) if err == nil { // the end entity is trusted, we need to go through each // chain of trust and store them in database for i, chain := range chains { log.WithFields(logrus.Fields{ "trust chain no": i, "path len": len(chain), }).Debug("domain: " + domain) // loop through each certificate in the chain and for _, cert := range chain { parentSignature := "" parentCert := getFirstParent(cert, chain) if parentCert != nil { parentSignature = certificate.SHA256Hash(parentCert.Raw) } else { log.Println("could not retrieve parent for " + dnsName) } updateCert(cert, parentSignature, domain, IP, truststore.Name, valInfo, certmap) } } return true } // the certificate is not trusted. // we store the cert in DB with its validation error if len(chains) > 0 { log.WithFields(logrus.Fields{ "domain": domain, }).Warning("Got validation error but chains are populated") } valInfo.ValidationError = err.Error() valInfo.IsValid = false parentSignature := "" c := getFirstParent(endEntity, intermediates) if c != nil { parentSignature = certificate.SHA256Hash(c.Raw) } else { log.WithFields(logrus.Fields{ "domain": domain, "servercert": certificate.SHA256Hash(endEntity.Raw), }).Info("Could not get parent") } updateCert(endEntity, parentSignature, domain, IP, truststore.Name, valInfo, certmap) return false }
[ "func", "isChainValid", "(", "endEntity", "*", "x509", ".", "Certificate", ",", "intermediates", "[", "]", "*", "x509", ".", "Certificate", ",", "truststore", "*", "certificate", ".", "TrustStore", ",", "domain", ",", "IP", "string", ",", "certmap", "map", ...
//isChainValid creates the valid certificate chains by combining the chain retrieved with the provided truststore. //It return true if it finds at least on validation chain or false if no valid chain of trust can be created. //It also updates the certificate map which gets pushed at the end of each iteration.
[ "isChainValid", "creates", "the", "valid", "certificate", "chains", "by", "combining", "the", "chain", "retrieved", "with", "the", "provided", "truststore", ".", "It", "return", "true", "if", "it", "finds", "at", "least", "on", "validation", "chain", "or", "fa...
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/tlsobs-scanner/analyser.go#L283-L363
train
mozilla/tls-observatory
tlsobs-scanner/analyser.go
updateCert
func updateCert(cert *x509.Certificate, parentSignature string, domain, ip, TSName string, valInfo *certificate.ValidationInfo, certmap map[string]certificate.Certificate) { id := certificate.SHA256Hash(cert.Raw) if storedCert, ok := certmap[id]; !ok { certmap[id] = certificate.CertToStored(cert, parentSignature, domain, ip, TSName, valInfo) } else { parentFound := false for _, p := range storedCert.ParentSignature { if parentSignature == p { parentFound = true break } } if !parentFound { storedCert.ParentSignature = append(storedCert.ParentSignature, parentSignature) } if !storedCert.CA { if storedCert.ScanTarget != domain { log.WithFields(logrus.Fields{ "domain": storedCert.ScanTarget, "domain_input": domain, "certificate": storedCert.Hashes.SHA256, }).Warning("Different domain input") } //add IP ( single domain may be served by multiple IPs ) ipFound := false for _, i := range storedCert.IPs { if ip == i { ipFound = true break } } if !ipFound { storedCert.IPs = append(storedCert.IPs, ip) } } storedCert.ValidationInfo[TSName] = *valInfo certmap[id] = storedCert } }
go
func updateCert(cert *x509.Certificate, parentSignature string, domain, ip, TSName string, valInfo *certificate.ValidationInfo, certmap map[string]certificate.Certificate) { id := certificate.SHA256Hash(cert.Raw) if storedCert, ok := certmap[id]; !ok { certmap[id] = certificate.CertToStored(cert, parentSignature, domain, ip, TSName, valInfo) } else { parentFound := false for _, p := range storedCert.ParentSignature { if parentSignature == p { parentFound = true break } } if !parentFound { storedCert.ParentSignature = append(storedCert.ParentSignature, parentSignature) } if !storedCert.CA { if storedCert.ScanTarget != domain { log.WithFields(logrus.Fields{ "domain": storedCert.ScanTarget, "domain_input": domain, "certificate": storedCert.Hashes.SHA256, }).Warning("Different domain input") } //add IP ( single domain may be served by multiple IPs ) ipFound := false for _, i := range storedCert.IPs { if ip == i { ipFound = true break } } if !ipFound { storedCert.IPs = append(storedCert.IPs, ip) } } storedCert.ValidationInfo[TSName] = *valInfo certmap[id] = storedCert } }
[ "func", "updateCert", "(", "cert", "*", "x509", ".", "Certificate", ",", "parentSignature", "string", ",", "domain", ",", "ip", ",", "TSName", "string", ",", "valInfo", "*", "certificate", ".", "ValidationInfo", ",", "certmap", "map", "[", "string", "]", "...
//updateCert takes the input certificate and updates the map holding all the certificates to be pushed. //If the certificates has already been inserted it updates the existing record else it creates it.
[ "updateCert", "takes", "the", "input", "certificate", "and", "updates", "the", "map", "holding", "all", "the", "certificates", "to", "be", "pushed", ".", "If", "the", "certificates", "has", "already", "been", "inserted", "it", "updates", "the", "existing", "re...
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/tlsobs-scanner/analyser.go#L525-L579
train
mozilla/tls-observatory
tlsobs-scanner/retriever.go
handleCert
func handleCert(domain string) (int64, int64, *certificate.Chain, error) { certs, ip, err := retrieveCertFromHost(domain, "443", true) if err != nil { log.WithFields(logrus.Fields{ "domain": domain, "error": err.Error(), }).Warning("Could not retrieve certs") return -1, -1, nil, err } if certs == nil { e := new(NoTLSCertsErr) return -1, -1, nil, e } var chain = certificate.Chain{} chain.Domain = domain chain.IP = ip for _, cert := range certs { chain.Certs = append(chain.Certs, base64.StdEncoding.EncodeToString(cert.Raw)) } rootCertId, trustId, err := handleCertChain(&chain) if err != nil { return -1, -1, nil, err } return rootCertId, trustId, &chain, nil }
go
func handleCert(domain string) (int64, int64, *certificate.Chain, error) { certs, ip, err := retrieveCertFromHost(domain, "443", true) if err != nil { log.WithFields(logrus.Fields{ "domain": domain, "error": err.Error(), }).Warning("Could not retrieve certs") return -1, -1, nil, err } if certs == nil { e := new(NoTLSCertsErr) return -1, -1, nil, e } var chain = certificate.Chain{} chain.Domain = domain chain.IP = ip for _, cert := range certs { chain.Certs = append(chain.Certs, base64.StdEncoding.EncodeToString(cert.Raw)) } rootCertId, trustId, err := handleCertChain(&chain) if err != nil { return -1, -1, nil, err } return rootCertId, trustId, &chain, nil }
[ "func", "handleCert", "(", "domain", "string", ")", "(", "int64", ",", "int64", ",", "*", "certificate", ".", "Chain", ",", "error", ")", "{", "certs", ",", "ip", ",", "err", ":=", "retrieveCertFromHost", "(", "domain", ",", "\"", "\"", ",", "true", ...
//HandleCert is the main function called to verify certificates. //It retrieves certificates and feeds them to handleCertChain. It then returns //its result.
[ "HandleCert", "is", "the", "main", "function", "called", "to", "verify", "certificates", ".", "It", "retrieves", "certificates", "and", "feeds", "them", "to", "handleCertChain", ".", "It", "then", "returns", "its", "result", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/tlsobs-scanner/retriever.go#L27-L61
train
mozilla/tls-observatory
certificate/constraints/constraints.go
Get
func Get(cert *x509.Certificate) (*Constraints, error) { certs, err := x509.ParseCertificates(cert.Raw) if err != nil { return nil, err } if len(certs) != 1 { return nil, fmt.Errorf("cert.Raw must contain exactly one certificate") } constraintCert := certs[0] return &Constraints{ PermittedDNSDomains: constraintCert.PermittedDNSDomains, ExcludedDNSDomains: constraintCert.ExcludedDNSDomains, PermittedIPRanges: constraintCert.PermittedIPRanges, ExcludedIPRanges: constraintCert.ExcludedIPRanges, }, nil }
go
func Get(cert *x509.Certificate) (*Constraints, error) { certs, err := x509.ParseCertificates(cert.Raw) if err != nil { return nil, err } if len(certs) != 1 { return nil, fmt.Errorf("cert.Raw must contain exactly one certificate") } constraintCert := certs[0] return &Constraints{ PermittedDNSDomains: constraintCert.PermittedDNSDomains, ExcludedDNSDomains: constraintCert.ExcludedDNSDomains, PermittedIPRanges: constraintCert.PermittedIPRanges, ExcludedIPRanges: constraintCert.ExcludedIPRanges, }, nil }
[ "func", "Get", "(", "cert", "*", "x509", ".", "Certificate", ")", "(", "*", "Constraints", ",", "error", ")", "{", "certs", ",", "err", ":=", "x509", ".", "ParseCertificates", "(", "cert", ".", "Raw", ")", "\n", "if", "err", "!=", "nil", "{", "retu...
// Get returns the Constraints for a given x509 certificate
[ "Get", "returns", "the", "Constraints", "for", "a", "given", "x509", "certificate" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/certificate/constraints/constraints.go#L19-L35
train
mozilla/tls-observatory
worker/mozillaEvaluationWorker/mozillaEvaluationWorker.go
getConffromURL
func getConffromURL(url string) error { r, err := http.Get(url) if err != nil { return err } defer r.Body.Close() err = json.NewDecoder(r.Body).Decode(&sstls) if err != nil { return err } return nil }
go
func getConffromURL(url string) error { r, err := http.Get(url) if err != nil { return err } defer r.Body.Close() err = json.NewDecoder(r.Body).Decode(&sstls) if err != nil { return err } return nil }
[ "func", "getConffromURL", "(", "url", "string", ")", "error", "{", "r", ",", "err", ":=", "http", ".", "Get", "(", "url", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "r", ".", "Body", ".", "Close", "(", ...
// getConffromURL retrieves the json containing the TLS configurations from the specified URL.
[ "getConffromURL", "retrieves", "the", "json", "containing", "the", "TLS", "configurations", "from", "the", "specified", "URL", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/mozillaEvaluationWorker/mozillaEvaluationWorker.go#L65-L79
train
mozilla/tls-observatory
worker/mozillaEvaluationWorker/mozillaEvaluationWorker.go
contains
func contains(slice []string, entry string) bool { for _, element := range slice { if element == entry { return true } } return false }
go
func contains(slice []string, entry string) bool { for _, element := range slice { if element == entry { return true } } return false }
[ "func", "contains", "(", "slice", "[", "]", "string", ",", "entry", "string", ")", "bool", "{", "for", "_", ",", "element", ":=", "range", "slice", "{", "if", "element", "==", "entry", "{", "return", "true", "\n", "}", "\n", "}", "\n", "return", "f...
// contains checks if an entry exists in a slice and returns // a booleans.
[ "contains", "checks", "if", "an", "entry", "exists", "in", "a", "slice", "and", "returns", "a", "booleans", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/mozillaEvaluationWorker/mozillaEvaluationWorker.go#L664-L671
train
mozilla/tls-observatory
worker/mozillaEvaluationWorker/mozillaEvaluationWorker.go
extra
func extra(s1, s2 []string) (extra []string) { for _, e := range s2 { // FIXME: https://github.com/mozilla/tls-observatory/issues/186 if e == "ECDHE-ECDSA-CHACHA20-POLY1305-OLD" || e == "ECDHE-RSA-CHACHA20-POLY1305-OLD" { continue } if !contains(s1, e) { extra = append(extra, e) } } return }
go
func extra(s1, s2 []string) (extra []string) { for _, e := range s2 { // FIXME: https://github.com/mozilla/tls-observatory/issues/186 if e == "ECDHE-ECDSA-CHACHA20-POLY1305-OLD" || e == "ECDHE-RSA-CHACHA20-POLY1305-OLD" { continue } if !contains(s1, e) { extra = append(extra, e) } } return }
[ "func", "extra", "(", "s1", ",", "s2", "[", "]", "string", ")", "(", "extra", "[", "]", "string", ")", "{", "for", "_", ",", "e", ":=", "range", "s2", "{", "// FIXME: https://github.com/mozilla/tls-observatory/issues/186", "if", "e", "==", "\"", "\"", "|...
// extra returns a slice of strings that are present in a slice s1 but not // in a slice s2.
[ "extra", "returns", "a", "slice", "of", "strings", "that", "are", "present", "in", "a", "slice", "s1", "but", "not", "in", "a", "slice", "s2", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/mozillaEvaluationWorker/mozillaEvaluationWorker.go#L675-L686
train
mozilla/tls-observatory
worker/top1m/top1m.go
analyseTargetRank
func (w ranker) analyseTargetRank(in worker.Input) (tr targetRank, err error) { tr = targetRank{ Domain: in.Target, Rank: certificate.Default_Cisco_Umbrella_Rank, CiscoRank: certificate.Default_Cisco_Umbrella_Rank, AlexaRank: certificate.Default_Cisco_Umbrella_Rank, } if val, ok := w.Ranks[tr.Domain]; ok { tr.CiscoRank = rank(val) tr.Rank = rank(val) } if val, ok := w.AlexaRanks[tr.Domain]; ok { tr.AlexaRank = rank(val) } if tr.AlexaRank < tr.Rank { tr.Rank = tr.AlexaRank } return }
go
func (w ranker) analyseTargetRank(in worker.Input) (tr targetRank, err error) { tr = targetRank{ Domain: in.Target, Rank: certificate.Default_Cisco_Umbrella_Rank, CiscoRank: certificate.Default_Cisco_Umbrella_Rank, AlexaRank: certificate.Default_Cisco_Umbrella_Rank, } if val, ok := w.Ranks[tr.Domain]; ok { tr.CiscoRank = rank(val) tr.Rank = rank(val) } if val, ok := w.AlexaRanks[tr.Domain]; ok { tr.AlexaRank = rank(val) } if tr.AlexaRank < tr.Rank { tr.Rank = tr.AlexaRank } return }
[ "func", "(", "w", "ranker", ")", "analyseTargetRank", "(", "in", "worker", ".", "Input", ")", "(", "tr", "targetRank", ",", "err", "error", ")", "{", "tr", "=", "targetRank", "{", "Domain", ":", "in", ".", "Target", ",", "Rank", ":", "certificate", "...
// Find the rank of the target
[ "Find", "the", "rank", "of", "the", "target" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/top1m/top1m.go#L177-L195
train
mozilla/tls-observatory
worker/caaWorker/caaWorker.go
Assertor
func (e eval) Assertor(caaResult, assertresults []byte) (pass bool, body []byte, err error) { var result, assertres Result pass = false err = json.Unmarshal(caaResult, &result) if err != nil { return } err = json.Unmarshal(assertresults, &assertres) if err != nil { return } if result.HasCAA != assertres.HasCAA { body = []byte("CAA mismatch") return } if result.Host != assertres.Host { body = []byte(fmt.Sprintf(`Assertion failed MatchedHost= %s`, result.Host)) return } if len(result.IssueCAs) != len(assertres.IssueCAs) { body = []byte("Issue CAs count mismatch") return } for i := range result.IssueCAs { if result.IssueCAs[i] != assertres.IssueCAs[i] { body = []byte(fmt.Sprintf(`Issue CAs mismatch %s != %s`, result.IssueCAs[i], assertres.IssueCAs[i])) return } } if len(result.IssueWildCAs) != len(assertres.IssueWildCAs) { body = []byte("Issue CAs count mismatch") return } for i := range result.IssueWildCAs { if result.IssueWildCAs[i] != assertres.IssueWildCAs[i] { body = []byte(fmt.Sprintf(`Issue CAs mismatch %s != %s`, result.IssueWildCAs[i], assertres.IssueWildCAs[i])) return } } pass = true return }
go
func (e eval) Assertor(caaResult, assertresults []byte) (pass bool, body []byte, err error) { var result, assertres Result pass = false err = json.Unmarshal(caaResult, &result) if err != nil { return } err = json.Unmarshal(assertresults, &assertres) if err != nil { return } if result.HasCAA != assertres.HasCAA { body = []byte("CAA mismatch") return } if result.Host != assertres.Host { body = []byte(fmt.Sprintf(`Assertion failed MatchedHost= %s`, result.Host)) return } if len(result.IssueCAs) != len(assertres.IssueCAs) { body = []byte("Issue CAs count mismatch") return } for i := range result.IssueCAs { if result.IssueCAs[i] != assertres.IssueCAs[i] { body = []byte(fmt.Sprintf(`Issue CAs mismatch %s != %s`, result.IssueCAs[i], assertres.IssueCAs[i])) return } } if len(result.IssueWildCAs) != len(assertres.IssueWildCAs) { body = []byte("Issue CAs count mismatch") return } for i := range result.IssueWildCAs { if result.IssueWildCAs[i] != assertres.IssueWildCAs[i] { body = []byte(fmt.Sprintf(`Issue CAs mismatch %s != %s`, result.IssueWildCAs[i], assertres.IssueWildCAs[i])) return } } pass = true return }
[ "func", "(", "e", "eval", ")", "Assertor", "(", "caaResult", ",", "assertresults", "[", "]", "byte", ")", "(", "pass", "bool", ",", "body", "[", "]", "byte", ",", "err", "error", ")", "{", "var", "result", ",", "assertres", "Result", "\n", "pass", ...
// Assertor compares 2 caaResults and reports differences.
[ "Assertor", "compares", "2", "caaResults", "and", "reports", "differences", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/caaWorker/caaWorker.go#L95-L145
train
mozilla/tls-observatory
connection/connection.go
Stored
func (s CipherscanOutput) Stored() (Stored, error) { c := Stored{} var err error c.ServerSide = stringtoBool(s.ServerSide) c.CurvesFallback = stringtoBool(s.CurvesFallback) c.ScanIP = s.IP for _, cipher := range s.CipherSuites { newcipher := Ciphersuite{} newcipher.Cipher = cipher.Cipher newcipher.Code = constants.CipherSuites[cipher.Cipher].Code newcipher.OCSPStapling = stringtoBool(cipher.OCSPStapling) newcipher.PFS = cipher.PFS newcipher.Protocols = cipher.Protocols if len(cipher.PubKey) > 1 { return c, fmt.Errorf("Multiple PubKeys for %s at cipher : %s", s.Target, cipher.Cipher) } if len(cipher.PubKey) > 0 { newcipher.PubKey, err = strconv.ParseFloat(cipher.PubKey[0], 64) } else { return c, errors.New("No Public Keys found") } if len(cipher.SigAlg) > 1 { return c, fmt.Errorf("Multiple SigAlgs for %s at cipher: %s", s.Target, cipher.Cipher) } if len(cipher.SigAlg) > 0 { newcipher.SigAlg = cipher.SigAlg[0] } else { return c, errors.New("No Signature Algorithms found") } newcipher.TicketHint = cipher.TicketHint if err != nil { return c, err } newcipher.Curves = append(newcipher.Curves, cipher.Curves...) c.CipherSuite = append(c.CipherSuite, newcipher) } return c, nil }
go
func (s CipherscanOutput) Stored() (Stored, error) { c := Stored{} var err error c.ServerSide = stringtoBool(s.ServerSide) c.CurvesFallback = stringtoBool(s.CurvesFallback) c.ScanIP = s.IP for _, cipher := range s.CipherSuites { newcipher := Ciphersuite{} newcipher.Cipher = cipher.Cipher newcipher.Code = constants.CipherSuites[cipher.Cipher].Code newcipher.OCSPStapling = stringtoBool(cipher.OCSPStapling) newcipher.PFS = cipher.PFS newcipher.Protocols = cipher.Protocols if len(cipher.PubKey) > 1 { return c, fmt.Errorf("Multiple PubKeys for %s at cipher : %s", s.Target, cipher.Cipher) } if len(cipher.PubKey) > 0 { newcipher.PubKey, err = strconv.ParseFloat(cipher.PubKey[0], 64) } else { return c, errors.New("No Public Keys found") } if len(cipher.SigAlg) > 1 { return c, fmt.Errorf("Multiple SigAlgs for %s at cipher: %s", s.Target, cipher.Cipher) } if len(cipher.SigAlg) > 0 { newcipher.SigAlg = cipher.SigAlg[0] } else { return c, errors.New("No Signature Algorithms found") } newcipher.TicketHint = cipher.TicketHint if err != nil { return c, err } newcipher.Curves = append(newcipher.Curves, cipher.Curves...) c.CipherSuite = append(c.CipherSuite, newcipher) } return c, nil }
[ "func", "(", "s", "CipherscanOutput", ")", "Stored", "(", ")", "(", "Stored", ",", "error", ")", "{", "c", ":=", "Stored", "{", "}", "\n\n", "var", "err", "error", "\n\n", "c", ".", "ServerSide", "=", "stringtoBool", "(", "s", ".", "ServerSide", ")",...
// Stored creates a Stored struct from the CipherscanOutput struct
[ "Stored", "creates", "a", "Stored", "struct", "from", "the", "CipherscanOutput", "struct" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/connection/connection.go#L126-L178
train
mozilla/tls-observatory
worker/worker.go
RegisterWorker
func RegisterWorker(name string, info Info) { if _, exist := AvailableWorkers[name]; exist { fmt.Fprintf(os.Stderr, "RegisterWorker: a worker named %q has already been registered.\nAre you trying to import the same worker twice?\n", name) os.Exit(1) } AvailableWorkers[name] = info }
go
func RegisterWorker(name string, info Info) { if _, exist := AvailableWorkers[name]; exist { fmt.Fprintf(os.Stderr, "RegisterWorker: a worker named %q has already been registered.\nAre you trying to import the same worker twice?\n", name) os.Exit(1) } AvailableWorkers[name] = info }
[ "func", "RegisterWorker", "(", "name", "string", ",", "info", "Info", ")", "{", "if", "_", ",", "exist", ":=", "AvailableWorkers", "[", "name", "]", ";", "exist", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\\n", "\"", ...
// RegisterWorker is called by each worker in order to register itself as available.
[ "RegisterWorker", "is", "called", "by", "each", "worker", "in", "order", "to", "register", "itself", "as", "available", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/worker.go#L45-L51
train
mozilla/tls-observatory
worker/worker.go
RegisterPrinter
func RegisterPrinter(name string, info Info) { if _, exist := AvailablePrinters[name]; exist { fmt.Fprintf(os.Stderr, "RegisterPrinter: a printer named %q has already been registered.\nAre you trying to import the same printer twice?\n", name) os.Exit(1) } AvailablePrinters[name] = info }
go
func RegisterPrinter(name string, info Info) { if _, exist := AvailablePrinters[name]; exist { fmt.Fprintf(os.Stderr, "RegisterPrinter: a printer named %q has already been registered.\nAre you trying to import the same printer twice?\n", name) os.Exit(1) } AvailablePrinters[name] = info }
[ "func", "RegisterPrinter", "(", "name", "string", ",", "info", "Info", ")", "{", "if", "_", ",", "exist", ":=", "AvailablePrinters", "[", "name", "]", ";", "exist", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\\n", "\"", ...
// RegisterPrinter is called by each worker in order to register itself as available.
[ "RegisterPrinter", "is", "called", "by", "each", "worker", "in", "order", "to", "register", "itself", "as", "available", "." ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/worker.go#L58-L64
train
mozilla/tls-observatory
tlsobs-api/middleware.go
HandleMiddlewares
func HandleMiddlewares(h http.Handler, adapters ...Middleware) http.Handler { // To make the middleware run in the order in which they are specified, // we reverse through them in the Middleware function, rather than just // ranging over them for i := len(adapters) - 1; i >= 0; i-- { h = adapters[i](h) } return h }
go
func HandleMiddlewares(h http.Handler, adapters ...Middleware) http.Handler { // To make the middleware run in the order in which they are specified, // we reverse through them in the Middleware function, rather than just // ranging over them for i := len(adapters) - 1; i >= 0; i-- { h = adapters[i](h) } return h }
[ "func", "HandleMiddlewares", "(", "h", "http", ".", "Handler", ",", "adapters", "...", "Middleware", ")", "http", ".", "Handler", "{", "// To make the middleware run in the order in which they are specified,", "// we reverse through them in the Middleware function, rather than just...
// Run the request through all middlewares
[ "Run", "the", "request", "through", "all", "middlewares" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/tlsobs-api/middleware.go#L69-L77
train
mozilla/tls-observatory
tlsobs-api/middleware.go
addtoContext
func addtoContext(r *http.Request, key string, value interface{}) *http.Request { ctx := r.Context() return r.WithContext(context.WithValue(ctx, key, value)) }
go
func addtoContext(r *http.Request, key string, value interface{}) *http.Request { ctx := r.Context() return r.WithContext(context.WithValue(ctx, key, value)) }
[ "func", "addtoContext", "(", "r", "*", "http", ".", "Request", ",", "key", "string", ",", "value", "interface", "{", "}", ")", "*", "http", ".", "Request", "{", "ctx", ":=", "r", ".", "Context", "(", ")", "\n", "return", "r", ".", "WithContext", "(...
// addToContext add the given key value pair to the given request's context
[ "addToContext", "add", "the", "given", "key", "value", "pair", "to", "the", "given", "request", "s", "context" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/tlsobs-api/middleware.go#L80-L83
train
mozilla/tls-observatory
database/database.go
GetLastScanTimeForTarget
func (db *DB) GetLastScanTimeForTarget(target string) (int64, time.Time, error) { var ( id int64 t time.Time ) row := db.QueryRow(`SELECT id, timestamp FROM scans WHERE target=$1 ORDER BY timestamp DESC LIMIT 1`, target) err := row.Scan(&id, &t) if err != nil { if err == sql.ErrNoRows { return -1, time.Now(), nil } else { return -1, time.Now(), err } } return id, t, nil }
go
func (db *DB) GetLastScanTimeForTarget(target string) (int64, time.Time, error) { var ( id int64 t time.Time ) row := db.QueryRow(`SELECT id, timestamp FROM scans WHERE target=$1 ORDER BY timestamp DESC LIMIT 1`, target) err := row.Scan(&id, &t) if err != nil { if err == sql.ErrNoRows { return -1, time.Now(), nil } else { return -1, time.Now(), err } } return id, t, nil }
[ "func", "(", "db", "*", "DB", ")", "GetLastScanTimeForTarget", "(", "target", "string", ")", "(", "int64", ",", "time", ".", "Time", ",", "error", ")", "{", "var", "(", "id", "int64", "\n", "t", "time", ".", "Time", "\n", ")", "\n\n", "row", ":=", ...
// 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.
[ "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"...
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/database/database.go#L99-L120
train
mozilla/tls-observatory
metrics/metrics.go
NewCertificate
func (sender *Sender) NewCertificate() { sender.cloudwatchSvc.PutMetricData(&cloudwatch.PutMetricDataInput{ MetricData: []*cloudwatch.MetricDatum{ &cloudwatch.MetricDatum{ MetricName: aws.String("NewCertificates"), Unit: aws.String(cloudwatch.StandardUnitNone), Value: aws.Float64(1.0), Dimensions: []*cloudwatch.Dimension{}, }, }, Namespace: aws.String("tls-observatory"), }) }
go
func (sender *Sender) NewCertificate() { sender.cloudwatchSvc.PutMetricData(&cloudwatch.PutMetricDataInput{ MetricData: []*cloudwatch.MetricDatum{ &cloudwatch.MetricDatum{ MetricName: aws.String("NewCertificates"), Unit: aws.String(cloudwatch.StandardUnitNone), Value: aws.Float64(1.0), Dimensions: []*cloudwatch.Dimension{}, }, }, Namespace: aws.String("tls-observatory"), }) }
[ "func", "(", "sender", "*", "Sender", ")", "NewCertificate", "(", ")", "{", "sender", ".", "cloudwatchSvc", ".", "PutMetricData", "(", "&", "cloudwatch", ".", "PutMetricDataInput", "{", "MetricData", ":", "[", "]", "*", "cloudwatch", ".", "MetricDatum", "{",...
// NewCertificate informs Cloudwatch that a new certificate has been created
[ "NewCertificate", "informs", "Cloudwatch", "that", "a", "new", "certificate", "has", "been", "created" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/metrics/metrics.go#L39-L51
train
mozilla/tls-observatory
worker/crlWorker/crlWorker.go
getCRLResponses
func getCRLResponses(cert certificate.Certificate) ([][]byte, error) { var wg sync.WaitGroup var out [][]byte crlPoints := cert.X509v3Extensions.CRLDistributionPoints wg.Add(len(crlPoints)) for i := range crlPoints { go func(point string, wg *sync.WaitGroup) { defer wg.Done() resp, err := httpClient.Get(point) if err != nil { return } defer resp.Body.Close() bs, err := ioutil.ReadAll(resp.Body) if err != nil { return } out = append(out, bs) }(crlPoints[i], &wg) } wg.Wait() if len(out) > 0 { return out, nil } return nil, fmt.Errorf("Unable to load CRL data for certificate %s", cert.Subject) }
go
func getCRLResponses(cert certificate.Certificate) ([][]byte, error) { var wg sync.WaitGroup var out [][]byte crlPoints := cert.X509v3Extensions.CRLDistributionPoints wg.Add(len(crlPoints)) for i := range crlPoints { go func(point string, wg *sync.WaitGroup) { defer wg.Done() resp, err := httpClient.Get(point) if err != nil { return } defer resp.Body.Close() bs, err := ioutil.ReadAll(resp.Body) if err != nil { return } out = append(out, bs) }(crlPoints[i], &wg) } wg.Wait() if len(out) > 0 { return out, nil } return nil, fmt.Errorf("Unable to load CRL data for certificate %s", cert.Subject) }
[ "func", "getCRLResponses", "(", "cert", "certificate", ".", "Certificate", ")", "(", "[", "]", "[", "]", "byte", ",", "error", ")", "{", "var", "wg", "sync", ".", "WaitGroup", "\n", "var", "out", "[", "]", "[", "]", "byte", "\n\n", "crlPoints", ":=",...
// Grab the first CRL response and return it in raw bytes
[ "Grab", "the", "first", "CRL", "response", "and", "return", "it", "in", "raw", "bytes" ]
a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c
https://github.com/mozilla/tls-observatory/blob/a3c1b6cfecfd7a0cf8f64c6bdc2b1e1d6a87e06c/worker/crlWorker/crlWorker.go#L168-L196
train
juju/juju
cmd/juju/storage/detach.go
NewDetachStorageCommandWithAPI
func NewDetachStorageCommandWithAPI() cmd.Command { command := &detachStorageCommand{} command.newEntityDetacherCloser = func() (EntityDetacherCloser, error) { return command.NewStorageAPI() } return modelcmd.Wrap(command) }
go
func NewDetachStorageCommandWithAPI() cmd.Command { command := &detachStorageCommand{} command.newEntityDetacherCloser = func() (EntityDetacherCloser, error) { return command.NewStorageAPI() } return modelcmd.Wrap(command) }
[ "func", "NewDetachStorageCommandWithAPI", "(", ")", "cmd", ".", "Command", "{", "command", ":=", "&", "detachStorageCommand", "{", "}", "\n", "command", ".", "newEntityDetacherCloser", "=", "func", "(", ")", "(", "EntityDetacherCloser", ",", "error", ")", "{", ...
// NewDetachStorageCommandWithAPI returns a command // used to detach storage from application units.
[ "NewDetachStorageCommandWithAPI", "returns", "a", "command", "used", "to", "detach", "storage", "from", "application", "units", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/storage/detach.go#L21-L27
train
juju/juju
cmd/juju/storage/detach.go
NewDetachStorageCommand
func NewDetachStorageCommand(new NewEntityDetacherCloserFunc) cmd.Command { command := &detachStorageCommand{} command.newEntityDetacherCloser = new return modelcmd.Wrap(command) }
go
func NewDetachStorageCommand(new NewEntityDetacherCloserFunc) cmd.Command { command := &detachStorageCommand{} command.newEntityDetacherCloser = new return modelcmd.Wrap(command) }
[ "func", "NewDetachStorageCommand", "(", "new", "NewEntityDetacherCloserFunc", ")", "cmd", ".", "Command", "{", "command", ":=", "&", "detachStorageCommand", "{", "}", "\n", "command", ".", "newEntityDetacherCloser", "=", "new", "\n", "return", "modelcmd", ".", "Wr...
// NewDetachStorageCommand returns a command used to // detach storage from application units.
[ "NewDetachStorageCommand", "returns", "a", "command", "used", "to", "detach", "storage", "from", "application", "units", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/storage/detach.go#L31-L35
train
juju/juju
worker/caasunitprovisioner/worker.go
NewWorker
func NewWorker(config Config) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } p := &provisioner{config: config} err := catacomb.Invoke(catacomb.Plan{ Site: &p.catacomb, Work: p.loop, }) return p, err }
go
func NewWorker(config Config) (worker.Worker, error) { if err := config.Validate(); err != nil { return nil, errors.Trace(err) } p := &provisioner{config: config} err := catacomb.Invoke(catacomb.Plan{ Site: &p.catacomb, Work: p.loop, }) return p, err }
[ "func", "NewWorker", "(", "config", "Config", ")", "(", "worker", ".", "Worker", ",", "error", ")", "{", "if", "err", ":=", "config", ".", "Validate", "(", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "errors", ".", "Trace", "(", "err",...
// NewWorker starts and returns a new CAAS unit provisioner worker.
[ "NewWorker", "starts", "and", "returns", "a", "new", "CAAS", "unit", "provisioner", "worker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/caasunitprovisioner/worker.go#L62-L72
train
juju/juju
worker/caasunitprovisioner/worker.go
saveApplicationWorker
func (p *provisioner) saveApplicationWorker(appName string, aw *applicationWorker) { p.mu.Lock() defer p.mu.Unlock() if p.appWorkers == nil { p.appWorkers = make(map[string]*applicationWorker) } p.appWorkers[appName] = aw }
go
func (p *provisioner) saveApplicationWorker(appName string, aw *applicationWorker) { p.mu.Lock() defer p.mu.Unlock() if p.appWorkers == nil { p.appWorkers = make(map[string]*applicationWorker) } p.appWorkers[appName] = aw }
[ "func", "(", "p", "*", "provisioner", ")", "saveApplicationWorker", "(", "appName", "string", ",", "aw", "*", "applicationWorker", ")", "{", "p", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "if", ...
// These helper methods protect the appWorkers map so we can access for testing.
[ "These", "helper", "methods", "protect", "the", "appWorkers", "map", "so", "we", "can", "access", "for", "testing", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/caasunitprovisioner/worker.go#L96-L104
train
juju/juju
cmd/juju/controller/addmodel.go
NewAddModelCommand
func NewAddModelCommand() cmd.Command { command := &addModelCommand{ newAddModelAPI: func(caller base.APICallCloser) AddModelAPI { return modelmanager.NewClient(caller) }, newCloudAPI: func(caller base.APICallCloser) CloudAPI { return cloudapi.NewClient(caller) }, providerRegistry: environs.GlobalProviderRegistry(), } command.CanClearCurrentModel = true return modelcmd.WrapController(command) }
go
func NewAddModelCommand() cmd.Command { command := &addModelCommand{ newAddModelAPI: func(caller base.APICallCloser) AddModelAPI { return modelmanager.NewClient(caller) }, newCloudAPI: func(caller base.APICallCloser) CloudAPI { return cloudapi.NewClient(caller) }, providerRegistry: environs.GlobalProviderRegistry(), } command.CanClearCurrentModel = true return modelcmd.WrapController(command) }
[ "func", "NewAddModelCommand", "(", ")", "cmd", ".", "Command", "{", "command", ":=", "&", "addModelCommand", "{", "newAddModelAPI", ":", "func", "(", "caller", "base", ".", "APICallCloser", ")", "AddModelAPI", "{", "return", "modelmanager", ".", "NewClient", "...
// NewAddModelCommand returns a command to add a model.
[ "NewAddModelCommand", "returns", "a", "command", "to", "add", "a", "model", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/controller/addmodel.go#L36-L48
train
juju/juju
cmd/juju/controller/addmodel.go
findCredential
func (c *addModelCommand) findCredential(ctx *cmd.Context, cloudClient CloudAPI, p *findCredentialParams) (_ *jujucloud.Credential, _ names.CloudCredentialTag, cloudRegion string, _ error) { if c.CredentialName == "" { return c.findUnspecifiedCredential(ctx, cloudClient, p) } return c.findSpecifiedCredential(ctx, cloudClient, p) }
go
func (c *addModelCommand) findCredential(ctx *cmd.Context, cloudClient CloudAPI, p *findCredentialParams) (_ *jujucloud.Credential, _ names.CloudCredentialTag, cloudRegion string, _ error) { if c.CredentialName == "" { return c.findUnspecifiedCredential(ctx, cloudClient, p) } return c.findSpecifiedCredential(ctx, cloudClient, p) }
[ "func", "(", "c", "*", "addModelCommand", ")", "findCredential", "(", "ctx", "*", "cmd", ".", "Context", ",", "cloudClient", "CloudAPI", ",", "p", "*", "findCredentialParams", ")", "(", "_", "*", "jujucloud", ".", "Credential", ",", "_", "names", ".", "C...
// findCredential finds a suitable credential to use for the new model. // The credential will first be searched for locally and then on the // controller. If a credential is found locally then it's value will be // returned as the first return value. If it is found on the controller // this will be nil as there is no need to upload it in that case.
[ "findCredential", "finds", "a", "suitable", "credential", "to", "use", "for", "the", "new", "model", ".", "The", "credential", "will", "first", "be", "searched", "for", "locally", "and", "then", "on", "the", "controller", ".", "If", "a", "credential", "is", ...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/cmd/juju/controller/addmodel.go#L465-L470
train
juju/juju
worker/pubsub/messagewriter.go
NewMessageWriter
func NewMessageWriter(info *api.Info) (MessageWriter, error) { conn, err := api.Open(info, dialOpts) if err != nil { return nil, errors.Trace(err) } a := pubsubapi.NewAPI(conn) writer, err := a.OpenMessageWriter() if err != nil { conn.Close() return nil, errors.Trace(err) } return &remoteConnection{connection: conn, MessageWriter: writer}, nil }
go
func NewMessageWriter(info *api.Info) (MessageWriter, error) { conn, err := api.Open(info, dialOpts) if err != nil { return nil, errors.Trace(err) } a := pubsubapi.NewAPI(conn) writer, err := a.OpenMessageWriter() if err != nil { conn.Close() return nil, errors.Trace(err) } return &remoteConnection{connection: conn, MessageWriter: writer}, nil }
[ "func", "NewMessageWriter", "(", "info", "*", "api", ".", "Info", ")", "(", "MessageWriter", ",", "error", ")", "{", "conn", ",", "err", ":=", "api", ".", "Open", "(", "info", ",", "dialOpts", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ni...
// NewMessageWriter will connect to the remote defined by the info, // and return a MessageWriter.
[ "NewMessageWriter", "will", "connect", "to", "the", "remote", "defined", "by", "the", "info", "and", "return", "a", "MessageWriter", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/worker/pubsub/messagewriter.go#L36-L48
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockEventInterface
func NewMockEventInterface(ctrl *gomock.Controller) *MockEventInterface { mock := &MockEventInterface{ctrl: ctrl} mock.recorder = &MockEventInterfaceMockRecorder{mock} return mock }
go
func NewMockEventInterface(ctrl *gomock.Controller) *MockEventInterface { mock := &MockEventInterface{ctrl: ctrl} mock.recorder = &MockEventInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockEventInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockEventInterface", "{", "mock", ":=", "&", "MockEventInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockEventInterfaceMockRecorder"...
// NewMockEventInterface creates a new mock instance
[ "NewMockEventInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L33-L37
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
GetFieldSelector
func (m *MockEventInterface) GetFieldSelector(arg0, arg1, arg2, arg3 *string) fields.Selector { ret := m.ctrl.Call(m, "GetFieldSelector", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(fields.Selector) return ret0 }
go
func (m *MockEventInterface) GetFieldSelector(arg0, arg1, arg2, arg3 *string) fields.Selector { ret := m.ctrl.Call(m, "GetFieldSelector", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(fields.Selector) return ret0 }
[ "func", "(", "m", "*", "MockEventInterface", ")", "GetFieldSelector", "(", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", "*", "string", ")", "fields", ".", "Selector", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ","...
// GetFieldSelector mocks base method
[ "GetFieldSelector", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L108-L112
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
GetFieldSelector
func (mr *MockEventInterfaceMockRecorder) GetFieldSelector(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFieldSelector", reflect.TypeOf((*MockEventInterface)(nil).GetFieldSelector), arg0, arg1, arg2, arg3) }
go
func (mr *MockEventInterfaceMockRecorder) GetFieldSelector(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetFieldSelector", reflect.TypeOf((*MockEventInterface)(nil).GetFieldSelector), arg0, arg1, arg2, arg3) }
[ "func", "(", "mr", "*", "MockEventInterfaceMockRecorder", ")", "GetFieldSelector", "(", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCall...
// GetFieldSelector indicates an expected call of GetFieldSelector
[ "GetFieldSelector", "indicates", "an", "expected", "call", "of", "GetFieldSelector" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L115-L117
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
PatchWithEventNamespace
func (m *MockEventInterface) PatchWithEventNamespace(arg0 *v1.Event, arg1 []byte) (*v1.Event, error) { ret := m.ctrl.Call(m, "PatchWithEventNamespace", arg0, arg1) ret0, _ := ret[0].(*v1.Event) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockEventInterface) PatchWithEventNamespace(arg0 *v1.Event, arg1 []byte) (*v1.Event, error) { ret := m.ctrl.Call(m, "PatchWithEventNamespace", arg0, arg1) ret0, _ := ret[0].(*v1.Event) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockEventInterface", ")", "PatchWithEventNamespace", "(", "arg0", "*", "v1", ".", "Event", ",", "arg1", "[", "]", "byte", ")", "(", "*", "v1", ".", "Event", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call",...
// PatchWithEventNamespace mocks base method
[ "PatchWithEventNamespace", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L151-L156
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Search
func (m *MockEventInterface) Search(arg0 *runtime.Scheme, arg1 runtime.Object) (*v1.EventList, error) { ret := m.ctrl.Call(m, "Search", arg0, arg1) ret0, _ := ret[0].(*v1.EventList) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockEventInterface) Search(arg0 *runtime.Scheme, arg1 runtime.Object) (*v1.EventList, error) { ret := m.ctrl.Call(m, "Search", arg0, arg1) ret0, _ := ret[0].(*v1.EventList) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockEventInterface", ")", "Search", "(", "arg0", "*", "runtime", ".", "Scheme", ",", "arg1", "runtime", ".", "Object", ")", "(", "*", "v1", ".", "EventList", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call"...
// Search mocks base method
[ "Search", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L164-L169
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
UpdateWithEventNamespace
func (m *MockEventInterface) UpdateWithEventNamespace(arg0 *v1.Event) (*v1.Event, error) { ret := m.ctrl.Call(m, "UpdateWithEventNamespace", arg0) ret0, _ := ret[0].(*v1.Event) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockEventInterface) UpdateWithEventNamespace(arg0 *v1.Event) (*v1.Event, error) { ret := m.ctrl.Call(m, "UpdateWithEventNamespace", arg0) ret0, _ := ret[0].(*v1.Event) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockEventInterface", ")", "UpdateWithEventNamespace", "(", "arg0", "*", "v1", ".", "Event", ")", "(", "*", "v1", ".", "Event", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ...
// UpdateWithEventNamespace mocks base method
[ "UpdateWithEventNamespace", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L190-L195
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockCoreV1Interface
func NewMockCoreV1Interface(ctrl *gomock.Controller) *MockCoreV1Interface { mock := &MockCoreV1Interface{ctrl: ctrl} mock.recorder = &MockCoreV1InterfaceMockRecorder{mock} return mock }
go
func NewMockCoreV1Interface(ctrl *gomock.Controller) *MockCoreV1Interface { mock := &MockCoreV1Interface{ctrl: ctrl} mock.recorder = &MockCoreV1InterfaceMockRecorder{mock} return mock }
[ "func", "NewMockCoreV1Interface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockCoreV1Interface", "{", "mock", ":=", "&", "MockCoreV1Interface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockCoreV1InterfaceMockRecor...
// NewMockCoreV1Interface creates a new mock instance
[ "NewMockCoreV1Interface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L227-L231
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
ComponentStatuses
func (m *MockCoreV1Interface) ComponentStatuses() v11.ComponentStatusInterface { ret := m.ctrl.Call(m, "ComponentStatuses") ret0, _ := ret[0].(v11.ComponentStatusInterface) return ret0 }
go
func (m *MockCoreV1Interface) ComponentStatuses() v11.ComponentStatusInterface { ret := m.ctrl.Call(m, "ComponentStatuses") ret0, _ := ret[0].(v11.ComponentStatusInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "ComponentStatuses", "(", ")", "v11", ".", "ComponentStatusInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", ...
// ComponentStatuses mocks base method
[ "ComponentStatuses", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L239-L243
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
ConfigMaps
func (m *MockCoreV1Interface) ConfigMaps(arg0 string) v11.ConfigMapInterface { ret := m.ctrl.Call(m, "ConfigMaps", arg0) ret0, _ := ret[0].(v11.ConfigMapInterface) return ret0 }
go
func (m *MockCoreV1Interface) ConfigMaps(arg0 string) v11.ConfigMapInterface { ret := m.ctrl.Call(m, "ConfigMaps", arg0) ret0, _ := ret[0].(v11.ConfigMapInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "ConfigMaps", "(", "arg0", "string", ")", "v11", ".", "ConfigMapInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=...
// ConfigMaps mocks base method
[ "ConfigMaps", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L251-L255
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Endpoints
func (m *MockCoreV1Interface) Endpoints(arg0 string) v11.EndpointsInterface { ret := m.ctrl.Call(m, "Endpoints", arg0) ret0, _ := ret[0].(v11.EndpointsInterface) return ret0 }
go
func (m *MockCoreV1Interface) Endpoints(arg0 string) v11.EndpointsInterface { ret := m.ctrl.Call(m, "Endpoints", arg0) ret0, _ := ret[0].(v11.EndpointsInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "Endpoints", "(", "arg0", "string", ")", "v11", ".", "EndpointsInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":="...
// Endpoints mocks base method
[ "Endpoints", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L263-L267
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
LimitRanges
func (m *MockCoreV1Interface) LimitRanges(arg0 string) v11.LimitRangeInterface { ret := m.ctrl.Call(m, "LimitRanges", arg0) ret0, _ := ret[0].(v11.LimitRangeInterface) return ret0 }
go
func (m *MockCoreV1Interface) LimitRanges(arg0 string) v11.LimitRangeInterface { ret := m.ctrl.Call(m, "LimitRanges", arg0) ret0, _ := ret[0].(v11.LimitRangeInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "LimitRanges", "(", "arg0", "string", ")", "v11", ".", "LimitRangeInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", "...
// LimitRanges mocks base method
[ "LimitRanges", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L287-L291
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Namespaces
func (m *MockCoreV1Interface) Namespaces() v11.NamespaceInterface { ret := m.ctrl.Call(m, "Namespaces") ret0, _ := ret[0].(v11.NamespaceInterface) return ret0 }
go
func (m *MockCoreV1Interface) Namespaces() v11.NamespaceInterface { ret := m.ctrl.Call(m, "Namespaces") ret0, _ := ret[0].(v11.NamespaceInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "Namespaces", "(", ")", "v11", ".", "NamespaceInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".",...
// Namespaces mocks base method
[ "Namespaces", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L299-L303
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Nodes
func (m *MockCoreV1Interface) Nodes() v11.NodeInterface { ret := m.ctrl.Call(m, "Nodes") ret0, _ := ret[0].(v11.NodeInterface) return ret0 }
go
func (m *MockCoreV1Interface) Nodes() v11.NodeInterface { ret := m.ctrl.Call(m, "Nodes") ret0, _ := ret[0].(v11.NodeInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "Nodes", "(", ")", "v11", ".", "NodeInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0", "]", ".", "(", ...
// Nodes mocks base method
[ "Nodes", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L311-L315
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
PersistentVolumeClaims
func (m *MockCoreV1Interface) PersistentVolumeClaims(arg0 string) v11.PersistentVolumeClaimInterface { ret := m.ctrl.Call(m, "PersistentVolumeClaims", arg0) ret0, _ := ret[0].(v11.PersistentVolumeClaimInterface) return ret0 }
go
func (m *MockCoreV1Interface) PersistentVolumeClaims(arg0 string) v11.PersistentVolumeClaimInterface { ret := m.ctrl.Call(m, "PersistentVolumeClaims", arg0) ret0, _ := ret[0].(v11.PersistentVolumeClaimInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "PersistentVolumeClaims", "(", "arg0", "string", ")", "v11", ".", "PersistentVolumeClaimInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "re...
// PersistentVolumeClaims mocks base method
[ "PersistentVolumeClaims", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L323-L327
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
PersistentVolumes
func (m *MockCoreV1Interface) PersistentVolumes() v11.PersistentVolumeInterface { ret := m.ctrl.Call(m, "PersistentVolumes") ret0, _ := ret[0].(v11.PersistentVolumeInterface) return ret0 }
go
func (m *MockCoreV1Interface) PersistentVolumes() v11.PersistentVolumeInterface { ret := m.ctrl.Call(m, "PersistentVolumes") ret0, _ := ret[0].(v11.PersistentVolumeInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "PersistentVolumes", "(", ")", "v11", ".", "PersistentVolumeInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ")", "\n", "ret0", ",", "_", ":=", "ret", "[", "0",...
// PersistentVolumes mocks base method
[ "PersistentVolumes", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L335-L339
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
PersistentVolumes
func (mr *MockCoreV1InterfaceMockRecorder) PersistentVolumes() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PersistentVolumes", reflect.TypeOf((*MockCoreV1Interface)(nil).PersistentVolumes)) }
go
func (mr *MockCoreV1InterfaceMockRecorder) PersistentVolumes() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PersistentVolumes", reflect.TypeOf((*MockCoreV1Interface)(nil).PersistentVolumes)) }
[ "func", "(", "mr", "*", "MockCoreV1InterfaceMockRecorder", ")", "PersistentVolumes", "(", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", "\"", ",", "reflec...
// PersistentVolumes indicates an expected call of PersistentVolumes
[ "PersistentVolumes", "indicates", "an", "expected", "call", "of", "PersistentVolumes" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L342-L344
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
PodTemplates
func (m *MockCoreV1Interface) PodTemplates(arg0 string) v11.PodTemplateInterface { ret := m.ctrl.Call(m, "PodTemplates", arg0) ret0, _ := ret[0].(v11.PodTemplateInterface) return ret0 }
go
func (m *MockCoreV1Interface) PodTemplates(arg0 string) v11.PodTemplateInterface { ret := m.ctrl.Call(m, "PodTemplates", arg0) ret0, _ := ret[0].(v11.PodTemplateInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "PodTemplates", "(", "arg0", "string", ")", "v11", ".", "PodTemplateInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ...
// PodTemplates mocks base method
[ "PodTemplates", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L347-L351
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
PodTemplates
func (mr *MockCoreV1InterfaceMockRecorder) PodTemplates(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PodTemplates", reflect.TypeOf((*MockCoreV1Interface)(nil).PodTemplates), arg0) }
go
func (mr *MockCoreV1InterfaceMockRecorder) PodTemplates(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PodTemplates", reflect.TypeOf((*MockCoreV1Interface)(nil).PodTemplates), arg0) }
[ "func", "(", "mr", "*", "MockCoreV1InterfaceMockRecorder", ")", "PodTemplates", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ","...
// PodTemplates indicates an expected call of PodTemplates
[ "PodTemplates", "indicates", "an", "expected", "call", "of", "PodTemplates" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L354-L356
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Pods
func (m *MockCoreV1Interface) Pods(arg0 string) v11.PodInterface { ret := m.ctrl.Call(m, "Pods", arg0) ret0, _ := ret[0].(v11.PodInterface) return ret0 }
go
func (m *MockCoreV1Interface) Pods(arg0 string) v11.PodInterface { ret := m.ctrl.Call(m, "Pods", arg0) ret0, _ := ret[0].(v11.PodInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "Pods", "(", "arg0", "string", ")", "v11", ".", "PodInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", ...
// Pods mocks base method
[ "Pods", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L359-L363
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
ReplicationControllers
func (m *MockCoreV1Interface) ReplicationControllers(arg0 string) v11.ReplicationControllerInterface { ret := m.ctrl.Call(m, "ReplicationControllers", arg0) ret0, _ := ret[0].(v11.ReplicationControllerInterface) return ret0 }
go
func (m *MockCoreV1Interface) ReplicationControllers(arg0 string) v11.ReplicationControllerInterface { ret := m.ctrl.Call(m, "ReplicationControllers", arg0) ret0, _ := ret[0].(v11.ReplicationControllerInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "ReplicationControllers", "(", "arg0", "string", ")", "v11", ".", "ReplicationControllerInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "re...
// ReplicationControllers mocks base method
[ "ReplicationControllers", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L383-L387
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
ResourceQuotas
func (m *MockCoreV1Interface) ResourceQuotas(arg0 string) v11.ResourceQuotaInterface { ret := m.ctrl.Call(m, "ResourceQuotas", arg0) ret0, _ := ret[0].(v11.ResourceQuotaInterface) return ret0 }
go
func (m *MockCoreV1Interface) ResourceQuotas(arg0 string) v11.ResourceQuotaInterface { ret := m.ctrl.Call(m, "ResourceQuotas", arg0) ret0, _ := ret[0].(v11.ResourceQuotaInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "ResourceQuotas", "(", "arg0", "string", ")", "v11", ".", "ResourceQuotaInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_...
// ResourceQuotas mocks base method
[ "ResourceQuotas", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L395-L399
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Secrets
func (m *MockCoreV1Interface) Secrets(arg0 string) v11.SecretInterface { ret := m.ctrl.Call(m, "Secrets", arg0) ret0, _ := ret[0].(v11.SecretInterface) return ret0 }
go
func (m *MockCoreV1Interface) Secrets(arg0 string) v11.SecretInterface { ret := m.ctrl.Call(m, "Secrets", arg0) ret0, _ := ret[0].(v11.SecretInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "Secrets", "(", "arg0", "string", ")", "v11", ".", "SecretInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "...
// Secrets mocks base method
[ "Secrets", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L407-L411
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
ServiceAccounts
func (m *MockCoreV1Interface) ServiceAccounts(arg0 string) v11.ServiceAccountInterface { ret := m.ctrl.Call(m, "ServiceAccounts", arg0) ret0, _ := ret[0].(v11.ServiceAccountInterface) return ret0 }
go
func (m *MockCoreV1Interface) ServiceAccounts(arg0 string) v11.ServiceAccountInterface { ret := m.ctrl.Call(m, "ServiceAccounts", arg0) ret0, _ := ret[0].(v11.ServiceAccountInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "ServiceAccounts", "(", "arg0", "string", ")", "v11", ".", "ServiceAccountInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", ...
// ServiceAccounts mocks base method
[ "ServiceAccounts", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L419-L423
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Services
func (m *MockCoreV1Interface) Services(arg0 string) v11.ServiceInterface { ret := m.ctrl.Call(m, "Services", arg0) ret0, _ := ret[0].(v11.ServiceInterface) return ret0 }
go
func (m *MockCoreV1Interface) Services(arg0 string) v11.ServiceInterface { ret := m.ctrl.Call(m, "Services", arg0) ret0, _ := ret[0].(v11.ServiceInterface) return ret0 }
[ "func", "(", "m", "*", "MockCoreV1Interface", ")", "Services", "(", "arg0", "string", ")", "v11", ".", "ServiceInterface", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", ...
// Services mocks base method
[ "Services", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L431-L435
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockNamespaceInterface
func NewMockNamespaceInterface(ctrl *gomock.Controller) *MockNamespaceInterface { mock := &MockNamespaceInterface{ctrl: ctrl} mock.recorder = &MockNamespaceInterfaceMockRecorder{mock} return mock }
go
func NewMockNamespaceInterface(ctrl *gomock.Controller) *MockNamespaceInterface { mock := &MockNamespaceInterface{ctrl: ctrl} mock.recorder = &MockNamespaceInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockNamespaceInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockNamespaceInterface", "{", "mock", ":=", "&", "MockNamespaceInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockNamespaceInterf...
// NewMockNamespaceInterface creates a new mock instance
[ "NewMockNamespaceInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L454-L458
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockPodInterface
func NewMockPodInterface(ctrl *gomock.Controller) *MockPodInterface { mock := &MockPodInterface{ctrl: ctrl} mock.recorder = &MockPodInterfaceMockRecorder{mock} return mock }
go
func NewMockPodInterface(ctrl *gomock.Controller) *MockPodInterface { mock := &MockPodInterface{ctrl: ctrl} mock.recorder = &MockPodInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockPodInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockPodInterface", "{", "mock", ":=", "&", "MockPodInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockPodInterfaceMockRecorder", "{",...
// NewMockPodInterface creates a new mock instance
[ "NewMockPodInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L598-L602
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Bind
func (m *MockPodInterface) Bind(arg0 *v1.Binding) error { ret := m.ctrl.Call(m, "Bind", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockPodInterface) Bind(arg0 *v1.Binding) error { ret := m.ctrl.Call(m, "Bind", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockPodInterface", ")", "Bind", "(", "arg0", "*", "v1", ".", "Binding", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "ret", "...
// Bind mocks base method
[ "Bind", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L610-L614
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Bind
func (mr *MockPodInterfaceMockRecorder) Bind(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bind", reflect.TypeOf((*MockPodInterface)(nil).Bind), arg0) }
go
func (mr *MockPodInterfaceMockRecorder) Bind(arg0 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bind", reflect.TypeOf((*MockPodInterface)(nil).Bind), arg0) }
[ "func", "(", "mr", "*", "MockPodInterfaceMockRecorder", ")", "Bind", "(", "arg0", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", "(", "mr", ".", "mock", ",", "\"", ...
// Bind indicates an expected call of Bind
[ "Bind", "indicates", "an", "expected", "call", "of", "Bind" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L617-L619
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
Evict
func (m *MockPodInterface) Evict(arg0 *v1beta1.Eviction) error { ret := m.ctrl.Call(m, "Evict", arg0) ret0, _ := ret[0].(error) return ret0 }
go
func (m *MockPodInterface) Evict(arg0 *v1beta1.Eviction) error { ret := m.ctrl.Call(m, "Evict", arg0) ret0, _ := ret[0].(error) return ret0 }
[ "func", "(", "m", "*", "MockPodInterface", ")", "Evict", "(", "arg0", "*", "v1beta1", ".", "Eviction", ")", "error", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "arg0", ")", "\n", "ret0", ",", "_", ":=", "re...
// Evict mocks base method
[ "Evict", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L659-L663
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
GetLogs
func (m *MockPodInterface) GetLogs(arg0 string, arg1 *v1.PodLogOptions) *rest.Request { ret := m.ctrl.Call(m, "GetLogs", arg0, arg1) ret0, _ := ret[0].(*rest.Request) return ret0 }
go
func (m *MockPodInterface) GetLogs(arg0 string, arg1 *v1.PodLogOptions) *rest.Request { ret := m.ctrl.Call(m, "GetLogs", arg0, arg1) ret0, _ := ret[0].(*rest.Request) return ret0 }
[ "func", "(", "m", "*", "MockPodInterface", ")", "GetLogs", "(", "arg0", "string", ",", "arg1", "*", "v1", ".", "PodLogOptions", ")", "*", "rest", ".", "Request", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"", ",", "ar...
// GetLogs mocks base method
[ "GetLogs", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L684-L688
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockServiceInterface
func NewMockServiceInterface(ctrl *gomock.Controller) *MockServiceInterface { mock := &MockServiceInterface{ctrl: ctrl} mock.recorder = &MockServiceInterfaceMockRecorder{mock} return mock }
go
func NewMockServiceInterface(ctrl *gomock.Controller) *MockServiceInterface { mock := &MockServiceInterface{ctrl: ctrl} mock.recorder = &MockServiceInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockServiceInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockServiceInterface", "{", "mock", ":=", "&", "MockServiceInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockServiceInterfaceMockR...
// NewMockServiceInterface creates a new mock instance
[ "NewMockServiceInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L777-L781
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
ProxyGet
func (m *MockServiceInterface) ProxyGet(arg0, arg1, arg2, arg3 string, arg4 map[string]string) rest.ResponseWrapper { ret := m.ctrl.Call(m, "ProxyGet", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(rest.ResponseWrapper) return ret0 }
go
func (m *MockServiceInterface) ProxyGet(arg0, arg1, arg2, arg3 string, arg4 map[string]string) rest.ResponseWrapper { ret := m.ctrl.Call(m, "ProxyGet", arg0, arg1, arg2, arg3, arg4) ret0, _ := ret[0].(rest.ResponseWrapper) return ret0 }
[ "func", "(", "m", "*", "MockServiceInterface", ")", "ProxyGet", "(", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", "string", ",", "arg4", "map", "[", "string", "]", "string", ")", "rest", ".", "ResponseWrapper", "{", "ret", ":=", "m", ".", "ctrl", "...
// ProxyGet mocks base method
[ "ProxyGet", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L858-L862
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
ProxyGet
func (mr *MockServiceInterfaceMockRecorder) ProxyGet(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProxyGet", reflect.TypeOf((*MockServiceInterface)(nil).ProxyGet), arg0, arg1, arg2, arg3, arg4) }
go
func (mr *MockServiceInterfaceMockRecorder) ProxyGet(arg0, arg1, arg2, arg3, arg4 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProxyGet", reflect.TypeOf((*MockServiceInterface)(nil).ProxyGet), arg0, arg1, arg2, arg3, arg4) }
[ "func", "(", "mr", "*", "MockServiceInterfaceMockRecorder", ")", "ProxyGet", "(", "arg0", ",", "arg1", ",", "arg2", ",", "arg3", ",", "arg4", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", ...
// ProxyGet indicates an expected call of ProxyGet
[ "ProxyGet", "indicates", "an", "expected", "call", "of", "ProxyGet" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L865-L867
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockConfigMapInterface
func NewMockConfigMapInterface(ctrl *gomock.Controller) *MockConfigMapInterface { mock := &MockConfigMapInterface{ctrl: ctrl} mock.recorder = &MockConfigMapInterfaceMockRecorder{mock} return mock }
go
func NewMockConfigMapInterface(ctrl *gomock.Controller) *MockConfigMapInterface { mock := &MockConfigMapInterface{ctrl: ctrl} mock.recorder = &MockConfigMapInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockConfigMapInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockConfigMapInterface", "{", "mock", ":=", "&", "MockConfigMapInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockConfigMapInterf...
// NewMockConfigMapInterface creates a new mock instance
[ "NewMockConfigMapInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L920-L924
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockPersistentVolumeInterface
func NewMockPersistentVolumeInterface(ctrl *gomock.Controller) *MockPersistentVolumeInterface { mock := &MockPersistentVolumeInterface{ctrl: ctrl} mock.recorder = &MockPersistentVolumeInterfaceMockRecorder{mock} return mock }
go
func NewMockPersistentVolumeInterface(ctrl *gomock.Controller) *MockPersistentVolumeInterface { mock := &MockPersistentVolumeInterface{ctrl: ctrl} mock.recorder = &MockPersistentVolumeInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockPersistentVolumeInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockPersistentVolumeInterface", "{", "mock", ":=", "&", "MockPersistentVolumeInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", ...
// NewMockPersistentVolumeInterface creates a new mock instance
[ "NewMockPersistentVolumeInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L1050-L1054
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockPersistentVolumeClaimInterface
func NewMockPersistentVolumeClaimInterface(ctrl *gomock.Controller) *MockPersistentVolumeClaimInterface { mock := &MockPersistentVolumeClaimInterface{ctrl: ctrl} mock.recorder = &MockPersistentVolumeClaimInterfaceMockRecorder{mock} return mock }
go
func NewMockPersistentVolumeClaimInterface(ctrl *gomock.Controller) *MockPersistentVolumeClaimInterface { mock := &MockPersistentVolumeClaimInterface{ctrl: ctrl} mock.recorder = &MockPersistentVolumeClaimInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockPersistentVolumeClaimInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockPersistentVolumeClaimInterface", "{", "mock", ":=", "&", "MockPersistentVolumeClaimInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", ...
// NewMockPersistentVolumeClaimInterface creates a new mock instance
[ "NewMockPersistentVolumeClaimInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L1193-L1197
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
DeleteCollection
func (mr *MockPersistentVolumeClaimInterfaceMockRecorder) DeleteCollection(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteCollection", reflect.TypeOf((*MockPersistentVolumeClaimInterface)(nil).DeleteCollection), arg0, arg1) }
go
func (mr *MockPersistentVolumeClaimInterfaceMockRecorder) DeleteCollection(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteCollection", reflect.TypeOf((*MockPersistentVolumeClaimInterface)(nil).DeleteCollection), arg0, arg1) }
[ "func", "(", "mr", "*", "MockPersistentVolumeClaimInterfaceMockRecorder", ")", "DeleteCollection", "(", "arg0", ",", "arg1", "interface", "{", "}", ")", "*", "gomock", ".", "Call", "{", "return", "mr", ".", "mock", ".", "ctrl", ".", "RecordCallWithMethodType", ...
// DeleteCollection indicates an expected call of DeleteCollection
[ "DeleteCollection", "indicates", "an", "expected", "call", "of", "DeleteCollection" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L1237-L1239
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockSecretInterface
func NewMockSecretInterface(ctrl *gomock.Controller) *MockSecretInterface { mock := &MockSecretInterface{ctrl: ctrl} mock.recorder = &MockSecretInterfaceMockRecorder{mock} return mock }
go
func NewMockSecretInterface(ctrl *gomock.Controller) *MockSecretInterface { mock := &MockSecretInterface{ctrl: ctrl} mock.recorder = &MockSecretInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockSecretInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockSecretInterface", "{", "mock", ":=", "&", "MockSecretInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockSecretInterfaceMockRecor...
// NewMockSecretInterface creates a new mock instance
[ "NewMockSecretInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L1336-L1340
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
NewMockNodeInterface
func NewMockNodeInterface(ctrl *gomock.Controller) *MockNodeInterface { mock := &MockNodeInterface{ctrl: ctrl} mock.recorder = &MockNodeInterfaceMockRecorder{mock} return mock }
go
func NewMockNodeInterface(ctrl *gomock.Controller) *MockNodeInterface { mock := &MockNodeInterface{ctrl: ctrl} mock.recorder = &MockNodeInterfaceMockRecorder{mock} return mock }
[ "func", "NewMockNodeInterface", "(", "ctrl", "*", "gomock", ".", "Controller", ")", "*", "MockNodeInterface", "{", "mock", ":=", "&", "MockNodeInterface", "{", "ctrl", ":", "ctrl", "}", "\n", "mock", ".", "recorder", "=", "&", "MockNodeInterfaceMockRecorder", ...
// NewMockNodeInterface creates a new mock instance
[ "NewMockNodeInterface", "creates", "a", "new", "mock", "instance" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L1466-L1470
train
juju/juju
caas/kubernetes/provider/mocks/corev1_mock.go
PatchStatus
func (m *MockNodeInterface) PatchStatus(arg0 string, arg1 []byte) (*v1.Node, error) { ret := m.ctrl.Call(m, "PatchStatus", arg0, arg1) ret0, _ := ret[0].(*v1.Node) ret1, _ := ret[1].(error) return ret0, ret1 }
go
func (m *MockNodeInterface) PatchStatus(arg0 string, arg1 []byte) (*v1.Node, error) { ret := m.ctrl.Call(m, "PatchStatus", arg0, arg1) ret0, _ := ret[0].(*v1.Node) ret1, _ := ret[1].(error) return ret0, ret1 }
[ "func", "(", "m", "*", "MockNodeInterface", ")", "PatchStatus", "(", "arg0", "string", ",", "arg1", "[", "]", "byte", ")", "(", "*", "v1", ".", "Node", ",", "error", ")", "{", "ret", ":=", "m", ".", "ctrl", ".", "Call", "(", "m", ",", "\"", "\"...
// PatchStatus mocks base method
[ "PatchStatus", "mocks", "base", "method" ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/mocks/corev1_mock.go#L1559-L1564
train
juju/juju
provider/azure/internal/tracing/tracing.go
PrepareDecorator
func PrepareDecorator(logger loggo.Logger) autorest.PrepareDecorator { return func(p autorest.Preparer) autorest.Preparer { return autorest.PreparerFunc(func(r *http.Request) (*http.Request, error) { if logger.IsTraceEnabled() { dump, err := httputil.DumpRequest(r, true) if err != nil { logger.Tracef("failed to dump request: %v", err) logger.Tracef("%+v", r) } else { logger.Tracef("%s", dump) } } return p.Prepare(r) }) } }
go
func PrepareDecorator(logger loggo.Logger) autorest.PrepareDecorator { return func(p autorest.Preparer) autorest.Preparer { return autorest.PreparerFunc(func(r *http.Request) (*http.Request, error) { if logger.IsTraceEnabled() { dump, err := httputil.DumpRequest(r, true) if err != nil { logger.Tracef("failed to dump request: %v", err) logger.Tracef("%+v", r) } else { logger.Tracef("%s", dump) } } return p.Prepare(r) }) } }
[ "func", "PrepareDecorator", "(", "logger", "loggo", ".", "Logger", ")", "autorest", ".", "PrepareDecorator", "{", "return", "func", "(", "p", "autorest", ".", "Preparer", ")", "autorest", ".", "Preparer", "{", "return", "autorest", ".", "PreparerFunc", "(", ...
// PrepareDecorator returns an autorest.PrepareDecorator that // logs requests at trace level.
[ "PrepareDecorator", "returns", "an", "autorest", ".", "PrepareDecorator", "that", "logs", "requests", "at", "trace", "level", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/internal/tracing/tracing.go#L16-L31
train
juju/juju
provider/azure/internal/tracing/tracing.go
RespondDecorator
func RespondDecorator(logger loggo.Logger) autorest.RespondDecorator { return func(r autorest.Responder) autorest.Responder { return autorest.ResponderFunc(func(resp *http.Response) error { if logger.IsTraceEnabled() { dump, err := httputil.DumpResponse(resp, true) if err != nil { logger.Tracef("failed to dump response: %v", err) logger.Tracef("%+v", resp) } else { logger.Tracef("%s", dump) } } return r.Respond(resp) }) } }
go
func RespondDecorator(logger loggo.Logger) autorest.RespondDecorator { return func(r autorest.Responder) autorest.Responder { return autorest.ResponderFunc(func(resp *http.Response) error { if logger.IsTraceEnabled() { dump, err := httputil.DumpResponse(resp, true) if err != nil { logger.Tracef("failed to dump response: %v", err) logger.Tracef("%+v", resp) } else { logger.Tracef("%s", dump) } } return r.Respond(resp) }) } }
[ "func", "RespondDecorator", "(", "logger", "loggo", ".", "Logger", ")", "autorest", ".", "RespondDecorator", "{", "return", "func", "(", "r", "autorest", ".", "Responder", ")", "autorest", ".", "Responder", "{", "return", "autorest", ".", "ResponderFunc", "(",...
// RespondDecorator returns an autorest.RespondDecorator that // logs responses at trace level.
[ "RespondDecorator", "returns", "an", "autorest", ".", "RespondDecorator", "that", "logs", "responses", "at", "trace", "level", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/provider/azure/internal/tracing/tracing.go#L35-L50
train
juju/juju
caas/kubernetes/provider/metadata.go
newLabelRequirements
func newLabelRequirements(rs ...requirementParams) k8slabels.Selector { s := k8slabels.NewSelector() for _, r := range rs { l, err := k8slabels.NewRequirement(r.key, r.operator, r.strValues) if err != nil { // this panic only happens if the compiled code is wrong. panic(errors.Annotatef(err, "incorrect requirement config %v", r)) } s = s.Add(*l) } return s }
go
func newLabelRequirements(rs ...requirementParams) k8slabels.Selector { s := k8slabels.NewSelector() for _, r := range rs { l, err := k8slabels.NewRequirement(r.key, r.operator, r.strValues) if err != nil { // this panic only happens if the compiled code is wrong. panic(errors.Annotatef(err, "incorrect requirement config %v", r)) } s = s.Add(*l) } return s }
[ "func", "newLabelRequirements", "(", "rs", "...", "requirementParams", ")", "k8slabels", ".", "Selector", "{", "s", ":=", "k8slabels", ".", "NewSelector", "(", ")", "\n", "for", "_", ",", "r", ":=", "range", "rs", "{", "l", ",", "err", ":=", "k8slabels",...
// newLabelRequirements creates a list of k8s node label requirements. // This should be called inside package init function to panic earlier // if there is a invalid requirement definition.
[ "newLabelRequirements", "creates", "a", "list", "of", "k8s", "node", "label", "requirements", ".", "This", "should", "be", "called", "inside", "package", "init", "function", "to", "panic", "earlier", "if", "there", "is", "a", "invalid", "requirement", "definitio...
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/metadata.go#L25-L36
train
juju/juju
caas/kubernetes/provider/metadata.go
CheckDefaultWorkloadStorage
func (k *kubernetesClient) CheckDefaultWorkloadStorage(cluster string, storageProvisioner *caas.StorageProvisioner) error { preferredStorage, ok := jujuPreferredWorkloadStorage[cluster] if !ok { return errors.NotFoundf("cluster %q", cluster) } return storageClassMatches(preferredStorage, storageProvisioner) }
go
func (k *kubernetesClient) CheckDefaultWorkloadStorage(cluster string, storageProvisioner *caas.StorageProvisioner) error { preferredStorage, ok := jujuPreferredWorkloadStorage[cluster] if !ok { return errors.NotFoundf("cluster %q", cluster) } return storageClassMatches(preferredStorage, storageProvisioner) }
[ "func", "(", "k", "*", "kubernetesClient", ")", "CheckDefaultWorkloadStorage", "(", "cluster", "string", ",", "storageProvisioner", "*", "caas", ".", "StorageProvisioner", ")", "error", "{", "preferredStorage", ",", "ok", ":=", "jujuPreferredWorkloadStorage", "[", "...
// CheckDefaultWorkloadStorage implements ClusterMetadataChecker.
[ "CheckDefaultWorkloadStorage", "implements", "ClusterMetadataChecker", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/caas/kubernetes/provider/metadata.go#L197-L203
train
juju/juju
state/userpermission.go
userPermission
func (st *State) userPermission(objectGlobalKey, subjectGlobalKey string) (*userPermission, error) { result := &userPermission{} permissions, closer := st.db().GetCollection(permissionsC) defer closer() id := permissionID(objectGlobalKey, subjectGlobalKey) err := permissions.FindId(id).One(&result.doc) if err == mgo.ErrNotFound { return nil, errors.NotFoundf("user permission for %q on %q", subjectGlobalKey, objectGlobalKey) } return result, nil }
go
func (st *State) userPermission(objectGlobalKey, subjectGlobalKey string) (*userPermission, error) { result := &userPermission{} permissions, closer := st.db().GetCollection(permissionsC) defer closer() id := permissionID(objectGlobalKey, subjectGlobalKey) err := permissions.FindId(id).One(&result.doc) if err == mgo.ErrNotFound { return nil, errors.NotFoundf("user permission for %q on %q", subjectGlobalKey, objectGlobalKey) } return result, nil }
[ "func", "(", "st", "*", "State", ")", "userPermission", "(", "objectGlobalKey", ",", "subjectGlobalKey", "string", ")", "(", "*", "userPermission", ",", "error", ")", "{", "result", ":=", "&", "userPermission", "{", "}", "\n", "permissions", ",", "closer", ...
// userPermission returns a Permission for the given Subject and User.
[ "userPermission", "returns", "a", "Permission", "for", "the", "given", "Subject", "and", "User", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/userpermission.go#L43-L54
train
juju/juju
state/userpermission.go
usersPermissions
func (st *State) usersPermissions(objectGlobalKey string) ([]*userPermission, error) { permissions, closer := st.db().GetCollection(permissionsC) defer closer() var matchingPermissions []permissionDoc findExpr := fmt.Sprintf("^%s#.*$", objectGlobalKey) if err := permissions.Find( bson.D{{"_id", bson.D{{"$regex", findExpr}}}}, ).All(&matchingPermissions); err != nil { return nil, err } var result []*userPermission for _, pDoc := range matchingPermissions { result = append(result, &userPermission{doc: pDoc}) } return result, nil }
go
func (st *State) usersPermissions(objectGlobalKey string) ([]*userPermission, error) { permissions, closer := st.db().GetCollection(permissionsC) defer closer() var matchingPermissions []permissionDoc findExpr := fmt.Sprintf("^%s#.*$", objectGlobalKey) if err := permissions.Find( bson.D{{"_id", bson.D{{"$regex", findExpr}}}}, ).All(&matchingPermissions); err != nil { return nil, err } var result []*userPermission for _, pDoc := range matchingPermissions { result = append(result, &userPermission{doc: pDoc}) } return result, nil }
[ "func", "(", "st", "*", "State", ")", "usersPermissions", "(", "objectGlobalKey", "string", ")", "(", "[", "]", "*", "userPermission", ",", "error", ")", "{", "permissions", ",", "closer", ":=", "st", ".", "db", "(", ")", ".", "GetCollection", "(", "pe...
// usersPermissions returns all permissions for a given object.
[ "usersPermissions", "returns", "all", "permissions", "for", "a", "given", "object", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/state/userpermission.go#L57-L73
train
juju/juju
mongo/oplog.go
UnmarshalObject
func (d *OplogDoc) UnmarshalObject(out interface{}) error { return d.unmarshal(d.Object, out) }
go
func (d *OplogDoc) UnmarshalObject(out interface{}) error { return d.unmarshal(d.Object, out) }
[ "func", "(", "d", "*", "OplogDoc", ")", "UnmarshalObject", "(", "out", "interface", "{", "}", ")", "error", "{", "return", "d", ".", "unmarshal", "(", "d", ".", "Object", ",", "out", ")", "\n", "}" ]
// UnmarshalObject unmarshals the Object field into out. The out // argument should be a pointer or a suitable map.
[ "UnmarshalObject", "unmarshals", "the", "Object", "field", "into", "out", ".", "The", "out", "argument", "should", "be", "a", "pointer", "or", "a", "suitable", "map", "." ]
ba728eedb1e44937c7bdc59f374b06400d0c7133
https://github.com/juju/juju/blob/ba728eedb1e44937c7bdc59f374b06400d0c7133/mongo/oplog.go#L34-L36
train