radareorg / sdb

Simple and fast string based key-value database with support for arrays and json
https://www.radare.org/
MIT License
217 stars 62 forks source link

Support plaintext .sdb files #214

Closed trufae closed 4 years ago

trufae commented 4 years ago

Identify when the .sdb file is k=v in plaintext instead of a disk hashtable in cdb format

This format should be defined somehow in the Sdb instance and saved in the same format when dumping.

thestr4ng3r commented 4 years ago

Requirements for the text format:

Here is my proposal for a concrete format since I am quite sure the current text k=v is completely broken (# stuff are just comments for explaining but should maybe not be part of the format):

some_key=some_val                             # a record in the root namespace
something\nwith\nnewlines=val\nwith\nnewlines # newlines separate different records, so must be escaped
key\=with\=equals=val=with\=quals             # = must be escaped in the key, but in the value it's optional
key\\with\\backslash=val\\with\\backslash

# completely empty lines are ignored

/subns                                        # lines beginning with '/' and no '=' enter a new namespace (path is always absolute to the root)
key_in_subns=val_in_subns

/subns/deeper                                 # deeper nesting (again, path is absolute)
deepest_key=deepest_val

/weird\=ns\\\nwtf                             # namespace names use the same escaping as keys ...
\/justa_key=henlo                             # except that keys must always escape the first char if it is a slash

/                                             # return to the root namespace (do we want to allow multiple places for a single ns?)
key_in=root