pyntcli 0.1.75__py3-none-any.whl → 0.1.76__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 +16 -6
- {pyntcli-0.1.75.dist-info → pyntcli-0.1.76.dist-info}/METADATA +1 -1
- {pyntcli-0.1.75.dist-info → pyntcli-0.1.76.dist-info}/RECORD +8 -8
- tests/auth/test_login.py +18 -4
- {pyntcli-0.1.75.dist-info → pyntcli-0.1.76.dist-info}/WHEEL +0 -0
- {pyntcli-0.1.75.dist-info → pyntcli-0.1.76.dist-info}/entry_points.txt +0 -0
- {pyntcli-0.1.75.dist-info → pyntcli-0.1.76.dist-info}/top_level.txt +0 -0
pyntcli/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.76"
|
pyntcli/auth/login.py
CHANGED
|
@@ -25,10 +25,15 @@ class InvalidTokenInEnvVarsException(LoginException):
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
PYNT_ID = "PYNT_ID"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
PYNT_CREDENTIALS = "PYNT_CREDENTIALS"
|
|
29
|
+
PYNT_SAAS = os.environ.get("PYNT_SAAS_URL") if os.environ.get(
|
|
30
|
+
"PYNT_SAAS_URL") else "https://api.pynt.io/v1"
|
|
31
|
+
PYNT_BUCKET_NAME = os.environ.get(
|
|
32
|
+
"PYNT_BUCKET_NAME") if os.environ.get("PYNT_BUCKET_NAME") else ""
|
|
33
|
+
PYNT_PARAM1 = os.environ.get(
|
|
34
|
+
"PYNT_PARAM1") if os.environ.get("PYNT_PARAM1") else ""
|
|
35
|
+
PYNT_PARAM2 = os.environ.get(
|
|
36
|
+
"PYNT_PARAM2") if os.environ.get("PYNT_PARAM2") else ""
|
|
32
37
|
|
|
33
38
|
|
|
34
39
|
class Login():
|
|
@@ -40,7 +45,9 @@ class Login():
|
|
|
40
45
|
|
|
41
46
|
def create_login_request(self):
|
|
42
47
|
request_id = uuid.uuid4()
|
|
43
|
-
request_url = self.base_authorization_url +
|
|
48
|
+
request_url = self.base_authorization_url + \
|
|
49
|
+
urllib.parse.urlencode(
|
|
50
|
+
{"request_id": request_id, "utm_source": "cli"})
|
|
44
51
|
webbrowser.open(request_url)
|
|
45
52
|
|
|
46
53
|
ui_thread.print(ui_thread.PrinterText("To continue, you need to log in to your account.")
|
|
@@ -54,7 +61,8 @@ class Login():
|
|
|
54
61
|
with ui_thread.spinner("Waiting...", "point"):
|
|
55
62
|
start = time.time()
|
|
56
63
|
while start + self.login_wait_period > time.time():
|
|
57
|
-
response = pynt_requests.get(self.poll_url, params={
|
|
64
|
+
response = pynt_requests.get(self.poll_url, params={
|
|
65
|
+
"request_id": request_id})
|
|
58
66
|
if response.status_code == 200:
|
|
59
67
|
return response.json()
|
|
60
68
|
time.sleep(self.delay)
|
|
@@ -153,6 +161,8 @@ def validate_creds_structure(data):
|
|
|
153
161
|
|
|
154
162
|
def should_login():
|
|
155
163
|
env_creds = os.environ.get(PYNT_ID, None)
|
|
164
|
+
if not env_creds:
|
|
165
|
+
env_creds = os.environ.get(PYNT_CREDENTIALS, None)
|
|
156
166
|
if env_creds:
|
|
157
167
|
validated_creds = validate_creds_structure(env_creds)
|
|
158
168
|
with CredStore() as store:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
pyntcli/__init__.py,sha256=
|
|
1
|
+
pyntcli/__init__.py,sha256=jVtRNUwef3C7goIQGYOlvZVl9Bl7_p_NJdso3mdhBCM,23
|
|
2
2
|
pyntcli/main.py,sha256=7ZDeG3IO04T98D2NJ1vHWVAVJVm8y719NeV2Aom7tPY,5171
|
|
3
3
|
pyntcli/analytics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
pyntcli/analytics/send.py,sha256=cKvMw4HIGJGLip5OMPqTv1AJDlKlc_Uk2Sfcl0e3QLE,2845
|
|
5
5
|
pyntcli/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
pyntcli/auth/login.py,sha256=
|
|
6
|
+
pyntcli/auth/login.py,sha256=TljsRXbEkNI1YUrKm5mlTw4YiecYScYUsit8Z8vstss,5228
|
|
7
7
|
pyntcli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
8
|
pyntcli/commands/burp.py,sha256=tbGpKP4NEuEZYSuBxqvLJaC4kRqtv0GO6BpBfPX2DRM,10397
|
|
9
9
|
pyntcli/commands/command.py,sha256=UvJEHv69iQ03R0pN2RCsi3my48xwSMoDBTvcnbg_XzE,9477
|
|
@@ -33,10 +33,10 @@ pyntcli/ui/pynt_errors.py,sha256=UAr8OV5EM4zLhfWSmK_qss8nal2Ezo66Dk8ZMvR_RTs,546
|
|
|
33
33
|
pyntcli/ui/report.py,sha256=W-icPSZrGLOubXgam0LpOvHLl_aZg9Zx9qIkL8Ym5PE,1930
|
|
34
34
|
pyntcli/ui/ui_thread.py,sha256=OVTbiIFMg2KgxAvHf7yy86xGm4RVS2vj_VYZkMi-SRY,4956
|
|
35
35
|
tests/conftest.py,sha256=gToq5K74GtgeGQXjFvXSzMaE6axBYxAzcFG5XJPOXjI,427
|
|
36
|
-
tests/auth/test_login.py,sha256=
|
|
36
|
+
tests/auth/test_login.py,sha256=KFlzWhXBAuwdi7GXf16gCB3ya94LQG2wjcSChE149rQ,3798
|
|
37
37
|
tests/store/test_cred_store.py,sha256=_7-917EtNC9eKEumO2_lt-7KuDmCwOZFaowCm7DbA_A,254
|
|
38
|
-
pyntcli-0.1.
|
|
39
|
-
pyntcli-0.1.
|
|
40
|
-
pyntcli-0.1.
|
|
41
|
-
pyntcli-0.1.
|
|
42
|
-
pyntcli-0.1.
|
|
38
|
+
pyntcli-0.1.76.dist-info/METADATA,sha256=JXoZK9xKFquRF05o6XSLXhLjQOpSgl8iNsFYHylrsHc,463
|
|
39
|
+
pyntcli-0.1.76.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
40
|
+
pyntcli-0.1.76.dist-info/entry_points.txt,sha256=kcGmqAxXDttNk2EPRcqunc_LTVp61gzakz0v-GEE2SY,43
|
|
41
|
+
pyntcli-0.1.76.dist-info/top_level.txt,sha256=u9MDStwVHB7UG8PUcODeWCul_NvzL2EzoLvSlgwLHFs,30
|
|
42
|
+
pyntcli-0.1.76.dist-info/RECORD,,
|
tests/auth/test_login.py
CHANGED
|
@@ -10,7 +10,7 @@ import os
|
|
|
10
10
|
from cryptography.hazmat.primitives.asymmetric import rsa
|
|
11
11
|
from cryptography.hazmat.primitives import serialization
|
|
12
12
|
|
|
13
|
-
from pyntcli.auth.login import Login, Timeout, InvalidTokenInEnvVarsException, is_jwt_expired, should_login, PYNT_ID
|
|
13
|
+
from pyntcli.auth.login import Login, Timeout, InvalidTokenInEnvVarsException, is_jwt_expired, should_login, PYNT_ID, PYNT_CREDENTIALS
|
|
14
14
|
from pyntcli.store import CredStore
|
|
15
15
|
|
|
16
16
|
|
|
@@ -74,17 +74,19 @@ class TestLogin():
|
|
|
74
74
|
"exp": int((datetime.datetime.now() - datetime.timedelta(days=1)).timestamp())
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
token = jwt.encode(token_data, private_key.decode(),
|
|
77
|
+
token = jwt.encode(token_data, private_key.decode(),
|
|
78
|
+
algorithm="RS256").decode("utf-8")
|
|
78
79
|
assert is_jwt_expired(token) == True
|
|
79
80
|
|
|
80
81
|
token_data = {
|
|
81
82
|
"exp": int((datetime.datetime.now() + datetime.timedelta(days=1)).timestamp())
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
token = jwt.encode(token_data, private_key.decode(),
|
|
85
|
+
token = jwt.encode(token_data, private_key.decode(),
|
|
86
|
+
algorithm="RS256").decode("utf-8")
|
|
85
87
|
assert is_jwt_expired(token) == False
|
|
86
88
|
|
|
87
|
-
def
|
|
89
|
+
def test_login_using_pynt_id_env_vars(self, mocker, mock_expanduser):
|
|
88
90
|
creds = json.dumps({"token": {"refresh_token": "some data"}})
|
|
89
91
|
mocker.patch.dict(os.environ, {PYNT_ID: creds})
|
|
90
92
|
assert should_login() == False
|
|
@@ -92,3 +94,15 @@ class TestLogin():
|
|
|
92
94
|
os.environ[PYNT_ID] = "some bad credentials"
|
|
93
95
|
with pytest.raises(InvalidTokenInEnvVarsException):
|
|
94
96
|
should_login()
|
|
97
|
+
|
|
98
|
+
def test_login_using_pynt_cred_env_vars(self, mocker, mock_expanduser):
|
|
99
|
+
creds = json.dumps({"token": {"refresh_token": "some data"}})
|
|
100
|
+
mocker.patch.dict(os.environ, {PYNT_CREDENTIALS: creds})
|
|
101
|
+
assert should_login() == False
|
|
102
|
+
|
|
103
|
+
os.environ[PYNT_CREDENTIALS] = "some bad credentials"
|
|
104
|
+
with pytest.raises(InvalidTokenInEnvVarsException):
|
|
105
|
+
should_login()
|
|
106
|
+
|
|
107
|
+
def test_should_login_no_env_var(self, mocker, mock_expanduser):
|
|
108
|
+
assert should_login() == True
|
|
File without changes
|
|
File without changes
|
|
File without changes
|