Skip to content

Commit

Permalink
Move constants to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Sep 29, 2024
1 parent 8c38532 commit 7433efe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
28 changes: 28 additions & 0 deletions plugin/constants.go
Original file line number Diff line number Diff line change
@@ -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"
)
29 changes: 2 additions & 27 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -68,6 +42,7 @@ type Plugin struct {

type InjectionDetectionPlugin struct {
goplugin.NetRPCUnsupportedPlugin

Impl Plugin
}

Expand Down

0 comments on commit 7433efe

Please sign in to comment.