general_notes.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Work in progress
  2. enc = CryptoEngine.get() in ui/cli.py (L:940)
  3. is called before the db is even set !
  4. when priniting nodes, decrypt is first called by:
  5. this initializes CryptoEngine instance,
  6. and sets the following instance properties:
  7. - _callback
  8. - _instance
  9. - _keycrypted
  10. - _timeout
  11. - _cypher
  12. this initialization asks the user for the decryption key
  13. of the database.
  14. the action that user does called the respective db function which
  15. returns an ENCRYPTED STRING!,
  16. which is then given to decryption via nodes.py or tags.py which do the
  17. actual decryption on each decrypted string returned from the DB.
  18. for example print_node:
  19. initializing a _db instance, then we call _db.open()
  20. calling do_print(10) calls _db.getnodes([i]) at this point
  21. the database is still not decrypted ... e.g. _cypher is still empty
  22. when _db.getnodes([i]) is done node inside print_node is containing
  23. alot of encrypted string.
  24. now print_node will be called, at which point the different methods
  25. of node instance will decrypt their respective string:
  26. e.g. get_username(self) instide nodes.py:
  27. self._username -> OexYH7vT/WVpXO0ZBM93RF/l8+o8/QU8ykgDB4qY8+BxBaKylAOeJWEQ+edjpLTU\n
  28. enc = CryptoEngine.get()
  29. enc.decrypt(self._username) -> nahum.oz@gmail.com
  30. to see this in work:
  31. insert
  32. import ipdb; ipdb.set_trace()
  33. to def getnodes(self, ids) in "pwman/data/drivers/sqlite.py.
  34. continue to pwman3/pwman/ui/cli.py(382) self.print_node(node[0])
  35. and then step into this function.
  36. continue further into def print_node(self, node) inside pwman3/pwman/ui/cli.py,
  37. finally you should step into:
  38. node.get_username()
  39. # New features to implement:
  40. 1. Password expiry date - register password date, remind when password is about to expire.
  41. 2. Make new passwords according to user defined rules.
  42. # build the package with
  43. python setup.py sdist
  44. # upload
  45. python setup.py sdist upload
  46. # PyCrypto Alternatives:
  47. * http://wiki.yobi.be/wiki/PyCryptoPlus#Differences_with_pycrypto
  48. * http://brandon.sternefamily.net/2007/06/aes-tutorial-python-implementation/
  49. * puresalsa20 - not document so good
  50. * http://code.google.com/p/pycrypt/
  51. * https://github.com/trevp/tlslite/tree/master/tlslite/utils
  52. * seems like the best next standard, but very young:
  53. https://github.com/alex/cryptography
  54. * another salsa Alternative: www.seanet.com/~bugbee/crypto/salsa20/salsa20.pyb
  55. # for windows port: https://pypi.python.org/pypi/colorama
  56. # db ... https://github.com/coleifer/peewee
  57. http://sqlobject.org/
  58. http://www.sqlalchemy.org/
  59. # when developing pwman3 you might be using a debugger. if so add the following
  60. pre-commit hook to your .git/ :
  61. $ cat .git/hooks/pre-commit
  62. #!/bin/bash
  63. VAR=$(git diff --cached | grep "\+*import i*pdb; i*pdb.set_trace")
  64. if [ ! -z "$VAR" ]; then
  65. echo "You've left a BREAK POINT in one of your files! Aborting commit..."
  66. exit 1
  67. fi
  68. make test || exit 1
  69. exit 0
  70. ### testing :
  71. Each class should have at least 95% coverage.
  72. Each module should be tested as a stand alone with:
  73. foo.py
  74. test_foo.py
  75. The test module test_foo.py should contain at the bottom:
  76. if __name__ == '__main__':
  77. # prepare everything for testing
  78. try:
  79. unittest.main(verbosity=2)
  80. except SystemExit:
  81. # clean everything after test was run
  82. You should be able to run the module testing with:
  83. $ python -m pwman.tests.test_foo
  84. But you should also run the tests as part of a larger scheme with:
  85. from test_foo import TestFoo
  86. ...
  87. ...
  88. loader = unittest.TestLoader()
  89. suite = unittest.TestSuite()
  90. suite.addTest(loader.loadTestsFromTestCase(DBTests))