Skip to content
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

2.4.70 #527

Merged
merged 364 commits into from
May 29, 2024
Merged

2.4.70 #527

merged 364 commits into from
May 29, 2024

Conversation

TOoSmOotH
Copy link
Contributor

No description provided.

defensivedepth and others added 30 commits April 18, 2024 16:44
Some updates weren't happening so I took a closer look at UpdateDetection. We want to be able to update most fields of any detection for one reason or another. Even community rules get updated versions. Some protections were getting in the way so they were moved up to the handler so they only applied to updates a user is making. This change invalidated some existing tests.

Changing from ETOPEN to ETPRO (and similar changes to where community rules are pulled from) will, on next sync, remove rules that are no longer present from the new import places.

The check that asks the question "Has a detection changed enough to warrant updating?" now checks if the ruleset has changed or if there are Overrides.

When updating repos, any folders that existed before updating that weren't listed for an update are removed. It's assumed we always try to update every repo we're getting community rules from.

Organized the util functions, added tests.
When validating a sigma rule client-side, first check if it has a publicID before checking that the ID matches the one in the rule. If the detection doesn't have a public ID then the rule is probably a duplicate in which the public ID will be extracted on next save to give the user a chance to change the publicID.

Better error messaging around UPDATING a detection to have a publicID that already exists. This behavior used to be unique to CREATING detections.
All the logic necessary before a detection in elasticsearch can be updated is now done in a PrepareForSave function on the DetectionHandler.

Detectionstore.UpdateDetection no longer needs to request the original detection before updating.

New way to compare Overrides.

Added and updated tests.
Forward and backward, this test shows that valid overrides can be properly compared for equality.
strconv.Unquote seems to be geared towards how the Go language parses strings when parsing Go code such as only removing single quotes if they're around a single char. Updated to use a more thorough, hand-written function that also doesn't throw an error.
…a-titles

Use Better Unquote Function For Suricata Titles
We were processing every non-commented line in the suricata rules file. Now we're processing every rule and using the comments to indicate if it's enabled or not (not commented = enabled).

Some new complexity was added that's unique to Suricata. Because we manipulate the rules through pillars, we now take advantage of a unique opportunity that will let the ruleset determine if a detection is enabled UNTIL a user modifies the detection at which point the user's preference will forever override the ruleset. The new logic is: if a community rule's sid is not in the enabled pillar or the disabled pillar at the time of import then the sid is left out of the pillars, conversely if the sid is found in a pillar then it should be updated. When not specified in either pillar, the status of a suricata detection will be determined by whether it's commented out or not in the original rule file.

De-linted a line. Readers only throw errors when unreading a non-seekable stream. The stream in use here is always seekable and will never return an error.
YARA files often contain multiple rules. If any of those rules need to import anything, they're imported once at the top of the file. Now, as SOC parses files it retains those imports and re-adds them to rules as it individualizes them making sure to only add the imports that are actually referenced.
Gridmembershandler.go had a custom implemented sanitize function, replaced it with the sanitize library of choice we use else where in the project.

PublicIds are used in a few places to name files being written to disk so some extra care was taken to be sure we validate them more stringently and sanitize them before use. They are, after all, externally provided content.

More test cases for validateId to ensure file paths or even the characters used in file paths aren't acceptable regardless of slash direction. This is used upstream of where we use PublicIds for file names.
jertel and others added 26 commits May 23, 2024 08:26
detections ui cosmetics; ensure soc logs included on grid screen pivot to hunt
One expected modify overrides to show up in the thresholding pillar and the other was a simple oversight highlighted by the test.
Compare the current content to the original value to determine if anything has changed.
The Update/Cancel buttons under the Detection Source now only appear when the source is modified. Sigma's Convert button still remains visible when appropriate.

Changing the source, not saving it using the provided Update button, but causing the detection to save some other way now results in an Unsaved Changes dialog appearing asking you if you want to save the source before continuing. Yes saves, No reverts the source.

Also fixed a bug where canceling your source changes linked the current model to the saved `origDetect` in a way that shouldn't have happened.

If saving a detection fails, the status indicator is reverted back to the original value to give the user a better experience.
…ved-changes-on-new

Don't show "unsaved changes" dialog on New Detection page
fix detection summary metadata styling
prevent creation of new overrides with blank, required values
…alert have

When a community detection needs to update, only update if there was a change in content, ruleset, or if there are overrides (hard to detect if there's a change so we always update them). This improvement is already present in suricata and elastalert.
…-strelka-import-speed

Give Strelka a similar performance boost that both suricata and elast…
several bug fixes in overrides, cosmetic corrections, implemented validation logic
When migrating, overrides should have their CreatedAt and UpdatedAt values set to the proper time.

When loading the overrides, in situations where the installation does not have any overrides there will be no file. This is not an error. Allow the migration to continue.

Tests updated.
…on-fixes

Migration override timestamps & sidsYaml does not exist
We should validate publicIds with the specific validatePublicId function to allow for YARA's long publicIds. Updated test.
…tbypublicid-length-fix

Proper Validation During GetDetectionByPublicId
@TOoSmOotH TOoSmOotH merged commit 09557cf into 2.4/main May 29, 2024
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants