Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Watcher notification settings Upgrade checks #36907

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ private DeprecationChecks() {
NodeDeprecationChecks::gcsRepositoryChanges,
NodeDeprecationChecks::fileDiscoveryPluginRemoved,
NodeDeprecationChecks::defaultSSLSettingsRemoved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build is failing though, you need a comma here.

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 email notifications' password settings has to be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have the un-secure setting are: [node_check]");
assertSettingsAndIssue("xpack.notification.email.account." + randomAlphaOfLength(4) + ".smtp.password", randomAlphaOfLength(4),
expected);
expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Watcher hipchat notifications' auth token settings has to be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have the un-secure setting are: [node_check]");
assertSettingsAndIssue("xpack.notification.hipchat.account." + randomAlphaOfLength(4) + ".auth_token", randomAlphaOfLength(4),
expected);
expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Watcher jira notifications' url, user and password settings have to be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have the un-secure 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 pagerduty notifications' service api key setting has to be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have the un-secure setting are: [node_check]");
assertSettingsAndIssue("xpack.notification.pagerduty.account." + randomAlphaOfLength(4) + ".service_api_key",
randomAlphaOfLength(4), expected);
expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
"Watcher slack notifications' url setting has to be defined securely",
"https://www.elastic.co/guide/en/elasticsearch/reference/master/breaking-changes-7.0.html"
+ "#watcher-notifications-account-settings",
"nodes which have the un-secure setting 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