Ban unarmored GPG keys
还没有人认领这个 Issue。
评估
调研方向
Start by reading issue #329 and the existing ASCII-armored GPG private-key ban. Compare the proposed file, python-magic, and self-implemented MIME matching approaches, then define a portable detection behavior and verify that unarmored private keys are rejected without incorrectly banning ordinary binary data.
由索引模型根据 Issue 内容生成。
描述
In #329 we added a ban for ASCII-armored GPG private keys. But as far as I can tell we don't have a method for detecting un-armored private keys, since they resemble unstructured binary data.
$ gpg --export-secret-keys > secrets
$ file -I secrets
secrets: application/octet-stream; charset=binary
However, that doesn't mean they can't be identified (evidently):
$ file secrets
secrets: PGP Secret Key - 4096b created on Sun Nov 17 19:37:04 2013 - RSA (Encrypt or Sign) e=65537 hashed AES with 128-bit key Salted&Iterated S2K SHA-11
It looks like the mime-type for PGP keys is defined here: https://tools.ietf.org/html/rfc3156
This leads to a fork in the road for implementation:
We could make a subprocess call to file.
I don't like this for portability reasons. We don't know that file exists and behaves consistently everywhere pre-commit will be deployed.
We could use the magic library.
This works:
$ python3
Python 3.7.1 (default, Nov 6 2018, 18:45:35)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
>>> mime = magic.Magic()
>>> mime.from_file('secrets')
'PGP\\011Secret Key - 4096b created on Sun Nov 17 19:37:04 2013 - RSA (Encrypt or Sign) e=65537 hashed AES with 128-bit key Salted&Iterated S2K SHA-1'
But it adds a dependency on a non-standard library: python-magic.
We could try to emulate the mimetype matching ourselves.
Reinvents a wheel and the consequences of getting it wrong when users trust us to get it right could be bad.
What do you think?
- 主要语言
- Python
- 星标
- 6.7k
- 派生
- 800
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pre-commit/pre-commit-hooks 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 45/100
pre-commit/pre-commit-hooks#1218 · 4 条评论 · 2 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
pre-commit/pre-commit-hooks#1020 · 8 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
pre-commit/pre-commit-hooks#780 · 5 条评论 · 2 个 reaction ·
-
难度 3/5 1-2 天 新手友好度 48/100
pre-commit/pre-commit-hooks#749 · 1 个 reaction ·
-
enhancement good-first-issue
难度 3/5 1-2 天 新手友好度 55/100
pre-commit/pre-commit-hooks#612 · 13 条评论 ·
查看 pre-commit/pre-commit-hooks 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
bug
难度 2/5 1-3 小时 新手友好度 86/100
zostera/django-bootstrap4#894 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
use-agent-os/agent-os#3276 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#117848 ·