1 # This module is intended to test just the new Communicator/MultiringCommunicator
2 # classes which are using curllib
3
4 # pylint: disable=no-member
5 # pylint: disable=protected-access
6 # pylint: disable=wrong-import-position
7
8 import logging
9 import os.path
10 import pprint
11 import sys
12
13 PACKAGE_DIR = os.path.dirname(os.path.abspath(__file__))
14 sys.path.insert(0, PACKAGE_DIR)
15
16 from pcs import utils # noqa: E402
17 from pcs.common.host import Destination # noqa: E402
18 from pcs.common.node_communicator import ( # noqa: E402
19 Request,
20 RequestData,
21 RequestTarget,
22 )
23
24 logger_handler = logging.StreamHandler()
25 logger_handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
26 logger = logging.getLogger("pcs")
|
CID (unavailable; MK=6ccbfc5f0f8986de6369a926d61e625d) (#1 of 1): Excessive log level (SIGMA.debug_logging_enabled): |
|
(1) Event Sigma main event: |
The Python application has been configured to create excessive logs using a `DEBUG` log level. Excessive logging can expose sensitive information in log files. |
|
(2) Event remediation: |
The log level of a production Python application should be set to `ERROR`, `WARN`, or `INFO`, instead of `DEBUG`. |
27 logger.setLevel(logging.DEBUG)
28 logger.addHandler(logger_handler)
29
30 global_target = RequestTarget(
31 "TestServer",
32 dest_list=[
33 Destination("httpbin.org2", 433),
34 Destination("httpbin.org", 443),
35 ],
36 )
37
38 pprint.pprint(global_target)
39
40
41 def get_request(timeout):
42 return Request(global_target, RequestData("delay/{0}".format(timeout)))
43
44
45 lib_env = utils.get_lib_env()
46 # utils.pcs_options["--debug"] = True
47 request_list = [get_request((i + 1) * 2) for i in range(6)]
48 factory = lib_env.get_node_communicator_factory()
49 factory._request_timeout = 10
50 communicator = factory.get_multiring_communicator()
51 # communicator.add_requests([get_request(10)])
52 # response = list(communicator.start_loop())[0]
53 # pprint.pprint(response.to_report_item())
54 communicator.add_requests(request_list)
55 for response in communicator.start_loop():
56 # print(80 * "-")
57 # print(response.request.url)
58 # print(response.data)
59 # print(80 * "-")
60 if response.request == request_list[2]:
61 r = get_request(5)
62 request_list.append(r)
63 communicator.add_requests([r])
64 if response.request == request_list[5]:
65 r = get_request(10)
66 request_list.append(r)
67 communicator.add_requests([r])
68 if len(request_list) == 8 and response.request == request_list[7]:
69 r = get_request(15)
70 communicator.add_requests([r])
71