keepasser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d972d66cb0b9e24666961435d3cebb074db16ec4a75b6ef30950e8e273d4af42
4
+ data.tar.gz: b05dbe748b5c8657e1d96f8d6f8b1c56ad5b76f7b96856fa7d5807bb8a9b4c98
5
+ SHA512:
6
+ metadata.gz: d3c2be284de034cc01582f3ba3c3da98eb331e27e9ba20b09407905ad750723b61592f17b1da6f7f17ad606638699f723368cf8af5eb3ac5df066f1cb539ab2e
7
+ data.tar.gz: 283d7fbf084cb226f48af27884487de16b3aaadcb5ac1be29459ddfefe9ce469f21d149e9793ad4678dfc8aaa1dbf7aa8cda0ed7d84d4d976c90fb8d727b93e8
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --format documentation
3
+ --color
@@ -0,0 +1 @@
1
+ 2.5.0
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.14.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at sam.pikesley@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in keepasser.gemspec
4
+ gemspec
@@ -0,0 +1,14 @@
1
+ guard :rspec, cmd: "bundle exec rspec" do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # RSpec files
6
+ rspec = dsl.rspec
7
+ watch(rspec.spec_helper) { rspec.spec_dir }
8
+ watch(rspec.spec_support) { rspec.spec_dir }
9
+ watch(rspec.spec_files)
10
+
11
+ # Ruby files
12
+ ruby = dsl.ruby
13
+ dsl.watch_spec_files_for(ruby.lib_files)
14
+ end
@@ -0,0 +1,21 @@
1
+ # The MIT License (MIT)
2
+
3
+ ## Copyright (c) 2018 'Sam Pikesley'
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.
@@ -0,0 +1,81 @@
1
+ [![Build Status](http://img.shields.io/travis/pikesley/keepasser.svg?style=flat-square)](https://travis-ci.org/pikesley/keepasser)
2
+ [![Coverage Status](http://img.shields.io/coveralls/pikesley/keepasser.svg?style=flat-square)](https://coveralls.io/r/pikesley/keepasser)
3
+ [![Code Climate](http://img.shields.io/codeclimate/github/pikesley/keepasser.svg?style=flat-square)](https://codeclimate.com/github/pikesley/keepasser)
4
+ [![Gem Version](http://img.shields.io/gem/v/keepasser.svg?style=flat-square)](https://rubygems.org/gems/keepasser)
5
+ [![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://pikesley.mit-license.org)
6
+
7
+ # Keepasser
8
+
9
+ I use [KeePassX](https://www.keepassx.org/) on various Macbooks and my Phone, with the `.kdb` file stored in Dropbox. For reasons I can't quite fathom, these files have started to suffer what appear to be merge-conflicts, so now my Dropbox looks like this:
10
+
11
+ keepassx (Sam P's conflicted copy) (1) (Sam P's conflicted copy).kdb
12
+ keepassx (Sam P's conflicted copy) (1).kdb
13
+ keepassx (Sam P's conflicted copy).kdb
14
+ keepassx (sampi's conflicted copy 2017-12-11).kdb
15
+ keepassx (sampi's conflicted copy 2018-01-29).kdb
16
+ keepassx.kdb
17
+
18
+ which, I'm sure you'll agree, is upsetting for any number of reasons. These files are all intact and usable, but it means that some of my logins are an untrustworthy mess
19
+
20
+ ## So, how does this help?
21
+
22
+ Well, once you've installed the gem
23
+
24
+ git clone https://github.com/pikesley/keepasser
25
+ cd keepasser
26
+ bundle
27
+ rake install
28
+
29
+ you need to:
30
+
31
+ * Open each of the `.kdb` files
32
+ * `File` > `Export to` > `Text file`
33
+ * I used the `.kdb` name between `keepassx ` and `.kdb` for the filename
34
+ * Yes, you now have all of your passwords on your laptop in plaintext _which is obviously a fucking terrible idea_, just remember to delete them when you're done, eh?
35
+ * Then, one at time, do `keepasser compare <trusted.kdb> <some_terrible_name.kdb>`
36
+
37
+ You should see some YAMLy output like:
38
+
39
+ ---
40
+ Missing entries:
41
+ web:
42
+ - Netflix:
43
+ title: Netflix
44
+ username: email@example.com
45
+ url: ''
46
+ password: password
47
+ comment:
48
+ - ''
49
+ - all4:
50
+ title: all4
51
+ username: email@example.com
52
+ url: ''
53
+ password: password
54
+ comment:
55
+ - ''
56
+ - bbc:
57
+ title: bbc
58
+ username: email@example.com
59
+ url: ''
60
+ password: password
61
+ comment:
62
+ - ''
63
+ - gopro:
64
+ title: gopro
65
+ username: email@example.com
66
+ url: ''
67
+ password: password
68
+ comment:
69
+ - ''
70
+ Different data:
71
+ web:
72
+ amazon:
73
+ password:
74
+ - oldpassword
75
+ - newpassword
76
+
77
+ ### Notes
78
+
79
+ * The assumption here is that `<trusted.kdb>` is your canonical database, and you're interested in tracking-down entries that are in the rogue DBs but not the `trusted` one, and adding them to `trusted`
80
+ * For the `Different data` section, I just went to the services concerned and tried each password to see which one was cromulent
81
+ * I may be the only person having this problem, of course
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "keepasser"
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(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'keepasser/cli'
4
+ Keepasser::CLI.start
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'keepasser/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'keepasser'
8
+ spec.version = Keepasser::VERSION
9
+ spec.authors = ['Sam Pikesley']
10
+ spec.email = ['sam.pikesley@gmail.com']
11
+
12
+ spec.summary = %q{Fix divergent KeepassX files}
13
+ spec.description = %q{Because Dropbox is bad}
14
+ spec.homepage = 'http://pikesley.org'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'thor', '~> 0.19'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.14'
27
+ spec.add_development_dependency 'rake', '~> 10.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'pry', '~> 0.11'
30
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
31
+ spec.add_development_dependency 'coveralls', '~> 0.8'
32
+ end
@@ -0,0 +1,7 @@
1
+ require 'yaml'
2
+ require 'thor'
3
+
4
+ require 'keepasser/version'
5
+ require 'keepasser/entry'
6
+ require 'keepasser/parser'
7
+ require 'keepasser/comparator'
@@ -0,0 +1,17 @@
1
+ require 'keepasser'
2
+
3
+ module Keepasser
4
+ class CLI < ::Thor
5
+ desc 'version', 'Print keepasser version'
6
+ def version
7
+ puts "keepasser version #{VERSION}"
8
+ end
9
+ map %w(-v --version) => :version
10
+
11
+ desc 'compare <a_file> <another_file>', 'Compare two KeepassX exports'
12
+ def compare left, right
13
+ comparator = Comparator.new left, right
14
+ puts comparator
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,50 @@
1
+ module Keepasser
2
+ class Comparator
3
+ attr_reader :errors
4
+
5
+ def initialize left, right
6
+ parsers = [Parser.new(left), Parser.new(right)]
7
+
8
+ @errors = {}
9
+
10
+ parsers[0].keys.each do |group|
11
+ missing = []
12
+ left = parsers[0][group].keys - parsers[1][group].keys
13
+ left.map { |entry| parsers[0][group].delete entry }
14
+
15
+ right = parsers[1][group].keys - parsers[0][group].keys
16
+ missing += right.map { |e| { e => parsers[1][group][e].fields } }
17
+ right.map { |entry| parsers[1][group].delete entry }
18
+
19
+ if missing.any?
20
+ begin
21
+ @errors['Missing entries'][group] = missing.clone
22
+ rescue NoMethodError
23
+ @errors['Missing entries'] = {}
24
+ @errors['Missing entries'][group] = missing.clone
25
+ end
26
+ end
27
+ end
28
+
29
+ parsers[0].each_pair do |group, entries|
30
+ entries.each_pair do |title, data|
31
+ if data.fields != parsers[1][group][title].fields
32
+ @errors['Different data'] = {}
33
+ @errors['Different data'][group] = {}
34
+ @errors['Different data'][group][title] = {}
35
+ data.fields.each_pair do |key, value|
36
+ other_value = parsers[1][group][title].fields[key]
37
+ if value != parsers[1][group][title].fields[key]
38
+ @errors['Different data'][group][title][key] = [value, other_value]
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ def to_s
47
+ @errors.to_yaml
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,31 @@
1
+ module Keepasser
2
+ class Entry
3
+ attr_accessor :group
4
+ attr_reader :fields
5
+
6
+ def initialize data
7
+ @fields = {}
8
+ data.map do |d|
9
+ parts = d.split ':'
10
+ if parts[1]
11
+ @fields[parts[0].downcase.strip] = parts[1].strip
12
+ end
13
+ end
14
+
15
+ @fields['comment'] = [@fields['comment']] if @fields['comment']
16
+ data.select { |f| f[0..5] == ' ' }.map { |c| @fields['comment'].push c.strip }
17
+ end
18
+
19
+ def [] key
20
+ @fields[key]
21
+ end
22
+
23
+ def method_missing m, *args
24
+ @fields[m.to_s]
25
+ end
26
+
27
+ def == other
28
+ @fields == other.fields
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,35 @@
1
+ module Keepasser
2
+ class Parser < Hash
3
+ attr_reader :path
4
+
5
+ def initialize path
6
+ @path = path
7
+ lines = File.readlines @path
8
+
9
+ bucket= []
10
+ lines.each do |line|
11
+ if line[0..8] == '*** Group'
12
+ @group = line[11..-6]
13
+ self[@group] = {}
14
+ else
15
+ unless line == "\n"
16
+ bucket.push line
17
+ else
18
+ if bucket.any?
19
+ e = Entry.new bucket
20
+ e.group = @group
21
+
22
+ self[@group][e.title] = e.clone
23
+
24
+ bucket = []
25
+ end
26
+ end
27
+ end
28
+ end
29
+ e = Entry.new bucket
30
+ e.group = @group
31
+
32
+ self[@group][e.title] = e.clone
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module Keepasser
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: keepasser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sam Pikesley
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
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.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
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: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
111
+ description: Because Dropbox is bad
112
+ email:
113
+ - sam.pikesley@gmail.com
114
+ executables:
115
+ - keepasser
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".ruby-version"
122
+ - ".travis.yml"
123
+ - CODE_OF_CONDUCT.md
124
+ - Gemfile
125
+ - Guardfile
126
+ - LICENSE.md
127
+ - README.md
128
+ - Rakefile
129
+ - bin/console
130
+ - bin/setup
131
+ - exe/keepasser
132
+ - keepasser.gemspec
133
+ - lib/keepasser.rb
134
+ - lib/keepasser/cli.rb
135
+ - lib/keepasser/comparator.rb
136
+ - lib/keepasser/entry.rb
137
+ - lib/keepasser/parser.rb
138
+ - lib/keepasser/version.rb
139
+ homepage: http://pikesley.org
140
+ licenses:
141
+ - MIT
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.7.3
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: Fix divergent KeepassX files
163
+ test_files: []