Skip to content

Commit 55a6624

Browse files
authored
ESQL: TO_IP can handle leading zeros (#126532)
Modifies TO_IP so it can handle leading `0`s in ipv4s. Here's how it works now: ``` ROW ip = TO_IP("192.168.0.1") // OK! ROW ip = TO_IP("192.168.010.1") // Fails ``` This adds ``` ROW ip = TO_IP("192.168.010.1", {"leading_zeros": "octal"}) ROW ip = TO_IP("192.168.010.1", {"leading_zeros": "decimal"}) ``` We do this because there isn't a consensus on how to parse leading zeros in ipv4s. The standard unix tools like `ping` and `ftp` interpret leading zeros as octal. Java's built in ip parsing interprets them as decimal. Because folks are using this for security rules we need to support all the choices. Closes #125460
1 parent fa09255 commit 55a6624

File tree

39 files changed

+977
-206
lines changed

39 files changed

+977
-206
lines changed

docs/changelog/126532.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126532
2+
summary: TO_IP can handle leading zeros
3+
area: ES|QL
4+
type: bug
5+
issues:
6+
- 125460

docs/reference/query-languages/esql/_snippets/functions/examples/to_ip.md

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/_snippets/functions/functionNamedParams/to_ip.md

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/_snippets/functions/layout/to_ip.md

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/_snippets/functions/parameters/to_ip.md

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/_snippets/functions/types/to_ip.md

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/images/functions/to_ip.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/reference/query-languages/esql/kibana/definition/functions/to_ip.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/CsvTestsDataLoader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ public class CsvTestsDataLoader {
133133
private static final TestDataset ADDRESSES = new TestDataset("addresses");
134134
private static final TestDataset BOOKS = new TestDataset("books").withSetting("books-settings.json");
135135
private static final TestDataset SEMANTIC_TEXT = new TestDataset("semantic_text").withInferenceEndpoint(true);
136+
private static final TestDataset LOGS = new TestDataset("logs");
136137

137138
public static final Map<String, TestDataset> CSV_DATASET_MAP = Map.ofEntries(
138139
Map.entry(EMPLOYEES.indexName, EMPLOYEES),
@@ -182,7 +183,8 @@ public class CsvTestsDataLoader {
182183
Map.entry(DISTANCES.indexName, DISTANCES),
183184
Map.entry(ADDRESSES.indexName, ADDRESSES),
184185
Map.entry(BOOKS.indexName, BOOKS),
185-
Map.entry(SEMANTIC_TEXT.indexName, SEMANTIC_TEXT)
186+
Map.entry(SEMANTIC_TEXT.indexName, SEMANTIC_TEXT),
187+
Map.entry(LOGS.indexName, LOGS)
186188
);
187189

188190
private static final EnrichConfig LANGUAGES_ENRICH = new EnrichConfig("languages_policy", "enrich-policy-languages.json");
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@timestamp:date ,system:keyword,message:keyword
2+
2023-10-23T13:55:01.543Z, ping,Pinging 192.168.86.046
3+
2023-10-23T13:55:01.544Z, cron,Running cats
4+
2023-10-23T13:55:01.545Z, java,Doing java stuff for 192.168.86.038
5+
2023-10-23T13:55:01.546Z, java,More java stuff

0 commit comments

Comments
 (0)