contentctl 4.0.5__py3-none-any.whl → 4.1.1__py3-none-any.whl
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.
- contentctl/actions/inspect.py +1 -1
- contentctl/actions/new_content.py +6 -3
- contentctl/actions/test.py +4 -1
- contentctl/actions/validate.py +1 -0
- contentctl/api.py +137 -0
- contentctl/contentctl.py +28 -24
- contentctl/enrichments/cve_enrichment.py +43 -78
- contentctl/input/director.py +72 -72
- contentctl/objects/abstract_security_content_objects/detection_abstract.py +77 -13
- contentctl/objects/abstract_security_content_objects/security_content_object_abstract.py +17 -0
- contentctl/objects/baseline.py +0 -1
- contentctl/objects/config.py +4 -8
- contentctl/objects/detection_tags.py +1 -1
- contentctl/objects/macro.py +8 -7
- contentctl/output/yml_writer.py +39 -1
- {contentctl-4.0.5.dist-info → contentctl-4.1.1.dist-info}/METADATA +7 -8
- {contentctl-4.0.5.dist-info → contentctl-4.1.1.dist-info}/RECORD +21 -23
- contentctl/actions/apav_deploy.py +0 -98
- contentctl/actions/api_deploy.py +0 -151
- contentctl/templates/app_template/default/distsearch.conf +0 -5
- /contentctl/actions/{acs_deploy.py → deploy_acs.py} +0 -0
- {contentctl-4.0.5.dist-info → contentctl-4.1.1.dist-info}/LICENSE.md +0 -0
- {contentctl-4.0.5.dist-info → contentctl-4.1.1.dist-info}/WHEEL +0 -0
- {contentctl-4.0.5.dist-info → contentctl-4.1.1.dist-info}/entry_points.txt +0 -0
contentctl/actions/api_deploy.py
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import sys
|
|
3
|
-
import json
|
|
4
|
-
import requests
|
|
5
|
-
from requests.auth import HTTPBasicAuth
|
|
6
|
-
|
|
7
|
-
from dataclasses import dataclass
|
|
8
|
-
from configparser import RawConfigParser
|
|
9
|
-
import splunklib.client as client
|
|
10
|
-
|
|
11
|
-
from contentctl.objects.config import Config
|
|
12
|
-
import pathlib
|
|
13
|
-
|
|
14
|
-
@dataclass(frozen=True)
|
|
15
|
-
class API_DeployInputDto:
|
|
16
|
-
path: pathlib.Path
|
|
17
|
-
config: Config
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
class API_Deploy:
|
|
21
|
-
def fix_newlines_in_conf_files(self, conf_path: pathlib.Path) -> RawConfigParser:
|
|
22
|
-
parser = RawConfigParser()
|
|
23
|
-
with open(conf_path, "r") as conf_data_file:
|
|
24
|
-
conf_data = conf_data_file.read()
|
|
25
|
-
|
|
26
|
-
# ConfigParser cannot read multipleline strings that simply escape the newline character with \
|
|
27
|
-
# To include a newline, you need to include a space at the beginning of the newline.
|
|
28
|
-
# We will simply replace all \NEWLINE with NEWLINESPACE (removing the leading literal \).
|
|
29
|
-
# We will discuss whether we intend to make these changes to the underlying conf files
|
|
30
|
-
# or just apply the changes here
|
|
31
|
-
conf_data = conf_data.replace("\\\n", "\n ")
|
|
32
|
-
|
|
33
|
-
parser.read_string(conf_data)
|
|
34
|
-
return parser
|
|
35
|
-
|
|
36
|
-
def execute(self, input_dto: API_DeployInputDto) -> None:
|
|
37
|
-
if len(input_dto.config.deployments.rest_api_deployments) == 0:
|
|
38
|
-
raise Exception("No rest_api_deployments defined in 'contentctl.yml'")
|
|
39
|
-
app_path = pathlib.Path(input_dto.config.build.path_root)/input_dto.config.build.title
|
|
40
|
-
if not app_path.is_dir():
|
|
41
|
-
raise Exception(f"The unpackaged app does not exist at the path {app_path}. Please run 'contentctl build' to generate the app.")
|
|
42
|
-
for target in input_dto.config.deployments.rest_api_deployments:
|
|
43
|
-
print(f"Deploying '{input_dto.config.build.title}' to target '{target.server}' [{target.description}]")
|
|
44
|
-
splunk_args = {
|
|
45
|
-
"host": target.server,
|
|
46
|
-
"port": target.port,
|
|
47
|
-
"username": target.username,
|
|
48
|
-
"password": target.password,
|
|
49
|
-
"owner": "nobody",
|
|
50
|
-
"app": "search",
|
|
51
|
-
}
|
|
52
|
-
print("Warning - we are currently deploying all content into the 'search' app. "
|
|
53
|
-
"At this time, this means the user does not have to install the app "
|
|
54
|
-
"manually, but this will change")
|
|
55
|
-
service = client.connect(**splunk_args)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
macros_parser = self.fix_newlines_in_conf_files(
|
|
59
|
-
app_path/"default"/"macros.conf"
|
|
60
|
-
)
|
|
61
|
-
import tqdm
|
|
62
|
-
|
|
63
|
-
bar_format_macros = (
|
|
64
|
-
f"Deploying macros "
|
|
65
|
-
+ "{percentage:3.0f}%[{bar:20}]"
|
|
66
|
-
+ "[{n_fmt}/{total_fmt} | ETA: {remaining}]"
|
|
67
|
-
)
|
|
68
|
-
bar_format_detections = (
|
|
69
|
-
f"Deploying saved searches"
|
|
70
|
-
+ "{percentage:3.0f}%[{bar:20}]"
|
|
71
|
-
+ "[{n_fmt}/{total_fmt} | ETA: {remaining}]"
|
|
72
|
-
)
|
|
73
|
-
for section in tqdm.tqdm(
|
|
74
|
-
macros_parser.sections(), bar_format=bar_format_macros
|
|
75
|
-
):
|
|
76
|
-
try:
|
|
77
|
-
service.post("properties/macros", __stanza=section)
|
|
78
|
-
service.post("properties/macros/" + section, **macros_parser[section])
|
|
79
|
-
tqdm.tqdm.write(f"Deployed macro [{section}]")
|
|
80
|
-
except Exception as e:
|
|
81
|
-
tqdm.tqdm.write(f"Error deploying macro {section}: {str(e)}")
|
|
82
|
-
|
|
83
|
-
detection_parser = RawConfigParser()
|
|
84
|
-
detection_parser = self.fix_newlines_in_conf_files(
|
|
85
|
-
app_path/"default"/"savedsearches.conf",
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
for section in tqdm.tqdm(
|
|
90
|
-
detection_parser.sections(), bar_format=bar_format_detections
|
|
91
|
-
):
|
|
92
|
-
try:
|
|
93
|
-
if section.startswith(input_dto.config.build.prefix):
|
|
94
|
-
params = detection_parser[section]
|
|
95
|
-
params["name"] = section
|
|
96
|
-
response_actions = []
|
|
97
|
-
if (
|
|
98
|
-
input_dto.config.detection_configuration.notable
|
|
99
|
-
and input_dto.config.detection_configuration.notable.rule_description
|
|
100
|
-
):
|
|
101
|
-
response_actions.append("notable")
|
|
102
|
-
if (
|
|
103
|
-
input_dto.config.detection_configuration.rba
|
|
104
|
-
and input_dto.config.detection_configuration.rba.enabled
|
|
105
|
-
):
|
|
106
|
-
response_actions.append("risk")
|
|
107
|
-
params["actions"] = ",".join(response_actions)
|
|
108
|
-
params["request.ui_dispatch_app"] = "ES Content Updates"
|
|
109
|
-
params["request.ui_dispatch_view"] = "ES Content Updates"
|
|
110
|
-
params["alert_type"] = params.pop("counttype")
|
|
111
|
-
params["alert_comparator"] = params.pop("relation")
|
|
112
|
-
params["alert_threshold"] = params.pop("quantity")
|
|
113
|
-
params.pop("enablesched")
|
|
114
|
-
|
|
115
|
-
try:
|
|
116
|
-
service.saved_searches.delete(section)
|
|
117
|
-
#tqdm.tqdm.write(f"Deleted old saved search: {section}")
|
|
118
|
-
except Exception as e:
|
|
119
|
-
#tqdm.tqdm.write(f"Error deleting savedsearch '{section}' :[{str(e)}]")
|
|
120
|
-
pass
|
|
121
|
-
|
|
122
|
-
service.post("saved/searches", **params)
|
|
123
|
-
tqdm.tqdm.write(f"Deployed savedsearch [{section}]")
|
|
124
|
-
|
|
125
|
-
except Exception as e:
|
|
126
|
-
tqdm.tqdm.write(f"Error deploying saved search {section}: {str(e)}")
|
|
127
|
-
|
|
128
|
-
# story_parser = RawConfigParser()
|
|
129
|
-
# story_parser.read(os.path.join(input_dto.path, input_dto.config.build.splunk_app.path, "default", "analyticstories.conf"))
|
|
130
|
-
|
|
131
|
-
# for section in story_parser.sections():
|
|
132
|
-
# if section.startswith("analytic_story"):
|
|
133
|
-
# params = story_parser[section]
|
|
134
|
-
# params = dict(params.items())
|
|
135
|
-
# params["spec_version"] = 1
|
|
136
|
-
# params["version"] = 1
|
|
137
|
-
# name = section[17:]
|
|
138
|
-
# #service.post('services/analyticstories/configs/analytic_story', name=name, content=json.dumps(params))
|
|
139
|
-
|
|
140
|
-
# url = "https://3.72.220.157:8089/services/analyticstories/configs/analytic_story"
|
|
141
|
-
# data = dict()
|
|
142
|
-
# data["name"] = name
|
|
143
|
-
# data["content"] = params
|
|
144
|
-
# print(json.dumps(data))
|
|
145
|
-
# response = requests.post(
|
|
146
|
-
# url,
|
|
147
|
-
# auth=HTTPBasicAuth('admin', 'fgWFshd0mm7eErMj9qX'),
|
|
148
|
-
# data=json.dumps(data),
|
|
149
|
-
# verify=False
|
|
150
|
-
# )
|
|
151
|
-
# print(response.text)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|