pyntcli 0.1.116__py3-none-any.whl → 0.1.117__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.
- pyntcli/__init__.py +1 -1
- pyntcli/auth/login.py +0 -7
- pyntcli/pynt_docker/container_utils.py +48 -2
- pyntcli/pynt_docker/pynt_container.py +24 -34
- {pyntcli-0.1.116.dist-info → pyntcli-0.1.117.dist-info}/METADATA +1 -1
- {pyntcli-0.1.116.dist-info → pyntcli-0.1.117.dist-info}/RECORD +9 -9
- {pyntcli-0.1.116.dist-info → pyntcli-0.1.117.dist-info}/WHEEL +1 -1
- {pyntcli-0.1.116.dist-info → pyntcli-0.1.117.dist-info}/entry_points.txt +0 -0
- {pyntcli-0.1.116.dist-info → pyntcli-0.1.117.dist-info}/top_level.txt +0 -0
pyntcli/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.117"
|
pyntcli/auth/login.py
CHANGED
|
@@ -31,13 +31,6 @@ PYNT_SAAS = os.environ.get("PYNT_SAAS_URL") if os.environ.get(
|
|
|
31
31
|
"PYNT_SAAS_URL") else "https://api.pynt.io/v1"
|
|
32
32
|
PYNT_APP_URL = os.environ.get("PYNT_APP_URL") if os.environ.get(
|
|
33
33
|
"PYNT_APP_URL") else "https://app.pynt.io"
|
|
34
|
-
PYNT_BUCKET_NAME = os.environ.get(
|
|
35
|
-
"PYNT_BUCKET_NAME") if os.environ.get("PYNT_BUCKET_NAME") else ""
|
|
36
|
-
PYNT_PARAM1 = os.environ.get(
|
|
37
|
-
"PYNT_PARAM1") if os.environ.get("PYNT_PARAM1") else ""
|
|
38
|
-
PYNT_PARAM2 = os.environ.get(
|
|
39
|
-
"PYNT_PARAM2") if os.environ.get("PYNT_PARAM2") else ""
|
|
40
|
-
|
|
41
34
|
|
|
42
35
|
def generate_device_code() -> str:
|
|
43
36
|
"""
|
|
@@ -1,7 +1,53 @@
|
|
|
1
|
-
|
|
2
1
|
import socket
|
|
2
|
+
import subprocess
|
|
3
|
+
import time
|
|
4
|
+
from typing import Optional, List
|
|
5
|
+
|
|
6
|
+
GRACEFUL_KILL_TIMEOUT_SECONDS = 10
|
|
3
7
|
|
|
4
8
|
|
|
5
9
|
def is_port_in_use(port: int) -> bool:
|
|
6
10
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
7
|
-
return s.connect_ex((
|
|
11
|
+
return s.connect_ex(("localhost", port)) == 0
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def list_running_containers(
|
|
15
|
+
name: Optional[str] = None, container_id: Optional[str] = None
|
|
16
|
+
) -> List[str]:
|
|
17
|
+
ps_filter = []
|
|
18
|
+
if name is not None:
|
|
19
|
+
ps_filter.extend(["-f", f"name={name}"])
|
|
20
|
+
elif container_id is not None:
|
|
21
|
+
ps_filter.extend(["-f", f"id={container_id}"])
|
|
22
|
+
|
|
23
|
+
output = subprocess.check_output(
|
|
24
|
+
["docker", "ps", "-a", "-q", *ps_filter],
|
|
25
|
+
text=True,
|
|
26
|
+
)
|
|
27
|
+
return output.splitlines()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def kill_container_gracefully(container_id: str):
|
|
31
|
+
subprocess.run(
|
|
32
|
+
["docker", "kill", "--signal", "SIGINT", container_id],
|
|
33
|
+
stdout=subprocess.DEVNULL,
|
|
34
|
+
stderr=subprocess.DEVNULL,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
for _ in range(GRACEFUL_KILL_TIMEOUT_SECONDS):
|
|
38
|
+
time.sleep(1)
|
|
39
|
+
is_still_running = len(list_running_containers(container_id=container_id)) > 0
|
|
40
|
+
if not is_still_running:
|
|
41
|
+
return
|
|
42
|
+
|
|
43
|
+
if len(list_running_containers(container_id=container_id)) > 0:
|
|
44
|
+
kill_container_gracefully(container_id)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def kill_container(container_id: str):
|
|
48
|
+
# `doccker remove -f` sends SIGKILL
|
|
49
|
+
subprocess.run(
|
|
50
|
+
["docker", "remove", "-f", container_id],
|
|
51
|
+
stdout=subprocess.DEVNULL,
|
|
52
|
+
stderr=subprocess.DEVNULL,
|
|
53
|
+
)
|
|
@@ -7,17 +7,15 @@ import argparse
|
|
|
7
7
|
import threading
|
|
8
8
|
from datetime import datetime
|
|
9
9
|
from typing import List
|
|
10
|
-
import base64
|
|
11
10
|
|
|
12
11
|
from . import container_utils
|
|
13
12
|
|
|
14
13
|
from pyntcli.ui import ui_thread
|
|
15
14
|
from pyntcli.analytics import send as analytics
|
|
16
15
|
from pyntcli.store import CredStore
|
|
17
|
-
from pyntcli.auth.login import PYNT_ID, PYNT_SAAS
|
|
16
|
+
from pyntcli.auth.login import PYNT_ID, PYNT_SAAS
|
|
18
17
|
|
|
19
18
|
PYNT_DOCKER_IMAGE = "ghcr.io/pynt-io/pynt"
|
|
20
|
-
IMAGE_TAGS = ["postman-latest", "newman-latest", "har-latest", "proxy-latest", "v1-latest"]
|
|
21
19
|
|
|
22
20
|
|
|
23
21
|
def create_mount(src, destination, mount_type="bind"):
|
|
@@ -95,8 +93,9 @@ class DockerContainerConfig:
|
|
|
95
93
|
self.docker_arguments = build_docker_args(integration_name, args, port_args)
|
|
96
94
|
self.mounts = get_docker_mounts(args)
|
|
97
95
|
self.env_vars = {PYNT_ID: CredStore().get_tokens(), "PYNT_SAAS_URL": PYNT_SAAS}
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
otel_endpoint = os.environ.get("OTEL_COLLECTOR_ENDPOINT")
|
|
97
|
+
if otel_endpoint:
|
|
98
|
+
self.env_vars["OTEL_COLLECTOR_ENDPOINT"] = otel_endpoint
|
|
100
99
|
|
|
101
100
|
|
|
102
101
|
def get_image_config(args: argparse.Namespace) -> PyntDockerImage:
|
|
@@ -122,16 +121,6 @@ def is_network_host() -> bool:
|
|
|
122
121
|
return True
|
|
123
122
|
|
|
124
123
|
|
|
125
|
-
def user_set_all_variables():
|
|
126
|
-
return all([PYNT_BUCKET_NAME, PYNT_PARAM1, PYNT_PARAM2])
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
def add_env_variables(env: dict):
|
|
130
|
-
env["PYNT_BUCKET_NAME"] = PYNT_BUCKET_NAME
|
|
131
|
-
env["PYNT_PARAM1"] = base64.b64encode(PYNT_PARAM1.encode('utf-8')).decode('utf-8')
|
|
132
|
-
env["PYNT_PARAM2"] = base64.b64encode(PYNT_PARAM2.encode('utf-8')).decode('utf-8')
|
|
133
|
-
|
|
134
|
-
|
|
135
124
|
def value_from_environment_variable(key):
|
|
136
125
|
e = os.environ.get(key)
|
|
137
126
|
|
|
@@ -300,29 +289,23 @@ class PyntContainerNative:
|
|
|
300
289
|
# Start log streaming in a separate thread
|
|
301
290
|
DockerLogFollower(docker_exec, container_id).start()
|
|
302
291
|
|
|
303
|
-
def kill_other_instances(self,
|
|
292
|
+
def kill_other_instances(self, gracefully: bool) -> int:
|
|
304
293
|
ui_thread.print_verbose("Killing other pynt containers if such exist")
|
|
294
|
+
killed_containers = 0
|
|
305
295
|
try:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
for container_id in container_ids:
|
|
314
|
-
kill_command = ["docker", "kill", container_id]
|
|
315
|
-
remove_command = ["docker", "remove", container_id]
|
|
316
|
-
subprocess.run(kill_command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
317
|
-
subprocess.run(remove_command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
318
|
-
if report_to_user:
|
|
319
|
-
ui_thread.print(
|
|
320
|
-
ui_thread.PrinterText("Another Pynt container was running, killed it", ui_thread.PrinterText))
|
|
321
|
-
|
|
296
|
+
container_ids = container_utils.list_running_containers(name=self.container_name)
|
|
297
|
+
for container_id in container_ids:
|
|
298
|
+
if gracefully:
|
|
299
|
+
container_utils.kill_container_gracefully(container_id)
|
|
300
|
+
else:
|
|
301
|
+
container_utils.kill_container(container_id)
|
|
302
|
+
killed_containers += 1
|
|
322
303
|
except subprocess.CalledProcessError:
|
|
323
304
|
analytics.emit(analytics.ERROR, {"error": "Unable to kill other pynt containers"})
|
|
324
305
|
ui_thread.print(ui_thread.PrinterText("Error: Unable to kill other pynt containers", ui_thread.PrinterText.WARNING))
|
|
325
306
|
|
|
307
|
+
return killed_containers
|
|
308
|
+
|
|
326
309
|
def fetch_and_validate_image(self):
|
|
327
310
|
try:
|
|
328
311
|
ui_thread.print(ui_thread.PrinterText("Pulling latest docker image", ui_thread.PrinterText.INFO))
|
|
@@ -356,11 +339,18 @@ class PyntContainerNative:
|
|
|
356
339
|
def stop(self):
|
|
357
340
|
if not self.running:
|
|
358
341
|
return
|
|
359
|
-
self.kill_other_instances(
|
|
342
|
+
self.kill_other_instances(gracefully=True)
|
|
360
343
|
self.running = False
|
|
361
344
|
|
|
362
345
|
def pre_run_validation(self, port):
|
|
363
|
-
self.kill_other_instances()
|
|
346
|
+
killed_containers = self.kill_other_instances(gracefully=False)
|
|
347
|
+
if killed_containers > 0:
|
|
348
|
+
ui_thread.print(
|
|
349
|
+
ui_thread.PrinterText(
|
|
350
|
+
"Another Pynt container was running, killed it",
|
|
351
|
+
ui_thread.PrinterText,
|
|
352
|
+
)
|
|
353
|
+
)
|
|
364
354
|
|
|
365
355
|
ui_thread.print_verbose("Checking if port is in use")
|
|
366
356
|
if container_utils.is_port_in_use(int(port)):
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
ignoreTests/conftest.py,sha256=gToq5K74GtgeGQXjFvXSzMaE6axBYxAzcFG5XJPOXjI,427
|
|
2
2
|
ignoreTests/auth/login.py,sha256=7GeBirHTD9t6EassLYsegCw1FZHkfjvVW1Z5uybHzgM,3801
|
|
3
3
|
ignoreTests/store/cred_store.py,sha256=_7-917EtNC9eKEumO2_lt-7KuDmCwOZFaowCm7DbA_A,254
|
|
4
|
-
pyntcli/__init__.py,sha256=
|
|
4
|
+
pyntcli/__init__.py,sha256=tC6Ly5NZvDBZKJuC4iaO2NyJcqX7enbauSAG6rxadFU,24
|
|
5
5
|
pyntcli/main.py,sha256=RD0W2_0ogYBCXubo-YewxHYkiIXxNv6NkZOh3n1VujE,5964
|
|
6
6
|
pyntcli/analytics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
pyntcli/analytics/send.py,sha256=0hJ0WJNFHLqyohtRr_xOg5WEXzxHrUOlcePPg-k65Hk,3846
|
|
8
8
|
pyntcli/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
pyntcli/auth/login.py,sha256=
|
|
9
|
+
pyntcli/auth/login.py,sha256=qtdoCgWIPi3_YXehI7SVk_E8aDVhH39wGc87tlkazSE,5558
|
|
10
10
|
pyntcli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
pyntcli/commands/burp.py,sha256=9kcqjC9Rgj5oZimGZuA_oO71Hn2Z3py8k5vr-eMKnUM,14317
|
|
12
12
|
pyntcli/commands/command.py,sha256=ulxhWyTnuqQfyNy5somqBbQoTCvd0Hg4OnPJ8thJzAs,11078
|
|
@@ -24,8 +24,8 @@ pyntcli/commands/util.py,sha256=ev06aUlJ9tCSw1eAGVIsGlVVY4u0H6AJG9b5MB_bAzs,4594
|
|
|
24
24
|
pyntcli/log/__init__.py,sha256=cOGwOYzMoshEbZiiasBGkj6wF0SBu3Jdpl-AuakDesw,19
|
|
25
25
|
pyntcli/log/log.py,sha256=YXCvcCzuhQ5QUT2L02uQEdN_lTCzLEuet4OnLuEnjlM,112
|
|
26
26
|
pyntcli/pynt_docker/__init__.py,sha256=PQIOVxc7XXtMLfEX7ojgwf_Z3mmTllO3ZvzUZTPOxQY,30
|
|
27
|
-
pyntcli/pynt_docker/container_utils.py,sha256=
|
|
28
|
-
pyntcli/pynt_docker/pynt_container.py,sha256=
|
|
27
|
+
pyntcli/pynt_docker/container_utils.py,sha256=DeI-uSgdcO_2rGs2dvQ5gBDNo_iKKuPIQO2D9oej5Gw,1485
|
|
28
|
+
pyntcli/pynt_docker/pynt_container.py,sha256=7VG7e8mCabFUJoX-AuSnxVoXtO9ben-QQdNBL5Y5z9g,13861
|
|
29
29
|
pyntcli/saas_client/__init__.py,sha256=HPBzoC5a6F5_WkHubcjq_W4m1OQ9i0TX8QXBtJlKm1M,26
|
|
30
30
|
pyntcli/saas_client/saas_client.py,sha256=7mJNo2x4Oy2N4NKdHyGRxXZUk_VHZvRu1x586rojrp0,1756
|
|
31
31
|
pyntcli/store/__init__.py,sha256=1fP8cEAQCF_myja3gnhHH9FEqtBiOJ-2aBmUXSKBdFA,41
|
|
@@ -42,8 +42,8 @@ pyntcli/ui/report.py,sha256=W-icPSZrGLOubXgam0LpOvHLl_aZg9Zx9qIkL8Ym5PE,1930
|
|
|
42
42
|
pyntcli/ui/ui_thread.py,sha256=XUBgLpYQjVhrilU-ofw7VSXgTiwneSdTxm61EvC3x4Q,5091
|
|
43
43
|
tests/test_utils.py,sha256=t5fTQUk1U_Js6iMxcGYGqt4C-crzOJ0CqCKtLkRtUi0,2050
|
|
44
44
|
tests/commands/test_pynt_cmd.py,sha256=J4JrEuD_qSVN76Fu6bKRjrxWSwCTXVEAzVPYdXMa0tI,8826
|
|
45
|
-
pyntcli-0.1.
|
|
46
|
-
pyntcli-0.1.
|
|
47
|
-
pyntcli-0.1.
|
|
48
|
-
pyntcli-0.1.
|
|
49
|
-
pyntcli-0.1.
|
|
45
|
+
pyntcli-0.1.117.dist-info/METADATA,sha256=R8P0CNK4GXBEwOB-ky2Qxu9lHrURd-eogrp1lIF3pwo,427
|
|
46
|
+
pyntcli-0.1.117.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
47
|
+
pyntcli-0.1.117.dist-info/entry_points.txt,sha256=kcGmqAxXDttNk2EPRcqunc_LTVp61gzakz0v-GEE2SY,43
|
|
48
|
+
pyntcli-0.1.117.dist-info/top_level.txt,sha256=64XSgBzSpgwjYjEKHZE7q3JH2a816zEeyZBXfJi3AKI,42
|
|
49
|
+
pyntcli-0.1.117.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|