From cc5de7453d49a9b29913281476fa5c2e4733e34e Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 12 Jun 2020 14:13:24 +0200 Subject: [PATCH 1/6] fix issue --- .../lib/requests/search/enrich_monitor_groups.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts index 53b1fe881cd92..9c42eb398995d 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts @@ -138,12 +138,15 @@ export const enrichMonitorGroups: MonitorEnricher = async ( if (curCheck.tls == null) { curCheck.tls = new HashMap(); } - if (!doc["tls.server.x509.not_after"].isEmpty()) { + if (doc.containsKey("tls.server.x509.not_after") && !doc["tls.server.x509.not_after"].isEmpty()) { curCheck.tls.not_after = doc["tls.server.x509.not_after"][0]; - } - if (!doc["tls.server.x509.not_before"].isEmpty()) { + } else if (!doc["tls.certificate_not_valid_after"].isEmpty()) { + curCheck.tls.certificate_not_valid_after = doc["tls.certificate_not_valid_after"][0]; + + if (doc.containsKey("tls.server.x509.not_after") && !doc["tls.server.x509.not_before"].isEmpty()) { curCheck.tls.not_before = doc["tls.server.x509.not_before"][0]; - } + } else if (!doc["tls.certificate_not_valid_before"].isEmpty()) { + curCheck.tls.certificate_not_valid_before = doc["tls.certificate_not_valid_before"][0]; state.checksByAgentIdIP[agentIdIP] = curCheck; `, From 5935878c0e5d43b28d2850a0e6be377109045643 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 12 Jun 2020 14:16:57 +0200 Subject: [PATCH 2/6] fix issue --- .../server/lib/requests/search/enrich_monitor_groups.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts index 9c42eb398995d..05bd666bd2838 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts @@ -140,12 +140,12 @@ export const enrichMonitorGroups: MonitorEnricher = async ( } if (doc.containsKey("tls.server.x509.not_after") && !doc["tls.server.x509.not_after"].isEmpty()) { curCheck.tls.not_after = doc["tls.server.x509.not_after"][0]; - } else if (!doc["tls.certificate_not_valid_after"].isEmpty()) { + } else if (doc.containsKey("tls.certificate_not_valid_after") !doc["tls.certificate_not_valid_after"].isEmpty()) { curCheck.tls.certificate_not_valid_after = doc["tls.certificate_not_valid_after"][0]; if (doc.containsKey("tls.server.x509.not_after") && !doc["tls.server.x509.not_before"].isEmpty()) { curCheck.tls.not_before = doc["tls.server.x509.not_before"][0]; - } else if (!doc["tls.certificate_not_valid_before"].isEmpty()) { + } else if (doc.containsKey("tls.certificate_not_valid_before") && !doc["tls.certificate_not_valid_before"].isEmpty()) { curCheck.tls.certificate_not_valid_before = doc["tls.certificate_not_valid_before"][0]; state.checksByAgentIdIP[agentIdIP] = curCheck; From 63ca8dbf02d9d388aee00ddefecc33fe48dec039 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 12 Jun 2020 14:53:03 +0200 Subject: [PATCH 3/6] Fix if condition --- .../uptime/server/lib/requests/search/enrich_monitor_groups.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts index 05bd666bd2838..7be4106a93085 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts @@ -140,7 +140,7 @@ export const enrichMonitorGroups: MonitorEnricher = async ( } if (doc.containsKey("tls.server.x509.not_after") && !doc["tls.server.x509.not_after"].isEmpty()) { curCheck.tls.not_after = doc["tls.server.x509.not_after"][0]; - } else if (doc.containsKey("tls.certificate_not_valid_after") !doc["tls.certificate_not_valid_after"].isEmpty()) { + } else if (doc.containsKey("tls.certificate_not_valid_after") && !doc["tls.certificate_not_valid_after"].isEmpty()) { curCheck.tls.certificate_not_valid_after = doc["tls.certificate_not_valid_after"][0]; if (doc.containsKey("tls.server.x509.not_after") && !doc["tls.server.x509.not_before"].isEmpty()) { From e6941b4f1cbcb481b6661aa5a77404ca1e4fe1a0 Mon Sep 17 00:00:00 2001 From: Andrew Cholakian Date: Fri, 12 Jun 2020 08:38:10 -0500 Subject: [PATCH 4/6] Fix closing brackets --- .../uptime/server/lib/requests/search/enrich_monitor_groups.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts index 7be4106a93085..9a178dd735b87 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts @@ -142,11 +142,13 @@ export const enrichMonitorGroups: MonitorEnricher = async ( curCheck.tls.not_after = doc["tls.server.x509.not_after"][0]; } else if (doc.containsKey("tls.certificate_not_valid_after") && !doc["tls.certificate_not_valid_after"].isEmpty()) { curCheck.tls.certificate_not_valid_after = doc["tls.certificate_not_valid_after"][0]; + } if (doc.containsKey("tls.server.x509.not_after") && !doc["tls.server.x509.not_before"].isEmpty()) { curCheck.tls.not_before = doc["tls.server.x509.not_before"][0]; } else if (doc.containsKey("tls.certificate_not_valid_before") && !doc["tls.certificate_not_valid_before"].isEmpty()) { curCheck.tls.certificate_not_valid_before = doc["tls.certificate_not_valid_before"][0]; + } state.checksByAgentIdIP[agentIdIP] = curCheck; `, From ce34d8b6578d5cd503015f3e61c003f0253414a4 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 12 Jun 2020 15:52:51 +0200 Subject: [PATCH 5/6] update --- .../lib/requests/search/enrich_monitor_groups.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts index 9a178dd735b87..6e52b3a11f25f 100644 --- a/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts +++ b/x-pack/plugins/uptime/server/lib/requests/search/enrich_monitor_groups.ts @@ -138,16 +138,11 @@ export const enrichMonitorGroups: MonitorEnricher = async ( if (curCheck.tls == null) { curCheck.tls = new HashMap(); } - if (doc.containsKey("tls.server.x509.not_after") && !doc["tls.server.x509.not_after"].isEmpty()) { - curCheck.tls.not_after = doc["tls.server.x509.not_after"][0]; - } else if (doc.containsKey("tls.certificate_not_valid_after") && !doc["tls.certificate_not_valid_after"].isEmpty()) { - curCheck.tls.certificate_not_valid_after = doc["tls.certificate_not_valid_after"][0]; + if (!doc["tls.certificate_not_valid_after"].isEmpty()) { + curCheck.tls.not_after = doc["tls.certificate_not_valid_after"][0]; } - - if (doc.containsKey("tls.server.x509.not_after") && !doc["tls.server.x509.not_before"].isEmpty()) { - curCheck.tls.not_before = doc["tls.server.x509.not_before"][0]; - } else if (doc.containsKey("tls.certificate_not_valid_before") && !doc["tls.certificate_not_valid_before"].isEmpty()) { - curCheck.tls.certificate_not_valid_before = doc["tls.certificate_not_valid_before"][0]; + if (!doc["tls.certificate_not_valid_before"].isEmpty()) { + curCheck.tls.not_before = doc["tls.certificate_not_valid_before"][0]; } state.checksByAgentIdIP[agentIdIP] = curCheck; From 78c774233172bb960edb172bd4ee06c55497ac16 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 12 Jun 2020 18:27:40 +0200 Subject: [PATCH 6/6] update monitor details case --- .../lib/requests/__tests__/get_latest_monitor.test.ts | 4 ++-- .../uptime/server/lib/requests/get_latest_monitor.ts | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/uptime/server/lib/requests/__tests__/get_latest_monitor.test.ts b/x-pack/plugins/uptime/server/lib/requests/__tests__/get_latest_monitor.test.ts index f8a335c387f2e..aa3574874af8e 100644 --- a/x-pack/plugins/uptime/server/lib/requests/__tests__/get_latest_monitor.test.ts +++ b/x-pack/plugins/uptime/server/lib/requests/__tests__/get_latest_monitor.test.ts @@ -37,8 +37,8 @@ describe('getLatestMonitor', () => { 'monitor', 'observer', '@timestamp', - 'tls.server.x509.not_after', - 'tls.server.x509.not_before', + 'tls.certificate_not_valid_after', + 'tls.certificate_not_valid_before', ], sort: { '@timestamp': { order: 'desc' }, diff --git a/x-pack/plugins/uptime/server/lib/requests/get_latest_monitor.ts b/x-pack/plugins/uptime/server/lib/requests/get_latest_monitor.ts index db34de5159213..a47e6173d9f00 100644 --- a/x-pack/plugins/uptime/server/lib/requests/get_latest_monitor.ts +++ b/x-pack/plugins/uptime/server/lib/requests/get_latest_monitor.ts @@ -50,8 +50,8 @@ export const getLatestMonitor: UMElasticsearchQueryFn