atomicshop 3.1.1__py3-none-any.whl → 3.1.3__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__ = '3.1.1'
4
+ __version__ = '3.1.3'
@@ -341,7 +341,7 @@ def thread_worker_main(
341
341
  client_message = client_connection_message
342
342
 
343
343
  bytes_to_send_list: list[bytes] = create_responder_response(client_message)
344
- print_api(f"Got responses from responder, count: [{len(bytes_to_send_list)}]", logger=network_logger,
344
+ print_api(f"Got responses from connect responder, count: [{len(bytes_to_send_list)}]", logger=network_logger,
345
345
  logger_method='info')
346
346
  else:
347
347
  client_message.reinitialize_dynamic_vars()
@@ -172,16 +172,6 @@ def add_execution_permissions_for_file(image_id_or_name: str, file_path: str, pr
172
172
 
173
173
 
174
174
  def stop_remove_containers_by_image_name(image_name: str):
175
- def stop_remove_container(container: Container):
176
- """
177
- Stop and remove a container.
178
- :param container: Container, the docker container object.
179
- :return:
180
- """
181
- if container.status == "running":
182
- print_api(f"Stopping container: [{container.name}]. Short ID: [{container.short_id}]")
183
- container.stop()
184
- container.remove()
185
175
  """
186
176
  Remove all containers by image name.
187
177
  :param image_name: str, the name of the image.
@@ -189,8 +179,8 @@ def stop_remove_containers_by_image_name(image_name: str):
189
179
  """
190
180
  client = docker.from_env()
191
181
  all_containers = client.containers.list(all=True)
192
- for current_container in all_containers:
193
- if any(image_name in tag for tag in current_container.image.tags):
182
+ for container in all_containers:
183
+ if any(image_name in tag for tag in container.image.tags):
194
184
  if container.status == "running":
195
185
  print_api(f"Stopping container: [{container.name}]. Short ID: [{container.short_id}]")
196
186
  container.stop()
@@ -241,7 +231,7 @@ def start_container_without_stop(
241
231
  return client, container
242
232
 
243
233
 
244
- def run_command_in_running_container(container: Container, command: list) -> tuple[int, str]:
234
+ def run_command_in_running_container(container: Container, command: list) -> tuple[int, bytes, str]:
245
235
  """
246
236
  Run a command in a running container.
247
237
  :param container: Container, the docker container object.
@@ -250,8 +240,22 @@ def run_command_in_running_container(container: Container, command: list) -> tup
250
240
  """
251
241
 
252
242
  # Run the command inside the already running container
253
- status_code, output_bytes = container.exec_run(cmd=command, stdout=True, stderr=True)
243
+ exec_result = container.exec_run(cmd=command, stdout=True, stderr=True)
254
244
  # Capture logs
255
- output_text = output_bytes.decode("utf-8", errors="replace")
256
-
257
- return status_code, output_text
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
@@ -867,7 +867,7 @@ def find(
867
867
  entries[entry_index]['_id'] = str(entry['_id'])
868
868
 
869
869
  if key_convert_to_dict and entries:
870
- entries = _convert_key_values_to_objects(keys_convert_to_dict=key_convert_to_dict, returned_data=entries)
870
+ entries = convert_key_values_to_objects(keys_convert_to_dict=key_convert_to_dict, returned_data=entries)
871
871
 
872
872
  if close_client:
873
873
  mongo_client.close()
@@ -1398,7 +1398,7 @@ def get_stats_db_size(
1398
1398
  return stats['dataSize']
1399
1399
 
1400
1400
 
1401
- def _convert_key_values_to_objects(
1401
+ def convert_key_values_to_objects(
1402
1402
  keys_convert_to_dict: list[str],
1403
1403
  returned_data: Union[dict, list]
1404
1404
  ) -> Union[dict, list]:
@@ -1424,9 +1424,9 @@ def _convert_key_values_to_objects(
1424
1424
  # This is needed only to know the possible exception types.
1425
1425
  raise
1426
1426
  else:
1427
- _convert_key_values_to_objects(keys_convert_to_dict, value)
1427
+ convert_key_values_to_objects(keys_convert_to_dict, value)
1428
1428
  elif isinstance(returned_data, list):
1429
1429
  for i, item in enumerate(returned_data):
1430
- returned_data[i] = _convert_key_values_to_objects(keys_convert_to_dict, item)
1430
+ returned_data[i] = convert_key_values_to_objects(keys_convert_to_dict, item)
1431
1431
 
1432
1432
  return returned_data
@@ -539,10 +539,15 @@ class SocketWrapper:
539
539
  process_name = get_command_instance.get_process_name(print_kwargs={'logger': self.logger})
540
540
 
541
541
  source_ip: str = client_address[0]
542
- source_hostname: str = socket.gethostbyaddr(source_ip)[0]
543
542
  engine_name: str = get_engine_name(domain_from_engine, self.engines_list)
544
543
  dest_port: int = listening_socket_object.getsockname()[1]
545
544
 
545
+ # Not always there will be a hostname resolved by the IP address, so we will leave it empty if it fails.
546
+ try:
547
+ source_hostname: str = socket.gethostbyaddr(source_ip)[0]
548
+ except socket.herror:
549
+ source_hostname = ''
550
+
546
551
  # If 'accept()' function worked well, SSL worked well, then 'client_socket' won't be empty.
547
552
  if client_socket:
548
553
  # Get the protocol type from the socket.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: atomicshop
3
- Version: 3.1.1
3
+ Version: 3.1.3
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=xTnJCkq3gj1NeN0vpvfRoCBltskMb4tZN_7g3G8Sg28,122
1
+ atomicshop/__init__.py,sha256=iecTS2GszzrWWXhhrFgck5TiMcZTtx_WUNY90_aJA6k,122
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
@@ -136,7 +136,7 @@ atomicshop/file_io/xmls.py,sha256=zh3SuK-dNaFq2NDNhx6ivcf4GYCfGM8M10PcEwDSpxk,21
136
136
  atomicshop/mitm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
137
137
  atomicshop/mitm/config_static.py,sha256=N3D06C_wUytwm80PQCL90ZGHLMHeQlCcI2XQQU2FZ1I,8145
138
138
  atomicshop/mitm/config_toml_editor.py,sha256=2p1CMcktWRR_NW-SmyDwylu63ad5e0-w1QPMa8ZLDBw,1635
139
- atomicshop/mitm/connection_thread_worker.py,sha256=ulE5x3hxWyd6gSyahSE-wpnF6VYl_wsJNBbNC0DzKU4,28499
139
+ atomicshop/mitm/connection_thread_worker.py,sha256=Iea2XszWwqcvIq1eyRDBkIuW1uUQHVaAxfdA9EZolac,28507
140
140
  atomicshop/mitm/import_config.py,sha256=gCH1hV-CxBAdwjeFJu1I5ntbm5hqzcB0y0vzRPkzra0,16936
141
141
  atomicshop/mitm/initialize_engines.py,sha256=Pj9k3iLdoE0KAl3QWG1Z10LHUHY8WQivSPFnQLhCWrc,7385
142
142
  atomicshop/mitm/message.py,sha256=CDhhm4BTuZE7oNZCjvIZ4BuPOW4MuIzQLOg91hJaxDI,3065
@@ -223,7 +223,7 @@ atomicshop/wrappers/ctyping/msi_windows_installer/cabs.py,sha256=htzwb2ROYI8yyc8
223
223
  atomicshop/wrappers/ctyping/msi_windows_installer/extract_msi_main.py,sha256=AEkjnqEhfCbCUcYaulv3uba5hZjTB03xm-puAINsZGM,5488
224
224
  atomicshop/wrappers/ctyping/msi_windows_installer/tables.py,sha256=tHsu0YfBgzuIk9L-PyqLgU_IzyVbCfy8L1EqelNnvWk,17674
225
225
  atomicshop/wrappers/dockerw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
226
- atomicshop/wrappers/dockerw/dockerw.py,sha256=cVLUiMetBDlvFVNnX9wzVsUO1ylJxQfEwEw8FOEg37w,9659
226
+ atomicshop/wrappers/dockerw/dockerw.py,sha256=mwQT8d1aUrn8FbMCwcmUjoP35UWexl8DztNSuJAHJQo,9865
227
227
  atomicshop/wrappers/dockerw/install_docker.py,sha256=7NTMxCPBesr0QcqB0RZ5YU0I8FDPtNux_mYAX28wI0I,9982
228
228
  atomicshop/wrappers/elasticsearchw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
229
229
  atomicshop/wrappers/elasticsearchw/config_basic.py,sha256=fDujtrjEjbWiYh_WQ3OcYp_8mXhXPYeKLy4wSPL5qM0,1177
@@ -275,7 +275,7 @@ atomicshop/wrappers/mongodbw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
275
275
  atomicshop/wrappers/mongodbw/install_mongodb_ubuntu.py,sha256=2eEOb35T259lhn5koynfTIm1hanxD02zN97ExGSBM2o,4021
276
276
  atomicshop/wrappers/mongodbw/install_mongodb_win.py,sha256=64EUQYx7VuMC3ndO2x3nSErh5NZ_BsqMwGvPcybfC-Q,8499
277
277
  atomicshop/wrappers/mongodbw/mongo_infra.py,sha256=IjEF0jPzQz866MpTm7rnksnyyWQeUT_B2h2DA9ryAio,2034
278
- atomicshop/wrappers/mongodbw/mongodbw.py,sha256=_C-v0ZKM7SRThZOnpOtUKmy3fvcvdiGQNvLCo3Drgls,56053
278
+ atomicshop/wrappers/mongodbw/mongodbw.py,sha256=CHbDfW9CXzXUs3V97DYQpt-dYlt_gB60JhwqG2tVFQY,56049
279
279
  atomicshop/wrappers/nodejsw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
280
280
  atomicshop/wrappers/nodejsw/install_nodejs_ubuntu.py,sha256=wjpJdfAaY92RYl_L9esDIWuBMGeYH35RHJ5BVgMof8Y,6260
281
281
  atomicshop/wrappers/nodejsw/install_nodejs_windows.py,sha256=WvXIcEVnKcQYD-KNwhVP094s__1tt0Ir2Y87MABl8Nc,6283
@@ -330,14 +330,14 @@ atomicshop/wrappers/socketw/sender.py,sha256=aX_K8l_rHjd5AWb8bi5mt8-YTkMYVRDB6Dn
330
330
  atomicshop/wrappers/socketw/sni.py,sha256=q-F-R1KtE94g8WGrR3QHgi-otXZJUPBprEwQqnY80_A,17639
331
331
  atomicshop/wrappers/socketw/socket_client.py,sha256=AQKjm_GZLH2PO7gkFbwzIbXzUXxRFvBTc6onrgapFqs,22048
332
332
  atomicshop/wrappers/socketw/socket_server_tester.py,sha256=Qobmh4XV8ZxLUaw-eW4ESKAbeSLecCKn2OWFzMhadk0,6420
333
- atomicshop/wrappers/socketw/socket_wrapper.py,sha256=hOOEpA-QNtCGroBzFDpOeD8z2KJWMVTiWaoUvtB1qvU,40886
333
+ atomicshop/wrappers/socketw/socket_wrapper.py,sha256=3sEz1VUar1JJU8KxocrOT09-vIh5hLpE29aTZH9TNC8,41117
334
334
  atomicshop/wrappers/socketw/ssl_base.py,sha256=kmiif84kMhBr5yjQW17p935sfjR5JKG0LxIwBA4iVvU,2275
335
335
  atomicshop/wrappers/socketw/statistics_csv.py,sha256=WcNyaqEZ82S5-f3kzqi1nllNT2Nd2P_zg8HqCc7vW4s,4120
336
336
  atomicshop/wrappers/winregw/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
337
337
  atomicshop/wrappers/winregw/winreg_installed_software.py,sha256=Qzmyktvob1qp6Tjk2DjLfAqr_yXV0sgWzdMW_9kwNjY,2345
338
338
  atomicshop/wrappers/winregw/winreg_network.py,sha256=3Ts1sVqSUiCDsHRHwJCbiZ9EYvv2ELGxF0Y_pibGU4k,9596
339
- atomicshop-3.1.1.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
340
- atomicshop-3.1.1.dist-info/METADATA,sha256=NGjnb2e0ON4vpeuBk4ELqQCNXm9SwV1o9L1js94ufRY,10653
341
- atomicshop-3.1.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
342
- atomicshop-3.1.1.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
343
- atomicshop-3.1.1.dist-info/RECORD,,
339
+ atomicshop-3.1.3.dist-info/LICENSE.txt,sha256=lLU7EYycfYcK2NR_1gfnhnRC8b8ccOTElACYplgZN88,1094
340
+ atomicshop-3.1.3.dist-info/METADATA,sha256=j8iedLkgbjssGczhijWtmc-mcil_AE8Z-LLIuJm_U4I,10653
341
+ atomicshop-3.1.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
342
+ atomicshop-3.1.3.dist-info/top_level.txt,sha256=EgKJB-7xcrAPeqTRF2laD_Np2gNGYkJkd4OyXqpJphA,11
343
+ atomicshop-3.1.3.dist-info/RECORD,,