_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q31100
AuditPanic
train
func (log *impl) AuditPanic() { if err := recover(); err != nil { buf := make([]byte, 8192) log.AuditErrf("Panic caused by err: %s", err) runtime.Stack(buf, false) log.AuditErrf("Stack Trace (Current frame) %s", buf) runtime.Stack(buf, true) log.Warningf("Stack Trace (All frames): %s", buf) } }
go
{ "resource": "" }
q31101
Err
train
func (log *impl) Err(msg string) { log.auditAtLevel(syslog.LOG_ERR, msg) }
go
{ "resource": "" }
q31102
Errf
train
func (log *impl) Errf(format string, a ...interface{}) { log.Err(fmt.Sprintf(format, a...)) }
go
{ "resource": "" }
q31103
Warning
train
func (log *impl) Warning(msg string) { log.w.logAtLevel(syslog.LOG_WARNING, msg) }
go
{ "resource": "" }
q31104
Warningf
train
func (log *impl) Warningf(format string, a ...interface{}) { log.Warning(fmt.Sprintf(format, a...)) }
go
{ "resource": "" }
q31105
Info
train
func (log *impl) Info(msg string) { log.w.logAtLevel(syslog.LOG_INFO, msg) }
go
{ "resource": "" }
q31106
Infof
train
func (log *impl) Infof(format string, a ...interface{}) { log.Info(fmt.Sprintf(format, a...)) }
go
{ "resource": "" }
q31107
Debug
train
func (log *impl) Debug(msg string) { log.w.logAtLevel(syslog.LOG_DEBUG, msg) }
go
{ "resource": "" }
q31108
Debugf
train
func (log *impl) Debugf(format string, a ...interface{}) { log.Debug(fmt.Sprintf(format, a...)) }
go
{ "resource": "" }
q31109
AuditInfo
train
func (log *impl) AuditInfo(msg string) { log.auditAtLevel(syslog.LOG_INFO, msg) }
go
{ "resource": "" }
q31110
AuditInfof
train
func (log *impl) AuditInfof(format string, a ...interface{}) { log.AuditInfo(fmt.Sprintf(format, a...)) }
go
{ "resource": "" }
q31111
AuditObject
train
func (log *impl) AuditObject(msg string, obj interface{}) { jsonObj, err := json.Marshal(obj) if err != nil { log.auditAtLevel(syslog.LOG_ERR, fmt.Sprintf("Object could not be serialized to JSON. Raw: %+v", obj)) return } log.auditAtLevel(syslog.LOG_INFO, fmt.Sprintf("%s JSON=%s", msg, jsonObj)) }
go
{ "resource": "" }
q31112
AuditErr
train
func (log *impl) AuditErr(msg string) { log.auditAtLevel(syslog.LOG_ERR, msg) }
go
{ "resource": "" }
q31113
AuditErrf
train
func (log *impl) AuditErrf(format string, a ...interface{}) { log.AuditErr(fmt.Sprintf(format, a...)) }
go
{ "resource": "" }
q31114
checkCAA
train
func (va *ValidationAuthorityImpl) checkCAA( ctx context.Context, identifier core.AcmeIdentifier, params *caaParams) *probs.ProblemDetails { present, valid, records, err := va.checkCAARecords(ctx, identifier, params) if err != nil { return probs.DNS("%v", err) } recordsStr, err := json.Marshal(&records) if e...
go
{ "resource": "" }
q31115
criticalUnknown
train
func (caaSet CAASet) criticalUnknown() bool { if len(caaSet.Unknown) > 0 { for _, caaRecord := range caaSet.Unknown { // The critical flag is the bit with significance 128. However, many CAA // record users have misinterpreted the RFC and concluded that the bit // with significance 1 is the critical bit. Th...
go
{ "resource": "" }
q31116
newCAASet
train
func newCAASet(CAAs []*dns.CAA) *CAASet { var filtered CAASet for _, caaRecord := range CAAs { switch strings.ToLower(caaRecord.Tag) { case "issue": filtered.Issue = append(filtered.Issue, caaRecord) case "issuewild": filtered.Issuewild = append(filtered.Issuewild, caaRecord) case "iodef": filtered....
go
{ "resource": "" }
q31117
checkAccountURI
train
func checkAccountURI(accountURI string, accountURIPrefixes []string, accountID int64) bool { for _, prefix := range accountURIPrefixes { if accountURI == fmt.Sprintf("%s%d", prefix, accountID) { return true } } return false }
go
{ "resource": "" }
q31118
RandomString
train
func RandomString(byteLength int) string { b := make([]byte, byteLength) _, err := io.ReadFull(RandReader, b) if err != nil { panic(fmt.Sprintf("Error reading random bytes: %s", err)) } return base64.RawURLEncoding.EncodeToString(b) }
go
{ "resource": "" }
q31119
Fingerprint256
train
func Fingerprint256(data []byte) string { d := sha256.New() _, _ = d.Write(data) // Never returns an error return base64.RawURLEncoding.EncodeToString(d.Sum(nil)) }
go
{ "resource": "" }
q31120
KeyDigest
train
func KeyDigest(key crypto.PublicKey) (string, error) { switch t := key.(type) { case *jose.JSONWebKey: if t == nil { return "", fmt.Errorf("Cannot compute digest of nil key") } return KeyDigest(t.Key) case jose.JSONWebKey: return KeyDigest(t.Key) default: keyDER, err := x509.MarshalPKIXPublicKey(key) ...
go
{ "resource": "" }
q31121
KeyDigestEquals
train
func KeyDigestEquals(j, k crypto.PublicKey) bool { digestJ, errJ := KeyDigest(j) digestK, errK := KeyDigest(k) // Keys that don't have a valid digest (due to marshalling problems) // are never equal. So, e.g. nil keys are not equal. if errJ != nil || errK != nil { return false } return digestJ == digestK }
go
{ "resource": "" }
q31122
PublicKeysEqual
train
func PublicKeysEqual(a, b interface{}) (bool, error) { if a == nil || b == nil { return false, errors.New("One or more nil arguments to PublicKeysEqual") } aBytes, err := x509.MarshalPKIXPublicKey(a) if err != nil { return false, err } bBytes, err := x509.MarshalPKIXPublicKey(b) if err != nil { return fals...
go
{ "resource": "" }
q31123
ValidSerial
train
func ValidSerial(serial string) bool { // Originally, serial numbers were 32 hex characters long. We later increased // them to 36, but we allow the shorter ones because they exist in some // production databases. if len(serial) != 32 && len(serial) != 36 { return false } _, err := hex.DecodeString(serial) if ...
go
{ "resource": "" }
q31124
UniqueLowerNames
train
func UniqueLowerNames(names []string) (unique []string) { nameMap := make(map[string]int, len(names)) for _, name := range names { nameMap[strings.ToLower(name)] = 1 } unique = make([]string, 0, len(nameMap)) for name := range nameMap { unique = append(unique, name) } sort.Strings(unique) return }
go
{ "resource": "" }
q31125
LoadCertBundle
train
func LoadCertBundle(filename string) ([]*x509.Certificate, error) { bundleBytes, err := ioutil.ReadFile(filename) if err != nil { return nil, err } var bundle []*x509.Certificate var block *pem.Block rest := bundleBytes for { block, rest = pem.Decode(rest) if block == nil { break } if block.Type != ...
go
{ "resource": "" }
q31126
LoadCert
train
func LoadCert(filename string) (cert *x509.Certificate, err error) { certPEM, err := ioutil.ReadFile(filename) if err != nil { return } block, _ := pem.Decode(certPEM) if block == nil { return nil, fmt.Errorf("No data in cert PEM file %s", filename) } cert, err = x509.ParseCertificate(block.Bytes) return }
go
{ "resource": "" }
q31127
IsASCII
train
func IsASCII(str string) bool { for _, r := range str { if r > unicode.MaxASCII { return false } } return true }
go
{ "resource": "" }
q31128
authzMetaToPB
train
func authzMetaToPB(authz core.Authorization) (*vapb.AuthzMeta, error) { return &vapb.AuthzMeta{ Id: &authz.ID, RegID: &authz.RegistrationID, }, nil }
go
{ "resource": "" }
q31129
orderValid
train
func orderValid(order *corepb.Order) bool { return order.Id != nil && order.BeganProcessing != nil && order.Created != nil && newOrderValid(order) }
go
{ "resource": "" }
q31130
newOrderValid
train
func newOrderValid(order *corepb.Order) bool { return !(order.RegistrationID == nil || order.Expires == nil || order.Authorizations == nil || order.Names == nil) }
go
{ "resource": "" }
q31131
New
train
func New(challengeTypes map[string]bool) (*AuthorityImpl, error) { pa := AuthorityImpl{ log: blog.Get(), enabledChallenges: challengeTypes, // We don't need real randomness for this. pseudoRNG: rand.New(rand.NewSource(99)), } return &pa, nil }
go
{ "resource": "" }
q31132
SetHostnamePolicyFile
train
func (pa *AuthorityImpl) SetHostnamePolicyFile(f string) error { var loadHandler func([]byte) error if strings.HasSuffix(f, ".json") { loadHandler = pa.loadHostnamePolicy(json.Unmarshal) } else if strings.HasSuffix(f, ".yml") || strings.HasSuffix(f, ".yaml") { loadHandler = pa.loadHostnamePolicy(yaml.Unmarshal) ...
go
{ "resource": "" }
q31133
processHostnamePolicy
train
func (pa *AuthorityImpl) processHostnamePolicy(policy blockedNamesPolicy) error { nameMap := make(map[string]bool) for _, v := range policy.HighRiskBlockedNames { nameMap[v] = true } for _, v := range policy.AdminBlockedNames { nameMap[v] = true } exactNameMap := make(map[string]bool) wildcardNameMap := make...
go
{ "resource": "" }
q31134
checkWildcardHostList
train
func (pa *AuthorityImpl) checkWildcardHostList(domain string) error { pa.blocklistMu.RLock() defer pa.blocklistMu.RUnlock() if pa.blocklist == nil { return fmt.Errorf("Hostname policy not yet loaded.") } if pa.wildcardExactBlocklist[domain] { return errPolicyForbidden } return nil }
go
{ "resource": "" }
q31135
ChallengesFor
train
func (pa *AuthorityImpl) ChallengesFor(identifier core.AcmeIdentifier) ([]core.Challenge, error) { challenges := []core.Challenge{} // If we are using the new authorization storage schema we only use a single // token for all challenges rather than a unique token per challenge. var token string if features.Enable...
go
{ "resource": "" }
q31136
ChallengeTypeEnabled
train
func (pa *AuthorityImpl) ChallengeTypeEnabled(t string) bool { pa.blocklistMu.RLock() defer pa.blocklistMu.RUnlock() return pa.enabledChallenges[t] }
go
{ "resource": "" }
q31137
NewNonceService
train
func NewNonceService(scope metrics.Scope) (*NonceService, error) { scope = scope.NewScope("NonceService") key := make([]byte, 16) if _, err := rand.Read(key); err != nil { return nil, err } c, err := aes.NewCipher(key) if err != nil { panic("Failure in NewCipher: " + err.Error()) } gcm, err := cipher.NewGC...
go
{ "resource": "" }
q31138
Nonce
train
func (ns *NonceService) Nonce() (string, error) { ns.mu.Lock() ns.latest++ latest := ns.latest ns.mu.Unlock() defer ns.stats.Inc("Generated", 1) return ns.encrypt(latest) }
go
{ "resource": "" }
q31139
Valid
train
func (ns *NonceService) Valid(nonce string) bool { c, err := ns.decrypt(nonce) if err != nil { ns.stats.Inc("Invalid.Decrypt", 1) return false } ns.mu.Lock() defer ns.mu.Unlock() if c > ns.latest { ns.stats.Inc("Invalid.TooHigh", 1) return false } if c <= ns.earliest { ns.stats.Inc("Invalid.TooLow",...
go
{ "resource": "" }
q31140
New
train
func New(pub core.Publisher, groups []cmd.CTGroup, informational []cmd.LogDescription, log blog.Logger, stats metrics.Scope, ) *CTPolicy { var finalLogs []cmd.LogDescription for _, group := range groups { for _, log := range group.Logs { if log.SubmitFinalCert { finalLogs = append(finalLogs, log) } ...
go
{ "resource": "" }
q31141
GetSCTs
train
func (ctp *CTPolicy) GetSCTs(ctx context.Context, cert core.CertDER, expiration time.Time) (core.SCTDERs, error) { results := make(chan result, len(ctp.groups)) subCtx, cancel := context.WithCancel(ctx) defer cancel() for i, g := range ctp.groups { go func(i int, g cmd.CTGroup) { sct, err := ctp.race(subCtx, c...
go
{ "resource": "" }
q31142
SubmitFinalCert
train
func (ctp *CTPolicy) SubmitFinalCert(cert []byte, expiration time.Time) { falseVar := false for _, log := range ctp.finalLogs { go func(l cmd.LogDescription) { uri, key, err := l.Info(expiration) if err != nil { ctp.log.Errf("unable to get log info: %s", err) return } _, err = ctp.pub.SubmitToSi...
go
{ "resource": "" }
q31143
WriteHeader
train
func (r *responseWriterWithStatus) WriteHeader(code int) { r.code = code r.ResponseWriter.WriteHeader(code) }
go
{ "resource": "" }
q31144
PerformValidation
train
func (vac ValidationAuthorityGRPCClient) PerformValidation(ctx context.Context, domain string, challenge core.Challenge, authz core.Authorization) ([]core.ValidationRecord, error) { req, err := argsToPerformValidationRequest(domain, challenge, authz) if err != nil { return nil, err } gRecords, err := vac.gc.Perfo...
go
{ "resource": "" }
q31145
requestProto
train
func requestProto(request *http.Request) string { proto := "http" // If the request was received via TLS, use `https://` for the protocol if request.TLS != nil { proto = "https" } // Allow upstream proxies to specify the forwarded protocol. Allow this value // to override our own guess. if specifiedProto :=...
go
{ "resource": "" }
q31146
Nonce
train
func (wfe *WebFrontEndImpl) Nonce( ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) { statusCode := http.StatusNoContent // The ACME specification says GET requets should receive http.StatusNoContent // and HEAD requests should receive http.StatusOK. We gate t...
go
{ "resource": "" }
q31147
processRevocation
train
func (wfe *WebFrontEndImpl) processRevocation( ctx context.Context, jwsBody []byte, acctID int64, authorizedToRevoke authorizedToRevokeCert, request *http.Request, logEvent *web.RequestEvent) *probs.ProblemDetails { // Read the revoke request from the JWS payload var revokeRequest struct { CertificateDER core...
go
{ "resource": "" }
q31148
revokeCertByKeyID
train
func (wfe *WebFrontEndImpl) revokeCertByKeyID( ctx context.Context, outerJWS *jose.JSONWebSignature, request *http.Request, logEvent *web.RequestEvent) *probs.ProblemDetails { // For Key ID revocations we authenticate the outer JWS by using // `validJWSForAccount` similar to other WFE endpoints jwsBody, _, acct,...
go
{ "resource": "" }
q31149
revokeCertByJWK
train
func (wfe *WebFrontEndImpl) revokeCertByJWK( ctx context.Context, outerJWS *jose.JSONWebSignature, request *http.Request, logEvent *web.RequestEvent) *probs.ProblemDetails { // We maintain the requestKey as a var that is closed-over by the // `authorizedToRevoke` function to use var requestKey *jose.JSONWebKey ...
go
{ "resource": "" }
q31150
RevokeCertificate
train
func (wfe *WebFrontEndImpl) RevokeCertificate( ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) { // The ACME specification handles the verification of revocation requests // differently from other endpoints. For this reason we do *not* immediately // call `w...
go
{ "resource": "" }
q31151
prepChallengeForDisplay
train
func (wfe *WebFrontEndImpl) prepChallengeForDisplay(request *http.Request, authz core.Authorization, challenge *core.Challenge) { // Update the challenge URL to be relative to the HTTP request Host if authz.V2 { challenge.URL = web.RelativeEndpoint(request, fmt.Sprintf("%sv2/%s/%s", challengePath, authz.ID, challen...
go
{ "resource": "" }
q31152
Account
train
func (wfe *WebFrontEndImpl) Account( ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) { body, _, currAcct, prob := wfe.validPOSTForAccount(request, ctx, logEvent) addRequesterHeader(response, logEvent.Requester) if prob != nil { // validPOSTForAccount handle...
go
{ "resource": "" }
q31153
Issuer
train
func (wfe *WebFrontEndImpl) Issuer(ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) { // TODO Content negotiation response.Header().Set("Content-Type", "application/pkix-cert") response.WriteHeader(http.StatusOK) if _, err := response.Write(wfe.IssuerCert); err !...
go
{ "resource": "" }
q31154
BuildID
train
func (wfe *WebFrontEndImpl) BuildID(ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) { response.Header().Set("Content-Type", "text/plain") response.WriteHeader(http.StatusOK) detailsString := fmt.Sprintf("Boulder=(%s %s)", core.GetBuildID(), core.GetBuildTime()) ...
go
{ "resource": "" }
q31155
Options
train
func (wfe *WebFrontEndImpl) Options(response http.ResponseWriter, request *http.Request, methodsStr string, methodsMap map[string]bool) { // Every OPTIONS request gets an Allow header with a list of supported methods. response.Header().Set("Allow", methodsStr) // CORS preflight requests get additional headers. See ...
go
{ "resource": "" }
q31156
NewOrder
train
func (wfe *WebFrontEndImpl) NewOrder( ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) { body, _, acct, prob := wfe.validPOSTForAccount(request, ctx, logEvent) addRequesterHeader(response, logEvent.Requester) if prob != nil { // validPOSTForAccount handles i...
go
{ "resource": "" }
q31157
GetOrder
train
func (wfe *WebFrontEndImpl) GetOrder(ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) { var requesterAccount *core.Registration // Any POSTs to the Order endpoint should be POST-as-GET requests. There are // no POSTs with a body allowed for this endpoint. if requ...
go
{ "resource": "" }
q31158
resolveEmailAddresses
train
func (m *mailer) resolveEmailAddresses() (emailToRecipientMap, error) { result := make(emailToRecipientMap, len(m.destinations)) for _, r := range m.destinations { // Get the email address for the reg ID emails, err := emailsForReg(r.id, m.dbMap) if err != nil { return nil, err } for _, email := range ...
go
{ "resource": "" }
q31159
emailsForReg
train
func emailsForReg(id int, dbMap dbSelector) ([]string, error) { var contact contactJSON err := dbMap.SelectOne(&contact, `SELECT id, contact FROM registrations WHERE contact != 'null' AND id = :id;`, map[string]interface{}{ "id": id, }) if err == sql.ErrNoRows { return []string{}, nil } if err != ni...
go
{ "resource": "" }
q31160
readRecipientsList
train
func readRecipientsList(filename string) ([]recipient, error) { f, err := os.Open(filename) if err != nil { return nil, err } reader := csv.NewReader(f) record, err := reader.Read() if err != nil { return nil, err } if len(record) == 0 { return nil, fmt.Errorf("no entries in CSV") } if record[0] != "id"...
go
{ "resource": "" }
q31161
newMockWriter
train
func newMockWriter() *mockWriter { msgChan := make(chan string) getChan := make(chan []string) clearChan := make(chan struct{}) closeChan := make(chan struct{}) w := &mockWriter{ logged: []string{}, msgChan: msgChan, getChan: getChan, clearChan: clearChan, closeChan: closeChan, } go func() { f...
go
{ "resource": "" }
q31162
Pass
train
func (pc *PasswordConfig) Pass() (string, error) { if pc.PasswordFile != "" { contents, err := ioutil.ReadFile(pc.PasswordFile) if err != nil { return "", err } return strings.TrimRight(string(contents), "\n"), nil } return pc.Password, nil }
go
{ "resource": "" }
q31163
URL
train
func (d *DBConfig) URL() (string, error) { if d.DBConnectFile != "" { url, err := ioutil.ReadFile(d.DBConnectFile) return strings.TrimSpace(string(url)), err } return d.DBConnect, nil }
go
{ "resource": "" }
q31164
CheckChallenges
train
func (pc PAConfig) CheckChallenges() error { if len(pc.Challenges) == 0 { return errors.New("empty challenges map in the Policy Authority config is not allowed") } for name := range pc.Challenges { if !core.ValidChallenge(name) { return fmt.Errorf("Invalid challenge in PA config: %s", name) } } return nil...
go
{ "resource": "" }
q31165
UnmarshalJSON
train
func (d *ConfigDuration) UnmarshalJSON(b []byte) error { s := "" err := json.Unmarshal(b, &s) if err != nil { if _, ok := err.(*json.UnmarshalTypeError); ok { return ErrDurationMustBeString } return err } dd, err := time.ParseDuration(s) d.Duration = dd return err }
go
{ "resource": "" }
q31166
MarshalJSON
train
func (d ConfigDuration) MarshalJSON() ([]byte, error) { return []byte(d.Duration.String()), nil }
go
{ "resource": "" }
q31167
Setup
train
func (ts *TemporalSet) Setup() error { if ts.Name == "" { return errors.New("Name cannot be empty") } if len(ts.Shards) == 0 { return errors.New("temporal set contains no shards") } for i := range ts.Shards { if ts.Shards[i].WindowEnd.Before(ts.Shards[i].WindowStart) || ts.Shards[i].WindowEnd.Equal(ts.Sha...
go
{ "resource": "" }
q31168
pick
train
func (ts *TemporalSet) pick(exp time.Time) (*LogShard, error) { for _, shard := range ts.Shards { if exp.Before(shard.WindowStart) { continue } if !exp.Before(shard.WindowEnd) { continue } return &shard, nil } return nil, fmt.Errorf("no valid shard available for temporal set %q for expiration date %q...
go
{ "resource": "" }
q31169
Info
train
func (ld LogDescription) Info(exp time.Time) (string, string, error) { if ld.TemporalSet == nil { return ld.URI, ld.Key, nil } shard, err := ld.TemporalSet.pick(exp) if err != nil { return "", "", err } return shard.URI, shard.Key, nil }
go
{ "resource": "" }
q31170
Resolve
train
func (sr *staticResolver) Resolve(target string) (naming.Watcher, error) { return sr, nil }
go
{ "resource": "" }
q31171
Next
train
func (sr *staticResolver) Next() ([]*naming.Update, error) { if sr.addresses != nil { addrs := sr.addresses sr.addresses = nil return addrs, nil } // Since staticResolver.Next is called in a tight loop block forever // after returning the initial set of addresses forever := make(chan struct{}) <-forever re...
go
{ "resource": "" }
q31172
NewAuthorization
train
func (wfe *WebFrontEndImpl) NewAuthorization(ctx context.Context, logEvent *web.RequestEvent, response http.ResponseWriter, request *http.Request) { body, _, currReg, prob := wfe.verifyPOST(ctx, logEvent, request, true, core.ResourceNewAuthz) addRequesterHeader(response, logEvent.Requester) if prob != nil { // ver...
go
{ "resource": "" }
q31173
ExtractSuffix
train
func ExtractSuffix(name string) (string, error) { if name == "" { return "", fmt.Errorf("Blank name argument passed to ExtractSuffix") } rule := publicsuffix.DefaultList.Find(name, &publicsuffix.FindOptions{IgnorePrivate: true, DefaultRule: nil}) if rule == nil { return "", fmt.Errorf("Domain %s has no IANA TL...
go
{ "resource": "" }
q31174
ProblemDetailsForError
train
func ProblemDetailsForError(err error, msg string) *probs.ProblemDetails { switch e := err.(type) { case *probs.ProblemDetails: return e case *berrors.BoulderError: return problemDetailsForBoulderError(e, msg) default: // Internal server error messages may include sensitive data, so we do // not include it....
go
{ "resource": "" }
q31175
GetThreshold
train
func (rlp *RateLimitPolicy) GetThreshold(key string, regID int64) int { regOverride, regOverrideExists := rlp.RegistrationOverrides[regID] keyOverride, keyOverrideExists := rlp.Overrides[key] if regOverrideExists && !keyOverrideExists { // If there is a regOverride and no keyOverride use the regOverride return ...
go
{ "resource": "" }
q31176
Error
train
func (e errBadJSON) Error() string { return fmt.Sprintf( "%s: error unmarshaling JSON %q: %s", e.msg, string(e.json), e.err) }
go
{ "resource": "" }
q31177
badJSONError
train
func badJSONError(msg string, jsonData []byte, err error) error { return errBadJSON{ msg: msg, json: jsonData, err: err, } }
go
{ "resource": "" }
q31178
selectRegistration
train
func selectRegistration(s dbOneSelector, q string, args ...interface{}) (*regModel, error) { var model regModel err := s.SelectOne( &model, "SELECT "+regFields+" FROM registrations "+q, args..., ) return &model, err }
go
{ "resource": "" }
q31179
selectPendingAuthz
train
func selectPendingAuthz(s dbOneSelector, q string, args ...interface{}) (*pendingauthzModel, error) { var model pendingauthzModel err := s.SelectOne( &model, "SELECT id, identifier, registrationID, status, expires, LockCol FROM pendingAuthorizations "+q, args..., ) return &model, err }
go
{ "resource": "" }
q31180
selectAuthz
train
func selectAuthz(s dbOneSelector, q string, args ...interface{}) (*authzModel, error) { var model authzModel err := s.SelectOne( &model, "SELECT "+authzFields+" FROM authz "+q, args..., ) return &model, err }
go
{ "resource": "" }
q31181
selectSctReceipt
train
func selectSctReceipt(s dbOneSelector, q string, args ...interface{}) (core.SignedCertificateTimestamp, error) { var model core.SignedCertificateTimestamp err := s.SelectOne( &model, "SELECT id, sctVersion, logID, timestamp, extensions, signature, certificateSerial, LockCol FROM sctReceipts "+q, args..., ) re...
go
{ "resource": "" }
q31182
SelectCertificate
train
func SelectCertificate(s dbOneSelector, q string, args ...interface{}) (core.Certificate, error) { var model core.Certificate err := s.SelectOne( &model, "SELECT "+certFields+" FROM certificates "+q, args..., ) return model, err }
go
{ "resource": "" }
q31183
SelectCertificates
train
func SelectCertificates(s dbSelector, q string, args map[string]interface{}) ([]core.Certificate, error) { var models []core.Certificate _, err := s.Select( &models, "SELECT "+certFields+" FROM certificates "+q, args) return models, err }
go
{ "resource": "" }
q31184
SelectCertificateStatus
train
func SelectCertificateStatus(s dbOneSelector, q string, args ...interface{}) (certStatusModel, error) { var model certStatusModel err := s.SelectOne( &model, "SELECT "+certStatusFields+" FROM certificateStatus "+q, args..., ) return model, err }
go
{ "resource": "" }
q31185
SelectCertificateStatuses
train
func SelectCertificateStatuses(s dbSelector, q string, args ...interface{}) ([]core.CertificateStatus, error) { var models []core.CertificateStatus _, err := s.Select( &models, "SELECT "+certStatusFields+" FROM certificateStatus "+q, args..., ) return models, err }
go
{ "resource": "" }
q31186
registrationToModel
train
func registrationToModel(r *core.Registration) (*regModel, error) { key, err := json.Marshal(r.Key) if err != nil { return nil, err } sha, err := core.KeyDigest(r.Key) if err != nil { return nil, err } if r.InitialIP == nil { return nil, fmt.Errorf("initialIP was nil") } if r.Contact == nil { r.Contac...
go
{ "resource": "" }
q31187
hasMultipleNonPendingChallenges
train
func hasMultipleNonPendingChallenges(challenges []*corepb.Challenge) bool { nonPending := false for _, c := range challenges { if *c.Status == string(core.StatusValid) || *c.Status == string(core.StatusInvalid) { if !nonPending { nonPending = true } else { return true } } } return false }
go
{ "resource": "" }
q31188
observeLatency
train
func (si *serverInterceptor) observeLatency(clientReqTime string) error { // Convert the metadata request time into an int64 reqTimeUnixNanos, err := strconv.ParseInt(clientReqTime, 10, 64) if err != nil { return berrors.InternalServerError("grpc metadata had illegal %s value: %q - %s", clientRequestTimeKey, cl...
go
{ "resource": "" }
q31189
ecArgs
train
func ecArgs(label string, curve *elliptic.CurveParams, keyID []byte) generateArgs { encodedCurve := curveToOIDDER[curve.Name] log.Printf("\tEncoded curve parameters for %s: %X\n", curve.Params().Name, encodedCurve) return generateArgs{ mechanism: []*pkcs11.Mechanism{ pkcs11.NewMechanism(pkcs11.CKM_EC_KEY_PAIR_G...
go
{ "resource": "" }
q31190
ecPub
train
func ecPub( ctx pkcs11helpers.PKCtx, session pkcs11.SessionHandle, object pkcs11.ObjectHandle, expectedCurve *elliptic.CurveParams, ) (*ecdsa.PublicKey, error) { pubKey, err := pkcs11helpers.GetECDSAPublicKey(ctx, session, object) if err != nil { return nil, err } if pubKey.Curve != expectedCurve { return n...
go
{ "resource": "" }
q31191
ecVerify
train
func ecVerify(ctx pkcs11helpers.PKCtx, session pkcs11.SessionHandle, object pkcs11.ObjectHandle, pub *ecdsa.PublicKey) error { nonce, err := getRandomBytes(ctx, session) if err != nil { return fmt.Errorf("failed to construct nonce: %s", err) } log.Printf("\tConstructed nonce: %d (%X)\n", big.NewInt(0).SetBytes(no...
go
{ "resource": "" }
q31192
ecGenerate
train
func ecGenerate(ctx pkcs11helpers.PKCtx, session pkcs11.SessionHandle, label, curveStr string) (*ecdsa.PublicKey, error) { curve, present := stringToCurve[curveStr] if !present { return nil, fmt.Errorf("curve %q not supported", curveStr) } keyID := make([]byte, 4) _, err := rand.Read(keyID) if err != nil { re...
go
{ "resource": "" }
q31193
DialContext
train
func (d *preresolvedDialer) DialContext( ctx context.Context, network, origAddr string) (net.Conn, error) { deadline, ok := ctx.Deadline() if !ok { // Shouldn't happen: All requests should have a deadline by this point. deadline = time.Now().Add(100 * time.Second) } else { // Set the context deadline slight...
go
{ "resource": "" }
q31194
httpTransport
train
func httpTransport(df dialerFunc) *http.Transport { return &http.Transport{ DialContext: df, // We are talking to a client that does not yet have a certificate, // so we accept a temporary, invalid one. TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // We don't expect to make multiple requests to a ...
go
{ "resource": "" }
q31195
newHTTPValidationTarget
train
func (va *ValidationAuthorityImpl) newHTTPValidationTarget( ctx context.Context, host string, port int, path string, query string) (*httpValidationTarget, error) { // Resolve IP addresses for the hostname addrs, err := va.getAddrs(ctx, host) if err != nil { // Convert the error into a ConnectionFailureError s...
go
{ "resource": "" }
q31196
extractRequestTarget
train
func (va *ValidationAuthorityImpl) extractRequestTarget(req *http.Request) (string, int, error) { // A nil request is certainly not a valid redirect and has no port to extract. if req == nil { return "", 0, fmt.Errorf("redirect HTTP request was nil") } reqScheme := req.URL.Scheme // The redirect request must u...
go
{ "resource": "" }
q31197
setupHTTPValidation
train
func (va *ValidationAuthorityImpl) setupHTTPValidation( ctx context.Context, reqURL string, target *httpValidationTarget) (*preresolvedDialer, core.ValidationRecord, error) { if reqURL == "" { return nil, core.ValidationRecord{}, fmt.Errorf("reqURL can not be nil") } if target == nil { // This is the on...
go
{ "resource": "" }
q31198
fetchHTTP
train
func (va *ValidationAuthorityImpl) fetchHTTP( ctx context.Context, host string, path string) ([]byte, []core.ValidationRecord, *probs.ProblemDetails) { body, records, err := va.processHTTPValidation(ctx, host, path) if err != nil { // Use detailedError to convert the error into a problem return body, records, ...
go
{ "resource": "" }
q31199
StatsAndLogging
train
func StatsAndLogging(logConf SyslogConfig, addr string) (metrics.Scope, blog.Logger) { logger := NewLogger(logConf) scope := newScope(addr, logger) return scope, logger }
go
{ "resource": "" }