From 7433efe35fa25d85d81d048105dc6e7571cd16eb Mon Sep 17 00:00:00 2001 From: Mostafa Moradian Date: Sun, 29 Sep 2024 21:21:41 +0200 Subject: [PATCH] Move constants to a separate file --- plugin/constants.go | 28 ++++++++++++++++++++++++++++ plugin/plugin.go | 29 ++--------------------------- 2 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 plugin/constants.go diff --git a/plugin/constants.go b/plugin/constants.go new file mode 100644 index 0000000..d2ff29b --- /dev/null +++ b/plugin/constants.go @@ -0,0 +1,28 @@ +package plugin + +const ( + DecodedQueryField string = "decodedQuery" + DetectorField string = "detector" + ScoreField string = "score" + QueryField string = "query" + ErrorField string = "error" + IsInjectionField string = "is_injection" + ResponseField string = "response" + OutputsField string = "outputs" + TokensField string = "tokens" + StringField string = "String" + ResponseTypeField string = "response_type" + + DeepLearningModel string = "deep_learning_model" + Libinjection string = "libinjection" + + ResponseType string = "error" + ErrorSeverity string = "EXCEPTION" + ErrorNumber string = "42000" + ErrorMessage string = "SQL injection detected" + ErrorDetail string = "Back off, you're not welcome here." + LogLevel string = "error" + + TokenizeAndSequencePath string = "/tokenize_and_sequence" + PredictPath string = "/v1/models/%s/versions/%s:predict" +) diff --git a/plugin/plugin.go b/plugin/plugin.go index 11c4abe..0cc72db 100644 --- a/plugin/plugin.go +++ b/plugin/plugin.go @@ -20,36 +20,10 @@ import ( "google.golang.org/grpc" ) -const ( - DecodedQueryField string = "decodedQuery" - DetectorField string = "detector" - ScoreField string = "score" - QueryField string = "query" - ErrorField string = "error" - IsInjectionField string = "is_injection" - ResponseField string = "response" - OutputsField string = "outputs" - TokensField string = "tokens" - StringField string = "String" - ResponseTypeField string = "response_type" - - DeepLearningModel string = "deep_learning_model" - Libinjection string = "libinjection" - - ResponseType string = "error" - ErrorSeverity string = "EXCEPTION" - ErrorNumber string = "42000" - ErrorMessage string = "SQL injection detected" - ErrorDetail string = "Back off, you're not welcome here." - LogLevel string = "error" - - TokenizeAndSequencePath string = "/tokenize_and_sequence" - PredictPath string = "/v1/models/%s/versions/%s:predict" -) - type Plugin struct { goplugin.GRPCPlugin v1.GatewayDPluginServiceServer + Logger hclog.Logger Threshold float32 EnableLibinjection bool @@ -68,6 +42,7 @@ type Plugin struct { type InjectionDetectionPlugin struct { goplugin.NetRPCUnsupportedPlugin + Impl Plugin }