-
-
Notifications
You must be signed in to change notification settings - Fork 22
Fixing conditions with multiple underscores and adding a working example for reference #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AdrielVelazquez
wants to merge
8
commits into
bradleyjkemp:main
Choose a base branch
from
AdrielVelazquez:hack_week_tweaks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fd6e52b
Adding the running example
AdrielVelazquez b61982d
Adding the install path
AdrielVelazquez 55d2081
Updating the readme example
AdrielVelazquez 40048aa
Update condition_parser.go
AdrielVelazquez 36ebf57
Update README.md
bradleyjkemp 77d9e19
going to revert anyway
AdrielVelazquez b729495
Revert "going to revert anyway"
AdrielVelazquez 98a1c2f
bash to generate all yml for upstream
AdrielVelazquez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,79 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "log" | ||
|
|
||
| "github.com/bradleyjkemp/sigma-go" | ||
| "github.com/bradleyjkemp/sigma-go/evaluator" | ||
| ) | ||
|
|
||
| func main() { | ||
| // | ||
| // Load the Sigma rule (simplified representation here) | ||
| sigmaRule := ` | ||
| title: Okta Application Modified or Deleted | ||
| id: 7899144b-e416-4c28-b0b5-ab8f9e0a541d | ||
| status: test | ||
| description: Detects when an application is modified or deleted. | ||
| references: | ||
| - https://developer.okta.com/docs/reference/api/system-log/ | ||
| - https://developer.okta.com/docs/reference/api/event-types/ | ||
| author: Austin Songer @austinsonger | ||
| date: 2021/09/12 | ||
| modified: 2022/10/09 | ||
| tags: | ||
| - attack.impact | ||
| logsource: | ||
| product: okta | ||
| service: okta | ||
| detection: | ||
| selection: | ||
| eventtype: | ||
| - application.lifecycle.update | ||
| - application.lifecycle.delete | ||
| condition: selection | ||
| falsepositives: | ||
| - Unknown | ||
|
|
||
| level: medium | ||
|
|
||
| ` | ||
| // Parse the Sigma rule | ||
| rule, err := sigma.ParseRule([]byte(sigmaRule)) | ||
| if err != nil { | ||
| log.Fatalf("Failed to parse Sigma rule: %v", err) | ||
| } | ||
|
|
||
| // Query Okta logs (simplified, you'll need to implement actual API querying) | ||
| oktaEvents := queryOktaLogs() | ||
|
|
||
| // Rules need to be wrapped in an evaluator. | ||
| // This is also where (if needed) you provide functions implementing the count, max, etc. aggregation functions | ||
| e := evaluator.ForRule(rule) | ||
|
|
||
| // Evaluate each Okta event against the Sigma rule | ||
| for _, event := range oktaEvents { | ||
| matches, err := e.Matches(context.Background(), event) | ||
| if err != nil { | ||
| log.Printf("Error evaluating rule: %v", err) | ||
| continue | ||
| } | ||
| if matches.Match { | ||
| fmt.Println("Detected an application modification or deletion event:", event) | ||
| // Implement your detection handling logic here (e.g., alerting) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // queryOktaLogs simulates querying Okta logs. Replace with actual API calls. | ||
| func queryOktaLogs() []map[string]interface{} { | ||
| // This is a simplified example. You should replace this function with one | ||
| // that makes HTTP requests to Okta's system log API and parses the response. | ||
| // See https://developer.okta.com/docs/reference/api/system-log/ for details. | ||
| return []map[string]interface{}{ | ||
| {"eventtype": "application.lifecycle.update", "details": "Application updated"}, | ||
| // Add more events as needed | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex is tricky and unfortunately what's allowed here isn't actually defined in the spec: it's referred to as
{search-identifier-pattern}but never actually defined https://github.com/SigmaHQ/sigma-specification/blob/main/Sigma_specification.md#conditionWe don't want to allow plain
*, but other than that we could just say any string containing a*and another character[a-zA-Z0-9_]is a SearchIdentifierPattern?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, there are rules committed upstream that does support at least what's presented. Reading the rules more thoroughly, seems like there are possibilities for wildcards to be present anywhere in the string.
So technically something like 1
of selection_*curl_*is allowed if I'm reading this correctly, which I don't think even the original pattern supports.Also I added a new bash script that pulls ALL of the rules down, and verifies that the tests still run with all rules provided by SigmaHQ. For some reason just doing a regex that matched only what you suggested wasn't working as expected.