atomicshop 2.18.24__py3-none-any.whl → 2.18.26__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.

Potentially problematic release.


This version of atomicshop might be problematic. Click here for more details.

atomicshop/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  """Atomic Basic functions and classes to make developer life easier"""
2
2
 
3
3
  __author__ = "Den Kras"
4
- __version__ = '2.18.24'
4
+ __version__ = '2.18.26'
@@ -36,7 +36,12 @@ def thread_worker_main(
36
36
 
37
37
  # Same goes for the '.path' attribute, if it is not HTTP message then there will be no path.
38
38
  try:
39
- http_path: str = client_message.request_auto_parsed.path
39
+ if client_message.request_auto_parsed and client_message.request_auto_parsed.path:
40
+ http_path: str = client_message.request_auto_parsed.path
41
+ elif client_message.response_auto_parsed.path:
42
+ http_path: str = client_message.response_auto_parsed.path
43
+ else:
44
+ http_path: str = str()
40
45
  except AttributeError:
41
46
  http_path: str = str()
42
47
 
@@ -114,12 +119,17 @@ def thread_worker_main(
114
119
  auto_parsed = request_http_parsed
115
120
  network_logger.info(
116
121
  f"HTTP Request Parsed: Method: {request_http_parsed.command} | Path: {request_http_parsed.path}")
122
+ http_path_queue.put(request_http_parsed.path)
123
+ network_logger.info(f"HTTP Request Parsed: Putting PATH to queue.")
117
124
 
118
125
  is_http_request_a_websocket(auto_parsed, client_message)
119
126
  elif is_http_response:
120
127
  auto_parsed = response_http_parsed
121
128
  network_logger.info(
122
129
  f"HTTP Response Parsed: Status: {response_http_parsed.code}")
130
+
131
+ auto_parsed.path = http_path_queue.get()
132
+ network_logger.info(f"HTTP Response Parsed: Got PATH from queue: [{auto_parsed.path}]")
123
133
  elif protocol == 'Websocket':
124
134
  client_message.protocol2 = 'Frame'
125
135
  auto_parsed = parse_websocket(raw_bytes)
@@ -516,6 +526,8 @@ def thread_worker_main(
516
526
  exception_or_close_in_receiving_thread: bool = False
517
527
  # Responder queue for ClientMessage objects.
518
528
  responder_queue: queue.Queue = queue.Queue()
529
+ # Queue for http request URI paths.
530
+ http_path_queue: queue.Queue = queue.Queue()
519
531
 
520
532
  try:
521
533
  client_ip, source_port = client_socket.getpeername()
@@ -1,5 +1,6 @@
1
1
  import docker
2
2
  from docker.models.containers import Container
3
+ from docker import DockerClient
3
4
 
4
5
  from ...print_api import print_api
5
6
 
@@ -187,14 +188,20 @@ def stop_remove_containers_by_image_name(image_name: str):
187
188
  client.close()
188
189
 
189
190
 
190
- def start_container_without_stop(image_name: str, **kwargs) -> Container:
191
+ def start_container_without_stop(
192
+ image_name: str,
193
+ client: DockerClient = None,
194
+ **kwargs) -> tuple[DockerClient, Container]:
191
195
  """
192
196
  Start a container in detached mode, this container will not run the entry point, but will run the infinite sleep.
193
197
  This way the container will continue running, you can execute commands in it and stop it manually when needed.
194
198
  :param image_name: str, the name of the image.
195
- :return:
199
+ :param client: docker.DockerClient, the docker client. If not provided, it will use the default client.
200
+ :return: Container, the docker container object.
196
201
  """
197
- client = docker.from_env()
202
+
203
+ if client is None:
204
+ client = docker.from_env()
198
205
 
199
206
  kwargs.setdefault('detach', True)
200
207
  kwargs.setdefault('mem_limit', '512m')
@@ -221,4 +228,34 @@ def start_container_without_stop(image_name: str, **kwargs) -> Container:
221
228
 
222
229
  print_api(f"Started container: [{container.name}]. Short ID: [{container.short_id}]")
223
230
 
224
- return container
231
+ return client, container
232
+
233
+
234
+ def run_command_in_running_container(container: Container, command: list) -> tuple[int, bytes, str]:
235
+ """
236
+ Run a command in a running container.
237
+ :param container: Container, the docker container object.
238
+ :param command: list, the command to run.
239
+ :return: tuple of (exit_code, output, string_output).
240
+ """
241
+
242
+ # Run the command inside the already running container
243
+ exec_result = container.exec_run(cmd=command, stdout=True, stderr=True)
244
+ # Capture logs
245
+ output_text = exec_result.output.decode("utf-8", errors="replace")
246
+ execution_result_message: str = str()
247
+ if output_text:
248
+ execution_result_message = f"Container execution result:\n{output_text}"
249
+
250
+ if exec_result.exit_code != 0:
251
+ # logging.warning(f"Extraction command returned code {exec_result.exit_code} for '{filename}'")
252
+ code_message = f"Extraction command returned code {exec_result.exit_code}"
253
+ else:
254
+ code_message = "Extraction succeeded"
255
+
256
+ if execution_result_message:
257
+ execution_result_message += f"\n{code_message}"
258
+ else:
259
+ execution_result_message = code_message
260
+
261
+ return exec_result.exit_code, exec_result.output, execution_result_message
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.18.24
3
+ Version: 2.18.26
4
4
  Summary: Atomic functions and classes to make developer life easier
5
5
  Author: Denis Kras
6
6
  License: MIT License
@@ -1,4 +1,4 @@
1
- atomicshop/__init__.py,sha256=40D415x6iBWWnyUHnyzzhp2ZQ0Khnt9ol-hd9e49cEk,124
1
+ atomicshop/__init__.py,sha256=bhazsvVh5VR5g-yOQejRoBGt1q11o68HYHVYAVxKpXc,124
2
2
  atomicshop/_basics_temp.py,sha256=6cu2dd6r2dLrd1BRNcVDKTHlsHs_26Gpw8QS6v32lQ0,3699
3
3
  atomicshop/_create_pdf_demo.py,sha256=Yi-PGZuMg0RKvQmLqVeLIZYadqEZwUm-4A9JxBl_vYA,3713
4
4
  atomicshop/_patch_import.py,sha256=ENp55sKVJ0e6-4lBvZnpz9PQCt3Otbur7F6aXDlyje4,6334
@@ -127,7 +127,7 @@ atomicshop/file_io/xmls.py,sha256=zh3SuK-dNaFq2NDNhx6ivcf4GYCfGM8M10PcEwDSpxk,21
127
127
  atomicshop/mitm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
128
  atomicshop/mitm/config_static.py,sha256=HIzxyMEj7DZksYvJsN5VuKpB-_HSVvuR6U59ztS9gi0,7871
129
129
  atomicshop/mitm/config_toml_editor.py,sha256=2p1CMcktWRR_NW-SmyDwylu63ad5e0-w1QPMa8ZLDBw,1635
130
- atomicshop/mitm/connection_thread_worker.py,sha256=JZL87yV_7giOEJW64hm1fxAUQ5lz525o8HEj1s7VLvI,27505
130
+ atomicshop/mitm/connection_thread_worker.py,sha256=2180oQgD3qRS53zloeALs_vYt66RJWJtnaCqjl2jVs4,28187
131
131
  atomicshop/mitm/import_config.py,sha256=0Ij14aISTllTOiWYJpIUMOWobQqGofD6uafui5uWllE,9272
132
132
  atomicshop/mitm/initialize_engines.py,sha256=NWz0yBErSrYBn0xWkJDBcHStBJ-kcsv9VtorcSP9x5M,8258
133
133
  atomicshop/mitm/message.py,sha256=mNo4Lphr_Jo6IlNX5mPJzABpogWGkjOhwI4meAivwHw,2987
@@ -211,7 +211,7 @@ atomicshop/wrappers/ctyping/msi_windows_installer/cabs.py,sha256=htzwb2ROYI8yyc8
211
211
  atomicshop/wrappers/ctyping/msi_windows_installer/extract_msi_main.py,sha256=AEkjnqEhfCbCUcYaulv3uba5hZjTB03xm-puAINsZGM,5488
212
212
  atomicshop/wrappers/ctyping/msi_windows_installer/tables.py,sha256=tHsu0YfBgzuIk9L-PyqLgU_IzyVbCfy8L1EqelNnvWk,17674
213
213
  atomicshop/wrappers/dockerw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
214
- atomicshop/wrappers/dockerw/dockerw.py,sha256=7EAlhl0ZEnkGoIp-NlOL6ezx4OUQumhMqLzmjoezv7o,8338
214
+ atomicshop/wrappers/dockerw/dockerw.py,sha256=mwQT8d1aUrn8FbMCwcmUjoP35UWexl8DztNSuJAHJQo,9865
215
215
  atomicshop/wrappers/dockerw/install_docker.py,sha256=7NTMxCPBesr0QcqB0RZ5YU0I8FDPtNux_mYAX28wI0I,9982
216
216
  atomicshop/wrappers/elasticsearchw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
217
217
  atomicshop/wrappers/elasticsearchw/config_basic.py,sha256=fDujtrjEjbWiYh_WQ3OcYp_8mXhXPYeKLy4wSPL5qM0,1177
@@ -321,8 +321,8 @@ atomicshop/wrappers/socketw/statistics_csv.py,sha256=fgMzDXI0cybwUEqAxprRmY3lqbh
321
321
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
322
322
  atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
323
323
  atomicshop/wrappers/winregw/winreg_network.py,sha256=AENV88H1qDidrcpyM9OwEZxX5svfi-Jb4N6FkS1xtqA,8851
324
- atomicshop-2.18.24.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
325
- atomicshop-2.18.24.dist-info/METADATA,sha256=fesLwc3X1CCKBWf5ddn1SFSFJtVWTaPOyJrxaJbnWVU,10631
326
- atomicshop-2.18.24.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
327
- atomicshop-2.18.24.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
328
- atomicshop-2.18.24.dist-info/RECORD,,
324
+ atomicshop-2.18.26.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
325
+ atomicshop-2.18.26.dist-info/METADATA,sha256=PCGI4liQF8srGPeqAAiOEuUZE0z0r4Fv7oYEdd8FnGk,10631
326
+ atomicshop-2.18.26.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
327
+ atomicshop-2.18.26.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
328
+ atomicshop-2.18.26.dist-info/RECORD,,