Skip to content

Commit

Permalink
Added some more MAC options.
Browse files Browse the repository at this point in the history
  • Loading branch information
ofir123 committed Dec 6, 2016
1 parent 48e1f97 commit 4a0163e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ NetworkAddress Analysis for ElasticSearch
--------------------------------------------------
| NetworkAddress Analysis Plugin | ElasticSearch |
--------------------------------------------------
| 2.0 | 2.3.5 |
| 2.0 | 2.3.4 |
--------------------------------------------------


Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</scm>

<properties>
<elasticsearch.version>2.3.5</elasticsearch.version>
<elasticsearch.version>2.3.4</elasticsearch.version>
<lucene.version>5.5.0</lucene.version>
<elasticsearch.assembly.descriptor>${project.basedir}/src/main/resources/plugin-metadata/plugin-assembly.xml</elasticsearch.assembly.descriptor>
<elasticsearch.plugin.classname>org.elasticsearch.plugin.analysis.networkaddress.AnalysisNetworkAddressPlugin</elasticsearch.plugin.classname>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ public final class FullNetworkAddressAnalyzer extends Analyzer {
private final String MAC_PATTERN2 = "[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9]";
private final String MAC_PATTERN3 = "[a-fA-F0-9][a-fA-F0-9]_[a-fA-F0-9][a-fA-F0-9]_[a-fA-F0-9][a-fA-F0-9]_[a-fA-F0-9][a-fA-F0-9]_[a-fA-F0-9][a-fA-F0-9]_[a-fA-F0-9][a-fA-F0-9]";
private final String MAC_PATTERN4 = "[a-fA-F0-9][a-fA-F0-9]\\.[a-fA-F0-9][a-fA-F0-9]\\.[a-fA-F0-9][a-fA-F0-9]\\.[a-fA-F0-9][a-fA-F0-9]\\.[a-fA-F0-9][a-fA-F0-9]\\.[a-fA-F0-9][a-fA-F0-9]";
private final String MAC_PATTERN5 = "[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]:[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]";
private final String MAC_PATTERN6 = "[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\.[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]\\.[a-fA-F0-9][a-fA-F0-9][a-fA-F0-9][a-fA-F0-9]";

private final Pattern pattern;
private final int group;

public FullNetworkAddressAnalyzer(Settings settings) {
String sPattern = settings.get("pattern", String.format("(?:%s)|(?:%s)|(?:%s)|(?:%s)|(?:%s)",
IP_PATTERN, MAC_PATTERN1, MAC_PATTERN2, MAC_PATTERN3, MAC_PATTERN4));
String sPattern = settings.get("pattern", String.format("(?:%s)|(?:%s)|(?:%s)|(?:%s)|(?:%s)|(?:%s)|(?:%s)",
IP_PATTERN, MAC_PATTERN1, MAC_PATTERN2, MAC_PATTERN3, MAC_PATTERN4, MAC_PATTERN5, MAC_PATTERN6));

this.pattern = Regex.compile(sPattern, settings.get("flags"));
this.group = settings.getAsInt("group", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ public final class NetworkAddressAnalyzer extends Analyzer {
private final String MAC_PATTERN2 = "([a-fA-F0-9][a-fA-F0-9]):([a-fA-F0-9][a-fA-F0-9]):([a-fA-F0-9][a-fA-F0-9]):([a-fA-F0-9][a-fA-F0-9]):([a-fA-F0-9][a-fA-F0-9]):([a-fA-F0-9][a-fA-F0-9])";
private final String MAC_PATTERN3 = "([a-fA-F0-9][a-fA-F0-9])_([a-fA-F0-9][a-fA-F0-9])_([a-fA-F0-9][a-fA-F0-9])_([a-fA-F0-9][a-fA-F0-9])_([a-fA-F0-9][a-fA-F0-9])_([a-fA-F0-9][a-fA-F0-9])";
private final String MAC_PATTERN4 = "([a-fA-F0-9][a-fA-F0-9])\\.([a-fA-F0-9][a-fA-F0-9])\\.([a-fA-F0-9][a-fA-F0-9])\\.([a-fA-F0-9][a-fA-F0-9])\\.([a-fA-F0-9][a-fA-F0-9])\\.([a-fA-F0-9][a-fA-F0-9])";
private final String MAC_PATTERN5 = "([a-fA-F0-9][a-fA-F0-9])([a-fA-F0-9][a-fA-F0-9]):([a-fA-F0-9][a-fA-F0-9])([a-fA-F0-9][a-fA-F0-9]):([a-fA-F0-9][a-fA-F0-9])([a-fA-F0-9][a-fA-F0-9])";
private final String MAC_PATTERN6 = "([a-fA-F0-9][a-fA-F0-9])([a-fA-F0-9][a-fA-F0-9])\\.([a-fA-F0-9][a-fA-F0-9])([a-fA-F0-9][a-fA-F0-9])\\.([a-fA-F0-9][a-fA-F0-9])([a-fA-F0-9][a-fA-F0-9])";

private final Pattern pattern;
private final int group;

public NetworkAddressAnalyzer(Settings settings) {
String sPattern = settings.get("pattern", String.format("(?:%s)|(?:%s)|(?:%s)|(?:%s)|(?:%s)",
IP_PATTERN, MAC_PATTERN1, MAC_PATTERN2, MAC_PATTERN3, MAC_PATTERN4));
String sPattern = settings.get("pattern", String.format("(?:%s)|(?:%s)|(?:%s)|(?:%s)|(?:%s)|(?:%s)|(?:%s)",
IP_PATTERN, MAC_PATTERN1, MAC_PATTERN2, MAC_PATTERN3, MAC_PATTERN4, MAC_PATTERN5, MAC_PATTERN6));

this.pattern = Regex.compile(sPattern, settings.get("flags"));
this.group = settings.getAsInt("group", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public void testFullNetworkAddressAnalyzer() throws Exception {
AnalysisTestUtils.testAnalyzer(new FullNetworkAddressAnalysisBinderProcessor(),
"fullnetworkaddress",
"aa 1.2.3.4 bb acw 22.44.33.42.1 22:4e:b2:53:d7:93 acDD.cccc.AAaa kn",
"1.2.3.4", "22.44.33.42", "22:4e:b2:53:d7:93");
"1.2.3.4", "22.44.33.42", "22:4e:b2:53:d7:93", "acdd.cccc.aaaa");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void testNetworkAddressAnalyzer() throws Exception {
"networkaddress",
"aa 1.2.3.4 bb acw 22.44.33.42.1 22:4e:b2:53:d7:93 acDD.cccc.AAaa kn",
"1", "2", "3", "4", "22", "44", "33", "42", "22", "4e", "b2", "53", "d7",
"93");
"93", "ac", "dd", "cc", "cc", "aa", "aa");
}

}

0 comments on commit 4a0163e

Please sign in to comment.