Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/bbannier/ipv6'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Mar 4, 2025
2 parents 1daf762 + 152a814 commit 9977eed
Show file tree
Hide file tree
Showing 4 changed files with 74,114 additions and 75,358 deletions.
12 changes: 2 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,16 +438,8 @@ module.exports = grammar({
file: ($) => /[^ \t\r\n]+/,
pattern: ($) => /\/((\\\/)?[^\r\n\/]?)*\/i?/,

// https://stackoverflow.com/questions/53497/regular-expression-that-matches-valid-ipv6-addresses
//
// This is technically more narrow than Zeek's own IPv6 regex in a few
// specific cases (IPv6-embedded v4 comes to mind, where Zeek accepts
// technically invalid strings). Might want to move to Zeek's regex, for
// consistency.
//
ipv6: ($) =>
/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/,
ipv4: ($) => /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/,
ipv4: (_) => /([0-9]+\.*){4}/,
ipv6: (_) => /\[([0-9a-fA-F]?:*)+(:+([0-9]+\.*){4})?\]/,

port: ($) => /[0-9]+\/(tcp|udp|icmp|unknown)/,

Expand Down
8 changes: 4 additions & 4 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9977eed

Please sign in to comment.