| OLD | NEW |
| 1 package aggregator | 1 package aggregator |
| 2 | 2 |
| 3 import ( | 3 import ( |
| 4 "bytes" | 4 "bytes" |
| 5 "crypto/sha1" | 5 "crypto/sha1" |
| 6 "fmt" | 6 "fmt" |
| 7 "io" | 7 "io" |
| 8 "io/ioutil" | 8 "io/ioutil" |
| 9 "os" | 9 "os" |
| 10 "path/filepath" | 10 "path/filepath" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 354 } |
| 355 return badFuzzPaths, nil | 355 return badFuzzPaths, nil |
| 356 } | 356 } |
| 357 | 357 |
| 358 // waitForAnalysis waits for files that need to be analyzed (from forAnalysis) a
nd makes a copy of | 358 // waitForAnalysis waits for files that need to be analyzed (from forAnalysis) a
nd makes a copy of |
| 359 // them in agg.fuzzPath with their hash as a file name. It then analyzes it usin
g the supplied | 359 // them in agg.fuzzPath with their hash as a file name. It then analyzes it usin
g the supplied |
| 360 // AnalysisPackage and then signals the results should be uploaded. If any unrec
overable errors | 360 // AnalysisPackage and then signals the results should be uploaded. If any unrec
overable errors |
| 361 // happen, this method terminates. | 361 // happen, this method terminates. |
| 362 func (agg *Aggregator) waitForAnalysis(identifier int) { | 362 func (agg *Aggregator) waitForAnalysis(identifier int) { |
| 363 defer agg.aggregationWaitGroup.Done() | 363 defer agg.aggregationWaitGroup.Done() |
| 364 » defer metrics2.NewCounter("analysis-process-count", nil).Dec(int64(1)) | 364 » defer metrics2.GetCounter("analysis-process-count", nil).Dec(int64(1)) |
| 365 glog.Infof("Spawning analyzer %d", identifier) | 365 glog.Infof("Spawning analyzer %d", identifier) |
| 366 | 366 |
| 367 // our own unique working folder | 367 // our own unique working folder |
| 368 executableDir := filepath.Join(config.Aggregator.ExecutablePath, fmt.Spr
intf("analyzer%d", identifier)) | 368 executableDir := filepath.Join(config.Aggregator.ExecutablePath, fmt.Spr
intf("analyzer%d", identifier)) |
| 369 if err := setupAnalysis(executableDir); err != nil { | 369 if err := setupAnalysis(executableDir); err != nil { |
| 370 glog.Errorf("Analyzer %d terminated due to error: %s", identifie
r, err) | 370 glog.Errorf("Analyzer %d terminated due to error: %s", identifie
r, err) |
| 371 return | 371 return |
| 372 } | 372 } |
| 373 for { | 373 for { |
| 374 select { | 374 select { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 // Append adds all of the strings to the underlying slice and sorts it | 532 // Append adds all of the strings to the underlying slice and sorts it |
| 533 func (s *SortedStringSlice) Append(strs []string) { | 533 func (s *SortedStringSlice) Append(strs []string) { |
| 534 s.strings = append(s.strings, strs...) | 534 s.strings = append(s.strings, strs...) |
| 535 s.strings.Sort() | 535 s.strings.Sort() |
| 536 } | 536 } |
| 537 | 537 |
| 538 // waitForUploads waits for uploadPackages to be sent through the forUpload chan
nel and then uploads | 538 // waitForUploads waits for uploadPackages to be sent through the forUpload chan
nel and then uploads |
| 539 // them. If any unrecoverable errors happen, this method terminates. | 539 // them. If any unrecoverable errors happen, this method terminates. |
| 540 func (agg *Aggregator) waitForUploads(identifier int) { | 540 func (agg *Aggregator) waitForUploads(identifier int) { |
| 541 defer agg.aggregationWaitGroup.Done() | 541 defer agg.aggregationWaitGroup.Done() |
| 542 » defer metrics2.NewCounter("upload-process-count", nil).Dec(int64(1)) | 542 » defer metrics2.GetCounter("upload-process-count", nil).Dec(int64(1)) |
| 543 glog.Infof("Spawning uploader %d", identifier) | 543 glog.Infof("Spawning uploader %d", identifier) |
| 544 for { | 544 for { |
| 545 select { | 545 select { |
| 546 case p := <-agg.forUpload: | 546 case p := <-agg.forUpload: |
| 547 atomic.AddInt64(&agg.uploadCount, int64(1)) | 547 atomic.AddInt64(&agg.uploadCount, int64(1)) |
| 548 if !agg.UploadGreyFuzzes && p.FuzzType == GREY_FUZZ { | 548 if !agg.UploadGreyFuzzes && p.FuzzType == GREY_FUZZ { |
| 549 glog.Infof("Skipping upload of grey fuzz %s", p.
Data.Name) | 549 glog.Infof("Skipping upload of grey fuzz %s", p.
Data.Name) |
| 550 // We are skipping the bugReport, so increment t
he counts. | 550 // We are skipping the bugReport, so increment t
he counts. |
| 551 atomic.AddInt64(&agg.bugReportCount, int64(1)) | 551 atomic.AddInt64(&agg.bugReportCount, int64(1)) |
| 552 continue | 552 continue |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 if agg.MakeBugOnBadFuzz && p.IsBadFuzz { | 671 if agg.MakeBugOnBadFuzz && p.IsBadFuzz { |
| 672 glog.Warningf("Should create bug for %s", p.FuzzName) | 672 glog.Warningf("Should create bug for %s", p.FuzzName) |
| 673 } | 673 } |
| 674 return nil | 674 return nil |
| 675 } | 675 } |
| 676 | 676 |
| 677 // monitorStatus sets up the monitoring routine, which reports how big the work
queues are and how | 677 // monitorStatus sets up the monitoring routine, which reports how big the work
queues are and how |
| 678 // many processes are up. | 678 // many processes are up. |
| 679 func (agg *Aggregator) monitorStatus(numAnalysisProcesses, numUploadProcesses in
t) { | 679 func (agg *Aggregator) monitorStatus(numAnalysisProcesses, numUploadProcesses in
t) { |
| 680 defer agg.monitoringWaitGroup.Done() | 680 defer agg.monitoringWaitGroup.Done() |
| 681 » analysisProcessCount := metrics2.NewCounter("analysis-process-count", ni
l) | 681 » analysisProcessCount := metrics2.GetCounter("analysis-process-count", ni
l) |
| 682 analysisProcessCount.Reset() | 682 analysisProcessCount.Reset() |
| 683 analysisProcessCount.Inc(int64(numAnalysisProcesses)) | 683 analysisProcessCount.Inc(int64(numAnalysisProcesses)) |
| 684 » uploadProcessCount := metrics2.NewCounter("upload-process-count", nil) | 684 » uploadProcessCount := metrics2.GetCounter("upload-process-count", nil) |
| 685 uploadProcessCount.Reset() | 685 uploadProcessCount.Reset() |
| 686 uploadProcessCount.Inc(int64(numUploadProcesses)) | 686 uploadProcessCount.Inc(int64(numUploadProcesses)) |
| 687 | 687 |
| 688 t := time.Tick(config.Aggregator.StatusPeriod) | 688 t := time.Tick(config.Aggregator.StatusPeriod) |
| 689 for { | 689 for { |
| 690 select { | 690 select { |
| 691 case <-agg.monitoringShutdown: | 691 case <-agg.monitoringShutdown: |
| 692 glog.Info("aggregator monitor got signal to shut down") | 692 glog.Info("aggregator monitor got signal to shut down") |
| 693 return | 693 return |
| 694 case <-t: | 694 case <-t: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 } | 780 } |
| 781 | 781 |
| 782 func (agg *Aggregator) ClearUploadedFuzzNames() { | 782 func (agg *Aggregator) ClearUploadedFuzzNames() { |
| 783 agg.greyNames = []string{} | 783 agg.greyNames = []string{} |
| 784 agg.badNames = []string{} | 784 agg.badNames = []string{} |
| 785 } | 785 } |
| 786 | 786 |
| 787 func (agg *Aggregator) UploadedFuzzNames() (bad, grey []string) { | 787 func (agg *Aggregator) UploadedFuzzNames() (bad, grey []string) { |
| 788 return agg.badNames, agg.greyNames | 788 return agg.badNames, agg.greyNames |
| 789 } | 789 } |
| OLD | NEW |