barnyard2waldo 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 +17 -0
- data/.travis.yml +15 -0
- data/Gemfile +7 -0
- data/LICENSE +22 -0
- data/README.md +42 -0
- data/Rakefile +12 -0
- data/barnyard2waldo.gemspec +26 -0
- data/bin/waldo +12 -0
- data/build-gem.sh +16 -0
- data/lib/barnyard2waldo/cli.rb +55 -0
- data/lib/barnyard2waldo/main.rb +11 -0
- data/lib/barnyard2waldo/version.rb +5 -0
- data/lib/barnyard2waldo/where.rb +33 -0
- data/lib/barnyard2waldo.rb +16 -0
- data/test/data/barnyard.waldo +0 -0
- data/test/test_helper.rb +17 -0
- data/test/test_waldo.rb +29 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8ea356aadbeba9653bd72431d7ec048454b90eb7
|
4
|
+
data.tar.gz: 1ef02ba555722bd6f099692a7ae86b3c7619b77a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 31cc75f49de447912ed88026e94353fb92e4cab859f0c2d54804442a8bea729e5380b0f08a5635ec93af582dfffe5b0ca454a6b44adc4fa51abcb54f213fccdc
|
7
|
+
data.tar.gz: 2609c78812e21ad443354d2e06240133ad52256d4d86fe10f07afdb466818ecb1c1e54899f6f1954daf7fdb4cac690eceb446478625928d89ca83801f8064f78
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
before_install: "gem install bundler"
|
4
|
+
install: "bundle install"
|
5
|
+
|
6
|
+
script: "rake"
|
7
|
+
|
8
|
+
rvm:
|
9
|
+
- 1.9.3
|
10
|
+
- 2.0.0
|
11
|
+
- 2.1.1
|
12
|
+
|
13
|
+
addons:
|
14
|
+
code_climate:
|
15
|
+
repo_token: f6dd2e0a5649c0fca6e159ee735ea367d39035f1ba8c0e67ceea66dc894269d0
|
data/Gemfile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# Put other dynamic build / pre-release gems here.
|
7
|
+
# Putting gems in a Gemfile does not install them during gem install foo! - Only developement hybrid environments use this.
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Scott MacGregor
|
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,42 @@
|
|
1
|
+
# barnyard2-waldo
|
2
|
+
|
3
|
+
[](http://badge.fury.io/rb/barnyard2waldo)
|
4
|
+
[](http://badge.fury.io/rb/barnyard2waldo)
|
5
|
+
|
6
|
+
Describe the waldo bookmark for barnyard2
|
7
|
+
|
8
|
+
## Code Status
|
9
|
+
|
10
|
+
[](https://travis-ci.org/shadowbq/barnyard2-waldo)
|
11
|
+
[](https://codeclimate.com/github/shadowbq/barnyard2-waldo)
|
12
|
+
[](https://codeclimate.com/github/shadowbq/barnyard2-waldo)
|
13
|
+
[](http://github.com/shadowbq/barnyard2-waldo)
|
14
|
+
|
15
|
+
This simple scripts provides a decoded output for the barnyard2 bookmark file (waldo file)
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
`$> gem install barnyard2waldo`
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```shell
|
24
|
+
$> waldo
|
25
|
+
Barnyard spool: /var/log/snort/merged.log.1426175522
|
26
|
+
Record Idx: 119879
|
27
|
+
2015-03-12 11:52:02 -0400
|
28
|
+
```
|
29
|
+
|
30
|
+
## Extended Help
|
31
|
+
|
32
|
+
```shell
|
33
|
+
$> waldo -h
|
34
|
+
Usage: waldo [OPTIONS]
|
35
|
+
-b Bookmark file
|
36
|
+
Default: /var/spool/barnyard.waldo
|
37
|
+
Options::
|
38
|
+
-h, --help Display this screen
|
39
|
+
```
|
40
|
+
|
41
|
+
## Reference:
|
42
|
+
https://github.com/firnsy/barnyard2/blob/master/src/spooler.c
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
2
|
+
name = "barnyard2waldo"
|
3
|
+
require "#{name}/version"
|
4
|
+
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.platform = Gem::Platform::RUBY
|
8
|
+
gem.authors = ["shadowbq"]
|
9
|
+
gem.email = ["shadowbq@gmail.com"]
|
10
|
+
gem.description = %q{Describe the waldo bookmark for barnyard2}
|
11
|
+
gem.summary = gem.description
|
12
|
+
gem.homepage = "https://github.com/shadowbq/barnyard2-waldo"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($\)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.name = "barnyard2waldo"
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.version = Barnyard2::Waldo::VERSION
|
20
|
+
gem.license = 'MIT'
|
21
|
+
|
22
|
+
gem.add_development_dependency('bump', '~> 0.3')
|
23
|
+
gem.add_development_dependency('minitest', '~> 5.5')
|
24
|
+
gem.add_development_dependency('ansi', '~> 1.5')
|
25
|
+
gem.add_development_dependency('simplecov', '0.9.2')
|
26
|
+
end
|
data/bin/waldo
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
begin
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
Bundler.setup(:default)
|
6
|
+
rescue ::Exception => e
|
7
|
+
end
|
8
|
+
|
9
|
+
# Executable with absolute path to lib for hacking and development
|
10
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'barnyard2waldo', 'cli')
|
11
|
+
|
12
|
+
Barnyard2::Waldo::CLI.invoke
|
data/build-gem.sh
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
if [ -f ./README.md ] && [ -f ./LICENSE ];
|
4
|
+
then
|
5
|
+
echo "Removing old gem.."
|
6
|
+
gem uninstall -x barnyard2waldo
|
7
|
+
echo "Building gem.."
|
8
|
+
gem build barnyard2waldo.gemspec
|
9
|
+
echo "Installing gem.."
|
10
|
+
gem install barnyard2waldo-`bump current |grep -o [0-9].*`.gem
|
11
|
+
git status
|
12
|
+
echo "Validating gem.."
|
13
|
+
gem list --local |grep barnyard2waldo
|
14
|
+
else
|
15
|
+
echo "not in root gem directory, existing."
|
16
|
+
fi
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'barnyard2waldo'
|
3
|
+
|
4
|
+
|
5
|
+
module Barnyard2
|
6
|
+
module Waldo
|
7
|
+
class CLI
|
8
|
+
|
9
|
+
def self.invoke
|
10
|
+
self.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
options = {}
|
15
|
+
options[:bookmark] = Barnyard2::Waldo::Defaults::Bookmark
|
16
|
+
|
17
|
+
opt_parser = OptionParser.new do |opt|
|
18
|
+
opt.banner = "Usage: waldo [OPTIONS]"
|
19
|
+
|
20
|
+
opt.on("-b","Bookmark file"," Default: #{options[:bookmark]}") do |value|
|
21
|
+
options[:bookmark] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
opt.separator "Options::"
|
25
|
+
|
26
|
+
opt.on_tail("-h","--help","Display this screen") do
|
27
|
+
puts opt_parser
|
28
|
+
exit 0
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
#Verify the options
|
34
|
+
begin
|
35
|
+
# raise unless ARGV.size > 0
|
36
|
+
opt_parser.parse!
|
37
|
+
|
38
|
+
#If options fail display help
|
39
|
+
#rescue Exception => e
|
40
|
+
# puts e.message
|
41
|
+
# puts e.backtrace.inspect
|
42
|
+
rescue
|
43
|
+
puts opt_parser
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
finder = Barnyard2::Waldo::Where.new(options[:bookmark])
|
48
|
+
puts finder
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end #Class
|
53
|
+
|
54
|
+
end #module
|
55
|
+
end #module
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Barnyard2
|
2
|
+
module Waldo
|
3
|
+
|
4
|
+
class Where
|
5
|
+
|
6
|
+
attr_reader :spool_dir, :spool_filebase, :epoch, :record
|
7
|
+
|
8
|
+
def initialize (bookmark=Barnyard2::Waldo::Defaults::Bookmark)
|
9
|
+
fp = open(bookmark, 'rb')
|
10
|
+
s = fp.read(Barnyard2::Waldo::MAX_FILEPATH_BUF)
|
11
|
+
@spool_dir = s.strip
|
12
|
+
|
13
|
+
s = fp.read(Barnyard2::Waldo::MAX_FILEPATH_BUF)
|
14
|
+
@spool_filebase = s.strip
|
15
|
+
|
16
|
+
s = fp.read(Barnyard2::Waldo::UINT32_t)
|
17
|
+
@epoch = s.unpack('V').first
|
18
|
+
|
19
|
+
s = fp.read(Barnyard2::Waldo::UINT32_t)
|
20
|
+
@record = s.unpack('V').first
|
21
|
+
ensure
|
22
|
+
fp.close
|
23
|
+
end
|
24
|
+
|
25
|
+
# Unpack the bytes and the array:
|
26
|
+
def to_s
|
27
|
+
"Barnyard spool: #{@spool_dir}/#{@spool_filebase}.#{@epoch}\nRecord Idx: #{@record}\n#{Time.at(@epoch)}"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#STDLIBS
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
module Barnyard2
|
5
|
+
module Waldo
|
6
|
+
$:.unshift(File.dirname(__FILE__))
|
7
|
+
|
8
|
+
MAX_FILEPATH_BUF = 1024
|
9
|
+
UINT32_t = 4
|
10
|
+
|
11
|
+
require "barnyard2waldo/main"
|
12
|
+
require "barnyard2waldo/version"
|
13
|
+
require "barnyard2waldo/where"
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
Binary file
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter "/test/"
|
7
|
+
add_group "Bin", "/lib/cli"
|
8
|
+
add_group "Lib", "/lib"
|
9
|
+
end
|
10
|
+
|
11
|
+
gem "minitest"
|
12
|
+
require 'minitest/autorun'
|
13
|
+
require 'minitest/spec'
|
14
|
+
require 'minitest/pride'
|
15
|
+
|
16
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'barnyard2waldo', 'cli')
|
17
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'barnyard2waldo')
|
data/test/test_waldo.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'minitest/spec'
|
3
|
+
|
4
|
+
describe Barnyard2::Waldo::Where do
|
5
|
+
before do
|
6
|
+
@where = Barnyard2::Waldo::Where.new('test/data/barnyard.waldo')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "when looking for waldo" do
|
10
|
+
it "should seek correctly" do
|
11
|
+
@where.spool_dir.must_equal '/var/log/snort'
|
12
|
+
end
|
13
|
+
it "should respond positively" do
|
14
|
+
@where.spool_filebase.must_equal 'merged.log'
|
15
|
+
end
|
16
|
+
it "should return epoch" do
|
17
|
+
@where.epoch.must_equal 1426175522
|
18
|
+
end
|
19
|
+
it "should return the idx" do
|
20
|
+
@where.record.must_equal 119879
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "when asking to print" do
|
25
|
+
it "it should print the string" do
|
26
|
+
@where.to_s.must_equal "Barnyard spool: /var/log/snort/merged.log.1426175522\nRecord Idx: 119879\n2015-03-12 11:52:02 -0400"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: barnyard2waldo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- shadowbq
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bump
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ansi
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.2
|
69
|
+
description: Describe the waldo bookmark for barnyard2
|
70
|
+
email:
|
71
|
+
- shadowbq@gmail.com
|
72
|
+
executables:
|
73
|
+
- waldo
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- barnyard2waldo.gemspec
|
84
|
+
- bin/waldo
|
85
|
+
- build-gem.sh
|
86
|
+
- lib/barnyard2waldo.rb
|
87
|
+
- lib/barnyard2waldo/cli.rb
|
88
|
+
- lib/barnyard2waldo/main.rb
|
89
|
+
- lib/barnyard2waldo/version.rb
|
90
|
+
- lib/barnyard2waldo/where.rb
|
91
|
+
- test/data/barnyard.waldo
|
92
|
+
- test/test_helper.rb
|
93
|
+
- test/test_waldo.rb
|
94
|
+
homepage: https://github.com/shadowbq/barnyard2-waldo
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.2.2
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: Describe the waldo bookmark for barnyard2
|
118
|
+
test_files:
|
119
|
+
- test/data/barnyard.waldo
|
120
|
+
- test/test_helper.rb
|
121
|
+
- test/test_waldo.rb
|