BlockchainCommons / BlockchainCommons/Secure-Development-Setup-macOS

Getting GPG info from `gh` & GitHub

Ouverte
#9 4 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Shell
Étoiles
8
Forks
5
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

@namcios,

You might find these code snippets useful:

```
#!/bin/bash

if [[ $(command -v gh) == "" ]]; then

printf "No \`gh\` Installed!\n"
brew install gh
printf "Installed \`gh\`.\n"
fi

if !(gh auth status --hostname "github.com" > /dev/null 2>&1); then
printf "You are not logged into \`gh\`!\n"
printf "Authenticate gh with GitHub using the Web and set ssh as default.\n"
gh auth login
printf "Logged into GitHub.\n"
fi

# Get the GitHub User Name from GitHub's `gh` cli config files
My_GitHub_User=$(cat <~/.config/gh/hosts.yml | grep -A0 user: | cut -d: -f2 | tr -d ' "')

printf "My_GitHub_User:\t$My_GitHub_User\t✅\n"

## Setup gnupg

## install gnupg if it is not already instealled
if [[ $(command -v gpg) == "" ]]; then
printf "No GPG Installed!\n"
brew install gpg2 pinentry-mac
printf "Installing gpg & pinentry-mac\n"
fi

My_GPG_Key=$(curl https://github.com/$My_GitHub_User.gpg 2>/dev/null)
if [ -z "$My_GPG_Key" ] ; then
script_exit "ERROR: Unable to find $My_GPG_Key from https://github.com/$My_GitHub_User.gpg!\n" 1
else
printf "My_GPG_Key:\tRETREIVED\t✅\n"
fi

export GPG_KEY=$My_GPG_Key

## Get GPG Fingerprint from $My_GPG_Key
# For instance https://github.com/ChristopherA.gpg
# $My_GPG_Key would equal "FDFE14A54ECB30FC5D2274EFF8D36C91357405ED"

My_GPG_KEY_Fingerprint=`echo $My_GPG_Key 2>/dev/null | gpg --with-colons --import-options show-only --import --fingerprint 2>/dev/null | awk -F: '$1 == "fpr" {print $10}' | head -1`

printf "My_GPG_KEY_Fingerprint:\t$My_GPG_Key_Fingerprint\t✅\n"
```

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par l'extrait de shell fourni, en vous concentrant sur gh auth status, ~/.config/gh/hosts.yml, l'endpoint .gpg de GitHub et la commande de récupération de l'empreinte GPG. L'issue ne nomme aucun fichier du dépôt ni aucun test ; une fois terminé, la récupération de l'utilisateur GitHub visé et de l'empreinte GPG devrait fonctionner dans le flux de configuration du projet.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
github, shell
Domaine
cli, security, tooling
Type d'issue
Fonctionnalité
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
25/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.