-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: The delay() plugin could lose events (#3973)
If the query was terminated the delay() plugin could lose events. Also the previous code could crash with "send on close channel"
- Loading branch information
Showing
6 changed files
with
113 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Queries: | ||
- SELECT * FROM delay(query={ SELECT "Hello" FROM scope() }, delay=1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT * FROM delay(query={ SELECT "Hello" FROM scope() }, delay=1)[ | ||
{ | ||
"\"Hello\"": "Hello" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package sigma | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"os" | ||
|
||
"github.com/Velocidex/ordereddict" | ||
"www.velocidex.com/golang/velociraptor/json" | ||
vql_subsystem "www.velocidex.com/golang/velociraptor/vql" | ||
"www.velocidex.com/golang/velociraptor/vtesting/assert" | ||
"www.velocidex.com/golang/vfilter" | ||
|
||
// For items plugin | ||
_ "www.velocidex.com/golang/velociraptor/vql/common" | ||
_ "www.velocidex.com/golang/velociraptor/vql/golang" | ||
) | ||
|
||
func (self *SigmaTestSuite) TestLogSourceIterator() { | ||
ctx := context.Background() | ||
|
||
scope := vql_subsystem.MakeScope() | ||
scope.SetLogger(log.New(os.Stdout, "", 0)) | ||
defer scope.Close() | ||
|
||
queries := []string{ | ||
"LET X <= sigma_log_sources(`*/windows/application`={SELECT * FROM info()})", | ||
` | ||
SELECT * FROM foreach( | ||
row={ | ||
SELECT _value FROM items(item=X) | ||
}, query={ | ||
SELECT typeof(a=_value), _value FROM scope() | ||
}) | ||
`, | ||
} | ||
|
||
results := ordereddict.NewDict() | ||
for _, query := range queries { | ||
rows := []vfilter.Row{} | ||
vql, err := vfilter.Parse(query) | ||
assert.NoError(self.T(), err) | ||
|
||
for row := range vql.Eval(ctx, scope) { | ||
rows = append(rows, row) | ||
} | ||
results.Set(query, rows) | ||
} | ||
|
||
json.Dump(results) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters