From 360e148f85d9e0f820b044b68337c637055cabdc Mon Sep 17 00:00:00 2001 From: Kjell Hedstrom Date: Fri, 22 May 2015 15:34:30 -0600 Subject: [PATCH 1/4] Added LuaDefined proto for Lua import/export/load --- protofiles/CommandRequest.proto | 1 + protofiles/LuaDefinedRule.proto | 32 ++++++++++++++++++++++++++++++++ scripts/buildProtoFiles.sh | 3 +++ 3 files changed, 36 insertions(+) create mode 100644 protofiles/LuaDefinedRule.proto diff --git a/protofiles/CommandRequest.proto b/protofiles/CommandRequest.proto index 2c250d2e86375..157b8a2bb8338 100644 --- a/protofiles/CommandRequest.proto +++ b/protofiles/CommandRequest.proto @@ -21,6 +21,7 @@ message CommandRequest { PCAP_RECONSTRUCTION = 10; LICENSE = 11; MACHINE_ID = 12; + LUA_IMPORT = 13; } required CommandType type = 1; optional string stringArgOne = 2; diff --git a/protofiles/LuaDefinedRule.proto b/protofiles/LuaDefinedRule.proto new file mode 100644 index 0000000000000..dd03ccfc27922 --- /dev/null +++ b/protofiles/LuaDefinedRule.proto @@ -0,0 +1,32 @@ +package protoMsg; + +option java_package = "com.logrhythm.nm.message"; +option java_outer_classname = "LuaDefinedRuleMsg"; + + + + +message LuaImport { + enum LuaType { + CUSTOM = 0; + SYSTEM = 1; + } + + enum LuaExecution { + PACKET_RULE = 0; + FLOW_RULE = 1; + } + + + required LuaType type = 1; + required string content =2; + + optional string name = 3; + optional bool enabled = 4; + optional string description = 5; + optional string author = 6; + optional string uuid = 7; + optional uint64 last_modified_date =8; +} + + diff --git a/scripts/buildProtoFiles.sh b/scripts/buildProtoFiles.sh index 32b560cb57357..ef1ddccac4080 100755 --- a/scripts/buildProtoFiles.sh +++ b/scripts/buildProtoFiles.sh @@ -80,6 +80,7 @@ cd "$cppSrcDir" "$protoc" -I="$protoFileDir":$thirdPartyDir:/usr/include:$DISTDIR/protobuf/include --cpp_out=libprocess "$protoFileDir"/ProcessRequest.proto "$protoc" -I="$protoFileDir":$thirdPartyDir:/usr/include:$DISTDIR/protobuf/include --cpp_out=libprocess "$protoFileDir"/ProcessReply.proto "$protoc" -I="$protoFileDir":$thirdPartyDir:/usr/include:$DISTDIR/protobuf/include --cpp_out=libcommand "$protoFileDir"/DriveInfo.proto +"$protoc" -I="$protoFileDir":$thirdPartyDir:/usr/include:$DISTDIR/protobuf/include --cpp_out=libcommand "$protoFileDir"/LuaDefinedRule.proto "$protoc" -I="$protoFileDir":$thirdPartyDir:/usr/include:$DISTDIR/protobuf/include --cpp_out=libcommand "$protoFileDir"/ConfigDefaults.proto "$protoc" -I="$protoFileDir":$thirdPartyDir:/usr/include:$DISTDIR/protobuf/include --cpp_out=libcommand "$protoFileDir"/ConfigDefaultsRequest.proto "$protoc" -I="$protoFileDir":$thirdPartyDir:/usr/include:$DISTDIR/protobuf/include --cpp_out=libfork "$protoFileDir"/ForkerReply.proto @@ -109,6 +110,8 @@ mv libcommand/CommandReply.pb.cc libcommand/CommandReply.pb.cpp mv libprocess/ProcessRequest.pb.cc libprocess/ProcessRequest.pb.cpp mv libprocess/ProcessReply.pb.cc libprocess/ProcessReply.pb.cpp mv libcommand/DriveInfo.pb.cc libcommand/DriveInfo.pb.cpp +mv libcommand/LuaDefinedRule.pb.cc libcommand/LuaDefinedRule.pb.cpp + mv libcommand/ConfigDefaults.pb.cc libcommand/ConfigDefaults.pb.cpp mv libcommand/ConfigDefaultsRequest.pb.cc libcommand/ConfigDefaultsRequest.pb.cpp mv libfork/ForkerReply.pb.cc libfork/ForkerReply.pb.cpp From 0363e32816c2835df779f647dd617ada7c945bde Mon Sep 17 00:00:00 2001 From: Kjell Hedstrom Date: Fri, 22 May 2015 17:14:50 -0600 Subject: [PATCH 2/4] After code review --- protofiles/CommandRequest.proto | 2 +- protofiles/LuaDefinedRule.proto | 48 ++++++++++++++++----------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/protofiles/CommandRequest.proto b/protofiles/CommandRequest.proto index 157b8a2bb8338..3813149d931c0 100644 --- a/protofiles/CommandRequest.proto +++ b/protofiles/CommandRequest.proto @@ -21,7 +21,7 @@ message CommandRequest { PCAP_RECONSTRUCTION = 10; LICENSE = 11; MACHINE_ID = 12; - LUA_IMPORT = 13; + LUA_SAVE = 13; } required CommandType type = 1; optional string stringArgOne = 2; diff --git a/protofiles/LuaDefinedRule.proto b/protofiles/LuaDefinedRule.proto index dd03ccfc27922..63b600272910a 100644 --- a/protofiles/LuaDefinedRule.proto +++ b/protofiles/LuaDefinedRule.proto @@ -5,28 +5,28 @@ option java_outer_classname = "LuaDefinedRuleMsg"; - -message LuaImport { - enum LuaType { - CUSTOM = 0; - SYSTEM = 1; - } - - enum LuaExecution { - PACKET_RULE = 0; - FLOW_RULE = 1; +message LuaRules { + message LuaDefinedRule { + enum LuaType { + CUSTOM = 0; + SYSTEM = 1; + } + + enum LuaExecution { + PACKET_RULE = 0; + FLOW_RULE = 1; + } + + required LuaType type = 1; + required string content =2; + + optional string name = 3; + optional bool enabled = 4; + optional string description = 5; + optional string author = 6; + optional string uuid = 7; + optional uint64 last_modified_date =8; } - - - required LuaType type = 1; - required string content =2; - - optional string name = 3; - optional bool enabled = 4; - optional string description = 5; - optional string author = 6; - optional string uuid = 7; - optional uint64 last_modified_date =8; -} - - + + repeated LuaDefinedRule rules =1; +} \ No newline at end of file From a3248cc397def058f8af3da4393e60cce7cf6da1 Mon Sep 17 00:00:00 2001 From: Kjell Hedstrom Date: Tue, 26 May 2015 12:06:11 -0600 Subject: [PATCH 3/4] Updated with separation of LuaDefinedRules and the repeated rules to send. When sending the LuaDefinedRule will be in serialized (string) format --- protofiles/LuaDefinedRule.proto | 53 ++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/protofiles/LuaDefinedRule.proto b/protofiles/LuaDefinedRule.proto index 63b600272910a..684e112a5d4a5 100644 --- a/protofiles/LuaDefinedRule.proto +++ b/protofiles/LuaDefinedRule.proto @@ -1,32 +1,37 @@ package protoMsg; option java_package = "com.logrhythm.nm.message"; -option java_outer_classname = "LuaDefinedRuleMsg"; +option java_outer_classname = "LuaRulesMsg"; +message LuaDefinedRule { + enum LuaType { + CUSTOM = 0; + SYSTEM = 1; + } -message LuaRules { - message LuaDefinedRule { - enum LuaType { - CUSTOM = 0; - SYSTEM = 1; - } - - enum LuaExecution { - PACKET_RULE = 0; - FLOW_RULE = 1; - } - - required LuaType type = 1; - required string content =2; - - optional string name = 3; - optional bool enabled = 4; - optional string description = 5; - optional string author = 6; - optional string uuid = 7; - optional uint64 last_modified_date =8; + enum LuaExecution { + PACKET_RULE = 0; + FLOW_RULE = 1; } - - repeated LuaDefinedRule rules =1; + + required LuaType type = 1; + required string content =2; + + optional string name = 3; + optional bool enabled = 4; + optional string description = 5; + optional string author = 6; + optional string uuid = 7; + optional uint64 last_modified_date =8; +} + + + +message LuaRules { + message LuaSerializedRule { + optional string uuid = 1; + required string rule = 2; + } + repeated LuaSerializedRule rules =1; } \ No newline at end of file From 615d9c852bddaacacbd5d5faaf11bd4e95c471fd Mon Sep 17 00:00:00 2001 From: Kjell Hedstrom Date: Tue, 26 May 2015 13:26:43 -0600 Subject: [PATCH 4/4] content -> code --- protofiles/LuaDefinedRule.proto | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protofiles/LuaDefinedRule.proto b/protofiles/LuaDefinedRule.proto index 684e112a5d4a5..4fe0bb54af99a 100644 --- a/protofiles/LuaDefinedRule.proto +++ b/protofiles/LuaDefinedRule.proto @@ -16,9 +16,9 @@ message LuaDefinedRule { } required LuaType type = 1; - required string content =2; + required string code =2; - optional string name = 3; + optional string name = 3; optional bool enabled = 4; optional string description = 5; optional string author = 6;