mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-17 19:25:26 +00:00
removed trailing comma from the jsonl exporter (#5861)
* removed trailing comma from the jsonl exporter * adding the O_TRUNC flag when opening the file to explicitly indicate that the file should be truncated if it exists.
This commit is contained in:
parent
1f985459b8
commit
557b4fba38
@ -70,7 +70,7 @@ func (exporter *Exporter) WriteRows() error {
|
|||||||
var err error
|
var err error
|
||||||
if exporter.outputFile == nil {
|
if exporter.outputFile == nil {
|
||||||
// Open the JSONL file for writing and create it if it doesn't exist
|
// Open the JSONL file for writing and create it if it doesn't exist
|
||||||
exporter.outputFile, err = os.OpenFile(exporter.options.File, os.O_WRONLY|os.O_CREATE, 0644)
|
exporter.outputFile, err = os.OpenFile(exporter.options.File, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to create JSONL file")
|
return errors.Wrap(err, "failed to create JSONL file")
|
||||||
}
|
}
|
||||||
@ -86,8 +86,7 @@ func (exporter *Exporter) WriteRows() error {
|
|||||||
return errors.Wrap(err, "failed to generate row for JSONL report")
|
return errors.Wrap(err, "failed to generate row for JSONL report")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a trailing newline to the JSON byte array to confirm with the JSONL format
|
obj = append(obj, '\n')
|
||||||
obj = append(obj, ',', '\n')
|
|
||||||
|
|
||||||
// Attempt to append the JSON line to file specified in options.JSONLExport
|
// Attempt to append the JSON line to file specified in options.JSONLExport
|
||||||
if _, err = exporter.outputFile.Write(obj); err != nil {
|
if _, err = exporter.outputFile.Write(obj); err != nil {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user