Skip to content

Commit

Permalink
Watcher notification settings Upgrade checks (#36907)
Browse files Browse the repository at this point in the history
Upgrade checks for watcher notifications account
deprecations in #36403 and #36736 .
  • Loading branch information
albertzaharovits committed Jan 20, 2019
1 parent c58cb40 commit 6ab4d18
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ private DeprecationChecks() {
NodeDeprecationChecks::azureRepositoryChanges,
NodeDeprecationChecks::gcsRepositoryChanges,
NodeDeprecationChecks::fileDiscoveryPluginRemoved,
NodeDeprecationChecks::defaultSSLSettingsRemoved
NodeDeprecationChecks::defaultSSLSettingsRemoved,
NodeDeprecationChecks::watcherNotificationsSecureSettingsCheck
));

static List<Function<IndexMetaData, DeprecationIssue>> INDEX_SETTINGS_CHECKS =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,29 @@ static DeprecationIssue discoveryConfigurationCheck(List<NodeInfo> nodeInfos, Li
return null;
}

static DeprecationIssue watcherNotificationsSecureSettingsCheck(List<NodeInfo> nodeInfos, List<NodeStats> nodeStats) {
List<String> nodesFound = nodeInfos.stream().filter(nodeInfo ->
(false == nodeInfo.getSettings().getByPrefix("xpack.notification.email.account.")
.filter(s -> s.endsWith(".smtp.password")).isEmpty())
|| (false == nodeInfo.getSettings().getByPrefix("xpack.notification.hipchat.account.")
.filter(s -> s.endsWith(".auth_token")).isEmpty())
|| (false == nodeInfo.getSettings().getByPrefix("xpack.notification.jira.account.")
.filter(s -> s.endsWith(".url") || s.endsWith(".user") || s.endsWith(".password")).isEmpty())
|| (false == nodeInfo.getSettings().getByPrefix("xpack.notification.pagerduty.account.")
.filter(s -> s.endsWith(".service_api_key")).isEmpty())
|| (false == nodeInfo.getSettings().getByPrefix("xpack.notification.slack.account.").filter(s -> s.endsWith(".url"))
.isEmpty()))
.map(nodeInfo -> nodeInfo.getNode().getName()).collect(Collectors.toList());
if (nodesFound.size() > 0) {
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Watcher notification accounts' authentication settings must be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html" +
"#watcher-notifications-account-settings",
"nodes which have insecure notification account settings are: " + nodesFound);
}
return null;
}

static DeprecationIssue azureRepositoryChanges(List<NodeInfo> nodeInfos, List<NodeStats> nodeStats) {
List<String> nodesFound = nodeInfos.stream()
.filter(nodeInfo ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,44 @@ public void testBulkThreadPoolCheck() {
assertSettingsAndIssue("thread_pool.bulk.queue_size", Integer.toString(randomIntBetween(1, 20000)), expected);
}

public void testWatcherNotificationsSecureSettings() {
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Watcher notification accounts' authentication settings must be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have insecure notification account settings are: [node_check]");
assertSettingsAndIssue("xpack.notification.email.account." + randomAlphaOfLength(4) + ".smtp.password", randomAlphaOfLength(4),
expected);
expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Watcher notification accounts' authentication settings must be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have insecure notification account settings are: [node_check]");
assertSettingsAndIssue("xpack.notification.hipchat.account." + randomAlphaOfLength(4) + ".auth_token", randomAlphaOfLength(4),
expected);
expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Watcher notification accounts' authentication settings must be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have insecure notification account settings are: [node_check]");
assertSettingsAndIssue("xpack.notification.jira.account." + randomAlphaOfLength(4) + ".url", randomAlphaOfLength(4), expected);
assertSettingsAndIssue("xpack.notification.jira.account." + randomAlphaOfLength(4) + ".user", randomAlphaOfLength(4), expected);
assertSettingsAndIssue("xpack.notification.jira.account." + randomAlphaOfLength(4) + ".password", randomAlphaOfLength(4), expected);
expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Watcher notification accounts' authentication settings must be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have insecure notification account settings are: [node_check]");
assertSettingsAndIssue("xpack.notification.pagerduty.account." + randomAlphaOfLength(4) + ".service_api_key",
randomAlphaOfLength(4), expected);
expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Watcher notification accounts' authentication settings must be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have insecure notification account settings are: [node_check]");
assertSettingsAndIssue("xpack.notification.slack.account." + randomAlphaOfLength(4) + ".url", randomAlphaOfLength(4), expected);
}

public void testTribeNodeCheck() {
String tribeSetting = "tribe." + randomAlphaOfLengthBetween(1, 20) + ".cluster.name";
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
Expand Down

0 comments on commit 6ab4d18

Please sign in to comment.