mirror of
https://github.com/mvt-project/mvt.git
synced 2026-10-02 05:59:39 +02:00
Do not treat a section's timing line as a section boundary
extract_command_section() ends a section at any line starting with "------". dumpstate prints a section's timing line when THAT section finishes, and it can land in the middle of the section currently being written, so the section is truncated at an arbitrary point and the rest is silently dropped. Skip the timing line instead of returning it: it never reaches a parser as content, and the real "------ <NAME> ------" boundary still ends the section. Measured over 40 bug reports carrying a dumpstate: SYSTEM PROPERTIES was truncated on 6 of them, losing 6559 properties, and 3 parsed no property at all. On one Samsung archive getprop goes from 418 to 1259 properties and from 0 to 473 ro.* ones, bringing back ro.product.model, ro.build.version.security_patch and ro.boot.verifiedbootstate. The other 34 archives are byte-identical. Fixes #938
This commit is contained in:
1 parent
777db67291
commit
6f65eee85a
2 files changed
+53
No files matched your search
@@ -0,0 +1,42 @@
|
||||
# Mobile Verification Toolkit (MVT)
|
||||
# Copyright (c) 2021-2026 The MVT Authors.
|
||||
# Use of this software is governed by the MVT License 1.1 that can be found at
|
||||
# https://license.mvt.re/1.1/
|
||||
"""A section ends at the next section, not at a timing line printed inside it."""
|
||||
|
||||
from mvt.android.modules.bugreport.base import BugReportModule
|
||||
|
||||
# dumpstate prints a section's duration when that section finishes, which can
|
||||
# land in the middle of the section currently being written.
|
||||
DUMPSTATE = """\
|
||||
------ SYSTEM PROPERTIES (getprop) ------
|
||||
[nfc.initialized]: [true]
|
||||
------ 0.101s was the duration of 'DROPBOX SYSTEM SERVER CRASHES' ------
|
||||
[ro.build.version.sdk]: [30]
|
||||
[ro.product.model]: [SM-A305F]
|
||||
------ 0.064s was the duration of 'SYSTEM PROPERTIES' ------
|
||||
------ STORAGE INFO (df) ------
|
||||
/dev/root 2.9G
|
||||
"""
|
||||
|
||||
|
||||
class TestExtractCommandSection:
|
||||
def test_a_foreign_timing_line_does_not_end_the_section(self):
|
||||
section = BugReportModule.extract_command_section(
|
||||
DUMPSTATE, "------ SYSTEM PROPERTIES"
|
||||
)
|
||||
assert "[ro.product.model]: [SM-A305F]" in section
|
||||
assert section.count("\n") == 2
|
||||
|
||||
def test_the_next_section_is_still_the_boundary(self):
|
||||
section = BugReportModule.extract_command_section(
|
||||
DUMPSTATE, "------ SYSTEM PROPERTIES"
|
||||
)
|
||||
assert "STORAGE INFO" not in section
|
||||
assert "/dev/root" not in section
|
||||
|
||||
def test_timing_lines_are_not_returned_as_content(self):
|
||||
section = BugReportModule.extract_command_section(
|
||||
DUMPSTATE, "------ SYSTEM PROPERTIES"
|
||||
)
|
||||
assert "was the duration of" not in section
|
||||
Reference in new issue
Block a user