pySigma-backend-databricks 0.1.6__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pysigma_backend_databricks-0.2.0/PKG-INFO +295 -0
- pysigma_backend_databricks-0.2.0/README.md +275 -0
- pysigma_backend_databricks-0.2.0/THIRD_PARTY_NOTICES +219 -0
- pysigma_backend_databricks-0.2.0/pySigma_backend_databricks.egg-info/PKG-INFO +295 -0
- pysigma_backend_databricks-0.2.0/pySigma_backend_databricks.egg-info/SOURCES.txt +106 -0
- pysigma_backend_databricks-0.2.0/pySigma_backend_databricks.egg-info/entry_points.txt +2 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/pySigma_backend_databricks.egg-info/requires.txt +3 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/pyproject.toml +13 -5
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/databricks.py +2329 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/field_paths.py +438 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/json_text.py +24 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/lakewatch_maps.py +260 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/lakewatch_output.py +24 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/lakewatch_overrides.py +111 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/lakewatch_pack.py +180 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/lakewatch_report.py +239 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/lakewatch_rule_deploy.py +522 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/lakewatch_schemas/__init__.py +1 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/lakewatch_schemas/builtin.json +24871 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/lakewatch_schemas/windows_custom.json +2916 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/mitre_techniques.json +4413 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/ocsf_attributes.json +183 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/ocsf_fields.py +40 -0
- pysigma_backend_databricks-0.2.0/sigma/backends/databricks/schema_catalog.py +127 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/sigma/pipelines/databricks/__init__.py +3 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/__init__.py +10 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/pipeline.py +337 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profile.py +676 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/akamai_waf.yml +93 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/aws_cloudtrail.yml +38 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/aws_waf_web_acl.yml +89 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/azure_audit.yml +77 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/azure_identity_protection.yml +54 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/azure_monitor_activity.yml +39 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/azure_signin.yml +93 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/carbonblack_endpoint_event.yml +121 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/ciscoumbrella_proxy.yml +89 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/cloudflare_http_request.yml +134 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/crowdstrike_fdr_event.yml +167 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/gcp_audit_log.yml +97 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/gcp_http_load_balancer.yml +60 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/google_workspace_reports.yml +77 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/microsoft365_audit_azure_active_directory.yml +62 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/microsoft365_audit_exchange.yml +141 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/microsoft365_audit_general.yml +42 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/okta_system_log.yml +25 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/sentinelone_deep_visibility.yml +263 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_application.yml +39 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_applocker.yml +38 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_defender_detection.yml +38 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_event_logs.yml +145 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_event_other.yml +151 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_ntlm_authentication.yml +38 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_powershell_other.yml +40 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_powershell_script.yml +55 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_security_account_change.yml +40 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_security_authentication.yml +41 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_security_group_management.yml +44 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_security_network.yml +38 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_security_other.yml +40 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_security_process.yml +103 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_security_user_access.yml +38 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_sysmon_dns.yml +48 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_sysmon_file.yml +84 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_sysmon_network.yml +48 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_sysmon_other.yml +72 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_sysmon_process.yml +90 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_sysmon_registry.yml +74 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_system.yml +39 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_taskscheduler.yml +38 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/windows_wmi_activity.yml +38 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/profiles/zscaler_zia_web_log.yml +85 -0
- pysigma_backend_databricks-0.2.0/sigma/pipelines/databricks/lakewatch/transforms.py +861 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/tests/test_backend_databricks_sigma.py +352 -37
- pysigma_backend_databricks-0.2.0/tests/test_field_paths.py +283 -0
- pysigma_backend_databricks-0.2.0/tests/test_gen_lakewatch_v2_schemas.py +66 -0
- pysigma_backend_databricks-0.2.0/tests/test_json_text.py +29 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_azure_profiles.py +311 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_builtin_profiles.py +163 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_content_pack.py +401 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_discovery.py +247 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_edr_profiles.py +632 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_entries.py +305 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_gcp_profiles.py +282 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_m365_profiles.py +242 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/tests/test_lakewatch_maps.py +69 -18
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_overrides.py +233 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_pipeline.py +602 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_profile.py +561 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_report.py +426 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_rule_deploy.py +834 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_summary.py +252 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_transforms.py +547 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_v2_backend.py +450 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_v2_parsed.py +1450 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_variant_arrays.py +175 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_web_profiles.py +492 -0
- pysigma_backend_databricks-0.2.0/tests/test_lakewatch_windows_profiles.py +446 -0
- pysigma_backend_databricks-0.2.0/tests/test_ocsf_fields.py +159 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/tests/test_pipelines_databricks_sigma.py +1 -1
- pysigma_backend_databricks-0.2.0/tests/test_schema_catalog.py +112 -0
- pysigma_backend_databricks-0.2.0/tests/test_schema_tooling.py +154 -0
- pysigma_backend_databricks-0.1.6/PKG-INFO +0 -151
- pysigma_backend_databricks-0.1.6/README.md +0 -134
- pysigma_backend_databricks-0.1.6/pySigma_backend_databricks.egg-info/PKG-INFO +0 -151
- pysigma_backend_databricks-0.1.6/pySigma_backend_databricks.egg-info/SOURCES.txt +0 -18
- pysigma_backend_databricks-0.1.6/sigma/backends/databricks/databricks.py +0 -565
- pysigma_backend_databricks-0.1.6/sigma/backends/databricks/lakewatch_maps.py +0 -138
- pysigma_backend_databricks-0.1.6/sigma/backends/databricks/mitre_techniques.json +0 -699
- pysigma_backend_databricks-0.1.6/tests/test_lakewatch_backend.py +0 -210
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/LICENSE +0 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/pySigma_backend_databricks.egg-info/dependency_links.txt +0 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/pySigma_backend_databricks.egg-info/top_level.txt +0 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/setup.cfg +0 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/sigma/backends/databricks/__init__.py +0 -0
- {pysigma_backend_databricks-0.1.6 → pysigma_backend_databricks-0.2.0}/sigma/pipelines/databricks/snake_case.py +0 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pySigma-backend-databricks
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: pySigma backend for Apache Spark/Databricks
|
|
5
|
+
Author-email: Alex Ott <alexott@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/alexott/pySigma-backend-databricks
|
|
8
|
+
Project-URL: Issues, https://github.com/alexott/pySigma-backend-databricks/issues
|
|
9
|
+
Project-URL: Repository, https://github.com/alexott/pySigma-backend-databricks
|
|
10
|
+
Keywords: cybersecurity,apache spark,spark,sigma,databricks,lakewatch
|
|
11
|
+
Requires-Python: <3.15,>=3.10
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: THIRD_PARTY_NOTICES
|
|
15
|
+
Requires-Dist: inflection<0.6.0,>=0.5.1
|
|
16
|
+
Requires-Dist: pysigma<2.0.0,>=1.3.2
|
|
17
|
+
Provides-Extra: deploy
|
|
18
|
+
Requires-Dist: databricks-sdk>=0.171; extra == "deploy"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+

|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
Status: **experimental**, work in progress:
|
|
26
|
+
|
|
27
|
+
* Requires more testing
|
|
28
|
+
|
|
29
|
+
# pySigma Databricks Backend
|
|
30
|
+
|
|
31
|
+
This is the Databricks backend for pySigma. It provides the package `sigma.backends.databricks` with the `DatabricksBackend` class.
|
|
32
|
+
Further, it contains the following processing pipelines in `sigma.pipelines.databricks`:
|
|
33
|
+
|
|
34
|
+
* `snake_case`: convert column names into snake case format
|
|
35
|
+
|
|
36
|
+
See [CHANGELOG.md](CHANGELOG.md) for the changes in each release.
|
|
37
|
+
|
|
38
|
+
It supports the following output formats:
|
|
39
|
+
|
|
40
|
+
* `lakewatch`: Lakewatch detection rules (Unity Catalog governed), batch by default;
|
|
41
|
+
* `default`: plain Databricks/Apache Spark SQL queries;
|
|
42
|
+
* `dbsql`: Databricks SQL queries with rules metadata (title, status) embedded as comment;
|
|
43
|
+
* `detection_yaml`: Yaml markup for my own detection framework.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install sigma-cli pySigma-backend-databricks
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
To deploy Lakewatch rules with `lakewatch-rule-deploy`, install the `deploy` extra as well (see
|
|
52
|
+
[Deploying rules](#deploying-rules)).
|
|
53
|
+
|
|
54
|
+
## Documentation
|
|
55
|
+
|
|
56
|
+
The README covers what you need to get started. The details are in `docs/`:
|
|
57
|
+
|
|
58
|
+
| Document | Contents |
|
|
59
|
+
|----------|----------|
|
|
60
|
+
| [Lakewatch rule output](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/lakewatch-output.md) | Sigma metadata mapping, output files, target modes (`workspace`, `content_pack`), content-pack output, alert summaries and overrides |
|
|
61
|
+
| [Parser discovery and conversion reports](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/discovery-and-reports.md) | Finding the parsers that fit your rules, and the `conversion_report.yaml` format |
|
|
62
|
+
| [Built-in profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/built-in-profiles.md) | The profile of each supported parser, and its known limitations |
|
|
63
|
+
| [Writing profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/writing-profiles.md) | Profile format, VARIANT paths and named entries, value transforms, keyword search and routing, scaffolding scripts, validation against live data |
|
|
64
|
+
| [Deploying rules](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/deploying.md) | `lakewatch-rule-deploy` in detail: ownership, updates, output and exit codes |
|
|
65
|
+
| [OCSF mode](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/ocsf.md) | Converting against OCSF gold tables, and how OCSF fields are rendered |
|
|
66
|
+
|
|
67
|
+
## Lakewatch Output
|
|
68
|
+
|
|
69
|
+
Generate [Lakewatch](https://www.databricks.com/product/lakewatch) detection rules from Sigma rules
|
|
70
|
+
(see the [Lakewatch documentation](https://docs.databricks.com/aws/en/lakewatch/)). Each rule is a
|
|
71
|
+
Unity Catalog governed resource. Rules are converted against the tables of Lakewatch parsers. A
|
|
72
|
+
*profile* maps the Sigma fields of a logsource to the columns of one parser's table, and the backend
|
|
73
|
+
ships a profile for each supported parser (see
|
|
74
|
+
[Built-in profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/built-in-profiles.md)).
|
|
75
|
+
Converting against OCSF gold tables is optional (see
|
|
76
|
+
[OCSF mode](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/ocsf.md)).
|
|
77
|
+
|
|
78
|
+
### Lakewatch quick start
|
|
79
|
+
|
|
80
|
+
1. **Find the parsers that fit your rules.** Without `-O parsers`, nothing is converted. Instead,
|
|
81
|
+
the backend reports which profiles can convert each rule, and suggests a `-O parsers=...` value:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
sigma convert -t databricks -f lakewatch rules/windows/
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Pick the parsers whose data you ingest: the suggestion lists every profile that fits. See
|
|
88
|
+
[Parser discovery](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/discovery-and-reports.md#parser-discovery).
|
|
89
|
+
|
|
90
|
+
2. **Convert the rules** for the selected parsers. `-s` skips the rules that fail, instead of
|
|
91
|
+
stopping at the first error:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
sigma convert -s -t databricks -f lakewatch -O parsers=aws_cloudtrail \
|
|
95
|
+
-O table_name=main.sec.aws_cloudtrail -O catalog_name=main -O schema_name=sec \
|
|
96
|
+
-O warehouse_id=1234567890abcdef rules/ -o detections.yaml
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
With several parsers, give each its table with `table_map`:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
sigma convert -s -t databricks -f lakewatch \
|
|
103
|
+
-O parsers=windows_sysmon_process,windows_security_process \
|
|
104
|
+
-O table_map=windows_sysmon_process:main.sec.sysmon,windows_security_process:main.sec.winsec \
|
|
105
|
+
-O catalog_name=main -O schema_name=sec -O warehouse_id=1234567890abcdef \
|
|
106
|
+
-O output_dir=detections rules/windows/
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Each selected parser produces one rule per Sigma rule, named `<rule_name>__<profile>`. Multiple
|
|
110
|
+
rules are emitted as separate `---` documents in one file. With `-O output_dir=<dir>`, each rule
|
|
111
|
+
is written to its own `<dir>/<rule_name>.yaml`, together with a `conversion_report.yaml` that
|
|
112
|
+
lists what converted, what failed and why (see
|
|
113
|
+
[Conversion report](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/discovery-and-reports.md#conversion-report)).
|
|
114
|
+
Don't use the `--output-dir`/`-od` option of sigma-cli: it writes only the bare SQL condition of
|
|
115
|
+
each rule, not the rule documents.
|
|
116
|
+
|
|
117
|
+
3. **Review and deploy the rules** (see [Deploying rules](#deploying-rules)). Converted rules are
|
|
118
|
+
disabled by default, so they can be tested first.
|
|
119
|
+
|
|
120
|
+
### Lakewatch options
|
|
121
|
+
|
|
122
|
+
Options are passed as `-O key=value`.
|
|
123
|
+
|
|
124
|
+
| Option | Default | Meaning |
|
|
125
|
+
|--------|---------|---------|
|
|
126
|
+
| `parsers` | *(none)* | Comma-separated profile ids, for example `aws_cloudtrail,okta_system_log`. Without it, parser discovery runs instead of a conversion. |
|
|
127
|
+
| `table_name` | *(none)* | Table to read from. Use it when exactly one parser is selected. |
|
|
128
|
+
| `table_map` | *(none)* | `profile:table,profile:table` for several parsers. Every selected profile needs a table. |
|
|
129
|
+
| `catalog_name` | *(required)* | `catalog_name` of the rule, also used as `batch.sql.default_catalog_name` to resolve unqualified tables. Conversion fails if it's unset. |
|
|
130
|
+
| `schema_name` | *(required)* | `schema_name` of the rule, also used as `batch.sql.default_schema_name`. Conversion fails if it's unset. |
|
|
131
|
+
| `warehouse_id` | *(required)* | `batch.warehouse_id`: the SQL warehouse that runs the rule. Conversion fails if it's unset (the server rejects batch rules without one). |
|
|
132
|
+
| `schedule` | `24h` | Rule schedule (Lakewatch duration). |
|
|
133
|
+
| `extend_lookback` | *(none)* | `timerange.extend_lookback`: widens the time window beyond the schedule. |
|
|
134
|
+
| `enabled` | `false` | `schedule.enabled`. Set `-O enabled=true` to schedule the rules immediately. |
|
|
135
|
+
| `default_fidelity` | *(from status)* | Override the rule fidelity. Accepts both `Investigative` and `FIDELITY_INVESTIGATIVE`. |
|
|
136
|
+
| `default_category` | `Static Signature` | Rule category. |
|
|
137
|
+
| `output_dir` | *(none)* | Write one file per rule, and `conversion_report.yaml`, into this directory. |
|
|
138
|
+
| `target` | `workspace` | `workspace` creates rules for the Lakewatch API, `content_pack` the rule documents of a Lakewatch content pack (see [Target modes](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/lakewatch-output.md#target-modes)). |
|
|
139
|
+
| `overrides` | *(none)* | YAML file with per-rule alert `summary`, `context` and `select` settings (see [Alert summaries](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/lakewatch-output.md#alert-summaries)). |
|
|
140
|
+
| `lakewatch_profiles_dir` | *(none)* | Directory with your own `*.yml` profiles. They are added to the built-in ones, and an id replaces a built-in id (see [Writing profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/writing-profiles.md)). |
|
|
141
|
+
| `lakewatch_schemas` | *(none)* | JSON file with additional parser schemas, in the format of the bundled catalog. |
|
|
142
|
+
| `raw_log_field` | *(none)* | STRING column searched by keyword (unbound) searches, for every selected profile. |
|
|
143
|
+
|
|
144
|
+
Sigma metadata maps to the rule: `title` becomes the alert summary, `description` the description
|
|
145
|
+
and objective, `level` the severity, `attack.*` tags the MITRE entries, and `falsepositives` the
|
|
146
|
+
runbook. Sigma `stable` rules get `FIDELITY_INVESTIGATIVE`, and all others `FIDELITY_DEVELOPMENT`.
|
|
147
|
+
The full mapping is in
|
|
148
|
+
[Lakewatch rule output](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/lakewatch-output.md#rule-metadata).
|
|
149
|
+
Only batch rules are generated (streaming is future work).
|
|
150
|
+
|
|
151
|
+
### Supported parsers
|
|
152
|
+
|
|
153
|
+
Built-in profiles cover these Lakewatch parsers:
|
|
154
|
+
|
|
155
|
+
* **Cloud:** AWS CloudTrail, Okta, Azure (audit, sign-in, activity, Identity Protection),
|
|
156
|
+
Microsoft 365 audit (general, Azure AD, Exchange), GCP Cloud Audit Logs, Google Workspace.
|
|
157
|
+
* **Web servers and proxies:** Cloudflare, GCP HTTP load balancer, Akamai WAF, AWS WAF, Zscaler ZIA,
|
|
158
|
+
Cisco Umbrella.
|
|
159
|
+
* **EDR:** CrowdStrike FDR, SentinelOne Deep Visibility, Carbon Black Cloud.
|
|
160
|
+
* **Windows event logs:** Sysmon, Security, PowerShell and other channels. Most of these profiles
|
|
161
|
+
need the custom Windows parsers, which aren't Lakewatch built-ins yet.
|
|
162
|
+
|
|
163
|
+
See [Built-in profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/built-in-profiles.md)
|
|
164
|
+
for the profile ids, the logsources they match, and their limitations. To support another parser,
|
|
165
|
+
write your own profile (see
|
|
166
|
+
[Writing profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/writing-profiles.md)).
|
|
167
|
+
|
|
168
|
+
## Deploying rules
|
|
169
|
+
|
|
170
|
+
To deploy the converted workspace rules, use one of the options below. Content-pack output isn't
|
|
171
|
+
deployed this way; install the pack instead.
|
|
172
|
+
|
|
173
|
+
**UI.** Open Detection rules, pick the rule, then Edit rule, Edit as YAML, and Save changes. See
|
|
174
|
+
[Edit a rule as YAML](https://docs.databricks.com/aws/en/lakewatch/detections/manage-detection-rules#edit-a-rule-as-yaml).
|
|
175
|
+
`catalog_name`, `schema_name` and `rule_name` can't be changed after the rule is created.
|
|
176
|
+
|
|
177
|
+
**One rule with the Databricks CLI** (Beta, CLI v1.27 or later). The CLI takes JSON, so convert the
|
|
178
|
+
YAML file first:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
python -c 'import json,sys,yaml; json.dump(yaml.safe_load(open(sys.argv[1])), sys.stdout)' rule.yaml > rule.json
|
|
182
|
+
databricks lakewatch create-rule --json @rule.json --profile <profile>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Many rules with `lakewatch-rule-deploy`.** The command creates or updates the workspace rules
|
|
186
|
+
written by `sigma convert -t databricks -f lakewatch`. It deploys detection rules only, not parsers,
|
|
187
|
+
data sources or content packs. Install it with the `deploy` extra:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
pip install "pySigma-backend-databricks[deploy]"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
sigma convert -s -t databricks -f lakewatch -O parsers=aws_cloudtrail \
|
|
195
|
+
-O table_name=main.sec.aws_cloudtrail -O catalog_name=main -O schema_name=sec \
|
|
196
|
+
-O warehouse_id=1234567890abcdef -O output_dir=detections rules/
|
|
197
|
+
lakewatch-rule-deploy --profile <profile> --dry-run detections/
|
|
198
|
+
lakewatch-rule-deploy --profile <profile> detections/
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Common flags:
|
|
202
|
+
|
|
203
|
+
| Flag | Meaning |
|
|
204
|
+
|------|---------|
|
|
205
|
+
| `--profile PROFILE` | Databricks CLI profile. Default: the SDK's standard auth chain. |
|
|
206
|
+
| `--dry-run` | Validate and print the planned changes; write nothing. |
|
|
207
|
+
| `--validate-only` | Validate the rules that would be written; write nothing. |
|
|
208
|
+
| `--warehouse-id ID` | Deploy with another SQL warehouse than the one in the files; also used for the validation dry run. |
|
|
209
|
+
| `--catalog C`, `--schema S` | Deploy into another catalog or schema than the one in the files. |
|
|
210
|
+
| `--force` | Overwrite rules that were not made from this Sigma rule. |
|
|
211
|
+
| `--json` | Print the result as JSON. |
|
|
212
|
+
|
|
213
|
+
Redeploying is safe: a rule is updated only if it was made from the same Sigma rule, unchanged
|
|
214
|
+
rules are left alone, `schedule.enabled` is kept, and nothing is ever deleted. Creating or updating
|
|
215
|
+
a rule starts a one-time run of it on the server. See
|
|
216
|
+
[Deploying rules](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/deploying.md)
|
|
217
|
+
for all flags, the output format and the exit codes.
|
|
218
|
+
|
|
219
|
+
## Plain SQL output
|
|
220
|
+
|
|
221
|
+
The `default`, `dbsql` and `detection_yaml` formats produce Spark SQL `WHERE` conditions, with no
|
|
222
|
+
parser profile:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
sigma convert -t databricks rules/windows/process_creation/proc_creation_win_whoami_execution.yml
|
|
226
|
+
sigma convert -t databricks -f dbsql -p snake_case rules/windows/
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Equality lists on one field render as a single `IN (...)`, and `|cidr` lists as one
|
|
230
|
+
`exists(array(...), ...)`, so a long list repeats the field expression once:
|
|
231
|
+
|
|
232
|
+
```sql
|
|
233
|
+
lower(Image) IN ('a.exe', 'b.exe')
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### CIDR Matching
|
|
237
|
+
|
|
238
|
+
The `|cidr` modifier is converted using the built-in Databricks IP functions
|
|
239
|
+
[`ip_cidr_contains`](https://docs.databricks.com/aws/en/sql/language-manual/functions/ip_cidr_contains)
|
|
240
|
+
and `try_ip_as_binary` (Databricks Runtime 18.2+, IPv4 and IPv6). Field values that aren't valid
|
|
241
|
+
IP addresses evaluate to `NULL` instead of failing the query. Note that, following SQL `NULL`
|
|
242
|
+
semantics, such rows don't match the negated condition either (e.g. `condition: not sel`), so they
|
|
243
|
+
are excluded from both `sel` and `not sel` results:
|
|
244
|
+
|
|
245
|
+
```yaml
|
|
246
|
+
detection:
|
|
247
|
+
sel:
|
|
248
|
+
src_ip|cidr: 192.168.0.0/16
|
|
249
|
+
condition: sel
|
|
250
|
+
```
|
|
251
|
+
Generates: `ip_cidr_contains('192.168.0.0/16', try_ip_as_binary(src_ip))`
|
|
252
|
+
|
|
253
|
+
For other Spark SQL engines (e.g. open source Apache Spark), override the expression with the
|
|
254
|
+
`cidr_expression` option. It's a format string with the placeholders `{field}`, `{value}`
|
|
255
|
+
(whole CIDR), `{network}`, `{prefixlen}` and `{netmask}`:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
sigma convert -t databricks -O "cidr_expression=cidrmatch({field}, '{value}')" rule.yml
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
```python
|
|
262
|
+
backend = DatabricksBackend(cidr_expression="cidrmatch({field}, '{value}')")
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
You need to register the corresponding function (here `cidrmatch`) as a UDF yourself.
|
|
266
|
+
|
|
267
|
+
### Unbound Keyword Search
|
|
268
|
+
|
|
269
|
+
Sigma rules with unbound keywords (values without field names) search the raw log line. By
|
|
270
|
+
default, the backend looks for keywords in a field named `raw` (`raw_data` when the target is
|
|
271
|
+
OCSF). Set another field with `-O raw_log_field=message`, or
|
|
272
|
+
`DatabricksBackend(raw_log_field="message")`. With `-f lakewatch`, each profile defines its own raw
|
|
273
|
+
event (see
|
|
274
|
+
[Keyword search and routing](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/writing-profiles.md#keyword-search-and-routing)).
|
|
275
|
+
|
|
276
|
+
```yaml
|
|
277
|
+
detection:
|
|
278
|
+
selection:
|
|
279
|
+
EventID: 4688
|
|
280
|
+
keywords:
|
|
281
|
+
- 'mimikatz'
|
|
282
|
+
- '|re': '.*evil(cmd|powershell).*'
|
|
283
|
+
condition: selection and keywords
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Generates: `EventID = 4688 AND (contains(lower(raw), 'mimikatz') OR raw rlike '.*evil(cmd|powershell).*')`
|
|
287
|
+
|
|
288
|
+
Keywords in a list are ORed, and `'|all'` ANDs them. Wildcards turn into `contains()`
|
|
289
|
+
(`*malware*`), `startswith()` (`cmd.exe*`) or `endswith()` (`*.dll`).
|
|
290
|
+
|
|
291
|
+
## Maintainer
|
|
292
|
+
|
|
293
|
+
This backend is currently maintained by:
|
|
294
|
+
|
|
295
|
+
* [Alex Ott](https://github.com/alexott/)
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Status: **experimental**, work in progress:
|
|
6
|
+
|
|
7
|
+
* Requires more testing
|
|
8
|
+
|
|
9
|
+
# pySigma Databricks Backend
|
|
10
|
+
|
|
11
|
+
This is the Databricks backend for pySigma. It provides the package `sigma.backends.databricks` with the `DatabricksBackend` class.
|
|
12
|
+
Further, it contains the following processing pipelines in `sigma.pipelines.databricks`:
|
|
13
|
+
|
|
14
|
+
* `snake_case`: convert column names into snake case format
|
|
15
|
+
|
|
16
|
+
See [CHANGELOG.md](CHANGELOG.md) for the changes in each release.
|
|
17
|
+
|
|
18
|
+
It supports the following output formats:
|
|
19
|
+
|
|
20
|
+
* `lakewatch`: Lakewatch detection rules (Unity Catalog governed), batch by default;
|
|
21
|
+
* `default`: plain Databricks/Apache Spark SQL queries;
|
|
22
|
+
* `dbsql`: Databricks SQL queries with rules metadata (title, status) embedded as comment;
|
|
23
|
+
* `detection_yaml`: Yaml markup for my own detection framework.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install sigma-cli pySigma-backend-databricks
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
To deploy Lakewatch rules with `lakewatch-rule-deploy`, install the `deploy` extra as well (see
|
|
32
|
+
[Deploying rules](#deploying-rules)).
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
The README covers what you need to get started. The details are in `docs/`:
|
|
37
|
+
|
|
38
|
+
| Document | Contents |
|
|
39
|
+
|----------|----------|
|
|
40
|
+
| [Lakewatch rule output](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/lakewatch-output.md) | Sigma metadata mapping, output files, target modes (`workspace`, `content_pack`), content-pack output, alert summaries and overrides |
|
|
41
|
+
| [Parser discovery and conversion reports](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/discovery-and-reports.md) | Finding the parsers that fit your rules, and the `conversion_report.yaml` format |
|
|
42
|
+
| [Built-in profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/built-in-profiles.md) | The profile of each supported parser, and its known limitations |
|
|
43
|
+
| [Writing profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/writing-profiles.md) | Profile format, VARIANT paths and named entries, value transforms, keyword search and routing, scaffolding scripts, validation against live data |
|
|
44
|
+
| [Deploying rules](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/deploying.md) | `lakewatch-rule-deploy` in detail: ownership, updates, output and exit codes |
|
|
45
|
+
| [OCSF mode](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/ocsf.md) | Converting against OCSF gold tables, and how OCSF fields are rendered |
|
|
46
|
+
|
|
47
|
+
## Lakewatch Output
|
|
48
|
+
|
|
49
|
+
Generate [Lakewatch](https://www.databricks.com/product/lakewatch) detection rules from Sigma rules
|
|
50
|
+
(see the [Lakewatch documentation](https://docs.databricks.com/aws/en/lakewatch/)). Each rule is a
|
|
51
|
+
Unity Catalog governed resource. Rules are converted against the tables of Lakewatch parsers. A
|
|
52
|
+
*profile* maps the Sigma fields of a logsource to the columns of one parser's table, and the backend
|
|
53
|
+
ships a profile for each supported parser (see
|
|
54
|
+
[Built-in profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/built-in-profiles.md)).
|
|
55
|
+
Converting against OCSF gold tables is optional (see
|
|
56
|
+
[OCSF mode](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/ocsf.md)).
|
|
57
|
+
|
|
58
|
+
### Lakewatch quick start
|
|
59
|
+
|
|
60
|
+
1. **Find the parsers that fit your rules.** Without `-O parsers`, nothing is converted. Instead,
|
|
61
|
+
the backend reports which profiles can convert each rule, and suggests a `-O parsers=...` value:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
sigma convert -t databricks -f lakewatch rules/windows/
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Pick the parsers whose data you ingest: the suggestion lists every profile that fits. See
|
|
68
|
+
[Parser discovery](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/discovery-and-reports.md#parser-discovery).
|
|
69
|
+
|
|
70
|
+
2. **Convert the rules** for the selected parsers. `-s` skips the rules that fail, instead of
|
|
71
|
+
stopping at the first error:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
sigma convert -s -t databricks -f lakewatch -O parsers=aws_cloudtrail \
|
|
75
|
+
-O table_name=main.sec.aws_cloudtrail -O catalog_name=main -O schema_name=sec \
|
|
76
|
+
-O warehouse_id=1234567890abcdef rules/ -o detections.yaml
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
With several parsers, give each its table with `table_map`:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
sigma convert -s -t databricks -f lakewatch \
|
|
83
|
+
-O parsers=windows_sysmon_process,windows_security_process \
|
|
84
|
+
-O table_map=windows_sysmon_process:main.sec.sysmon,windows_security_process:main.sec.winsec \
|
|
85
|
+
-O catalog_name=main -O schema_name=sec -O warehouse_id=1234567890abcdef \
|
|
86
|
+
-O output_dir=detections rules/windows/
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Each selected parser produces one rule per Sigma rule, named `<rule_name>__<profile>`. Multiple
|
|
90
|
+
rules are emitted as separate `---` documents in one file. With `-O output_dir=<dir>`, each rule
|
|
91
|
+
is written to its own `<dir>/<rule_name>.yaml`, together with a `conversion_report.yaml` that
|
|
92
|
+
lists what converted, what failed and why (see
|
|
93
|
+
[Conversion report](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/discovery-and-reports.md#conversion-report)).
|
|
94
|
+
Don't use the `--output-dir`/`-od` option of sigma-cli: it writes only the bare SQL condition of
|
|
95
|
+
each rule, not the rule documents.
|
|
96
|
+
|
|
97
|
+
3. **Review and deploy the rules** (see [Deploying rules](#deploying-rules)). Converted rules are
|
|
98
|
+
disabled by default, so they can be tested first.
|
|
99
|
+
|
|
100
|
+
### Lakewatch options
|
|
101
|
+
|
|
102
|
+
Options are passed as `-O key=value`.
|
|
103
|
+
|
|
104
|
+
| Option | Default | Meaning |
|
|
105
|
+
|--------|---------|---------|
|
|
106
|
+
| `parsers` | *(none)* | Comma-separated profile ids, for example `aws_cloudtrail,okta_system_log`. Without it, parser discovery runs instead of a conversion. |
|
|
107
|
+
| `table_name` | *(none)* | Table to read from. Use it when exactly one parser is selected. |
|
|
108
|
+
| `table_map` | *(none)* | `profile:table,profile:table` for several parsers. Every selected profile needs a table. |
|
|
109
|
+
| `catalog_name` | *(required)* | `catalog_name` of the rule, also used as `batch.sql.default_catalog_name` to resolve unqualified tables. Conversion fails if it's unset. |
|
|
110
|
+
| `schema_name` | *(required)* | `schema_name` of the rule, also used as `batch.sql.default_schema_name`. Conversion fails if it's unset. |
|
|
111
|
+
| `warehouse_id` | *(required)* | `batch.warehouse_id`: the SQL warehouse that runs the rule. Conversion fails if it's unset (the server rejects batch rules without one). |
|
|
112
|
+
| `schedule` | `24h` | Rule schedule (Lakewatch duration). |
|
|
113
|
+
| `extend_lookback` | *(none)* | `timerange.extend_lookback`: widens the time window beyond the schedule. |
|
|
114
|
+
| `enabled` | `false` | `schedule.enabled`. Set `-O enabled=true` to schedule the rules immediately. |
|
|
115
|
+
| `default_fidelity` | *(from status)* | Override the rule fidelity. Accepts both `Investigative` and `FIDELITY_INVESTIGATIVE`. |
|
|
116
|
+
| `default_category` | `Static Signature` | Rule category. |
|
|
117
|
+
| `output_dir` | *(none)* | Write one file per rule, and `conversion_report.yaml`, into this directory. |
|
|
118
|
+
| `target` | `workspace` | `workspace` creates rules for the Lakewatch API, `content_pack` the rule documents of a Lakewatch content pack (see [Target modes](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/lakewatch-output.md#target-modes)). |
|
|
119
|
+
| `overrides` | *(none)* | YAML file with per-rule alert `summary`, `context` and `select` settings (see [Alert summaries](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/lakewatch-output.md#alert-summaries)). |
|
|
120
|
+
| `lakewatch_profiles_dir` | *(none)* | Directory with your own `*.yml` profiles. They are added to the built-in ones, and an id replaces a built-in id (see [Writing profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/writing-profiles.md)). |
|
|
121
|
+
| `lakewatch_schemas` | *(none)* | JSON file with additional parser schemas, in the format of the bundled catalog. |
|
|
122
|
+
| `raw_log_field` | *(none)* | STRING column searched by keyword (unbound) searches, for every selected profile. |
|
|
123
|
+
|
|
124
|
+
Sigma metadata maps to the rule: `title` becomes the alert summary, `description` the description
|
|
125
|
+
and objective, `level` the severity, `attack.*` tags the MITRE entries, and `falsepositives` the
|
|
126
|
+
runbook. Sigma `stable` rules get `FIDELITY_INVESTIGATIVE`, and all others `FIDELITY_DEVELOPMENT`.
|
|
127
|
+
The full mapping is in
|
|
128
|
+
[Lakewatch rule output](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/lakewatch-output.md#rule-metadata).
|
|
129
|
+
Only batch rules are generated (streaming is future work).
|
|
130
|
+
|
|
131
|
+
### Supported parsers
|
|
132
|
+
|
|
133
|
+
Built-in profiles cover these Lakewatch parsers:
|
|
134
|
+
|
|
135
|
+
* **Cloud:** AWS CloudTrail, Okta, Azure (audit, sign-in, activity, Identity Protection),
|
|
136
|
+
Microsoft 365 audit (general, Azure AD, Exchange), GCP Cloud Audit Logs, Google Workspace.
|
|
137
|
+
* **Web servers and proxies:** Cloudflare, GCP HTTP load balancer, Akamai WAF, AWS WAF, Zscaler ZIA,
|
|
138
|
+
Cisco Umbrella.
|
|
139
|
+
* **EDR:** CrowdStrike FDR, SentinelOne Deep Visibility, Carbon Black Cloud.
|
|
140
|
+
* **Windows event logs:** Sysmon, Security, PowerShell and other channels. Most of these profiles
|
|
141
|
+
need the custom Windows parsers, which aren't Lakewatch built-ins yet.
|
|
142
|
+
|
|
143
|
+
See [Built-in profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/built-in-profiles.md)
|
|
144
|
+
for the profile ids, the logsources they match, and their limitations. To support another parser,
|
|
145
|
+
write your own profile (see
|
|
146
|
+
[Writing profiles](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/writing-profiles.md)).
|
|
147
|
+
|
|
148
|
+
## Deploying rules
|
|
149
|
+
|
|
150
|
+
To deploy the converted workspace rules, use one of the options below. Content-pack output isn't
|
|
151
|
+
deployed this way; install the pack instead.
|
|
152
|
+
|
|
153
|
+
**UI.** Open Detection rules, pick the rule, then Edit rule, Edit as YAML, and Save changes. See
|
|
154
|
+
[Edit a rule as YAML](https://docs.databricks.com/aws/en/lakewatch/detections/manage-detection-rules#edit-a-rule-as-yaml).
|
|
155
|
+
`catalog_name`, `schema_name` and `rule_name` can't be changed after the rule is created.
|
|
156
|
+
|
|
157
|
+
**One rule with the Databricks CLI** (Beta, CLI v1.27 or later). The CLI takes JSON, so convert the
|
|
158
|
+
YAML file first:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
python -c 'import json,sys,yaml; json.dump(yaml.safe_load(open(sys.argv[1])), sys.stdout)' rule.yaml > rule.json
|
|
162
|
+
databricks lakewatch create-rule --json @rule.json --profile <profile>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Many rules with `lakewatch-rule-deploy`.** The command creates or updates the workspace rules
|
|
166
|
+
written by `sigma convert -t databricks -f lakewatch`. It deploys detection rules only, not parsers,
|
|
167
|
+
data sources or content packs. Install it with the `deploy` extra:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
pip install "pySigma-backend-databricks[deploy]"
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
sigma convert -s -t databricks -f lakewatch -O parsers=aws_cloudtrail \
|
|
175
|
+
-O table_name=main.sec.aws_cloudtrail -O catalog_name=main -O schema_name=sec \
|
|
176
|
+
-O warehouse_id=1234567890abcdef -O output_dir=detections rules/
|
|
177
|
+
lakewatch-rule-deploy --profile <profile> --dry-run detections/
|
|
178
|
+
lakewatch-rule-deploy --profile <profile> detections/
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Common flags:
|
|
182
|
+
|
|
183
|
+
| Flag | Meaning |
|
|
184
|
+
|------|---------|
|
|
185
|
+
| `--profile PROFILE` | Databricks CLI profile. Default: the SDK's standard auth chain. |
|
|
186
|
+
| `--dry-run` | Validate and print the planned changes; write nothing. |
|
|
187
|
+
| `--validate-only` | Validate the rules that would be written; write nothing. |
|
|
188
|
+
| `--warehouse-id ID` | Deploy with another SQL warehouse than the one in the files; also used for the validation dry run. |
|
|
189
|
+
| `--catalog C`, `--schema S` | Deploy into another catalog or schema than the one in the files. |
|
|
190
|
+
| `--force` | Overwrite rules that were not made from this Sigma rule. |
|
|
191
|
+
| `--json` | Print the result as JSON. |
|
|
192
|
+
|
|
193
|
+
Redeploying is safe: a rule is updated only if it was made from the same Sigma rule, unchanged
|
|
194
|
+
rules are left alone, `schedule.enabled` is kept, and nothing is ever deleted. Creating or updating
|
|
195
|
+
a rule starts a one-time run of it on the server. See
|
|
196
|
+
[Deploying rules](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/deploying.md)
|
|
197
|
+
for all flags, the output format and the exit codes.
|
|
198
|
+
|
|
199
|
+
## Plain SQL output
|
|
200
|
+
|
|
201
|
+
The `default`, `dbsql` and `detection_yaml` formats produce Spark SQL `WHERE` conditions, with no
|
|
202
|
+
parser profile:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
sigma convert -t databricks rules/windows/process_creation/proc_creation_win_whoami_execution.yml
|
|
206
|
+
sigma convert -t databricks -f dbsql -p snake_case rules/windows/
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Equality lists on one field render as a single `IN (...)`, and `|cidr` lists as one
|
|
210
|
+
`exists(array(...), ...)`, so a long list repeats the field expression once:
|
|
211
|
+
|
|
212
|
+
```sql
|
|
213
|
+
lower(Image) IN ('a.exe', 'b.exe')
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### CIDR Matching
|
|
217
|
+
|
|
218
|
+
The `|cidr` modifier is converted using the built-in Databricks IP functions
|
|
219
|
+
[`ip_cidr_contains`](https://docs.databricks.com/aws/en/sql/language-manual/functions/ip_cidr_contains)
|
|
220
|
+
and `try_ip_as_binary` (Databricks Runtime 18.2+, IPv4 and IPv6). Field values that aren't valid
|
|
221
|
+
IP addresses evaluate to `NULL` instead of failing the query. Note that, following SQL `NULL`
|
|
222
|
+
semantics, such rows don't match the negated condition either (e.g. `condition: not sel`), so they
|
|
223
|
+
are excluded from both `sel` and `not sel` results:
|
|
224
|
+
|
|
225
|
+
```yaml
|
|
226
|
+
detection:
|
|
227
|
+
sel:
|
|
228
|
+
src_ip|cidr: 192.168.0.0/16
|
|
229
|
+
condition: sel
|
|
230
|
+
```
|
|
231
|
+
Generates: `ip_cidr_contains('192.168.0.0/16', try_ip_as_binary(src_ip))`
|
|
232
|
+
|
|
233
|
+
For other Spark SQL engines (e.g. open source Apache Spark), override the expression with the
|
|
234
|
+
`cidr_expression` option. It's a format string with the placeholders `{field}`, `{value}`
|
|
235
|
+
(whole CIDR), `{network}`, `{prefixlen}` and `{netmask}`:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
sigma convert -t databricks -O "cidr_expression=cidrmatch({field}, '{value}')" rule.yml
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
```python
|
|
242
|
+
backend = DatabricksBackend(cidr_expression="cidrmatch({field}, '{value}')")
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
You need to register the corresponding function (here `cidrmatch`) as a UDF yourself.
|
|
246
|
+
|
|
247
|
+
### Unbound Keyword Search
|
|
248
|
+
|
|
249
|
+
Sigma rules with unbound keywords (values without field names) search the raw log line. By
|
|
250
|
+
default, the backend looks for keywords in a field named `raw` (`raw_data` when the target is
|
|
251
|
+
OCSF). Set another field with `-O raw_log_field=message`, or
|
|
252
|
+
`DatabricksBackend(raw_log_field="message")`. With `-f lakewatch`, each profile defines its own raw
|
|
253
|
+
event (see
|
|
254
|
+
[Keyword search and routing](https://github.com/alexott/pySigma-backend-databricks/blob/main/docs/writing-profiles.md#keyword-search-and-routing)).
|
|
255
|
+
|
|
256
|
+
```yaml
|
|
257
|
+
detection:
|
|
258
|
+
selection:
|
|
259
|
+
EventID: 4688
|
|
260
|
+
keywords:
|
|
261
|
+
- 'mimikatz'
|
|
262
|
+
- '|re': '.*evil(cmd|powershell).*'
|
|
263
|
+
condition: selection and keywords
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Generates: `EventID = 4688 AND (contains(lower(raw), 'mimikatz') OR raw rlike '.*evil(cmd|powershell).*')`
|
|
267
|
+
|
|
268
|
+
Keywords in a list are ORed, and `'|all'` ANDs them. Wildcards turn into `contains()`
|
|
269
|
+
(`*malware*`), `startswith()` (`cmd.exe*`) or `endswith()` (`*.dll`).
|
|
270
|
+
|
|
271
|
+
## Maintainer
|
|
272
|
+
|
|
273
|
+
This backend is currently maintained by:
|
|
274
|
+
|
|
275
|
+
* [Alex Ott](https://github.com/alexott/)
|