BlockchainCommons / BlockchainCommons/Secure-Development-Setup-macOS

Getting GPG info from `gh` & GitHub

Đang mở
#9 4 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Shell
Star
8
Fork
5
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

@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"
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với shell snippet được cung cấp, tập trung vào gh auth status, ~/.config/gh/hosts.yml, endpoint .gpg của GitHub và lệnh lấy dấu vân tay GPG. Issue không nêu tên tệp repository hoặc bài kiểm thử; khi hoàn tất, việc lấy người dùng GitHub dự kiến và dấu vân tay GPG phải hoạt động trong luồng thiết lập của dự án.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
github, shell
Lĩnh vực
cli, security, tooling
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.