自动敏感数据清理和恢复程序。
lucido的Python项目详细描述
卢西多
曾经想向开源社区发布一个项目,如果不是因为每次提交时都要去掉敏感数据(如api密钥)的麻烦的话?
或者你不得不重写你的版本控制历史,因为你不小心犯了一些其他人不该看到的错误?
lucido(读作loo chee面团)是一个简单的脚本,旨在使这些问题成为过去。它自己可以轻松地剥离和恢复敏感数据。在git存储库中,lucido阻止您提交敏感数据,并在任何合并后自动为您恢复它。
安装
从命令行:
pip install lucido
如果lucido已经安装,您可以使用以下命令升级到最新版本:
pip install --upgrade lucido
您还需要安装perl [1]。对大多数人来说,这不应该是个问题。
开始
您需要创建一个名为luci.yml的文件。(如果在git存储库中执行此操作,请确保luci.yml位于存储库的根目录中。)它至少应包含一个sensitive键,该键将获取lucido应清除的值列表。它还可以包含一个exclude键,该键可以获取不应清除的目录列表。
下面是一个示例:
exclude: - .git sensitive: - qqhPKzffeZu0 - ALpeJmcMs7TG - z-1JWjRdbXzN - 3r_h1q_1TEs3
请注意,您还可以使用正则表达式:
exclude: - .git sensitive: - \w{12}
使用量
如果计划在git存储库中使用lucido,只需运行以下命令:
luci -i
这将为您创建git钩子,以便自动完成清理/恢复。(从技术上讲,清理不是自动的,因为预提交挂钩不应该更改要提交的文件的内容。但是,如果发现敏感数据,提交将失败,并且您将收到一条关于如何清除数据的有用消息。)
如果您没有在git存储库中使用lucido,则需要运行以下命令:
# check for sensitive data luci -c # if present, scrub the sensitive data luci -s # at a later time, restore the sensitive data luci -r
选项
-c, --check: Checks for sensitive data in the current working directory. -i, --init: Creates git hooks and adds luci.yml to .gitignore if run within a git repository. -s, --scrub: Scrubs sensitive data in the current working directory. -r, --restore: Restores sensitive data in the current working directory.
Git钩子
在git存储库中初始化时,lucido会添加以下git钩子:
- pre-commit:提交之前,lucido将检查存储库中的敏感数据。如果存在敏感数据,则不会创建提交。
- post-commit,post-merge:提交或合并新的更改后,lucido将还原存储库中的敏感数据,以便您的代码按预期工作。
版本信息
目前的稳定版本是v0.3,最后一次更新是在2012年11月3日。
贡献
请随意在项目的bug tracker上提交任何问题。
或者,如果你有一个更慈悲的心情,考虑留下一个Gittip。
[1] | lucido makes use of Perl in order to perform sed-like replacements in files. The reason sed itself isn’t used is because it doesn’t support literal (non-regex) search/replace, and juggling the escape characters is a circus feat I don’t have the patience to perform. |
更改日志
v0.3
- 添加Python2.7兼容性
v0.2
- 防止外壳注入的可能性
- 添加对正则表达式的支持
v0.1
- 初始版本