Repository: incubator-metron Updated Branches: refs/heads/master 0e629f3be -> 1ef8cd8ff
http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/1ef8cd8f/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorEnrichmentConfigControllerIntegrationTest.java ---------------------------------------------------------------------- diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorEnrichmentConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorEnrichmentConfigControllerIntegrationTest.java index 6a67473..dd4eff7 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorEnrichmentConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorEnrichmentConfigControllerIntegrationTest.java @@ -236,13 +236,23 @@ public class SensorEnrichmentConfigControllerIntegrationTest { .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").doesNotExist()); - this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/list/available").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/list/available/enrichments").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[0]").value("geo")) .andExpect(jsonPath("$[1]").value("host")) .andExpect(jsonPath("$[2]").value("whois")); + this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/list/available/threat/triage/aggregators").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[0]").value("MAX")) + .andExpect(jsonPath("$[1]").value("MIN")) + .andExpect(jsonPath("$[2]").value("SUM")) + .andExpect(jsonPath("$[3]").value("MEAN")) + .andExpect(jsonPath("$[4]").value("POSITIVE_MEAN")) + ; + sensorEnrichmentConfigService.delete("broTest"); } } http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/1ef8cd8f/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StormControllerIntegrationTest.java ---------------------------------------------------------------------- diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StormControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StormControllerIntegrationTest.java index 69d8da6..111b510 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StormControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StormControllerIntegrationTest.java @@ -189,7 +189,9 @@ public class StormControllerIntegrationTest { .andExpect(jsonPath("$.id", containsString("broTest"))) .andExpect(jsonPath("$.status").value("ACTIVE")) .andExpect(jsonPath("$.latency").exists()) - .andExpect(jsonPath("$.throughput").exists()); + .andExpect(jsonPath("$.throughput").exists()) + .andExpect(jsonPath("$.emitted").exists()) + .andExpect(jsonPath("$.acked").exists()); this.mockMvc.perform(get(stormUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) @@ -246,7 +248,9 @@ public class StormControllerIntegrationTest { .andExpect(jsonPath("$.id", containsString("enrichment"))) .andExpect(jsonPath("$.status").value("ACTIVE")) .andExpect(jsonPath("$.latency").exists()) - .andExpect(jsonPath("$.throughput").exists()); + .andExpect(jsonPath("$.throughput").exists()) + .andExpect(jsonPath("$.emitted").exists()) + .andExpect(jsonPath("$.acked").exists()); this.mockMvc.perform(get(stormUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) @@ -298,7 +302,9 @@ public class StormControllerIntegrationTest { .andExpect(jsonPath("$.id", containsString("indexing"))) .andExpect(jsonPath("$.status").value("ACTIVE")) .andExpect(jsonPath("$.latency").exists()) - .andExpect(jsonPath("$.throughput").exists()); + .andExpect(jsonPath("$.throughput").exists()) + .andExpect(jsonPath("$.emitted").exists()) + .andExpect(jsonPath("$.acked").exists()); this.mockMvc.perform(get(stormUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/1ef8cd8f/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GrokServiceImplTest.java ---------------------------------------------------------------------- diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GrokServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GrokServiceImplTest.java index 6dd95c5..1935269 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GrokServiceImplTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GrokServiceImplTest.java @@ -232,4 +232,18 @@ public class GrokServiceImplTest { grokService.saveTemporary(null, "squid"); } -} \ No newline at end of file + + @Test + public void getStatementFromClasspathShouldReturnStatement() throws Exception { + String expected = FileUtils.readFileToString(new File("../../metron-platform/metron-parsers/src/main/resources/patterns/squid")); + assertEquals(expected, grokService.getStatementFromClasspath("/patterns/squid")); + } + + @Test + public void getStatementFromClasspathShouldThrowRestException() throws Exception { + exception.expect(RestException.class); + exception.expectMessage("Could not find a statement at path /bad/path"); + + grokService.getStatementFromClasspath("/bad/path"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/1ef8cd8f/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImplTest.java ---------------------------------------------------------------------- diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImplTest.java index d292948..c26a210 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImplTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImplTest.java @@ -242,6 +242,17 @@ public class SensorEnrichmentConfigServiceImplTest { }}, sensorEnrichmentConfigService.getAvailableEnrichments()); } + @Test + public void getAvailableThreatTriageAggregatorsShouldReturnAggregators() throws Exception { + assertEquals(new ArrayList<String>() {{ + add("MAX"); + add("MIN"); + add("SUM"); + add("MEAN"); + add("POSITIVE_MEAN"); + }}, sensorEnrichmentConfigService.getAvailableThreatTriageAggregators()); + } + private SensorEnrichmentConfig getTestSensorEnrichmentConfig() { SensorEnrichmentConfig sensorEnrichmentConfig = new SensorEnrichmentConfig(); EnrichmentConfig enrichmentConfig = new EnrichmentConfig(); http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/1ef8cd8f/metron-interface/metron-rest/src/test/resources/README.vm ---------------------------------------------------------------------- diff --git a/metron-interface/metron-rest/src/test/resources/README.vm b/metron-interface/metron-rest/src/test/resources/README.vm index 99f4286..ca54e6a 100644 --- a/metron-interface/metron-rest/src/test/resources/README.vm +++ b/metron-interface/metron-rest/src/test/resources/README.vm @@ -10,24 +10,24 @@ This module provides a RESTful API for interacting with Metron. #[[##]]# Installation 1. Package the application with Maven: -``` -mvn clean package -``` + ``` + mvn clean package + ``` 1. Untar the archive in the target directory. The directory structure will look like: -``` -bin - start_metron_rest.sh -lib - metron-rest-$METRON_VERSION.jar -``` + ``` + bin + start_metron_rest.sh + lib + metron-rest-$METRON_VERSION.jar + ``` -1. Create an `application.yml` file with the contents of [application-docker.yml](src/main/resources/application-docker.yml). Substitute the appropriate Metron service urls (Kafka, Zookeeper, Storm, etc) in properties containing `${docker.host.address}` and update the `spring.datasource.*` properties as needed (see the [Security](#security) section for more details). +1. Create an `application.yml` file with the contents of [application-docker.yml](src/main/resources/application-docker.yml). Substitute the appropriate Metron service urls (Kafka, Zookeeper, Storm, etc.) in properties containing `${docker.host.address}` and update the `spring.datasource.*` properties as needed (see the [Security](#security) section for more details). 1. Start the application with this command: -``` -./bin/start_metron_rest.sh /path/to/application.yml -``` + ``` + ./bin/start_metron_rest.sh /path/to/application.yml + ``` #[[##]]# Usage @@ -45,36 +45,36 @@ For [production use](http://docs.spring.io/spring-boot/docs/1.4.1.RELEASE/refere 1. Create a MySQL user for the Metron REST application (http://dev.mysql.com/doc/refman/5.7/en/adding-users.html). 1. Connect to MySQL and create a Metron REST database: -``` -CREATE DATABASE IF NOT EXISTS metronrest -``` + ``` + CREATE DATABASE IF NOT EXISTS metronrest + ``` 1. Add users: -``` -use metronrest; -insert into users (username, password, enabled) values ('your_username','your_password',1); -insert into authorities (username, authority) values ('your_username', 'ROLE_USER'); -``` + ``` + use metronrest; + insert into users (username, password, enabled) values ('your_username','your_password',1); + insert into authorities (username, authority) values ('your_username', 'ROLE_USER'); + ``` 1. Replace the H2 connection information in the application.yml file with MySQL connection information: -``` -spring: - datasource: - driverClassName: com.mysql.jdbc.Driver - url: jdbc:mysql://mysql_host:3306/metronrest - username: metron_rest_user - password: metron_rest_password - platform: mysql -``` + ``` + spring: + datasource: + driverClassName: com.mysql.jdbc.Driver + url: jdbc:mysql://mysql_host:3306/metronrest + username: metron_rest_user + password: metron_rest_password + platform: mysql + ``` 1. Add a dependency for the MySQL JDBC connector in the metron-rest pom.xml: -``` -<dependency> - <groupId>mysql</groupId> - <artifactId>mysql-connector-java</artifactId> - <version>${mysql.client.version}</version> -</dependency> -``` + ``` + <dependency> + <groupId>mysql</groupId> + <artifactId>mysql-connector-java</artifactId> + <version>${mysql.client.version}</version> + </dependency> + ``` 1. Follow the steps in the [Installation](#installation) section @@ -85,7 +85,7 @@ Request and Response objects are JSON formatted. The JSON schemas are available | | | ---------- | #foreach( $restControllerInfo in $endpoints ) -| [ `$restControllerInfo.getMethod().toString() $restControllerInfo.getPath()`](#$restControllerInfo.getMethod().toString().toLowerCase()-$restControllerInfo.getPath().toLowerCase().replaceAll("/", ""))| +| [ `$restControllerInfo.getMethod().toString() $restControllerInfo.getPath()`](#$restControllerInfo.getMethod().toString().toLowerCase()-$restControllerInfo.getPath().toLowerCase().replaceAll("[/\{\}]", ""))| #end #foreach( $restControllerInfo in $endpoints ) http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/1ef8cd8f/metron-interface/pom.xml ---------------------------------------------------------------------- diff --git a/metron-interface/pom.xml b/metron-interface/pom.xml index 805c024..d762924 100644 --- a/metron-interface/pom.xml +++ b/metron-interface/pom.xml @@ -39,6 +39,7 @@ </license> </licenses> <modules> + <module>metron-config</module> <module>metron-rest</module> <module>metron-rest-client</module> </modules> http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/1ef8cd8f/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 7907435..e86c5de 100644 --- a/pom.xml +++ b/pom.xml @@ -301,7 +301,20 @@ <exclude>**/hbase/data/**</exclude> <exclude>**/kafkazk/data/**</exclude> <exclude>**/wait-for-it.sh</exclude> - <exclude>**/*.out</exclude> + <exclude>**/*.out</exclude> + <!-- Directory containing dependencies downloaded by NPM --> + <exclude>node_modules/**</exclude> + <!-- Nodejs installed locally by the frontend-maven-plugin --> + <exclude>node/**</exclude> + <!-- Javascript code coverage report generated by Istanbul --> + <exclude>coverage/**</exclude> + <!-- ACE editor assets are covered in the metron-config NOTICE file --> + <exclude>**/src/assets/ace/**</exclude> + <exclude>dist/assets/ace/**</exclude> + <!-- Generated svg containing Font Awesome fonts are covered in the metron-config README and NOTICE file --> + <exclude>dist/*.svg</exclude> + + <exclude>e2e/*.js.map</exclude> </excludes> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/incubator-metron/blob/1ef8cd8f/site-book/bin/generate-md.sh ---------------------------------------------------------------------- diff --git a/site-book/bin/generate-md.sh b/site-book/bin/generate-md.sh index 65bbfd7..0859b7c 100755 --- a/site-book/bin/generate-md.sh +++ b/site-book/bin/generate-md.sh @@ -49,6 +49,7 @@ EXCLUSION_LIST=( '/site/' '/site-book/' '/build_utils/' + '/node_modules/' '/\.github/' )