-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normally the Sigma Model needs to specify the field mappings into the event. This makes it difficult to write rules targeting fields which are present in the event but have no mapping yet. It also means most mappings are fairly obvious. For example consider the event: { ... "EventData": { "ImageFileName": "WmiPrvSE.exe" } } To refer to the ImageFileName we would need a field mapping like: ImageFileName = x=>x.EventData.ImageFileName However in a Sigma rule it is just as easy to specify: detection: filename_condition: EventData.ImageFileName|contains: WmiPrvSE This is both clear and unambigious. This PR allows field names to have "." and refer directly to the event itself.
- Loading branch information
Showing
13 changed files
with
189 additions
and
27 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
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
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
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,49 @@ | ||
package evaluator | ||
|
||
import ( | ||
"sync" | ||
|
||
"www.velocidex.com/golang/velociraptor/utils" | ||
"www.velocidex.com/golang/vfilter" | ||
) | ||
|
||
type FieldMappingRecord struct { | ||
Name string | ||
Lambda *vfilter.Lambda | ||
} | ||
|
||
type FieldMappingResolver struct { | ||
mappings map[string]FieldMappingRecord | ||
mu sync.Mutex | ||
} | ||
|
||
func (self *FieldMappingResolver) Get(name string) (*vfilter.Lambda, error) { | ||
self.mu.Lock() | ||
defer self.mu.Unlock() | ||
|
||
res, pres := self.mappings[name] | ||
if !pres { | ||
return nil, utils.NotFoundError | ||
} | ||
return res.Lambda, nil | ||
} | ||
|
||
func (self *FieldMappingResolver) Len() int { | ||
self.mu.Lock() | ||
defer self.mu.Unlock() | ||
|
||
return len(self.mappings) | ||
} | ||
|
||
func (self *FieldMappingResolver) Set(name string, lambda *vfilter.Lambda) { | ||
self.mu.Lock() | ||
defer self.mu.Unlock() | ||
|
||
self.mappings[name] = FieldMappingRecord{Name: name, Lambda: lambda} | ||
} | ||
|
||
func NewFieldMappingResolver() *FieldMappingResolver { | ||
return &FieldMappingResolver{ | ||
mappings: make(map[string]FieldMappingRecord), | ||
} | ||
} |
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
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