RESTful数据存储。一种简单的方式存储大量平均大小的文件。
项目描述
为什么选择reststore?
reststore是我和我的朋友们用来共享和存储恶意软件样本的一种简单方式。我们追求的是大量文件。使用reststore获得的优点在于其能够根据数据插入的时间顺序返回哈希切片。它实现了一种简单而强大的获取、缓存和存储模式,使得处理大量数据变得轻而易举。
什么是reststore?
一种方便存储大量数据的方法。
能够本地访问数据或通过托管reststore webapp的服务器访问数据。
将多个webapp服务器连接起来,直到它们达到单一的权威reststore webapp。
reststore中有什么?
一个名为Files的简单接口,它提供了对reststore功能的完全控制和访问。
灵活的配置以支持更复杂的reststore部署。
一组命令行操作,用于获取、设置和列出数据。
一个RESTful webapi,以便以客户端无关的方式访问数据。
由github.com提供项目托管。
安装
只需运行以下命令
> python setup.py install
或PyPi
> pip install reststore
入门
使用reststore进行编码
Files和FilesClient是两个用于从存储中访问数据的类。
本地会话
$ ipython In [1]: import reststore In [2]: files = reststore.Files() In [3]: files. files.get files.hash_len files.put files.hash_func files.index files.select In [3]: files.put("test data") Out[3]: 'eb733a00c0c9d336e65691a37ab54293' In [4]: files.put("test with some more data") Out[4]: 'a99fb3880c8ac126b3cf6163aa965305' In [5]: files.put("test with some more data... and more") Out[5]: 'e93a9d514c57f96d158864754f1ca330' In [6]: files['e93a9d514c57f96d158864754f1ca330'] Out[6]: u'/tmp/files/00195/00065/3' In [7]: files.select(2,-1) Out[7]: ['e93a9d514c57f96d158864754f1ca330'] In [8]: files.select(1,-1) Out[8]: [a99fb3880c8ac126b3cf6163aa965305', e93a9d514c57f96d158864754f1ca330'] In [9]: for hexdigest in files: ...: print hexdigest ...: eb733a00c0c9d336e65691a37ab54293 a99fb3880c8ac126b3cf6163aa965305 e93a9d514c57f96d158864754f1ca330
上面的代码可以使用FilesClient类工作,它将与reststore webapp服务器无缝接口。
配置reststore
reststore具有一个非常简单的配置系统。配置的顺序如下:
reststore.config中的默认设置
/etc/reststore.yaml
~/reststore.yaml
环境变量 <- 每个配置值都以RESTSTORE_[INTERFACE]_[NAME]=Value的形式编写
默认配置示例
$ cat ~/.reststore.yaml client: {uri: 'http://127.0.0.1:8586/'} files: {assert_data_ok: false, hash_function: md5, name: files, root: /tmp, tune_size: 100000000} webapp: {debug: false, host: 127.0.0.1, port: 8586, proxy_requests: false, quiet: false, server: wsgiref}
命令行界面
探索命令行界面应揭示reststore的核心功能
$ reststorei -h NAME reststore - control over the reststore SYNOPSIS reststore [COMMAND] Commands: get [FILE-OPTIONS] [HEXDIGEST] Return a filepath to the data behind hexdigest. arguments HEXDIGEST of the data to lookup in reststore. read [FILE-OPTIONS] [HEXDIGEST] > stdout Attempt to retrieve a file and write it out to stdout. A check is made in the local reststore first, if the file is in available, an attempt to read the file from the web reststore is made. arguments HEXDIGEST of the data to lookup in reststore. put [FILE-OPTIONS] FILEPATH(s) Put a file into the reststore. arguments Path(s) of files to be loaded into the reststore. unzip [OPTIONS FILE-OPTIONS] ZIPFILE Extra files from a zipfile straight into the reststore. arguments A path to the zip file to extract into the reststore. options --password= Define a password for unzipping the zip file. --flush=1000 Number of files to read into memory before flushing through to the reststore. list [OPTIONS FILE-OPTIONS] list out hexdigests found in the reststore. options --select=[A:B] List all of the hashes between A:B. Hashes are stored chronologically. 0 is the first file inserted, -1 is the last file inserted. i.e. select the last 1000 hexdigests -1001:-1 len [FILE-OPTIONS] print out the number of files stored in the reststore. web [OPTIONS FILE-OPTIONS] [[HOST:][PORT]] Run the RESTful web app. arguments HOST:PORT defaults to 127.0.0.1:8586 options --server=wsgiref Choose the server adapter to use. --debug=False Run in debug mode. --quiet=False Run in quite mode. --proxy_requests=False If True, this web app will proxy requests through to the authoritative server defined by the client uri. File options: --name=files Set the default reststore name (i.e. domain or realm) --hash_function=md5 Set the hash function to be used --tune_size=100000000 Set the approximate size the reststore may grow up to. --root=/tmp Set the root for the reststore. --assert_data_ok=False Do extra checks when reading and writing data. --weboff This flag forces access to a local repository only. --uri=http://170.0.229.223:8586/ The uri to the upstream reststore web server.
问题
变更日志
版本 0.0.1 (2013年8月6日)
解压插入和批量put
版本 0.0.0 (2013年5月6日)
项目详情
reststore-0.0.2.tar.gz的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | fd1125b440152ed86c8b5f1a4647a829ec4864df902cfd476bdd54c90d29d106 |
|
MD5 | 329b53dc6ee0268d07c21f55bcecc3f6 |
|
BLAKE2b-256 | 95d830cf607a02554e2f51edc36078561275decc00687032d41389bcd0ad0350 |