Skip to content

Commit

Permalink
fix: LuksDump not parsing multiple data segments (#3569)
Browse files Browse the repository at this point in the history
* fix: LuksDump not parsing multiple data segments

Signed-off-by: daniel.zatovic <[email protected]>

* Add regression test for parsing luksDump segments

Signed-off-by: daniel.zatovic <[email protected]>

Signed-off-by: daniel.zatovic <[email protected]>
  • Loading branch information
danzatt authored Nov 3, 2022
1 parent 4ac809a commit 568dbf9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion insights/parsers/cryptsetup_luksDump.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self):

ZeroLevelKVPair = Key + Value1
FirstLevelKVPair = FirstIndent >> Key + Value1
SecondLevelKVPair = SecondIndent >> WithIndent(Key + Value)
SecondLevelKVPair = SecondIndent >> WithIndent(Key + Value) << Opt(Many(Char("\n")))

Luks2SectionName = Key << Char("\n")
Luks2SectionEntry = (FirstLevelKVPair + Many(SecondLevelKVPair).map(dict)).map(self.convert_type)
Expand Down
16 changes: 15 additions & 1 deletion insights/tests/parsers/test_cryptsetup_luksDump.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
cipher: aes-xts-plain64
sector: 4096 [bytes]
1: crypt
offset: 16777216 [bytes]
length: (whole device)
cipher: aes-xts-plain64
sector: 4096 [bytes]
flags : backup-previous
2: crypt
offset: 16777216 [bytes]
length: (whole device)
cipher: aes-xts-plain64
sector: 4096 [bytes]
flags : backup-final
Keyslots:
0: luks2
Key: 512 bits
Expand Down Expand Up @@ -146,7 +160,7 @@ def test_cryptsetup_luks_dump_luks2():
assert luks2_parsed.dump["header"]["Version"] == "2"
assert len(luks2_parsed.dump["Keyslots"].keys()) == 3
assert luks2_parsed.dump["Keyslots"]["0"]["type"] == "luks2"
assert len(luks2_parsed.dump["Data segments"].keys()) == 1
assert len(luks2_parsed.dump["Data segments"].keys()) == 3
assert len(luks2_parsed.dump["Tokens"].keys()) == 1
assert len(luks2_parsed.dump["Digests"].keys()) == 1

Expand Down

0 comments on commit 568dbf9

Please sign in to comment.