secret_hub 0.1.3 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -79
- data/bin/secrethub +3 -0
- data/lib/secret_hub/cli.rb +6 -7
- data/lib/secret_hub/commands/bulk.rb +24 -13
- data/lib/secret_hub/commands/org.rb +62 -0
- data/lib/secret_hub/commands/repo.rb +61 -0
- data/lib/secret_hub/config.rb +1 -1
- data/lib/secret_hub/exceptions.rb +1 -0
- data/lib/secret_hub/github_client.rb +33 -5
- data/lib/secret_hub/version.rb +1 -1
- metadata +5 -6
- data/lib/secret_hub/commands/delete.rb +0 -23
- data/lib/secret_hub/commands/list.rb +0 -22
- data/lib/secret_hub/commands/save.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55c57ad86eb27ea766d06923f3231e513dcb37da3050c6d1ac22de4831796140
|
4
|
+
data.tar.gz: d653818ddfd5967f66761ad76512a027c0b7e1942c72a3f0b3e91ce4c99a7bc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f7f20c2ac2b71264a73a33fae3436e22968083f3bb00855a5f3f74c0a0e528c80ac6b2d0d9d2a2ab374a19c2345212e1c79bed7601a3244fd8f08c4f981164d
|
7
|
+
data.tar.gz: 8e4b87a3229d977c6c61c5629481517e4cdc945825e0e00b8343f629ab1d4811c6ab1958c6aaedc5258bcd75c9f75b4cde95fbb3cf141b427e7fa9f96f629b3a
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
SecretHub - GitHub Secrets CLI
|
2
|
-
==================================================
|
1
|
+
# SecretHub - GitHub Secrets CLI
|
3
2
|
|
4
3
|
[![Gem Version](https://badge.fury.io/rb/secret_hub.svg)](https://badge.fury.io/rb/secret_hub)
|
5
4
|
[![Build Status](https://github.com/DannyBen/secret_hub/workflows/Test/badge.svg)](https://github.com/DannyBen/secret_hub/actions?query=workflow%3ATest)
|
@@ -8,20 +7,25 @@ SecretHub - GitHub Secrets CLI
|
|
8
7
|
---
|
9
8
|
|
10
9
|
SecretHub lets you easily manage your GitHub secrets from the command line
|
11
|
-
with support for bulk operations.
|
10
|
+
with support for bulk operations and organization secrets.
|
12
11
|
|
13
12
|
---
|
14
13
|
|
15
|
-
Installation
|
16
|
-
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
With Ruby:
|
17
17
|
|
18
18
|
```shell
|
19
19
|
$ gem install secret_hub
|
20
20
|
```
|
21
21
|
|
22
|
+
Or with Docker:
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
```shell
|
25
|
+
$ alias secrethub='docker run --rm -it -e GITHUB_ACCESS_TOKEN -v "$PWD:/app" dannyben/secrethub'
|
26
|
+
```
|
27
|
+
|
28
|
+
## Prerequisites
|
25
29
|
|
26
30
|
SecretHub is a wrapper around the [GitHub Secrets API][secrets-api]. To use
|
27
31
|
it, you need to set up your environment with a
|
@@ -32,50 +36,57 @@ it, you need to set up your environment with a
|
|
32
36
|
$ export GITHUB_ACCESS_TOKEN=<your access token>
|
33
37
|
```
|
34
38
|
|
39
|
+
Give your token the `repo` scope, and for organization secrets, the `admin:org` scope.
|
35
40
|
|
36
|
-
Usage
|
37
|
-
--------------------------------------------------
|
38
|
-
|
39
|
-
SecretHub has two families of commands:
|
41
|
+
## Usage
|
40
42
|
|
41
|
-
|
42
|
-
2. Commands that operate on multiple repositories, and multiple secrets.
|
43
|
+
SecretHub has three families of commands:
|
43
44
|
|
44
|
-
|
45
|
+
1. `secrethub repo` - manage repository secrets.
|
46
|
+
2. `secrethub org` - manage organization secrets.
|
47
|
+
3. `secrethub bulk` - manage multiple secrets in multiple repositories using a config file.
|
45
48
|
|
46
49
|
```shell
|
47
|
-
$ secrethub
|
48
|
-
|
50
|
+
$ secrethub
|
51
|
+
GitHub Secret Manager
|
49
52
|
|
50
|
-
|
51
|
-
|
53
|
+
Commands:
|
54
|
+
repo Manage repository secrets
|
55
|
+
org Manage organization secrets
|
56
|
+
bulk Manage multiple secrets in multiple repositories
|
52
57
|
|
53
|
-
|
58
|
+
Run secrethub COMMAND --help for command specific help
|
54
59
|
|
55
|
-
```shell
|
56
|
-
# secrethub list REPO
|
57
|
-
$ secrethub list you/your-repo
|
58
|
-
```
|
59
60
|
|
60
|
-
|
61
|
+
$ secrethub repo
|
62
|
+
Usage:
|
63
|
+
secrethub repo list REPO
|
64
|
+
secrethub repo save REPO KEY [VALUE]
|
65
|
+
secrethub repo delete REPO KEY
|
66
|
+
secrethub repo (-h|--help)
|
61
67
|
|
62
|
-
```shell
|
63
|
-
# secrethub save REPO KEY VALUE
|
64
|
-
$ secrethub list you/your-repo SECRET "there is no spoon"
|
65
|
-
```
|
66
68
|
|
67
|
-
|
69
|
+
$ secrethub org
|
70
|
+
Usage:
|
71
|
+
secrethub org list ORG
|
72
|
+
secrethub org save ORG KEY [VALUE]
|
73
|
+
secrethub org delete ORG KEY
|
74
|
+
secrethub org (-h|--help)
|
68
75
|
|
69
|
-
```shell
|
70
|
-
# secrethub delete REPO KEY
|
71
|
-
$ secrethub list you/your-repo SECRET
|
72
|
-
```
|
73
76
|
|
77
|
+
$ secrethub bulk
|
78
|
+
Usage:
|
79
|
+
secrethub bulk init [CONFIG]
|
80
|
+
secrethub bulk show [CONFIG --visible]
|
81
|
+
secrethub bulk list [CONFIG]
|
82
|
+
secrethub bulk save [CONFIG --clean --dry --only REPO]
|
83
|
+
secrethub bulk clean [CONFIG --dry]
|
84
|
+
secrethub bulk (-h|--help)
|
85
|
+
```
|
74
86
|
|
75
|
-
Bulk operations
|
76
|
-
--------------------------------------------------
|
87
|
+
## Bulk operations
|
77
88
|
|
78
|
-
All the bulk operations
|
89
|
+
All the bulk operations use a simple YAML configuration file.
|
79
90
|
The configuration file includes a list of GitHub repositories, each with a
|
80
91
|
list of its secrets.
|
81
92
|
|
@@ -127,7 +138,7 @@ docker: &docker
|
|
127
138
|
DOCKER_USER:
|
128
139
|
DOCKER_PASSWORD:
|
129
140
|
|
130
|
-
user/
|
141
|
+
user/repo:
|
131
142
|
<<: *docker
|
132
143
|
SECRET:
|
133
144
|
PASSWORD: p4ssw0rd
|
@@ -136,48 +147,7 @@ user/another-repo:
|
|
136
147
|
Note that YAML anchors only work with the hash syntax.
|
137
148
|
|
138
149
|
|
139
|
-
|
140
|
-
|
141
|
-
```shell
|
142
|
-
# secrethub bulk init [CONFIG]
|
143
|
-
$ secrethub bulk init mysecrets.yml
|
144
|
-
```
|
145
|
-
|
146
|
-
### Show the configuration file and its secrets
|
147
|
-
|
148
|
-
```shell
|
149
|
-
# secrethub bulk show [CONFIG --visible]
|
150
|
-
$ secrethub bulk show mysecrets.yml
|
151
|
-
```
|
152
|
-
|
153
|
-
### Show all secrets stored on GitHub in all repositories
|
154
|
-
|
155
|
-
```shell
|
156
|
-
# secrethub bulk list [CONFIG]
|
157
|
-
$ secrethub bulk list mysecrets.yml
|
158
|
-
```
|
159
|
-
|
160
|
-
### Save multiple secrets to multiple repositories
|
161
|
-
|
162
|
-
```shell
|
163
|
-
# secrethub bulk save [CONFIG --clean]
|
164
|
-
$ secrethub bulk save mysecrets.yml --clean
|
165
|
-
```
|
166
|
-
|
167
|
-
Using the `--clean` flag, you can ensure that the repositories do not have
|
168
|
-
any secrets that you are unaware of. This flag will delete any secret that is
|
169
|
-
not specified in your config file.
|
170
|
-
|
171
|
-
### Delete secrets from multiple repositories unless they are specified in the config file
|
172
|
-
|
173
|
-
```shell
|
174
|
-
# secrethub bulk clean [CONFIG]
|
175
|
-
$ secrethub bulk clean mysecrets.yml
|
176
|
-
```
|
177
|
-
|
178
|
-
|
179
|
-
Contributing / Support
|
180
|
-
--------------------------------------------------
|
150
|
+
## Contributing / Support
|
181
151
|
|
182
152
|
If you experience any issue, have a question or a suggestion, or if you wish
|
183
153
|
to contribute, feel free to [open an issue][issues].
|
data/bin/secrethub
CHANGED
data/lib/secret_hub/cli.rb
CHANGED
@@ -1,19 +1,18 @@
|
|
1
1
|
require 'mister_bin'
|
2
2
|
require 'secret_hub/commands/base'
|
3
|
-
require 'secret_hub/commands/
|
4
|
-
require 'secret_hub/commands/save'
|
5
|
-
require 'secret_hub/commands/delete'
|
3
|
+
require 'secret_hub/commands/repo'
|
6
4
|
require 'secret_hub/commands/bulk'
|
5
|
+
require 'secret_hub/commands/org'
|
7
6
|
|
8
7
|
module SecretHub
|
9
8
|
class CLI
|
10
9
|
def self.router
|
11
10
|
router = MisterBin::Runner.new version: VERSION,
|
12
|
-
header: "GitHub Secret Manager"
|
11
|
+
header: "GitHub Secret Manager",
|
12
|
+
footer: "Run !txtpur!secrethub COMMAND --help!txtrst! for command specific help"
|
13
13
|
|
14
|
-
router.route '
|
15
|
-
router.route '
|
16
|
-
router.route 'delete', to: Commands::Delete
|
14
|
+
router.route 'repo', to: Commands::Repo
|
15
|
+
router.route 'org', to: Commands::Org
|
17
16
|
router.route 'bulk', to: Commands::Bulk
|
18
17
|
|
19
18
|
router
|
@@ -6,13 +6,13 @@ module SecretHub
|
|
6
6
|
class Bulk < Base
|
7
7
|
using StringObfuscation
|
8
8
|
|
9
|
-
summary "
|
9
|
+
summary "Manage multiple secrets in multiple repositories"
|
10
10
|
|
11
11
|
usage "secrethub bulk init [CONFIG]"
|
12
12
|
usage "secrethub bulk show [CONFIG --visible]"
|
13
13
|
usage "secrethub bulk list [CONFIG]"
|
14
|
-
usage "secrethub bulk save [CONFIG --clean]"
|
15
|
-
usage "secrethub bulk clean [CONFIG]"
|
14
|
+
usage "secrethub bulk save [CONFIG --clean --dry --only REPO]"
|
15
|
+
usage "secrethub bulk clean [CONFIG --dry]"
|
16
16
|
usage "secrethub bulk (-h|--help)"
|
17
17
|
|
18
18
|
command "init", "Create a sample configuration file in the current directory"
|
@@ -23,6 +23,8 @@ module SecretHub
|
|
23
23
|
|
24
24
|
option "-c, --clean", "Also delete any other secret not defined in the configuration file"
|
25
25
|
option "-v, --visible", "Also show secret values"
|
26
|
+
option "-d, --dry", "Dry run"
|
27
|
+
option "-o, --only REPO", "Save all secrets to a single repository from the configuration file"
|
26
28
|
|
27
29
|
param "CONFIG", "Path to the configuration file [default: secrethub.yml]"
|
28
30
|
|
@@ -30,8 +32,9 @@ module SecretHub
|
|
30
32
|
example "secrethub bulk show --visible"
|
31
33
|
example "secrethub bulk clean"
|
32
34
|
example "secrethub bulk list mysecrets.yml"
|
33
|
-
example "secrethub bulk save mysecrets.yml"
|
35
|
+
example "secrethub bulk save mysecrets.yml --dry"
|
34
36
|
example "secrethub bulk save --clean"
|
37
|
+
example "secrethub bulk save --only me/my-important-repo"
|
35
38
|
|
36
39
|
def init_command
|
37
40
|
raise SecretHubError, "File #{config_file} already exists" if File.exist? config_file
|
@@ -58,45 +61,53 @@ module SecretHub
|
|
58
61
|
end
|
59
62
|
|
60
63
|
def save_command
|
61
|
-
|
64
|
+
dry = args['--dry']
|
65
|
+
only = args['--only']
|
62
66
|
skipped = 0
|
63
67
|
|
64
68
|
config.each do |repo, secrets|
|
69
|
+
next if only and repo != only
|
65
70
|
say "!txtblu!#{repo}"
|
66
|
-
skipped += update_repo repo, secrets
|
67
|
-
clean_repo repo, secrets.keys if clean
|
71
|
+
skipped += update_repo repo, secrets, dry
|
72
|
+
clean_repo repo, secrets.keys, dry if args['--clean']
|
68
73
|
end
|
69
74
|
|
70
|
-
|
75
|
+
puts "\n" if skipped > 0 or dry
|
76
|
+
say "Skipped #{skipped} missing secrets" if skipped > 0
|
77
|
+
say "Dry run, nothing happened" if dry
|
71
78
|
end
|
72
79
|
|
73
80
|
def clean_command
|
81
|
+
dry = args['--dry']
|
82
|
+
|
74
83
|
config.each do |repo, secrets|
|
75
84
|
say "!txtblu!#{repo}"
|
76
|
-
clean_repo repo, secrets.keys
|
85
|
+
clean_repo repo, secrets.keys, dry
|
77
86
|
end
|
87
|
+
|
88
|
+
say "\nDry run, nothing happened" if dry
|
78
89
|
end
|
79
90
|
|
80
91
|
private
|
81
92
|
|
82
|
-
def clean_repo(repo, keys)
|
93
|
+
def clean_repo(repo, keys, dry)
|
83
94
|
repo_keys = github.secrets repo
|
84
95
|
delete_candidates = repo_keys - keys
|
85
96
|
|
86
97
|
delete_candidates.each do |key|
|
87
98
|
say "delete !txtpur!#{key} "
|
88
|
-
|
99
|
+
github.delete_secret repo, key unless dry
|
89
100
|
say "!txtgrn!OK"
|
90
101
|
end
|
91
102
|
end
|
92
103
|
|
93
|
-
def update_repo(repo, secrets)
|
104
|
+
def update_repo(repo, secrets, dry)
|
94
105
|
skipped = 0
|
95
106
|
|
96
107
|
secrets.each do |key, value|
|
97
108
|
say "save !txtpur!#{key} "
|
98
109
|
if value
|
99
|
-
github.put_secret repo, key, value
|
110
|
+
github.put_secret repo, key, value unless dry
|
100
111
|
say "!txtgrn!OK"
|
101
112
|
else
|
102
113
|
say "!txtred!MISSING"
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module SecretHub
|
2
|
+
module Commands
|
3
|
+
class Org < Base
|
4
|
+
summary "Manage organization secrets"
|
5
|
+
|
6
|
+
usage "secrethub org list ORG"
|
7
|
+
usage "secrethub org save ORG KEY [VALUE]"
|
8
|
+
usage "secrethub org delete ORG KEY"
|
9
|
+
usage "secrethub org (-h|--help)"
|
10
|
+
|
11
|
+
command "list", "Show all organization secrets"
|
12
|
+
command "save", "Create or update an organization secret (with private repositories visibility)"
|
13
|
+
command "delete", "Delete an organization secret"
|
14
|
+
|
15
|
+
param "ORG", "Name of the organization"
|
16
|
+
param "KEY", "The name of the secret"
|
17
|
+
param "VALUE", "The plain text secret value. If not provided, it is expected to be set as an environment variable"
|
18
|
+
|
19
|
+
example "secrethub org list myorg"
|
20
|
+
example "secrethub org save myorg PASSWORD"
|
21
|
+
example "secrethub org save myorg PASSWORD s3cr3t"
|
22
|
+
example "secrethub org delete myorg PASSWORD"
|
23
|
+
|
24
|
+
def list_command
|
25
|
+
say "!txtblu!#{org}:"
|
26
|
+
github.org_secrets(org).each do |secret|
|
27
|
+
say "- !txtpur!#{secret}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def save_command
|
32
|
+
github.put_org_secret org, key, value
|
33
|
+
say "Saved !txtblu!#{org} !txtpur!#{key}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete_command
|
37
|
+
github.delete_org_secret org, key
|
38
|
+
say "Deleted !txtblu!#{org} !txtpur!#{key}"
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def org
|
44
|
+
args['ORG']
|
45
|
+
end
|
46
|
+
|
47
|
+
def key
|
48
|
+
args['KEY']
|
49
|
+
end
|
50
|
+
|
51
|
+
def value
|
52
|
+
result = args['VALUE'] || ENV[key]
|
53
|
+
if result
|
54
|
+
result
|
55
|
+
else
|
56
|
+
raise InvalidInput, "Please provide a value, either in the command line or in the environment variable '#{key}'"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module SecretHub
|
2
|
+
module Commands
|
3
|
+
class Repo < Base
|
4
|
+
summary "Manage repository secrets"
|
5
|
+
|
6
|
+
usage "secrethub repo list REPO"
|
7
|
+
usage "secrethub repo save REPO KEY [VALUE]"
|
8
|
+
usage "secrethub repo delete REPO KEY"
|
9
|
+
usage "secrethub repo (-h|--help)"
|
10
|
+
|
11
|
+
command "list", "Show all repository secrets"
|
12
|
+
command "save", "Create or update a repository secret"
|
13
|
+
command "delete", "Delete a repository secret"
|
14
|
+
|
15
|
+
param "REPO", "Full name of the GitHub repository (user/repo)"
|
16
|
+
param "KEY", "The name of the secret"
|
17
|
+
param "VALUE", "The plain text secret value. If not provided, it is expected to be set as an environment variable"
|
18
|
+
|
19
|
+
example "secrethub repo list me/myrepo"
|
20
|
+
example "secrethub repo save me/myrepo PASSWORD"
|
21
|
+
example "secrethub repo save me/myrepo PASSWORD s3cr3t"
|
22
|
+
example "secrethub repo delete me/myrepo PASSWORD"
|
23
|
+
|
24
|
+
def list_command
|
25
|
+
say "!txtblu!#{repo}:"
|
26
|
+
github.secrets(repo).each do |secret|
|
27
|
+
say "- !txtpur!#{secret}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def save_command
|
32
|
+
github.put_secret repo, key, value
|
33
|
+
say "Saved !txtblu!#{repo} !txtpur!#{key}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete_command
|
37
|
+
github.delete_secret repo, key
|
38
|
+
say "Deleted !txtblu!#{repo} !txtpur!#{key}"
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def repo
|
44
|
+
args['REPO']
|
45
|
+
end
|
46
|
+
|
47
|
+
def key
|
48
|
+
args['KEY']
|
49
|
+
end
|
50
|
+
|
51
|
+
def value
|
52
|
+
result = args['VALUE'] || ENV[key]
|
53
|
+
if result
|
54
|
+
result
|
55
|
+
else
|
56
|
+
raise InvalidInput, "Please provide a value, either in the command line or in the environment variable '#{key}'"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/secret_hub/config.rb
CHANGED
@@ -5,7 +5,7 @@ module SecretHub
|
|
5
5
|
attr_reader :data
|
6
6
|
|
7
7
|
def self.load(config_file)
|
8
|
-
raise ConfigurationError, "Config file not found #{
|
8
|
+
raise ConfigurationError, "Config file not found #{config_file}" unless File.exist? config_file
|
9
9
|
new YAML.load_file config_file
|
10
10
|
end
|
11
11
|
|
@@ -11,8 +11,15 @@ module SecretHub
|
|
11
11
|
end
|
12
12
|
|
13
13
|
# GET /repos/:owner/:repo/actions/secrets/public-key
|
14
|
-
|
15
|
-
|
14
|
+
# GET /orgs/:org/actions/secrets/public-key
|
15
|
+
def public_key(repo_or_org)
|
16
|
+
if repo_or_org.include? '/'
|
17
|
+
repo = repo_or_org
|
18
|
+
public_keys[repo_or_org] ||= get("/repos/#{repo}/actions/secrets/public-key")
|
19
|
+
else
|
20
|
+
org = repo_or_org
|
21
|
+
public_keys[repo_or_org] ||= get("/orgs/#{org}/actions/secrets/public-key")
|
22
|
+
end
|
16
23
|
end
|
17
24
|
|
18
25
|
# GET /repos/:owner/:repo/actions/secrets
|
@@ -21,28 +28,49 @@ module SecretHub
|
|
21
28
|
response['secrets'].map { |s| s['name'] }
|
22
29
|
end
|
23
30
|
|
31
|
+
# GET /orgs/:org/actions/secrets
|
32
|
+
def org_secrets(org)
|
33
|
+
response = get "/orgs/#{org}/actions/secrets"
|
34
|
+
response['secrets'].map { |s| s['name'] }
|
35
|
+
end
|
36
|
+
|
24
37
|
# PUT /repos/:owner/:repo/actions/secrets/:name
|
25
38
|
def put_secret(repo, name, value)
|
26
|
-
secret =
|
39
|
+
secret = encrypt_for repo, value
|
27
40
|
key_id = public_key(repo)['key_id']
|
28
41
|
put "/repos/#{repo}/actions/secrets/#{name}",
|
29
42
|
encrypted_value: secret,
|
30
43
|
key_id: key_id
|
31
44
|
end
|
32
45
|
|
46
|
+
# PUT /orgs/:org/actions/secrets/:secret_name
|
47
|
+
def put_org_secret(org, name, value)
|
48
|
+
secret = encrypt_for org, value
|
49
|
+
key_id = public_key(org)['key_id']
|
50
|
+
put "/orgs/#{org}/actions/secrets/#{name}",
|
51
|
+
encrypted_value: secret,
|
52
|
+
key_id: key_id,
|
53
|
+
visibility: 'private'
|
54
|
+
end
|
55
|
+
|
33
56
|
# DELETE /repos/:owner/:repo/actions/secrets/:name
|
34
57
|
def delete_secret(repo, name)
|
35
58
|
delete "/repos/#{repo}/actions/secrets/#{name}"
|
36
59
|
end
|
37
60
|
|
61
|
+
# DELETE /orgs/:org/actions/secrets/:secret_name
|
62
|
+
def delete_org_secret(org, name)
|
63
|
+
delete "/orgs/#{org}/actions/secrets/#{name}"
|
64
|
+
end
|
65
|
+
|
38
66
|
private
|
39
67
|
|
40
68
|
def public_keys
|
41
69
|
@public_keys ||= {}
|
42
70
|
end
|
43
71
|
|
44
|
-
def
|
45
|
-
public_key = public_key(
|
72
|
+
def encrypt_for(repo_or_org, secret)
|
73
|
+
public_key = public_key(repo_or_org)['key']
|
46
74
|
encrypt secret, public_key
|
47
75
|
end
|
48
76
|
|
data/lib/secret_hub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secret_hub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mister_bin
|
@@ -107,9 +107,8 @@ files:
|
|
107
107
|
- lib/secret_hub/cli.rb
|
108
108
|
- lib/secret_hub/commands/base.rb
|
109
109
|
- lib/secret_hub/commands/bulk.rb
|
110
|
-
- lib/secret_hub/commands/
|
111
|
-
- lib/secret_hub/commands/
|
112
|
-
- lib/secret_hub/commands/save.rb
|
110
|
+
- lib/secret_hub/commands/org.rb
|
111
|
+
- lib/secret_hub/commands/repo.rb
|
113
112
|
- lib/secret_hub/config-template.yml
|
114
113
|
- lib/secret_hub/config.rb
|
115
114
|
- lib/secret_hub/exceptions.rb
|
@@ -136,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
135
|
- !ruby/object:Gem::Version
|
137
136
|
version: '0'
|
138
137
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
138
|
+
rubygems_version: 3.1.2
|
140
139
|
signing_key:
|
141
140
|
specification_version: 4
|
142
141
|
summary: Manage GitHub secrets over multiple repositories
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module SecretHub
|
2
|
-
module Commands
|
3
|
-
class Delete < Base
|
4
|
-
summary "Delete a secret from a repository"
|
5
|
-
|
6
|
-
usage "secrethub delete REPO KEY"
|
7
|
-
usage "secrethub delete (-h|--help)"
|
8
|
-
|
9
|
-
param "REPO", "Full name of the GitHub repository (user/repo)"
|
10
|
-
param "KEY", "The name of the secret"
|
11
|
-
|
12
|
-
example "secrethub delete bob/vault PASSWORD"
|
13
|
-
|
14
|
-
def run
|
15
|
-
repo = args['REPO']
|
16
|
-
key = args['KEY']
|
17
|
-
|
18
|
-
success = github.delete_secret repo, key
|
19
|
-
say "Deleted !txtblu!#{repo} !txtpur!#{key}"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module SecretHub
|
2
|
-
module Commands
|
3
|
-
class List < Base
|
4
|
-
summary "Show secrets for a repository"
|
5
|
-
|
6
|
-
usage "secrethub list REPO"
|
7
|
-
usage "secrethub list (-h|--help)"
|
8
|
-
|
9
|
-
param "REPO", "Full name of the GitHub repository (user/repo)"
|
10
|
-
|
11
|
-
example "secrethub list bob/repo-woth-secrets"
|
12
|
-
|
13
|
-
def run
|
14
|
-
repo = args['REPO']
|
15
|
-
say "!txtblu!#{repo}:"
|
16
|
-
github.secrets(repo).each do |secret|
|
17
|
-
say "- !txtpur!#{secret}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module SecretHub
|
2
|
-
module Commands
|
3
|
-
class Save < Base
|
4
|
-
summary "Create or update a secret in a repository"
|
5
|
-
|
6
|
-
usage "secrethub save REPO KEY VALUE"
|
7
|
-
usage "secrethub save (-h|--help)"
|
8
|
-
|
9
|
-
param "REPO", "Full name of the GitHub repository (user/repo)"
|
10
|
-
param "KEY", "The name of the secret"
|
11
|
-
param "VALUE", "The plain text secret value"
|
12
|
-
|
13
|
-
example "secrethub save bob/vault PASSWORD p4ssw0rd"
|
14
|
-
|
15
|
-
def run
|
16
|
-
repo = args['REPO']
|
17
|
-
key = args['KEY']
|
18
|
-
value = args['VALUE']
|
19
|
-
|
20
|
-
github.put_secret repo, key, value
|
21
|
-
say "Saved !txtblu!#{repo} !txtpur!#{key}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|