forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintain row count per query. (Velocidex#2113)
This fixes a bug where row count was not consistent for aritfacts with multiple sources because the row count was maintained for each request but a request may contain multiple queries. This only affects CloudVelo
- Loading branch information
Showing
4 changed files
with
45 additions
and
8 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,36 @@ | ||
package actions | ||
|
||
import ( | ||
"sync" | ||
|
||
actions_proto "www.velocidex.com/golang/velociraptor/actions/proto" | ||
) | ||
|
||
type QueryTracker struct { | ||
mu sync.Mutex | ||
|
||
queriesToStartRow map[string]uint64 | ||
} | ||
|
||
func (self *QueryTracker) GetStartRow(query *actions_proto.VQLRequest) uint64 { | ||
self.mu.Lock() | ||
defer self.mu.Unlock() | ||
|
||
start_row, _ := self.queriesToStartRow[query.Name] | ||
return start_row | ||
} | ||
|
||
func (self *QueryTracker) AddRows( | ||
query *actions_proto.VQLRequest, count uint64) { | ||
self.mu.Lock() | ||
defer self.mu.Unlock() | ||
|
||
start_row, _ := self.queriesToStartRow[query.Name] | ||
self.queriesToStartRow[query.Name] = start_row + count | ||
} | ||
|
||
func NewQueryTracker() *QueryTracker { | ||
return &QueryTracker{ | ||
queriesToStartRow: make(map[string]uint64), | ||
} | ||
} |
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