diff --git a/src/plugins/data/common/es_query/kuery/ast/_generated_/kuery.js b/src/plugins/data/common/es_query/kuery/ast/_generated_/kuery.js index 4557c874c8264..72083bd335c68 100644 --- a/src/plugins/data/common/es_query/kuery/ast/_generated_/kuery.js +++ b/src/plugins/data/common/es_query/kuery/ast/_generated_/kuery.js @@ -229,8 +229,7 @@ module.exports = (function() { if (sequence === 'true') return buildLiteralNode(true); if (sequence === 'false') return buildLiteralNode(false); if (chars.includes(wildcardSymbol)) return buildWildcardNode(sequence); - const isNumberPattern = /^(-?[1-9]+\d*([.]\d+)?)$|^(-?0[.]\d*[1-9]+)$|^0$|^0.0$|^[.]\d{1,}$/ - return buildLiteralNode(isNumberPattern.test(sequence) ? Number(sequence) : sequence); + return buildLiteralNode(sequence); }, peg$c53 = { type: "any", description: "any character" }, peg$c54 = "*", diff --git a/src/plugins/data/common/es_query/kuery/ast/ast.test.ts b/src/plugins/data/common/es_query/kuery/ast/ast.test.ts index f43049542f9de..34e91787c6320 100644 --- a/src/plugins/data/common/es_query/kuery/ast/ast.test.ts +++ b/src/plugins/data/common/es_query/kuery/ast/ast.test.ts @@ -168,10 +168,10 @@ describe('kuery AST API', () => { test('should support exclusive range operators', () => { const expected = nodeTypes.function.buildNode('and', [ nodeTypes.function.buildNode('range', 'bytes', { - gt: 1000, + gt: '1000', }), nodeTypes.function.buildNode('range', 'bytes', { - lt: 8000, + lt: '8000', }), ]); const actual = fromKueryExpression('bytes > 1000 and bytes < 8000'); @@ -181,10 +181,10 @@ describe('kuery AST API', () => { test('should support inclusive range operators', () => { const expected = nodeTypes.function.buildNode('and', [ nodeTypes.function.buildNode('range', 'bytes', { - gte: 1000, + gte: '1000', }), nodeTypes.function.buildNode('range', 'bytes', { - lte: 8000, + lte: '8000', }), ]); const actual = fromKueryExpression('bytes >= 1000 and bytes <= 8000'); @@ -279,25 +279,24 @@ describe('kuery AST API', () => { const stringLiteral = nodeTypes.literal.buildNode('foo'); const booleanFalseLiteral = nodeTypes.literal.buildNode(false); const booleanTrueLiteral = nodeTypes.literal.buildNode(true); - const numberLiteral = nodeTypes.literal.buildNode(42); expect(fromLiteralExpression('foo')).toEqual(stringLiteral); expect(fromLiteralExpression('true')).toEqual(booleanTrueLiteral); expect(fromLiteralExpression('false')).toEqual(booleanFalseLiteral); - expect(fromLiteralExpression('42')).toEqual(numberLiteral); - - expect(fromLiteralExpression('.3').value).toEqual(0.3); - expect(fromLiteralExpression('.36').value).toEqual(0.36); - expect(fromLiteralExpression('.00001').value).toEqual(0.00001); - expect(fromLiteralExpression('3').value).toEqual(3); - expect(fromLiteralExpression('-4').value).toEqual(-4); - expect(fromLiteralExpression('0').value).toEqual(0); - expect(fromLiteralExpression('0.0').value).toEqual(0); - expect(fromLiteralExpression('2.0').value).toEqual(2.0); - expect(fromLiteralExpression('0.8').value).toEqual(0.8); - expect(fromLiteralExpression('790.9').value).toEqual(790.9); - expect(fromLiteralExpression('0.0001').value).toEqual(0.0001); - expect(fromLiteralExpression('96565646732345').value).toEqual(96565646732345); + + expect(fromLiteralExpression('.3').value).toEqual('.3'); + expect(fromLiteralExpression('.36').value).toEqual('.36'); + expect(fromLiteralExpression('.00001').value).toEqual('.00001'); + expect(fromLiteralExpression('3').value).toEqual('3'); + expect(fromLiteralExpression('-4').value).toEqual('-4'); + expect(fromLiteralExpression('0').value).toEqual('0'); + expect(fromLiteralExpression('0.0').value).toEqual('0.0'); + expect(fromLiteralExpression('2.0').value).toEqual('2.0'); + expect(fromLiteralExpression('0.8').value).toEqual('0.8'); + expect(fromLiteralExpression('790.9').value).toEqual('790.9'); + expect(fromLiteralExpression('0.0001').value).toEqual('0.0001'); + expect(fromLiteralExpression('96565646732345').value).toEqual('96565646732345'); + expect(fromLiteralExpression('070').value).toEqual('070'); expect(fromLiteralExpression('..4').value).toEqual('..4'); expect(fromLiteralExpression('.3text').value).toEqual('.3text'); diff --git a/src/plugins/data/common/es_query/kuery/ast/kuery.peg b/src/plugins/data/common/es_query/kuery/ast/kuery.peg index 865e4f04e0b10..e4d305ced7270 100644 --- a/src/plugins/data/common/es_query/kuery/ast/kuery.peg +++ b/src/plugins/data/common/es_query/kuery/ast/kuery.peg @@ -251,8 +251,7 @@ UnquotedLiteral if (sequence === 'true') return buildLiteralNode(true); if (sequence === 'false') return buildLiteralNode(false); if (chars.includes(wildcardSymbol)) return buildWildcardNode(sequence); - const isNumberPattern = /^(-?[1-9]+\d*([.]\d+)?)$|^(-?0[.]\d*[1-9]+)$|^0$|^0.0$|^[.]\d{1,}$/ - return buildLiteralNode(isNumberPattern.test(sequence) ? Number(sequence) : sequence); + return buildLiteralNode(sequence); } UnquotedCharacter diff --git a/src/plugins/data/common/search/aggs/buckets/filters.test.ts b/src/plugins/data/common/search/aggs/buckets/filters.test.ts index 14b8d95f195ed..4e5ab8cf71c13 100644 --- a/src/plugins/data/common/search/aggs/buckets/filters.test.ts +++ b/src/plugins/data/common/search/aggs/buckets/filters.test.ts @@ -153,7 +153,7 @@ describe('Filters Agg', () => { "should": Array [ Object { "match": Object { - "field": 200, + "field": "200", }, }, ], @@ -171,7 +171,7 @@ describe('Filters Agg', () => { Object { "range": Object { "field": Object { - "gt": 500, + "gt": "500", }, }, }, diff --git a/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.test.ts b/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.test.ts index 2a7bc6238e5d9..3c04e2b0da9c3 100644 --- a/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.test.ts +++ b/x-pack/plugins/security_solution/common/detection_engine/get_query_filter.test.ts @@ -1028,7 +1028,7 @@ describe('get_filter', () => { "should": Array [ Object { "match": Object { - "suricata.eve.alert.signature_id": 2610182, + "suricata.eve.alert.signature_id": "2610182", }, }, ], @@ -1040,7 +1040,7 @@ describe('get_filter', () => { "should": Array [ Object { "match": Object { - "suricata.eve.alert.signature_id": 2610183, + "suricata.eve.alert.signature_id": "2610183", }, }, ], @@ -1052,7 +1052,7 @@ describe('get_filter', () => { "should": Array [ Object { "match": Object { - "suricata.eve.alert.signature_id": 2610184, + "suricata.eve.alert.signature_id": "2610184", }, }, ], @@ -1064,7 +1064,7 @@ describe('get_filter', () => { "should": Array [ Object { "match": Object { - "suricata.eve.alert.signature_id": 2610185, + "suricata.eve.alert.signature_id": "2610185", }, }, ], @@ -1076,7 +1076,7 @@ describe('get_filter', () => { "should": Array [ Object { "match": Object { - "suricata.eve.alert.signature_id": 2610186, + "suricata.eve.alert.signature_id": "2610186", }, }, ], @@ -1088,7 +1088,7 @@ describe('get_filter', () => { "should": Array [ Object { "match": Object { - "suricata.eve.alert.signature_id": 2610187, + "suricata.eve.alert.signature_id": "2610187", }, }, ], diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx index 8e03a56c1aa9b..0438acdfe44d4 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/helpers.test.tsx @@ -332,8 +332,8 @@ describe('Combined Queries', () => { kqlQuery: { query: '', language: 'kuery' }, kqlMode: 'search', })!; - expect(filterQuery).toEqual( - '{"bool":{"must":[],"filter":[{"bool":{"should":[{"range":{"@timestamp":{"gte":1521848183232,"lte":1521848183232}}}],"minimum_should_match":1}}],"should":[],"must_not":[]}}' + expect(filterQuery).toMatchInlineSnapshot( + `"{\\"bool\\":{\\"must\\":[],\\"filter\\":[{\\"bool\\":{\\"should\\":[{\\"range\\":{\\"@timestamp\\":{\\"gte\\":\\"1521848183232\\",\\"lte\\":\\"1521848183232\\"}}}],\\"minimum_should_match\\":1}}],\\"should\\":[],\\"must_not\\":[]}}"` ); }); @@ -350,8 +350,8 @@ describe('Combined Queries', () => { kqlQuery: { query: '', language: 'kuery' }, kqlMode: 'search', })!; - expect(filterQuery).toEqual( - '{"bool":{"must":[],"filter":[{"bool":{"should":[{"range":{"@timestamp":{"gte":1521848183232,"lte":1521848183232}}}],"minimum_should_match":1}}],"should":[],"must_not":[]}}' + expect(filterQuery).toMatchInlineSnapshot( + `"{\\"bool\\":{\\"must\\":[],\\"filter\\":[{\\"bool\\":{\\"should\\":[{\\"range\\":{\\"@timestamp\\":{\\"gte\\":\\"1521848183232\\",\\"lte\\":\\"1521848183232\\"}}}],\\"minimum_should_match\\":1}}],\\"should\\":[],\\"must_not\\":[]}}"` ); }); @@ -368,8 +368,8 @@ describe('Combined Queries', () => { kqlQuery: { query: '', language: 'kuery' }, kqlMode: 'search', })!; - expect(filterQuery).toEqual( - '{"bool":{"must":[],"filter":[{"bool":{"should":[{"match":{"event.end":1521848183232}}],"minimum_should_match":1}}],"should":[],"must_not":[]}}' + expect(filterQuery).toMatchInlineSnapshot( + `"{\\"bool\\":{\\"must\\":[],\\"filter\\":[{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"event.end\\":\\"1521848183232\\"}}],\\"minimum_should_match\\":1}}],\\"should\\":[],\\"must_not\\":[]}}"` ); }); @@ -386,8 +386,8 @@ describe('Combined Queries', () => { kqlQuery: { query: '', language: 'kuery' }, kqlMode: 'search', })!; - expect(filterQuery).toEqual( - '{"bool":{"must":[],"filter":[{"bool":{"should":[{"match":{"event.end":1521848183232}}],"minimum_should_match":1}}],"should":[],"must_not":[]}}' + expect(filterQuery).toMatchInlineSnapshot( + `"{\\"bool\\":{\\"must\\":[],\\"filter\\":[{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"event.end\\":\\"1521848183232\\"}}],\\"minimum_should_match\\":1}}],\\"should\\":[],\\"must_not\\":[]}}"` ); }); diff --git a/x-pack/plugins/uptime/server/lib/alerts/status_check.test.ts b/x-pack/plugins/uptime/server/lib/alerts/status_check.test.ts index 4fac71a53a1dc..12db6eeff8fcf 100644 --- a/x-pack/plugins/uptime/server/lib/alerts/status_check.test.ts +++ b/x-pack/plugins/uptime/server/lib/alerts/status_check.test.ts @@ -354,7 +354,7 @@ describe('status check alert', () => { "should": Array [ Object { "match": Object { - "url.port": 12349, + "url.port": "12349", }, }, ], @@ -366,7 +366,7 @@ describe('status check alert', () => { "should": Array [ Object { "match": Object { - "url.port": 5601, + "url.port": "5601", }, }, ], @@ -378,7 +378,7 @@ describe('status check alert', () => { "should": Array [ Object { "match": Object { - "url.port": 443, + "url.port": "443", }, }, ], @@ -735,7 +735,7 @@ describe('status check alert', () => { expect(mockAvailability.mock.calls[0]).toMatchInlineSnapshot(` Array [ Object { - "filters": "{\\"bool\\":{\\"filter\\":[{\\"bool\\":{\\"should\\":[{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"url.port\\":12349}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"url.port\\":5601}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"url.port\\":443}}],\\"minimum_should_match\\":1}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"observer.geo.name\\":\\"harrisburg\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"monitor.type\\":\\"http\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"tags\\":\\"unsecured\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"tags\\":\\"containers\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match_phrase\\":{\\"tags\\":\\"org:google\\"}}],\\"minimum_should_match\\":1}}],\\"minimum_should_match\\":1}}]}}", + "filters": "{\\"bool\\":{\\"filter\\":[{\\"bool\\":{\\"should\\":[{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"url.port\\":\\"12349\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"url.port\\":\\"5601\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"url.port\\":\\"443\\"}}],\\"minimum_should_match\\":1}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"observer.geo.name\\":\\"harrisburg\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"monitor.type\\":\\"http\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"tags\\":\\"unsecured\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match\\":{\\"tags\\":\\"containers\\"}}],\\"minimum_should_match\\":1}},{\\"bool\\":{\\"should\\":[{\\"match_phrase\\":{\\"tags\\":\\"org:google\\"}}],\\"minimum_should_match\\":1}}],\\"minimum_should_match\\":1}}]}}", "range": 35, "rangeUnit": "d", "threshold": "99.34",