keepassx 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +30 -0
  3. data/.gitignore +9 -0
  4. data/.rubocop.yml +64 -0
  5. data/.travis.yml +12 -3
  6. data/Gemfile +4 -2
  7. data/Guardfile +16 -0
  8. data/LICENSE +19 -0
  9. data/README.md +33 -0
  10. data/Rakefile +3 -2
  11. data/keepassx.gemspec +20 -10
  12. data/lib/keepassx.rb +42 -3
  13. data/lib/keepassx/aes_crypt.rb +16 -6
  14. data/lib/keepassx/database.rb +218 -27
  15. data/lib/keepassx/database/dumper.rb +87 -0
  16. data/lib/keepassx/database/finder.rb +102 -0
  17. data/lib/keepassx/database/loader.rb +217 -0
  18. data/lib/keepassx/entry.rb +70 -38
  19. data/lib/keepassx/field/base.rb +191 -0
  20. data/lib/keepassx/field/entry.rb +32 -0
  21. data/lib/keepassx/field/group.rb +27 -0
  22. data/lib/keepassx/fieldable.rb +161 -0
  23. data/lib/keepassx/group.rb +93 -20
  24. data/lib/keepassx/hashable_payload.rb +6 -0
  25. data/lib/keepassx/header.rb +102 -27
  26. data/lib/keepassx/version.rb +5 -0
  27. data/spec/factories.rb +23 -0
  28. data/spec/fixtures/database_empty.kdb +0 -0
  29. data/spec/fixtures/database_test.kdb +0 -0
  30. data/spec/fixtures/database_test_dumped.yml +76 -0
  31. data/spec/fixtures/database_with_key.kdb +0 -0
  32. data/spec/fixtures/database_with_key.key +1 -0
  33. data/spec/fixtures/database_with_key2.key +1 -0
  34. data/spec/fixtures/test_data_array.yml +113 -0
  35. data/spec/fixtures/test_data_array_dumped.yml +124 -0
  36. data/spec/keepassx/database_spec.rb +491 -29
  37. data/spec/keepassx/entry_spec.rb +95 -0
  38. data/spec/keepassx/group_spec.rb +92 -0
  39. data/spec/keepassx_spec.rb +17 -0
  40. data/spec/spec_helper.rb +59 -3
  41. metadata +143 -69
  42. data/.rvmrc +0 -1
  43. data/Gemfile.lock +0 -28
  44. data/lib/keepassx/entry_field.rb +0 -49
  45. data/lib/keepassx/group_field.rb +0 -44
  46. data/spec/test_database.kdb +0 -0
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm 1.8.7-p249@keepassx --create
@@ -1,28 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- keepassx (0.1.0)
5
- fast-aes (~> 0.1)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- diff-lcs (1.1.3)
11
- fast-aes (0.1.1)
12
- rake (0.8.7)
13
- rspec (2.11.0)
14
- rspec-core (~> 2.11.0)
15
- rspec-expectations (~> 2.11.0)
16
- rspec-mocks (~> 2.11.0)
17
- rspec-core (2.11.1)
18
- rspec-expectations (2.11.3)
19
- diff-lcs (~> 1.1.3)
20
- rspec-mocks (2.11.3)
21
-
22
- PLATFORMS
23
- ruby
24
-
25
- DEPENDENCIES
26
- keepassx!
27
- rake (= 0.8.7)
28
- rspec (= 2.11.0)
@@ -1,49 +0,0 @@
1
- module Keepassx
2
- class EntryField
3
- FIELD_TYPES = [
4
- [0x0, 'ignored', :null],
5
- [0x1, 'uuid', :ascii],
6
- [0x2, 'groupid', :int],
7
- [0x3, 'imageid', :int],
8
- [0x4, 'title', :string],
9
- [0x5, 'url', :string],
10
- [0x6, 'username', :string],
11
- [0x7, 'password', :string],
12
- [0x8, 'notes', :string],
13
- [0x9, 'creation_time', :date],
14
- [0xa, 'last_mod_time', :date],
15
- [0xb, 'last_acc_time', :date],
16
- [0xc, 'expiration_time', :date],
17
- [0xd, 'binary_desc', :string],
18
- [0xe, 'binary_data', :shunt],
19
- [0xFFFF, 'terminator', :nil]
20
- ]
21
- FIELD_TERMINATOR = 0xFFFF
22
- TYPE_CODE_FIELD_SIZE = 2 # unsigned short integer
23
- DATA_LENGTH_FIELD_SIZE = 4 # unsigned integer
24
-
25
-
26
- attr_reader :name, :data_type, :data
27
-
28
- def initialize(payload)
29
- type_code, @data_length = payload.read(TYPE_CODE_FIELD_SIZE + DATA_LENGTH_FIELD_SIZE).unpack('SI')
30
- @name, @data_type = _parse_type_code(type_code)
31
- @data = payload.read(@data_length)
32
- end
33
-
34
- def terminator?
35
- name == 'terminator'
36
- end
37
-
38
- def length
39
- TYPE_CODE_FIELD_SIZE + DATA_LENGTH_FIELD_SIZE + @data_length
40
- end
41
-
42
- def _parse_type_code(type_code)
43
- (_, name, data_type) = FIELD_TYPES.detect do |(code, *rest)|
44
- code == type_code
45
- end
46
- [name, data_type]
47
- end
48
- end
49
- end
@@ -1,44 +0,0 @@
1
- module Keepassx
2
- class GroupField
3
- FIELD_TYPES = [
4
- [0x0, 'ignored', :null],
5
- [0x1, 'groupid', :int],
6
- [0x2, 'group_name', :string],
7
- [0x3, 'creation_time', :date],
8
- [0x4, 'lastmod_time', :date],
9
- [0x5, 'lastacc_time', :date],
10
- [0x6, 'expire_time', :date],
11
- [0x7, 'imageid', :int],
12
- [0x8, 'level', :short],
13
- [0x9, 'flags', :int],
14
- [0xFFFF, 'terminator', :null]
15
- ]
16
- FIELD_TERMINATOR = 0xFFFF
17
- TYPE_CODE_FIELD_SIZE = 2 # unsigned short integer
18
- DATA_LENGTH_FIELD_SIZE = 4 # unsigned integer
19
-
20
-
21
- attr_reader :name, :data_type, :data
22
-
23
- def initialize(payload)
24
- type_code, @data_length = payload.read(TYPE_CODE_FIELD_SIZE + DATA_LENGTH_FIELD_SIZE).unpack('SI')
25
- @name, @data_type = _parse_type_code(type_code)
26
- @data = payload.read(@data_length)
27
- end
28
-
29
- def terminator?
30
- name == 'terminator'
31
- end
32
-
33
- def length
34
- TYPE_CODE_FIELD_SIZE + DATA_LENGTH_FIELD_SIZE + @data_length
35
- end
36
-
37
- def _parse_type_code(type_code)
38
- (_, name, data_type) = FIELD_TYPES.detect do |(code, *rest)|
39
- code == type_code
40
- end
41
- [name, data_type]
42
- end
43
- end
44
- end
Binary file