mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-22 21:05:24 +00:00
Fix panic error due to file already closed in stats mode (#5774)
This commit is contained in:
parent
b57d086afc
commit
97403c203e
@ -392,6 +392,9 @@ func (r *Runner) Close() {
|
|||||||
if r.tmpDir != "" {
|
if r.tmpDir != "" {
|
||||||
_ = os.RemoveAll(r.tmpDir)
|
_ = os.RemoveAll(r.tmpDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//this is no-op unless nuclei is built with stats build tag
|
||||||
|
events.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
// setupPDCPUpload sets up the PDCP upload writer
|
// setupPDCPUpload sets up the PDCP upload writer
|
||||||
|
|||||||
@ -9,3 +9,6 @@ func AddScanEvent(event ScanEvent) {
|
|||||||
|
|
||||||
func InitWithConfig(config *ScanConfig, statsDirectory string) {
|
func InitWithConfig(config *ScanConfig, statsDirectory string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Close() {
|
||||||
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ type ScanStatsWorker struct {
|
|||||||
config *ScanConfig
|
config *ScanConfig
|
||||||
m *sync.Mutex
|
m *sync.Mutex
|
||||||
directory string
|
directory string
|
||||||
|
file *os.File
|
||||||
enc *json.Encoder
|
enc *json.Encoder
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ func (s *ScanStatsWorker) initEventsFile() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
s.file = f
|
||||||
s.enc = json.NewEncoder(f)
|
s.enc = json.NewEncoder(f)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -79,3 +80,22 @@ func AddScanEvent(event ScanEvent) {
|
|||||||
}
|
}
|
||||||
defaultWorker.AddScanEvent(event)
|
defaultWorker.AddScanEvent(event)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close closes the file associated with the worker
|
||||||
|
func (s *ScanStatsWorker) Close() {
|
||||||
|
s.m.Lock()
|
||||||
|
defer s.m.Unlock()
|
||||||
|
|
||||||
|
if s.file != nil {
|
||||||
|
_ = s.file.Close()
|
||||||
|
s.file = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close closes the file associated with the worker
|
||||||
|
func Close() {
|
||||||
|
if defaultWorker == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defaultWorker.Close()
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user