general_notes.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. twine upload dist/pwman.tar.gz
  46. # db ... https://github.com/coleifer/peewee
  47. http://sqlobject.org/
  48. http://www.sqlalchemy.org/
  49. # when developing pwman3 you might be using a debugger. if so add the following
  50. pre-commit hook to your .git/ :
  51. $ cat .git/hooks/pre-commit
  52. #!/bin/bash
  53. VAR=$(git diff --cached | grep "\+*import i*pdb; i*pdb.set_trace")
  54. if [ ! -z "$VAR" ]; then
  55. echo "You've left a BREAK POINT in one of your files! Aborting commit..."
  56. exit 1
  57. fi
  58. make test || exit 1
  59. exit 0
  60. ### testing :
  61. Each class should have at least 95% coverage.
  62. Each module should be tested as a stand alone with:
  63. foo.py
  64. test_foo.py
  65. The test module test_foo.py should contain at the bottom:
  66. if __name__ == '__main__':
  67. # prepare everything for testing
  68. try:
  69. unittest.main(verbosity=2)
  70. except SystemExit:
  71. # clean everything after test was run
  72. You should be able to run the module testing with:
  73. $ python -m pwman.tests.test_foo
  74. But you should also run the tests as part of a larger scheme with:
  75. from test_foo import TestFoo
  76. ...
  77. ...
  78. loader = unittest.TestLoader()
  79. suite = unittest.TestSuite()
  80. suite.addTest(loader.loadTestsFromTestCase(DBTests))