vijay 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +9 -0
- data/LICENSE +22 -0
- data/README.md +49 -0
- data/bin/vijay +29 -0
- data/lib/vijay.rb +4 -0
- data/lib/vijay/file.rb +14 -0
- data/lib/vijay/inspector.rb +61 -0
- data/lib/vijay/server.rb +18 -0
- data/lib/vijay/version.rb +3 -0
- data/vijay.gemspec +19 -0
- metadata +57 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a8d305a03b13e23c72571637125c82e257764e1d
|
4
|
+
data.tar.gz: bed59a03f9743396158c6c14209733ed302cf905
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 38ba1817df62c542c8bc3f1e354713c31c6df716dfe0c4642d6109eb43161badcbf31dd97bd509dc84f9121b13770808e29b9a79fae6727c069ed0b4d923583a
|
7
|
+
data.tar.gz: 50838293c3b308f732d539fd81899d47b4daa5863db9a0e83ff83f9acd2c461272dced13f543d27001590bbb86a361f7a7847d0312cae2d57480f23f5dd5921e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gem 'net-ssh'
|
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Edwin Tunggawan (a.k.a sdsdkkk)
|
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,49 @@
|
|
1
|
+
# Vijay
|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install vijay
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Run Vijay using this command.
|
14
|
+
|
15
|
+
```
|
16
|
+
vijay config.yml
|
17
|
+
```
|
18
|
+
|
19
|
+
The config must be a YAML file with the following format.
|
20
|
+
|
21
|
+
```yml
|
22
|
+
servers:
|
23
|
+
172.16.0.1:
|
24
|
+
user: someuser
|
25
|
+
pass: somepass
|
26
|
+
172.16.0.2:
|
27
|
+
user: someuser
|
28
|
+
pass: somepass
|
29
|
+
files:
|
30
|
+
/etc/hosts: c00db144055821cd01c1cd087fc7ad1e
|
31
|
+
/etc/resolv.conf: afb773b653b26779358391137d0fbcc0
|
32
|
+
```
|
33
|
+
|
34
|
+
Sample output:
|
35
|
+
|
36
|
+
```
|
37
|
+
[Vijay] Inspection started at 2015-11-06 23:11:45 +0700 and finished at 2015-11-06 23:11:47 +0700
|
38
|
+
[Vijay] Inspection conducted in 1 server(s) for 2 file(s)
|
39
|
+
[Vijay] Files altered on host 172.16.0.1:
|
40
|
+
[Vijay] - /etc/resolv.conf
|
41
|
+
```
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
MIT License
|
46
|
+
|
47
|
+
## Author
|
48
|
+
|
49
|
+
[Edwin Tunggawan](http://github.com/sdsdkkk)
|
data/bin/vijay
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift "#{File.expand_path(File.dirname(__FILE__))}/../lib"
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'vijay'
|
8
|
+
|
9
|
+
if ARGV.count < 1
|
10
|
+
puts 'Usage:'
|
11
|
+
puts ' vijay <inspector configuration file>'
|
12
|
+
puts ''
|
13
|
+
puts 'Inspector configuration file must be a YAML file with the following format.'
|
14
|
+
puts ''
|
15
|
+
puts 'servers:'
|
16
|
+
puts ' 172.16.0.1:'
|
17
|
+
puts ' user: someuser'
|
18
|
+
puts ' pass: somepass'
|
19
|
+
puts ' 172.16.0.2:'
|
20
|
+
puts ' user: someuser'
|
21
|
+
puts ' pass: somepass'
|
22
|
+
puts 'files:'
|
23
|
+
puts ' /etc/hosts: c00db144055821cd01c1cd087fc7ad1e'
|
24
|
+
puts ' /etc/resolv.conf: afb773b653b26779358391137d0fbcc0'
|
25
|
+
else
|
26
|
+
inspector = Vijay::Inspector.new(ARGV[0])
|
27
|
+
inspector.inspect!
|
28
|
+
inspector.report
|
29
|
+
end
|
data/lib/vijay.rb
ADDED
data/lib/vijay/file.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'net/ssh'
|
3
|
+
|
4
|
+
module Vijay
|
5
|
+
class Inspector
|
6
|
+
attr_reader :servers, :files
|
7
|
+
|
8
|
+
def initialize(filename)
|
9
|
+
config_data = YAML.load_file filename
|
10
|
+
list_servers!(config_data["servers"])
|
11
|
+
list_files!(config_data["files"])
|
12
|
+
end
|
13
|
+
|
14
|
+
def inspect!
|
15
|
+
@altered_files = {}
|
16
|
+
@start_time = Time.now
|
17
|
+
@servers.each do |server|
|
18
|
+
altered = []
|
19
|
+
Net::SSH.start(server.host, server.user, password: server.password) do |ssh|
|
20
|
+
@files.each do |file|
|
21
|
+
digest = ssh.exec!("md5sum #{file.name}").split(' ').first
|
22
|
+
altered << file.name if file.altered?(digest)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
@altered_files[server.host] = altered unless altered.empty?
|
26
|
+
end
|
27
|
+
@end_time = Time.now
|
28
|
+
end
|
29
|
+
|
30
|
+
def report
|
31
|
+
puts "[Vijay] Inspection started at #{@start_time} and finished at #{@end_time}"
|
32
|
+
puts "[Vijay] Inspection conducted in #{@servers.count} server(s) for #{@files.count} file(s)"
|
33
|
+
if @altered_files.empty?
|
34
|
+
puts "[Vijay] No altered files detected"
|
35
|
+
else
|
36
|
+
puts "[Vijay] Altered files detected!"
|
37
|
+
end
|
38
|
+
@altered_files.each do |k, v|
|
39
|
+
puts "[Vijay] Files altered on host #{k}:"
|
40
|
+
v.each do |f|
|
41
|
+
puts "[Vijay] - #{f}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
def list_servers!(servers)
|
48
|
+
@servers = []
|
49
|
+
servers && servers.each do |k, v|
|
50
|
+
@servers << ::Vijay::Server.new(k, v)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def list_files!(files)
|
55
|
+
@files = []
|
56
|
+
files && files.each do |k, v|
|
57
|
+
@files << ::Vijay::File.new(k, v)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/vijay/server.rb
ADDED
data/vijay.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vijay/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "vijay"
|
8
|
+
gem.version = Vijay::VERSION
|
9
|
+
gem.authors = ["Edwin Tunggawan"]
|
10
|
+
gem.email = ["vcc.edwint@gmail.com"]
|
11
|
+
gem.description = %q{Making sure your remote config is not tampered}
|
12
|
+
gem.summary = %q{Checking for altered configuration files in the remote host}
|
13
|
+
gem.homepage = "https://github.com/sdsdkkk/vijay"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib", "lib/vijay"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vijay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Edwin Tunggawan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Making sure your remote config is not tampered
|
14
|
+
email:
|
15
|
+
- vcc.edwint@gmail.com
|
16
|
+
executables:
|
17
|
+
- vijay
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- Gemfile
|
23
|
+
- Gemfile.lock
|
24
|
+
- LICENSE
|
25
|
+
- README.md
|
26
|
+
- bin/vijay
|
27
|
+
- lib/vijay.rb
|
28
|
+
- lib/vijay/file.rb
|
29
|
+
- lib/vijay/inspector.rb
|
30
|
+
- lib/vijay/server.rb
|
31
|
+
- lib/vijay/version.rb
|
32
|
+
- vijay.gemspec
|
33
|
+
homepage: https://github.com/sdsdkkk/vijay
|
34
|
+
licenses: []
|
35
|
+
metadata: {}
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
- lib/vijay
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 2.2.2
|
54
|
+
signing_key:
|
55
|
+
specification_version: 4
|
56
|
+
summary: Checking for altered configuration files in the remote host
|
57
|
+
test_files: []
|