Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #366 from ripienaar/347.6
Browse files Browse the repository at this point in the history
(#347) Bolt Task AAA
  • Loading branch information
ripienaar committed Nov 12, 2017
2 parents 8311a50 + e2dcf04 commit bcfd0e6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
1 change: 0 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
--color
--format doc
21 changes: 21 additions & 0 deletions lib/mcollective/agent/bolt_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,27 @@ class Bolt_task < RPC::Agent
end
end

# Performs an additional authorization and audit line using the task name as action
def before_processing_hook(msg, connection)
if respond_to?("authorization_hook")
original_action = request.action
task = request[:task]

begin
Log.debug(request)
if ["run_and_wait", "run_no_wait"].include?(original_action) && task
request.action = task
authorization_hook(request)
audit_request(request, connection)
end
rescue
raise(RPCAborted, "You are not authorized to run Bolt Task %s" % task)
ensure
request.action = original_action
end
end
end

def reply_task_status(status)
reply[:exitcode] = status["exitcode"]
reply[:stdout] = status["stdout"]
Expand Down
2 changes: 2 additions & 0 deletions lib/mcollective/util/tasks_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ def file_sha256(file_path)
# @raise [StandardError] when the file does not exist
def file_size(file_path)
File.stat(file_path).size
rescue
-1
end

# Validates a task cache file
Expand Down

0 comments on commit bcfd0e6

Please sign in to comment.