trisulrp 3.2.43 → 4.2.54

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80cba7114005ca50ffa03b9e8eb08243a025123cddea8e6bb8953810b3100335
4
- data.tar.gz: 1bb31482b9a3959b9053cef73cd0cab05840a504c06309a1e93aba50e2af89f5
3
+ metadata.gz: 89c8e7d686d1d581859b36d4f0e55b87b61df14b1a8425aab15df7bb0bd3ddd0
4
+ data.tar.gz: 267c771796edad2ffc3ace07b044f636955be2b812dbdbf0da8f85a0d7a61cfb
5
5
  SHA512:
6
- metadata.gz: b80b17dc617b2757eb46e549290ee1a495224054870bd69ddbab4d7205805443704486a46b08972c21244b37d61b3d099d3e5e8dc32694f3260973fdddf529c1
7
- data.tar.gz: 0aaa32bdb2b1fc16a1c1a4a7a2b516c47914076b55b95f4a7f1fb46bb80b56e09db15a51208784b8470e01539a76c3b301b0143a75c3302ca9692f4b302f2c0a
6
+ metadata.gz: b94c828ed97e7e378407c61dda9425baf211af67d4070bd945c819bf19026f0a4c46cdcaeda501eba491a118eaf608096ca934b0f135772c42c82dd209770cbb
7
+ data.tar.gz: 6f028f639dee78260b013fd4aa6706221c61444bdd0691596060eb6a65667c3f713cc4aabb73da8b7cdb28fa2c5a992b0b3c26497618bb031dc88f9e50cd01e4
data/.gitignore ADDED
@@ -0,0 +1,54 @@
1
+ # rcov generated
2
+ coverage
3
+
4
+ # rdoc generated
5
+ rdoc
6
+
7
+ # yard generated
8
+ doc
9
+ .yardoc
10
+
11
+ # bundler
12
+ .bundle
13
+
14
+ # jeweler generated
15
+ pkg
16
+
17
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
18
+ #
19
+ # * Create a file at ~/.gitignore
20
+ # * Include files you want ignored
21
+ # * Run: git config --global core.excludesfile ~/.gitignore
22
+ #
23
+ # After doing this, these files will be ignored in all your git projects,
24
+ # saving you from having to 'pollute' every project you touch with them
25
+ #
26
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
27
+ #
28
+ # For MacOS:
29
+ #
30
+ #.DS_Store
31
+ #
32
+ # For TextMate
33
+ #*.tmproj
34
+ #tmtags
35
+ #
36
+ # For emacs:
37
+ #*~
38
+ #\#*
39
+ #.\#*
40
+ #
41
+ # For vim:
42
+ #*.swp
43
+
44
+ #Gemfile lock
45
+ Gemfile.lock
46
+
47
+ #ignore gitignore
48
+ .gitignore
49
+
50
+ #ignore svn
51
+ .svn
52
+ test/Demo_Client_Clear.key
53
+ test/t.pcap
54
+ #
data/Gemfile CHANGED
@@ -1,14 +1,3 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
- # Add dependencies required to use your gem here.
4
- gem "protobuf"
5
-
6
-
7
- # Add dependencies to develop your gem here.
8
- # Include everything needed to run rake, tests, features, etc.
9
- group :development do
10
- gem "shoulda"
11
- gem "bundler"
12
- gem "juwelier"
13
- gem "simplecov"
14
- end
3
+ gemspec
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- $SAFE=0
1
+ $SAFE=0 if defined?($SAFE)
2
2
  require 'rubygems'
3
3
  require 'bundler'
4
4
  begin
@@ -10,29 +10,27 @@ rescue Bundler::BundlerError => e
10
10
  end
11
11
  require 'rake'
12
12
 
13
- require 'juwelier'
14
- Juwelier::Tasks.new do |gem|
15
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
16
- gem.name = "trisulrp"
17
- gem.homepage = "http://github.com/vivekrajan/trisulrp"
18
- gem.license = "MIT"
19
- gem.summary = %Q{trisul trp}
20
- gem.description = %Q{This gem deals about the trisul remote protocol}
21
- gem.email = "vivek_rajagopal@yahoo.com"
22
- gem.authors = ["vivek"]
23
- # Include your dependencies below. Runtime dependencies are required when using your gem,
24
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
25
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
26
- # gem.add_development_dependency 'rspec', '> 1.2.3'
13
+ begin
14
+ require 'bundler/gem_tasks'
15
+ rescue LoadError
27
16
  end
28
- Juwelier::RubygemsDotOrgTasks.new
29
17
 
30
18
  require 'rdoc/task'
31
19
  Rake::RDocTask.new do |rdoc|
32
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
20
+ version = File.exist?('VERSION') ? File.read('VERSION').strip : ""
33
21
 
34
22
  rdoc.rdoc_dir = 'rdoc'
35
23
  rdoc.title = "trisulrp #{version}"
36
24
  rdoc.rdoc_files.include('README*')
37
25
  rdoc.rdoc_files.include('lib/**/*.rb')
38
26
  end
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << "test"
31
+ t.libs << "lib"
32
+ t.test_files = FileList['test/test_*.rb']
33
+ t.verbose = true
34
+ end
35
+
36
+ task :default => :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.43
1
+ 4.2.54
@@ -52,7 +52,7 @@ module TrisulRP::Protocol
52
52
  # * The client does not have permissions to connect with that cert
53
53
  # * The private key password is wrong
54
54
  #
55
- def connect(server,port,client_cert_file,client_key_file)
55
+ def connect1(server,port,client_cert_file,client_key_file)
56
56
  tcp_sock=TCPSocket.open(server,port)
57
57
  ctx = OpenSSL::SSL::SSLContext.new(:TLSv1)
58
58
  ctx.cert = OpenSSL::X509::Certificate.new(File.read(client_cert_file))
@@ -144,7 +144,7 @@ module TrisulRP::Protocol
144
144
  outbuf=""
145
145
 
146
146
  # out
147
- outbuf=trp_request.encode
147
+ outbuf=TRP::Message.encode(trp_request)
148
148
  ctx=ZMQ::Context.new
149
149
  sock = ctx.socket(ZMQ::REQ)
150
150
 
@@ -176,9 +176,8 @@ module TrisulRP::Protocol
176
176
  #in
177
177
  dataarray=""
178
178
  rsock.recv_string(dataarray)
179
- resp =TRP::Message.new
180
- resp.decode dataarray
181
- if resp.trp_command.to_i == TRP::Message::Command::ERROR_RESPONSE
179
+ resp = TRP::Message.decode(dataarray)
180
+ if resp.trp_command==TRP::Message::Command.lookup(5)
182
181
  print "TRP ErrorResponse: #{resp.error_response.error_message}\n"
183
182
  rsock.close
184
183
  ctx.terminate
@@ -188,7 +187,8 @@ module TrisulRP::Protocol
188
187
  rsock.close
189
188
  ctx.terminate
190
189
  unwrap_resp = unwrap_response(resp)
191
- unwrap_resp.instance_variable_set("@trp_resp_command_id",resp.trp_command.to_i)
190
+ cmd_id = resp.trp_command.is_a?(Symbol) ? TRP::Message::Command.resolve(resp.trp_command) : resp.trp_command.to_i
191
+ unwrap_resp.instance_variable_set("@trp_resp_command_id", cmd_id)
192
192
  yield unwrap_resp if block_given?
193
193
  return unwrap_resp
194
194
 
@@ -304,12 +304,11 @@ module TrisulRP::Protocol
304
304
  resp = get_response(conn,req)
305
305
  end
306
306
  rescue Exception=>ex
307
- raise ex
307
+ raise ex
308
308
  end
309
309
 
310
310
  from_tm = Time.at(resp.total_window.from.tv_sec)
311
311
  to_tm = Time.at(resp.total_window.to.tv_sec)
312
-
313
312
  return [from_tm,to_tm]
314
313
 
315
314
  end
@@ -376,25 +375,36 @@ module TrisulRP::Protocol
376
375
  params[:time_interval] = mk_time_interval(ti)
377
376
  end
378
377
 
378
+ # Ignore extra parameters that are not in the message descriptor
379
+ params.delete_if { |k, v| !msg.descriptor.lookup(k.to_s) }
380
+
379
381
  params.each do |k,v|
380
- f = msg.get_field(k)
382
+ f = msg.descriptor.lookup(k.to_s)
383
+ next unless f
381
384
  if v.is_a? String
382
- if f.is_a? Protobuf::Field::MessageField and f.type_class.to_s == "TRP::KeyT"
385
+ if f.type == :message and f.subtype and f.subtype.name == "TRP.KeyT"
383
386
  params[k] = TRP::KeyT.new( :label => v )
384
- elsif f.is_a? Protobuf::Field::Int64Field
387
+ elsif f.type == :int64 or f.type == :int32 or f.type == :uint64 or f.type == :uint32
385
388
  params[k] = v.to_i
386
- elsif f.is_a? Protobuf::Field::StringField and f.rule == :repeated
389
+ elsif f.type == :string and f.label == :repeated
387
390
  params[k] = v.split(',')
388
- elsif f.is_a? Protobuf::Field::BoolField
389
- params[k] = ( v == "true")
391
+ elsif f.type == :bool
392
+ params[k] = ( v == "true" || v == "1")
390
393
  end
391
394
  elsif v.is_a? BigDecimal or v.is_a? Float
392
- if f.is_a? Protobuf::Field::Int64Field
395
+ if f.type == :int64 or f.type == :int32 or f.type == :uint64 or f.type == :uint32
393
396
  params[k] = v.to_i
394
397
  end
395
- elsif v.is_a?Array and f.is_a?Protobuf::Field::MessageField and f.type_class.to_s == "TRP::KeyT"
396
- v.each_with_index do |v1,idx|
397
- v[idx]= TRP::KeyT.new( :label => v1 ) if v1.is_a?String
398
+ elsif v.is_a?Array
399
+ # unfreeze any strings inside the array
400
+ v.each_with_index do |v1, idx|
401
+ v[idx] = v1.dup if v1.is_a?(String) && v1.frozen?
402
+ end
403
+
404
+ if f.type == :message and f.subtype and f.subtype.name == "TRP.KeyT"
405
+ v.each_with_index do |v1,idx|
406
+ v[idx]= TRP::KeyT.new( :label => v1 ) if v1.is_a?String
407
+ end
398
408
  end
399
409
  end
400
410
  end
@@ -437,17 +447,24 @@ module TrisulRP::Protocol
437
447
  #
438
448
  #
439
449
  def mk_request(cmd_id,in_params={})
440
- params =in_params.dup
441
- opts = {:trp_command=> cmd_id}
442
- if params.has_key?(:destination_node)
443
- opts[:destination_node] = params[:destination_node]
444
- end
445
- if params.has_key?(:probe_id)
446
- opts[:probe_id] = params[:probe_id]
447
- end
448
- if params.has_key?(:run_async)
449
- opts[:run_async] = params[:run_async]
450
- end
450
+
451
+ # Duplicate hash and unfreeze any frozen strings to prevent google-protobuf FrozenError
452
+ params = {}
453
+ in_params.each do |k, v|
454
+ params[k] = (v.is_a?(String) && v.frozen?) ? v.dup : v
455
+ end
456
+
457
+ opts = {:trp_command=> cmd_id}
458
+ desc = TRP::Message.descriptor
459
+ if params.has_key?(:destination_node) && desc.lookup("destination_node")
460
+ opts[:destination_node] = params.delete(:destination_node)
461
+ end
462
+ if params.has_key?(:probe_id) && desc.lookup("probe_id")
463
+ opts[:probe_id] = params.delete(:probe_id)
464
+ end
465
+ if params.has_key?(:run_async) && desc.lookup("run_async")
466
+ opts[:run_async] = params.delete(:run_async)
467
+ end
451
468
  req = TRP::Message.new(opts)
452
469
  case cmd_id
453
470
  when TRP::Message::Command::HELLO_REQUEST
@@ -552,6 +569,27 @@ module TrisulRP::Protocol
552
569
  when TRP::Message::Command::TOOL_INFO_REQUEST
553
570
  fix_TRP_Fields( TRP::ToolInfoRequest, params)
554
571
  req.tool_info_request = TRP::ToolInfoRequest.new(params)
572
+ when TRP::Message::Command::UPDATE_SLICE_REQUEST
573
+ fix_TRP_Fields( TRP::UpdateSliceRequest, params)
574
+ req.update_slice_request = TRP::UpdateSliceRequest.new(params)
575
+ when TRP::Message::Command::COUNTER_ITEM_NG_REQUEST
576
+ fix_TRP_Fields( TRP::CounterItemNGRequest, params)
577
+ req.counter_item_ng_request = TRP::CounterItemNGRequest.new(params)
578
+ when TRP::Message::Command::CONTEXT_CREATE_REQUEST
579
+ fix_TRP_Fields( TRP::ContextCreateRequest, params)
580
+ req.context_create_request = TRP::ContextCreateRequest.new(params)
581
+ when TRP::Message::Command::CONTEXT_DELETE_REQUEST
582
+ fix_TRP_Fields( TRP::ContextDeleteRequest, params)
583
+ req.context_delete_request = TRP::ContextDeleteRequest.new(params)
584
+ when TRP::Message::Command::AGGREGATE_RESOURCES_REQUEST
585
+ fix_TRP_Fields( TRP::AggregateResourcesRequest, params)
586
+ req.aggregate_resources_request = TRP::AggregateResourcesRequest.new(params)
587
+ when TRP::Message::Command::HA_CONTROL_REQUEST
588
+ fix_TRP_Fields( TRP::HAControlRequest, params)
589
+ req.ha_control_request = TRP::HAControlRequest.new(params)
590
+ when TRP::Message::Command::DDOS_REPORT_REQUEST
591
+ fix_TRP_Fields( TRP::DDosReportRequest, params)
592
+ req.ddos_report_request = TRP::DDosReportRequest.new(params)
555
593
  else
556
594
  raise "Unknown TRP command ID"
557
595
  end
@@ -594,7 +632,8 @@ module TrisulRP::Protocol
594
632
  #
595
633
  #
596
634
  def unwrap_response(resp)
597
- case resp.trp_command.to_i
635
+ cmd_id = resp.trp_command.is_a?(Symbol) ? TRP::Message::Command.resolve(resp.trp_command) : resp.trp_command.to_i
636
+ case cmd_id
598
637
  when TRP::Message::Command::HELLO_RESPONSE
599
638
  resp.hello_response
600
639
  when TRP::Message::Command::COUNTER_GROUP_TOPPER_RESPONSE
@@ -655,6 +694,14 @@ module TrisulRP::Protocol
655
694
  resp.run_tool_response
656
695
  when TRP::Message::Command::TOOL_INFO_RESPONSE
657
696
  resp.tool_info_response
697
+ when TRP::Message::Command::UPDATE_SLICE_RESPONSE
698
+ resp.update_slice_response
699
+ when TRP::Message::Command::AGGREGATE_RESOURCES_RESPONSE
700
+ resp.aggregate_resources_response
701
+ when TRP::Message::Command::HA_CONTROL_RESPONSE
702
+ resp.ha_control_response
703
+ when TRP::Message::Command::DDOS_REPORT_RESPONSE
704
+ resp.ddos_report_response
658
705
  else
659
706
  raise "#{resp.trp_command.to_i} Unknown TRP command ID"
660
707
  end
@@ -6,7 +6,7 @@
6
6
  // Based on Google Protocol Buffers
7
7
  // (c) 2012-16, Unleash Networks (http://www.unleashnetworks.com)
8
8
  // $Rev: 6946 $
9
-
9
+ syntax = "proto2";
10
10
  option optimize_for = LITE_RUNTIME;
11
11
 
12
12
 
@@ -96,7 +96,7 @@ message KeyStats {
96
96
  /// Top level objects are named ObjT
97
97
  /// eg KeyT - Key Type, SessionT - Session Type etc.
98
98
  message KeyT {
99
- optional string key=1; /// key in trisul key format eg, C0.A8.01.02 for 192.168.1.2
99
+ optional string key=1; /// key in trisul key format eg, C0.A8.01.02
100
100
  optional string readable=2; /// human friendly name
101
101
  optional string label=3; /// a user label eg, a hostname or manually assigned name
102
102
  optional string description=4; /// description
@@ -190,6 +190,9 @@ message AlertT{
190
190
  optional string probe_id=16; /// probe generating this alert
191
191
  optional string alert_status=17; /// FIRE,CLEAR,BLOCK etc
192
192
  optional int64 acknowledge_flag=18; /// ACK or NOT
193
+ optional string tactic_id=19; /// from MITRE
194
+ optional string technique_id=20;
195
+ optional string subtechnique_id=21;
193
196
  }
194
197
 
195
198
 
@@ -374,7 +377,8 @@ message Message {
374
377
  TOOL_INFO_RESPONSE=144;
375
378
  DDOS_REPORT_REQUEST=153;
376
379
  DDOS_REPORT_RESPONSE=154;
377
-
380
+ UPDATE_SLICE_REQUEST=155;
381
+ COUNTER_ITEM_NG_REQUEST=156;
378
382
  }
379
383
 
380
384
  required Command trp_command=1;
@@ -450,6 +454,8 @@ message Message {
450
454
  optional ToolInfoResponse tool_info_response=153;
451
455
  optional DDosReportRequest ddos_report_request=154;
452
456
  optional DDosReportResponse ddos_report_response=155;
457
+ optional UpdateSliceRequest update_slice_request=156;
458
+ optional CounterItemNGRequest counter_item_ng_request=157;
453
459
  optional string destination_node=200; // todo move 2nd
454
460
  optional string probe_id=201; // todo move 3rd
455
461
  optional bool run_async=202; /// if run_async = true, then you will immediately get a AsynResponse with a token you can poll
@@ -519,8 +525,20 @@ message CounterItemResponse{
519
525
  optional StatsArray samples=8; /// if volumes_only = 1 this contains SAMPLES(..)
520
526
  optional StatsArray percentiles=9; /// if get_percentile > 0 this contains PERCENTILE(..) stream approx
521
527
  optional StatsArray latests=10; /// if volumes_only = 1 this contains LATEST(..)
528
+ optional StatsArray rate_volumes=11; /// if volumes_only = 1 this contains BUCKETSIZE*TOTALS(..) for Bps units to Volumes MB,GB
522
529
  }
523
530
 
531
+ /// CounterItemNGRequest : NG version works with multiple resolutions
532
+ /// Time series history statistics for an item
533
+ message CounterItemNGRequest{
534
+ required string counter_group=2; /// guid of counter group
535
+ optional int64 meter=3; /// optional meter, default will retrieve all (same cost)
536
+ required KeyT key=4; /// key (can specify key.key, key.label, etc too
537
+ required TimeInterval time_interval=5; /// Time interval for query
538
+ optional int64 volumes_only=6 [default=0]; /// if '1' ; then only retrieves totals for each meter
539
+ optional bool get_key_attributes=7 [default=false]; /// if true, response keys get key_attributes as well
540
+ optional int64 get_percentile=8[default=0]; /// enter 95 here if you want 95th percentile (using streaming)
541
+ }
524
542
 
525
543
  /// CounterGroupTopperRequest - retrieve toppers for a counter group (top-K)
526
544
  message CounterGroupTopperRequest{
@@ -641,6 +659,8 @@ message AggregateSessionsRequest {
641
659
  optional int64 aggregate_topcount=19[default=100]; /// number of count-star per field
642
660
  repeated string group_by_fields=20; /// list of field names
643
661
  optional KeyT any_nf_ifindex=21; /// matches either gen2 or gen3
662
+ repeated string custom_conversation_fields=22; /// string field names and taggroups to string
663
+ /// source_ip dest_ip dest_port NBAR ASN USERID
644
664
  }
645
665
 
646
666
  /// AggregateSessionsResponse
@@ -678,6 +698,7 @@ message AggregateSessionsResponse {
678
698
  repeated KeyTCount external_ip=20; /// external IPs
679
699
  repeated TagGroup tag_group=21; /// tag groups
680
700
  repeated KeyTCount conversation=22; /// conversation
701
+ repeated KeyTCount custom_conversation=23; /// custom conversation fields
681
702
  }
682
703
 
683
704
 
@@ -690,6 +711,14 @@ message UpdateKeyRequest{
690
711
  repeated string remove_attributes=6; /// remove these attributes only from keys
691
712
  }
692
713
 
714
+ /// UpdateSliceRequerst
715
+ /// Response = OKResponse or ErrorResponse
716
+ message UpdateSliceRequest {
717
+ required int64 id=1; /// the number slice_id
718
+ repeated string add_tags=2; /// tags to be added to slice
719
+ repeated string remove_tags=3; /// tags to be removed from slice
720
+ }
721
+
693
722
  /// SessionTrackerRequest - query session trackers
694
723
  /// session trackers are top-k streaming algorithm for network flows
695
724
  /// They are Top Sessions fulfilling a particular preset criterion
@@ -736,6 +765,9 @@ message QueryAlertsRequest {
736
765
  repeated KeyT ip_pair=20; /// array of 2 ips
737
766
  optional string message_regex=21; /// searech via regex of the dispatch message
738
767
  optional bool approx_count_only=22[default=false]; /// approx count per alert group
768
+ optional string tactic_id=23;
769
+ optional string technique_id=24; /// MITRE fields
770
+ optional string subtechnique_id=25;
739
771
  }
740
772
 
741
773
  /// QueryAlertsResponse - response
@@ -936,11 +968,27 @@ message TimeSlicesResponse {
936
968
  optional int64 disk_size=4;
937
969
  optional string path=5;
938
970
  optional bool available=6;
971
+ repeated string tags=7;
972
+ optional int64 id=8;
939
973
  };
940
974
 
975
+ message PoolT
976
+ {
977
+ required string status=1;
978
+ optional int64 total_size=2;
979
+ optional int64 avail_size=3;
980
+ optional string file_system=4;
981
+ optional string mounted=5;
982
+ optional bool offline_archive=6 [default=false];
983
+ optional bool offline_archive_mounted=7 [default=false];
984
+ optional string additional_info=8;
985
+ }
986
+
941
987
  repeated SliceT slices=1;
942
988
  optional TimeInterval total_window=2;
943
989
  optional string context_name=3;
990
+ repeated PoolT pools=4;
991
+ optional bool ha_slave_mode=5;
944
992
  }
945
993
 
946
994