elastic / detection-rules

https://www.elastic.co/guide/en/security/current/detection-engine-overview.html
Other
1.92k stars 492 forks source link

Support toml lint for investigate transforms #4066

Closed shashank-elastic closed 3 weeks ago

shashank-elastic commented 4 weeks ago

Pull Request

Issue link(s): https://github.com/elastic/detection-rules/issues/4033

Summary - What I changed

How To Test

❯ python -m detection_rules toml-lint -f rules/windows/command_and_control_remote_file_copy_powershell.toml       
Loaded config file: /Users/shashankks/elastic_workspace/detection-rules/.detection-rules-cfg.json

█▀▀▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄   ▄      █▀▀▄ ▄  ▄ ▄   ▄▄▄ ▄▄▄
█  █ █▄▄  █  █▄▄ █    █   █  █ █ █▀▄ █      █▄▄▀ █  █ █   █▄▄ █▄▄
█▄▄▀ █▄▄  █  █▄▄ █▄▄  █  ▄█▄ █▄█ █ ▀▄█      █ ▀▄ █▄▄█ █▄▄ █▄▄ ▄▄█

TOML file linting complete
(.venv) 
detection-rules on  issue-4033 [$!?] is 📦 v0.1.0 via 🐍 v3.12.5 (.venv) on ☁️  shashank.suryanarayana@elastic.co 
❯ 

image

❯ python -m detection_rules toml-lint -f rules/linux/persistence_setuid_setgid_capability_set.toml         
Loaded config file: /Users/shashankks/elastic_workspace/detection-rules/.detection-rules-cfg.json

█▀▀▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄   ▄      █▀▀▄ ▄  ▄ ▄   ▄▄▄ ▄▄▄
█  █ █▄▄  █  █▄▄ █    █   █  █ █ █▀▄ █      █▄▄▀ █  █ █   █▄▄ █▄▄
█▄▄▀ █▄▄  █  █▄▄ █▄▄  █  ▄█▄ █▄█ █ ▀▄█      █ ▀▄ █▄▄█ █▄▄ █▄▄ ▄▄█

TOML file linting complete
(.venv) 
detection-rules on  issue-4033 [$?] is 📦 v0.1.0 via 🐍 v3.12.5 (.venv) on ☁️  shashank.suryanarayana@elastic.co 
❯ 

No changes detected

image

Checklist

Contributor checklist

protectionsmachine commented 4 weeks ago

Bug - Guidelines

These guidelines serve as a reminder set of considerations when addressing a bug in the code.

Documentation and Context

Code Standards and Practices

Testing

Additional Checks

Mikaayenson commented 4 weeks ago

@shashank-elastic can you share an example of it working with a rule that has the investigation fields?

shashank-elastic commented 4 weeks ago

@shashank-elastic can you share an example of it working with a rule that has the investigation fields?

@Mikaayenson Already updated in "How to Test" part of the PR :)

Mikaayenson commented 4 weeks ago

@shashank-elastic can you share an example of it working with a rule that has the investigation fields?

@Mikaayenson Already updated in "How to Test" part of the PR :)

Looks good. I think we should update the test_toml.json file so the new fields are added to the unit test TestRuleTomlFormatter

shashank-elastic commented 4 weeks ago

@shashank-elastic can you share an example of it working with a rule that has the investigation fields?

@Mikaayenson Already updated in "How to Test" part of the PR :)

Looks good. I think we should update the test_toml.json file so the new fields are added to the unit test TestRuleTomlFormatter

@Mikaayenson Done

shashank-elastic commented 3 weeks ago

@Mikaayenson make test-cli execution completed The output is pretty huge and I have truncated for better readability



Loaded config file: /Users/shashankks/elastic_workspace/detection-rules/.detection-rules-cfg.json

█▀▀▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄▄▄ ▄   ▄      █▀▀▄ ▄  ▄ ▄   ▄▄▄ ▄▄▄
█  █ █▄▄  █  █▄▄ █    █   █  █ █ █▀▄ █      █▄▄▀ █  █ █   █▄▄ █▄▄
█▄▄▀ █▄▄  █  █▄▄ █▄▄  █  ▄█▄ █▄█ █ ▀▄█      █ ▀▄ █▄▄█ █▄▄ █▄▄ ▄▄█

Building integration schemas...
processing endpoint
final integrations manifests dumped: /Users/shashankks/elastic_workspace/detection-rules/detection_rules/etc/integration-schemas.json.gz
Detection-rules CLI tests completed!