conjur-asset-audit-send 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.project +18 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +11 -0
- data/conjur-asset-audit-send.gemspec +26 -0
- data/lib/conjur-asset-audit-send-version.rb +27 -0
- data/lib/conjur-asset-audit-send.rb +23 -0
- data/lib/conjur/api/audit_send.rb +37 -0
- data/lib/conjur/audit-send-api.rb +22 -0
- data/lib/conjur/command/audit_send.rb +38 -0
- data/spec/command/audit_send_spec.rb +93 -0
- data/spec/lib/audit_send_spec.rb +51 -0
- data/spec/spec_helper.rb +7 -0
- metadata +133 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6767218a4d2c9e01ce15f0a2d9dac16033af10c
|
4
|
+
data.tar.gz: 2b99ef6ca918d1e6e7b04fee9732cc09453074d9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2df95137ab1f9a643e9c427d273e5e0e5537be4768a274cde1ad313aebb2bc7051314e2fc072ac5dafa4837fa5257dd1c57753bbde85ad6984809a16e5870e76
|
7
|
+
data.tar.gz: 00563b2908226c039ebff2ecfd4249925bc9fd13828114302ea50372c8e689543512ee5226fc8d586e692644603737492e2d054ffc3252fa10cfa955539fe2aa
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
.conjurrc
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
.yardoc
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
data/.project
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<projectDescription>
|
3
|
+
<name>conjur-asset-audit-send</name>
|
4
|
+
<comment></comment>
|
5
|
+
<projects>
|
6
|
+
</projects>
|
7
|
+
<buildSpec>
|
8
|
+
<buildCommand>
|
9
|
+
<name>com.aptana.ide.core.unifiedBuilder</name>
|
10
|
+
<arguments>
|
11
|
+
</arguments>
|
12
|
+
</buildCommand>
|
13
|
+
</buildSpec>
|
14
|
+
<natures>
|
15
|
+
<nature>com.aptana.ruby.core.rubynature</nature>
|
16
|
+
<nature>com.aptana.projects.webnature</nature>
|
17
|
+
</natures>
|
18
|
+
</projectDescription>
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in conjur-asset-audit-send.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
#ruby-gemset=conjur-asset-audit-send
|
7
|
+
|
8
|
+
group :test, :development do
|
9
|
+
gem 'conjur-api', github: 'conjurinc/api-ruby', branch: 'master'
|
10
|
+
gem 'conjur-cli', github: 'conjurinc/cli-ruby', branch: 'master'
|
11
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Kevin Gilpin
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Conjur::Asset::AuditSend
|
2
|
+
|
3
|
+
API and CLI interface to send events to Conjur.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'conjur-asset-audit-send-api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install conjur-asset-audit-send-api
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/[my-github-username]/conjur-asset-audit-send/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
|
4
|
+
require 'ci/reporter/rake/rspec'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new :spec
|
8
|
+
|
9
|
+
task :jenkins => ['ci:setup:rspec', :spec] do
|
10
|
+
File.write('build_number', ENV['BUILD_NUMBER']) if ENV['BUILD_NUMBER']
|
11
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'conjur-asset-audit-send-version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "conjur-asset-audit-send"
|
8
|
+
spec.version = Conjur::Asset::AuditSend::VERSION
|
9
|
+
spec.authors = ["Kevin Gilpin"]
|
10
|
+
spec.email = ["kgilpin@gmail.com"]
|
11
|
+
spec.summary = %q{Conjur asset plugin to send custom audit events}
|
12
|
+
spec.homepage = "https://github.com/conjurinc/conjur-asset-audit-send"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "webmock"
|
22
|
+
# inherited from cli tests, as our specs rely on them
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
|
+
spec.add_development_dependency 'ci_reporter_rspec', '~> 1.0'
|
25
|
+
spec.add_development_dependency 'io-grab', '~> 0.0.1'
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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
|
+
module Conjur
|
22
|
+
module Asset
|
23
|
+
module AuditSend
|
24
|
+
VERSION = "1.0.0"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
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-asset-audit-send-version'
|
22
|
+
require 'conjur/api'
|
23
|
+
require 'conjur/audit-send-api'
|
@@ -0,0 +1,37 @@
|
|
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
|
+
module Conjur
|
22
|
+
class API
|
23
|
+
# Send custom event to the audit system
|
24
|
+
# @param input [String|Hash|Array] event or array of events (optionally serialized to JSON)
|
25
|
+
def audit_send input
|
26
|
+
json = if input.kind_of? String
|
27
|
+
input
|
28
|
+
elsif input.kind_of? Array or input.kind_of? Hash
|
29
|
+
input.to_json
|
30
|
+
else
|
31
|
+
raise ArgumentError, "Parameter should be either String, Hash or Array"
|
32
|
+
end
|
33
|
+
rest_api = RestClient::Resource.new(Conjur::Authz::API.host, credentials)["audit"]
|
34
|
+
rest_api.post json, content_type: "text/plain"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
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
|
+
|
22
|
+
require 'conjur/api/audit_send'
|
@@ -0,0 +1,38 @@
|
|
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
|
+
|
22
|
+
require 'conjur/command/audit'
|
23
|
+
|
24
|
+
class Conjur::Command::AuditSend < Conjur::Command
|
25
|
+
desc "Fetch and send audit events"
|
26
|
+
command :audit do |audit|
|
27
|
+
audit.desc "Send custom event(s) to audit system"
|
28
|
+
audit.long_desc "Send custom event(s) to audit system. Events should be provided in JSON format, describing either single hash or array of hashes."
|
29
|
+
audit.arg_name "( json_string | STDIN )"
|
30
|
+
audit.command :send do |c|
|
31
|
+
c.action do |global_options, options, args|
|
32
|
+
json = ( args.shift || STDIN.read )
|
33
|
+
api.audit_send json
|
34
|
+
puts "Events sent successfully"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'conjur/command/audit_send'
|
3
|
+
|
4
|
+
describe Conjur::Command::AuditSend, logged_in: true do
|
5
|
+
include_context "default audit behavior"
|
6
|
+
|
7
|
+
describe_command "audit:send '[{\"action\":\"login\",\"user\":\"alice\"},{\"action\":\"sudo\",\"user\":\"alice\"}]' " do
|
8
|
+
it 'calls api.audit_send with provided parameter' do
|
9
|
+
expect(api).to receive(:audit_send).with("'[{\"action\":\"login\",\"user\":\"alice\"},{\"action\":\"sudo\",\"user\":\"alice\"}]'")
|
10
|
+
expect { invoke }.to write "Events sent successfully"
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'does not hide exceptions coming from API' do
|
14
|
+
expect(api).to receive(:audit_send).and_raise(ArgumentError)
|
15
|
+
expect { invoke }.to raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe_command "audit all -s" do
|
20
|
+
let(:common_prefix) { "[#{default_audit_event["timestamp"]}] #{default_audit_event["user"]}" }
|
21
|
+
let(:audit_event) { test_event }
|
22
|
+
before {
|
23
|
+
expect(api).to receive(:audit_event_feed).and_yield([audit_event])
|
24
|
+
}
|
25
|
+
|
26
|
+
describe "(audit:send)" do
|
27
|
+
# reported [facility:action] (by role) (on resource) (allowed: <allowed>)(; message: <audit_message>)”
|
28
|
+
|
29
|
+
describe "standard behaviour" do
|
30
|
+
let(:test_event) { default_audit_event.merge("kind"=>"audit", "action"=>"login") }
|
31
|
+
it_behaves_like "it supports standard prefix:"
|
32
|
+
it_behaves_like "it recognizes error messages:"
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "if facility is not specified" do
|
36
|
+
let(:test_event) { default_audit_event.merge("kind"=>"audit", "action"=>"login") }
|
37
|
+
it "prints 'reported <action>'" do
|
38
|
+
expect { invoke }.to write "reported login"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
describe "if facility is specified" do
|
42
|
+
let(:test_event) { default_audit_event.merge("kind"=>"audit", "action"=>"login", "facility"=>"ssh") }
|
43
|
+
it "prints 'reported <action>'" do
|
44
|
+
expect { invoke }.to write "reported ssh:login"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "if role is specified" do
|
49
|
+
let(:test_event) { default_audit_event.merge("kind"=>"audit", "action"=>"login", "role"=>"user:alice") }
|
50
|
+
it "prints 'by <role>'" do
|
51
|
+
expect { invoke }.to write "reported login by user:alice"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "if resource_id is specified" do
|
56
|
+
let(:test_event) { default_audit_event.merge("kind"=>"audit", "action"=>"login", "resource_id"=>"host:frontend") }
|
57
|
+
it "prints 'on <resource>'" do
|
58
|
+
expect { invoke }.to write "reported login on host:frontend"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "if allowed is specified" do
|
63
|
+
let(:test_event) { default_audit_event.merge("kind"=>"audit", "action"=>"login", "allowed"=>false) }
|
64
|
+
it "prints '(allowed: <allowed>)'" do
|
65
|
+
expect { invoke }.to write "reported login (allowed: false)"
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "if audit_message is specified" do
|
70
|
+
let(:test_event) { default_audit_event.merge("kind"=>"audit", "action"=>"login", "audit_message"=>"something important to know") }
|
71
|
+
it "prints '; message: <audit_message>'" do
|
72
|
+
expect { invoke }.to write "reported login; message: something important to know"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "if facility, role, resource_id, allowed, audit_message are specified" do
|
77
|
+
let(:test_event) { default_audit_event.merge("user"=>"host:monitoring", "acting_as" => "host:monitoring",
|
78
|
+
"kind"=>"audit",
|
79
|
+
"action"=>"sudo",
|
80
|
+
"facility"=>"ssh",
|
81
|
+
"role"=>"user:alice",
|
82
|
+
"resource_id"=>"host:frontend",
|
83
|
+
"allowed"=>"false",
|
84
|
+
"audit_message" => "sudo command is 'su'"
|
85
|
+
)
|
86
|
+
}
|
87
|
+
it 'prints all optional components together' do
|
88
|
+
expect { invoke }.to write "[#{default_audit_event["timestamp"]}] host:monitoring reported ssh:sudo by user:alice on host:frontend (allowed: false); message: sudo command is 'su'"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Conjur::API do
|
4
|
+
let(:username) { "user" }
|
5
|
+
let(:api){ Conjur::API.new_from_key username, 'key' }
|
6
|
+
let(:credentials) { { headers: { authorization: "Token token=\"stub\"" } } } #, username: username } }
|
7
|
+
|
8
|
+
before do
|
9
|
+
api.stub credentials: credentials
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "#audit_send" do
|
13
|
+
context "valid input" do
|
14
|
+
let(:http_parameters) {
|
15
|
+
{
|
16
|
+
headers: credentials[:headers].merge(content_type: "text/plain"),
|
17
|
+
method: :post ,
|
18
|
+
url: "#{Conjur::Authz::API.host}/audit"
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
it "sends Hash as JSON" do
|
23
|
+
event = { action: "login", user: "alice" }
|
24
|
+
RestClient::Request.should_receive(:execute).with(
|
25
|
+
http_parameters.merge( payload: event.to_json )
|
26
|
+
)
|
27
|
+
api.audit_send event
|
28
|
+
end
|
29
|
+
it "sends array as JSON" do
|
30
|
+
events = [ { action: "login", user: "alice" }, { action: "sudo", user: "alice" } ]
|
31
|
+
RestClient::Request.should_receive(:execute).with(
|
32
|
+
http_parameters.merge( payload: events.to_json )
|
33
|
+
)
|
34
|
+
api.audit_send events
|
35
|
+
end
|
36
|
+
|
37
|
+
it "sends string as is (consider it preformatted JSON)" do
|
38
|
+
events_serialized = "this is supposed to be JSON"
|
39
|
+
RestClient::Request.should_receive(:execute).with(
|
40
|
+
http_parameters.merge( payload: events_serialized )
|
41
|
+
)
|
42
|
+
api.audit_send events_serialized
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it "rejects any other types of arguments" do
|
47
|
+
expect { api.audit_send( api ) }.to raise_error(ArgumentError)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: conjur-asset-audit-send
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kevin Gilpin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: webmock
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ci_reporter_rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: io-grab
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.1
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- kgilpin@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- .project
|
92
|
+
- CHANGELOG.md
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- conjur-asset-audit-send.gemspec
|
98
|
+
- lib/conjur-asset-audit-send-version.rb
|
99
|
+
- lib/conjur-asset-audit-send.rb
|
100
|
+
- lib/conjur/api/audit_send.rb
|
101
|
+
- lib/conjur/audit-send-api.rb
|
102
|
+
- lib/conjur/command/audit_send.rb
|
103
|
+
- spec/command/audit_send_spec.rb
|
104
|
+
- spec/lib/audit_send_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
homepage: https://github.com/conjurinc/conjur-asset-audit-send
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.2.1
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Conjur asset plugin to send custom audit events
|
130
|
+
test_files:
|
131
|
+
- spec/command/audit_send_spec.rb
|
132
|
+
- spec/lib/audit_send_spec.rb
|
133
|
+
- spec/spec_helper.rb
|