conjur-cli 4.25.2 → 4.26.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,31 +49,31 @@ class Conjur::Command::Plugin < Conjur::Command
49
49
  end
50
50
 
51
51
  cmd.desc 'Install a plugin'
52
- cmd.arg_name 'name'
52
+ cmd.arg_name 'PLUGIN'
53
53
  cmd.command :install do |c|
54
54
  c.arg_name 'version'
55
55
  c.desc 'Version of the plugin to install'
56
56
  c.flag [:v, :version], :default_value => Gem::Requirement.default
57
57
 
58
58
  c.action do |_, options, args|
59
- install_plugin(require_arg(args, 'name'), options[:version])
59
+ install_plugin(require_arg(args, 'PLUGIN'), options[:version])
60
60
  end
61
61
  end
62
62
 
63
63
  cmd.desc 'Uninstall a plugin'
64
- cmd.arg_name 'name'
64
+ cmd.arg_name 'PLUGIN'
65
65
  cmd.command :uninstall do |c|
66
66
  c.action do |_, _, args|
67
- name = require_arg(args, 'name')
67
+ name = require_arg(args, 'PLUGIN')
68
68
  uninstall_plugin(name)
69
69
  end
70
70
  end
71
71
 
72
72
  cmd.desc "Show a plugin's details"
73
- cmd.arg_name 'name'
73
+ cmd.arg_name 'PLUGIN'
74
74
  cmd.command :show do |c|
75
75
  c.action do |_, _, args|
76
- name = require_arg(args, 'name')
76
+ name = require_arg(args, 'PLUGIN')
77
77
  begin
78
78
  gem = Gem::Specification.find_by_name "conjur-asset-#{name}"
79
79
  puts "Name: #{name}"
@@ -62,7 +62,7 @@ annotations on the policy. The policy role becomes the owner of the owned policy
62
62
  --as-group and --as-role options can be used to set the owner of the policy role. The default
63
63
  owner of the policy role is the logged-in user (you), as always.
64
64
  DESC
65
- policy.arg_name "(policy-file | STDIN)"
65
+ policy.arg_name "FILE"
66
66
  policy.command :load do |c|
67
67
  acting_as_option(c)
68
68
 
@@ -71,7 +71,7 @@ owner of the policy role is the logged-in user (you), as always.
71
71
  c.flag [:collection]
72
72
 
73
73
  c.desc "Load context from this config file, and save it when finished. The file permissions will be 0600 by default."
74
- c.arg_name "context"
74
+ c.arg_name "FILE"
75
75
  c.flag [:c, :context]
76
76
 
77
77
  c.action do |global_options,options,args|
@@ -26,19 +26,19 @@ class Conjur::Command::Pubkeys < Conjur::Command
26
26
  command :pubkeys do |pubkeys|
27
27
 
28
28
  pubkeys.desc "List public keys for the given user"
29
- pubkeys.arg_name "username"
29
+ pubkeys.arg_name "USER"
30
30
  pubkeys.command :show do |c|
31
31
  c.action do |global_options, options, args|
32
- username = require_arg args, "username"
32
+ username = require_arg args, "USER"
33
33
  puts api.public_keys(username)
34
34
  end
35
35
  end
36
36
 
37
37
  pubkeys.desc "List the names of a user's public keys"
38
- pubkeys.arg_name "username"
38
+ pubkeys.arg_name "USER"
39
39
  pubkeys.command :names do |c|
40
40
  c.action do |global_options, options, args|
41
- username = require_arg args, "username"
41
+ username = require_arg args, "USER"
42
42
  api.public_keys(username)
43
43
  .split("\n")
44
44
  .map{|k| k.split(' ').last}
@@ -65,7 +65,7 @@ The public key itself may be provided in several ways.
65
65
 
66
66
  c.action do |global_options, options, args|
67
67
  options[:interactive] = $stdin.isatty if options[:interactive].nil?
68
- username = require_arg args, "username"
68
+ username = require_arg args, "USER"
69
69
  if key = args.shift
70
70
  if /^@(.+)$/ =~ key
71
71
  key = File.read(File.expand_path($1))
@@ -86,11 +86,11 @@ The public key itself may be provided in several ways.
86
86
  end
87
87
 
88
88
  pubkeys.desc "Removes a public key for a user"
89
- pubkeys.arg_name "username keyname"
89
+ pubkeys.arg_name "USER KEY"
90
90
  pubkeys.command :delete do |c|
91
91
  c.action do |global_options, options, args|
92
- username = require_arg args, "username"
93
- keyname = require_arg args, "keyname"
92
+ username = require_arg args, "USER"
93
+ keyname = require_arg args, "KEY"
94
94
  api.delete_public_key username, keyname
95
95
  puts "Public key '#{keyname}' deleted"
96
96
  end
@@ -24,12 +24,12 @@ class Conjur::Command::Resources < Conjur::Command
24
24
  command :resource do |resource|
25
25
 
26
26
  resource.desc "Create a new resource"
27
- resource.arg_name "resource-id"
27
+ resource.arg_name "RESOURCE"
28
28
  resource.command :create do |c|
29
29
  acting_as_option(c)
30
30
 
31
31
  c.action do |global_options,options,args|
32
- id = full_resource_id( require_arg(args, "resource-id") )
32
+ id = full_resource_id( require_arg(args, "RESOURCE") )
33
33
  resource = api.resource(id)
34
34
 
35
35
  if ownerid = options.delete(:ownerid)
@@ -42,32 +42,32 @@ class Conjur::Command::Resources < Conjur::Command
42
42
  end
43
43
 
44
44
  resource.desc "Show a resource"
45
- resource.arg_name "resource-id"
45
+ resource.arg_name "RESOURCE"
46
46
  resource.command :show do |c|
47
47
  c.action do |global_options,options,args|
48
- id = full_resource_id( require_arg(args, "resource-id") )
48
+ id = full_resource_id( require_arg(args, "RESOURCE") )
49
49
  display api.resource(id).attributes
50
50
  end
51
51
  end
52
52
 
53
53
  resource.desc "Determines whether a resource exists"
54
- resource.arg_name "resource-id"
54
+ resource.arg_name "RESOURCE"
55
55
  resource.command :exists do |c|
56
56
  c.action do |global_options,options,args|
57
- id = full_resource_id( require_arg(args, "resource-id") )
57
+ id = full_resource_id( require_arg(args, "RESOURCE") )
58
58
  puts api.resource(id).exists?
59
59
  end
60
60
  end
61
61
 
62
62
  resource.desc "Give a privilege on a resource"
63
- resource.arg_name "resource-id role privilege"
63
+ resource.arg_name "RESOURCE ROLE PRIVILEGE"
64
64
  resource.command :permit do |c|
65
65
  c.desc "allow transfer to other roles"
66
66
  c.switch [:g, :grantable]
67
67
  c.action do |global_options,options,args|
68
- id = full_resource_id( require_arg(args, "resource-id") )
69
- role = require_arg(args, "role")
70
- privilege = require_arg(args, "privilege")
68
+ id = full_resource_id( require_arg(args, "RESOURCE") )
69
+ role = require_arg(args, "ROLE")
70
+ privilege = require_arg(args, "PRIVILEGE")
71
71
  unless options[:g]
72
72
  api.resource(id).permit privilege, role
73
73
  else
@@ -79,12 +79,12 @@ class Conjur::Command::Resources < Conjur::Command
79
79
  end
80
80
 
81
81
  resource.desc "Deny a privilege on a resource"
82
- resource.arg_name "resource-id role privilege"
82
+ resource.arg_name "RESOURCE ROLE PRIVILEGE"
83
83
  resource.command :deny do |c|
84
84
  c.action do |global_options,options,args|
85
- id = full_resource_id( require_arg(args, "resource-id") )
86
- role = require_arg(args, "role")
87
- privilege = require_arg(args, "privilege")
85
+ id = full_resource_id( require_arg(args, "RESOURCE") )
86
+ role = require_arg(args, "ROLE")
87
+ privilege = require_arg(args, "PRIVILEGE")
88
88
  api.resource(id).deny privilege, role
89
89
  puts "Permission revoked"
90
90
  end
@@ -97,13 +97,13 @@ class Conjur::Command::Resources < Conjur::Command
97
97
  When the role argument is used, either the logged-in user must either own the specified
98
98
  resource or be an admin of the specified role (i.e. be granted the specified role with grant option).
99
99
  """
100
- resource.arg_name "resource-id privilege"
100
+ resource.arg_name "RESOURCE PRIVILEGE"
101
101
  resource.command :check do |c|
102
102
  c.desc "Role to check. By default, the current logged-in role is used"
103
103
  c.flag [:r,:role]
104
104
 
105
105
  c.action do |global_options,options,args|
106
- id = full_resource_id( require_arg(args, "resource-id") )
106
+ id = full_resource_id( require_arg(args, "RESOURCE") )
107
107
  privilege = args.shift or raise "Missing parameter: privilege"
108
108
  if role = options[:role]
109
109
  role = api.role(role)
@@ -115,38 +115,38 @@ class Conjur::Command::Resources < Conjur::Command
115
115
  end
116
116
 
117
117
  resource.desc "Grant ownership on a resource to a new owner"
118
- resource.arg_name "resource-id owner"
118
+ resource.arg_name "RESOURCE USER"
119
119
  resource.command :give do |c|
120
120
  c.action do |global_options,options,args|
121
- id = full_resource_id( require_arg(args, "resource-id") )
122
- owner = require_arg(args, "owner")
121
+ id = full_resource_id( require_arg(args, "RESOURCE") )
122
+ owner = require_arg(args, "USER")
123
123
  api.resource(id).give_to owner
124
124
  puts "Ownership granted"
125
125
  end
126
126
  end
127
127
 
128
128
  resource.desc "List roles with a specified permission on the resource"
129
- resource.arg_name "resource-id permission"
129
+ resource.arg_name "RESOURCE PERMISSION"
130
130
  resource.command :permitted_roles do |c|
131
131
  c.action do |global_options,options,args|
132
- id = full_resource_id( require_arg(args, "resource-id") )
133
- permission = require_arg(args, "permission")
132
+ id = full_resource_id( require_arg(args, "RESOURCE") )
133
+ permission = require_arg(args, "PERMISSION")
134
134
  display api.resource(id).permitted_roles(permission)
135
135
  end
136
136
  end
137
137
 
138
138
  resource.desc "Set an annotation on a resource"
139
- resource.arg_name "resource-id name value"
139
+ resource.arg_name "RESOURCE ANNOTATION value"
140
140
  resource.command :annotate do |c|
141
141
  interactive_option c
142
142
 
143
143
  c.action do |global_options, options, args|
144
- id = full_resource_id require_arg(args, 'resource-id')
144
+ id = full_resource_id require_arg(args, 'RESOURCE')
145
145
 
146
146
  annotations = if options[:interactive]
147
147
  prompt_for_annotations
148
148
  else
149
- name = require_arg args, 'name'
149
+ name = require_arg args, 'ANNOTATION'
150
150
  value = require_arg args, 'value'
151
151
  { name => value }
152
152
  end
@@ -158,21 +158,21 @@ class Conjur::Command::Resources < Conjur::Command
158
158
  end
159
159
 
160
160
  resource.desc "Show an annotation for a resource"
161
- resource.arg_name "resource-id name"
161
+ resource.arg_name "RESOURCE ANNOTATION"
162
162
  resource.command :annotation do |c|
163
163
  c.action do |global_options, options, args|
164
- id = full_resource_id require_arg args, 'resource-id'
165
- name = require_arg args, 'name'
164
+ id = full_resource_id require_arg args, 'RESOURCE'
165
+ name = require_arg args, 'ANNOTATION'
166
166
  value = api.resource(id).annotations[name]
167
167
  puts value unless value.nil?
168
168
  end
169
169
  end
170
170
 
171
171
  resource.desc "Print annotations as JSON"
172
- resource.arg_name 'resource-id'
172
+ resource.arg_name 'RESOURCE'
173
173
  resource.command :annotations do |c|
174
174
  c.action do |go, o, args|
175
- id = full_resource_id require_arg args, 'resource-id'
175
+ id = full_resource_id require_arg args, 'RESOURCE'
176
176
  annots = api.resource(id).annotations.to_h
177
177
  puts annots.to_json
178
178
  end
@@ -27,7 +27,7 @@ class Conjur::Command::Roles < Conjur::Command
27
27
  command :role do |role|
28
28
 
29
29
  role.desc "Create a new role"
30
- role.arg_name "role"
30
+ role.arg_name "ROLE"
31
31
  role.command :create do |c|
32
32
  acting_as_option(c)
33
33
 
@@ -35,7 +35,7 @@ class Conjur::Command::Roles < Conjur::Command
35
35
  c.switch "json"
36
36
 
37
37
  c.action do |global_options,options,args|
38
- id = require_arg(args, 'role')
38
+ id = require_arg(args, 'ROLE')
39
39
  role = api.role(id)
40
40
 
41
41
  if ownerid = options.delete(:ownerid)
@@ -54,13 +54,13 @@ class Conjur::Command::Roles < Conjur::Command
54
54
  end
55
55
 
56
56
  role.desc "Determines whether a role exists"
57
- role.arg_name "role"
57
+ role.arg_name "ROLE"
58
58
  role.command :exists do |c|
59
59
  c.desc "Output a JSON response with a single field, exists"
60
60
  c.switch "json"
61
61
 
62
62
  c.action do |global_options,options,args|
63
- id = require_arg(args, 'role')
63
+ id = require_arg(args, 'ROLE')
64
64
  role = api.role(id)
65
65
  if options[:json]
66
66
  display({
@@ -73,7 +73,7 @@ class Conjur::Command::Roles < Conjur::Command
73
73
  end
74
74
 
75
75
  role.desc "Lists role memberships. The role membership list is recursively expanded."
76
- role.arg_name "role"
76
+ role.arg_name "ROLE"
77
77
 
78
78
  role.command :memberships do |c|
79
79
  c.desc "Whether to show system (internal) roles"
@@ -91,7 +91,7 @@ class Conjur::Command::Roles < Conjur::Command
91
91
  end
92
92
 
93
93
  role.desc "Lists all direct members of the role. The membership list is not recursively expanded."
94
- role.arg_name "role"
94
+ role.arg_name "ROLE"
95
95
  role.command :members do |c|
96
96
  c.desc "Verbose output"
97
97
  c.switch [:V,:verbose]
@@ -103,14 +103,14 @@ class Conjur::Command::Roles < Conjur::Command
103
103
  end
104
104
 
105
105
  role.desc "Grant a role to another role. You must have admin permission on the granting role."
106
- role.arg_name "role member"
106
+ role.arg_name "ROLE-1 ROLE-2"
107
107
  role.command :grant_to do |c|
108
108
  c.desc "Whether to grant with admin option"
109
109
  c.switch [:a,:admin]
110
110
 
111
111
  c.action do |global_options,options,args|
112
- id = require_arg(args, 'role')
113
- member = require_arg(args, 'member')
112
+ id = require_arg(args, 'ROLE-1')
113
+ member = require_arg(args, 'ROLE-2')
114
114
  role = api.role(id)
115
115
  grant_options = {}
116
116
  grant_options[:admin_option] = true if options[:admin]
@@ -121,11 +121,11 @@ class Conjur::Command::Roles < Conjur::Command
121
121
 
122
122
 
123
123
  role.desc "Revoke a role from another role. You must have admin permission on the revoking role."
124
- role.arg_name "role member"
124
+ role.arg_name "ROLE-1 ROLE-2"
125
125
  role.command :revoke_from do |c|
126
126
  c.action do |global_options,options,args|
127
- id = require_arg(args, 'role')
128
- member = require_arg(args, 'member')
127
+ id = require_arg(args, 'ROLE-1')
128
+ member = require_arg(args, 'ROLE-2')
129
129
  role = api.role(id)
130
130
  role.revoke_from member
131
131
  puts "Role revoked"
@@ -176,7 +176,7 @@ If the --short flag is not present, the JSON output will be more verbose:
176
176
  EOD
177
177
 
178
178
  role.desc "Describe role memberships as a digraph"
179
- role.arg_name "role", :multiple
179
+ role.arg_name "ROLE", :multiple
180
180
  role.command :graph do |c|
181
181
  c.desc "Output formats [#{GRAPH_FORMATS}]"
182
182
  c.flag [:f,:format], default_value: 'json', must_match: GRAPH_FORMATS
@@ -214,4 +214,4 @@ EOD
214
214
  end
215
215
  end
216
216
  end
217
- end
217
+ end
@@ -14,7 +14,6 @@ shared_context "default audit behavior" do
14
14
  "account"=>"the-account"
15
15
  }
16
16
  },
17
- "user" => "account:user:alice",
18
17
  "acting_as" => "account:group:admins",
19
18
  "conjur" => { # new behaviour
20
19
  "user" => "account:user:alice",
@@ -28,7 +28,7 @@ class Conjur::Command::Script < Conjur::DSLCommand
28
28
  acting_as_option(c)
29
29
 
30
30
  c.desc "Load context from this config file, and save it when finished. The file permissions will be 0600 by default."
31
- c.arg_name "context"
31
+ c.arg_name "FILE"
32
32
  c.flag [:c, :context]
33
33
 
34
34
  c.action do |global_options,options,args|
@@ -36,4 +36,4 @@ class Conjur::Command::Script < Conjur::DSLCommand
36
36
  end
37
37
  end
38
38
  end
39
- end
39
+ end
@@ -0,0 +1,36 @@
1
+ #
2
+ # Copyright (C) 2014 Conjur Inc
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy of
5
+ # this software and associated documentation files (the "Software"), to deal in
6
+ # the Software without restriction, including without limitation the rights to
7
+ # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8
+ # the Software, and to permit persons to whom the Software is furnished to do so,
9
+ # subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17
+ # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18
+ # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
+ # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ #
21
+ require 'conjur/command'
22
+
23
+ class Conjur::Command::ShellInit < Conjur::Command
24
+ desc 'Provide the command to initialize the shell for conjur'
25
+
26
+ Conjur::CLI.command :shellinit do |c|
27
+ hide_docs c
28
+ c.desc 'Provide the command to initialize the shell for conjur'
29
+ c.action do |global_options,options,args|
30
+ cmd = <<-eoc
31
+ complete -o nospace -C _conjur conjur;
32
+ eoc
33
+ puts cmd.tr "\n", " "
34
+ end
35
+ end
36
+ end
@@ -25,7 +25,7 @@ class Conjur::Command::Users < Conjur::Command
25
25
  command :user do |user|
26
26
 
27
27
  user.desc "Create a new user"
28
- user.arg_name "login"
28
+ user.arg_name "NAME"
29
29
  user.command :create do |c|
30
30
  c.desc "Prompt for a password for the user (default: --no-password)"
31
31
  c.switch [:p,:password]
@@ -86,21 +86,21 @@ class Conjur::Command::Users < Conjur::Command
86
86
  end
87
87
 
88
88
  user.desc "Show a user"
89
- user.arg_name "id"
89
+ user.arg_name "USER"
90
90
  user.command :show do |c|
91
91
  c.action do |global_options,options,args|
92
- id = require_arg(args, 'id')
92
+ id = require_arg(args, 'USER')
93
93
  display(api.user(id), options)
94
94
  end
95
95
  end
96
96
 
97
97
  user.desc "Decommission a user"
98
- user.arg_name "id"
98
+ user.arg_name "USER"
99
99
  user.command :retire do |c|
100
100
  retire_options c
101
101
 
102
102
  c.action do |global_options,options,args|
103
- id = require_arg(args, 'id')
103
+ id = require_arg(args, 'USER')
104
104
 
105
105
  user = api.user(id)
106
106
 
@@ -137,12 +137,12 @@ class Conjur::Command::Users < Conjur::Command
137
137
  end
138
138
 
139
139
  user.desc "Update user's attributes (only uidnumber supported now)"
140
- user.arg_name "login"
140
+ user.arg_name "USER"
141
141
  user.command :update do |c|
142
142
  c.desc "UID number to be associated with user"
143
143
  c.flag [:uidnumber]
144
144
  c.action do |global_options, options, args|
145
- login=require_arg(args,'login')
145
+ login=require_arg(args,'USER')
146
146
  raise "Uidnumber should be integer" unless /\d+/ =~ options[:uidnumber]
147
147
  options[:uidnumber]=options[:uidnumber].to_i
148
148
  api.user(login).update(options)
@@ -151,7 +151,7 @@ class Conjur::Command::Users < Conjur::Command
151
151
  end
152
152
 
153
153
  user.desc "Find the user by UID"
154
- user.arg_name "uid"
154
+ user.arg_name "uid"
155
155
  user.command :uidsearch do |c|
156
156
  c.action do |global_options, options, args|
157
157
  uidnumber = require_arg(args,'uid')