dfindexeddb 20240305__py3-none-any.whl → 20240324__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dfindexeddb/indexeddb/blink.py +2 -1
- dfindexeddb/indexeddb/chromium.py +4 -4
- dfindexeddb/indexeddb/cli.py +101 -0
- dfindexeddb/indexeddb/utils.py +0 -0
- dfindexeddb/leveldb/cli.py +217 -0
- dfindexeddb/leveldb/definitions.py +16 -0
- dfindexeddb/leveldb/descriptor.py +10 -11
- dfindexeddb/leveldb/ldb.py +20 -24
- dfindexeddb/leveldb/log.py +25 -18
- dfindexeddb/leveldb/record.py +102 -0
- dfindexeddb/leveldb/utils.py +116 -0
- dfindexeddb/utils.py +5 -46
- dfindexeddb/version.py +1 -1
- {dfindexeddb-20240305.dist-info → dfindexeddb-20240324.dist-info}/METADATA +46 -32
- dfindexeddb-20240324.dist-info/RECORD +26 -0
- {dfindexeddb-20240305.dist-info → dfindexeddb-20240324.dist-info}/WHEEL +1 -1
- dfindexeddb-20240324.dist-info/entry_points.txt +3 -0
- dfindexeddb/cli.py +0 -180
- dfindexeddb-20240305.dist-info/RECORD +0 -22
- dfindexeddb-20240305.dist-info/entry_points.txt +0 -2
- {dfindexeddb-20240305.dist-info → dfindexeddb-20240324.dist-info}/AUTHORS +0 -0
- {dfindexeddb-20240305.dist-info → dfindexeddb-20240324.dist-info}/LICENSE +0 -0
- {dfindexeddb-20240305.dist-info → dfindexeddb-20240324.dist-info}/top_level.txt +0 -0
dfindexeddb/cli.py
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
# Copyright 2024 Google LLC
|
|
3
|
-
#
|
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
# you may not use this file except in compliance with the License.
|
|
6
|
-
# You may obtain a copy of the License at
|
|
7
|
-
#
|
|
8
|
-
# https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
#
|
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
-
# See the License for the specific language governing permissions and
|
|
14
|
-
# limitations under the License.
|
|
15
|
-
"""A CLI tool for dfindexeddb."""
|
|
16
|
-
import argparse
|
|
17
|
-
import dataclasses
|
|
18
|
-
from datetime import datetime
|
|
19
|
-
import json
|
|
20
|
-
import pathlib
|
|
21
|
-
import sys
|
|
22
|
-
import traceback
|
|
23
|
-
|
|
24
|
-
from dfindexeddb import errors
|
|
25
|
-
from dfindexeddb import version
|
|
26
|
-
from dfindexeddb.leveldb import descriptor
|
|
27
|
-
from dfindexeddb.leveldb import ldb
|
|
28
|
-
from dfindexeddb.leveldb import log
|
|
29
|
-
from dfindexeddb.indexeddb import chromium
|
|
30
|
-
from dfindexeddb.indexeddb import v8
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
_VALID_PRINTABLE_CHARACTERS = (
|
|
34
|
-
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' +
|
|
35
|
-
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~.')
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
class Encoder(json.JSONEncoder):
|
|
39
|
-
"""A JSON encoder class for dfindexeddb fields."""
|
|
40
|
-
def default(self, o):
|
|
41
|
-
if isinstance(o, bytes):
|
|
42
|
-
out = []
|
|
43
|
-
for x in o:
|
|
44
|
-
if chr(x) not in _VALID_PRINTABLE_CHARACTERS:
|
|
45
|
-
out.append(f'\\x{x:02X}')
|
|
46
|
-
else:
|
|
47
|
-
out.append(chr(x))
|
|
48
|
-
return ''.join(out)
|
|
49
|
-
if isinstance(o, datetime):
|
|
50
|
-
return o.isoformat()
|
|
51
|
-
if isinstance(o, v8.Undefined):
|
|
52
|
-
return "<undefined>"
|
|
53
|
-
if isinstance(o, v8.Null):
|
|
54
|
-
return "<null>"
|
|
55
|
-
if isinstance(o, set):
|
|
56
|
-
return list(o)
|
|
57
|
-
if isinstance(o, v8.RegExp):
|
|
58
|
-
return str(o)
|
|
59
|
-
return json.JSONEncoder.default(self, o)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
def _Output(structure, to_json=False):
|
|
63
|
-
"""Helper method to output parsed structure to stdout."""
|
|
64
|
-
if to_json:
|
|
65
|
-
structure_dict = dataclasses.asdict(structure)
|
|
66
|
-
print(json.dumps(structure_dict, indent=2, cls=Encoder))
|
|
67
|
-
else:
|
|
68
|
-
print(structure)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def IndexeddbCommand(args):
|
|
72
|
-
"""The CLI for processing a log/ldb file as indexeddb."""
|
|
73
|
-
if args.source.name.endswith('.log'):
|
|
74
|
-
records = list(
|
|
75
|
-
log.FileReader(args.source).GetKeyValueRecords())
|
|
76
|
-
elif args.source.name.endswith('.ldb'):
|
|
77
|
-
records = list(
|
|
78
|
-
ldb.FileReader(args.source).GetKeyValueRecords())
|
|
79
|
-
else:
|
|
80
|
-
print('Unsupported file type.', file=sys.stderr)
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
for record in records:
|
|
84
|
-
try:
|
|
85
|
-
record = chromium.IndexedDBRecord.FromLevelDBRecord(record)
|
|
86
|
-
except (errors.ParserError, errors.DecoderError) as err:
|
|
87
|
-
print(
|
|
88
|
-
(f'Error parsing blink value: {err} for {record.__class__.__name__} '
|
|
89
|
-
f'at offset {record.offset}'), file=sys.stderr)
|
|
90
|
-
print(f'Traceback: {traceback.format_exc()}', file=sys.stderr)
|
|
91
|
-
_Output(record, to_json=args.json)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def ManifestCommand(args):
|
|
95
|
-
"""The CLI for processing MANIFEST aka Descriptor files."""
|
|
96
|
-
manifest_file = descriptor.FileReader(args.source)
|
|
97
|
-
|
|
98
|
-
for version_edit in manifest_file.GetVersionEdits():
|
|
99
|
-
_Output(version_edit, to_json=args.json)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def LdbCommand(args):
|
|
103
|
-
"""The CLI for processing ldb files."""
|
|
104
|
-
ldb_file = ldb.FileReader(args.source)
|
|
105
|
-
|
|
106
|
-
if args.structure_type == 'blocks':
|
|
107
|
-
# Prints block information.
|
|
108
|
-
for block in ldb_file.GetBlocks():
|
|
109
|
-
_Output(block, to_json=args.json)
|
|
110
|
-
|
|
111
|
-
elif args.structure_type == 'records':
|
|
112
|
-
# Prints key value record information.
|
|
113
|
-
for record in ldb_file.GetKeyValueRecords():
|
|
114
|
-
_Output(record, to_json=args.json)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
def LogCommand(args):
|
|
118
|
-
"""The CLI for processing log files."""
|
|
119
|
-
log_file = log.FileReader(args.source)
|
|
120
|
-
|
|
121
|
-
if args.structure_type == 'blocks':
|
|
122
|
-
# Prints block information.
|
|
123
|
-
for block in log_file.GetBlocks():
|
|
124
|
-
_Output(block, to_json=args.json)
|
|
125
|
-
|
|
126
|
-
elif args.structure_type == 'physical_records':
|
|
127
|
-
# Prints log file physical record information.
|
|
128
|
-
for log_file_record in log_file.GetPhysicalRecords():
|
|
129
|
-
_Output(log_file_record, to_json=args.json)
|
|
130
|
-
|
|
131
|
-
elif args.structure_type == 'write_batches':
|
|
132
|
-
# Prints log file batch information.
|
|
133
|
-
for batch in log_file.GetWriteBatches():
|
|
134
|
-
_Output(batch, to_json=args.json)
|
|
135
|
-
|
|
136
|
-
elif args.structure_type in ('parsed_internal_key', 'records'):
|
|
137
|
-
# Prints key value record information.
|
|
138
|
-
for record in log_file.GetKeyValueRecords():
|
|
139
|
-
_Output(record, to_json=args.json)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def App():
|
|
143
|
-
"""The CLI app entrypoint."""
|
|
144
|
-
parser = argparse.ArgumentParser(
|
|
145
|
-
prog='dfindexeddb',
|
|
146
|
-
description='A cli tool for the dfindexeddb package',
|
|
147
|
-
epilog=f'Version {version.GetVersion()}')
|
|
148
|
-
|
|
149
|
-
parser.add_argument(
|
|
150
|
-
'-s', '--source', required=True, type=pathlib.Path,
|
|
151
|
-
help='The source leveldb file')
|
|
152
|
-
parser.add_argument('--json', action='store_true', help='Output as JSON')
|
|
153
|
-
subparsers = parser.add_subparsers(required=True)
|
|
154
|
-
|
|
155
|
-
parser_log = subparsers.add_parser('log')
|
|
156
|
-
parser_log.add_argument(
|
|
157
|
-
'structure_type', choices=[
|
|
158
|
-
'blocks',
|
|
159
|
-
'physical_records',
|
|
160
|
-
'write_batches',
|
|
161
|
-
'parsed_internal_key',
|
|
162
|
-
'records'])
|
|
163
|
-
parser_log.set_defaults(func=LogCommand)
|
|
164
|
-
|
|
165
|
-
parser_log = subparsers.add_parser('ldb')
|
|
166
|
-
parser_log.add_argument(
|
|
167
|
-
'structure_type', choices=[
|
|
168
|
-
'blocks',
|
|
169
|
-
'records'])
|
|
170
|
-
parser_log.set_defaults(func=LdbCommand)
|
|
171
|
-
|
|
172
|
-
parser_log = subparsers.add_parser('manifest')
|
|
173
|
-
parser_log.set_defaults(func=ManifestCommand)
|
|
174
|
-
|
|
175
|
-
parser_log = subparsers.add_parser('indexeddb')
|
|
176
|
-
parser_log.set_defaults(func=IndexeddbCommand)
|
|
177
|
-
|
|
178
|
-
args = parser.parse_args()
|
|
179
|
-
|
|
180
|
-
args.func(args)
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
dfindexeddb/__init__.py,sha256=KPYL9__l8od6_OyDfGRTgaJ6iy_fqIgZ-dS2S-e3Rac,599
|
|
2
|
-
dfindexeddb/cli.py,sha256=fm7iGA5k1VVIc4jT80w8yQ2kb6h9AucByikwNFNuG3A,5593
|
|
3
|
-
dfindexeddb/errors.py,sha256=PNpwyf_lrPc4TE77oAakX3mu5D_YcP3f80wq8Y1LkvY,749
|
|
4
|
-
dfindexeddb/utils.py,sha256=fp4NaJhJR1LI4THH3PPo_dGyuMkQ6sOtk-l3e9lIdLY,10349
|
|
5
|
-
dfindexeddb/version.py,sha256=KH2nfTUTTcPB19XDYtCGJUOAturiQSDckkQvGgYWdYg,750
|
|
6
|
-
dfindexeddb/indexeddb/__init__.py,sha256=kExXSVBCTKCD5BZJkdMfUMqGksH-DMJxP2_lI0gq-BE,575
|
|
7
|
-
dfindexeddb/indexeddb/blink.py,sha256=MblpYfv-ByG7n_fjYKu2EUhpfVJdUveoW4oSAg5T4tY,3534
|
|
8
|
-
dfindexeddb/indexeddb/chromium.py,sha256=6aePZ7quQzQgHi2KYtlmrjeWZyURGdUFYKIPH80cEAs,44696
|
|
9
|
-
dfindexeddb/indexeddb/definitions.py,sha256=yline3y3gmZx6s-dwjpPDNs5HO4zT6KZqPWQfEsHDoM,7413
|
|
10
|
-
dfindexeddb/indexeddb/v8.py,sha256=ldqpc9T1kG7BOdjnHjQ5hNO9OCXZ3_Zd6vRSpC-NrEA,21893
|
|
11
|
-
dfindexeddb/leveldb/__init__.py,sha256=KPYL9__l8od6_OyDfGRTgaJ6iy_fqIgZ-dS2S-e3Rac,599
|
|
12
|
-
dfindexeddb/leveldb/definitions.py,sha256=d34YBXNRJZklS-KLKOKiwf_ojxevQedYaoJoNGaeM5g,1109
|
|
13
|
-
dfindexeddb/leveldb/descriptor.py,sha256=tfJ0Smk4apUuVZIxEWDTPPjNaTqVtRndA1YsZdHlceI,10394
|
|
14
|
-
dfindexeddb/leveldb/ldb.py,sha256=dOZpzh9WHL3qwfTyIJFn6-OaApTNnqTHeJgXYwOM1-c,7931
|
|
15
|
-
dfindexeddb/leveldb/log.py,sha256=5m6OADTM7BP3AWbamlqAwTn_UGcG2UXZz1YpCq1o4Gk,8858
|
|
16
|
-
dfindexeddb-20240305.dist-info/AUTHORS,sha256=QbvjbAom57fpEkekkCVFUj0B9KUMGraR510aUMBC-PE,286
|
|
17
|
-
dfindexeddb-20240305.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
18
|
-
dfindexeddb-20240305.dist-info/METADATA,sha256=_iqPyDYZsvVd-ITp--C8yyfwB11gs_D1JIIKFDAezW4,15933
|
|
19
|
-
dfindexeddb-20240305.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
20
|
-
dfindexeddb-20240305.dist-info/entry_points.txt,sha256=UsfPLLhTiVAAtZ8Rq3ZR7JNFGMuHqJy-tugGWonQWtc,52
|
|
21
|
-
dfindexeddb-20240305.dist-info/top_level.txt,sha256=X9OTaub1c8S_JJ7g-f8JdkhhdiZ4x1j4eni1hdUCwE4,12
|
|
22
|
-
dfindexeddb-20240305.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|