id
stringlengths
2
7
text
stringlengths
17
51.2k
title
stringclasses
1 value
c5500
{ logger.Error("Failed to create log directory", "err", err) } } var hundler logger.Handler if _, err := os.Stat(logDir); err == nil { logPath := filepath.Join(logDir, "cve-dictionary.log") hundler = logger.MultiHandler( logger.Must.FileHandler(logPath, logFormat), lvlHundler, ) } else { hundler...
c5501
logger.Crit(fmt.Sprintf(format, args...)) }
c5502
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{ Output: f, })) // Routes e.GET("/health", health()) e.GET("/cves/:id", getCve(driver)) e.POST("/cpes", getCveByCpeName(driver)) bindURL := fmt.Sprintf("%s:%s", config.Conf.Bind, config.Conf.Port) log.Infof("Listening on %s", bindURL) e.Start(bind...
c5503
(%s).", driver.Name()) if err = driver.OpenDB(dbType, dbpath, debugSQL); err != nil { return } return }
c5504
); result.Err() != nil { return fmt.Errorf("Failed to ZAdd cpe. err: %s", result.Err()) } } var jc []byte if jc, err = json.Marshal(cpes); err != nil { return fmt.Errorf("Failed to marshal json. err: %s", err) } if result := pipe.HSet(cpeHashKeyPrefix+c.CveID, "Jvn", string(jc)); result.Err...
c5505
ok := result.Val()[url]; ok { if err := json.Unmarshal([]byte(s), meta); err != nil { return nil, err } return meta, nil } return meta, nil }
c5506
fmt.Errorf("Failed to HSet META. err: %s", result.Err()) } if _, err := pipe.Exec(); err != nil { return fmt.Errorf("Failed to exec pipeline. err: %s", err) } return nil }
c5507
&& f.Hash == f.LatestHash }
c5508
&& f.Hash != f.LatestHash }
c5509
color.New(color.FgRed, color.Bold).SprintFunc() return red("Out-Dated") } else if f.UpToDate() { return color.GreenString("Up-to-Date") } return "Unknown" }
c5510
nil case jvn: if strings.HasSuffix(f.URL, "jvndb.rdf") { return "modified", true, nil } else if strings.HasSuffix(f.URL, "jvndb_new.rdf") { return "recent", true, nil } else { return strings.TrimSuffix( strings.Split(f.URL, "jvndb_")[1], ".rdf"), true, nil } default: return "", false, fmt.Erro...
c5511
return []string{ f.color(f.source()), f.color(y), f.StatusForStdout(), f.color(fetched), f.color(latest), } }
c5512
nil, fmt.Errorf( "Failed to unmarshal. url: %s, err: %s", res.URL, err) } for _, item := range nvd.CveItems { cve, err := convertToModel(&item) if err != nil { return nil, fmt.Errorf("Failed to convert to model. cve: %s, err: %s", item.Cve.CveDataMeta.ID, err) } cves = append(cves, *cv...
c5513
return c.register(false, fns...) }
c5514
return c.register(true, fns...) }
c5515
m := newMigration(version) filePath := filepath.Join(dir, fileName) if strings.HasSuffix(fileName, ".up.sql") { if m.Up != nil { return fmt.Errorf("migration=%d already has Up func", version) } m.UpTx = strings.HasSuffix(fileName, ".tx.up.sql") m.Up = newSQLMigration(filePath) continue } ...
c5516
if r.total > 0 { fmt.Fprintf(&buf, "Total: %4d ms\n", int(r.total/time.Millisecond)) } else { fmt.Fprintf(&buf, "Total: %4s ms\n", "-") } io.WriteString(s, buf.String()) return } fallthrough case 's', 'q': d := r.durations() list := make([]string, 0, len(d)) for k...
c5517
return withClientTrace(ctx, r) }
c5518
} else if w.isAllowedPerRobotsPolicies(ctx.url) { w.requestURL(ctx, ctx.HeadBeforeGet) } else { // Must still notify Crawler that this URL was processed, although not visited w.opts.Extender.Disallowed(ctx) w.sendResponse(ctx, false, nil, false) } // No need to check for idle timeo...
c5519
ok := w.robotsGroup.Test(u.Path) if !ok { w.logFunc(LogIgnored, "ignored on robots.txt policy: %s", u.String()) } return ok } // No robots.txt = everything is allowed return true }
c5520
} else { // Error based on status code received w.opts.Extender.Error(newCrawlErrorMessage(ctx, res.Status, CekHttpStatusCode)) w.logFunc(LogError, "ERROR status code for %s: %s", ctx.url, res.Status) } w.sendResponse(ctx, visited, harvested, false) } }
c5521
:= w.fetchURL(ctx, w.opts.UserAgent, false); ok { // Close the body on function end defer res.Body.Close() w.robotsGroup = w.getRobotsTxtGroup(ctx, nil, res) } }
c5522
be parsed, will return nil, which will allow access by default. // Reasonable, since by default no robots.txt means full access, so invalid // robots.txt is similar behavior. if e != nil { w.opts.Extender.Error(newCrawlError(nil, e, CekParseRobots)) w.logFunc(LogError, "ERROR parsing robots.txt for host %s: %s"...
c5523
w.opts.Extender.ComputeDelay(w.host, &DelayInfo{ w.opts.CrawlDelay, robDelay, w.lastCrawlDelay, }, w.lastFetch) w.logFunc(LogInfo, "using crawl-delay: %v", w.lastCrawlDelay) }
c5524
set to nil w.lastFetch = nil if !silent { // Notify error w.opts.Extender.Error(newCrawlError(ctx, e, CekFetch)) w.logFunc(LogError, "ERROR fetching %s: %s", ctx.url, e) } // Return from this URL crawl w.sendResponse(ctx, false, nil, false) return nil, false } // Get the fetch dura...
c5525
w.logFunc(LogInfo, "ignoring send response, will stop.") return default: // Nothing, just continue... } // No stop signal, send the response res := &workerResponse{ ctx, visited, harvested, w.host, idleDeath, } w.push <- res } }
c5526
// Links were not processed by the visitor, so process links if doc != nil { harvested = w.processLinks(doc) } else { w.opts.Extender.Error(newCrawlErrorMessage(ctx, "No goquery document to process links.", CekProcessLinks)) w.logFunc(LogError, "ERROR processing links %s", ctx.url) } } // Notify that...
c5527
to parse anyway) if len(s) > 0 && !strings.HasPrefix(s, "#") { if parsed, e := url.Parse(s); e == nil { parsed = doc.Url.ResolveReference(parsed) result = append(result, parsed) } else { w.logFunc(LogIgnored, "ignore on unparsable policy %s: %s", s, e.Error()) } } } return }
c5528
if logFlags&msgLevel == msgLevel { log.Println(msg) } }
c5529
if di.RobotsDelay > 0 { return di.RobotsDelay } return di.OptsDelay }
c5530
doc *goquery.Document) (harvested interface{}, findLinks bool) { return nil, true }
c5531
new(Crawler) ret.Options = opts return ret }
c5532
// Create a shiny new WaitGroup c.wg = new(sync.WaitGroup) // Initialize the visits fields c.visited = make(map[string]struct{}, l) c.pushPopRefCount, c.visits = 0, 0 // Create the workers map and the push channel (the channel used by workers // to communicate back to the crawler) c.stop = make(chan struct{})...
c5533
c.logFunc(LogInfo, "extender is not a struct, cannot set the enqueue channel") return } ec := el.FieldByName("EnqueueChan") if !ec.IsValid() { c.logFunc(LogInfo, "extender.EnqueueChan does not exist, cannot set the enqueue channel") return } t := ec.Type() if t.Kind() != reflect.Chan || t.ChanDir() != re...
c5534
c.Options.LogFlags, i), opts: c.Options, } // Increment wait group count c.wg.Add(1) // Launch worker go w.run() c.logFunc(LogInfo, "worker %d launched for host %s", i, w.host) c.workers[w.host] = w return w }
c5535
} // Otherwise, check if the URL is from one of the seed hosts _, ok := c.hosts[ctx.normalizedURL.Host] return ok }
c5536
host of the normalized URL w, ok := c.workers[ctx.normalizedURL.Host] if !ok { // No worker exists for this host, launch a new one w = c.launchWorker(ctx) // Automatically enqueue the robots.txt URL as first in line if robCtx, e := ctx.getRobotsURLCtx(); e != nil { c.Options.Extender.Error(n...
c5537
STOP signals...") close(c.stop) return nil } select { case res := <-c.push: // Received a response, check if it contains URLs to enqueue if res.visited { c.visits++ if c.Options.MaxVisits > 0 && c.visits >= c.Options.MaxVisits { // Limit reached, request workers to stop c.logFunc(L...
c5538
"error when manually stopping crawler: %s", err) } }() // this channel may be closed already close(c.stop) }
c5539
ce.Err != nil { return ce.Err.Error() } return ce.msg }
c5540
return &CrawlError{ctx, e, kind, ""} }
c5541
return &CrawlError{ctx, nil, kind, msg} }
c5542
{ normalizedSrc = &url.URL{} *normalizedSrc = *uc.normalizedURL } rawDst := &url.URL{} *rawDst = *dst purell.NormalizeURL(dst, normFlags) return &URLContext{ HeadBeforeGet: uc.HeadBeforeGet, State: uc.State, url: rawDst, normalizedURL: dst, sourceURL: ...
c5543
DefaultCrawlDelay, DefaultIdleTTL, true, false, DefaultNormalizationFlags, LogError, ext, } }
c5544
'z' { if capNext { n += strings.ToUpper(string(v)) } else { n += string(v) } } if v == '_' || v == ' ' || v == '-' { capNext = true } else { capNext = false } } return n }
c5545
s = strings.ToLower(string(r)) + s[1:] } return toCamelInitCase(s, false) }
c5546
s.Command(name, a...).Run() }
c5547
err != nil { return } return json.NewDecoder(bufrw).Decode(data) }
c5548
err != nil { return } return xml.NewDecoder(bufrw).Decode(data) }
c5549
w: w, SampleRate: sampleRate, BitDepth: bitDepth, NumChans: numChans, WavAudioFormat: audioFormat, } }
c5550
binary.Write(e.w, binary.LittleEndian, src) }
c5551
binary.Write(e.w, binary.BigEndian, src) }
c5552
a temporary chunksize e.pcmChunkSizePos = e.WrittenBytes if err := e.AddLE(uint32(42)); err != nil { return fmt.Errorf("%v when writing wav data chunk size header", err) } } e.frames++ return e.AddLE(value) }
c5553
copy(c.ID[:], scratch[:4]) if err := binary.Read(r, binary.LittleEndian, &c.Position); err != nil { return err } if _, err = r.Read(scratch); err != nil { return fmt.Errorf("failed to read the data chunk id") } copy(c.DataChunkID[:], scratch[:4]) if err := binary.Read(r, binary.Litt...
c5554
r, parser: riff.New(r), } }
c5555
return d.r.Seek(offset, whence) }
c5556
return nil } return d.err }
c5557
nil || d.err == io.EOF { return true } return false }
c5558
DecodeSamplerChunk(d, chunk); err != nil { if err != io.EOF { d.err = err } } case CIDCue: if err = DecodeCueChunk(d, chunk); err != nil { if err != io.EOF { d.err = err } } default: // fmt.Println(string(chunk.ID[:])) chunk.Drain() } } }
c5559
the duration of a nil pointer") } return d.parser.Duration() }
c5560
footer // because so many players don't support that chunk properly // it is recommended to have it at the end of the file. DecodeListChunk(d, chunk) // unexpected chunk order, might be a bext chunk rewindBytes += int64(chunk.Size) + 8 } else if chunk.ID == CIDSmpl { DecodeSamplerChunk(d, chunk) ...
c5561
nil case 3: return func(s []byte) float64 { var output int32 output |= int32(s[2]) << 0 output |= int32(s[1]) << 8 output |= int32(s[0]) << 16 return float64(output) }, nil case 4: // TODO: fix the float64 conversion (current int implementation) return func(s []byte) float64 { return float6...
c5562
Pdiff((*sbuf)(&desc), a, b) return desc }
c5563
Pdiff(&wprintfer{w}, a, b) }
c5564
diffPrinter{w: p}.diff(reflect.ValueOf(a), reflect.ValueOf(b)) }
c5565
Pdiff(&logprintfer{l}, a, b) }
c5566
return true case reflect.Chan, reflect.UnsafePointer, reflect.Ptr: a, b := av.Pointer(), bv.Pointer() return a == b case reflect.Interface: return keyEqual(av.Elem(), bv.Elem()) case reflect.String: a, b := av.String(), bv.String() return a == b case reflect.Struct: for i := 0; i < av.NumField(); i++ ...
c5567
return Errorf(token.Pos, format, args...) }
c5568
:= scanner.Scan(v, pos) return parser.Parse(ch) }
c5569
== nil { p.peeked = <-p.ch } return p.peeked }
c5570
is reached. if token.Type != EOF { p.peeked = nil } return token }
c5571
Peek() or Read() after we've closed. p.peeked = &Token{ Type: EOF, Content: "", } }
c5572
} } if len(exprs) == 0 { // If we have no parts at all then the input must've // been an empty string. exprs = append(exprs, &ast.LiteralNode{ Value: "", Typex: ast.TypeString, Posx: startPos, }) } // As a special case, if our "Output" contains only one expression // and it's a literal string ...
c5573
`unfinished backslash escape sequence`, ) } escapeType := raw[i+1] switch escapeType { case '\\': // skip over the second slash i++ case 'n': b = '\n' i++ case '"': b = '"' i++ default: return "", Errorf( ast.Pos{ Column: tok.Pos.Column + utf8.RuneCount(r...
c5574
:= p.peeker.Peek() var newOperator ast.ArithmeticOp var ok bool if newOperator, ok = thisLevel[next.Type]; !ok { break } // Are we extending an expression started on // the previous iteration? if operator != ast.ArithmeticOpInvalid { lhs = &ast.Arithmetic{ Op: operator, Exprs: []ast.Nod...
c5575
ast.TypeFloat: "__builtin_StringToFloat", ast.TypeBool: "__builtin_StringToBool", }, ast.TypeBool: { ast.TypeString: "__builtin_BoolToString", }, } // Build our own semantic checks that we always run tv := &TypeCheck{Scope: scope, Implicit: implicitMap} ic := &IdentifierCheck{Scope: scope} // Bui...
c5576
case *ast.VariableAccess: return &evalVariableAccess{n}, nil default: en, ok := n.(EvalNode) if !ok { return nil, fmt.Errorf("node doesn't support evaluation: %#v", raw) } return en, nil } }
c5577
hilType = TypeString default: return nil, fmt.Errorf("unsupported literal node type: %T", value) } return &LiteralNode{ Value: value, Typex: hilType, Posx: pos, }, nil }
c5578
{ node, err := NewLiteralNode(value, pos) if err != nil { panic(err) } return node }
c5579
n.Typex, Value: n.Value, }) }
c5580
:= range v.Value.(map[string]Variable) { if IsUnknown(el) { return true } } default: } // Not a container type or survive the above checks return false }
c5581
return reflectwalk.Walk(v, walker) }
c5582
{ ch := make(chan *Token) go scan(s, ch, startPos) return ch }
c5583
break } // If we reach a star, it must be between periods to be part // of the same identifier. if nextRune == '*' && s[byteLen-1] != '.' { break } // If our previous character was a star, then the current must // be period. Otherwise, undo that and exit. if byteLen > 0 && s[byteLen-1] == '*' && n...
c5584
default: err = fmt.Errorf("Unknown type: %s", v.Kind()) } result.Value = v return }
c5585
fmt.Sprintf("{Variable (%s): %+v}", v.Type, v.Value) }
c5586
&Avx512Digest{uid: uid, a512srv: a512srv} }
c5587
true} d.nx = 0 d.len = 0 d.final = false }
c5588
p = p[n:] } if len(p) >= chunk { n := len(p) &^ (chunk - 1) d.a512srv.blocksCh <- blockInput{uid: d.uid, msg: p[:n]} p = p[n:] } if len(p) > 0 { d.nx = copy(d.x[:], p) } return }
c5589
{ tmp[i] = byte(len >> (56 - 8*i)) } trail = append(trail, tmp[0:8]...) sumCh := make(chan [Size]byte) d.a512srv.blocksCh <- blockInput{uid: d.uid, msg: trail, final: true, sumCh: sumCh} d.result = <-sumCh d.final = true return append(in, d.result[:]...) }
c5590
for i := 0; i < 16; i++ { output[i] = getDigest(i, digests[:]) } return output }
c5591
a single thread for reading from the input channel go a512srv.Process() return a512srv }
c5592
{ // fmt.Println("Invoking Blocks() while FULL: ") a512srv.blocks() } // TODO: test with larger timeout case <-time.After(1 * time.Microsecond): for _, lane := range a512srv.lanes { if lane.block != nil { // check if there is any input to process // fmt.Println("Invoking Blocks() on TIMEOU...
c5593
a512srv.lanes[i] = Avx512LaneInfo{} // clear message a512srv.totalIn-- } } } // Delete entry from hash map delete(a512srv.digests, uid) }
c5594
outputCh := a512srv.lanes[i].uid, a512srv.lanes[i].outputCh a512srv.digests[uid] = outputs[i] a512srv.lanes[i] = Avx512LaneInfo{} if outputCh != nil { // Send back result outputCh <- outputs[i] delete(a512srv.digests, uid) // Delete entry from hashmap } } return }
c5595
blockInput{uid: uid, msg: p, final: true, sumCh: sumCh} return <-sumCh }
c5596
d.h[5] = init5 d.h[6] = init6 d.h[7] = init7 d.nx = 0 d.len = 0 }
c5597
to the standard golang implementation // if no features were found. return sha256.New() }
c5598
d.Reset() d.Write(data) result = d.checkSum() return }
c5599
*d hash := d0.checkSum() return append(in, hash[:]...) }