Ban unarmored GPG keys
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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?
- Lingua principale
- Python
- Stelle
- 6.7k
- Fork
- 800
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pre-commit/pre-commit-hooks
-
Immutable Releases Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 45/100
pre-commit/pre-commit-hooks#1218 · 4 commenti · 2 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
pre-commit/pre-commit-hooks#1020 · 8 commenti · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
pre-commit/pre-commit-hooks#780 · 5 commenti · 2 reazioni ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 48/100
pre-commit/pre-commit-hooks#749 · 1 reazione ·
-
enhancement good-first-issue
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
pre-commit/pre-commit-hooks#612 · 13 commenti ·
Tutte le issue di pre-commit/pre-commit-hooks
Issue simili
-
link-check link-check:sphinx-theme
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
OpenHands/extensions#626 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
CSCfi/sd-search-api#39 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100