Protect new subsystems against empty event in APIs

This commit is contained in:
DanB
2018-04-23 18:27:36 +02:00
parent 54ffa4b9a6
commit 92a5b349fb
5 changed files with 26 additions and 2 deletions

View File

@@ -328,6 +328,8 @@ func (tS *ThresholdService) processEvent(args *ArgsProcessEvent) (hits int, err
func (tS *ThresholdService) V1ProcessEvent(args *ArgsProcessEvent, reply *int) (err error) {
if missing := utils.MissingStructFields(args, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
} else if args.CGREvent.Event == nil {
return utils.NewErrMandatoryIeMissing("Event")
}
if hits, err := tS.processEvent(args); err != nil {
return err
@@ -341,6 +343,8 @@ func (tS *ThresholdService) V1ProcessEvent(args *ArgsProcessEvent, reply *int) (
func (tS *ThresholdService) V1GetThresholdsForEvent(args *ArgsProcessEvent, reply *Thresholds) (err error) {
if missing := utils.MissingStructFields(args, []string{"Tenant", "ID"}); len(missing) != 0 { //Params missing
return utils.NewErrMandatoryIeMissing(missing...)
} else if args.CGREvent.Event == nil {
return utils.NewErrMandatoryIeMissing("Event")
}
var ts Thresholds
if ts, err = tS.matchingThresholdsForEvent(args); err == nil {