detectl 0.2.1__tar.gz → 0.3.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.
Files changed (28) hide show
  1. {detectl-0.2.1 → detectl-0.3.0}/PKG-INFO +6 -5
  2. {detectl-0.2.1 → detectl-0.3.0}/README.md +1 -1
  3. {detectl-0.2.1 → detectl-0.3.0}/detectl/__init__.py +1 -1
  4. {detectl-0.2.1 → detectl-0.3.0}/detectl/cli.py +58 -5
  5. {detectl-0.2.1 → detectl-0.3.0}/detectl.egg-info/PKG-INFO +6 -5
  6. {detectl-0.2.1 → detectl-0.3.0}/detectl.egg-info/requires.txt +1 -1
  7. {detectl-0.2.1 → detectl-0.3.0}/pyproject.toml +5 -4
  8. {detectl-0.2.1 → detectl-0.3.0}/tests/test_cli.py +18 -0
  9. {detectl-0.2.1 → detectl-0.3.0}/LICENSE +0 -0
  10. {detectl-0.2.1 → detectl-0.3.0}/detectl/__main__.py +0 -0
  11. {detectl-0.2.1 → detectl-0.3.0}/detectl/adapters/__init__.py +0 -0
  12. {detectl-0.2.1 → detectl-0.3.0}/detectl/adapters/base.py +0 -0
  13. {detectl-0.2.1 → detectl-0.3.0}/detectl/adapters/chronicle.py +0 -0
  14. {detectl-0.2.1 → detectl-0.3.0}/detectl/adapters/crowdstrike.py +0 -0
  15. {detectl-0.2.1 → detectl-0.3.0}/detectl/adapters/elastic.py +0 -0
  16. {detectl-0.2.1 → detectl-0.3.0}/detectl/adapters/qradar.py +0 -0
  17. {detectl-0.2.1 → detectl-0.3.0}/detectl/adapters/sentinel.py +0 -0
  18. {detectl-0.2.1 → detectl-0.3.0}/detectl/adapters/splunk.py +0 -0
  19. {detectl-0.2.1 → detectl-0.3.0}/detectl/adapters/sumologic.py +0 -0
  20. {detectl-0.2.1 → detectl-0.3.0}/detectl/config.py +0 -0
  21. {detectl-0.2.1 → detectl-0.3.0}/detectl/exceptions.py +0 -0
  22. {detectl-0.2.1 → detectl-0.3.0}/detectl/models.py +0 -0
  23. {detectl-0.2.1 → detectl-0.3.0}/detectl.egg-info/SOURCES.txt +0 -0
  24. {detectl-0.2.1 → detectl-0.3.0}/detectl.egg-info/dependency_links.txt +0 -0
  25. {detectl-0.2.1 → detectl-0.3.0}/detectl.egg-info/entry_points.txt +0 -0
  26. {detectl-0.2.1 → detectl-0.3.0}/detectl.egg-info/top_level.txt +0 -0
  27. {detectl-0.2.1 → detectl-0.3.0}/setup.cfg +0 -0
  28. {detectl-0.2.1 → detectl-0.3.0}/tests/test_config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: detectl
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: A CLI for managing detection rules, tuning lists, alerts, and ad-hoc queries across multiple SIEM/EDR platforms through one consistent interface.
5
5
  Author: Kyle Main
6
6
  License: MIT
@@ -13,19 +13,20 @@ Classifier: Environment :: Console
13
13
  Classifier: Intended Audience :: Information Technology
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.9
17
16
  Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Programming Language :: Python :: 3.11
19
18
  Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
20
21
  Classifier: Topic :: Security
21
- Requires-Python: >=3.9
22
+ Requires-Python: >=3.10
22
23
  Description-Content-Type: text/markdown
23
24
  License-File: LICENSE
24
25
  Requires-Dist: click>=8.0
25
26
  Requires-Dist: PyYAML>=6.0
26
27
  Requires-Dist: requests>=2.28
27
28
  Provides-Extra: sigma
28
- Requires-Dist: sigmux>=0.3.0; extra == "sigma"
29
+ Requires-Dist: sigmux>=0.3.1; extra == "sigma"
29
30
  Provides-Extra: dryrun
30
31
  Requires-Dist: rich>=13.0; extra == "dryrun"
31
32
  Dynamic: license-file
@@ -353,7 +354,7 @@ pip install -e ../sigmux -e .
353
354
 
354
355
  docker run -d --name detectl-demo-es -p 9200:9200 \
355
356
  -e discovery.type=single-node -e xpack.security.enabled=false \
356
- docker.elastic.co/elasticsearch/elasticsearch:8.13.4
357
+ docker.elastic.co/elasticsearch/elasticsearch:8.19.25
357
358
 
358
359
  # wait for it to report healthy (takes ~10-20s)
359
360
  until curl -sf http://localhost:9200/_cluster/health; do sleep 2; done
@@ -321,7 +321,7 @@ pip install -e ../sigmux -e .
321
321
 
322
322
  docker run -d --name detectl-demo-es -p 9200:9200 \
323
323
  -e discovery.type=single-node -e xpack.security.enabled=false \
324
- docker.elastic.co/elasticsearch/elasticsearch:8.13.4
324
+ docker.elastic.co/elasticsearch/elasticsearch:8.19.25
325
325
 
326
326
  # wait for it to report healthy (takes ~10-20s)
327
327
  until curl -sf http://localhost:9200/_cluster/health; do sleep 2; done
@@ -8,4 +8,4 @@ under detectl.adapters, all implementing the same abstract interface
8
8
  alerts, and raw event queries.
9
9
  """
10
10
 
11
- __version__ = "0.2.1"
11
+ __version__ = "0.3.0"
@@ -59,9 +59,7 @@ def _load_sigmux():
59
59
  from sigmux.rule import SigmaRule
60
60
  except ImportError as exc:
61
61
  raise click.ClickException(
62
- "rules create-from-sigma needs sigmux installed: pip install 'detectl[sigma]' "
63
- "(sigmux isn't on PyPI yet -- that extra installs it straight from "
64
- "https://github.com/kylemain/sigmux)"
62
+ "rules create-from-sigma needs sigmux installed: pip install 'detectl[sigma]'"
65
63
  ) from exc
66
64
  return SigmaRule, get_backend
67
65
 
@@ -78,6 +76,40 @@ def _load_rich():
78
76
  return Console, Panel, Text
79
77
 
80
78
 
79
+ def _try_load_rich():
80
+ """Soft-import counterpart to _load_rich(), for callers (like `targets`)
81
+ that should still work perfectly well without the optional `dryrun`
82
+ extra -- falls back to (None, None) instead of raising."""
83
+ try:
84
+ from rich.console import Console
85
+ from rich.table import Table
86
+ except ImportError:
87
+ return None, None
88
+ return Console, Table
89
+
90
+
91
+ def _stdout_is_tty() -> bool:
92
+ """Broken out as its own function (rather than an inline sys.stdout.isatty()
93
+ call) purely so tests can patch it directly -- Click's CliRunner swaps
94
+ out sys.stdout for a captured buffer during invoke(), which would make
95
+ patching sys.stdout.isatty itself unreliable."""
96
+ return sys.stdout.isatty()
97
+
98
+
99
+ # Display metadata for `targets` only -- purely cosmetic. Colors match
100
+ # sigmux's _TARGET_INFO exactly for the same platform, since sigmux's
101
+ # target names and detectl's platform names are the same 1:1 set.
102
+ _PLATFORM_INFO: Dict[str, Dict[str, str]] = {
103
+ "splunk": {"query": "Splunk SPL", "rules": "Saved searches / correlation searches", "color": "orange3"},
104
+ "elastic": {"query": "Elasticsearch Query DSL", "rules": "Detection Engine rules", "color": "gold3"},
105
+ "sentinel": {"query": "Microsoft Sentinel (KQL)", "rules": "Scheduled Analytics Rules", "color": "deep_sky_blue1"},
106
+ "crowdstrike": {"query": "CrowdStrike Falcon LogScale (LQL)", "rules": "Custom IOA rules", "color": "magenta1"},
107
+ "qradar": {"query": "IBM QRadar (AQL)", "rules": "CRE rule metadata (enable/disable/delete)", "color": "green3"},
108
+ "chronicle": {"query": "Google Chronicle (YARA-L 2.0)", "rules": "Rules (YARA-L text)", "color": "cyan1"},
109
+ "sumologic": {"query": "Sumo Logic search query", "rules": "Monitors Library", "color": "red3"},
110
+ }
111
+
112
+
81
113
  def _append_field(body, sign: str, key: str, value: Any, style: str) -> None:
82
114
  if isinstance(value, str) and "\n" in value:
83
115
  body.append(f" {sign} {key}:\n", style=style)
@@ -145,9 +177,30 @@ def _adapter(ctx: click.Context) -> SIEMAdapter:
145
177
 
146
178
  @main.command()
147
179
  def targets():
148
- """List supported SIEM/EDR platforms."""
180
+ """List supported SIEM/EDR platforms.
181
+
182
+ Renders a colored table (matching sigmux's `targets` command) in an
183
+ interactive terminal. Falls back to a plain one-name-per-line list --
184
+ same as always -- when piped/redirected, or when rich isn't installed,
185
+ so `detectl targets | xargs ...`-style scripting still works exactly
186
+ as before.
187
+ """
188
+ Console, Table = _try_load_rich() if _stdout_is_tty() else (None, None)
189
+ if Console is None:
190
+ for name in sorted(REGISTRY):
191
+ click.echo(name)
192
+ return
193
+
194
+ table = Table(title="detectl supported platforms", header_style="bold")
195
+ table.add_column("Platform", style="bold")
196
+ table.add_column("Ad-hoc query language")
197
+ table.add_column("Rules resource")
149
198
  for name in sorted(REGISTRY):
150
- click.echo(name)
199
+ info = _PLATFORM_INFO.get(name, {})
200
+ color = info.get("color", "white")
201
+ table.add_row(f"[{color}]{name}[/{color}]", info.get("query", "--"), info.get("rules", "--"))
202
+
203
+ Console().print(table)
151
204
 
152
205
 
153
206
  @main.command("test-connection")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: detectl
3
- Version: 0.2.1
3
+ Version: 0.3.0
4
4
  Summary: A CLI for managing detection rules, tuning lists, alerts, and ad-hoc queries across multiple SIEM/EDR platforms through one consistent interface.
5
5
  Author: Kyle Main
6
6
  License: MIT
@@ -13,19 +13,20 @@ Classifier: Environment :: Console
13
13
  Classifier: Intended Audience :: Information Technology
14
14
  Classifier: License :: OSI Approved :: MIT License
15
15
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.9
17
16
  Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Programming Language :: Python :: 3.11
19
18
  Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
20
21
  Classifier: Topic :: Security
21
- Requires-Python: >=3.9
22
+ Requires-Python: >=3.10
22
23
  Description-Content-Type: text/markdown
23
24
  License-File: LICENSE
24
25
  Requires-Dist: click>=8.0
25
26
  Requires-Dist: PyYAML>=6.0
26
27
  Requires-Dist: requests>=2.28
27
28
  Provides-Extra: sigma
28
- Requires-Dist: sigmux>=0.3.0; extra == "sigma"
29
+ Requires-Dist: sigmux>=0.3.1; extra == "sigma"
29
30
  Provides-Extra: dryrun
30
31
  Requires-Dist: rich>=13.0; extra == "dryrun"
31
32
  Dynamic: license-file
@@ -353,7 +354,7 @@ pip install -e ../sigmux -e .
353
354
 
354
355
  docker run -d --name detectl-demo-es -p 9200:9200 \
355
356
  -e discovery.type=single-node -e xpack.security.enabled=false \
356
- docker.elastic.co/elasticsearch/elasticsearch:8.13.4
357
+ docker.elastic.co/elasticsearch/elasticsearch:8.19.25
357
358
 
358
359
  # wait for it to report healthy (takes ~10-20s)
359
360
  until curl -sf http://localhost:9200/_cluster/health; do sleep 2; done
@@ -6,4 +6,4 @@ requests>=2.28
6
6
  rich>=13.0
7
7
 
8
8
  [sigma]
9
- sigmux>=0.3.0
9
+ sigmux>=0.3.1
@@ -4,10 +4,10 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "detectl"
7
- version = "0.2.1"
7
+ version = "0.3.0"
8
8
  description = "A CLI for managing detection rules, tuning lists, alerts, and ad-hoc queries across multiple SIEM/EDR platforms through one consistent interface."
9
9
  readme = "README.md"
10
- requires-python = ">=3.9"
10
+ requires-python = ">=3.10"
11
11
  license = { text = "MIT" }
12
12
  authors = [{ name = "Kyle Main" }]
13
13
  keywords = ["siem", "detection-engineering", "splunk", "elastic", "sentinel", "crowdstrike", "qradar", "sumologic", "chronicle", "security", "sigmux", "sigma"]
@@ -17,10 +17,11 @@ classifiers = [
17
17
  "Intended Audience :: Information Technology",
18
18
  "License :: OSI Approved :: MIT License",
19
19
  "Programming Language :: Python :: 3",
20
- "Programming Language :: Python :: 3.9",
21
20
  "Programming Language :: Python :: 3.10",
22
21
  "Programming Language :: Python :: 3.11",
23
22
  "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
24
25
  "Topic :: Security",
25
26
  ]
26
27
  dependencies = [
@@ -37,7 +38,7 @@ dependencies = [
37
38
  # package whose metadata contains a direct URL/VCS dependency ("Can't have
38
39
  # direct dependency: ... See https://packaging.python.org/specifications/core-metadata"),
39
40
  # so a real version pin is required here, not just a good idea.
40
- sigma = ["sigmux>=0.3.0"]
41
+ sigma = ["sigmux>=0.3.1"]
41
42
  dryrun = ["rich>=13.0"]
42
43
 
43
44
  [project.scripts]
@@ -55,6 +55,24 @@ class TestCli(unittest.TestCase):
55
55
  for name in ("splunk", "elastic", "sentinel", "crowdstrike"):
56
56
  self.assertIn(name, result.output)
57
57
 
58
+ def test_targets_plain_list_when_not_a_tty(self):
59
+ # CliRunner's captured output isn't a real tty, so this is really
60
+ # just documenting/pinning the default (piped) behavior explicitly.
61
+ result = self.runner.invoke(main, ["targets"])
62
+ self.assertEqual(result.exit_code, 0)
63
+ lines = result.output.strip().splitlines()
64
+ self.assertEqual(sorted(lines), sorted(["splunk", "elastic", "sentinel", "crowdstrike", "qradar", "sumologic", "chronicle"]))
65
+
66
+ @patch("detectl.cli._stdout_is_tty", return_value=True)
67
+ def test_targets_renders_rich_table_when_tty(self, _mock_tty):
68
+ result = self.runner.invoke(main, ["targets"])
69
+ self.assertEqual(result.exit_code, 0)
70
+ self.assertIn("detectl supported platforms", result.output)
71
+ for name in ("splunk", "elastic", "sentinel", "crowdstrike", "qradar", "sumologic", "chronicle"):
72
+ self.assertIn(name, result.output)
73
+ self.assertIn("Ad-hoc query language", result.output)
74
+ self.assertIn("Rules resource", result.output)
75
+
58
76
  def test_platform_required(self):
59
77
  result = self.runner.invoke(main, ["rules", "list"])
60
78
  self.assertNotEqual(result.exit_code, 0)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes