atomicshop 2.18.23__py3-none-any.whl → 2.18.25__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.23'
4
+ __version__ = '2.18.25'
@@ -36,13 +36,18 @@ 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.response_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
 
43
48
  # Same goes for the '.command' attribute, if it is not HTTP message then there will be no command.
44
49
  try:
45
- http_command: str = client_message.response_auto_parsed.command
50
+ http_command: str = client_message.request_auto_parsed.command
46
51
  except AttributeError:
47
52
  http_command: str = str()
48
53
 
@@ -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,4 +1,5 @@
1
1
  import docker
2
+ from docker.models.containers import Container
2
3
 
3
4
  from ...print_api import print_api
4
5
 
@@ -167,3 +168,57 @@ def add_execution_permissions_for_file(image_id_or_name: str, file_path: str, pr
167
168
  list_of_commands=[f"chmod +x {file_path}"],
168
169
  print_kwargs=print_kwargs
169
170
  )
171
+
172
+
173
+ def stop_remove_containers_by_image_name(image_name: str):
174
+ """
175
+ Remove all containers by image name.
176
+ :param image_name: str, the name of the image.
177
+ :return:
178
+ """
179
+ client = docker.from_env()
180
+ all_containers = client.containers.list(all=True)
181
+ for container in all_containers:
182
+ if any(image_name in tag for tag in container.image.tags):
183
+ if container.status == "running":
184
+ print_api(f"Stopping container: [{container.name}]. Short ID: [{container.short_id}]")
185
+ container.stop()
186
+ container.remove()
187
+ client.close()
188
+
189
+
190
+ def start_container_without_stop(image_name: str, **kwargs) -> Container:
191
+ """
192
+ Start a container in detached mode, this container will not run the entry point, but will run the infinite sleep.
193
+ This way the container will continue running, you can execute commands in it and stop it manually when needed.
194
+ :param image_name: str, the name of the image.
195
+ :return:
196
+ """
197
+ client = docker.from_env()
198
+
199
+ kwargs.setdefault('detach', True)
200
+ kwargs.setdefault('mem_limit', '512m')
201
+ kwargs.setdefault('ulimits', [docker.types.Ulimit(name='nofile', soft=20000, hard=50000)])
202
+ kwargs.setdefault('remove', False)
203
+
204
+ # Start the container with a "do nothing" command so it stays running
205
+ print_api(f"Starting container from image '{image_name}'...")
206
+ container = client.containers.run(
207
+ image=image_name,
208
+ entrypoint=["/bin/sh", "-c", "tail -f /dev/null"],
209
+ **kwargs
210
+ )
211
+
212
+ stdout = container.logs(stdout=True, stderr=False).decode()
213
+ stderr = container.logs(stdout=False, stderr=True).decode()
214
+ if stdout:
215
+ print_api(f"Container stdout: {stdout}")
216
+ if stderr:
217
+ print_api(f"Container stderr: {stderr}")
218
+
219
+ if not stderr:
220
+ print_api("Container started successfully.")
221
+
222
+ print_api(f"Started container: [{container.name}]. Short ID: [{container.short_id}]")
223
+
224
+ return container
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 2.18.23
3
+ Version: 2.18.25
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=TOJZyGtDB7N_DCBbBdTeSRLcWWwRhtH02juoLGZ2oDs,124
1
+ atomicshop/__init__.py,sha256=VYY4rRuPaRWzCl2qpmWJGJNhw3urqzTdtnJA8xHBRFE,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=fdeRBF8Ff-LgD_1PeGPVm2ET4BhRY_rCvESEuiJfWPI,27507
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=w8zSJr5C7cbvbuG09ORCpAe0BOcibqqL_Z2EKEBHYK4,6266
214
+ atomicshop/wrappers/dockerw/dockerw.py,sha256=7EAlhl0ZEnkGoIp-NlOL6ezx4OUQumhMqLzmjoezv7o,8338
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.23.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
325
- atomicshop-2.18.23.dist-info/METADATA,sha256=dp_b-W8f6jCO2JA-Ep5MoLeAAZANWZaj7iErb84MX7A,10631
326
- atomicshop-2.18.23.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
327
- atomicshop-2.18.23.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
328
- atomicshop-2.18.23.dist-info/RECORD,,
324
+ atomicshop-2.18.25.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
325
+ atomicshop-2.18.25.dist-info/METADATA,sha256=_5QbjevzVET5wXMH4nvX5y92B_0rCxCdP1xxrubqVsk,10631
326
+ atomicshop-2.18.25.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
327
+ atomicshop-2.18.25.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
328
+ atomicshop-2.18.25.dist-info/RECORD,,