pyntcli 0.1.81__py3-none-any.whl → 0.1.83__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.81"
1
+ __version__ = "0.1.83"
pyntcli/commands/burp.py CHANGED
@@ -10,6 +10,7 @@ from subprocess import Popen, PIPE
10
10
  from functools import partial
11
11
  import xmltodict
12
12
  import base64
13
+ import pyntcli.log.log as log
13
14
  from xml.parsers.expat import ExpatError
14
15
 
15
16
  from pyntcli.pynt_docker import pynt_container
@@ -30,6 +31,9 @@ methods = [
30
31
  "connect",
31
32
  ]
32
33
 
34
+ logger = log.get_logger()
35
+ supported_encoding = ["utf-8", "latin1", "utf-16", "cp1252"]
36
+
33
37
 
34
38
  def is_valid_method(method: str):
35
39
  if method.lower() in methods:
@@ -37,9 +41,31 @@ def is_valid_method(method: str):
37
41
  return False
38
42
 
39
43
 
44
+ def decode_request(item) -> str:
45
+ error = None
46
+ for encoding in supported_encoding:
47
+ try:
48
+ return base64.b64decode(item["request"]["#text"]).decode(encoding)
49
+ except UnicodeDecodeError as e:
50
+ error = e
51
+ continue
52
+ except Exception as e:
53
+ error = e
54
+ break
55
+
56
+ ui_thread.print(
57
+ ui_thread.PrinterText(
58
+ f"Error decoding request: {error}"),
59
+ ui_thread.PrinterText.WARNING)
60
+ logger.error(f"Error decoding request: {error}")
61
+
62
+ raise e
63
+
64
+
40
65
  def replay_req(item, proxy_port):
41
66
  url = item["url"]
42
- decoded_req = base64.b64decode(item["request"]["#text"]).decode("utf-8")
67
+ decoded_req = decode_request(item)
68
+
43
69
  method = decoded_req.split("\r\n")[0].split(" ")[0]
44
70
 
45
71
  if not is_valid_method(method):
@@ -289,12 +315,12 @@ class BurpCommand(sub_command.PyntSubCommand):
289
315
  json_report_path = util.get_user_report_path(full_path, "json")
290
316
 
291
317
  if html_report:
292
- with open(html_report_path, "w",encoding="utf-8") as html_file:
318
+ with open(html_report_path, "w", encoding="utf-8") as html_file:
293
319
  html_file.write(html_report)
294
320
  webbrowser.open("file://{}".format(html_report_path))
295
321
 
296
322
  if json_report:
297
- with open(json_report_path, "w",encoding="utf-8") as json_file:
323
+ with open(json_report_path, "w", encoding="utf-8") as json_file:
298
324
  json_file.write(json_report)
299
325
  reporter = cli_reporter.PyntReporter(json_report_path)
300
326
  reporter.print_summary()
pyntcli/commands/root.py CHANGED
@@ -1,6 +1,4 @@
1
1
  import argparse
2
- import sys
3
-
4
2
  from os import environ
5
3
 
6
4
  from pyntcli.auth import login
@@ -15,22 +13,16 @@ def root_usage():
15
13
  .with_line("\tpynt [COMMAND] [OPTIONS]")
16
14
  .with_line("")
17
15
  .with_line("Commands:", style=ui_thread.PrinterText.HEADER)
18
- .with_line(
19
- "\tpostman - integration with postman, run scan from pynt postman collection"
20
- )
16
+ .with_line("\tpostman - integration with postman, run scan from pynt postman collection")
21
17
  .with_line("\tnewman - run postman collection from the CLI")
22
18
  .with_line("\thar - run scan on static har file")
23
19
  .with_line("\tcommand - run scan with a given command")
24
20
  .with_line("\tlisten - run scan with a routed traffic")
25
21
  .with_line("\tburp - run scan on a burp xml output file")
26
- .with_line(
27
- "\tpynt-id - view your pynt-id to use when running pynt in CI pipeline"
28
- )
22
+ .with_line("\tpynt-id - view your pynt-id to use when running pynt in CI pipeline")
23
+ .with_line("\tlogout - log out from your user")
29
24
  .with_line("")
30
- .with_line(
31
- "Run pynt [COMMAND] -h to get help on a specific command",
32
- style=ui_thread.PrinterText.INFO,
33
- )
25
+ .with_line("Run pynt [COMMAND] -h to get help on a specific command", style=ui_thread.PrinterText.INFO,)
34
26
  )
35
27
 
36
28
 
pyntcli/main.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from sys import argv, exit
2
2
  import signal
3
-
3
+ import os
4
4
  import pyntcli.log.log as log
5
5
  from pyntcli.commands import pynt_cmd
6
6
  from pyntcli.pynt_docker import pynt_container
@@ -16,6 +16,8 @@ from pyntcli.commands.util import SomeFindingsOrWarningsException
16
16
  from pyntcli.commands.postman import PyntWebSocketException
17
17
  from pyntcli import __version__
18
18
 
19
+ from pyntcli.store import CredStore
20
+
19
21
 
20
22
  def shutdown_cli():
21
23
  analytics.stop()
@@ -48,9 +50,25 @@ def start_analytics():
48
50
  log.add_user_details(user_id)
49
51
 
50
52
 
53
+ def logout():
54
+ creds_path = CredStore().get_path()
55
+ try:
56
+ if os.path.isfile(creds_path):
57
+ os.remove(creds_path)
58
+ ui_thread.print("you have successfully logged out")
59
+ return
60
+ except Exception:
61
+ ui_thread.print(f"not able to log out - try to manually delete the {creds_path} file")
62
+
63
+ ui_thread.print("you are not logged in. run pynt --help and choose the required command")
64
+
65
+
51
66
  def main():
52
67
  print_header()
53
68
  try:
69
+ if argv[1] == "logout":
70
+ logout()
71
+ return
54
72
  log.set_source(__version__)
55
73
  start_analytics()
56
74
  check_for_dependecies()
pyntcli/store/store.py CHANGED
@@ -10,8 +10,8 @@ class Store():
10
10
  self.file_location = file_location
11
11
  self.connector: StoreConnector = None
12
12
  self._file = None
13
- self._connector_tpye = connector_type
14
-
13
+ self._connector_type = connector_type
14
+
15
15
  def _get_file_data(self):
16
16
  if self.connector:
17
17
  return
@@ -22,11 +22,11 @@ class Store():
22
22
 
23
23
  if not os.path.exists(self.file_location):
24
24
  with open(self.file_location, "w") as f:
25
- self.connector = self._connector_tpye(self._connector_tpye.default_value())
25
+ self.connector = self._connector_type(self._connector_type.default_value())
26
26
  return
27
27
 
28
28
  with open(self.file_location, "r+") as f:
29
- self.connector = self._connector_tpye(f.read())
29
+ self.connector = self._connector_type(f.read())
30
30
 
31
31
  def get(self, key):
32
32
  self._get_file_data()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyntcli
3
- Version: 0.1.81
3
+ Version: 0.1.83
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,11 +1,11 @@
1
- pyntcli/__init__.py,sha256=4reVRut6pFQ0MxDHMjUh2C4vPGa3csSjDj46nUuBiXs,23
2
- pyntcli/main.py,sha256=qTGMG2JSpieg-1RRgBz9dPL4vHo1WJJIxTPQYAuzxuY,5138
1
+ pyntcli/__init__.py,sha256=YNVbuQj-JrlVU3yGuccLkZ5P-L-37tQUcshGno0Ijlo,23
2
+ pyntcli/main.py,sha256=wg2Is1ckRCb3EwsLFshDsbPKvntPOR7sDB2Nq-DW4wk,5689
3
3
  pyntcli/analytics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pyntcli/analytics/send.py,sha256=pJOyOWl3g_Vm9apKK3LzNVqsnC6zsWA1bCK3ZegbLpc,3637
5
5
  pyntcli/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  pyntcli/auth/login.py,sha256=TljsRXbEkNI1YUrKm5mlTw4YiecYScYUsit8Z8vstss,5228
7
7
  pyntcli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- pyntcli/commands/burp.py,sha256=KuxeX9I0ZXSVAMHdt9OYFok79X9IK6z71-ZN-_fnrvU,10565
8
+ pyntcli/commands/burp.py,sha256=2FqLc65SjuXdenUS1ggC6dGRU_iSA52Ft_8OnfGsm_8,11193
9
9
  pyntcli/commands/command.py,sha256=0O7Za_cjT6vDkDfM0OTMPB6DLI3U1r1R7lXQydz7458,9495
10
10
  pyntcli/commands/har.py,sha256=mSCbTUnxQrKzJd-dAWoc6Tkw6tU1LDH7Ha1w2ylrrrg,3654
11
11
  pyntcli/commands/id_command.py,sha256=UBEgMIpm4vauTCsKyixltiGUolNg_OfHEJvJ_i5BpJY,943
@@ -13,7 +13,7 @@ pyntcli/commands/listen.py,sha256=JoDo3BirYf9f3Fr21qAQ7kIDmLbM5cuFzQtf8RQ_nhs,84
13
13
  pyntcli/commands/newman.py,sha256=y0KolwMgsvoqPz2mp0QRug_qNr-ftOZbu_tN7h4bH7I,4826
14
14
  pyntcli/commands/postman.py,sha256=GWq4NJJ_9WdFiXk5rv2nTyMM27w50XLh4LKkuuWpw4I,4721
15
15
  pyntcli/commands/pynt_cmd.py,sha256=KOl9guUtesO2JcMM5nPKKkjnK6F9HV4jHHcoUk4KVhw,2825
16
- pyntcli/commands/root.py,sha256=GijCi8hqe8sXEo6faWimlCmT8d782yjrw1IWJT5RAMk,3320
16
+ pyntcli/commands/root.py,sha256=dmgdzoFuf5LkwrkwvWf1MtlwTBgsVpS85Yr_cQCVuGA,3291
17
17
  pyntcli/commands/sub_command.py,sha256=GF3-rE_qk2L4jGPFqHLm9SdGINmu3EakhjJTFyWjRms,374
18
18
  pyntcli/commands/util.py,sha256=NJBJk4tKzrWmilYdo-7CROH5IXKl0UQAPKaMzRZtxm8,2827
19
19
  pyntcli/log/__init__.py,sha256=cOGwOYzMoshEbZiiasBGkj6wF0SBu3Jdpl-AuakDesw,19
@@ -23,7 +23,7 @@ pyntcli/pynt_docker/container_utils.py,sha256=_Onn7loInzyJAG2-Uk6CGpsuRyelmUFHOv
23
23
  pyntcli/pynt_docker/pynt_container.py,sha256=y4m8wZU16gqFPaMzEJKKHut4DbjPxr_du8g7I4-AcHk,8761
24
24
  pyntcli/store/__init__.py,sha256=xuS9OB21F6B1sUx5XPGxz_6WpG6-KTMbuq50RrZS5OY,29
25
25
  pyntcli/store/json_connector.py,sha256=UGs3uORw3iyn0YJ8kzab-veEZToA6d-ByXYuqEleWsA,560
26
- pyntcli/store/store.py,sha256=Kf4IFCAu0i0DPVGgntrSYUiwz6kmW9HvItKnCT-MosE,1905
26
+ pyntcli/store/store.py,sha256=9KwalOd1EA1VtYwr9oJgBsPgUYakX5uyif_sNXGQ614,1917
27
27
  pyntcli/store/store_connector.py,sha256=w4LzcpRZesUZL1f63RmLlWEFRtJ6Y6rcS6PkkGtO4MA,357
28
28
  pyntcli/transport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
29
  pyntcli/transport/pynt_requests.py,sha256=KiEG3hNcwY7DLIJDCq-7LIPq54yYQcDBhHe3KhpqRTc,1563
@@ -35,8 +35,8 @@ pyntcli/ui/ui_thread.py,sha256=OVTbiIFMg2KgxAvHf7yy86xGm4RVS2vj_VYZkMi-SRY,4956
35
35
  tests/conftest.py,sha256=gToq5K74GtgeGQXjFvXSzMaE6axBYxAzcFG5XJPOXjI,427
36
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.81.dist-info/METADATA,sha256=D5hWFtXYjvdJp7uIjMBlj8Z_yYP0pobzSV1Ce6T1onM,463
39
- pyntcli-0.1.81.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
40
- pyntcli-0.1.81.dist-info/entry_points.txt,sha256=kcGmqAxXDttNk2EPRcqunc_LTVp61gzakz0v-GEE2SY,43
41
- pyntcli-0.1.81.dist-info/top_level.txt,sha256=u9MDStwVHB7UG8PUcODeWCul_NvzL2EzoLvSlgwLHFs,30
42
- pyntcli-0.1.81.dist-info/RECORD,,
38
+ pyntcli-0.1.83.dist-info/METADATA,sha256=XcLyBCUa_7GOUyGDqDBpGeWC5M-i1C4DM1CoWtCL7ok,463
39
+ pyntcli-0.1.83.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
40
+ pyntcli-0.1.83.dist-info/entry_points.txt,sha256=kcGmqAxXDttNk2EPRcqunc_LTVp61gzakz0v-GEE2SY,43
41
+ pyntcli-0.1.83.dist-info/top_level.txt,sha256=u9MDStwVHB7UG8PUcODeWCul_NvzL2EzoLvSlgwLHFs,30
42
+ pyntcli-0.1.83.dist-info/RECORD,,