Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Correctly identify Secure Notes, correctly send optional args
- I had SECURE-NOTE whereas in my pwman it's SECURE-NOTES. Dur! |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
11718ac61a1c7b1d373dc4f0d3d31f45 |
User & Date: | atomicules 2019-06-25 12:07:56 |
2019-06-25
| ||
12:30 |
Only send --url if it's a login item
Not applicable for Secure Notes and op won't allow it. Using append and | |
12:07 |
Correctly identify Secure Notes, correctly send optional args
- I had SECURE-NOTE whereas in my pwman it's SECURE-NOTES. Dur! | |
11:12 |
Initial commit of pwman2op
It "works", but doesn't yet. Main issues are: - Seems to send everything as a Login item... but maybe that's correct based on Update README to reflect that this repo now includes this file as well. check-in: 81d3818ee0 user: atomicules tags: master, trunk | |
Changes to pwman2op.lisp.
︙ | ︙ | |||
23 24 25 26 27 28 29 30 31 32 33 34 35 | (progn ; Case would be better if I can figure that out ; Need to fill in correct template (print "op-category:") (print op-category) (print "pwman-category") (print pwman-category) (defparameter template (if (string= op-category "Login") (template-login username passwd launch) ; Errr... I guess just assume it's... need to do this and not multiple ifs in progn as otherwise template picks up NIL from progmn ; Need to combine fields for Secure notes (template-secure-note (concatenate 'string "host: " host "; user: " username "; password: " passwd "; launch: " launch)))) | > > | | | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | (progn ; Case would be better if I can figure that out ; Need to fill in correct template (print "op-category:") (print op-category) (print "pwman-category") (print pwman-category) (print "name") (print name) (defparameter template (if (string= op-category "Login") (template-login username passwd launch) ; Errr... I guess just assume it's... need to do this and not multiple ifs in progn as otherwise template picks up NIL from progmn ; Need to combine fields for Secure notes (template-secure-note (concatenate 'string "host: " host "; user: " username "; password: " passwd "; launch: " launch)))) ;(print "template:") ;(print template) ; Encode first and get return ; Probably many better ways to do this... ; Myabe base64 encode directly here... subtle differences though it seems with op ; Need to single quote encode the json (defparameter extproc (sb-ext:run-program "sh" (list "-c" (concatenate 'string "echo '" template "' | op encode")) :search :environment :output :stream)) (defparameter encoded-item (read-line (sb-ext:process-output extproc))) ;(print encoded-item) ; Create item ; Just going to send blanks, etc if that's what some fields are. It doesn't seem to matter. ; ALMOST working... ; Need to pick up correct env... I.e. thinks not logged in... ; Maybe pass session variable to this? Maybe no need...? (defparameter cproc (sb-ext:run-program "op" (list "create" "item" op-category encoded-item (concatenate 'string "--title=" name) (concatenate 'string "--url=" host) (concatenate 'string "--tags=" pwman-category)) :search :environment :output :stream)) (defparameter output (read-line (sb-ext:process-output cproc))) (print output))) ; Mappings are as follows: ; `op create item <category> <encodeditem> [--title=<title>] [--url=<url>] [--vault=<vault>] [--tags=<tags>]` ; |
︙ | ︙ | |||
86 87 88 89 90 91 92 | ;(dom:do-node-list (category *categories*) (print (dom:get-attribute category "name"))) (dom:do-node-list (category *categories*) (progn (defparameter category-name (dom:get-attribute category "name")) (defparameter pwlists (dom:child-nodes category)) ; Kept for ref - prints category | | | | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | ;(dom:do-node-list (category *categories*) (print (dom:get-attribute category "name"))) (dom:do-node-list (category *categories*) (progn (defparameter category-name (dom:get-attribute category "name")) (defparameter pwlists (dom:child-nodes category)) ; Kept for ref - prints category ;(print category-name) (dom:do-node-list (pwlist pwlists) (progn ; Rather than loop through at this point, call things explicitly so can then build the op command (defparameter pwitems (dom:child-nodes pwlist)) ; Kept for ref - prints Name ;(print (dom:tag-name (dom:item pwitems 0))) ;(print (dom:data (dom:item (dom:child-nodes (dom:item pwitems 0)) 0))) ; Need to check for NIL and only then set paremter. E.g: (defparameter name (if (dom:item (dom:child-nodes (dom:item pwitems 0)) 0) (dom:data (dom:item (dom:child-nodes (dom:item pwitems 0)) 0)) ""))) (defparameter host (if (dom:item (dom:child-nodes (dom:item pwitems 1)) 0) |
︙ | ︙ | |||
115 116 117 118 119 120 121 | (if (dom:item (dom:child-nodes (dom:item pwitems 3)) 0) (dom:data (dom:item (dom:child-nodes (dom:item pwitems 3)) 0)) "")) (defparameter launch (if (dom:item (dom:child-nodes (dom:item pwitems 4)) 0) (dom:data (dom:item (dom:child-nodes (dom:item pwitems 4)) 0)) "")) | | | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | (if (dom:item (dom:child-nodes (dom:item pwitems 3)) 0) (dom:data (dom:item (dom:child-nodes (dom:item pwitems 3)) 0)) "")) (defparameter launch (if (dom:item (dom:child-nodes (dom:item pwitems 4)) 0) (dom:data (dom:item (dom:child-nodes (dom:item pwitems 4)) 0)) "")) (if (string= category-name "SECURE-NOTES") (send-to-op "Secure Note" category-name name host username passwd launch) (progn (if (string/= category-name "INACTIVE") (send-to-op "Login" category-name name host username passwd launch))))))) ; Only right at end do we want to delete file ; (if (= 0 (sb-ext:process-exit-code proc)) ; ;If that was successful, then delete the un-encrypted files ; (progn ; (delete-file infile) ; (delete-file "pwman.txt")) ; ;If not restore backup and leave plain text files (otherwise will fail next time on above rename) ; (progn ; (rename-file (concatenate 'string (sb-unix::posix-getenv "HOME") "/.pwman.db.bak") (concatenate 'string (sb-unix::posix-getenv "HOME") "/.pwman.db")) ; (print "Couldn't encrypt file, plain text files have not been deleted")))) |