From 0b7371e4415a6607837fc039034a00e1b956605e Mon Sep 17 00:00:00 2001 From: Steven Neiland Date: Wed, 18 Aug 2021 20:35:09 -0400 Subject: [PATCH 1/4] Additional ignores --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3b55a5e..a92b4bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ /*~ /deploy/ -.DS_Store \ No newline at end of file +.DS_Store +/Vagrantfile +/vagrantscripts/ +/database/ +/.vagrant/ From a32c27c805f79e0e20a7fdc6f7c4445380e527f8 Mon Sep 17 00:00:00 2001 From: Steven Neiland Date: Wed, 18 Aug 2021 20:35:31 -0400 Subject: [PATCH 2/4] ignore web-inf --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index a92b4bd..ab32dfb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /vagrantscripts/ /database/ /.vagrant/ +/WEB-INF/ From e857f3b47cc334fd84de5892ca53b0d5ec7a68a7 Mon Sep 17 00:00:00 2001 From: Steven Neiland Date: Wed, 18 Aug 2021 20:36:28 -0400 Subject: [PATCH 3/4] Ignore log files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ab32dfb..c64ff87 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /database/ /.vagrant/ /WEB-INF/ +/*.log From 05b2ad0bb239ca70f38cc2c6ea5f38ca04c036ac Mon Sep 17 00:00:00 2001 From: Steven Neiland Date: Thu, 19 Aug 2021 16:39:17 -0400 Subject: [PATCH 4/4] Add simple slack integration --- components/SlackService.cfc | 26 +++++++++ components/baseRule.cfc | 29 ++++++++++ components/bugLogListener.cfc | 6 +- components/hq/slackService.cfc | 41 +++++++++++++ config/buglog-config.xml.cfm | 5 +- extensions/rules/firstMessageAlert.cfc | 80 ++++++++++++++++++++++---- extensions/rules/frequencyAlert.cfc | 12 +++- extensions/rules/heartbeatMonitor.cfc | 12 +++- hq/config/config.xml.cfm | 5 ++ hq/handlers/admin.cfc | 73 ++++++++++++++++------- hq/handlers/extensions.cfc | 8 ++- hq/views/admin.cfm | 1 + hq/views/admin/slack.cfm | 31 ++++++++++ 13 files changed, 291 insertions(+), 38 deletions(-) create mode 100644 components/SlackService.cfc create mode 100644 components/hq/slackService.cfc create mode 100644 hq/views/admin/slack.cfm diff --git a/components/SlackService.cfc b/components/SlackService.cfc new file mode 100644 index 0000000..2905db4 --- /dev/null +++ b/components/SlackService.cfc @@ -0,0 +1,26 @@ + + + + + + + + + variables.endpoint = arguments.configObj.getSetting("slack.endpoint", variables.endpoint); + variables.enabled = arguments.configObj.getSetting("slack.enabled", variables.enabled); + return this; + + + + + + + + + + + + + + + diff --git a/components/baseRule.cfc b/components/baseRule.cfc index 708bee2..66d9a97 100644 --- a/components/baseRule.cfc +++ b/components/baseRule.cfc @@ -134,6 +134,29 @@ + + + + + + + var buglogHref = getBaseBugLogHREF(); + var bugReportURL = ""; + var text = ""; + + if( arguments.entryID gt 0 ){ + bugReportURL = getBugEntryHREF(arguments.entryID); + } + + + +#arguments.comment# +Bug Report URL: #bugReportURL# + + + + + @@ -168,6 +191,12 @@ + + + + + + diff --git a/components/bugLogListener.cfc b/components/bugLogListener.cfc index b27436c..a5a6f91 100644 --- a/components/bugLogListener.cfc +++ b/components/bugLogListener.cfc @@ -59,6 +59,9 @@ // load the mailer service variables.mailerService = createObject("component","bugLog.components.MailerService").init( variables.oConfig ); + // load the slack service + variables.slackService = createObject("component","bugLog.components.SlackService").init(variables.oConfig); + // load rules loadRules(); @@ -412,7 +415,8 @@ thisRule.instance .setListener(this) .setDAOFactory( variables.oDAOFactory ) - .setMailerService( variables.mailerService ); + .setMailerService( variables.mailerService ) + .setSlackService( variables.slackService ); // add rule to processor variables.oRuleProcessor.addRule(oRule); diff --git a/components/hq/slackService.cfc b/components/hq/slackService.cfc new file mode 100644 index 0000000..930a5ed --- /dev/null +++ b/components/hq/slackService.cfc @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/buglog-config.xml.cfm b/config/buglog-config.xml.cfm index 1db3e61..e1f981e 100644 --- a/config/buglog-config.xml.cfm +++ b/config/buglog-config.xml.cfm @@ -35,9 +35,12 @@ + false + + 90 false - + false 24 diff --git a/extensions/rules/firstMessageAlert.cfc b/extensions/rules/firstMessageAlert.cfc index f23001f..5dd2590 100644 --- a/extensions/rules/firstMessageAlert.cfc +++ b/extensions/rules/firstMessageAlert.cfc @@ -1,13 +1,15 @@ - - + + + @@ -19,19 +21,24 @@ + + + + + - + @@ -72,13 +79,20 @@ if(variables.severityID neq ID_NOT_SET) args.severityID = variables.severityID; qry = oEntryFinder.search(argumentCollection = args); - + if(qry.recordCount eq 1 or (qry.recordCount gt 1 and dateDiff("n", variables.lastEmailTimestamp, now()) gt variables.config.timespan)) { logTrigger(entry); - sendEmail(qry, rawEntry); + if( variables.config.sendEmailAlert ){ + sendEmail(qry, rawEntry); + } + + if( variables.config.sendSlackAlert ){ + sendSlack(qry, rawEntry); + } + variables.lastEmailTimestamp = now(); } - + return true; @@ -104,24 +118,68 @@ with a severity of #variables.config.severity# - on the last + on the last #numHours# hours and #numMinutes# minutes - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extensions/rules/frequencyAlert.cfc b/extensions/rules/frequencyAlert.cfc index 8d556bb..bccc73e 100644 --- a/extensions/rules/frequencyAlert.cfc +++ b/extensions/rules/frequencyAlert.cfc @@ -9,6 +9,9 @@ + + + @@ -22,6 +25,9 @@ + + + @@ -30,15 +36,19 @@ + + + + - + diff --git a/extensions/rules/heartbeatMonitor.cfc b/extensions/rules/heartbeatMonitor.cfc index 48b6437..42b0542 100644 --- a/extensions/rules/heartbeatMonitor.cfc +++ b/extensions/rules/heartbeatMonitor.cfc @@ -1,4 +1,4 @@ - @@ -8,6 +8,8 @@ + + @@ -16,19 +18,25 @@ + + + + + + - + diff --git a/hq/config/config.xml.cfm b/hq/config/config.xml.cfm index ac8abbd..3e0cb63 100644 --- a/hq/config/config.xml.cfm +++ b/hq/config/config.xml.cfm @@ -41,6 +41,11 @@ + + + + + diff --git a/hq/handlers/admin.cfc b/hq/handlers/admin.cfc index dd5eec6..92e3a5e 100644 --- a/hq/handlers/admin.cfc +++ b/hq/handlers/admin.cfc @@ -1,27 +1,29 @@ - + - + var user = getValue("currentUser"); var app = getService("app"); var cfg = app.getConfig(); var jira = getService("jira"); + var slack = getService("slack"); var jiraConfig = structNew(); + var slackConfig = structNew(); var panel = getValue("panel"); - + if(panel eq "") { if(user.getIsAdmin()) panel = "general"; else - panel = "changePassword"; + panel = "changePassword"; } - + try { switch(panel) { case "general": @@ -75,25 +77,32 @@ jiraConfig.endpoint = jira.getSetting("endpoint"); jiraConfig.username = jira.getSetting("username"); jiraConfig.password = jira.getSetting("password"); - setValue("jiraConfig",jiraConfig); + setValue("jiraConfig",jiraConfig); + break; + + case "slack": + if(not user.getIsAdmin()) throw(type="validation", message=variables.msgs.userNotAllowed); + slackConfig.enabled = slack.getSetting("enabled",false); + slackConfig.endpoint = slack.getSetting("endpoint"); + setValue("slackConfig",slackConfig); break; case "digest": if(not user.getIsAdmin()) throw(type="validation", message=variables.msgs.userNotAllowed); digestConfig = app.getDigestSettings(); - setValue("enabled", digestConfig.enabled); - setValue("recipients", digestConfig.recipients); - setValue("interval", digestConfig.schedulerIntervalHours); - setValue("startTime", digestConfig.schedulerStartTime); - setValue("sendIfEmpty", digestConfig.sendIfEmpty); - setValue("app", digestConfig.application); - setValue("host", digestConfig.host); - setValue("severity", digestConfig.severity); + setValue("enabled", digestConfig.enabled); + setValue("recipients", digestConfig.recipients); + setValue("interval", digestConfig.schedulerIntervalHours); + setValue("startTime", digestConfig.schedulerStartTime); + setValue("sendIfEmpty", digestConfig.sendIfEmpty); + setValue("app", digestConfig.application); + setValue("host", digestConfig.host); + setValue("severity", digestConfig.severity); break; - + case "listeners": setValue("APIKey", app.getServiceSetting("APIKey")); - setValue("bugLogHREF", app.getBaseBugLogHREF()); + setValue("bugLogHREF", app.getBaseBugLogHREF()); break; } @@ -317,15 +326,39 @@ setMessage("info","JIRA integration settings updated."); setNextEvent("admin.main","panel=jira"); - + } catch(any e) { setMessage("error",e.message); getService("bugTracker").notifyService(e.message, e); setNextEvent("admin.main","panel=jira"); } - - - + + + + + + var user = getValue("currentUser"); + var enabled = getValue("enabled",false); + var endpoint = getValue("endpoint"); + + try { + if(not user.getIsAdmin()) {setMessage("warning",variables.msgs.userNotAllowedAction); setNextEvent("admin.main","panel=slack");} + if(not isConfigEditingAllowed()) {setMessage("warning",variables.msgs.editingSettingsNotAllowed); setNextEvent("admin.main","panel=slack");} + getService("slack").setSetting("enabled", enabled) + .setSetting("endpoint", endpoint) + .reinit(); + + setMessage("info","Slack integration settings updated."); + setNextEvent("admin.main","panel=slack"); + + } catch(any e) { + setMessage("error",e.message); + getService("bugTracker").notifyService(e.message, e); + setNextEvent("admin.main","panel=slack"); + } + + + var user = getValue("currentUser"); diff --git a/hq/handlers/extensions.cfc b/hq/handlers/extensions.cfc index 003c43f..b5ab921 100644 --- a/hq/handlers/extensions.cfc +++ b/hq/handlers/extensions.cfc @@ -61,11 +61,15 @@ setValue("stRule", stRule); setValue("id", id); setValue("ruleName", ruleName); - + if(id eq 0 ){ + setValue("sendEmailAlert", true); + setValue("sendSlackAlert", false); + } + if(id gt 0) { setValue("aActiveRule", app.getRule(id,user)); } - + setValue("pageTitle", "Rules > Add/Edit Rule"); setView("extensions/edit"); diff --git a/hq/views/admin.cfm b/hq/views/admin.cfm index ab0e957..0adbaec 100644 --- a/hq/views/admin.cfm +++ b/hq/views/admin.cfm @@ -12,6 +12,7 @@ { id = "purgeHistory", label = "Purge History", display = isAdmin, href="admin/purgeHistory.cfm" }, { id = "APISecurity", label = "API Security", display = isAdmin, href="admin/APISecurity.cfm" }, { id = "jira", label = "JIRA Integration", display = isAdmin, href="admin/jira.cfm" }, + { id = "slack", label = "Slack Integration", display = isAdmin, href="admin/slack.cfm" }, { id = "digest", label = "Digest", display = isAdmin, href="admin/digest.cfm" }, { id = "listeners", label = "BugLog Listeners", display = true, href="admin/listeners.cfm" } ]> diff --git a/hq/views/admin/slack.cfm b/hq/views/admin/slack.cfm new file mode 100644 index 0000000..19cde98 --- /dev/null +++ b/hq/views/admin/slack.cfm @@ -0,0 +1,31 @@ + + + +

Slack Integration:

+ +
+
#editingSettingsNotAllowedMsg#
+ + +
+ + + + + + + + + + +
Enabled: + checked disabled> Yes +   + checked disabled> No +
Endpoint:disabled>
+
+ disabled> +
+
+ +
\ No newline at end of file