last_kee_diff 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3750c66535bcc255fdf0ebb3d9217c987adc4f81
4
+ data.tar.gz: be07b8282ca3925005c7c8b9204d936ed9efdd9e
5
+ SHA512:
6
+ metadata.gz: b53d27e16773ac871dba5dc24ed41ff30c3e53c0a6da40ea1014add9d688bdd537213c38590cdabc12cf0f88993b91b199dc7aeecb76a362b7a68ed8914330ab
7
+ data.tar.gz: bf5a747f1b1d774f7d61df00eaa3aaa5e2b1566fa95cc2e0801524da6c30630c915001811aaa0ede26d74dda5919cdd2c9b5bf03248d07a5a3918fcf71988b92
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ last_kee_diff
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.2.0
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in last_kee_diff.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Roque Pinel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # LastKeeDiff
2
+
3
+ This gem allows you to compare entries from LassPass and KeePass. It describe the differences into three groups: entries only present in LastPass, entries only present in KeePass and common entries.
4
+
5
+ ## Installation
6
+
7
+ Install the gem and make the executable available:
8
+
9
+ $ gem install last_kee_diff
10
+
11
+ ## Usage
12
+
13
+ *First, to void leaving your passwords vulnerable please consider keeping your exported files in an encrypted storage.*
14
+
15
+ 1. Export the CSV file from LassPass. Let's call it ```lass_pass.csv```.
16
+ 2. Export the XML file from KeePass. Let's call it ```kee_pass.xml```.
17
+ 3. Run ```last-kee-diff -l lass_pass.csv -k kee_pass.xml```.
18
+
19
+ ## Development
20
+
21
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
22
+
23
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/last_kee_diff/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'test'
8
+ t.test_files = FileList['test/**/test*.rb']
9
+ end
10
+
11
+ task(default: :test)
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "last_kee_diff"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/last-kee-diff ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'last_kee_diff'
4
+
5
+ options = {}
6
+ opt_parser = OptionParser.new do |opts|
7
+ opts.banner = 'Usage: last-kee-diff [options]'
8
+
9
+ opts.separator ''
10
+ opts.separator 'Required options:'
11
+
12
+ opts.on('-l', '--last-pass [LAST_PASS_FILE]', 'The LastPass CSV file') do |last_pass_file|
13
+ options[:last_pass_file] = last_pass_file
14
+ end
15
+
16
+ opts.on('-k', '--kee-pass [KEE_PASS_FILE]', 'The KeePass XML file') do |kee_pass_file|
17
+ options[:kee_pass_file] = kee_pass_file
18
+ end
19
+
20
+ opts.separator ''
21
+ opts.separator 'Extra options:'
22
+
23
+ opts.on_tail('-h', '--help', 'Show this message') do
24
+ puts opts
25
+ exit
26
+ end
27
+
28
+ opts.on_tail('-v', '--version', 'Show version') do
29
+ puts LastKeeDiff::VERSION
30
+ exit
31
+ end
32
+ end
33
+
34
+ opt_parser.parse!
35
+
36
+ abort opt_parser.to_s if options[:last_pass_file].nil? || options[:kee_pass_file].nil?
37
+
38
+ LastKeeDiff.diff options[:last_pass_file], options[:kee_pass_file]
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'last_kee_diff/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "last_kee_diff"
8
+ spec.version = LastKeeDiff::VERSION
9
+ spec.authors = ["Roque Pinel"]
10
+ spec.email = ["repinel@gmail.com"]
11
+
12
+ spec.summary = %q{LastPass and KeePass diff.}
13
+ spec.description = %q{Compare LastPass and KeePass entries.}
14
+ spec.homepage = "https://github.com/repinel/last_kee_diff"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "nokogiri", "~> 1.6"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.8"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.5"
27
+ end
@@ -0,0 +1,120 @@
1
+ require 'last_kee_diff/entry'
2
+ require 'last_kee_diff/version'
3
+
4
+ require 'csv'
5
+ require 'nokogiri'
6
+
7
+ module LastKeeDiff
8
+ def self.diff(csv_file, xml_file)
9
+ csv_entries = self.read_csv csv_file
10
+ xml_entries = self.read_xml xml_file
11
+
12
+ #... extra csv entries
13
+ puts '>> Entries only present in LastPass:'
14
+ (csv_entries.keys - xml_entries.keys).each do |key|
15
+ puts csv_entries[key]
16
+ end
17
+
18
+ #... common entries
19
+ puts '>> Common entries (LastPass <-> KeePass):'
20
+ (csv_entries.keys & xml_entries.keys).each do |key|
21
+ io = StringIO.new
22
+
23
+ csv_entries[key].instance_variables.each do |att|
24
+ att = att.to_s[1..-1]
25
+ if csv_entries[key].send(att).to_s.sub(/^http:\/\//, '') != xml_entries[key].send(att).to_s.sub(/^http:\/\//, '')
26
+ io.puts "\t#{att.capitalize} changed: ''#{csv_entries[key].send(att)}'' <-> ''#{xml_entries[key].send(att)}''"
27
+ end
28
+ end
29
+
30
+ if io.size > 0
31
+ puts key
32
+ puts io.string
33
+ end
34
+ end
35
+
36
+ #... extra xml entries
37
+ puts '>> Entries only present in KeePass:'
38
+ (xml_entries.keys - csv_entries.keys).each do |key|
39
+ puts xml_entries[key]
40
+ end
41
+ end
42
+
43
+ # CSV format:
44
+ # 0: url
45
+ # 1: username
46
+ # 2: password
47
+ # 3: extra
48
+ # 4: name
49
+ # 5: grouping
50
+ # 6: fav
51
+ def self.read_csv(file_name)
52
+ puts "Reading CSV..."
53
+
54
+ entries = {}
55
+
56
+ CSV.foreach file_name, headers: true do |row|
57
+ entry = Entry.new row[5].to_s.gsub(/\\/, '/'), row[4], row[1], row[2], row[0]
58
+ self.add_if_not_duplicated entries, entry
59
+ end
60
+
61
+ entries
62
+ end
63
+
64
+ # XML format:
65
+ # <database>
66
+ # <group>
67
+ # <title></title>
68
+ # <entry>
69
+ # <title></title>
70
+ # <username></username>
71
+ # <password></password>
72
+ # <url></url>
73
+ # </entry>
74
+ # <!-- multiples entries or groups -->
75
+ # </group>
76
+ # <!-- multiples groups -->
77
+ # </database>
78
+ def self.read_xml(file_name)
79
+ puts "Reading XML..."
80
+
81
+ entries = {}
82
+
83
+ File.open file_name do |f|
84
+ doc = Nokogiri::XML f
85
+
86
+ doc.xpath('//group').each do |group|
87
+ # skip backups
88
+ next if group.at_css('title').text == 'Backup' && group.parent && group.parent.name != 'group'
89
+
90
+ group_name = group.at_css('title').text.tap do |text|
91
+ parent = group.parent
92
+ while parent && parent.name == 'group'
93
+ text.prepend "#{parent.at_css('title').text}/"
94
+ parent = parent.parent
95
+ end
96
+ end
97
+
98
+ group.xpath('./entry').each do |entry|
99
+ entry = Entry.new group_name,
100
+ entry.at_css('title').text,
101
+ entry.at_css('username').text,
102
+ entry.at_css('password').text,
103
+ entry.at_css('url').text
104
+
105
+ self.add_if_not_duplicated entries, entry
106
+ end
107
+ end
108
+ end
109
+
110
+ entries
111
+ end
112
+
113
+ def self.add_if_not_duplicated(entries, entry)
114
+ if entries[entry.key]
115
+ puts "Duplicated key: #{entry.key}"
116
+ else
117
+ entries[entry.key] = entry
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,26 @@
1
+ module LastKeeDiff
2
+ class Entry
3
+ attr_reader :group_name, :title, :username, :password, :url
4
+
5
+ def initialize(group_name, title, username, password, url)
6
+ @group_name = group_name
7
+ @title = title
8
+ @username = username
9
+ @password = password
10
+ @url = url
11
+ end
12
+
13
+ def to_s
14
+ [
15
+ self.key,
16
+ "Username: #{self.username}",
17
+ "Password: #{self.password}",
18
+ "URL: #{self.url}"
19
+ ].join("\n\t")
20
+ end
21
+
22
+ def key
23
+ "#{self.group_name}/#{self.title}"
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module LastKeeDiff
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: last_kee_diff
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Roque Pinel
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.5'
69
+ description: Compare LastPass and KeePass entries.
70
+ email:
71
+ - repinel@gmail.com
72
+ executables:
73
+ - last-kee-diff
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".ruby-gemset"
79
+ - ".ruby-version"
80
+ - ".travis.yml"
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - exe/last-kee-diff
89
+ - last_kee_diff.gemspec
90
+ - lib/last_kee_diff.rb
91
+ - lib/last_kee_diff/entry.rb
92
+ - lib/last_kee_diff/version.rb
93
+ homepage: https://github.com/repinel/last_kee_diff
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.4.5
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: LastPass and KeePass diff.
117
+ test_files: []