Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Comment: | Handle single and double quotes. Update README with assumptions
Quite a hacky mess to handle single and double quotes but seems to work. This was the test file used: ``` |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e97152f6128e014d23e024125e4eb9d2 |
User & Date: | atomicules 2019-08-09 13:36:13 |
2019-08-09
| ||
15:48 |
Much more sensible escaping of quotes
I'd tried unicode before, but couldn't get it to work, I think because I was | |
13:36 |
Handle single and double quotes. Update README with assumptions
Quite a hacky mess to handle single and double quotes but seems to work. This was the test file used: ``` | |
2019-06-29
| ||
11:05 | Some spaces to tabs check-in: c039cd9bd1 user: atomicules tags: master, trunk | |
Changes to README.markdown.
︙ | ︙ | |||
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | - Assumes two-level hierarchy of data in pwman - Only uses Login and Secure Note op templates - Secure Notes have to be in a "SECURE-NOTES" category/heading in PWman - Ignores stuff in a "INACTIVE" category/heading in PWman - Assumes an existing authenticated op session - pwman.db file needs to be decrypted up front to `~/.pwman.db.decrypt` - Mappings from PWman to 1password are as follows: - For Logins - name -> title - host -> url - user -> username - passwd -> password - launch -> notesPlain - category -> tag - For Secure Notes - name -> title - host -> notesPlain - user -> notesPlain - passwd -> notesPlain - launch -> notesPlain - category -> tag | > > > < < < < < < | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | - Assumes two-level hierarchy of data in pwman - Only uses Login and Secure Note op templates - Secure Notes have to be in a "SECURE-NOTES" category/heading in PWman - Ignores stuff in a "INACTIVE" category/heading in PWman - Assumes an existing authenticated op session - pwman.db file needs to be decrypted up front to `~/.pwman.db.decrypt` - Assumes untampered with XML. Note that newlines and spaces will add additional "nodes" that breaks the assumption of this code. By default PWman includes no spaces or newlines, etc. - Mappings from PWman to 1password are as follows: - For Logins - name -> title - host -> url - user -> username - passwd -> password - launch -> notesPlain - category -> tag - For Secure Notes - name -> title - host -> notesPlain - user -> notesPlain - passwd -> notesPlain - launch -> notesPlain - category -> tag |
Changes to pwman2op.lisp.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ; CLisp script for SBCL to export PWman to 1password ; Converts items to 1pass using 1password cli to import rather than an intermediate format; assumes an existing authenticated session ; See README for usage instructions ; Load quicklisp (load "~/.sbclrc") ; Load libraries ; Had parsing errors with xmls so use cxml instead (ql:quickload "cxml") ; Just assume two template types ; Obtained from `op get template <category>` (defun template-secure-note (content) | > > > > > > | | | | | | | > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 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 | ; CLisp script for SBCL to export PWman to 1password ; Converts items to 1pass using 1password cli to import rather than an intermediate format; assumes an existing authenticated session ; See README for usage instructions ; Load quicklisp (load "~/.sbclrc") ; Load libraries ; Had parsing errors with xmls so use cxml instead (ql:quickload "cxml") (ql:quickload "cl-ppcre") ; "Escape" certain characters. Will replace back on cli call (defun escape-quotes (text) (cl-ppcre:regex-replace-all "\"" (cl-ppcre:regex-replace-all "'" text "SINGLEQUOTE" :preserve-case t) "DOUBLEQUOTE" :preserve-case t)) ; Just assume two template types ; Obtained from `op get template <category>` (defun template-secure-note (content) (concatenate 'string "{\"notesPlain\":\"" (escape-quotes content) "\",\"sections\":[]}")) (defun template-login (username password content) (concatenate 'string "{\"notesPlain\":\"" (escape-quotes content) "\",\"sections\":[],\"passwordHistory\":[],\"fields\":[{\"value\":\"" username "\",\"name\":\"username\",\"type\":\"T\",\"designation\":\"username\"},{\"value\":\"" password "\",\"name\":\"password\",\"type\":\"P\",\"designation\":\"password\"}]}")) (defun send-to-op (op-category pwman-category name host username passwd launch) (progn ; Case would be better if I can figure that out (defparameter template (if (string= op-category "Login") (template-login username passwd launch) ; 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)))) ; Command line notes, because multiple levels of escaping are confusing ; echo | sed 's#DOUBLEQUOTE#\\"#' ; echo | sed s#SINGLEQUOTE#\\\'# ; should work (defparameter extproc (sb-ext:run-program "sh" (list "-c" (concatenate 'string "echo '" template "' | sed 's#DOUBLEQUOTE#\\\\\"#g' | sed s#SINGLEQUOTE#\\\'#g | op encode")) :search :environment :output :stream)) (print template) (print (concatenate 'string "echo '" template "' | sed 's#DOUBLEQUOTE#\\\"#g' | sed s#SINGLEQUOTE#\\\'#g | op encode")) (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. ; Need to only send url if it's a Login item (defparameter defaultargs (list "create" "item" op-category encoded-item (concatenate 'string "--title=" name) (concatenate 'string "--tags=" pwman-category))) (defparameter args (if (string= op-category "Login") ; Append, because need at end |
︙ | ︙ |