Skip to content

Commit bc18175

Browse files
vikramdevtrongireesh-naidueshankvaishdevopsdevtonkirandevtn
authored
misc: Release candidate v0.19.0 (#84)
* feat: configure cluster filter in notification settings (#78) * feat: add cluster filtering for configuring the notifications * test fix * fix: legacy query fix * fix: query fix for all prod/non prod environments * app and env combination case missing in legacy query * app and env combination case missing in legacy query * chore: comments added * chore: bump version for axios, braces and notifme-sdk * added mech for tagging of hotfixes * Update tag-patch-incre.yaml * Update tag-patch-incre.yaml --------- Co-authored-by: Eshank Vaish <[email protected]> Co-authored-by: systemsdt <[email protected]> Co-authored-by: Kiran <[email protected]> * chore: upgrade express to 4.21.0 * chore: upgrade body parser to 1.20.3 * fix: add Mustache.escape for template parsing --------- Co-authored-by: Gireesh Naidu <[email protected]> Co-authored-by: Eshank Vaish <[email protected]> Co-authored-by: systemsdt <[email protected]> Co-authored-by: Kiran <[email protected]> Co-authored-by: vivek-devtron <[email protected]> Co-authored-by: Vivekanand Pandey <[email protected]>
1 parent 0639239 commit bc18175

File tree

10 files changed

+1796
-282
lines changed

10 files changed

+1796
-282
lines changed

package-lock.json

Lines changed: 1562 additions & 198 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,27 @@
2323
"typescript": "^4.8.3"
2424
},
2525
"dependencies": {
26-
"@types/express": "^4.16.1",
26+
"@types/express": "^4.17.21",
2727
"@types/mustache": "^0.8.32",
2828
"@types/node": "^12.0.2",
2929
"@types/request": "^2.48.1",
30-
"body-parser": "^1.20.2",
31-
"axios": "1.6.8",
32-
"express": "^4.19.2",
30+
"axios": "^1.7.7",
31+
"body-parser": "^1.20.3",
32+
"express": "^4.21.0",
3333
"js-yaml": "^3.13.1",
3434
"json-rules-engine": "^2.3.6",
3535
"moment-timezone": "^0.5.31",
3636
"mustache": "^3.0.1",
3737
"nats": "2.10.0",
38-
"notifme-sdk": "^1.14.1",
38+
"notifme-sdk": "^1.16.13",
3939
"pg": "^8.2.1",
4040
"reflect-metadata": "^0.1.13",
4141
"typeorm": "0.3.17",
4242
"winston": "^3.2.1"
43+
},
44+
"overrides": {
45+
"node-gcm": {
46+
"axios": "1.7.7"
47+
}
4348
}
4449
}

src/common/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,7 @@ export enum EVENT_TYPE {
147147
ScoopNotification = 9,
148148
}
149149

150+
export enum ENV_TYPE_INT{
151+
AllExistingAndFutureProdEnvs = -2,
152+
AllExistingAndFutureNonProdEnvs = -1
153+
}

src/destination/destinationHandlers/sesHandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ export class SESService implements Handler {
182182
if(event.eventTypeId===4 || event.eventTypeId === EVENT_TYPE.ImagePromotion){
183183
let commentDisplayStyle = (event.payload.imageComment === "") ? 'none' : 'inline';
184184
let tagDisplayStyle = (event.payload.imageTagNames === null) ? 'none' : 'inline';
185-
json = Mustache.render(template, { ...parsedEvent, commentDisplayStyle ,tagDisplayStyle});
185+
json = Mustache.render(Mustache.escape(template), { ...parsedEvent, commentDisplayStyle ,tagDisplayStyle});
186186
}else if(event.eventTypeId===5){
187187
let commentDisplayStyle = (event.payload.protectConfigComment === "") ? 'none' : 'inline';
188-
json = Mustache.render(template, { ...parsedEvent, commentDisplayStyle });
188+
json = Mustache.render(Mustache.escape(template), { ...parsedEvent, commentDisplayStyle });
189189
}
190190
else{
191-
json = Mustache.render(template, parsedEvent)
191+
json = Mustache.render(Mustache.escape(template), parsedEvent)
192192
}
193193

194194
const res = await sdk.send(
@@ -218,4 +218,4 @@ export class SESService implements Handler {
218218
let eventLog = this.eventLogBuilder.buildEventLog(event, p.dest, false, setting);
219219
this.eventLogRepository.saveEventLog(eventLog);
220220
}
221-
}
221+
}

src/destination/destinationHandlers/slackHandler.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ export class SlackService implements Handler {
130130
if (event.eventTypeId == EVENT_TYPE.ScoopNotification){
131131
const date = moment(event.eventTime);
132132
event.payload.scoopNotificationConfig.data.interceptedAt = date.unix();
133-
jsons = Mustache.render(template, event.payload.scoopNotificationConfig.data);
133+
jsons = Mustache.render(Mustache.escape(template), event.payload.scoopNotificationConfig.data);
134134
}else{
135135
let parsedEvent = this.mh.parseEvent(event as Event, true);
136-
jsons = Mustache.render(template, parsedEvent);
136+
jsons = Mustache.render(Mustache.escape(template), parsedEvent);
137137
}
138138

139139
let j = JSON.parse(jsons)
@@ -162,4 +162,4 @@ export class SlackService implements Handler {
162162
let eventLog = this.eventLogBuilder.buildEventLog(event, p.dest, false, setting);
163163
this.eventLogRepository.saveEventLog(eventLog);
164164
}
165-
}
165+
}

src/destination/destinationHandlers/smtpHandler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,12 @@ export class SMTPService implements Handler {
199199
if(event.eventTypeId===4){
200200
let commentDisplayStyle = (event.payload.imageComment === "") ? 'none' : 'inline';
201201
let tagDisplayStyle = (event.payload.imageTagNames === null) ? 'none' : 'inline';
202-
json = Mustache.render(template, { ...parsedEvent, commentDisplayStyle ,tagDisplayStyle});
202+
json = Mustache.render(Mustache.escape(template), { ...parsedEvent, commentDisplayStyle ,tagDisplayStyle});
203203
}else if(event.eventTypeId===5){
204204
let commentDisplayStyle = (event.payload.protectConfigComment === "") ? 'none' : 'inline';
205-
json = Mustache.render(template, { ...parsedEvent, commentDisplayStyle });
205+
json = Mustache.render(Mustache.escape(template), { ...parsedEvent, commentDisplayStyle });
206206
}else{
207-
json = Mustache.render(template, parsedEvent)
207+
json = Mustache.render(Mustache.escape(template), parsedEvent)
208208
}
209209
const res = await sdk.send(
210210
{
@@ -233,4 +233,4 @@ export class SMTPService implements Handler {
233233
let eventLog = this.eventLogBuilder.buildEventLog(event, p.dest, false, setting);
234234
this.eventLogRepository.saveEventLog(eventLog);
235235
}
236-
}
236+
}

src/destination/destinationHandlers/webhookHandler.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
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";
1820
import 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";
2225
import { WebhookConfig } from '../../entities/webhookconfig';
23-
import {NotificationSettings} from "../../entities/notificationSettings";
26+
import { Event, Handler } from '../../notification/service/notificationService';
27+
import { EventLogRepository } from '../../repository/notifierEventLogRepository';
2428
import { 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

3030
export 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+
}

src/notification/service/notificationService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class NotificationService {
159159
throw new CustomError("Event is not valid", 400)
160160
}
161161

162-
const settingsResults=await this.notificationSettingsRepository.findByEventSource(event.pipelineType, event.pipelineId, event.eventTypeId, event.appId, event.envId, event.teamId);
162+
const settingsResults=await this.notificationSettingsRepository.findByEventSource(event.pipelineType, event.pipelineId, event.eventTypeId, event.appId, event.envId, event.teamId, event.clusterId, event.isProdEnv);
163163
this.logger.info('notificationSettingsRepository.findByEventSource')
164164
if (!settingsResults || settingsResults.length == 0) {
165165
this.logger.info("no notification settings found for event " + event.correlationId);
@@ -253,7 +253,8 @@ class Event {
253253
appId: number
254254
envId: number
255255
teamId: number
256+
clusterId: number
257+
isProdEnv: boolean
256258
baseUrl?: string
257259
}
258-
259260
export {NotificationService, Event}

0 commit comments

Comments
 (0)