lastpass 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ Version 1.2.0
2
+ -------------
3
+
4
+ - Server secure note support
5
+
6
+
1
7
  Version 1.1.0
2
8
  -------------
3
9
 
@@ -20,15 +20,36 @@ module LastPass
20
20
  end
21
21
 
22
22
  # Parses an account chunk, decrypts and creates an Account object.
23
+ # May return nil when the chunk does not represent an account.
24
+ # All secure notes are ACCTs but not all of them strore account
25
+ # information.
26
+ #
27
+ # TODO: Make a test case that covers secure note account
23
28
  def self.parse_ACCT chunk, encryption_key
24
29
  StringIO.open chunk.payload do |io|
25
30
  id = read_item io
26
31
  name = decode_aes256_auto read_item(io), encryption_key
27
32
  group = decode_aes256_auto read_item(io), encryption_key
28
33
  url = decode_hex read_item io
29
- 3.times { skip_item io }
34
+ notes = decode_aes256_auto read_item(io), encryption_key
35
+ 2.times { skip_item io }
30
36
  username = decode_aes256_auto read_item(io), encryption_key
31
37
  password = decode_aes256_auto read_item(io), encryption_key
38
+ 2.times { skip_item io }
39
+ secure_note = read_item io
40
+
41
+ # Parse secure note
42
+ if secure_note == "1"
43
+ 17.times { skip_item io }
44
+ secure_note_type = read_item io
45
+
46
+ # Only "Server" secure note stores account information
47
+ if secure_note_type != "Server"
48
+ return nil
49
+ end
50
+
51
+ url, username, password = parse_secure_note_server notes
52
+ end
32
53
 
33
54
  Account.new id, name, username, password, url, group
34
55
  end
@@ -84,6 +105,26 @@ module LastPass
84
105
  end
85
106
  end
86
107
 
108
+ def self.parse_secure_note_server notes
109
+ url = nil
110
+ username = nil
111
+ password = nil
112
+
113
+ notes.split("\n").each do |i|
114
+ key, value = i.split ":", 2
115
+ case key
116
+ when "Hostname"
117
+ url = value
118
+ when "Username"
119
+ username = value
120
+ when "Password"
121
+ password = value
122
+ end
123
+ end
124
+
125
+ [url, username, password]
126
+ end
127
+
87
128
  # Reads one chunk from a stream and creates a Chunk object with the data read.
88
129
  def self.read_chunk stream
89
130
  # LastPass blob chunk is made up of 4-byte ID,
@@ -36,7 +36,10 @@ module LastPass
36
36
  case i.id
37
37
  when "ACCT"
38
38
  # TODO: Put shared folder name as group in the account
39
- @accounts.push Parser.parse_ACCT i, key
39
+ account = Parser.parse_ACCT i, key
40
+ if account
41
+ @accounts << account
42
+ end
40
43
  when "PRIK"
41
44
  rsa_private_key = Parser.parse_PRIK i, encryption_key
42
45
  when "SHAR"
@@ -2,5 +2,5 @@
2
2
  # Licensed under the terms of the MIT license. See LICENCE for details.
3
3
 
4
4
  module LastPass
5
- VERSION = "1.1.0"
5
+ VERSION = "1.2.0"
6
6
  end
data/spec/parser_spec.rb CHANGED
@@ -185,6 +185,20 @@ describe LastPass::Parser do
185
185
  end
186
186
  end
187
187
 
188
+ describe ".parse_secure_note_server" do
189
+ let(:url) { "url" }
190
+ let(:username) { "username" }
191
+ let(:password) { "password" }
192
+ let(:notes) { "Hostname:#{url}\nUsername:#{username}\nPassword:#{password}" }
193
+
194
+ it "returns parsed values" do
195
+ result = LastPass::Parser.parse_secure_note_server notes
196
+ expect(result[0]).to eq url
197
+ expect(result[1]).to eq username
198
+ expect(result[2]).to eq password
199
+ end
200
+ end
201
+
188
202
  describe ".read_chunk" do
189
203
  it "returns a chunk" do
190
204
  with_chunk_hex "ABCD", "DEADBEEF", padding do |io|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lastpass
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-16 00:00:00.000000000 Z
12
+ date: 2014-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty