diff --git a/internal/operators/pm_from_file.go b/internal/operators/pm_from_file.go index 035a448e..d15d48c4 100644 --- a/internal/operators/pm_from_file.go +++ b/internal/operators/pm_from_file.go @@ -51,5 +51,6 @@ func newPMFromFile(options plugintypes.OperatorOptions) (plugintypes.Operator, e } func init() { - Register("pmFromFile", newPMFromFile) + Register("pmFromFile", newPMFromFile) + Register("pmf", newPMFromFile) } diff --git a/internal/operators/pm_from_file_test.go b/internal/operators/pm_from_file_test.go new file mode 100644 index 00000000..2fa6849d --- /dev/null +++ b/internal/operators/pm_from_file_test.go @@ -0,0 +1,27 @@ +package operators +import ( + "testing" + + "github.com/corazawaf/coraza/v3/experimental/plugins/plugintypes" +) +func TestPmFromFileAlias(t *testing.T) { + opts := plugintypes.OperatorOptions{ + Arguments: "test_1", + Datasets: map[string][]string{ + "test_1": {"value1", "value2"}, + }, + } + pm, err := newPM(opts) + if err != nil { + t.Fatalf("Failed to initialize pm: %v", err) + } + pmFromFile, err := newPMFromFile(opts) + if err != nil { + t.Fatalf("Failed to initialize pmFromFile: %v", err) + } + input := "value1" + if pm.Evaluate(nil, input) != pmFromFile.Evaluate(nil, input) { + t.Errorf("pm and pmFromFile returned different results for input: %s", input) + } +} +