pyntcli 0.1.117__py3-none-any.whl → 0.1.118__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 CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.117"
1
+ __version__ = "0.1.118"
@@ -98,7 +98,8 @@ class CommandSubCommand(sub_command.PyntSubCommand):
98
98
  env_copy.update(
99
99
  {
100
100
  "http_proxy": "http://localhost:{}".format(args.proxy_port),
101
- "https_proxy": "http://localhost:{}".format(args.proxy_port)
101
+ "https_proxy": "http://localhost:{}".format(args.proxy_port),
102
+ "JAVA_TOOL_OPTIONS": "-Dhttp.proxyHost=localhost -Dhttp.proxyPort={} -Dhttps.proxyHost=localhost -Dhttps.proxyPort={}".format(args.proxy_port, args.proxy_port),
102
103
  }
103
104
  )
104
105
  return env_copy
@@ -1,5 +1,4 @@
1
1
  import argparse
2
- import requests
3
2
  from typing import Dict, List
4
3
  from datetime import datetime, timedelta
5
4
  from pyntcli import __version__ as cli_version
@@ -134,30 +133,36 @@ class PyntCommand:
134
133
  return False
135
134
 
136
135
  def _post_login_args_validation(self, args: argparse.Namespace, command: str, is_business_plan_user: bool):
136
+ if not is_business_plan_user:
137
+ # All other validations only relevant for business plan users
138
+ return
139
+
140
+ if command in commands_without_app_id:
141
+ # Skip application validation if it isn't required
142
+ return
143
+
144
+
137
145
  if getattr(args, "application_name"):
138
- try:
139
- pynt_client.get_application_by_name(args.application_name)
140
- except HTTPError as e:
141
- if e.response.status_code == 404:
142
- if getattr(args, "yes") or self._is_auto_create_app_confirmed(args.application_name):
143
- return
144
- else:
145
- raise UserAbortedException()
146
- if getattr(args, "yes") or self._is_missing_app_id_confirmed():
146
+ # When `--application-name` exists, we'll validate its existence.
147
+ # If the validation fails due to some error, we'll throw it back as we can't continue the execution.
148
+ #
149
+ # In any case, when `application-name` is provided, we don't need `application-id`
150
+ if pynt_client.validate_application_name_exists(args.application_name):
151
+ return
152
+
153
+ # Application does not exist, validate if the user wants to create it automatically
154
+ if getattr(args, "yes") or self._is_auto_create_app_confirmed(args.application_name):
147
155
  return
148
156
  else:
149
157
  raise UserAbortedException()
150
158
 
151
- # Confirm not using application-id flag if applicable
152
- if getattr(args, "application_id") or command in commands_without_app_id:
159
+ if getattr(args, "application_id"):
153
160
  return
154
161
 
155
- # For a business user, it's recommended to always provide the application-id.
156
- if is_business_plan_user:
157
- if getattr(args, "yes") or self._is_missing_app_id_confirmed():
158
- return
159
- else:
160
- raise UserAbortedException()
162
+ if getattr(args, "yes") or self._is_missing_app_id_confirmed():
163
+ return
164
+ else:
165
+ raise UserAbortedException()
161
166
 
162
167
  def is_confirmed(self, prompt_history_key: str, confirmation_message: str, default_confirmation: str) -> bool:
163
168
  """
@@ -195,5 +200,5 @@ class PyntCommand:
195
200
 
196
201
 
197
202
  def _is_auto_create_app_confirmed(self, application_name: str) -> bool:
198
- return self.is_confirmed("", f"Application {application_name} will be created automatically if it does not exist.\n" +
203
+ return self.is_confirmed("", f"Application {application_name} will be created automatically as it does not exist.\n" +
199
204
  f"Do you want to continue with the application name {application_name}?", "yes")
@@ -1,3 +1,4 @@
1
+ import json
1
2
  import os
2
3
  import requests
3
4
 
@@ -5,7 +6,6 @@ import pyntcli.log.log as log
5
6
  from pyntcli.store import CredStore
6
7
 
7
8
  PYNT_SAAS = os.environ.get("PYNT_SAAS_URL", "https://api.pynt.io/v1")
8
- logger = log.get_logger()
9
9
 
10
10
  class PyntClient:
11
11
  def __init__(self, base_url=PYNT_SAAS):
@@ -29,28 +29,29 @@ class PyntClient:
29
29
  return response.json() # returning actual data
30
30
 
31
31
  except requests.exceptions.HTTPError as e:
32
- logger.error(f"HTTP error accessing '{url}': {e}")
33
32
  raise e
34
- except requests.exceptions.RequestException as e:
35
- logger.error(f"Error accessing '{url}': {e}")
33
+ except requests.exceptions.RequestException:
34
+ pass
36
35
 
37
36
  return None
38
37
 
39
- def get_application_by_name(self, application_name):
40
- url = f"{self.base_url}/application/{application_name}"
38
+ def validate_application_name_exists(self, application_name):
39
+ url = f"{self.base_url}/application"
41
40
  headers = self._get_headers()
42
-
43
- try:
44
- response = requests.get(url, headers=headers)
45
- response.raise_for_status()
46
- return response.json() # returning actual data
47
-
48
- except requests.exceptions.HTTPError as e:
49
- logger.error(f"HTTP error accessing '{url}': {e}")
50
- raise e
51
- except requests.exceptions.RequestException as e:
52
- logger.error(f"Error accessing '{url}': {e}")
53
-
54
- return None
41
+ query_filter = {
42
+ "filter": json.dumps({
43
+ "where": {
44
+ "name": application_name,
45
+ },
46
+ })
47
+ }
48
+
49
+ applications_response = requests.get(url, headers=headers, params=query_filter)
50
+ if applications_response.status_code == 404:
51
+ return False
52
+ applications_response.raise_for_status()
53
+
54
+ applications = applications_response.json()
55
+ return len(applications) == 1
55
56
 
56
57
  pynt_client = PyntClient()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyntcli
3
- Version: 0.1.117
3
+ Version: 0.1.118
4
4
  Summary: Command line utility to handle all of Pynt's different integrations
5
5
  Author-email: Pynt-io <support@pynt.io>
6
6
  Project-URL: Homepage, https://pynt.io
@@ -1,7 +1,7 @@
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=tC6Ly5NZvDBZKJuC4iaO2NyJcqX7enbauSAG6rxadFU,24
4
+ pyntcli/__init__.py,sha256=NPyYE62Vvtk0QcfoU6DNt1tjRHKRzegMxg0JMV_i078,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
@@ -9,13 +9,13 @@ pyntcli/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
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
- pyntcli/commands/command.py,sha256=ulxhWyTnuqQfyNy5somqBbQoTCvd0Hg4OnPJ8thJzAs,11078
12
+ pyntcli/commands/command.py,sha256=TuX7It8gOSG8fY6RvpAak3bkvmKKy-3k7kw-SI8xvKw,11260
13
13
  pyntcli/commands/har.py,sha256=laVRjG35LDEykoSfRIuEwHYfLstui6EpPxSjcam64ng,4719
14
14
  pyntcli/commands/id_command.py,sha256=UBEgMIpm4vauTCsKyixltiGUolNg_OfHEJvJ_i5BpJY,943
15
15
  pyntcli/commands/listen.py,sha256=RTlUt2oq5_BPeBZpG5yQ6GPAG_Cf0JVrUrkzz8uw9ns,9042
16
16
  pyntcli/commands/newman.py,sha256=w0d0Pi1swJQ8E3oRs6vsgw_591sl-4bcLpWZwuBXmDI,5282
17
17
  pyntcli/commands/postman.py,sha256=kN1PkzPpcUnsbirg17AN9JwJZu6VBt6OeKYrLGrvtFc,4964
18
- pyntcli/commands/pynt_cmd.py,sha256=TcsKVl0QZLEDIZjo-977IY6k4MAXVk_hljraW1eJmyg,7790
18
+ pyntcli/commands/pynt_cmd.py,sha256=oRKgiG9i84sxkS-C5Nw4vv9mIO6zL8YfqhOUJ-XVpas,7934
19
19
  pyntcli/commands/root.py,sha256=bTGlFroeK7WG9dAhFkVTVnpEM-Gdp8QKCuTxW_QWNlQ,4441
20
20
  pyntcli/commands/static_file_extensions.py,sha256=PZJb02BI-64tbU-j3rdCNsXzTh7gkIDGxGKbKNw3h5k,1995
21
21
  pyntcli/commands/sub_command.py,sha256=GF3-rE_qk2L4jGPFqHLm9SdGINmu3EakhjJTFyWjRms,374
@@ -27,7 +27,7 @@ pyntcli/pynt_docker/__init__.py,sha256=PQIOVxc7XXtMLfEX7ojgwf_Z3mmTllO3ZvzUZTPOx
27
27
  pyntcli/pynt_docker/container_utils.py,sha256=DeI-uSgdcO_2rGs2dvQ5gBDNo_iKKuPIQO2D9oej5Gw,1485
28
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
- pyntcli/saas_client/saas_client.py,sha256=7mJNo2x4Oy2N4NKdHyGRxXZUk_VHZvRu1x586rojrp0,1756
30
+ pyntcli/saas_client/saas_client.py,sha256=Cpf1pitVlxjW7KpchPL7Q-DgUqw6A8ldCtDlBXaPig0,1663
31
31
  pyntcli/store/__init__.py,sha256=1fP8cEAQCF_myja3gnhHH9FEqtBiOJ-2aBmUXSKBdFA,41
32
32
  pyntcli/store/json_connector.py,sha256=UGs3uORw3iyn0YJ8kzab-veEZToA6d-ByXYuqEleWsA,560
33
33
  pyntcli/store/store.py,sha256=Kl_HT9FJFdKlAH7SwAt3g4-bW-r-1ve_u13OPggQai0,2529
@@ -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.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,,
45
+ pyntcli-0.1.118.dist-info/METADATA,sha256=0FTF3QHwBL7UzwrFnPrvSNjSO_A0D6XMPS_tPi-N3xM,427
46
+ pyntcli-0.1.118.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
47
+ pyntcli-0.1.118.dist-info/entry_points.txt,sha256=kcGmqAxXDttNk2EPRcqunc_LTVp61gzakz0v-GEE2SY,43
48
+ pyntcli-0.1.118.dist-info/top_level.txt,sha256=64XSgBzSpgwjYjEKHZE7q3JH2a816zEeyZBXfJi3AKI,42
49
+ pyntcli-0.1.118.dist-info/RECORD,,