trisulrp 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/trisulrp/protocol.rb +2 -0
- data/lib/trisulrp/trp.pb.rb +24 -0
- data/lib/trisulrp/trp.proto +22 -0
- data/test/helper.rb +42 -0
- data/test/test_grep.rb +31 -0
- data/test/test_key_flows.rb +40 -29
- data/trisulrp.gemspec +5 -2
- metadata +7 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.7
|
data/lib/trisulrp/protocol.rb
CHANGED
@@ -247,6 +247,8 @@ module TrisulRP::Protocol
|
|
247
247
|
req.counter_group_info_request = TRP::CounterGroupInfoRequest.new(params)
|
248
248
|
when TRP::Message::Command::KEY_SESS_ACTIVITY_REQUEST
|
249
249
|
req.key_session_activity_request = TRP::KeySessionActivityRequest.new(params)
|
250
|
+
when TRP::Message::Command::GREP_REQUEST
|
251
|
+
req.grep_request = TRP::GrepRequest.new(params)
|
250
252
|
else
|
251
253
|
raise "Unknown TRP command ID"
|
252
254
|
end
|
data/lib/trisulrp/trp.pb.rb
CHANGED
@@ -63,6 +63,8 @@ module TRP
|
|
63
63
|
class ResourceGroupResponse < ::ProtocolBuffers::Message; end
|
64
64
|
class KeyLookupRequest < ::ProtocolBuffers::Message; end
|
65
65
|
class KeyLookupResponse < ::ProtocolBuffers::Message; end
|
66
|
+
class GrepRequest < ::ProtocolBuffers::Message; end
|
67
|
+
class GrepResponse < ::ProtocolBuffers::Message; end
|
66
68
|
|
67
69
|
# enums
|
68
70
|
module AuthLevel
|
@@ -216,6 +218,8 @@ module TRP
|
|
216
218
|
RESOURCE_GROUP_RESPONSE = 49
|
217
219
|
KEY_LOOKUP_REQUEST = 50
|
218
220
|
KEY_LOOKUP_RESPONSE = 51
|
221
|
+
GREP_REQUEST = 60
|
222
|
+
GREP_RESPONSE = 61
|
219
223
|
end
|
220
224
|
|
221
225
|
required ::TRP::Message::Command, :trp_command, 1
|
@@ -263,6 +267,8 @@ module TRP
|
|
263
267
|
optional ::TRP::ResourceGroupResponse, :resource_group_response, 48
|
264
268
|
optional ::TRP::KeyLookupRequest, :key_lookup_request, 49
|
265
269
|
optional ::TRP::KeyLookupResponse, :key_lookup_response, 50
|
270
|
+
optional ::TRP::GrepRequest, :grep_request, 51
|
271
|
+
optional ::TRP::GrepResponse, :grep_response, 52
|
266
272
|
|
267
273
|
gen_methods! # new fields ignored after this point
|
268
274
|
end
|
@@ -731,4 +737,22 @@ module TRP
|
|
731
737
|
gen_methods! # new fields ignored after this point
|
732
738
|
end
|
733
739
|
|
740
|
+
class GrepRequest < ::ProtocolBuffers::Message
|
741
|
+
optional :int64, :context, 1, :default => 0
|
742
|
+
optional :string, :session_group, 2, :default => "{99A78737-4B41-4387-8F31-8077DB917336}"
|
743
|
+
required ::TRP::TimeInterval, :time_interval, 3
|
744
|
+
optional :int64, :maxitems, 4, :default => 500
|
745
|
+
required :string, :pattern, 5
|
746
|
+
|
747
|
+
gen_methods! # new fields ignored after this point
|
748
|
+
end
|
749
|
+
|
750
|
+
class GrepResponse < ::ProtocolBuffers::Message
|
751
|
+
optional :int64, :context, 1
|
752
|
+
optional :string, :session_group, 2, :default => "{99A78737-4B41-4387-8F31-8077DB917336}"
|
753
|
+
repeated ::TRP::SessionID, :sessions, 3
|
754
|
+
|
755
|
+
gen_methods! # new fields ignored after this point
|
756
|
+
end
|
757
|
+
|
734
758
|
end
|
data/lib/trisulrp/trp.proto
CHANGED
@@ -126,6 +126,8 @@ message Message {
|
|
126
126
|
RESOURCE_GROUP_RESPONSE=49;
|
127
127
|
KEY_LOOKUP_REQUEST=50;
|
128
128
|
KEY_LOOKUP_RESPONSE=51;
|
129
|
+
GREP_REQUEST=60;
|
130
|
+
GREP_RESPONSE=61;
|
129
131
|
}
|
130
132
|
|
131
133
|
required Command trp_command=1;
|
@@ -173,6 +175,8 @@ message Message {
|
|
173
175
|
optional ResourceGroupResponse resource_group_response=48;
|
174
176
|
optional KeyLookupRequest key_lookup_request=49;
|
175
177
|
optional KeyLookupResponse key_lookup_response=50;
|
178
|
+
optional GrepRequest grep_request=51;
|
179
|
+
optional GrepResponse grep_response=52;
|
176
180
|
}
|
177
181
|
|
178
182
|
///////////////////////////////
|
@@ -617,3 +621,21 @@ message KeyLookupResponse {
|
|
617
621
|
repeated KeyDetails key_details=3;
|
618
622
|
}
|
619
623
|
|
624
|
+
////////////////////////////////////
|
625
|
+
// GrepRequest
|
626
|
+
message GrepRequest {
|
627
|
+
optional int64 context=1[default=0];
|
628
|
+
optional string session_group=2[default="{99A78737-4B41-4387-8F31-8077DB917336}"];
|
629
|
+
required TimeInterval time_interval=3;
|
630
|
+
optional int64 maxitems=4 [default=500];
|
631
|
+
required string pattern=5;
|
632
|
+
}
|
633
|
+
|
634
|
+
/////////////////////////////////////
|
635
|
+
// GrepResponse
|
636
|
+
message GrepResponse {
|
637
|
+
optional int64 context=1;
|
638
|
+
optional string session_group=2[default="{99A78737-4B41-4387-8F31-8077DB917336}"];
|
639
|
+
repeated SessionID sessions=3;
|
640
|
+
}
|
641
|
+
|
data/test/helper.rb
CHANGED
@@ -15,4 +15,46 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
15
15
|
require 'trisulrp'
|
16
16
|
|
17
17
|
class Test::Unit::TestCase
|
18
|
+
|
19
|
+
# helper function to get session info and print in a table
|
20
|
+
def print_session_details(conn,sessions)
|
21
|
+
all_sids = sessions.collect{ |ai| TRP::SessionID.new(
|
22
|
+
:slice_id => ai.slice_id,
|
23
|
+
:session_id => ai.session_id ) }
|
24
|
+
|
25
|
+
follow_up = TrisulRP::Protocol.mk_request(TRP::Message::Command::SESSION_ITEM_REQUEST,
|
26
|
+
:session_ids => all_sids)
|
27
|
+
|
28
|
+
TrisulRP::Protocol.get_response(conn,follow_up) do |resp|
|
29
|
+
resp.session_item_response.items.each do |item|
|
30
|
+
print "#{item.session_id.slice_id},#{item.session_id.session_id} "
|
31
|
+
print "#{Time.at(item.time_interval.from.tv_sec)} "
|
32
|
+
print "#{item.time_interval.to.tv_sec-item.time_interval.from.tv_sec} ".rjust(8)
|
33
|
+
print "#{item.key1A.label}".ljust(28)
|
34
|
+
print "#{item.key2A.label}".ljust(11)
|
35
|
+
print "#{item.key1Z.label}".ljust(28)
|
36
|
+
print "#{item.key2Z.label}".ljust(11)
|
37
|
+
print "#{item.az_bytes}".rjust(10)
|
38
|
+
print "#{item.za_bytes}".rjust(10)
|
39
|
+
print "\n"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# convert a string to a key
|
45
|
+
def mk_trisul_key(guid,str)
|
46
|
+
req = TrisulRP::Protocol.mk_request(TRP::Message::Command::SEARCH_KEYS_REQUEST,
|
47
|
+
:pattern => str,
|
48
|
+
:counter_group => guid,
|
49
|
+
:maxitems => 1)
|
50
|
+
|
51
|
+
resp = TrisulRP::Protocol.get_response(@conn,req)
|
52
|
+
|
53
|
+
if resp.search_keys_response.found_keys.size > 0
|
54
|
+
resp.search_keys_response.found_keys[0].key
|
55
|
+
else
|
56
|
+
str
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
18
60
|
end
|
data/test/test_grep.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
|
2
|
+
# Trisul Remote Protocol TRP Demo script
|
3
|
+
require 'rubygems'
|
4
|
+
require './helper'
|
5
|
+
include TrisulRP::Protocol
|
6
|
+
include TrisulRP::Keys
|
7
|
+
|
8
|
+
class TestTrisulrp < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def test_grep
|
11
|
+
|
12
|
+
|
13
|
+
conn=TrisulRP::Protocol.connect("127.0.0.1", 12001,"Demo_Client.crt","Demo_Client.key")
|
14
|
+
|
15
|
+
avail_tm = TrisulRP::Protocol.get_available_time(conn)
|
16
|
+
|
17
|
+
req = TrisulRP::Protocol.mk_request(TRP::Message::Command::GREP_REQUEST,
|
18
|
+
:time_interval => mk_time_interval(avail_tm),
|
19
|
+
:maxitems => 4,
|
20
|
+
:pattern => "HELO footballbat2.usma.bluenet")
|
21
|
+
|
22
|
+
|
23
|
+
TrisulRP::Protocol.get_response(conn,req) do |resp|
|
24
|
+
|
25
|
+
print_session_details(conn,resp.grep_response.sessions)
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
data/test/test_key_flows.rb
CHANGED
@@ -4,41 +4,52 @@
|
|
4
4
|
require 'rubygems'
|
5
5
|
require './helper'
|
6
6
|
include TrisulRP::Protocol
|
7
|
-
|
7
|
+
include TrisulRP::Guids
|
8
8
|
|
9
9
|
class TestTrisulrp < Test::Unit::TestCase
|
10
|
-
|
10
|
+
|
11
|
+
def setup
|
12
|
+
@conn = TrisulRP::Protocol.connect("127.0.0.1",12001,"Demo_Client.crt","Demo_Client.key")
|
13
|
+
end
|
14
|
+
|
15
|
+
def teardown
|
16
|
+
end
|
17
|
+
|
18
|
+
def atest_flows_for_host
|
11
19
|
|
12
20
|
target_key = "0A.01.3C.BB"
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
21
|
+
|
22
|
+
tmarr = TrisulRP::Protocol.get_available_time(@conn)
|
23
|
+
|
24
|
+
req = TrisulRP::Protocol.mk_request(TRP::Message::Command::KEY_SESS_ACTIVITY_REQUEST,
|
25
|
+
:key => target_key ,
|
26
|
+
:time_interval => mk_time_interval(tmarr))
|
27
|
+
|
28
|
+
TrisulRP::Protocol.get_response(@conn,req) do |resp|
|
29
|
+
print_session_details(@conn,resp.key_session_activity_response.sessions)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
# test flows for ssh
|
35
|
+
# note we need to convert the "ssh" into a key first
|
36
|
+
def test_flows_for_appname
|
37
|
+
|
38
|
+
target = "ssh"
|
39
|
+
target_key = mk_trisul_key(CG_APP,target)
|
40
|
+
|
41
|
+
tmarr = TrisulRP::Protocol.get_available_time(@conn)
|
42
|
+
|
43
|
+
req = TrisulRP::Protocol.mk_request(TRP::Message::Command::KEY_SESS_ACTIVITY_REQUEST,
|
44
|
+
:key => target_key ,
|
45
|
+
:time_interval => mk_time_interval(tmarr))
|
46
|
+
|
47
|
+
TrisulRP::Protocol.get_response(@conn,req) do |resp|
|
48
|
+
print_session_details(@conn,resp.key_session_activity_response.sessions)
|
40
49
|
end
|
50
|
+
|
41
51
|
end
|
52
|
+
|
42
53
|
end
|
43
54
|
|
44
55
|
|
data/trisulrp.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{trisulrp}
|
8
|
-
s.version = "1.2.
|
8
|
+
s.version = "1.2.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["vivek"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-02-17}
|
13
13
|
s.description = %q{This gem deals about the trisul remote protocol}
|
14
14
|
s.email = %q{vivek_rajagopal@yahoo.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -35,6 +35,8 @@ Gem::Specification.new do |s|
|
|
35
35
|
"test/helper.rb",
|
36
36
|
"test/test_alerts.rb",
|
37
37
|
"test/test_cap.rb",
|
38
|
+
"test/test_grep.rb",
|
39
|
+
"test/test_key.rb",
|
38
40
|
"test/test_key_flows.rb",
|
39
41
|
"test/test_resources.rb",
|
40
42
|
"test/test_trisulrp.rb",
|
@@ -50,6 +52,7 @@ Gem::Specification.new do |s|
|
|
50
52
|
"test/helper.rb",
|
51
53
|
"test/test_alerts.rb",
|
52
54
|
"test/test_cap.rb",
|
55
|
+
"test/test_grep.rb",
|
53
56
|
"test/test_key.rb",
|
54
57
|
"test/test_key_flows.rb",
|
55
58
|
"test/test_resources.rb",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 1.2.
|
8
|
+
- 7
|
9
|
+
version: 1.2.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- vivek
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-02-17 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -131,11 +131,12 @@ files:
|
|
131
131
|
- test/helper.rb
|
132
132
|
- test/test_alerts.rb
|
133
133
|
- test/test_cap.rb
|
134
|
+
- test/test_grep.rb
|
135
|
+
- test/test_key.rb
|
134
136
|
- test/test_key_flows.rb
|
135
137
|
- test/test_resources.rb
|
136
138
|
- test/test_trisulrp.rb
|
137
139
|
- trisulrp.gemspec
|
138
|
-
- test/test_key.rb
|
139
140
|
has_rdoc: true
|
140
141
|
homepage: http://github.com/vivekrajan/trisulrp
|
141
142
|
licenses:
|
@@ -150,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
151
|
requirements:
|
151
152
|
- - ">="
|
152
153
|
- !ruby/object:Gem::Version
|
153
|
-
hash: -
|
154
|
+
hash: -1049257823
|
154
155
|
segments:
|
155
156
|
- 0
|
156
157
|
version: "0"
|
@@ -174,6 +175,7 @@ test_files:
|
|
174
175
|
- test/helper.rb
|
175
176
|
- test/test_alerts.rb
|
176
177
|
- test/test_cap.rb
|
178
|
+
- test/test_grep.rb
|
177
179
|
- test/test_key.rb
|
178
180
|
- test/test_key_flows.rb
|
179
181
|
- test/test_resources.rb
|