Skip to content

Commit 8f24494

Browse files
committed
convert plain enums, or enums with
multiple inheritance, to StrEnum or IntEnum
1 parent e5c150d commit 8f24494

File tree

3 files changed

+22
-60
lines changed

3 files changed

+22
-60
lines changed

contentctl/actions/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from dataclasses import dataclass
66

7-
from contentctl.objects.enums import SecurityContentProduct, SecurityContentType
7+
from contentctl.objects.enums import SecurityContentType
88
from contentctl.input.director import Director, DirectorOutputDto
99
from contentctl.output.conf_output import ConfOutput
1010
from contentctl.output.conf_writer import ConfWriter

contentctl/actions/detection_testing/DetectionTestingManager.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from contentctl.actions.detection_testing.infrastructures.DetectionTestingInfrastructureServer import DetectionTestingInfrastructureServer
66
from urllib.parse import urlparse
77
from copy import deepcopy
8-
from contentctl.objects.enums import DetectionTestingTargetInfrastructure
98
import signal
109
import datetime
1110
# from queue import Queue

contentctl/objects/enums.py

Lines changed: 21 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
from __future__ import annotations
22
from typing import List
3-
import enum
3+
from enum import StrEnum, IntEnum
44

55

6-
class AnalyticsType(str, enum.Enum):
6+
class AnalyticsType(StrEnum):
77
TTP = "TTP"
88
Anomaly = "Anomaly"
99
Hunting = "Hunting"
1010
Correlation = "Correlation"
1111

12-
class DeploymentType(str, enum.Enum):
12+
class DeploymentType(StrEnum):
1313
TTP = "TTP"
1414
Anomaly = "Anomaly"
1515
Hunting = "Hunting"
@@ -18,7 +18,7 @@ class DeploymentType(str, enum.Enum):
1818
Embedded = "Embedded"
1919

2020

21-
class DataModel(str,enum.Enum):
21+
class DataModel(StrEnum):
2222
ENDPOINT = "Endpoint"
2323
NETWORK_TRAFFIC = "Network_Traffic"
2424
AUTHENTICATION = "Authentication"
@@ -40,11 +40,11 @@ class DataModel(str,enum.Enum):
4040
SPLUNK_AUDIT = "Splunk_Audit"
4141

4242

43-
class PlaybookType(str, enum.Enum):
43+
class PlaybookType(StrEnum):
4444
INVESTIGATION = "Investigation"
4545
RESPONSE = "Response"
4646

47-
class SecurityContentType(enum.Enum):
47+
class SecurityContentType(IntEnum):
4848
detections = 1
4949
baselines = 2
5050
stories = 3
@@ -68,20 +68,15 @@ class SecurityContentType(enum.Enum):
6868
# json_objects = "json_objects"
6969

7070

71-
class SecurityContentProduct(enum.Enum):
72-
SPLUNK_APP = 1
73-
API = 3
74-
CUSTOM = 4
7571

76-
77-
class SecurityContentProductName(str, enum.Enum):
72+
class SecurityContentProductName(StrEnum):
7873
SPLUNK_ENTERPRISE = "Splunk Enterprise"
7974
SPLUNK_ENTERPRISE_SECURITY = "Splunk Enterprise Security"
8075
SPLUNK_CLOUD = "Splunk Cloud"
8176
SPLUNK_SECURITY_ANALYTICS_FOR_AWS = "Splunk Security Analytics for AWS"
8277
SPLUNK_BEHAVIORAL_ANALYTICS = "Splunk Behavioral Analytics"
8378

84-
class SecurityContentInvestigationProductName(str, enum.Enum):
79+
class SecurityContentInvestigationProductName(StrEnum):
8580
SPLUNK_ENTERPRISE = "Splunk Enterprise"
8681
SPLUNK_ENTERPRISE_SECURITY = "Splunk Enterprise Security"
8782
SPLUNK_CLOUD = "Splunk Cloud"
@@ -90,33 +85,20 @@ class SecurityContentInvestigationProductName(str, enum.Enum):
9085
SPLUNK_PHANTOM = "Splunk Phantom"
9186

9287

93-
class DetectionStatus(enum.Enum):
94-
production = "production"
95-
deprecated = "deprecated"
96-
experimental = "experimental"
97-
validation = "validation"
98-
99-
100-
class DetectionStatusSSA(enum.Enum):
88+
class DetectionStatus(StrEnum):
10189
production = "production"
10290
deprecated = "deprecated"
10391
experimental = "experimental"
10492
validation = "validation"
10593

10694

107-
class LogLevel(enum.Enum):
95+
class LogLevel(StrEnum):
10896
NONE = "NONE"
10997
ERROR = "ERROR"
11098
INFO = "INFO"
11199

112100

113-
class AlertActions(enum.Enum):
114-
notable = "notable"
115-
rba = "rba"
116-
email = "email"
117-
118-
119-
class StoryCategory(str, enum.Enum):
101+
class StoryCategory(StrEnum):
120102
ABUSE = "Abuse"
121103
ADVERSARY_TACTICS = "Adversary Tactics"
122104
BEST_PRACTICES = "Best Practices"
@@ -139,37 +121,18 @@ class StoryCategory(str, enum.Enum):
139121
UNAUTHORIZED_SOFTWARE = "Unauthorized Software"
140122

141123

142-
class PostTestBehavior(str, enum.Enum):
124+
class PostTestBehavior(StrEnum):
143125
always_pause = "always_pause"
144126
pause_on_failure = "pause_on_failure"
145127
never_pause = "never_pause"
146128

147129

148-
class DetectionTestingMode(str, enum.Enum):
130+
class DetectionTestingMode(StrEnum):
149131
selected = "selected"
150132
all = "all"
151133
changes = "changes"
152134

153135

154-
class DetectionTestingTargetInfrastructure(str, enum.Enum):
155-
container = "container"
156-
server = "server"
157-
158-
159-
class InstanceState(str, enum.Enum):
160-
starting = "starting"
161-
running = "running"
162-
error = "error"
163-
stopping = "stopping"
164-
stopped = "stopped"
165-
166-
167-
class SigmaConverterTarget(enum.Enum):
168-
CIM = 1
169-
RAW = 2
170-
OCSF = 3
171-
ALL = 4
172-
173136
# It's unclear why we use a mix of constants and enums. The following list was taken from:
174137
# contentctl/contentctl/helper/constants.py.
175138
# We convect it to an enum here
@@ -183,7 +146,7 @@ class SigmaConverterTarget(enum.Enum):
183146
# "Command And Control": 6,
184147
# "Actions on Objectives": 7
185148
# }
186-
class KillChainPhase(str, enum.Enum):
149+
class KillChainPhase(StrEnum):
187150
UNKNOWN ="Unknown"
188151
RECONNAISSANCE = "Reconnaissance"
189152
WEAPONIZATION = "Weaponization"
@@ -194,7 +157,7 @@ class KillChainPhase(str, enum.Enum):
194157
ACTIONS_ON_OBJECTIVES = "Actions on Objectives"
195158

196159

197-
class DataSource(str,enum.Enum):
160+
class DataSource(StrEnum):
198161
OSQUERY_ES_PROCESS_EVENTS = "OSQuery ES Process Events"
199162
POWERSHELL_4104 = "Powershell 4104"
200163
SYSMON_EVENT_ID_1 = "Sysmon EventID 1"
@@ -234,7 +197,7 @@ class DataSource(str,enum.Enum):
234197
WINDOWS_SECURITY_5145 = "Windows Security 5145"
235198
WINDOWS_SYSTEM_7045 = "Windows System 7045"
236199

237-
class ProvidingTechnology(str, enum.Enum):
200+
class ProvidingTechnology(StrEnum):
238201
AMAZON_SECURITY_LAKE = "Amazon Security Lake"
239202
AMAZON_WEB_SERVICES_CLOUDTRAIL = "Amazon Web Services - Cloudtrail"
240203
AZURE_AD = "Azure AD"
@@ -302,7 +265,7 @@ def getProvidingTechFromSearch(search_string:str)->List[ProvidingTechnology]:
302265
return sorted(list(matched_technologies))
303266

304267

305-
class Cis18Value(str,enum.Enum):
268+
class Cis18Value(StrEnum):
306269
CIS_0 = "CIS 0"
307270
CIS_1 = "CIS 1"
308271
CIS_2 = "CIS 2"
@@ -323,15 +286,15 @@ class Cis18Value(str,enum.Enum):
323286
CIS_17 = "CIS 17"
324287
CIS_18 = "CIS 18"
325288

326-
class SecurityDomain(str, enum.Enum):
289+
class SecurityDomain(StrEnum):
327290
ENDPOINT = "endpoint"
328291
NETWORK = "network"
329292
THREAT = "threat"
330293
IDENTITY = "identity"
331294
ACCESS = "access"
332295
AUDIT = "audit"
333296

334-
class AssetType(str, enum.Enum):
297+
class AssetType(StrEnum):
335298
AWS_ACCOUNT = "AWS Account"
336299
AWS_EKS_KUBERNETES_CLUSTER = "AWS EKS Kubernetes cluster"
337300
AWS_FEDERATED_ACCOUNT = "AWS Federated Account"
@@ -382,7 +345,7 @@ class AssetType(str, enum.Enum):
382345
WEB_APPLICATION = "Web Application"
383346
WINDOWS = "Windows"
384347

385-
class NistCategory(str, enum.Enum):
348+
class NistCategory(StrEnum):
386349
ID_AM = "ID.AM"
387350
ID_BE = "ID.BE"
388351
ID_GV = "ID.GV"
@@ -406,7 +369,7 @@ class NistCategory(str, enum.Enum):
406369
RC_IM = "RC.IM"
407370
RC_CO = "RC.CO"
408371

409-
class RiskSeverity(str,enum.Enum):
372+
class RiskSeverity(StrEnum):
410373
# Levels taken from the following documentation link
411374
# https://docs.splunk.com/Documentation/ES/7.3.2/User/RiskScoring
412375
# 20 - info (0-20 for us)

0 commit comments

Comments
 (0)