pyntcli 0.1.71__py3-none-any.whl → 0.1.73__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/commands/root.py CHANGED
@@ -7,33 +7,48 @@ from pyntcli.auth import login
7
7
  from pyntcli.ui import ui_thread
8
8
  from pyntcli.analytics import send as analytics
9
9
 
10
+
10
11
  def root_usage():
11
- return ui_thread.PrinterText("Usage:",style=ui_thread.PrinterText.HEADER) \
12
- .with_line("\tpynt [COMMAND] [OPTIONS]") \
13
- .with_line("") \
14
- .with_line("Commands:",style=ui_thread.PrinterText.HEADER) \
15
- .with_line("\tpostman - integration with postman, run scan from pynt postman collection") \
16
- .with_line("\tnewman - run postman collection from the CLI") \
17
- .with_line("\tpynt-id - view your pynt-id to use when running pynt in CI pipeline") \
18
- .with_line("") \
19
- .with_line("Run pynt [COMMAND] -h to get help on a specific command",style=ui_thread.PrinterText.INFO)
12
+ return (
13
+ ui_thread.PrinterText("Usage:", style=ui_thread.PrinterText.HEADER)
14
+ .with_line("\tpynt [COMMAND] [OPTIONS]")
15
+ .with_line("")
16
+ .with_line("Commands:", style=ui_thread.PrinterText.HEADER)
17
+ .with_line(
18
+ "\tpostman - integration with postman, run scan from pynt postman collection"
19
+ )
20
+ .with_line("\tnewman - run postman collection from the CLI")
21
+ .with_line("\thar - run scan on static har file")
22
+ .with_line("\tcommand - run scan with a given command")
23
+ .with_line("\tlisten - run scan with a routed traffic")
24
+ .with_line("\tburp - run scan on a burp xml output file")
25
+ .with_line(
26
+ "\tpynt-id - view your pynt-id to use when running pynt in CI pipeline"
27
+ )
28
+ .with_line("")
29
+ .with_line(
30
+ "Run pynt [COMMAND] -h to get help on a specific command",
31
+ style=ui_thread.PrinterText.INFO,
32
+ )
33
+ )
34
+
20
35
 
21
36
  def usage(*args):
22
37
  ui_thread.print(root_usage())
23
38
 
24
39
 
25
40
  def check_cicd_context():
26
- if environ.get('GITHUB_ACTION') is not None:
41
+ if environ.get("GITHUB_ACTION") is not None:
27
42
  analytics.emit(analytics.CICD, {"env": "GitHub"})
28
43
  return
29
- if environ.get('GITLAB_USER_ID') is not None:
44
+ if environ.get("GITLAB_USER_ID") is not None:
30
45
  analytics.emit(analytics.CICD, {"env": "GitLab"})
31
46
  return
32
- if environ.get('JENKINS_HOME') is not None:
47
+ if environ.get("JENKINS_HOME") is not None:
33
48
  analytics.emit(analytics.CICD, {"env": "Jenkins"})
34
-
35
49
 
36
- class BaseCommand():
50
+
51
+ class BaseCommand:
37
52
  def __init__(self) -> None:
38
53
  self.base: argparse.ArgumentParser = None
39
54
  self.subparser: argparse._SubParsersAction = None
@@ -41,15 +56,21 @@ class BaseCommand():
41
56
  def cmd(self):
42
57
  if self.base:
43
58
  return self.base
44
-
59
+
45
60
  self.base = argparse.ArgumentParser(prog="pynt")
46
61
  self.base.print_usage = usage
47
62
  self.base.print_help = usage
48
- return self.base
49
-
63
+ return self.base
64
+
50
65
  def add_base_arguments(self, parser):
51
- parser.add_argument("--insecure", default=False, required=False, action='store_true',help="use when target uses self signed certificates")
52
- parser.add_argument("--dev-flags", type=str,default="", help=argparse.SUPPRESS)
66
+ parser.add_argument(
67
+ "--insecure",
68
+ default=False,
69
+ required=False,
70
+ action="store_true",
71
+ help="use when target uses self signed certificates",
72
+ )
73
+ parser.add_argument("--dev-flags", type=str, default="", help=argparse.SUPPRESS)
53
74
  parser.add_argument("--host-ca", type=str, default="")
54
75
  parser.add_argument("--transport-config", type=str, default="")
55
76
  parser.add_argument("--application-id", type=str, default="", required=False)
@@ -58,7 +79,7 @@ class BaseCommand():
58
79
  def get_subparser(self) -> argparse._SubParsersAction:
59
80
  if self.subparser is None:
60
81
  self.subparser = self.base.add_subparsers(help="", dest="command")
61
-
82
+
62
83
  return self.subparser
63
84
 
64
85
  def run_cmd(self, args: argparse.Namespace):
@@ -67,11 +88,11 @@ class BaseCommand():
67
88
  if login.should_login():
68
89
  l = login.Login().login()
69
90
  else:
70
- login.refresh_token()
71
-
91
+ login.refresh_token()
92
+
72
93
  analytics.emit(analytics.LOGIN_DONE)
73
94
  user_id = login.user_id()
74
95
  if user_id:
75
96
  analytics.set_user_id(user_id)
76
97
 
77
- check_cicd_context()
98
+ check_cicd_context()
pyntcli/main.py CHANGED
@@ -7,7 +7,7 @@ from pyntcli.pynt_docker import pynt_container
7
7
  from pyntcli.ui import ui_thread
8
8
  from pyntcli.ui import pynt_errors
9
9
  from pyntcli.ui import ui_thread
10
- from pyntcli.auth import login
10
+ from pyntcli.auth import login
11
11
  from pyntcli.analytics import send as analytics
12
12
  from requests.exceptions import SSLError
13
13
  from pyntcli.transport.pynt_requests import InvalidPathException, InvalidCertFormat
@@ -17,28 +17,36 @@ from pyntcli.commands.postman import PyntWebSocketException
17
17
  from pyntcli import __version__
18
18
 
19
19
 
20
+ def shutdown_cli():
21
+ analytics.stop()
22
+ pynt_container.PyntContainerRegistery.instance().stop_all_containers()
23
+ ui_thread.stop()
24
+
20
25
 
21
26
  def signal_handler(signal_number, frame):
22
27
  ui_thread.print(ui_thread.PrinterText("Exiting..."))
23
-
24
- analytics.stop()
25
- pynt_container.PyntContainerRegistery.instance().stop_all_containers()
26
- ui_thread.stop()
28
+
29
+ shutdown_cli()
27
30
 
28
31
  exit(0)
29
32
 
33
+
30
34
  def check_for_dependecies():
31
35
  pynt_container.get_docker_type()
32
36
 
37
+
33
38
  def print_header():
34
- ui_thread.print(ui_thread.PrinterText(*ui_thread.pynt_header()) \
35
- .with_line(*ui_thread.pynt_version()) \
39
+ ui_thread.print(ui_thread.PrinterText(*ui_thread.pynt_header())
40
+ .with_line(*ui_thread.pynt_version())
36
41
  .with_line(""))
42
+
43
+
37
44
  def start_analytics():
38
45
  user_id = login.user_id()
39
46
  if user_id:
40
- analytics.set_user_id(user_id)
41
-
47
+ analytics.set_user_id(user_id)
48
+
49
+
42
50
  def main():
43
51
  print_header()
44
52
  try:
@@ -50,42 +58,42 @@ def main():
50
58
  cli.run_cmd(cli.parse_args(argv[1:]))
51
59
  analytics.stop()
52
60
  except pynt_cmd.PyntCommandException:
53
- pynt_cmd.root.usage()
61
+ pynt_cmd.root.usage()
54
62
  except pynt_container.DockerNotAvailableException:
55
63
  ui_thread.print(ui_thread.PrinterText("Docker was unavailable, please make sure docker is installed and running.", ui_thread.PrinterText.WARNING))
56
64
  analytics.emit(analytics.ERROR, {"error": "docker unavailable"})
57
- except SSLError:
65
+ except SSLError:
58
66
  ui_thread.print(ui_thread.PrinterText("We encountered SSL issues and could not proceed, this may be the cause of a VPN or a Firewall in place.", ui_thread.PrinterText.WARNING))
59
- except login.Timeout:
67
+ except login.Timeout:
60
68
  ui_thread.print(ui_thread.PrinterText("Pynt CLI exited due to incomplete registration, please try again.", ui_thread.PrinterText.WARNING))
61
69
  analytics.emit(analytics.ERROR, {"error": "login timeout"})
62
70
  except login.InvalidTokenInEnvVarsException:
63
71
  ui_thread.print(ui_thread.PrinterText("Pynt CLI exited due to malformed credentials provided in env vars.", ui_thread.PrinterText.WARNING))
64
72
  analytics.emit(analytics.ERROR, {"error": "invalid pynt cli credentials in env vars"})
65
73
  except pynt_container.ImageUnavailableException:
66
- analytics.emit(analytics.ERROR,{"error": "Couldnt pull pynt image and no local image found"})
74
+ analytics.emit(analytics.ERROR, {"error": "Couldnt pull pynt image and no local image found"})
67
75
  pynt_errors.unexpected_error()
68
76
  except HtmlReportNotCreatedException:
69
- analytics.emit(analytics.ERROR,{"error": "Html report was not created"})
77
+ analytics.emit(analytics.ERROR, {"error": "Html report was not created"})
70
78
  pynt_errors.unexpected_error()
71
79
  except InvalidPathException as e:
72
80
  ui_thread.print(ui_thread.PrinterText("Pynt CLI exited due to invalid host-CA path: {}".format(e), ui_thread.PrinterText.WARNING))
73
- analytics.emit(analytics.ERROR,{"error": "Host CA path provided was invalid"})
81
+ analytics.emit(analytics.ERROR, {"error": "Host CA path provided was invalid"})
74
82
  except InvalidCertFormat as e:
75
83
  ui_thread.print(ui_thread.PrinterText("Pynt CLI exited due to invalid host-CA. Please provide a file in PEM format: {}".format(e), ui_thread.PrinterText.WARNING))
76
- analytics.emit(analytics.ERROR,{"error": "Host CA provided was not in valid pem format"})
84
+ analytics.emit(analytics.ERROR, {"error": "Host CA provided was not in valid pem format"})
77
85
  except PyntWebSocketException:
78
- analytics.emit(analytics.ERROR,{"error": "postman websocket failed to connect"})
86
+ analytics.emit(analytics.ERROR, {"error": "postman websocket failed to connect"})
79
87
  pynt_errors.unexpected_error()
80
88
  except SomeFoundingsOrWargningsException as e:
81
89
  exit(1)
82
90
  except Exception as e:
83
- analytics.emit(analytics.ERROR,{"error": "{}".format(e)})
91
+ analytics.emit(analytics.ERROR, {"error": "{}".format(e)})
84
92
  pynt_errors.unexpected_error()
85
93
  finally:
86
94
  log.flush_logger()
87
- ui_thread.stop()
88
- analytics.stop()
95
+ shutdown_cli()
96
+
89
97
 
90
98
  if __name__ == "__main__":
91
99
  main()
@@ -6,23 +6,29 @@ import certifi
6
6
  import tempfile
7
7
 
8
8
 
9
-
10
9
  class HostCaException(Exception):
11
10
  pass
12
11
 
12
+
13
13
  class InvalidPathException(HostCaException):
14
14
  pass
15
15
 
16
+
16
17
  class InvalidCertFormat(HostCaException):
17
18
  pass
18
19
 
20
+
19
21
  verify = True
20
22
 
23
+ urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
24
+
25
+
21
26
  def disable_tls_termination():
22
27
  global verify
23
28
  verify = False
24
29
  urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
25
30
 
31
+
26
32
  def add_host_ca(ca_path):
27
33
  global verify
28
34
  if not os.path.isfile(ca_path):
@@ -31,24 +37,30 @@ def add_host_ca(ca_path):
31
37
  raise InvalidCertFormat("{} - Invalid Format".format(ca_path))
32
38
 
33
39
  cert_data = open(ca_path, "rb").read()
34
-
40
+
35
41
  cafile = certifi.where()
36
42
  ca_chain = open(cafile, 'rb').read()
37
-
43
+
38
44
  bundle_path = os.path.join(tempfile.gettempdir(), "bundle.pem")
39
- with open(bundle_path,"wb") as f:
45
+ with open(bundle_path, "wb") as f:
40
46
  f.write(ca_chain)
41
47
  f.write(b'\n')
42
48
  f.write(cert_data)
43
-
49
+
44
50
  verify = bundle_path
45
51
 
46
-
52
+
47
53
  def get(url, params=None, **kwargs):
48
- return requests.get(url,params=params,verify=verify,**kwargs)
54
+ return requests.get(url, params=params, verify=verify, **kwargs)
55
+
49
56
 
50
57
  def post(url, data=None, json=None, **kwargs):
51
- return requests.post(url,data=data,json=json, verify=verify,**kwargs)
58
+ return requests.post(url, data=data, json=json, verify=verify, **kwargs)
59
+
52
60
 
53
61
  def put(url, data=None, **kwargs):
54
- return requests.put(url,data=data,verify=verify,**kwargs)
62
+ return requests.put(url, data=data, verify=verify, **kwargs)
63
+
64
+
65
+ def request_from_xml(method, url, proxies=None, data=None, **kwargs):
66
+ return requests.request(method=method, url=url, data=data, verify=False, proxies=proxies, **kwargs)
pyntcli/ui/ui_thread.py CHANGED
@@ -6,6 +6,7 @@ from rich.text import Text
6
6
  from rich.console import Console
7
7
  from rich.status import Status
8
8
  from rich.progress import Progress
9
+ from rich.markup import escape
9
10
  from typing import Tuple
10
11
 
11
12
  from pyntcli import __version__ as cli_version
@@ -140,6 +141,9 @@ class Printer():
140
141
  if isinstance(data, PyntProgress):
141
142
  self._handle_progress(data)
142
143
  continue
144
+ if isinstance(data, str):
145
+ self.console.print(escape(str(data)))
146
+ continue
143
147
  else:
144
148
  self.console.print(data)
145
149
  except queue.Empty:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyntcli
3
- Version: 0.1.71
3
+ Version: 0.1.73
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
@@ -12,4 +12,5 @@ Requires-Dist: pem
12
12
  Requires-Dist: certifi >=2017.4.17
13
13
  Requires-Dist: logzio-python-handler >=4.1.0
14
14
  Requires-Dist: websocket-client
15
+ Requires-Dist: xmltodict
15
16
 
@@ -1,18 +1,19 @@
1
- pyntcli/__init__.py,sha256=ebu6Nblu_UmpciwG6xnbUJm-16F-ZA6L-sagDt37smo,23
2
- pyntcli/main.py,sha256=cyDbu8Gbx-Uwri4z9KKL--BMMERunSzrZ0VTiX3JC48,4114
1
+ pyntcli/__init__.py,sha256=B2xptQoAZtCL_O_fLMSWF71JDtlCZp8jLmdtHyMdosE,23
2
+ pyntcli/main.py,sha256=cqratxd_ZJXLsP4xRbF2fmwj3Eo4kQ8WlbrwUtfZQ94,4125
3
3
  pyntcli/analytics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pyntcli/analytics/send.py,sha256=ewNAKnn3KbKwfDuOasgAsSGbUWILLD8rPaXIAlLucnM,2507
5
5
  pyntcli/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  pyntcli/auth/login.py,sha256=WgF5r00bpM4c1__thzD6zCJ6207qxgtT0ixPvD1cEHA,5109
7
7
  pyntcli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- pyntcli/commands/command.py,sha256=lZBLLtkfbQ7fFAqWuMP00T_ZkUsnCpiAPd4p5sn4MzM,7870
9
- pyntcli/commands/har.py,sha256=s5TUw9JVhINRa1kaU6d784u6k_UAMcYu8ZzLk9W6JG4,2935
8
+ pyntcli/commands/burp.py,sha256=wd-HuNyj6v6IHk6x9-DAaqXcm1cQa-RA5FlxveBd6wA,10427
9
+ pyntcli/commands/command.py,sha256=tSjJj0fhQt2lCvtdu8H3IuiBlAllesx4f6ptNfuinTw,9435
10
+ pyntcli/commands/har.py,sha256=Iq0455umKvlcMxcU4l70-NIZh7Wovry3f76u68drmQ4,3654
10
11
  pyntcli/commands/id_command.py,sha256=2J5oEa39uyBMMSCRHzuKh3_11CeUEYi7YLoBk1yuu_I,942
11
- pyntcli/commands/listen.py,sha256=2cVWc9athlLOmM1NLf-VVTqZENhlrbxW7yf7TRNVMro,7782
12
- pyntcli/commands/newman.py,sha256=GfLPgOx7Pmx1S6ZI8wJOiSzhxBFn4WuEjN-MWL3mW0Y,4233
13
- pyntcli/commands/postman.py,sha256=5eF14wjdDwJC8AvXjwyuZnlb6JZsPs_QWh5e77LauGA,4928
14
- pyntcli/commands/pynt_cmd.py,sha256=OBdgglzJJPFUOWtleORkLErpmd_0QkUF0hhK-_MRaak,2417
15
- pyntcli/commands/root.py,sha256=4TLH67_n1S4nxmlB2YzyDLZpx2GJLK2rXMEfD3Wze1M,2839
12
+ pyntcli/commands/listen.py,sha256=aANo5DwZ6_TAuXdJX3L8eDk9I6ompPAqtaUgxnEbR54,8536
13
+ pyntcli/commands/newman.py,sha256=_AspmTk98nY0Ct26WNK4fFgoYbqzmU90FfkygxJjgjY,4828
14
+ pyntcli/commands/postman.py,sha256=x5sPR-KaawKzAkLRK9vJXDzZ3sx9-6TuH6SNd5tnM4Y,4946
15
+ pyntcli/commands/pynt_cmd.py,sha256=NkzT8X4mI_fhzui_9KdAQXY5AnMGdoQkzDH6pcreLHU,2453
16
+ pyntcli/commands/root.py,sha256=FEf2gXvFyO_RZi6XzFakSVnOQw_sGBopY5SL5gldudg,3248
16
17
  pyntcli/commands/sub_command.py,sha256=GF3-rE_qk2L4jGPFqHLm9SdGINmu3EakhjJTFyWjRms,374
17
18
  pyntcli/commands/util.py,sha256=IREZvHYJ7wEth8ujOkk5ZXZ4UrUA7jDv134_UueED4s,2995
18
19
  pyntcli/log/__init__.py,sha256=cOGwOYzMoshEbZiiasBGkj6wF0SBu3Jdpl-AuakDesw,19
@@ -24,17 +25,17 @@ pyntcli/store/json_connector.py,sha256=UGs3uORw3iyn0YJ8kzab-veEZToA6d-ByXYuqEleW
24
25
  pyntcli/store/store.py,sha256=Fbc7yxjht0EJ89eGF8eMgNQJ3sgYRTPmj2-sWQ5UUPs,1766
25
26
  pyntcli/store/store_connector.py,sha256=w4LzcpRZesUZL1f63RmLlWEFRtJ6Y6rcS6PkkGtO4MA,357
26
27
  pyntcli/transport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
- pyntcli/transport/pynt_requests.py,sha256=a9siz45X1RESKCWoVDe1tnhzn0vjVdYd_25KIxQO4h0,1316
28
+ pyntcli/transport/pynt_requests.py,sha256=KiEG3hNcwY7DLIJDCq-7LIPq54yYQcDBhHe3KhpqRTc,1563
28
29
  pyntcli/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
30
  pyntcli/ui/progress.py,sha256=RrnO_jJNunoyupylakmWmHOEPw3lh99OHpKBzL6OBiE,1008
30
31
  pyntcli/ui/pynt_errors.py,sha256=UAr8OV5EM4zLhfWSmK_qss8nal2Ezo66Dk8ZMvR_RTs,546
31
32
  pyntcli/ui/report.py,sha256=W-icPSZrGLOubXgam0LpOvHLl_aZg9Zx9qIkL8Ym5PE,1930
32
- pyntcli/ui/ui_thread.py,sha256=JAonXc6aOFawaEixghclxHSCHZBieEWfZzsPef_ZNMI,4796
33
+ pyntcli/ui/ui_thread.py,sha256=OVTbiIFMg2KgxAvHf7yy86xGm4RVS2vj_VYZkMi-SRY,4956
33
34
  tests/conftest.py,sha256=gToq5K74GtgeGQXjFvXSzMaE6axBYxAzcFG5XJPOXjI,427
34
35
  tests/auth/test_login.py,sha256=M6JRFTQRZrL6M2-iph_r-aBSQMMiFDncQbVYeObBFYU,3296
35
36
  tests/store/test_cred_store.py,sha256=_7-917EtNC9eKEumO2_lt-7KuDmCwOZFaowCm7DbA_A,254
36
- pyntcli-0.1.71.dist-info/METADATA,sha256=tG8dyjc1MzjQ8KtUmktrda1d4JW1m3Dq6EWGwMBakx4,438
37
- pyntcli-0.1.71.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
38
- pyntcli-0.1.71.dist-info/entry_points.txt,sha256=kcGmqAxXDttNk2EPRcqunc_LTVp61gzakz0v-GEE2SY,43
39
- pyntcli-0.1.71.dist-info/top_level.txt,sha256=u9MDStwVHB7UG8PUcODeWCul_NvzL2EzoLvSlgwLHFs,30
40
- pyntcli-0.1.71.dist-info/RECORD,,
37
+ pyntcli-0.1.73.dist-info/METADATA,sha256=YG6eADsoX_vyR3rTTkWvpkrKZeY8okAneTVRDvu3yZU,463
38
+ pyntcli-0.1.73.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
39
+ pyntcli-0.1.73.dist-info/entry_points.txt,sha256=kcGmqAxXDttNk2EPRcqunc_LTVp61gzakz0v-GEE2SY,43
40
+ pyntcli-0.1.73.dist-info/top_level.txt,sha256=u9MDStwVHB7UG8PUcODeWCul_NvzL2EzoLvSlgwLHFs,30
41
+ pyntcli-0.1.73.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5