Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

brain_ssl.py 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Copyright (c) 2016 Claudiu Popa <pcmanticore@gmail.com>
  2. # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  3. # For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER
  4. """Astroid hooks for the ssl library."""
  5. from astroid import MANAGER, register_module_extender
  6. from astroid.builder import AstroidBuilder
  7. from astroid import nodes
  8. from astroid import parse
  9. def ssl_transform():
  10. return parse('''
  11. from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
  12. from _ssl import _SSLContext, MemoryBIO
  13. from _ssl import (
  14. SSLError, SSLZeroReturnError, SSLWantReadError, SSLWantWriteError,
  15. SSLSyscallError, SSLEOFError,
  16. )
  17. from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
  18. from _ssl import txt2obj as _txt2obj, nid2obj as _nid2obj
  19. from _ssl import RAND_status, RAND_add, RAND_bytes, RAND_pseudo_bytes
  20. try:
  21. from _ssl import RAND_egd
  22. except ImportError:
  23. # LibreSSL does not provide RAND_egd
  24. pass
  25. from _ssl import (OP_ALL, OP_CIPHER_SERVER_PREFERENCE,
  26. OP_NO_COMPRESSION, OP_NO_SSLv2, OP_NO_SSLv3,
  27. OP_NO_TLSv1, OP_NO_TLSv1_1, OP_NO_TLSv1_2,
  28. OP_SINGLE_DH_USE, OP_SINGLE_ECDH_USE)
  29. from _ssl import (ALERT_DESCRIPTION_ACCESS_DENIED, ALERT_DESCRIPTION_BAD_CERTIFICATE,
  30. ALERT_DESCRIPTION_BAD_CERTIFICATE_HASH_VALUE,
  31. ALERT_DESCRIPTION_BAD_CERTIFICATE_STATUS_RESPONSE,
  32. ALERT_DESCRIPTION_BAD_RECORD_MAC,
  33. ALERT_DESCRIPTION_CERTIFICATE_EXPIRED,
  34. ALERT_DESCRIPTION_CERTIFICATE_REVOKED,
  35. ALERT_DESCRIPTION_CERTIFICATE_UNKNOWN,
  36. ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE,
  37. ALERT_DESCRIPTION_CLOSE_NOTIFY, ALERT_DESCRIPTION_DECODE_ERROR,
  38. ALERT_DESCRIPTION_DECOMPRESSION_FAILURE,
  39. ALERT_DESCRIPTION_DECRYPT_ERROR,
  40. ALERT_DESCRIPTION_HANDSHAKE_FAILURE,
  41. ALERT_DESCRIPTION_ILLEGAL_PARAMETER,
  42. ALERT_DESCRIPTION_INSUFFICIENT_SECURITY,
  43. ALERT_DESCRIPTION_INTERNAL_ERROR,
  44. ALERT_DESCRIPTION_NO_RENEGOTIATION,
  45. ALERT_DESCRIPTION_PROTOCOL_VERSION,
  46. ALERT_DESCRIPTION_RECORD_OVERFLOW,
  47. ALERT_DESCRIPTION_UNEXPECTED_MESSAGE,
  48. ALERT_DESCRIPTION_UNKNOWN_CA,
  49. ALERT_DESCRIPTION_UNKNOWN_PSK_IDENTITY,
  50. ALERT_DESCRIPTION_UNRECOGNIZED_NAME,
  51. ALERT_DESCRIPTION_UNSUPPORTED_CERTIFICATE,
  52. ALERT_DESCRIPTION_UNSUPPORTED_EXTENSION,
  53. ALERT_DESCRIPTION_USER_CANCELLED)
  54. from _ssl import (SSL_ERROR_EOF, SSL_ERROR_INVALID_ERROR_CODE, SSL_ERROR_SSL,
  55. SSL_ERROR_SYSCALL, SSL_ERROR_WANT_CONNECT, SSL_ERROR_WANT_READ,
  56. SSL_ERROR_WANT_WRITE, SSL_ERROR_WANT_X509_LOOKUP, SSL_ERROR_ZERO_RETURN)
  57. from _ssl import VERIFY_CRL_CHECK_CHAIN, VERIFY_CRL_CHECK_LEAF, VERIFY_DEFAULT, VERIFY_X509_STRICT
  58. from _ssl import HAS_SNI, HAS_ECDH, HAS_NPN, HAS_ALPN
  59. from _ssl import _OPENSSL_API_VERSION
  60. from _ssl import PROTOCOL_SSLv23, PROTOCOL_TLSv1, PROTOCOL_TLSv1_1, PROTOCOL_TLSv1_2
  61. ''')
  62. register_module_extender(MANAGER, 'ssl', ssl_transform)