BlockchainCommons / BlockchainCommons/Secure-Development-Setup-macOS
Getting GPG info from `gh` & GitHub
- 主要語言
- Shell
- 星號
- 8
- 分支
- 5
- PR 合併指標
- 30 天內沒有已合併 PR
描述
@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"
```
貢獻指南
研究方向
從提供的 shell 片段開始,重點關注 gh auth status、~/.config/gh/hosts.yml、GitHub 的 .gpg endpoint,以及取得 GPG 指紋的命令。該 issue 沒有指定 repository 檔案或測試;完成後,應能在專案的設定流程中正常取得預期的 GitHub 使用者和 GPG 指紋。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- github, shell
- 領域
- cli, security, tooling
- Issue 類型
- 功能
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100