Skip to content

Commit 9fbedb8

Browse files
committed
feat: become a gh extension
1 parent 82a370f commit 9fbedb8

File tree

9 files changed

+273
-246
lines changed

9 files changed

+273
-246
lines changed

.github/dependabot.yaml

-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "docker"
4-
directory: "/"
5-
schedule:
6-
interval: "daily"
7-
labels:
8-
- "dependencies"
93
- package-ecosystem: "github-actions"
104
directory: "/"
115
schedule:

.github/workflows/ci.yaml

+8-21
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,24 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Checkout repository
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v3
1313
- name: Setup Go
14-
uses: actions/setup-go@v2
14+
uses: actions/setup-go@v3
1515
with:
16-
go-version: '1.16'
17-
- name: Setup build cache
18-
uses: actions/cache@v2
19-
with:
20-
path: ~/go/pkg/mod
21-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
22-
restore-keys: ${{ runner.os }}-go-
16+
go-version: "1.19"
2317
- name: Build service
24-
run: make build
18+
run: go build
2519
lint:
2620
name: Lint
2721
runs-on: ubuntu-latest
2822
steps:
2923
- name: Checkout repository
30-
uses: actions/checkout@v2
24+
uses: actions/checkout@v3
3125
- name: Setup Go
32-
uses: actions/setup-go@v2
33-
with:
34-
go-version: '1.16'
35-
- name: Setup build cache
36-
uses: actions/cache@v2
26+
uses: actions/setup-go@v3
3727
with:
38-
path: ~/go/pkg/mod
39-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
40-
restore-keys: ${{ runner.os }}-go-
28+
go-version: "1.19"
4129
- name: Lint
42-
uses: golangci/golangci-lint-action@v2
30+
uses: golangci/golangci-lint-action@v3
4331
with:
4432
args: --enable dupl,gofmt,revive
45-
skip-go-installation: true

.github/workflows/release.yaml

+14-49
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,31 @@ on:
44
branches:
55
- main
66
jobs:
7-
release-please:
8-
name: Run Release Please
7+
release:
8+
name: Create release
99
runs-on: ubuntu-latest
1010
outputs:
11-
release-created: ${{ steps.release.outputs.release_created }}
12-
upload-url: ${{ steps.release.outputs.upload_url }}
11+
release_created: ${{ steps.release.outputs.release_created }}
1312
steps:
1413
- name: Checkout repository
15-
uses: actions/checkout@v2
14+
uses: actions/checkout@v3
1615
- name: Setup release please
17-
uses: google-github-actions/release-please-action@v2
1816
id: release
17+
uses: google-github-actions/release-please-action@v3
1918
with:
2019
token: ${{ secrets.GITHUB_TOKEN }}
2120
release-type: simple
22-
package-name: audit-org-keys
23-
build-publish:
24-
name: Build and publish assets
21+
package-name: gh-vanity
22+
upload_assets:
23+
name: Upload assets
2524
runs-on: ubuntu-latest
26-
needs: release-please
27-
if: needs.release-please.outputs.release-created
25+
needs: release
26+
if: needs.release.outputs.release_created == 'true'
2827
steps:
2928
- name: Checkout repository
30-
uses: actions/checkout@v2
31-
- name: Setup Go
32-
uses: actions/setup-go@v2
29+
uses: actions/checkout@v3
3330
with:
34-
go-version: '1.16'
35-
- name: Setup build cache
36-
uses: actions/cache@v2
31+
fetch-depth: 0
32+
- uses: cli/gh-extension-precompile@v1
3733
with:
38-
path: ~/go/pkg/mod
39-
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
40-
restore-keys: ${{ runner.os }}-go-
41-
- name: Build release assets
42-
run: make dist
43-
- name: Upload Windows asset
44-
uses: actions/upload-release-asset@v1
45-
env:
46-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47-
with:
48-
upload_url: ${{ needs.release-please.outputs.upload-url }}
49-
asset_path: ./audit-org-keys-windows-amd64.exe
50-
asset_name: audit-org-keys-windows-amd64.exe
51-
asset_content_type: application/octet-stream
52-
- name: Upload Linux asset
53-
uses: actions/upload-release-asset@v1
54-
env:
55-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56-
with:
57-
upload_url: ${{ needs.release-please.outputs.upload-url }}
58-
asset_path: ./audit-org-keys-linux-amd64
59-
asset_name: audit-org-keys-linux-amd64
60-
asset_content_type: application/octet-stream
61-
- name: Upload macOS asset
62-
uses: actions/upload-release-asset@v1
63-
env:
64-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65-
with:
66-
upload_url: ${{ needs.release-please.outputs.upload-url }}
67-
asset_path: ./audit-org-keys-darwin-amd64
68-
asset_name: audit-org-keys-darwin-amd64
69-
asset_content_type: application/octet-stream
34+
go_version: "1.19"

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.idea/
2-
bin/
2+
3+
audit-org-keys

Makefile

-41
This file was deleted.

README.md

+52-15
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,73 @@
1-
# audit-org-keys [![Release](https://img.shields.io/github/workflow/status/jef/audit-org-keys/Release?color=24292e&label=Release&logo=github&logoColor=white&style=flat-square)](https://github.com/jef/audit-org-keys/actions/workflows/release.yaml)
1+
# gh-audit-org-keys [![Release](https://github.com/jef/gh-audit-org-keys/actions/workflows/release.yaml/badge.svg)](https://github.com/jef/gh-vanity/actions/workflows/release.yaml)
22

33
The point of this project is to help demonstrate that users of GitHub could potentially fall victim to getting their private SSH key cracked. This based on the size and complexity of the key the user generates.
44

55
Programs like `ssh2john` from **John the Ripper** can best demonstrate how fast an SSH private key can be solved from a _not so_ complex algorithm with low key lengths (think RSA < 1024 bits).
66

77
## Installation
88

9-
`go get -u github.com/jef/audit-org-keys/cmd/audit_org_keys`
9+
1. Install the `gh` cli - see the [installation](https://github.com/cli/cli#installation)
1010

11-
Also available under [GitHub Releases](https://github.com/jef/audit-org-keys/releases) as an executable.
11+
_Installation requires a minimum version (2.0.0) of the GitHub CLI that supports extensions._
12+
13+
2. Install this extension:
14+
15+
```shell
16+
gh extension install jef/gh-audit-org-keys
17+
```
18+
19+
<details>
20+
<summary><strong>Manual Installation</strong></summary>
21+
22+
Requirements: `cli/cli` and `go`.
23+
24+
1. Clone the repository
25+
26+
```shell
27+
# git
28+
git clone git@github.com:jef/gh-audit-org-keys.git
29+
30+
# GitHub CLI
31+
gh repo clone jef/gh-audit-org-keys
32+
```
33+
34+
2. `cd` into it
35+
36+
```shell
37+
cd gh-audit-org-keys
38+
```
39+
40+
3. Build it
41+
42+
```shell
43+
make build
44+
```
45+
46+
4. Install it locally
47+
48+
```shell
49+
gh extension install .
50+
```
51+
</details>
1252

1353
## Usage
1454

15-
It is required that you use a GitHub Personal Access Token (PAT). You can generate one [here](https://github.com/settings/tokens/new). The required scopes are `['read:org']`. Set your PAT to environment variable `GITHUB_TOKEN`. If `GITHUB_TOKEN` isn't set, then you may not get the results you expect.
55+
To run:
1656

1757
```shell
18-
Usage of audit_org_keys:
19-
-o, --organization string [required] GitHub organization provided to inspect
20-
-s, --show-users all display users with filter (all, `with`, `without`, `multiple`)
58+
gh audit-org-keys
2159
```
2260

23-
### Examples
61+
To upgrade:
2462

25-
- `audit-org-keys --organization="actions"`
26-
- `audit-org-keys --organization="actions" --show-users="all"`
63+
```sh
64+
gh extension upgrade audit-org-keys
65+
```
2766

28-
## Releases
67+
### Examples
2968

30-
| Tag | Description |
31-
|:---:|---|
32-
| `latest` | Built against tagged releases; stable
33-
| `nightly` | Built against HEAD; generally considered stable, but could have problems |
69+
- `gh audit-org-keys --organization="actions"`
70+
- `gh audit-org-keys --organization="actions" --show-users="all"`
3471

3572
### Acknowledgments
3673

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/jef/audit-org-keys
33
go 1.16
44

55
require (
6+
github.com/cli/go-gh v0.1.1
67
github.com/olekukonko/tablewriter v0.0.5
7-
github.com/rs/zerolog v1.23.0
8-
github.com/spf13/pflag v1.0.5
8+
github.com/spf13/cobra v1.5.0
99
)

0 commit comments

Comments
 (0)