elastic / detection-rules

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

Refresh ECS, Beats manifest and schemas #3993

Closed shashank-elastic closed 1 month ago

shashank-elastic commented 1 month ago

Pull Request

Issue link(s): Monthly Refresh as part of Release https://github.com/elastic/ia-trade-team/issues/430

Summary - What I changed

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

loading rules to determine all integration tags loaded sentinel_one_cloud_funnel manifests from the following package versions: ['1.3.0', '1.2.1', '1.2.0', '1.1.0', '1.0.0', '0.14.2', '0.14.1', '0.14.0', '0.13.0', '0.12.0', '0.11.0', '0.10.1', '0.10.0', '0.9.0', '0.7.1', '0.7.0', '0.6.0', '0.5.0', '0.4.0', '0.3.0', '0.2.0', '0.1.0'] final integrations manifests dumped: /Users/shashankks/elastic_workspace/detection-rules/detection_rules/etc/integration-manifests.json.gz (.venv) detection-rules on  refresh_schema [$!?] is 📦 v0.1.0 via 🐍 v3.12.5 (.venv) on ☁️ shashank.suryanarayana@elastic.co ❯ python -m detection_rules dev integrations build-schemas -o -i sentinel_one_cloud_funnel

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

Building integration schemas... processing sentinel_one_cloud_funnel final integrations manifests dumped: /Users/shashankks/elastic_workspace/detection-rules/detection_rules/etc/integration-schemas.json.gz



With the ongoing issue with DGA filed mapping we have revert the Integration Schema Refresh! 

## How To Test

- Unit Test to Pass

## Checklist

<!-- Delete any items that are not applicable to this PR. -->

- [x] Added a label for the type of pr: `bug`, `enhancement`, `schema`, `Rule: New`, `Rule: Deprecation`, `Rule: Tuning`, `Hunt: New`, or `Hunt: Tuning` so guidelines can be generated
- [x] Added the `meta:rapid-merge` label if planning to merge within 24 hours
- [ ] Secret and sensitive material has been managed correctly
- [ ] Automated testing was updated or added to match the most common scenarios
- [ ] Documentation and comments were added for features that require explanation

## Contributor checklist

- Have you signed the [contributor license agreement](https://www.elastic.co/contributor-agreement)?
- Have you followed the [contributor guidelines](https://github.com/elastic/detection-rules/blob/main/CONTRIBUTING.md)?
protectionsmachine commented 1 month ago

Enhancement - Guidelines

These guidelines serve as a reminder set of considerations when addressing adding a new schema feature to the code.

Documentation and Context

Code Standards and Practices

Testing

Additional Schema Related Checks

terrancedejesus commented 1 month ago

Left a few questions. Did we attempt to refresh MITRE ATT&CK mapping?

shashank-elastic commented 1 month ago

Left a few questions. Did we attempt to refresh MITRE ATT&CK mapping?

We dont have any latest versions for MITRE - https://attack.mitre.org/resources/versions/

shashank-elastic commented 1 month ago

For the Unit Test Failures Debugging

Rule in Question : https://github.com/elastic/detection-rules/blob/main/rules/integrations/dga/command_and_control_ml_dga_activity_using_sunburst_domain.toml

Query

ml_is_dga.malicious_prediction:1 and dns.question.registered_domain:avsvmcloud.com

When we load the schemas these fields are present

>>> from detection_rules.integrations import load_integrations_manifests, load_integrations_schemas
>>> schemas = load_integrations_schemas()
>>> 'dns.question.registered_domain' in schemas['network_traffic']['1.9.3']['dns'].keys()
True
>>> schemas['dga']['2.0.2']
{'dga-2.0.2': {'data_stream.type': 'constant_keyword', 'data_stream.dataset': 'constant_keyword', 'data_stream.namespace': 'constant_keyword', '@timestamp': 'date', 'ml_is_dga.malicious_prediction': 'long', 'ml_is_dga.malicious_probability': 'float'}, 'jobs': ['dga_high_sum_probability']}
>>> 

DAC has touched rule_validators, so initial suspect would be to debug from there

cc @eric-forte-elastic

shashank-elastic commented 1 month ago

Interestingly we have a new DGA version 2.0.3

And the field have massively changed for 2.0.3

{
    "1.0.0": {
        "jobs": [
            "dga_high_sum_probability"
        ]
    },
    "1.0.1": {
        "jobs": [
            "dga_high_sum_probability"
        ]
    },
    "1.1.0": {
        "jobs": [
            "dga_high_sum_probability"
        ]
    },
    "2.0.0": {
        "dga-2.0.0": {
            "data_stream.type": "constant_keyword",
            "data_stream.dataset": "constant_keyword",
            "data_stream.namespace": "constant_keyword",
            "@timestamp": "date",
            "ml_is_dga.malicious_prediction": "long",
            "ml_is_dga.malicious_probability": "float"
        },
        "jobs": [
            "dga_high_sum_probability"
        ]
    },
    "2.0.1": {
        "dga-2.0.1": {
            "data_stream.type": "constant_keyword",
            "data_stream.dataset": "constant_keyword",
            "data_stream.namespace": "constant_keyword",
            "@timestamp": "date",
            "ml_is_dga.malicious_prediction": "long",
            "ml_is_dga.malicious_probability": "float"
        },
        "jobs": [
            "dga_high_sum_probability"
        ]
    },
    "2.0.2": {
        "dga-2.0.2": {
            "data_stream.type": "constant_keyword",
            "data_stream.dataset": "constant_keyword",
            "data_stream.namespace": "constant_keyword",
            "@timestamp": "date",
            "ml_is_dga.malicious_prediction": "long",
            "ml_is_dga.malicious_probability": "float"
        },
        "jobs": [
            "dga_high_sum_probability"
        ]
    },
    "2.0.3": {
        "jobs": [
            "dga_high_sum_probability"
        ]
    }
}
shashank-elastic commented 1 month ago

The issue is changes in upstream Refer - https://github.com/elastic/integrations/pull/10476

image (10)