1414 * limitations under the License.
1515 */
1616
17- import { Event , Handler } from '../../notification/service/notificationService' ;
17+ import axios from 'axios' ;
18+ import Engine from 'json-rules-engine' ;
19+ import moment from "moment-timezone" ;
1820import Mustache from 'mustache' ;
19- import Engine from 'json-rules-engine'
20- import { EventLogBuilder } from "../../common/eventLogBuilder"
21- import { EventLogRepository } from '../../repository/notifierEventLogRepository' ;
21+ import { EventLogBuilder } from "../../common/eventLogBuilder" ;
22+ import { MustacheHelper } from '../../common/mustacheHelper' ;
23+ import { EVENT_TYPE } from "../../common/types" ;
24+ import { NotificationSettings } from "../../entities/notificationSettings" ;
2225import { WebhookConfig } from '../../entities/webhookconfig' ;
23- import { NotificationSettings } from "../../entities/notificationSettings" ;
26+ import { Event , Handler } from '../../notification/service/notificationService' ;
27+ import { EventLogRepository } from '../../repository/notifierEventLogRepository' ;
2428import { WebhookConfigRepository } from '../../repository/webhookConfigRepository' ;
25- import { MustacheHelper } from '../../common/mustacheHelper' ;
26- import axios from 'axios' ;
27- import { EVENT_TYPE , WebhookParsedEvent } from "../../common/types" ;
28- import moment from "moment-timezone" ;
2929
3030export class WebhookService implements Handler {
3131 eventLogRepository : EventLogRepository
@@ -113,10 +113,10 @@ export class WebhookService implements Handler{
113113 if ( event . eventTypeId == EVENT_TYPE . ScoopNotification ) {
114114 const date = moment ( event . eventTime ) ;
115115 event . payload . scoopNotificationConfig . data . interceptedAt = date . unix ( ) ;
116- jsons = Mustache . render ( template , event . payload . scoopNotificationConfig . data ) ;
116+ jsons = Mustache . render ( Mustache . escape ( template ) , event . payload . scoopNotificationConfig . data ) ;
117117 } else {
118118 let parsedEvent = this . mh . parseEventForWebhook ( event as Event ) ;
119- jsons = Mustache . render ( template , parsedEvent ) ;
119+ jsons = Mustache . render ( Mustache . escape ( template ) , parsedEvent ) ;
120120 }
121121
122122 let j = JSON . parse ( jsons ) ;
@@ -149,4 +149,4 @@ export class WebhookService implements Handler{
149149 this . eventLogRepository . saveEventLog ( eventLog ) ;
150150 }
151151
152- }
152+ }
0 commit comments