Skip to content

Commit

Permalink
#9 Implement interface in the validator
Browse files Browse the repository at this point in the history
  • Loading branch information
thegodenage committed May 9, 2024
1 parent 775bc94 commit e8e0e5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/ddosml/forest.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func newRandomForestClassifier() *randomForestClassifier {
}
}

// AddNewClassifierModel adds new Request to the randomForestClassifier.
// EnhanceClassifierWithRequest adds new Request to the randomForestClassifier.
// The trees are regenerated in order to increase decision success.
func (r *randomForestClassifier) EnhanceClassifierWithRequest(m *Request) {
r.mu.Lock()
Expand Down
9 changes: 9 additions & 0 deletions internal/ddosml/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ddosml
import (
"context"
"io"
"net/http"
)

type Classifier interface {
Expand Down Expand Up @@ -30,3 +31,11 @@ func NewMlModelValidator(classifier Classifier) *MLBasedModelValidator {
classifier: classifier,
}
}

func (m *MLBasedModelValidator) ValidateRequest(ctx context.Context, req *http.Request) (bool, error) {
requestModel := Request{}

isDDOS := m.classifier.IsRequestPotentialDDOS(ctx, &requestModel)

return isDDOS, nil
}

0 comments on commit e8e0e5b

Please sign in to comment.