From b7d310ede8785f411c9a4518207dfa3ef77983b3 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Wed, 19 Oct 2016 10:24:52 -0500 Subject: [PATCH 01/54] Initial implementation of REST service --- metron-interface/metron-rest/pom.xml | 132 +++++++++++ .../metron/rest/MetronRestApplication.java | 29 +++ .../metron/rest/config/ZookeeperConfig.java | 38 +++ .../SensorParserConfigController.java | 65 ++++++ .../service/SensorParserConfigService.java | 84 +++++++ .../src/main/resources/application.yml | 21 ++ .../rest/MetronRestApplicationTest.java | 42 ++++ ...ParserConfigControllerIntegrationTest.java | 216 ++++++++++++++++++ .../rest/service/SensorParserConfigTest.java | 104 +++++++++ metron-interface/pom.xml | 94 ++++++++ pom.xml | 1 + 11 files changed, 826 insertions(+) create mode 100644 metron-interface/metron-rest/pom.xml create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestApplication.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java create mode 100644 metron-interface/metron-rest/src/main/resources/application.yml create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/MetronRestApplicationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java create mode 100644 metron-interface/pom.xml diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml new file mode 100644 index 0000000000..ebfb0adf4e --- /dev/null +++ b/metron-interface/metron-rest/pom.xml @@ -0,0 +1,132 @@ + + + + + 4.0.0 + + org.apache.metron + metron-interface + 0.2.1BETA + + metron-rest + + UTF-8 + UTF-8 + 1.8 + 4.5 + 2.7.1 + 1.6.4 + + + + org.springframework.boot + spring-boot-starter-web + + + org.apache.curator + curator-recipes + ${curator.version} + + + com.googlecode.json-simple + json-simple + ${global_json_simple_version} + + + org.antlr + antlr4-runtime + ${antlr.version} + + + org.apache.metron + metron-common + ${project.parent.version} + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito + ${powermock.version} + test + + + org.apache.metron + metron-integration-test + ${project.parent.version} + test + + + + + + + + org.springframework.boot + spring-boot-dependencies + 1.4.1.RELEASE + pom + import + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.19.1 + + + org.codehaus.mojo + emma-maven-plugin + 1.0-alpha-3 + + + org.apache.maven.plugins + maven-pmd-plugin + + ${global_java_version} + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestApplication.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestApplication.java new file mode 100644 index 0000000000..ac89b1dc67 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestApplication.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MetronRestApplication { + + public static void main(String[] args) { + SpringApplication.run(MetronRestApplication.class, args); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java new file mode 100644 index 0000000000..7091f9b74e --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java @@ -0,0 +1,38 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import org.apache.curator.RetryPolicy; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.ExponentialBackoffRetry; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; + +@Configuration +public class ZookeeperConfig { + + public static final String ZK_URL_SPRING_PROPERTY = "zookeeper.url"; + + @Bean(initMethod = "start", destroyMethod="close") + public CuratorFramework client(Environment environment) { + RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3); + return CuratorFrameworkFactory.newClient(environment.getProperty(ZK_URL_SPRING_PROPERTY), retryPolicy); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java new file mode 100644 index 0000000000..0bd01bcbf7 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java @@ -0,0 +1,65 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.service.SensorParserConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@org.springframework.web.bind.annotation.RestController +@RequestMapping("/sensorParserConfigs") +public class SensorParserConfigController { + + @Autowired + private SensorParserConfigService sensorParserConfigService; + + @RequestMapping(method = RequestMethod.POST) + ResponseEntity save(@RequestBody SensorParserConfig sensorParserConfig) throws Exception { + return new ResponseEntity<>(sensorParserConfigService.save(sensorParserConfig), HttpStatus.CREATED); + } + + @RequestMapping(value = "/{name}", method = RequestMethod.GET) + ResponseEntity findOne(@PathVariable String name) throws Exception { + SensorParserConfig sensorParserConfig = sensorParserConfigService.findOne(name); + if (sensorParserConfig != null) { + return new ResponseEntity<>(sensorParserConfig, HttpStatus.OK); + } + + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + @RequestMapping(method = RequestMethod.GET) + ResponseEntity> findAll() throws Exception { + return new ResponseEntity<>(sensorParserConfigService.findAll(), HttpStatus.OK); + } + + @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) + ResponseEntity delete(@PathVariable String name) throws Exception { + if (sensorParserConfigService.delete(name)) { + return new ResponseEntity<>(HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java new file mode 100644 index 0000000000..31b09b7349 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -0,0 +1,84 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.curator.framework.CuratorFramework; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.ConfigurationsUtils; +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.common.utils.JSONUtils; +import org.apache.zookeeper.KeeperException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class SensorParserConfigService { + + private CuratorFramework client; + + @Autowired + public void setClient(CuratorFramework client) { + this.client = client; + } + + public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws Exception { + ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), JSONUtils.INSTANCE.toJSON(sensorParserConfig), client); + return sensorParserConfig; + } + + public SensorParserConfig findOne(String name) throws Exception{ + SensorParserConfig sensorParserConfig; + try { + sensorParserConfig = ConfigurationsUtils.readSensorParserConfigFromZookeeper(name, client); + } catch (KeeperException.NoNodeException e) { + sensorParserConfig = null; + } + return sensorParserConfig; + } + + public Iterable findAll() throws Exception { + List sensorParserConfigs = new ArrayList<>(); + List sensorNames = getAllTypes(); + for (String name : sensorNames) { + sensorParserConfigs.add(findOne(name)); + } + return sensorParserConfigs; + } + + public boolean delete(String name) throws Exception { + try { + client.delete().forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/" + name); + } catch (KeeperException.NoNodeException e) { + return false; + } + return true; + } + + public List getAllTypes() throws Exception { + List types; + try { + types = client.getChildren().forPath(ConfigurationType.PARSER.getZookeeperRoot()); + } catch (KeeperException.NoNodeException e) { + types = new ArrayList<>(); + } + return types; + } +} diff --git a/metron-interface/metron-rest/src/main/resources/application.yml b/metron-interface/metron-rest/src/main/resources/application.yml new file mode 100644 index 0000000000..0554bb2b28 --- /dev/null +++ b/metron-interface/metron-rest/src/main/resources/application.yml @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +server: + contextPath: /api/v1 + +zookeeper: + url: node1:2181 \ No newline at end of file diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/MetronRestApplicationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/MetronRestApplicationTest.java new file mode 100644 index 0000000000..3025932094 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/MetronRestApplicationTest.java @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.boot.SpringApplication; + +import static org.mockito.Mockito.times; +import static org.powermock.api.mockito.PowerMockito.mockStatic; +import static org.powermock.api.mockito.PowerMockito.verifyStatic; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({SpringApplication.class}) +public class MetronRestApplicationTest { + + @Test + public void test() { + mockStatic(SpringApplication.class); + String[] args = {"arg1", "arg2"}; + MetronRestApplication.main(args); + verifyStatic(times(1)); + SpringApplication.run(MetronRestApplication.class, args); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java new file mode 100644 index 0000000000..01bc602527 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -0,0 +1,216 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import com.google.common.base.Function; +import org.adrianwalker.multilinestring.Multiline; +import org.apache.curator.RetryPolicy; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.metron.integration.ComponentRunner; +import org.apache.metron.integration.components.KafkaWithZKComponent; +import org.apache.metron.rest.service.SensorParserConfigService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import javax.annotation.Nullable; + +import static org.hamcrest.Matchers.hasSize; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +public class SensorParserConfigControllerIntegrationTest { + + /** + { + "parserClassName": "org.apache.metron.parsers.GrokParser", + "sensorTopic": "squid", + "parserConfig": { + "grokPath": "/patterns/squid", + "patternLabel": "SQUID_DELIMITED", + "timestampField": "timestamp" + }, + "fieldTransformations" : [ + { + "transformation" : "STELLAR" + ,"output" : [ "full_hostname", "domain_without_subdomains" ] + ,"config" : { + "full_hostname" : "URL_TO_HOST(url)" + ,"domain_without_subdomains" : "DOMAIN_REMOVE_SUBDOMAINS(full_hostname)" + } + } + ] + } + */ + @Multiline + public static String squidJson; + + /** + { + "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", + "sensorTopic":"bro", + "parserConfig": {} + } + */ + @Multiline + public static String broJson; + + @Autowired + private WebApplicationContext wac; + + private MockMvc mockMvc; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); + } + + @Autowired + private ApplicationContext applicationContext; + + @Test + public void test() throws Exception { + final KafkaWithZKComponent kafkaWithZKComponent = new KafkaWithZKComponent().withPostStartCallback(new Function() { + @Nullable + @Override + public Void apply(@Nullable KafkaWithZKComponent kafkaWithZKComponent) { + SensorParserConfigService sensorParserConfigService = (SensorParserConfigService) applicationContext.getBean("sensorParserConfigService"); + RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3); + CuratorFramework client = CuratorFrameworkFactory.newClient(kafkaWithZKComponent.getZookeeperConnect(), retryPolicy); + client.start(); + sensorParserConfigService.setClient(client); + return null; + } + }); + ComponentRunner runner = new ComponentRunner.Builder() + .withComponent("kafka", kafkaWithZKComponent) + .build(); + runner.start(); + + this.mockMvc.perform(post("/sensorParserConfigs").contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.GrokParser")) + .andExpect(jsonPath("$.sensorTopic").value("squid")) + .andExpect(jsonPath("$.parserConfig.grokPath").value("/patterns/squid")) + .andExpect(jsonPath("$.parserConfig.patternLabel").value("SQUID_DELIMITED")) + .andExpect(jsonPath("$.parserConfig.timestampField").value("timestamp")) + .andExpect(jsonPath("$.fieldTransformations[0].transformation").value("STELLAR")) + .andExpect(jsonPath("$.fieldTransformations[0].output[0]").value("full_hostname")) + .andExpect(jsonPath("$.fieldTransformations[0].output[1]").value("domain_without_subdomains")) + .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) + .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); + + this.mockMvc.perform(get("/sensorParserConfigs/squid")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.GrokParser")) + .andExpect(jsonPath("$.sensorTopic").value("squid")) + .andExpect(jsonPath("$.parserConfig.grokPath").value("/patterns/squid")) + .andExpect(jsonPath("$.parserConfig.patternLabel").value("SQUID_DELIMITED")) + .andExpect(jsonPath("$.parserConfig.timestampField").value("timestamp")) + .andExpect(jsonPath("$.fieldTransformations[0].transformation").value("STELLAR")) + .andExpect(jsonPath("$.fieldTransformations[0].output[0]").value("full_hostname")) + .andExpect(jsonPath("$.fieldTransformations[0].output[1]").value("domain_without_subdomains")) + .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) + .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); + + this.mockMvc.perform(get("/sensorParserConfigs")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$", hasSize(1))) + .andExpect(jsonPath("$[0].parserClassName").value("org.apache.metron.parsers.GrokParser")) + .andExpect(jsonPath("$[0].sensorTopic").value("squid")) + .andExpect(jsonPath("$[0].parserConfig.grokPath").value("/patterns/squid")) + .andExpect(jsonPath("$[0].parserConfig.patternLabel").value("SQUID_DELIMITED")) + .andExpect(jsonPath("$[0].parserConfig.timestampField").value("timestamp")) + .andExpect(jsonPath("$[0].fieldTransformations[0].transformation").value("STELLAR")) + .andExpect(jsonPath("$[0].fieldTransformations[0].output[0]").value("full_hostname")) + .andExpect(jsonPath("$[0].fieldTransformations[0].output[1]").value("domain_without_subdomains")) + .andExpect(jsonPath("$[0].fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) + .andExpect(jsonPath("$[0].fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); + + this.mockMvc.perform(post("/sensorParserConfigs").contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$.sensorTopic").value("bro")) + .andExpect(jsonPath("$.parserConfig").isEmpty()); + + this.mockMvc.perform(get("/sensorParserConfigs")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$", hasSize(2))) + .andExpect(jsonPath("$[0].parserClassName").value("org.apache.metron.parsers.GrokParser")) + .andExpect(jsonPath("$[0].sensorTopic").value("squid")) + .andExpect(jsonPath("$[0].parserConfig.grokPath").value("/patterns/squid")) + .andExpect(jsonPath("$[0].parserConfig.patternLabel").value("SQUID_DELIMITED")) + .andExpect(jsonPath("$[0].parserConfig.timestampField").value("timestamp")) + .andExpect(jsonPath("$[0].fieldTransformations[0].transformation").value("STELLAR")) + .andExpect(jsonPath("$[0].fieldTransformations[0].output[0]").value("full_hostname")) + .andExpect(jsonPath("$[0].fieldTransformations[0].output[1]").value("domain_without_subdomains")) + .andExpect(jsonPath("$[0].fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) + .andExpect(jsonPath("$[0].fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")) + .andExpect(jsonPath("$[1].parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$[1].sensorTopic").value("bro")) + .andExpect(jsonPath("$[1].parserConfig").isEmpty()); + + this.mockMvc.perform(delete("/sensorParserConfigs/squid")) + .andExpect(status().isOk()); + + this.mockMvc.perform(get("/sensorParserConfigs/squid")) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(delete("/sensorParserConfigw/squid")) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(get("/sensorParserConfigs")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[0].parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$[0].sensorTopic").value("bro")) + .andExpect(jsonPath("$[0].parserConfig").isEmpty()); + + this.mockMvc.perform(delete("/sensorParserConfigs/bro")) + .andExpect(status().isOk()); + + this.mockMvc.perform(delete("/sensorParserConfigs/bro")) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(get("/sensorParserConfigs")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$", hasSize(0))); + + runner.stop(); + } +} + diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java new file mode 100644 index 0000000000..0d1242ce2b --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java @@ -0,0 +1,104 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.api.DeleteBuilder; +import org.apache.curator.framework.api.GetChildrenBuilder; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.ConfigurationsUtils; +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.common.utils.JSONUtils; +import org.apache.zookeeper.KeeperException; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.mockStatic; +import static org.powermock.api.mockito.PowerMockito.verifyStatic; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({ConfigurationsUtils.class}) +public class SensorParserConfigTest { + + @Mock + private GetChildrenBuilder getChildrenBuilder; + + @Mock + private DeleteBuilder deleteBuilder; + + @Mock + private CuratorFramework client; + + @InjectMocks + private SensorParserConfigService sensorParserConfigService; + + @Before + public void setUp() throws Exception { + MockitoAnnotations.initMocks(this); + Mockito.when(client.getChildren()).thenReturn(getChildrenBuilder); + Mockito.when(client.delete()).thenReturn(deleteBuilder); + } + + @Test + public void test() throws Exception { + mockStatic(ConfigurationsUtils.class); + SensorParserConfig broParserConfig = new SensorParserConfig(); + broParserConfig.setParserClassName("org.apache.metron.parsers.bro.BasicBroParser"); + broParserConfig.setSensorTopic("bro"); + sensorParserConfigService.save(broParserConfig); + verifyStatic(times(1)); + ConfigurationsUtils.writeSensorParserConfigToZookeeper("bro", JSONUtils.INSTANCE.toJSON(broParserConfig), client); + + PowerMockito.when(ConfigurationsUtils.readSensorParserConfigFromZookeeper("bro", client)).thenReturn(broParserConfig); + assertEquals(broParserConfig, sensorParserConfigService.findOne("bro")); + + SensorParserConfig squidParserConfig = new SensorParserConfig(); + squidParserConfig.setParserClassName("org.apache.metron.parsers.GrokParser"); + squidParserConfig.setSensorTopic("squid"); + PowerMockito.when(ConfigurationsUtils.readSensorParserConfigFromZookeeper("squid", client)).thenReturn(squidParserConfig); + + List allTypes = new ArrayList() {{ + add("bro"); + add("squid"); + }}; + Mockito.when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())).thenReturn(allTypes); + assertEquals(new ArrayList() {{ add(broParserConfig); add(squidParserConfig); }}, sensorParserConfigService.findAll()); + + Mockito.when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())).thenThrow(new KeeperException.NoNodeException()); + assertEquals(new ArrayList<>(), sensorParserConfigService.findAll()); + + assertTrue(sensorParserConfigService.delete("bro")); + verify(deleteBuilder, times(1)).forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro"); + Mockito.when(deleteBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenThrow(new KeeperException.NoNodeException()); + assertFalse(sensorParserConfigService.delete("bro")); + } +} diff --git a/metron-interface/pom.xml b/metron-interface/pom.xml new file mode 100644 index 0000000000..07d6e1c1c1 --- /dev/null +++ b/metron-interface/pom.xml @@ -0,0 +1,94 @@ + + + + + 4.0.0 + metron-interface + pom + metron-interface + + org.apache.metron + Metron + 0.2.1BETA + + Interfaces for Metron + https://metron.incubator.apache.org/ + + scm:git:https://git-wip-us.apache.org/repos/asf/incubator-metron.git + scm:git:https://git-wip-us.apache.org/repos/asf/incubator-metron.git + HEAD + https://git-wip-us.apache.org/repos/asf/incubator-metron + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + metron-rest + + + + junit + junit + 4.12 + test + + + org.adrianwalker + multiline-string + 0.1.2 + test + + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18 + + + org.apache.maven.plugins + maven-pmd-plugin + 3.3 + + ${global_java_version} + + + + org.codehaus.mojo + emma-maven-plugin + 1.0-alpha-3 + true + + + + + + multiline-release-repo + https://raw.github.com/benelog/multiline/master/maven-repository + + false + + + + diff --git a/pom.xml b/pom.xml index 4d6adb38cc..a2fe51cb76 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ metron-analytics metron-platform metron-deployment + metron-interface @ApacheMetron From 77e79aba34e992c951ee804d918aea1e70b638ec Mon Sep 17 00:00:00 2001 From: rmerriman Date: Wed, 19 Oct 2016 10:31:18 -0500 Subject: [PATCH 02/54] added newline at the end of application.yml --- metron-interface/metron-rest/src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metron-interface/metron-rest/src/main/resources/application.yml b/metron-interface/metron-rest/src/main/resources/application.yml index 0554bb2b28..2d63bae336 100644 --- a/metron-interface/metron-rest/src/main/resources/application.yml +++ b/metron-interface/metron-rest/src/main/resources/application.yml @@ -18,4 +18,4 @@ server: contextPath: /api/v1 zookeeper: - url: node1:2181 \ No newline at end of file + url: node1:2181 From b042dfdce8e12bf320ff5dcd7b46edf68c66a302 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 24 Oct 2016 11:07:21 -0500 Subject: [PATCH 03/54] Added logging configuration and fixed SLF4J warnings. --- metron-interface/metron-rest/pom.xml | 35 ++++++++++++++++++- .../src/main/resources/application-test.yml | 24 +++++++++++++ .../src/main/resources/application.yml | 3 ++ ...ParserConfigControllerIntegrationTest.java | 2 ++ .../src/test/resources/log4j.properties | 4 +++ 5 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 metron-interface/metron-rest/src/main/resources/application-test.yml create mode 100644 metron-interface/metron-rest/src/test/resources/log4j.properties diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index ebfb0adf4e..dd84a0c907 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -21,6 +21,7 @@ 0.2.1BETA metron-rest + ${project.parent.version} UTF-8 UTF-8 @@ -28,11 +29,22 @@ 4.5 2.7.1 1.6.4 + 1.4.1.RELEASE org.springframework.boot spring-boot-starter-web + + + ch.qos.logback + logback-classic + + + org.slf4j + log4j-over-slf4j + + org.apache.curator @@ -77,6 +89,16 @@ metron-integration-test ${project.parent.version} test + + + org.apache.logging.log4j + log4j-slf4j-impl + + + org.slf4j + log4j-over-slf4j + + @@ -86,9 +108,19 @@ org.springframework.boot spring-boot-dependencies - 1.4.1.RELEASE + ${spring.boot.version} pom import + + + org.apache.logging.log4j + log4j-slf4j-impl + + + ch.qos.logback + logback-classic + + @@ -119,6 +151,7 @@ org.springframework.boot spring-boot-maven-plugin + ${spring.boot.version} diff --git a/metron-interface/metron-rest/src/main/resources/application-test.yml b/metron-interface/metron-rest/src/main/resources/application-test.yml new file mode 100644 index 0000000000..8fe6d9ac69 --- /dev/null +++ b/metron-interface/metron-rest/src/main/resources/application-test.yml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +logging: + level: + root: ERROR + +server: + contextPath: /api/v1 + +zookeeper: + url: localhost:2181 \ No newline at end of file diff --git a/metron-interface/metron-rest/src/main/resources/application.yml b/metron-interface/metron-rest/src/main/resources/application.yml index 2d63bae336..32375f936e 100644 --- a/metron-interface/metron-rest/src/main/resources/application.yml +++ b/metron-interface/metron-rest/src/main/resources/application.yml @@ -13,6 +13,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +logging: + level: + root: ERROR server: contextPath: /api/v1 diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java index 01bc602527..5bd96cf4ec 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -33,6 +33,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; @@ -47,6 +48,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") public class SensorParserConfigControllerIntegrationTest { /** diff --git a/metron-interface/metron-rest/src/test/resources/log4j.properties b/metron-interface/metron-rest/src/test/resources/log4j.properties new file mode 100644 index 0000000000..ffc66d622b --- /dev/null +++ b/metron-interface/metron-rest/src/test/resources/log4j.properties @@ -0,0 +1,4 @@ +log4j.rootLogger=ERROR, stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS} %-5p [%c] - %m%n \ No newline at end of file From 2012369e3094dcc0d15365b914005d035e938824 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 18 Nov 2016 17:11:40 -0600 Subject: [PATCH 04/54] Metron Docker implementation --- metron-docker/.env | 2 + metron-docker/.gitignore | 6 + metron-docker/README.md | 68 + metron-docker/create-docker-machine.sh | 18 + metron-docker/docker-compose.yml | 73 + metron-docker/hbase/Dockerfile | 42 + metron-docker/hbase/bin/init-commands.txt | 5 + metron-docker/hbase/bin/init-hbase.sh | 21 + metron-docker/hbase/bin/start.sh | 21 + metron-docker/hbase/bin/wait-for-it.sh | 161 + .../hbase/conf/enrichment-extractor.json | 12 + .../hbase/conf/hbase-site.docker.xml | 41 + .../hbase/conf/threatintel-extractor.json | 11 + metron-docker/hbase/data/enrichments.csv | 3 + metron-docker/hbase/data/threatintel.csv | 3 + metron-docker/install-metron.sh | 39 + metron-docker/kafkazk/Dockerfile | 33 + metron-docker/kafkazk/bin/create-topic.sh | 18 + metron-docker/kafkazk/bin/init-kafka.sh | 19 + metron-docker/kafkazk/bin/init-zk.sh | 22 + metron-docker/kafkazk/bin/produce-data.sh | 37 + metron-docker/kafkazk/bin/run-consumer.sh | 18 + metron-docker/kafkazk/bin/start.sh | 24 + metron-docker/kafkazk/bin/wait-for-it.sh | 161 + .../kafkazk/data/BroExampleOutput.txt | 10 + .../kafkazk/data/SquidExampleOutput.txt | 5 + metron-docker/kibana/Dockerfile | 20 + metron-docker/kibana/conf/kibana-index.json | 34 + metron-docker/kibana/images/metron.svg | 73 + metron-docker/kibana/styles/commons.style.css | 11944 ++++++++++++++++ metron-docker/mysql/Dockerfile | 36 + metron-docker/mysql/bin/init-mysql.sh | 19 + metron-docker/mysql/bin/start.sh | 21 + metron-docker/mysql/bin/wait-for-it.sh | 161 + metron-docker/storm/Dockerfile | 58 + metron-docker/storm/bin/init-storm.sh | 19 + metron-docker/storm/bin/start.sh | 19 + 37 files changed, 13277 insertions(+) create mode 100644 metron-docker/.env create mode 100644 metron-docker/.gitignore create mode 100644 metron-docker/README.md create mode 100755 metron-docker/create-docker-machine.sh create mode 100644 metron-docker/docker-compose.yml create mode 100644 metron-docker/hbase/Dockerfile create mode 100755 metron-docker/hbase/bin/init-commands.txt create mode 100755 metron-docker/hbase/bin/init-hbase.sh create mode 100755 metron-docker/hbase/bin/start.sh create mode 100755 metron-docker/hbase/bin/wait-for-it.sh create mode 100644 metron-docker/hbase/conf/enrichment-extractor.json create mode 100644 metron-docker/hbase/conf/hbase-site.docker.xml create mode 100644 metron-docker/hbase/conf/threatintel-extractor.json create mode 100644 metron-docker/hbase/data/enrichments.csv create mode 100644 metron-docker/hbase/data/threatintel.csv create mode 100755 metron-docker/install-metron.sh create mode 100644 metron-docker/kafkazk/Dockerfile create mode 100755 metron-docker/kafkazk/bin/create-topic.sh create mode 100755 metron-docker/kafkazk/bin/init-kafka.sh create mode 100755 metron-docker/kafkazk/bin/init-zk.sh create mode 100755 metron-docker/kafkazk/bin/produce-data.sh create mode 100755 metron-docker/kafkazk/bin/run-consumer.sh create mode 100755 metron-docker/kafkazk/bin/start.sh create mode 100755 metron-docker/kafkazk/bin/wait-for-it.sh create mode 100644 metron-docker/kafkazk/data/BroExampleOutput.txt create mode 100644 metron-docker/kafkazk/data/SquidExampleOutput.txt create mode 100644 metron-docker/kibana/Dockerfile create mode 100644 metron-docker/kibana/conf/kibana-index.json create mode 100644 metron-docker/kibana/images/metron.svg create mode 100644 metron-docker/kibana/styles/commons.style.css create mode 100644 metron-docker/mysql/Dockerfile create mode 100755 metron-docker/mysql/bin/init-mysql.sh create mode 100755 metron-docker/mysql/bin/start.sh create mode 100755 metron-docker/mysql/bin/wait-for-it.sh create mode 100644 metron-docker/storm/Dockerfile create mode 100755 metron-docker/storm/bin/init-storm.sh create mode 100755 metron-docker/storm/bin/start.sh diff --git a/metron-docker/.env b/metron-docker/.env new file mode 100644 index 0000000000..95e14bb5c8 --- /dev/null +++ b/metron-docker/.env @@ -0,0 +1,2 @@ +METRON_VERSION=0.3.0 +COMPOSE_PROJECT_NAME=metron \ No newline at end of file diff --git a/metron-docker/.gitignore b/metron-docker/.gitignore new file mode 100644 index 0000000000..001e46c9d3 --- /dev/null +++ b/metron-docker/.gitignore @@ -0,0 +1,6 @@ +/mysql/enrichment +/hbase/data-management +/storm/elasticsearch +/storm/enrichment +/storm/parser +/storm/indexing \ No newline at end of file diff --git a/metron-docker/README.md b/metron-docker/README.md new file mode 100644 index 0000000000..c54cb2e1c5 --- /dev/null +++ b/metron-docker/README.md @@ -0,0 +1,68 @@ +# Metron Docker + +Metron Docker is a [Docker Compose](https://docs.docker.com/compose/overview/) application that is intended for development and integration testing of Metron. Use this instead of Vagrant when: + + - You want an environment that can be built and spun up quickly + - You need to frequently rebuild and restart services + - You only need to test, troubleshoot or develop against a subset of services + +Metron Docker includes these images that have been customized for Metron: + + - Kafka (with Zookeeper) + - HBase + - Storm (with all topologies deployed) + - MySQL + - Elasticsearch + - Kibana + +Setup +----- + +Install Docker from https://docs.docker.com/docker-for-mac/. The following versions have been tested: + + - Docker version 1.12.0 + - docker-machine version 0.8.0 + - docker-compose version 1.8.0 + +External Metron binaries must be deployed to the various Dockerfile contexts. Run this script to do that: +``` +./install-metron.sh -b +``` + +If your Metron project has already been compiled and packaged with Maven, you can skip that step by removing the -b option: +``` +./install-metron.sh +``` + +You are welcome to use an existing docker-machine but we prefer a machine with more resources. You can create one of those by running this: +``` +./create-docker-machine.sh +``` + +This will create a docker-machine called "metron-machine". Anytime you want to run Docker commands against this machine, make sure you run this first to set the Docker environment variables: +``` +eval "$(docker-machine env metron-machine)" +``` + +Usage +----- + +The Metron Docker environment lifecycle is controlled by the [docker-compose](https://docs.docker.com/compose/reference/overview/) command. For example, to build the environment run this command: +``` +docker-compose up -d +``` + +If a new parser is added to metron-parsers, run these commands to redeploy the parsers to the Storm image: +``` +docker-compose down +./install-metron -b +docker-compose build storm +docker-compose up -d +``` + +If there is a problem with Kafka, run this command to connect and explore the Kafka container: +``` +docker-compose exec kafkazk bash +``` + +These service names can be found in the docker-compose.yml file. \ No newline at end of file diff --git a/metron-docker/create-docker-machine.sh b/metron-docker/create-docker-machine.sh new file mode 100755 index 0000000000..241f4ae433 --- /dev/null +++ b/metron-docker/create-docker-machine.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +docker-machine create --driver virtualbox --virtualbox-disk-size "30000" --virtualbox-memory "4096" --virtualbox-cpu-count "2" metron-machine diff --git a/metron-docker/docker-compose.yml b/metron-docker/docker-compose.yml new file mode 100644 index 0000000000..1e2da2bcff --- /dev/null +++ b/metron-docker/docker-compose.yml @@ -0,0 +1,73 @@ +version: '2' +services: + mysql: + #container_name: metron-mysql + build: + context: ./mysql + args: + METRON_VERSION: $METRON_VERSION + ports: + - "3306:3306" + environment: + MYSQL_ROOT_PASSWORD: root +# networks: +# - metron-network + kafkazk: + #container_name: metron-kafkazk + build: + context: ./kafkazk + args: + DOCKER_HOST: $DOCKER_HOST + ports: + - "9092:9092" + - "2181:2181" +# networks: +# - metron-network + hbase: + # container_name: metron-hbase + build: + context: ./hbase + args: + METRON_VERSION: $METRON_VERSION + ports: + - "16010:16010" + volumes: + - "/opt/hbase-1.1.6/conf" +# networks: +# - metron-network + depends_on: + - kafkazk + storm: + # container_name: metron-storm + build: + context: ./storm + args: + METRON_VERSION: $METRON_VERSION + ports: + - "8000:8000" + - "8080:8080" + - "8081:8081" + environment: + ZOOKEEPER_ADDR: kafkazk + volumes_from: + - hbase + depends_on: + - mysql + - kafkazk + - hbase + - elasticsearch +# networks: +# - metron-network + command: --daemon nimbus supervisor ui logviewer + elasticsearch: + # container_name: metron-elasticsearch + image: elasticsearch:2.3 + ports: + - "9200:9200" + - "9300:9300" + kibana: + build: ./kibana + ports: + - "5601:5601" + depends_on: + - elasticsearch diff --git a/metron-docker/hbase/Dockerfile b/metron-docker/hbase/Dockerfile new file mode 100644 index 0000000000..f29bd2ed2c --- /dev/null +++ b/metron-docker/hbase/Dockerfile @@ -0,0 +1,42 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM centos + +ARG METRON_VERSION + +ENV METRON_VERSION $METRON_VERSION +ENV JAVA_HOME /usr +ENV HBASE_HOME /opt/hbase-1.1.6 +ENV HBASE_MANAGES_ZK false +ENV METRON_HOME /usr/metron/$METRON_VERSION/ + +ADD ./data /data +ADD ./data-management /data-management +RUN mkdir -p $METRON_HOME +RUN tar -xzf /data-management/metron-data-management-$METRON_VERSION-archive.tar.gz -C /usr/metron/$METRON_VERSION/ +ADD http://archive.apache.org/dist/hbase/1.1.6/hbase-1.1.6-bin.tar.gz /opt/hbase-1.1.6-bin.tar.gz +RUN tar -xzf /opt/hbase-1.1.6-bin.tar.gz -C /opt +RUN yum install -y java-1.8.0-openjdk lsof +ADD ./conf/enrichment-extractor.json /conf/enrichment-extractor.json +ADD ./conf/threatintel-extractor.json /conf/threatintel-extractor.json +ADD ./conf/hbase-site.docker.xml $HBASE_HOME/conf/hbase-site.xml +ADD ./bin $HBASE_HOME/bin + +EXPOSE 8080 8085 9090 9095 16000 16010 16201 16301 + +WORKDIR /opt/hbase-1.1.6 +CMD ./bin/start.sh diff --git a/metron-docker/hbase/bin/init-commands.txt b/metron-docker/hbase/bin/init-commands.txt new file mode 100755 index 0000000000..31ce0f39cf --- /dev/null +++ b/metron-docker/hbase/bin/init-commands.txt @@ -0,0 +1,5 @@ +create 'access_tracker', 'cf' +create 'ip', 'cf' +create 'enrichment', 'cf' +create 'threatintel', 'cf' +exit \ No newline at end of file diff --git a/metron-docker/hbase/bin/init-hbase.sh b/metron-docker/hbase/bin/init-hbase.sh new file mode 100755 index 0000000000..bbe1716918 --- /dev/null +++ b/metron-docker/hbase/bin/init-hbase.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +export HBASE_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` +./bin/hbase shell ./bin/init-commands.txt +java -cp $HBASE_CLASSPATH:/usr/metron/$METRON_VERSION/lib/metron-data-management-$METRON_VERSION.jar org.apache.metron.dataloads.nonbulk.flatfile.SimpleEnrichmentFlatFileLoader -e /conf/enrichment-extractor.json -t enrichment -c cf -i /data/enrichments.csv +java -cp $HBASE_CLASSPATH:/usr/metron/$METRON_VERSION/lib/metron-data-management-$METRON_VERSION.jar org.apache.metron.dataloads.nonbulk.flatfile.SimpleEnrichmentFlatFileLoader -e /conf/threatintel-extractor.json -t threatintel -c cf -i /data/threatintel.csv diff --git a/metron-docker/hbase/bin/start.sh b/metron-docker/hbase/bin/start.sh new file mode 100755 index 0000000000..20d01d261a --- /dev/null +++ b/metron-docker/hbase/bin/start.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +./bin/start-hbase.sh +./bin/wait-for-it.sh localhost:16010 +./bin/init-hbase.sh +tail -f /dev/null diff --git a/metron-docker/hbase/bin/wait-for-it.sh b/metron-docker/hbase/bin/wait-for-it.sh new file mode 100755 index 0000000000..eca6c3b9c8 --- /dev/null +++ b/metron-docker/hbase/bin/wait-for-it.sh @@ -0,0 +1,161 @@ +#!/usr/bin/env bash +# Use this script to test if a given TCP host/port are available + +cmdname=$(basename $0) + +echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } + +usage() +{ + cat << USAGE >&2 +Usage: + $cmdname host:port [-s] [-t timeout] [-- command args] + -h HOST | --host=HOST Host or IP under test + -p PORT | --port=PORT TCP port under test + Alternatively, you specify the host and port as host:port + -s | --strict Only execute subcommand if the test succeeds + -q | --quiet Don't output any status messages + -t TIMEOUT | --timeout=TIMEOUT + Timeout in seconds, zero for no timeout + -- COMMAND ARGS Execute command with args after the test finishes +USAGE + exit 1 +} + +wait_for() +{ + if [[ $TIMEOUT -gt 0 ]]; then + echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" + else + echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" + fi + start_ts=$(date +%s) + while : + do + (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 + result=$? + if [[ $result -eq 0 ]]; then + end_ts=$(date +%s) + echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" + break + fi + sleep 1 + done + return $result +} + +wait_for_wrapper() +{ + # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 + if [[ $QUIET -eq 1 ]]; then + timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & + else + timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & + fi + PID=$! + trap "kill -INT -$PID" INT + wait $PID + RESULT=$? + if [[ $RESULT -ne 0 ]]; then + echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" + fi + return $RESULT +} + +# process arguments +while [[ $# -gt 0 ]] +do + case "$1" in + *:* ) + hostport=(${1//:/ }) + HOST=${hostport[0]} + PORT=${hostport[1]} + shift 1 + ;; + --child) + CHILD=1 + shift 1 + ;; + -q | --quiet) + QUIET=1 + shift 1 + ;; + -s | --strict) + STRICT=1 + shift 1 + ;; + -h) + HOST="$2" + if [[ $HOST == "" ]]; then break; fi + shift 2 + ;; + --host=*) + HOST="${1#*=}" + shift 1 + ;; + -p) + PORT="$2" + if [[ $PORT == "" ]]; then break; fi + shift 2 + ;; + --port=*) + PORT="${1#*=}" + shift 1 + ;; + -t) + TIMEOUT="$2" + if [[ $TIMEOUT == "" ]]; then break; fi + shift 2 + ;; + --timeout=*) + TIMEOUT="${1#*=}" + shift 1 + ;; + --) + shift + CLI="$@" + break + ;; + --help) + usage + ;; + *) + echoerr "Unknown argument: $1" + usage + ;; + esac +done + +if [[ "$HOST" == "" || "$PORT" == "" ]]; then + echoerr "Error: you need to provide a host and port to test." + usage +fi + +TIMEOUT=${TIMEOUT:-15} +STRICT=${STRICT:-0} +CHILD=${CHILD:-0} +QUIET=${QUIET:-0} + +if [[ $CHILD -gt 0 ]]; then + wait_for + RESULT=$? + exit $RESULT +else + if [[ $TIMEOUT -gt 0 ]]; then + wait_for_wrapper + RESULT=$? + else + wait_for + RESULT=$? + fi +fi + +if [[ $CLI != "" ]]; then + if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then + echoerr "$cmdname: strict mode, refusing to execute subprocess" + exit $RESULT + fi + exec $CLI +else + exit $RESULT +fi diff --git a/metron-docker/hbase/conf/enrichment-extractor.json b/metron-docker/hbase/conf/enrichment-extractor.json new file mode 100644 index 0000000000..f00b3cf599 --- /dev/null +++ b/metron-docker/hbase/conf/enrichment-extractor.json @@ -0,0 +1,12 @@ +{ + "config" : { + "columns" : { + "ip" : 0 + ,"message" : 1 + } + ,"indicator_column" : "ip" + ,"type" : "sample" + ,"separator" : "," + } +,"extractor" : "CSV" +} \ No newline at end of file diff --git a/metron-docker/hbase/conf/hbase-site.docker.xml b/metron-docker/hbase/conf/hbase-site.docker.xml new file mode 100644 index 0000000000..2db8b26bed --- /dev/null +++ b/metron-docker/hbase/conf/hbase-site.docker.xml @@ -0,0 +1,41 @@ + + + + + hbase.rootdir + file:///home/root/hbase + + + hbase.zookeeper.property.dataDir + /home/root/zookeeper + + + + hbase.zookeeper.property.clientPort + 2181 + Property from ZooKeeper's config zoo.cfg. + The port at which the clients will connect. + + + + + hbase.zookeeper.quorum + kafkazk + Comma separated list of servers in the ZooKeeper Quorum. + + + \ No newline at end of file diff --git a/metron-docker/hbase/conf/threatintel-extractor.json b/metron-docker/hbase/conf/threatintel-extractor.json new file mode 100644 index 0000000000..490ef61421 --- /dev/null +++ b/metron-docker/hbase/conf/threatintel-extractor.json @@ -0,0 +1,11 @@ +{ + "config": { + "columns": { + "ip": 0 + }, + "indicator_column": "ip", + "type" : "malicious_ip", + "separator": "," + }, + "extractor": "CSV" +} \ No newline at end of file diff --git a/metron-docker/hbase/data/enrichments.csv b/metron-docker/hbase/data/enrichments.csv new file mode 100644 index 0000000000..4db096d5d6 --- /dev/null +++ b/metron-docker/hbase/data/enrichments.csv @@ -0,0 +1,3 @@ +93.188.160.43,enrichment 1 +192.249.113.37,enrichment 2 +10.122.196.204,enrichment 3 \ No newline at end of file diff --git a/metron-docker/hbase/data/threatintel.csv b/metron-docker/hbase/data/threatintel.csv new file mode 100644 index 0000000000..e68913ca97 --- /dev/null +++ b/metron-docker/hbase/data/threatintel.csv @@ -0,0 +1,3 @@ +93.188.160.43 +192.249.113.37 +10.122.196.204 \ No newline at end of file diff --git a/metron-docker/install-metron.sh b/metron-docker/install-metron.sh new file mode 100755 index 0000000000..7aa7e7adce --- /dev/null +++ b/metron-docker/install-metron.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +METRON_DOCKER_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $METRON_DOCKER_ROOT/.env +METRON_PLATFORM_ROOT=$METRON_DOCKER_ROOT/../metron-platform +if [ $# -gt 0 ] && [ $1 == "-b" ] + then cd $METRON_PLATFORM_ROOT && mvn clean package -DskipTests +fi +mkdir -p $METRON_DOCKER_ROOT/mysql/enrichment/ +mkdir -p $METRON_DOCKER_ROOT/hbase/data-management +mkdir -p $METRON_DOCKER_ROOT/storm/parser/ +mkdir -p $METRON_DOCKER_ROOT/storm/enrichment/ +mkdir -p $METRON_DOCKER_ROOT/storm/indexing/ +mkdir -p $METRON_DOCKER_ROOT/storm/elasticsearch/ +echo Installing MySQL dependencies +cp $METRON_PLATFORM_ROOT/metron-enrichment/target/metron-enrichment-$METRON_VERSION-archive.tar.gz $METRON_DOCKER_ROOT/mysql/enrichment/ +echo Installing HBase dependencies +cp $METRON_PLATFORM_ROOT/metron-data-management/target/metron-data-management-$METRON_VERSION-archive.tar.gz $METRON_DOCKER_ROOT/hbase/data-management +echo Installing Storm dependencies +cp $METRON_PLATFORM_ROOT/metron-parsers/target/metron-parsers-$METRON_VERSION-archive.tar.gz $METRON_DOCKER_ROOT/storm/parser/ +cp $METRON_PLATFORM_ROOT/metron-enrichment/target/metron-enrichment-$METRON_VERSION-archive.tar.gz $METRON_DOCKER_ROOT/storm/enrichment/ +cp $METRON_PLATFORM_ROOT/metron-indexing/target/metron-indexing-$METRON_VERSION-archive.tar.gz $METRON_DOCKER_ROOT/storm/indexing/ +echo Installing Elasticsearch dependencies +cp $METRON_PLATFORM_ROOT/metron-elasticsearch/target/metron-elasticsearch-$METRON_VERSION-archive.tar.gz $METRON_DOCKER_ROOT/storm/elasticsearch/ diff --git a/metron-docker/kafkazk/Dockerfile b/metron-docker/kafkazk/Dockerfile new file mode 100644 index 0000000000..54cec4ad2f --- /dev/null +++ b/metron-docker/kafkazk/Dockerfile @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM centos + +ARG DOCKER_HOST="localhost" + +ADD https://archive.apache.org/dist/kafka/0.10.0.0/kafka_2.11-0.10.0.0.tgz /opt/kafka_2.11-0.10.0.0.tgz +RUN tar -xzf /opt/kafka_2.11-0.10.0.0.tgz -C /opt +RUN echo -n 'advertised.listeners=PLAINTEXT://' >> /opt/kafka_2.11-0.10.0.0/config/server.properties +RUN echo $DOCKER_HOST | sed "s/tcp:\\/\\///g" | sed "s/:.*/:9092/g" >> /opt/kafka_2.11-0.10.0.0/config/server.properties +RUN echo 'delete.topic.enable=true' >> /opt/kafka_2.11-0.10.0.0/config/server.properties +RUN yum install -y java-1.8.0-openjdk lsof +ADD ./bin /opt/kafka_2.11-0.10.0.0/bin +ADD ./data /data + +EXPOSE 2181 9092 + +WORKDIR /opt/kafka_2.11-0.10.0.0 +CMD ./bin/start.sh diff --git a/metron-docker/kafkazk/bin/create-topic.sh b/metron-docker/kafkazk/bin/create-topic.sh new file mode 100755 index 0000000000..7db950adc4 --- /dev/null +++ b/metron-docker/kafkazk/bin/create-topic.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic $1 diff --git a/metron-docker/kafkazk/bin/init-kafka.sh b/metron-docker/kafkazk/bin/init-kafka.sh new file mode 100755 index 0000000000..078c1841b0 --- /dev/null +++ b/metron-docker/kafkazk/bin/init-kafka.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +./bin/create-topic.sh enrichments +./bin/create-topic.sh indexing diff --git a/metron-docker/kafkazk/bin/init-zk.sh b/metron-docker/kafkazk/bin/init-zk.sh new file mode 100755 index 0000000000..7dd4ab214e --- /dev/null +++ b/metron-docker/kafkazk/bin/init-zk.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +echo "create /metron metron" | ./bin/zookeeper-shell.sh localhost:2181 +echo "create /metron/topology topology" | ./bin/zookeeper-shell.sh localhost:2181 +echo 'create /metron/topology/global {"solr.zookeeper":"metron-kafkazk:2181","solr.collection":"metron","solr.numShards":1,"solr.replicationFactor":1,"es.clustername":"elasticsearch","es.ip":"metron-elasticsearch","es.port":"9300","es.date.format":"yyyy.MM.dd.HH"}' | ./bin/zookeeper-shell.sh localhost:2181 +echo "create /metron/topology/parsers parsers" | ./bin/zookeeper-shell.sh localhost:2181 +echo "create /metron/topology/enrichments enrichments" | ./bin/zookeeper-shell.sh localhost:2181 diff --git a/metron-docker/kafkazk/bin/produce-data.sh b/metron-docker/kafkazk/bin/produce-data.sh new file mode 100755 index 0000000000..ff62e94bfc --- /dev/null +++ b/metron-docker/kafkazk/bin/produce-data.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +trap trapint 2 +function trapint { + exit 0 +} +if [ $# -ne 2 ] + then + echo "Usage: produce-data.sh " + exit 0 +fi + +TOPIC=$1 +FILE_PATH=$2 +while : +do +cat $FILE_PATH | while read line +do +echo "Emitting data in $FILE_PATH to Kafka topic $TOPIC" +echo "$line" | ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic $TOPIC > /dev/null +done +done diff --git a/metron-docker/kafkazk/bin/run-consumer.sh b/metron-docker/kafkazk/bin/run-consumer.sh new file mode 100755 index 0000000000..af744d90ec --- /dev/null +++ b/metron-docker/kafkazk/bin/run-consumer.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +./bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic $1 diff --git a/metron-docker/kafkazk/bin/start.sh b/metron-docker/kafkazk/bin/start.sh new file mode 100755 index 0000000000..757e0e6331 --- /dev/null +++ b/metron-docker/kafkazk/bin/start.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +./bin/zookeeper-server-start.sh config/zookeeper.properties & +./bin/wait-for-it.sh localhost:2181 +./bin/init-zk.sh +./bin/kafka-server-start.sh config/server.properties & +./bin/wait-for-it.sh localhost:9092 +./bin/init-kafka.sh +tail -f /dev/null diff --git a/metron-docker/kafkazk/bin/wait-for-it.sh b/metron-docker/kafkazk/bin/wait-for-it.sh new file mode 100755 index 0000000000..eca6c3b9c8 --- /dev/null +++ b/metron-docker/kafkazk/bin/wait-for-it.sh @@ -0,0 +1,161 @@ +#!/usr/bin/env bash +# Use this script to test if a given TCP host/port are available + +cmdname=$(basename $0) + +echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } + +usage() +{ + cat << USAGE >&2 +Usage: + $cmdname host:port [-s] [-t timeout] [-- command args] + -h HOST | --host=HOST Host or IP under test + -p PORT | --port=PORT TCP port under test + Alternatively, you specify the host and port as host:port + -s | --strict Only execute subcommand if the test succeeds + -q | --quiet Don't output any status messages + -t TIMEOUT | --timeout=TIMEOUT + Timeout in seconds, zero for no timeout + -- COMMAND ARGS Execute command with args after the test finishes +USAGE + exit 1 +} + +wait_for() +{ + if [[ $TIMEOUT -gt 0 ]]; then + echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" + else + echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" + fi + start_ts=$(date +%s) + while : + do + (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 + result=$? + if [[ $result -eq 0 ]]; then + end_ts=$(date +%s) + echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" + break + fi + sleep 1 + done + return $result +} + +wait_for_wrapper() +{ + # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 + if [[ $QUIET -eq 1 ]]; then + timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & + else + timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & + fi + PID=$! + trap "kill -INT -$PID" INT + wait $PID + RESULT=$? + if [[ $RESULT -ne 0 ]]; then + echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" + fi + return $RESULT +} + +# process arguments +while [[ $# -gt 0 ]] +do + case "$1" in + *:* ) + hostport=(${1//:/ }) + HOST=${hostport[0]} + PORT=${hostport[1]} + shift 1 + ;; + --child) + CHILD=1 + shift 1 + ;; + -q | --quiet) + QUIET=1 + shift 1 + ;; + -s | --strict) + STRICT=1 + shift 1 + ;; + -h) + HOST="$2" + if [[ $HOST == "" ]]; then break; fi + shift 2 + ;; + --host=*) + HOST="${1#*=}" + shift 1 + ;; + -p) + PORT="$2" + if [[ $PORT == "" ]]; then break; fi + shift 2 + ;; + --port=*) + PORT="${1#*=}" + shift 1 + ;; + -t) + TIMEOUT="$2" + if [[ $TIMEOUT == "" ]]; then break; fi + shift 2 + ;; + --timeout=*) + TIMEOUT="${1#*=}" + shift 1 + ;; + --) + shift + CLI="$@" + break + ;; + --help) + usage + ;; + *) + echoerr "Unknown argument: $1" + usage + ;; + esac +done + +if [[ "$HOST" == "" || "$PORT" == "" ]]; then + echoerr "Error: you need to provide a host and port to test." + usage +fi + +TIMEOUT=${TIMEOUT:-15} +STRICT=${STRICT:-0} +CHILD=${CHILD:-0} +QUIET=${QUIET:-0} + +if [[ $CHILD -gt 0 ]]; then + wait_for + RESULT=$? + exit $RESULT +else + if [[ $TIMEOUT -gt 0 ]]; then + wait_for_wrapper + RESULT=$? + else + wait_for + RESULT=$? + fi +fi + +if [[ $CLI != "" ]]; then + if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then + echoerr "$cmdname: strict mode, refusing to execute subprocess" + exit $RESULT + fi + exec $CLI +else + exit $RESULT +fi diff --git a/metron-docker/kafkazk/data/BroExampleOutput.txt b/metron-docker/kafkazk/data/BroExampleOutput.txt new file mode 100644 index 0000000000..d6ab902e87 --- /dev/null +++ b/metron-docker/kafkazk/data/BroExampleOutput.txt @@ -0,0 +1,10 @@ +{"http":{"ts":1402307733,"uid":"CTo78A11g7CYbbOHvj","id.orig_h":"192.249.113.37","id.orig_p":58808,"id.resp_h":"72.163.4.161","id.resp_p":80,"trans_depth":1,"method":"GET","host":"www.cisco.com","uri":"/","user_agent":"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3","request_body_len":0,"response_body_len":25523,"status_code":200,"status_msg":"OK","tags":[],"resp_fuids":["FJDyMC15lxUn5ngPfd"],"resp_mime_types":["text/html"]}} +{"dns":{"ts":1402308259,"uid":"CuJT272SKaJSuqO0Ia","id.orig_h":"10.122.196.204","id.orig_p":33976,"id.resp_h":"144.254.71.184","id.resp_p":53,"proto":"udp","trans_id":62418,"query":"www.cisco.com","qclass":1,"qclass_name":"C_INTERNET","qtype":28,"qtype_name":"AAAA","rcode":0,"rcode_name":"NOERROR","AA":true,"TC":false,"RD":true,"RA":true,"Z":0,"answers":["www.cisco.com.akadns.net","origin-www.cisco.com","2001:420:1201:2::a"],"TTLs":[3600.0,289.0,14.0],"rejected":false}} +{"http":{"ts":1402307733,"uid":"KIRAN","id.orig_h":"10.122.196.204","id.orig_p":58808,"id.resp_h":"72.163.4.161","id.resp_p":80,"trans_depth":1,"method":"GET","host":"www.cisco.com","uri":"/","user_agent":"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3","request_body_len":0,"response_body_len":25523,"status_code":200,"status_msg":"OK","tags":[],"resp_fuids":["FJDyMC15lxUn5ngPfd"],"resp_mime_types":["text/html"]}} +{"http":{"ts":1402307733,"uid":"KIRAN12312312","id.orig_h":"192.249.113.37","id.orig_p":58808,"id.resp_h":"72.163.4.161","id.resp_p":80,"trans_depth":1,"method":"GET","host":"www.cisco.com","uri":"/","user_agent":"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3","request_body_len":0,"response_body_len":25523,"status_code":200,"status_msg":"OK","tags":[],"resp_fuids":["FJDyMC15lxUn5ngPfd"],"resp_mime_types":["text/html"]}} +{"http":{"ts":1402307733,"uid":"KIRAN12312312","id.orig_h":"192.249.113.37","id.orig_p":58808,"id.resp_h":"72.163.4.161","id.resp_p":80,"trans_depth":1,"method":"GET","host":"www.cisco.com","uri":"/","user_agent":"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3","request_body_len":0,"response_body_len":25523,"status_code":200,"status_msg":"OK","tags":[],"resp_fuids":["FJDyMC15lxUn5ngPfd"],"resp_mime_types":["text/html"]}} +{"http":{"ts":1402307733,"uid":"CTo78A11g7CYbbOHvj","id.orig_h":"10.122.196.204","id.orig_p":58808,"id.resp_h":"72.163.4.161","id.resp_p":80,"trans_depth":1,"email":"abullis@mail.csuchico.edu","method":"GET","host":"gabacentre.pw","uri":"/","user_agent":"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3","request_body_len":0,"response_body_len":25523,"status_code":200,"status_msg":"OK","tags":[],"resp_fuids":["FJDyMC15lxUn5ngPfd"],"resp_mime_types":["text/html"]}} +{"dns":{"ts":1402308259,"uid":"CYbbOHvj","id.orig_h":"93.188.160.43","id.orig_p":33976,"id.resp_h":"144.254.71.184","id.resp_p":53,"proto":"udp","trans_id":62418,"query":"www.cisco.com","qclass":1,"qclass_name":"C_INTERNET","qtype":28,"qtype_name":"AAAA","rcode":0,"rcode_name":"NOERROR","AA":true,"TC":false,"RD":true,"RA":true,"Z":0,"answers":["gabacentre.pw","www.cisco.com.akadns.net","origin-www.cisco.com","2001:420:1201:2::a"],"TTLs":[3600.0,289.0,14.0],"rejected":false}} +{"http":{"ts":1402307733,"uid":"CTo78A11g7CYbbOHvj","id.orig_h":"192.249.113.37","id.orig_p":58808,"id.resp_h":"72.163.4.161","id.resp_p":80,"trans_depth":1,"method":"GET","host":"www.cisco.com","uri":"/","user_agent":"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3","request_body_len":0,"response_body_len":25523,"status_code":200,"status_msg":"OK","tags":[],"resp_fuids":["FJDyMC15lxUn5ngPfd"],"resp_mime_types":["text/html"]}} +{"dns":{"ts":1402308259,"uid":"CuJT272SKaJSuqO0Ia","id.orig_h":"10.122.196.204","id.orig_p":33976,"id.resp_h":"144.254.71.184","id.resp_p":53,"proto":"udp","trans_id":62418,"query":"www.cisco.com","qclass":1,"qclass_name":"C_INTERNET","qtype":28,"qtype_name":"AAAA","rcode":0,"rcode_name":"NOERROR","AA":true,"TC":false,"RD":true,"RA":true,"Z":0,"answers":["www.cisco.com.akadns.net","origin-www.cisco.com","2001:420:1201:2::a"],"TTLs":[3600.0,289.0,14.0],"rejected":false}} +{"http":{"ts":1402307733,"uid":"KIRAN","id.orig_h":"10.122.196.204","id.orig_p":58808,"id.resp_h":"72.163.4.161","id.resp_p":80,"trans_depth":1,"method":"GET","host":"www.cisco.com","uri":"/","user_agent":"curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3","request_body_len":0,"response_body_len":25523,"status_code":200,"status_msg":"OK","tags":[],"resp_fuids":["FJDyMC15lxUn5ngPfd"],"resp_mime_types":["text/html"]}} \ No newline at end of file diff --git a/metron-docker/kafkazk/data/SquidExampleOutput.txt b/metron-docker/kafkazk/data/SquidExampleOutput.txt new file mode 100644 index 0000000000..358a24da05 --- /dev/null +++ b/metron-docker/kafkazk/data/SquidExampleOutput.txt @@ -0,0 +1,5 @@ +1461576382.642 161 127.0.0.1 TCP_MISS/200 103701 GET http://www.cnn.com/ - DIRECT/199.27.79.73 text/html +1461576442.228 159 127.0.0.1 TCP_MISS/200 137183 GET http://www.nba.com/ - DIRECT/66.210.41.9 text/html +1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html +1467011158.083 671 127.0.0.1 TCP_MISS/200 41846 GET http://www.help.1and1.co.uk/domains-c40986/transfer-domains-c79878 - DIRECT/212.227.34.3 text/html +1467011159.978 1893 127.0.0.1 TCP_MISS/200 153925 GET http://www.pravda.ru/science/ - DIRECT/185.103.135.90 text/html \ No newline at end of file diff --git a/metron-docker/kibana/Dockerfile b/metron-docker/kibana/Dockerfile new file mode 100644 index 0000000000..1047a3471d --- /dev/null +++ b/metron-docker/kibana/Dockerfile @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM kibana:4.5.3 + +ADD /images/metron.svg /opt/kibana/optimize/bundles/src/ui/public/images/kibana.svg +ADD /styles/commons.style.css /opt/kibana/optimize/bundles/commons.style.css diff --git a/metron-docker/kibana/conf/kibana-index.json b/metron-docker/kibana/conf/kibana-index.json new file mode 100644 index 0000000000..ad522d26c9 --- /dev/null +++ b/metron-docker/kibana/conf/kibana-index.json @@ -0,0 +1,34 @@ +{"_index":".kibana","_type":"index-pattern","_id":"bro*","_score":1,"_source":{"title":"bro*","timeFieldName":"timestamp","fields":"[{\"name\":\"TTLs\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"qclass_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"bro_timestamp\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"enrichments:geo:ip_dst_addr:location_point\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"answers\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichmentjoinbolt:joiner:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:geoadapter:begin:ts\",\"type\":\"date\",\"count\":1,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"resp_mime_types\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"protocol\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"original_string\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"adapter:threatinteladapter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"host\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:geoadapter:end:ts\",\"type\":\"date\",\"count\":1,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"AA\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"method\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichmentsplitterbolt:splitter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"query\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:city\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"rcode\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:hostfromjsonlistadapter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"orig_mime_types\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"RA\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"RD\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"orig_fuids\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"proto\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:threatinteladapter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"enrichments:geo:ip_dst_addr:country\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"response_body_len\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:locID\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"qtype_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"status_code\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"ip_dst_port\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:dmaCode\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threatinteljoinbolt:joiner:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"rejected\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"qtype\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichmentsplitterbolt:splitter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"trans_id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:latitude\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"uid\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"source:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"trans_depth\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip_dst_addr\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:hostfromjsonlistadapter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"Z\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip_src_addr\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threatintelsplitterbolt:splitter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:longitude\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"user_agent\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"qclass\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"resp_fuids\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"request_body_len\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:postalCode\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"uri\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"rcode_name\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"TC\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"referrer\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip_src_port\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"status_msg\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threatintelsplitterbolt:splitter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":1,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":2,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false}]"}} +{"_index":".kibana","_type":"index-pattern","_id":"yaf*","_score":1,"_source":{"title":"yaf*","timeFieldName":"timestamp","fields":"[{\"name\":\"enrichments:geo:ip_dst_addr:location_point\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"isn\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichmentjoinbolt:joiner:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"dip\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:geoadapter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"dp\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"protocol\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"rpkt\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"original_string\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"adapter:threatinteladapter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:geoadapter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"tag\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"app\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"oct\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"end_reason\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"enrichmentsplitterbolt:splitter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:city\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:hostfromjsonlistadapter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"start_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"riflags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"proto\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:threatinteladapter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"enrichments:geo:ip_dst_addr:country\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:locID\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"iflags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"ip_dst_port\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:dmaCode\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threatinteljoinbolt:joiner:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"uflags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichmentsplitterbolt:splitter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:latitude\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"duration\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"source:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip_dst_addr\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"pkt\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:hostfromjsonlistadapter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ruflags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"roct\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"sip\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"sp\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip_src_addr\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"rtag\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threatintelsplitterbolt:splitter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:longitude\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"end-reason\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"risn\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"end_time\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:postalCode\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"rtt\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip_src_port\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threatintelsplitterbolt:splitter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false}]"}} +{"_index":".kibana","_type":"index-pattern","_id":"snort*","_score":1,"_source":{"title":"snort*","timeFieldName":"timestamp","fields":"[{\"name\":\"msg\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"enrichments:geo:ip_dst_addr:location_point\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"dgmlen\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_src_addr:longitude\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichmentjoinbolt:joiner:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_src_addr:dmaCode\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:geoadapter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"tcpack\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"protocol\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:threatinteladapter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_src_addr:locID\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"original_string\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"adapter:geoadapter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_src_addr:location_point\",\"type\":\"geo_point\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichmentsplitterbolt:splitter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:city\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:hostfromjsonlistadapter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_src_addr:postalCode\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ethlen\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threat:triage:level\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"tcpflags\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"adapter:threatinteladapter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_source\",\"type\":\"_source\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"enrichments:geo:ip_dst_addr:country\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:locID\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_index\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"ip_dst_port\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threatinteljoinbolt:joiner:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:dmaCode\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"sig_rev\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"ethsrc\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"tcpseq\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"enrichmentsplitterbolt:splitter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"tcpwindow\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":true,\"doc_values\":false},{\"name\":\"enrichments:geo:ip_dst_addr:latitude\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"source:type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip_dst_addr\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"adapter:hostfromjsonlistadapter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"tos\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip_src_addr\",\"type\":\"ip\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threatintelsplitterbolt:splitter:end:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_src_addr:latitude\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:longitude\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"timestamp\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ethdst\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_dst_addr:postalCode\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"is_alert\",\"type\":\"boolean\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_src_addr:country\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ttl\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"iplen\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"ip_src_port\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"threatintelsplitterbolt:splitter:begin:ts\",\"type\":\"date\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"sig_id\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"sig_generator\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"enrichments:geo:ip_src_addr:city\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":true,\"analyzed\":false,\"doc_values\":true},{\"name\":\"_id\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_type\",\"type\":\"string\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false},{\"name\":\"_score\",\"type\":\"number\",\"count\":0,\"scripted\":false,\"indexed\":false,\"analyzed\":false,\"doc_values\":false}]"}} +{"_index":".kibana","_type":"config","_id":"{{ kibana_version }}","_score":1,"_source":{"buildNum":9892,"defaultIndex":"bro*"}} +{"_index":".kibana","_type":"search","_id":"web-search","_score":1,"_source":{"title":"Web Requests","description":"","hits":0,"columns":["method","host","uri","referrer","ip_src_addr","ip_dst_addr"],"sort":["timestamp","desc"],"version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"bro*\",\"query\":{\"query_string\":{\"query\":\"protocol: http OR protocol: https\",\"analyze_wildcard\":true}},\"filter\":[],\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}},\"require_field_match\":false,\"fragment_size\":2147483647}}"}}} +{"_index":".kibana","_type":"search","_id":"yaf-search","_score":1,"_source":{"title":"YAF","description":"","hits":0,"columns":["ip_src_addr","ip_src_port","ip_dst_addr","ip_dst_port","protocol","duration","pkt"],"sort":["timestamp","desc"],"version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"yaf*\",\"filter\":[],\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}},\"require_field_match\":false,\"fragment_size\":2147483647},\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}}}"}}} +{"_index":".kibana","_type":"search","_id":"snort-search","_score":1,"_source":{"title":"Snort Alerts","description":"","hits":0,"columns":["msg","sig_id","ip_src_addr","ip_src_port","ip_dst_addr","ip_dst_port"],"sort":["timestamp","desc"],"version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"snort*\",\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}},\"filter\":[],\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}},\"require_field_match\":false,\"fragment_size\":2147483647}}"}}} +{"_index":".kibana","_type":"search","_id":"dns-search","_score":1,"_source":{"title":"DNS Requests","description":"","hits":0,"columns":["query","qtype_name","answers","ip_src_addr","ip_dst_addr"],"sort":["timestamp","desc"],"version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"bro*\",\"query\":{\"query_string\":{\"query\":\"protocol: dns\",\"analyze_wildcard\":true}},\"filter\":[],\"highlight\":{\"pre_tags\":[\"@kibana-highlighted-field@\"],\"post_tags\":[\"@/kibana-highlighted-field@\"],\"fields\":{\"*\":{}},\"require_field_match\":false,\"fragment_size\":2147483647}}"}}} +{"_index":".kibana","_type":"visualization","_id":"Welcome","_score":1,"_source":{"title":"Welcome to Apache Metron","visState":"{\"title\":\"Welcome to Apache Metron\",\"type\":\"markdown\",\"params\":{\"markdown\":\"This dashboard enables the validation of Apache Metron and the end-to-end functioning of its default sensor suite. The default sensor suite includes [Snort](https://www.snort.org/), [Bro](https://www.bro.org/), and [YAF](https://tools.netsa.cert.org/yaf/). One of Apache Metron's primary goals is to simplify the onboarding of additional sources of telemetry. In a production deployment these default sensors should be replaced with ones applicable to the target environment.\\n\\nApache Metron enables disparate sources of telemetry to all be viewed under a 'single pane of glass.' Telemetry from each of the default sensors can be searched, aggregated, summarized, and viewed within this dashboard. This dashboard should be used as a springboard upon which to create your own customized dashboards.\\n\\nThe panels below highlight the volume and variety of events that are currently being consumed by Apache Metron.\"},\"aggs\":[],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Top-Snort-Alerts-by-Source","_score":1,"_source":{"title":"Top Snort Alerts by Source","visState":"{\"title\":\"Top Snort Alerts by Source\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"ip_src_addr\",\"size\":10,\"order\":\"desc\",\"orderBy\":\"1\",\"customLabel\":\"Source IP\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"snort*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Web-Request-Type","_score":1,"_source":{"title":"Web Request Type","visState":"{\"title\":\"Web Request Type\",\"type\":\"pie\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"isDonut\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"method\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","savedSearchId":"web-search","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Web-Request-Header","_score":1,"_source":{"title":"Web Request Header","visState":"{\"title\":\"Web Request Header\",\"type\":\"markdown\",\"params\":{\"markdown\":\"The [Bro Network Security Monitor](https://www.bro.org/) is extracting application-level information from raw network packets. In this example, Bro is extracting HTTP(S) requests being made over the network. \"},\"aggs\":[],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Events","_score":1,"_source":{"title":"Events","visState":"{\"title\":\"Events\",\"type\":\"histogram\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"scale\":\"linear\",\"mode\":\"stacked\",\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"timestamp\",\"interval\":\"auto\",\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"source:type\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}","uiStateJSON":"{\"vis\":{\"legendOpen\":false}}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":[\"yaf*\", \"bro*\", \"snort*\"],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Flow-Duration","_score":1,"_source":{"title":"Flow Duration","visState":"{\"title\":\"Flow Duration\",\"type\":\"area\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"smoothLines\":false,\"scale\":\"linear\",\"interpolate\":\"linear\",\"mode\":\"stacked\",\"times\":[],\"addTimeMarker\":false,\"defaultYExtents\":false,\"setYExtents\":false,\"yAxis\":{}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"duration\",\"interval\":10,\"extended_bounds\":{},\"customLabel\":\"Flow Duration (seconds)\"}}],\"listeners\":{}}","uiStateJSON":"{\"vis\":{\"legendOpen\":false}}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"yaf*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Snort-Header","_score":1,"_source":{"title":"Snort","visState":"{\"title\":\"Snort\",\"type\":\"markdown\",\"params\":{\"markdown\":\"[Snort](https://www.snort.org/) is a Network Intrusion Detection System (NIDS) that is being used to generate alerts identifying known bad events. Snort relies on a fixed set of rules that act as signatures for identifying abnormal events.\"},\"aggs\":[],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Unique-Location(s)","_score":1,"_source":{"title":"Geo-IP Locations","visState":"{\"title\":\"Geo-IP Locations\",\"type\":\"metric\",\"params\":{\"handleNoResults\":true,\"fontSize\":60},\"aggs\":[{\"id\":\"1\",\"type\":\"cardinality\",\"schema\":\"metric\",\"params\":{\"field\":\"enrichments:geo:ip_src_addr:locID\",\"customLabel\":\"Unique Location(s)\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":[\"yaf*\", \"bro*\", \"snort*\"],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Event-Types","_score":1,"_source":{"title":"Event Sources","visState":"{\"title\":\"Event Sources\",\"type\":\"pie\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"isDonut\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"source:type\",\"size\":10,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":[\"yaf*\", \"bro*\", \"snort*\"],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Total-Events","_score":1,"_source":{"title":"Event Count","visState":"{\"title\":\"Event Count\",\"type\":\"metric\",\"params\":{\"handleNoResults\":true,\"fontSize\":60},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{\"customLabel\":\"Events\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":[\"yaf*\", \"bro*\", \"snort*\"],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Top-DNS-Query","_score":1,"_source":{"title":"Top DNS Query","visState":"{\"title\":\"Top DNS Query\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"query\",\"size\":10,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"bro*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"YAF-Flow(s)","_score":1,"_source":{"title":"YAF Flows","visState":"{\"title\":\"YAF Flows\",\"type\":\"metric\",\"params\":{\"handleNoResults\":true,\"fontSize\":60},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"yaf*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Top-Alerts-By-Host","_score":1,"_source":{"title":"Top Alerts By Host","visState":"{\"title\":\"New Visualization\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"ip_src_addr\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"customLabel\":\"Source\"}},{\"id\":\"3\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"ip_dst_addr\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"customLabel\":\"Destination\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","savedSearchId":"snort-search","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Location-Header","_score":1,"_source":{"title":"Enrichment","visState":"{\"title\":\"Enrichment\",\"type\":\"markdown\",\"params\":{\"markdown\":\"Apache Metron can perform real-time enrichment of telemetry data as it is consumed. To highlight this feature, all of the IP address fields collected from the default sensor suite were used to perform geo-ip lookups. This data was then used to pinpoint each location on the map.\"},\"aggs\":[],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Frequent-DNS-Queries","_score":1,"_source":{"title":"Frequent DNS Requests","visState":"{\"title\":\"Frequent DNS Requests\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"query\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"bro*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Snort-Alert-Types","_score":1,"_source":{"title":"Snort Alert Types","visState":"{\"title\":\"Snort Alert Types\",\"type\":\"metric\",\"params\":{\"handleNoResults\":true,\"fontSize\":60},\"aggs\":[{\"id\":\"1\",\"type\":\"cardinality\",\"schema\":\"metric\",\"params\":{\"field\":\"sig_id\",\"customLabel\":\"Alert Type(s)\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"snort*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"HTTP(S)-Requests","_score":1,"_source":{"title":"Web Requests","visState":"{\"title\":\"Web Requests\",\"type\":\"metric\",\"params\":{\"handleNoResults\":true,\"fontSize\":60},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","savedSearchId":"web-search","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"DNS-Request(s)","_score":1,"_source":{"title":"DNS Requests","visState":"{\"title\":\"DNS Requests\",\"type\":\"metric\",\"params\":{\"handleNoResults\":true,\"fontSize\":60},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","savedSearchId":"dns-search","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"YAF-Flows-Header","_score":1,"_source":{"title":"YAF","visState":"{\"title\":\"YAF\",\"type\":\"markdown\",\"params\":{\"markdown\":\"[YAF](https://tools.netsa.cert.org/yaf/yaf.html) can be used to generate Netflow-like flow records. These flow records provide significant visibility of the actors communicating over the target network.\"},\"aggs\":[],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"DNS-Requests-Header","_score":1,"_source":{"title":"DNS Requests","visState":"{\"aggs\":[],\"listeners\":{},\"params\":{\"markdown\":\"[Bro](https://www.bro.org/) is extracting DNS requests and responses being made over the network. Understanding who is making those requests, the frequency, and types can provide a deep understanding of the actors present on the network.\"},\"title\":\"DNS Requests\",\"type\":\"markdown\"}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Top-Destinations","_score":1,"_source":{"title":"Top Destinations","visState":"{\"title\":\"Top Destinations\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"ip_dst_addr\",\"size\":10,\"order\":\"desc\",\"orderBy\":\"1\",\"customLabel\":\"Destination IP\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":[\"yaf*\", \"bro*\", \"snort*\"],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Country","_score":1,"_source":{"title":"By Country","visState":"{\"title\":\"By Country\",\"type\":\"pie\",\"params\":{\"shareYAxis\":true,\"addTooltip\":true,\"addLegend\":true,\"isDonut\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"segment\",\"params\":{\"field\":\"enrichments:geo:ip_src_addr:country\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":[\"yaf*\", \"bro*\", \"snort*\"],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Frequent-DNS-Requests","_score":1,"_source":{"title":"Frequent DNS Requests","visState":"{\"title\":\"Frequent DNS Requests\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"query\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"customLabel\":\"DNS Query\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":\"bro*\",\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Unusual-Referrers","_score":1,"_source":{"title":"Unusual Referrers","visState":"{\"title\":\"Unusual Referrers\",\"type\":\"table\",\"params\":{\"perPage\":10,\"showPartialRows\":false,\"showMeticsAtAllLevels\":false},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"significant_terms\",\"schema\":\"bucket\",\"params\":{\"field\":\"referrer\",\"size\":5,\"customLabel\":\"Top 5 Unusual Referrers\"}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","savedSearchId":"web-search","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"filter\":[]}"}}} +{"_index":".kibana","_type":"visualization","_id":"Flow-Locations","_score":1,"_source":{"title":"Flow Locations","visState":"{\"title\":\"New Visualization\",\"type\":\"tile_map\",\"params\":{\"mapType\":\"Scaled Circle Markers\",\"isDesaturated\":true,\"addTooltip\":true,\"heatMaxZoom\":16,\"heatMinOpacity\":0.1,\"heatRadius\":25,\"heatBlur\":15,\"heatNormalizeData\":true,\"wms\":{\"enabled\":false,\"url\":\"https://basemap.nationalmap.gov/arcgis/services/USGSTopo/MapServer/WMSServer\",\"options\":{\"version\":\"1.3.0\",\"layers\":\"0\",\"format\":\"image/png\",\"transparent\":true,\"attribution\":\"Maps provided by USGS\",\"styles\":\"\"}}},\"aggs\":[{\"id\":\"1\",\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"type\":\"geohash_grid\",\"schema\":\"segment\",\"params\":{\"field\":\"enrichments:geo:ip_dst_addr:location_point\",\"autoPrecision\":true,\"precision\":2}}],\"listeners\":{}}","uiStateJSON":"{}","description":"","version":1,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"index\":[\"yaf*\", \"bro*\", \"snort*\"],\"query\":{\"query_string\":{\"query\":\"*\",\"analyze_wildcard\":true}},\"filter\":[]}"}}} +{"_index":".kibana","_type":"dashboard","_id":"Metron-Dashboard","_score":1,"_source":{"title":"Metron Dashboard","hits":0,"description":"","panelsJSON":"[{\"col\":1,\"id\":\"Welcome\",\"panelIndex\":30,\"row\":1,\"size_x\":11,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Total-Events\",\"panelIndex\":6,\"row\":3,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":4,\"id\":\"Events\",\"panelIndex\":16,\"row\":3,\"size_x\":8,\"size_y\":4,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Event-Types\",\"panelIndex\":15,\"row\":5,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Location-Header\",\"panelIndex\":24,\"row\":7,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Unique-Location(s)\",\"panelIndex\":23,\"row\":9,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":4,\"id\":\"Flow-Locations\",\"panelIndex\":32,\"row\":7,\"size_x\":8,\"size_y\":6,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Country\",\"panelIndex\":8,\"row\":11,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"YAF-Flows-Header\",\"panelIndex\":27,\"row\":13,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"YAF-Flow(s)\",\"panelIndex\":21,\"row\":15,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":4,\"columns\":[\"ip_src_addr\",\"ip_src_port\",\"ip_dst_addr\",\"ip_dst_port\",\"protocol\",\"duration\",\"pkt\"],\"id\":\"yaf-search\",\"panelIndex\":20,\"row\":13,\"size_x\":8,\"size_y\":6,\"sort\":[\"duration\",\"desc\"],\"type\":\"search\"},{\"col\":1,\"id\":\"Flow-Duration\",\"panelIndex\":31,\"row\":17,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Snort-Header\",\"panelIndex\":25,\"row\":19,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":4,\"columns\":[\"msg\",\"sig_id\",\"ip_src_addr\",\"ip_src_port\",\"ip_dst_addr\",\"ip_dst_port\"],\"id\":\"snort-search\",\"panelIndex\":3,\"row\":19,\"size_x\":8,\"size_y\":6,\"sort\":[\"timestamp\",\"desc\"],\"type\":\"search\"},{\"col\":1,\"id\":\"Snort-Alert-Types\",\"panelIndex\":10,\"row\":21,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Top-Alerts-By-Host\",\"panelIndex\":19,\"row\":23,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Web-Request-Header\",\"panelIndex\":26,\"row\":25,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":4,\"columns\":[\"method\",\"host\",\"uri\",\"referrer\",\"user_agent\",\"ip_src_addr\",\"ip_dst_addr\"],\"id\":\"web-search\",\"panelIndex\":4,\"row\":25,\"size_x\":8,\"size_y\":6,\"sort\":[\"timestamp\",\"desc\"],\"type\":\"search\"},{\"col\":1,\"id\":\"HTTP(S)-Requests\",\"panelIndex\":17,\"row\":27,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"DNS-Requests-Header\",\"panelIndex\":29,\"row\":31,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":4,\"columns\":[\"query\",\"qtype_name\",\"answers\",\"ip_src_addr\",\"ip_dst_addr\"],\"id\":\"dns-search\",\"panelIndex\":5,\"row\":31,\"size_x\":8,\"size_y\":6,\"sort\":[\"timestamp\",\"desc\"],\"type\":\"search\"},{\"col\":1,\"id\":\"DNS-Request(s)\",\"panelIndex\":14,\"row\":33,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"},{\"col\":1,\"id\":\"Web-Request-Type\",\"panelIndex\":33,\"row\":29,\"size_x\":3,\"size_y\":2,\"type\":\"visualization\"}]","optionsJSON":"{\"darkTheme\":false}","uiStateJSON":"{\"P-23\":{\"spy\":{\"mode\":{\"name\":null,\"fill\":false}}},\"P-34\":{\"vis\":{\"legendOpen\":false}}}","version":1,"timeRestore":false,"kibanaSavedObjectMeta":{"searchSourceJSON":"{\"filter\":[{\"query\":{\"query_string\":{\"analyze_wildcard\":true,\"query\":\"*\"}}}]}"}}} \ No newline at end of file diff --git a/metron-docker/kibana/images/metron.svg b/metron-docker/kibana/images/metron.svg new file mode 100644 index 0000000000..6be05f1570 --- /dev/null +++ b/metron-docker/kibana/images/metron.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/metron-docker/kibana/styles/commons.style.css b/metron-docker/kibana/styles/commons.style.css new file mode 100644 index 0000000000..ac7a8df335 --- /dev/null +++ b/metron-docker/kibana/styles/commons.style.css @@ -0,0 +1,11944 @@ +.app-links { + text-align: justify; +} +.app-links .app-link { + display: inline-block; + vertical-align: top; + text-align: left; + width: 68px; + margin: 0px 10px; + padding: 10px; + border-radius: 4px; +} +.app-links .app-link .app-icon { + display: block; + height: 48px; + width: 48px; + background-position: center; + background-size: contain; + border-radius: 4px; + background-color: #b4bcc2; + width: 100%; +} +.app-links .app-link .app-icon-missing { + text-align: center; + font-size: 2.7em; + font-weight: bold; + font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #fff; +} +.app-links .app-link .app-title { + color: #444444; + font-size: 0.9em; + width: 100%; + text-align: center; + margin-top: 3px; +} +.app-links .app-link:hover .app-title { + text-decoration: underline; +} +.app-links .app-link.active { + background: #ecf0f1; +} +.app-links .app-link.active .app-title { + text-decoration: underline; +} +/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */ +html { + font-family: sans-serif; + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; +} +body { + margin: 0; +} +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +menu, +nav, +section, +summary { + display: block; +} +audio, +canvas, +progress, +video { + display: inline-block; + vertical-align: baseline; +} +audio:not([controls]) { + display: none; + height: 0; +} +[hidden], +template { + display: none; +} +a { + background-color: transparent; +} +a:active, +a:hover { + outline: 0; +} +abbr[title] { + border-bottom: 1px dotted; +} +b, +strong { + font-weight: bold; +} +dfn { + font-style: italic; +} +h1 { + font-size: 2em; + margin: 0.67em 0; +} +mark { + background: #ff0; + color: #000; +} +small { + font-size: 80%; +} +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} +sup { + top: -0.5em; +} +sub { + bottom: -0.25em; +} +img { + border: 0; +} +svg:not(:root) { + overflow: hidden; +} +figure { + margin: 1em 40px; +} +hr { + box-sizing: content-box; + height: 0; +} +pre { + overflow: auto; +} +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} +button, +input, +optgroup, +select, +textarea { + color: inherit; + font: inherit; + margin: 0; +} +button { + overflow: visible; +} +button, +select { + text-transform: none; +} +button, +html input[type="button"], +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; + cursor: pointer; +} +button[disabled], +html input[disabled] { + cursor: default; +} +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} +input { + line-height: normal; +} +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; + padding: 0; +} +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} +input[type="search"] { + -webkit-appearance: textfield; + box-sizing: content-box; +} +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} +legend { + border: 0; + padding: 0; +} +textarea { + overflow: auto; +} +optgroup { + font-weight: bold; +} +table { + border-collapse: collapse; + border-spacing: 0; +} +td, +th { + padding: 0; +} +/*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */ +@media print { + *, + *:before, + *:after { + background: transparent !important; + color: #000 !important; + box-shadow: none !important; + text-shadow: none !important; + } + a, + a:visited { + text-decoration: underline; + } + a[href]:after { + content: " (" attr(href) ")"; + } + abbr[title]:after { + content: " (" attr(title) ")"; + } + a[href^="#"]:after, + a[href^="javascript:"]:after { + content: ""; + } + pre, + blockquote { + border: 1px solid #999; + page-break-inside: avoid; + } + thead { + display: table-header-group; + } + tr, + img { + page-break-inside: avoid; + } + img { + max-width: 100% !important; + } + p, + h2, + h3 { + orphans: 3; + widows: 3; + } + h2, + h3 { + page-break-after: avoid; + } + .navbar { + display: none; + } + .btn > .caret, + .dropup > .btn > .caret { + border-top-color: #000 !important; + } + .label { + border: 1px solid #000; + } + .table { + border-collapse: collapse !important; + } + .table td, + .table th { + background-color: #fff !important; + } + .table-bordered th, + .table-bordered td { + border: 1px solid #ddd !important; + } +} +@font-face { + font-family: 'Glyphicons Halflings'; + src: url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.eot); + src: url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.eot?#iefix) format('embedded-opentype'), url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.woff2) format('woff2'), url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.woff) format('woff'), url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.ttf) format('truetype'), url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular) format('svg'); +} +.glyphicon { + position: relative; + top: 1px; + display: inline-block; + font-family: 'Glyphicons Halflings'; + font-style: normal; + font-weight: normal; + line-height: 1; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} +.glyphicon-asterisk:before { + content: "*"; +} +.glyphicon-plus:before { + content: "+"; +} +.glyphicon-euro:before, +.glyphicon-eur:before { + content: "\20AC"; +} +.glyphicon-minus:before { + content: "\2212"; +} +.glyphicon-cloud:before { + content: "\2601"; +} +.glyphicon-envelope:before { + content: "\2709"; +} +.glyphicon-pencil:before { + content: "\270F"; +} +.glyphicon-glass:before { + content: "\E001"; +} +.glyphicon-music:before { + content: "\E002"; +} +.glyphicon-search:before { + content: "\E003"; +} +.glyphicon-heart:before { + content: "\E005"; +} +.glyphicon-star:before { + content: "\E006"; +} +.glyphicon-star-empty:before { + content: "\E007"; +} +.glyphicon-user:before { + content: "\E008"; +} +.glyphicon-film:before { + content: "\E009"; +} +.glyphicon-th-large:before { + content: "\E010"; +} +.glyphicon-th:before { + content: "\E011"; +} +.glyphicon-th-list:before { + content: "\E012"; +} +.glyphicon-ok:before { + content: "\E013"; +} +.glyphicon-remove:before { + content: "\E014"; +} +.glyphicon-zoom-in:before { + content: "\E015"; +} +.glyphicon-zoom-out:before { + content: "\E016"; +} +.glyphicon-off:before { + content: "\E017"; +} +.glyphicon-signal:before { + content: "\E018"; +} +.glyphicon-cog:before { + content: "\E019"; +} +.glyphicon-trash:before { + content: "\E020"; +} +.glyphicon-home:before { + content: "\E021"; +} +.glyphicon-file:before { + content: "\E022"; +} +.glyphicon-time:before { + content: "\E023"; +} +.glyphicon-road:before { + content: "\E024"; +} +.glyphicon-download-alt:before { + content: "\E025"; +} +.glyphicon-download:before { + content: "\E026"; +} +.glyphicon-upload:before { + content: "\E027"; +} +.glyphicon-inbox:before { + content: "\E028"; +} +.glyphicon-play-circle:before { + content: "\E029"; +} +.glyphicon-repeat:before { + content: "\E030"; +} +.glyphicon-refresh:before { + content: "\E031"; +} +.glyphicon-list-alt:before { + content: "\E032"; +} +.glyphicon-lock:before { + content: "\E033"; +} +.glyphicon-flag:before { + content: "\E034"; +} +.glyphicon-headphones:before { + content: "\E035"; +} +.glyphicon-volume-off:before { + content: "\E036"; +} +.glyphicon-volume-down:before { + content: "\E037"; +} +.glyphicon-volume-up:before { + content: "\E038"; +} +.glyphicon-qrcode:before { + content: "\E039"; +} +.glyphicon-barcode:before { + content: "\E040"; +} +.glyphicon-tag:before { + content: "\E041"; +} +.glyphicon-tags:before { + content: "\E042"; +} +.glyphicon-book:before { + content: "\E043"; +} +.glyphicon-bookmark:before { + content: "\E044"; +} +.glyphicon-print:before { + content: "\E045"; +} +.glyphicon-camera:before { + content: "\E046"; +} +.glyphicon-font:before { + content: "\E047"; +} +.glyphicon-bold:before { + content: "\E048"; +} +.glyphicon-italic:before { + content: "\E049"; +} +.glyphicon-text-height:before { + content: "\E050"; +} +.glyphicon-text-width:before { + content: "\E051"; +} +.glyphicon-align-left:before { + content: "\E052"; +} +.glyphicon-align-center:before { + content: "\E053"; +} +.glyphicon-align-right:before { + content: "\E054"; +} +.glyphicon-align-justify:before { + content: "\E055"; +} +.glyphicon-list:before { + content: "\E056"; +} +.glyphicon-indent-left:before { + content: "\E057"; +} +.glyphicon-indent-right:before { + content: "\E058"; +} +.glyphicon-facetime-video:before { + content: "\E059"; +} +.glyphicon-picture:before { + content: "\E060"; +} +.glyphicon-map-marker:before { + content: "\E062"; +} +.glyphicon-adjust:before { + content: "\E063"; +} +.glyphicon-tint:before { + content: "\E064"; +} +.glyphicon-edit:before { + content: "\E065"; +} +.glyphicon-share:before { + content: "\E066"; +} +.glyphicon-check:before { + content: "\E067"; +} +.glyphicon-move:before { + content: "\E068"; +} +.glyphicon-step-backward:before { + content: "\E069"; +} +.glyphicon-fast-backward:before { + content: "\E070"; +} +.glyphicon-backward:before { + content: "\E071"; +} +.glyphicon-play:before { + content: "\E072"; +} +.glyphicon-pause:before { + content: "\E073"; +} +.glyphicon-stop:before { + content: "\E074"; +} +.glyphicon-forward:before { + content: "\E075"; +} +.glyphicon-fast-forward:before { + content: "\E076"; +} +.glyphicon-step-forward:before { + content: "\E077"; +} +.glyphicon-eject:before { + content: "\E078"; +} +.glyphicon-chevron-left:before { + content: "\E079"; +} +.glyphicon-chevron-right:before { + content: "\E080"; +} +.glyphicon-plus-sign:before { + content: "\E081"; +} +.glyphicon-minus-sign:before { + content: "\E082"; +} +.glyphicon-remove-sign:before { + content: "\E083"; +} +.glyphicon-ok-sign:before { + content: "\E084"; +} +.glyphicon-question-sign:before { + content: "\E085"; +} +.glyphicon-info-sign:before { + content: "\E086"; +} +.glyphicon-screenshot:before { + content: "\E087"; +} +.glyphicon-remove-circle:before { + content: "\E088"; +} +.glyphicon-ok-circle:before { + content: "\E089"; +} +.glyphicon-ban-circle:before { + content: "\E090"; +} +.glyphicon-arrow-left:before { + content: "\E091"; +} +.glyphicon-arrow-right:before { + content: "\E092"; +} +.glyphicon-arrow-up:before { + content: "\E093"; +} +.glyphicon-arrow-down:before { + content: "\E094"; +} +.glyphicon-share-alt:before { + content: "\E095"; +} +.glyphicon-resize-full:before { + content: "\E096"; +} +.glyphicon-resize-small:before { + content: "\E097"; +} +.glyphicon-exclamation-sign:before { + content: "\E101"; +} +.glyphicon-gift:before { + content: "\E102"; +} +.glyphicon-leaf:before { + content: "\E103"; +} +.glyphicon-fire:before { + content: "\E104"; +} +.glyphicon-eye-open:before { + content: "\E105"; +} +.glyphicon-eye-close:before { + content: "\E106"; +} +.glyphicon-warning-sign:before { + content: "\E107"; +} +.glyphicon-plane:before { + content: "\E108"; +} +.glyphicon-calendar:before { + content: "\E109"; +} +.glyphicon-random:before { + content: "\E110"; +} +.glyphicon-comment:before { + content: "\E111"; +} +.glyphicon-magnet:before { + content: "\E112"; +} +.glyphicon-chevron-up:before { + content: "\E113"; +} +.glyphicon-chevron-down:before { + content: "\E114"; +} +.glyphicon-retweet:before { + content: "\E115"; +} +.glyphicon-shopping-cart:before { + content: "\E116"; +} +.glyphicon-folder-close:before { + content: "\E117"; +} +.glyphicon-folder-open:before { + content: "\E118"; +} +.glyphicon-resize-vertical:before { + content: "\E119"; +} +.glyphicon-resize-horizontal:before { + content: "\E120"; +} +.glyphicon-hdd:before { + content: "\E121"; +} +.glyphicon-bullhorn:before { + content: "\E122"; +} +.glyphicon-bell:before { + content: "\E123"; +} +.glyphicon-certificate:before { + content: "\E124"; +} +.glyphicon-thumbs-up:before { + content: "\E125"; +} +.glyphicon-thumbs-down:before { + content: "\E126"; +} +.glyphicon-hand-right:before { + content: "\E127"; +} +.glyphicon-hand-left:before { + content: "\E128"; +} +.glyphicon-hand-up:before { + content: "\E129"; +} +.glyphicon-hand-down:before { + content: "\E130"; +} +.glyphicon-circle-arrow-right:before { + content: "\E131"; +} +.glyphicon-circle-arrow-left:before { + content: "\E132"; +} +.glyphicon-circle-arrow-up:before { + content: "\E133"; +} +.glyphicon-circle-arrow-down:before { + content: "\E134"; +} +.glyphicon-globe:before { + content: "\E135"; +} +.glyphicon-wrench:before { + content: "\E136"; +} +.glyphicon-tasks:before { + content: "\E137"; +} +.glyphicon-filter:before { + content: "\E138"; +} +.glyphicon-briefcase:before { + content: "\E139"; +} +.glyphicon-fullscreen:before { + content: "\E140"; +} +.glyphicon-dashboard:before { + content: "\E141"; +} +.glyphicon-paperclip:before { + content: "\E142"; +} +.glyphicon-heart-empty:before { + content: "\E143"; +} +.glyphicon-link:before { + content: "\E144"; +} +.glyphicon-phone:before { + content: "\E145"; +} +.glyphicon-pushpin:before { + content: "\E146"; +} +.glyphicon-usd:before { + content: "\E148"; +} +.glyphicon-gbp:before { + content: "\E149"; +} +.glyphicon-sort:before { + content: "\E150"; +} +.glyphicon-sort-by-alphabet:before { + content: "\E151"; +} +.glyphicon-sort-by-alphabet-alt:before { + content: "\E152"; +} +.glyphicon-sort-by-order:before { + content: "\E153"; +} +.glyphicon-sort-by-order-alt:before { + content: "\E154"; +} +.glyphicon-sort-by-attributes:before { + content: "\E155"; +} +.glyphicon-sort-by-attributes-alt:before { + content: "\E156"; +} +.glyphicon-unchecked:before { + content: "\E157"; +} +.glyphicon-expand:before { + content: "\E158"; +} +.glyphicon-collapse-down:before { + content: "\E159"; +} +.glyphicon-collapse-up:before { + content: "\E160"; +} +.glyphicon-log-in:before { + content: "\E161"; +} +.glyphicon-flash:before { + content: "\E162"; +} +.glyphicon-log-out:before { + content: "\E163"; +} +.glyphicon-new-window:before { + content: "\E164"; +} +.glyphicon-record:before { + content: "\E165"; +} +.glyphicon-save:before { + content: "\E166"; +} +.glyphicon-open:before { + content: "\E167"; +} +.glyphicon-saved:before { + content: "\E168"; +} +.glyphicon-import:before { + content: "\E169"; +} +.glyphicon-export:before { + content: "\E170"; +} +.glyphicon-send:before { + content: "\E171"; +} +.glyphicon-floppy-disk:before { + content: "\E172"; +} +.glyphicon-floppy-saved:before { + content: "\E173"; +} +.glyphicon-floppy-remove:before { + content: "\E174"; +} +.glyphicon-floppy-save:before { + content: "\E175"; +} +.glyphicon-floppy-open:before { + content: "\E176"; +} +.glyphicon-credit-card:before { + content: "\E177"; +} +.glyphicon-transfer:before { + content: "\E178"; +} +.glyphicon-cutlery:before { + content: "\E179"; +} +.glyphicon-header:before { + content: "\E180"; +} +.glyphicon-compressed:before { + content: "\E181"; +} +.glyphicon-earphone:before { + content: "\E182"; +} +.glyphicon-phone-alt:before { + content: "\E183"; +} +.glyphicon-tower:before { + content: "\E184"; +} +.glyphicon-stats:before { + content: "\E185"; +} +.glyphicon-sd-video:before { + content: "\E186"; +} +.glyphicon-hd-video:before { + content: "\E187"; +} +.glyphicon-subtitles:before { + content: "\E188"; +} +.glyphicon-sound-stereo:before { + content: "\E189"; +} +.glyphicon-sound-dolby:before { + content: "\E190"; +} +.glyphicon-sound-5-1:before { + content: "\E191"; +} +.glyphicon-sound-6-1:before { + content: "\E192"; +} +.glyphicon-sound-7-1:before { + content: "\E193"; +} +.glyphicon-copyright-mark:before { + content: "\E194"; +} +.glyphicon-registration-mark:before { + content: "\E195"; +} +.glyphicon-cloud-download:before { + content: "\E197"; +} +.glyphicon-cloud-upload:before { + content: "\E198"; +} +.glyphicon-tree-conifer:before { + content: "\E199"; +} +.glyphicon-tree-deciduous:before { + content: "\E200"; +} +.glyphicon-cd:before { + content: "\E201"; +} +.glyphicon-save-file:before { + content: "\E202"; +} +.glyphicon-open-file:before { + content: "\E203"; +} +.glyphicon-level-up:before { + content: "\E204"; +} +.glyphicon-copy:before { + content: "\E205"; +} +.glyphicon-paste:before { + content: "\E206"; +} +.glyphicon-alert:before { + content: "\E209"; +} +.glyphicon-equalizer:before { + content: "\E210"; +} +.glyphicon-king:before { + content: "\E211"; +} +.glyphicon-queen:before { + content: "\E212"; +} +.glyphicon-pawn:before { + content: "\E213"; +} +.glyphicon-bishop:before { + content: "\E214"; +} +.glyphicon-knight:before { + content: "\E215"; +} +.glyphicon-baby-formula:before { + content: "\E216"; +} +.glyphicon-tent:before { + content: "\26FA"; +} +.glyphicon-blackboard:before { + content: "\E218"; +} +.glyphicon-bed:before { + content: "\E219"; +} +.glyphicon-apple:before { + content: "\F8FF"; +} +.glyphicon-erase:before { + content: "\E221"; +} +.glyphicon-hourglass:before { + content: "\231B"; +} +.glyphicon-lamp:before { + content: "\E223"; +} +.glyphicon-duplicate:before { + content: "\E224"; +} +.glyphicon-piggy-bank:before { + content: "\E225"; +} +.glyphicon-scissors:before { + content: "\E226"; +} +.glyphicon-bitcoin:before { + content: "\E227"; +} +.glyphicon-btc:before { + content: "\E227"; +} +.glyphicon-xbt:before { + content: "\E227"; +} +.glyphicon-yen:before { + content: "\A5"; +} +.glyphicon-jpy:before { + content: "\A5"; +} +.glyphicon-ruble:before { + content: "\20BD"; +} +.glyphicon-rub:before { + content: "\20BD"; +} +.glyphicon-scale:before { + content: "\E230"; +} +.glyphicon-ice-lolly:before { + content: "\E231"; +} +.glyphicon-ice-lolly-tasted:before { + content: "\E232"; +} +.glyphicon-education:before { + content: "\E233"; +} +.glyphicon-option-horizontal:before { + content: "\E234"; +} +.glyphicon-option-vertical:before { + content: "\E235"; +} +.glyphicon-menu-hamburger:before { + content: "\E236"; +} +.glyphicon-modal-window:before { + content: "\E237"; +} +.glyphicon-oil:before { + content: "\E238"; +} +.glyphicon-grain:before { + content: "\E239"; +} +.glyphicon-sunglasses:before { + content: "\E240"; +} +.glyphicon-text-size:before { + content: "\E241"; +} +.glyphicon-text-color:before { + content: "\E242"; +} +.glyphicon-text-background:before { + content: "\E243"; +} +.glyphicon-object-align-top:before { + content: "\E244"; +} +.glyphicon-object-align-bottom:before { + content: "\E245"; +} +.glyphicon-object-align-horizontal:before { + content: "\E246"; +} +.glyphicon-object-align-left:before { + content: "\E247"; +} +.glyphicon-object-align-vertical:before { + content: "\E248"; +} +.glyphicon-object-align-right:before { + content: "\E249"; +} +.glyphicon-triangle-right:before { + content: "\E250"; +} +.glyphicon-triangle-left:before { + content: "\E251"; +} +.glyphicon-triangle-bottom:before { + content: "\E252"; +} +.glyphicon-triangle-top:before { + content: "\E253"; +} +.glyphicon-console:before { + content: "\E254"; +} +.glyphicon-superscript:before { + content: "\E255"; +} +.glyphicon-subscript:before { + content: "\E256"; +} +.glyphicon-menu-left:before { + content: "\E257"; +} +.glyphicon-menu-right:before { + content: "\E258"; +} +.glyphicon-menu-down:before { + content: "\E259"; +} +.glyphicon-menu-up:before { + content: "\E260"; +} +* { + box-sizing: border-box; +} +*:before, +*:after { + box-sizing: border-box; +} +html { + font-size: 10px; + -webkit-tap-highlight-color: rgba(0, 0, 0, 0); +} +body { + font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 13px; + line-height: 1.42857143; + color: #444444; + background-color: #ffffff; +} +input, +button, +select, +textarea { + font-family: inherit; + font-size: inherit; + line-height: inherit; +} +a { + color: #1f6b7a; + text-decoration: none; +} +a:hover, +a:focus { + color: #298fa3; + text-decoration: none; +} +a:focus { + outline: thin dotted; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} +figure { + margin: 0; +} +img { + vertical-align: middle; +} +.img-responsive, +.thumbnail > img, +.thumbnail a > img, +.carousel-inner > .item > img, +.carousel-inner > .item > a > img { + display: block; + max-width: 100%; + height: auto; +} +.img-rounded { + border-radius: 6px; +} +.img-thumbnail { + padding: 4px; + line-height: 1.42857143; + background-color: #ffffff; + border: 1px solid #ecf0f1; + border-radius: 4px; + -webkit-transition: all 0.2s ease-in-out; + transition: all 0.2s ease-in-out; + display: inline-block; + max-width: 100%; + height: auto; +} +.img-circle { + border-radius: 50%; +} +hr { + margin-top: 18px; + margin-bottom: 18px; + border: 0; + border-top: 1px solid #ecf0f1; +} +.sr-only { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip: rect(0, 0, 0, 0); + border: 0; +} +.sr-only-focusable:active, +.sr-only-focusable:focus { + position: static; + width: auto; + height: auto; + margin: 0; + overflow: visible; + clip: auto; +} +[role="button"] { + cursor: pointer; +} +h1, +h2, +h3, +h4, +h5, +h6, +.h1, +.h2, +.h3, +.h4, +.h5, +.h6 { + font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-weight: 400; + line-height: 1.1; + color: inherit; +} +h1 small, +h2 small, +h3 small, +h4 small, +h5 small, +h6 small, +.h1 small, +.h2 small, +.h3 small, +.h4 small, +.h5 small, +.h6 small, +h1 .small, +h2 .small, +h3 .small, +h4 .small, +h5 .small, +h6 .small, +.h1 .small, +.h2 .small, +.h3 .small, +.h4 .small, +.h5 .small, +.h6 .small { + font-weight: normal; + line-height: 1; + color: #b4bcc2; +} +h1, +.h1, +h2, +.h2, +h3, +.h3 { + margin-top: 18px; + margin-bottom: 9px; +} +h1 small, +.h1 small, +h2 small, +.h2 small, +h3 small, +.h3 small, +h1 .small, +.h1 .small, +h2 .small, +.h2 .small, +h3 .small, +.h3 .small { + font-size: 65%; +} +h4, +.h4, +h5, +.h5, +h6, +.h6 { + margin-top: 9px; + margin-bottom: 9px; +} +h4 small, +.h4 small, +h5 small, +.h5 small, +h6 small, +.h6 small, +h4 .small, +.h4 .small, +h5 .small, +.h5 .small, +h6 .small, +.h6 .small { + font-size: 75%; +} +h1, +.h1 { + font-size: 33px; +} +h2, +.h2 { + font-size: 27px; +} +h3, +.h3 { + font-size: 23px; +} +h4, +.h4 { + font-size: 17px; +} +h5, +.h5 { + font-size: 13px; +} +h6, +.h6 { + font-size: 12px; +} +p { + margin: 0 0 9px; +} +.lead { + margin-bottom: 18px; + font-size: 14px; + font-weight: 300; + line-height: 1.4; +} +@media (min-width: 768px) { + .lead { + font-size: 19.5px; + } +} +small, +.small { + font-size: 92%; +} +mark, +.mark { + background-color: #f39c12; + padding: .2em; +} +.text-left { + text-align: left; +} +.text-right { + text-align: right; +} +.text-center { + text-align: center; +} +.text-justify { + text-align: justify; +} +.text-nowrap { + white-space: nowrap; +} +.text-lowercase { + text-transform: lowercase; +} +.text-uppercase { + text-transform: uppercase; +} +.text-capitalize { + text-transform: capitalize; +} +.text-muted { + color: #b4bcc2; +} +.text-primary { + color: #444444; +} +a.text-primary:hover, +a.text-primary:focus { + color: #2b2b2b; +} +.text-success { + color: #ffffff; +} +a.text-success:hover, +a.text-success:focus { + color: #e6e6e6; +} +.text-info { + color: #ffffff; +} +a.text-info:hover, +a.text-info:focus { + color: #e6e6e6; +} +.text-warning { + color: #ffffff; +} +a.text-warning:hover, +a.text-warning:focus { + color: #e6e6e6; +} +.text-danger { + color: #ffffff; +} +a.text-danger:hover, +a.text-danger:focus { + color: #e6e6e6; +} +.bg-primary { + color: #fff; + background-color: #444444; +} +a.bg-primary:hover, +a.bg-primary:focus { + background-color: #2b2b2b; +} +.bg-success { + background-color: #31c471; +} +a.bg-success:hover, +a.bg-success:focus { + background-color: #279b59; +} +.bg-info { + background-color: #1f6b7a; +} +a.bg-info:hover, +a.bg-info:focus { + background-color: #154751; +} +.bg-warning { + background-color: #f39c12; +} +a.bg-warning:hover, +a.bg-warning:focus { + background-color: #c87f0a; +} +.bg-danger { + background-color: #e74c3c; +} +a.bg-danger:hover, +a.bg-danger:focus { + background-color: #d62c1a; +} +.page-header { + padding-bottom: 8px; + margin: 36px 0 18px; + border-bottom: 1px solid transparent; +} +ul, +ol { + margin-top: 0; + margin-bottom: 9px; +} +ul ul, +ol ul, +ul ol, +ol ol { + margin-bottom: 0; +} +.list-unstyled { + padding-left: 0; + list-style: none; +} +.list-inline { + padding-left: 0; + list-style: none; + margin-left: -5px; +} +.list-inline > li { + display: inline-block; + padding-left: 5px; + padding-right: 5px; +} +dl { + margin-top: 0; + margin-bottom: 18px; +} +dt, +dd { + line-height: 1.42857143; +} +dt { + font-weight: bold; +} +dd { + margin-left: 0; +} +@media (min-width: 768px) { + .dl-horizontal dt { + float: left; + width: 160px; + clear: left; + text-align: right; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .dl-horizontal dd { + margin-left: 180px; + } +} +abbr[title], +abbr[data-original-title] { + cursor: help; + border-bottom: 1px dotted #b4bcc2; +} +.initialism { + font-size: 90%; + text-transform: uppercase; +} +blockquote { + padding: 9px 18px; + margin: 0 0 18px; + font-size: 16.25px; + border-left: 5px solid #ecf0f1; +} +blockquote p:last-child, +blockquote ul:last-child, +blockquote ol:last-child { + margin-bottom: 0; +} +blockquote footer, +blockquote small, +blockquote .small { + display: block; + font-size: 80%; + line-height: 1.42857143; + color: #b4bcc2; +} +blockquote footer:before, +blockquote small:before, +blockquote .small:before { + content: '\2014 \A0'; +} +.blockquote-reverse, +blockquote.pull-right { + padding-right: 15px; + padding-left: 0; + border-right: 5px solid #ecf0f1; + border-left: 0; + text-align: right; +} +.blockquote-reverse footer:before, +blockquote.pull-right footer:before, +.blockquote-reverse small:before, +blockquote.pull-right small:before, +.blockquote-reverse .small:before, +blockquote.pull-right .small:before { + content: ''; +} +.blockquote-reverse footer:after, +blockquote.pull-right footer:after, +.blockquote-reverse small:after, +blockquote.pull-right small:after, +.blockquote-reverse .small:after, +blockquote.pull-right .small:after { + content: '\A0 \2014'; +} +address { + margin-bottom: 18px; + font-style: normal; + line-height: 1.42857143; +} +code, +kbd, +pre, +samp { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; +} +code { + padding: 2px 4px; + font-size: 90%; + color: #c7254e; + background-color: #f9f2f4; + border-radius: 4px; +} +kbd { + padding: 2px 4px; + font-size: 90%; + color: #ffffff; + background-color: #333333; + border-radius: 3px; + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25); +} +kbd kbd { + padding: 0; + font-size: 100%; + font-weight: bold; + box-shadow: none; +} +pre { + display: block; + padding: 8.5px; + margin: 0 0 9px; + font-size: 12px; + line-height: 1.42857143; + word-break: break-all; + word-wrap: break-word; + color: #7b8a8b; + background-color: #ecf0f1; + border: 1px solid #cccccc; + border-radius: 4px; +} +pre code { + padding: 0; + font-size: inherit; + color: inherit; + white-space: pre-wrap; + background-color: transparent; + border-radius: 0; +} +.pre-scrollable { + max-height: 340px; + overflow-y: scroll; +} +.container { + margin-right: auto; + margin-left: auto; + padding-left: 15px; + padding-right: 15px; +} +@media (min-width: 768px) { + .container { + width: 750px; + } +} +@media (min-width: 992px) { + .container { + width: 970px; + } +} +@media (min-width: 1200px) { + .container { + width: 1170px; + } +} +.container-fluid { + margin-right: auto; + margin-left: auto; + padding-left: 15px; + padding-right: 15px; +} +.row { + margin-left: -15px; + margin-right: -15px; +} +.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 { + position: relative; + min-height: 1px; + padding-left: 15px; + padding-right: 15px; +} +.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 { + float: left; +} +.col-xs-12 { + width: 100%; +} +.col-xs-11 { + width: 91.66666667%; +} +.col-xs-10 { + width: 83.33333333%; +} +.col-xs-9 { + width: 75%; +} +.col-xs-8 { + width: 66.66666667%; +} +.col-xs-7 { + width: 58.33333333%; +} +.col-xs-6 { + width: 50%; +} +.col-xs-5 { + width: 41.66666667%; +} +.col-xs-4 { + width: 33.33333333%; +} +.col-xs-3 { + width: 25%; +} +.col-xs-2 { + width: 16.66666667%; +} +.col-xs-1 { + width: 8.33333333%; +} +.col-xs-pull-12 { + right: 100%; +} +.col-xs-pull-11 { + right: 91.66666667%; +} +.col-xs-pull-10 { + right: 83.33333333%; +} +.col-xs-pull-9 { + right: 75%; +} +.col-xs-pull-8 { + right: 66.66666667%; +} +.col-xs-pull-7 { + right: 58.33333333%; +} +.col-xs-pull-6 { + right: 50%; +} +.col-xs-pull-5 { + right: 41.66666667%; +} +.col-xs-pull-4 { + right: 33.33333333%; +} +.col-xs-pull-3 { + right: 25%; +} +.col-xs-pull-2 { + right: 16.66666667%; +} +.col-xs-pull-1 { + right: 8.33333333%; +} +.col-xs-pull-0 { + right: auto; +} +.col-xs-push-12 { + left: 100%; +} +.col-xs-push-11 { + left: 91.66666667%; +} +.col-xs-push-10 { + left: 83.33333333%; +} +.col-xs-push-9 { + left: 75%; +} +.col-xs-push-8 { + left: 66.66666667%; +} +.col-xs-push-7 { + left: 58.33333333%; +} +.col-xs-push-6 { + left: 50%; +} +.col-xs-push-5 { + left: 41.66666667%; +} +.col-xs-push-4 { + left: 33.33333333%; +} +.col-xs-push-3 { + left: 25%; +} +.col-xs-push-2 { + left: 16.66666667%; +} +.col-xs-push-1 { + left: 8.33333333%; +} +.col-xs-push-0 { + left: auto; +} +.col-xs-offset-12 { + margin-left: 100%; +} +.col-xs-offset-11 { + margin-left: 91.66666667%; +} +.col-xs-offset-10 { + margin-left: 83.33333333%; +} +.col-xs-offset-9 { + margin-left: 75%; +} +.col-xs-offset-8 { + margin-left: 66.66666667%; +} +.col-xs-offset-7 { + margin-left: 58.33333333%; +} +.col-xs-offset-6 { + margin-left: 50%; +} +.col-xs-offset-5 { + margin-left: 41.66666667%; +} +.col-xs-offset-4 { + margin-left: 33.33333333%; +} +.col-xs-offset-3 { + margin-left: 25%; +} +.col-xs-offset-2 { + margin-left: 16.66666667%; +} +.col-xs-offset-1 { + margin-left: 8.33333333%; +} +.col-xs-offset-0 { + margin-left: 0%; +} +@media (min-width: 768px) { + .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 { + float: left; + } + .col-sm-12 { + width: 100%; + } + .col-sm-11 { + width: 91.66666667%; + } + .col-sm-10 { + width: 83.33333333%; + } + .col-sm-9 { + width: 75%; + } + .col-sm-8 { + width: 66.66666667%; + } + .col-sm-7 { + width: 58.33333333%; + } + .col-sm-6 { + width: 50%; + } + .col-sm-5 { + width: 41.66666667%; + } + .col-sm-4 { + width: 33.33333333%; + } + .col-sm-3 { + width: 25%; + } + .col-sm-2 { + width: 16.66666667%; + } + .col-sm-1 { + width: 8.33333333%; + } + .col-sm-pull-12 { + right: 100%; + } + .col-sm-pull-11 { + right: 91.66666667%; + } + .col-sm-pull-10 { + right: 83.33333333%; + } + .col-sm-pull-9 { + right: 75%; + } + .col-sm-pull-8 { + right: 66.66666667%; + } + .col-sm-pull-7 { + right: 58.33333333%; + } + .col-sm-pull-6 { + right: 50%; + } + .col-sm-pull-5 { + right: 41.66666667%; + } + .col-sm-pull-4 { + right: 33.33333333%; + } + .col-sm-pull-3 { + right: 25%; + } + .col-sm-pull-2 { + right: 16.66666667%; + } + .col-sm-pull-1 { + right: 8.33333333%; + } + .col-sm-pull-0 { + right: auto; + } + .col-sm-push-12 { + left: 100%; + } + .col-sm-push-11 { + left: 91.66666667%; + } + .col-sm-push-10 { + left: 83.33333333%; + } + .col-sm-push-9 { + left: 75%; + } + .col-sm-push-8 { + left: 66.66666667%; + } + .col-sm-push-7 { + left: 58.33333333%; + } + .col-sm-push-6 { + left: 50%; + } + .col-sm-push-5 { + left: 41.66666667%; + } + .col-sm-push-4 { + left: 33.33333333%; + } + .col-sm-push-3 { + left: 25%; + } + .col-sm-push-2 { + left: 16.66666667%; + } + .col-sm-push-1 { + left: 8.33333333%; + } + .col-sm-push-0 { + left: auto; + } + .col-sm-offset-12 { + margin-left: 100%; + } + .col-sm-offset-11 { + margin-left: 91.66666667%; + } + .col-sm-offset-10 { + margin-left: 83.33333333%; + } + .col-sm-offset-9 { + margin-left: 75%; + } + .col-sm-offset-8 { + margin-left: 66.66666667%; + } + .col-sm-offset-7 { + margin-left: 58.33333333%; + } + .col-sm-offset-6 { + margin-left: 50%; + } + .col-sm-offset-5 { + margin-left: 41.66666667%; + } + .col-sm-offset-4 { + margin-left: 33.33333333%; + } + .col-sm-offset-3 { + margin-left: 25%; + } + .col-sm-offset-2 { + margin-left: 16.66666667%; + } + .col-sm-offset-1 { + margin-left: 8.33333333%; + } + .col-sm-offset-0 { + margin-left: 0%; + } +} +@media (min-width: 992px) { + .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { + float: left; + } + .col-md-12 { + width: 100%; + } + .col-md-11 { + width: 91.66666667%; + } + .col-md-10 { + width: 83.33333333%; + } + .col-md-9 { + width: 75%; + } + .col-md-8 { + width: 66.66666667%; + } + .col-md-7 { + width: 58.33333333%; + } + .col-md-6 { + width: 50%; + } + .col-md-5 { + width: 41.66666667%; + } + .col-md-4 { + width: 33.33333333%; + } + .col-md-3 { + width: 25%; + } + .col-md-2 { + width: 16.66666667%; + } + .col-md-1 { + width: 8.33333333%; + } + .col-md-pull-12 { + right: 100%; + } + .col-md-pull-11 { + right: 91.66666667%; + } + .col-md-pull-10 { + right: 83.33333333%; + } + .col-md-pull-9 { + right: 75%; + } + .col-md-pull-8 { + right: 66.66666667%; + } + .col-md-pull-7 { + right: 58.33333333%; + } + .col-md-pull-6 { + right: 50%; + } + .col-md-pull-5 { + right: 41.66666667%; + } + .col-md-pull-4 { + right: 33.33333333%; + } + .col-md-pull-3 { + right: 25%; + } + .col-md-pull-2 { + right: 16.66666667%; + } + .col-md-pull-1 { + right: 8.33333333%; + } + .col-md-pull-0 { + right: auto; + } + .col-md-push-12 { + left: 100%; + } + .col-md-push-11 { + left: 91.66666667%; + } + .col-md-push-10 { + left: 83.33333333%; + } + .col-md-push-9 { + left: 75%; + } + .col-md-push-8 { + left: 66.66666667%; + } + .col-md-push-7 { + left: 58.33333333%; + } + .col-md-push-6 { + left: 50%; + } + .col-md-push-5 { + left: 41.66666667%; + } + .col-md-push-4 { + left: 33.33333333%; + } + .col-md-push-3 { + left: 25%; + } + .col-md-push-2 { + left: 16.66666667%; + } + .col-md-push-1 { + left: 8.33333333%; + } + .col-md-push-0 { + left: auto; + } + .col-md-offset-12 { + margin-left: 100%; + } + .col-md-offset-11 { + margin-left: 91.66666667%; + } + .col-md-offset-10 { + margin-left: 83.33333333%; + } + .col-md-offset-9 { + margin-left: 75%; + } + .col-md-offset-8 { + margin-left: 66.66666667%; + } + .col-md-offset-7 { + margin-left: 58.33333333%; + } + .col-md-offset-6 { + margin-left: 50%; + } + .col-md-offset-5 { + margin-left: 41.66666667%; + } + .col-md-offset-4 { + margin-left: 33.33333333%; + } + .col-md-offset-3 { + margin-left: 25%; + } + .col-md-offset-2 { + margin-left: 16.66666667%; + } + .col-md-offset-1 { + margin-left: 8.33333333%; + } + .col-md-offset-0 { + margin-left: 0%; + } +} +@media (min-width: 1200px) { + .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 { + float: left; + } + .col-lg-12 { + width: 100%; + } + .col-lg-11 { + width: 91.66666667%; + } + .col-lg-10 { + width: 83.33333333%; + } + .col-lg-9 { + width: 75%; + } + .col-lg-8 { + width: 66.66666667%; + } + .col-lg-7 { + width: 58.33333333%; + } + .col-lg-6 { + width: 50%; + } + .col-lg-5 { + width: 41.66666667%; + } + .col-lg-4 { + width: 33.33333333%; + } + .col-lg-3 { + width: 25%; + } + .col-lg-2 { + width: 16.66666667%; + } + .col-lg-1 { + width: 8.33333333%; + } + .col-lg-pull-12 { + right: 100%; + } + .col-lg-pull-11 { + right: 91.66666667%; + } + .col-lg-pull-10 { + right: 83.33333333%; + } + .col-lg-pull-9 { + right: 75%; + } + .col-lg-pull-8 { + right: 66.66666667%; + } + .col-lg-pull-7 { + right: 58.33333333%; + } + .col-lg-pull-6 { + right: 50%; + } + .col-lg-pull-5 { + right: 41.66666667%; + } + .col-lg-pull-4 { + right: 33.33333333%; + } + .col-lg-pull-3 { + right: 25%; + } + .col-lg-pull-2 { + right: 16.66666667%; + } + .col-lg-pull-1 { + right: 8.33333333%; + } + .col-lg-pull-0 { + right: auto; + } + .col-lg-push-12 { + left: 100%; + } + .col-lg-push-11 { + left: 91.66666667%; + } + .col-lg-push-10 { + left: 83.33333333%; + } + .col-lg-push-9 { + left: 75%; + } + .col-lg-push-8 { + left: 66.66666667%; + } + .col-lg-push-7 { + left: 58.33333333%; + } + .col-lg-push-6 { + left: 50%; + } + .col-lg-push-5 { + left: 41.66666667%; + } + .col-lg-push-4 { + left: 33.33333333%; + } + .col-lg-push-3 { + left: 25%; + } + .col-lg-push-2 { + left: 16.66666667%; + } + .col-lg-push-1 { + left: 8.33333333%; + } + .col-lg-push-0 { + left: auto; + } + .col-lg-offset-12 { + margin-left: 100%; + } + .col-lg-offset-11 { + margin-left: 91.66666667%; + } + .col-lg-offset-10 { + margin-left: 83.33333333%; + } + .col-lg-offset-9 { + margin-left: 75%; + } + .col-lg-offset-8 { + margin-left: 66.66666667%; + } + .col-lg-offset-7 { + margin-left: 58.33333333%; + } + .col-lg-offset-6 { + margin-left: 50%; + } + .col-lg-offset-5 { + margin-left: 41.66666667%; + } + .col-lg-offset-4 { + margin-left: 33.33333333%; + } + .col-lg-offset-3 { + margin-left: 25%; + } + .col-lg-offset-2 { + margin-left: 16.66666667%; + } + .col-lg-offset-1 { + margin-left: 8.33333333%; + } + .col-lg-offset-0 { + margin-left: 0%; + } +} +table { + background-color: transparent; +} +caption { + padding-top: 8px; + padding-bottom: 8px; + color: #b4bcc2; + text-align: left; +} +th { + text-align: left; +} +.table { + width: 100%; + max-width: 100%; + margin-bottom: 18px; +} +.table > thead > tr > th, +.table > tbody > tr > th, +.table > tfoot > tr > th, +.table > thead > tr > td, +.table > tbody > tr > td, +.table > tfoot > tr > td { + padding: 8px; + line-height: 1.42857143; + vertical-align: top; + border-top: 1px solid #ecf0f1; +} +.table > thead > tr > th { + vertical-align: bottom; + border-bottom: 2px solid #ecf0f1; +} +.table > caption + thead > tr:first-child > th, +.table > colgroup + thead > tr:first-child > th, +.table > thead:first-child > tr:first-child > th, +.table > caption + thead > tr:first-child > td, +.table > colgroup + thead > tr:first-child > td, +.table > thead:first-child > tr:first-child > td { + border-top: 0; +} +.table > tbody + tbody { + border-top: 2px solid #ecf0f1; +} +.table .table { + background-color: #ffffff; +} +.table-condensed > thead > tr > th, +.table-condensed > tbody > tr > th, +.table-condensed > tfoot > tr > th, +.table-condensed > thead > tr > td, +.table-condensed > tbody > tr > td, +.table-condensed > tfoot > tr > td { + padding: 5px; +} +.table-bordered { + border: 1px solid #ecf0f1; +} +.table-bordered > thead > tr > th, +.table-bordered > tbody > tr > th, +.table-bordered > tfoot > tr > th, +.table-bordered > thead > tr > td, +.table-bordered > tbody > tr > td, +.table-bordered > tfoot > tr > td { + border: 1px solid #ecf0f1; +} +.table-bordered > thead > tr > th, +.table-bordered > thead > tr > td { + border-bottom-width: 2px; +} +.table-striped > tbody > tr:nth-of-type(odd) { + background-color: #f9f9f9; +} +.table-hover > tbody > tr:hover { + background-color: #ecf0f1; +} +table col[class*="col-"] { + position: static; + float: none; + display: table-column; +} +table td[class*="col-"], +table th[class*="col-"] { + position: static; + float: none; + display: table-cell; +} +.table > thead > tr > td.active, +.table > tbody > tr > td.active, +.table > tfoot > tr > td.active, +.table > thead > tr > th.active, +.table > tbody > tr > th.active, +.table > tfoot > tr > th.active, +.table > thead > tr.active > td, +.table > tbody > tr.active > td, +.table > tfoot > tr.active > td, +.table > thead > tr.active > th, +.table > tbody > tr.active > th, +.table > tfoot > tr.active > th { + background-color: #ecf0f1; +} +.table-hover > tbody > tr > td.active:hover, +.table-hover > tbody > tr > th.active:hover, +.table-hover > tbody > tr.active:hover > td, +.table-hover > tbody > tr:hover > .active, +.table-hover > tbody > tr.active:hover > th { + background-color: #dde4e6; +} +.table > thead > tr > td.success, +.table > tbody > tr > td.success, +.table > tfoot > tr > td.success, +.table > thead > tr > th.success, +.table > tbody > tr > th.success, +.table > tfoot > tr > th.success, +.table > thead > tr.success > td, +.table > tbody > tr.success > td, +.table > tfoot > tr.success > td, +.table > thead > tr.success > th, +.table > tbody > tr.success > th, +.table > tfoot > tr.success > th { + background-color: #31c471; +} +.table-hover > tbody > tr > td.success:hover, +.table-hover > tbody > tr > th.success:hover, +.table-hover > tbody > tr.success:hover > td, +.table-hover > tbody > tr:hover > .success, +.table-hover > tbody > tr.success:hover > th { + background-color: #2cb065; +} +.table > thead > tr > td.info, +.table > tbody > tr > td.info, +.table > tfoot > tr > td.info, +.table > thead > tr > th.info, +.table > tbody > tr > th.info, +.table > tfoot > tr > th.info, +.table > thead > tr.info > td, +.table > tbody > tr.info > td, +.table > tfoot > tr.info > td, +.table > thead > tr.info > th, +.table > tbody > tr.info > th, +.table > tfoot > tr.info > th { + background-color: #1f6b7a; +} +.table-hover > tbody > tr > td.info:hover, +.table-hover > tbody > tr > th.info:hover, +.table-hover > tbody > tr.info:hover > td, +.table-hover > tbody > tr:hover > .info, +.table-hover > tbody > tr.info:hover > th { + background-color: #1a5966; +} +.table > thead > tr > td.warning, +.table > tbody > tr > td.warning, +.table > tfoot > tr > td.warning, +.table > thead > tr > th.warning, +.table > tbody > tr > th.warning, +.table > tfoot > tr > th.warning, +.table > thead > tr.warning > td, +.table > tbody > tr.warning > td, +.table > tfoot > tr.warning > td, +.table > thead > tr.warning > th, +.table > tbody > tr.warning > th, +.table > tfoot > tr.warning > th { + background-color: #f39c12; +} +.table-hover > tbody > tr > td.warning:hover, +.table-hover > tbody > tr > th.warning:hover, +.table-hover > tbody > tr.warning:hover > td, +.table-hover > tbody > tr:hover > .warning, +.table-hover > tbody > tr.warning:hover > th { + background-color: #e08e0b; +} +.table > thead > tr > td.danger, +.table > tbody > tr > td.danger, +.table > tfoot > tr > td.danger, +.table > thead > tr > th.danger, +.table > tbody > tr > th.danger, +.table > tfoot > tr > th.danger, +.table > thead > tr.danger > td, +.table > tbody > tr.danger > td, +.table > tfoot > tr.danger > td, +.table > thead > tr.danger > th, +.table > tbody > tr.danger > th, +.table > tfoot > tr.danger > th { + background-color: #e74c3c; +} +.table-hover > tbody > tr > td.danger:hover, +.table-hover > tbody > tr > th.danger:hover, +.table-hover > tbody > tr.danger:hover > td, +.table-hover > tbody > tr:hover > .danger, +.table-hover > tbody > tr.danger:hover > th { + background-color: #e43725; +} +.table-responsive { + overflow-x: auto; + min-height: 0.01%; +} +@media screen and (max-width: 767px) { + .table-responsive { + width: 100%; + margin-bottom: 13.5px; + overflow-y: hidden; + -ms-overflow-style: -ms-autohiding-scrollbar; + border: 1px solid #ecf0f1; + } + .table-responsive > .table { + margin-bottom: 0; + } + .table-responsive > .table > thead > tr > th, + .table-responsive > .table > tbody > tr > th, + .table-responsive > .table > tfoot > tr > th, + .table-responsive > .table > thead > tr > td, + .table-responsive > .table > tbody > tr > td, + .table-responsive > .table > tfoot > tr > td { + white-space: nowrap; + } + .table-responsive > .table-bordered { + border: 0; + } + .table-responsive > .table-bordered > thead > tr > th:first-child, + .table-responsive > .table-bordered > tbody > tr > th:first-child, + .table-responsive > .table-bordered > tfoot > tr > th:first-child, + .table-responsive > .table-bordered > thead > tr > td:first-child, + .table-responsive > .table-bordered > tbody > tr > td:first-child, + .table-responsive > .table-bordered > tfoot > tr > td:first-child { + border-left: 0; + } + .table-responsive > .table-bordered > thead > tr > th:last-child, + .table-responsive > .table-bordered > tbody > tr > th:last-child, + .table-responsive > .table-bordered > tfoot > tr > th:last-child, + .table-responsive > .table-bordered > thead > tr > td:last-child, + .table-responsive > .table-bordered > tbody > tr > td:last-child, + .table-responsive > .table-bordered > tfoot > tr > td:last-child { + border-right: 0; + } + .table-responsive > .table-bordered > tbody > tr:last-child > th, + .table-responsive > .table-bordered > tfoot > tr:last-child > th, + .table-responsive > .table-bordered > tbody > tr:last-child > td, + .table-responsive > .table-bordered > tfoot > tr:last-child > td { + border-bottom: 0; + } +} +fieldset { + padding: 0; + margin: 0; + border: 0; + min-width: 0; +} +legend { + display: block; + width: 100%; + padding: 0; + margin-bottom: 18px; + font-size: 19.5px; + line-height: inherit; + color: #444444; + border: 0; + border-bottom: 1px solid transparent; +} +label { + display: inline-block; + max-width: 100%; + margin-bottom: 5px; + font-weight: bold; +} +input[type="search"] { + box-sizing: border-box; +} +input[type="radio"], +input[type="checkbox"] { + margin: 4px 0 0; + margin-top: 1px \9; + line-height: normal; +} +input[type="file"] { + display: block; +} +input[type="range"] { + display: block; + width: 100%; +} +select[multiple], +select[size] { + height: auto; +} +input[type="file"]:focus, +input[type="radio"]:focus, +input[type="checkbox"]:focus { + outline: thin dotted; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} +output { + display: block; + padding-top: 6px; + font-size: 13px; + line-height: 1.42857143; + color: #444444; +} +.form-control { + display: block; + width: 100%; + height: 30px; + padding: 5px 15px; + font-size: 13px; + line-height: 1.42857143; + color: #444444; + background-color: #ffffff; + background-image: none; + border: 1px solid #ecf0f1; + border-radius: 4px; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; + transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; +} +.form-control:focus { + border-color: #b4bcc2; + outline: 0; + box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(180, 188, 194, 0.6); +} +.form-control::-moz-placeholder { + color: #acb6c0; + opacity: 1; +} +.form-control:-ms-input-placeholder { + color: #acb6c0; +} +.form-control::-webkit-input-placeholder { + color: #acb6c0; +} +.form-control[disabled], +.form-control[readonly], +fieldset[disabled] .form-control { + background-color: #ecf0f1; + opacity: 1; +} +.form-control[disabled], +fieldset[disabled] .form-control { + cursor: not-allowed; +} +textarea.form-control { + height: auto; +} +input[type="search"] { + -webkit-appearance: none; +} +@media screen and (-webkit-min-device-pixel-ratio: 0) { + input[type="date"].form-control, + input[type="time"].form-control, + input[type="datetime-local"].form-control, + input[type="month"].form-control { + line-height: 30px; + } + input[type="date"].input-sm, + input[type="time"].input-sm, + input[type="datetime-local"].input-sm, + input[type="month"].input-sm, + .input-group-sm input[type="date"], + .input-group-sm input[type="time"], + .input-group-sm input[type="datetime-local"], + .input-group-sm input[type="month"] { + line-height: 32px; + } + input[type="date"].input-lg, + input[type="time"].input-lg, + input[type="datetime-local"].input-lg, + input[type="month"].input-lg, + .input-group-lg input[type="date"], + .input-group-lg input[type="time"], + .input-group-lg input[type="datetime-local"], + .input-group-lg input[type="month"] { + line-height: 61px; + } +} +.form-group { + margin-bottom: 15px; +} +.radio, +.checkbox { + position: relative; + display: block; + margin-top: 10px; + margin-bottom: 10px; +} +.radio label, +.checkbox label { + min-height: 18px; + padding-left: 20px; + margin-bottom: 0; + font-weight: normal; + cursor: pointer; +} +.radio input[type="radio"], +.radio-inline input[type="radio"], +.checkbox input[type="checkbox"], +.checkbox-inline input[type="checkbox"] { + position: absolute; + margin-left: -20px; + margin-top: 4px \9; +} +.radio + .radio, +.checkbox + .checkbox { + margin-top: -5px; +} +.radio-inline, +.checkbox-inline { + position: relative; + display: inline-block; + padding-left: 20px; + margin-bottom: 0; + vertical-align: middle; + font-weight: normal; + cursor: pointer; +} +.radio-inline + .radio-inline, +.checkbox-inline + .checkbox-inline { + margin-top: 0; + margin-left: 10px; +} +input[type="radio"][disabled], +input[type="checkbox"][disabled], +input[type="radio"].disabled, +input[type="checkbox"].disabled, +fieldset[disabled] input[type="radio"], +fieldset[disabled] input[type="checkbox"] { + cursor: not-allowed; +} +.radio-inline.disabled, +.checkbox-inline.disabled, +fieldset[disabled] .radio-inline, +fieldset[disabled] .checkbox-inline { + cursor: not-allowed; +} +.radio.disabled label, +.checkbox.disabled label, +fieldset[disabled] .radio label, +fieldset[disabled] .checkbox label { + cursor: not-allowed; +} +.form-control-static { + padding-top: 6px; + padding-bottom: 6px; + margin-bottom: 0; + min-height: 31px; +} +.form-control-static.input-lg, +.form-control-static.input-sm { + padding-left: 0; + padding-right: 0; +} +.input-sm { + height: 32px; + padding: 6px 9px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +select.input-sm { + height: 32px; + line-height: 32px; +} +textarea.input-sm, +select[multiple].input-sm { + height: auto; +} +.form-group-sm .form-control { + height: 32px; + padding: 6px 9px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +.form-group-sm select.form-control { + height: 32px; + line-height: 32px; +} +.form-group-sm textarea.form-control, +.form-group-sm select[multiple].form-control { + height: auto; +} +.form-group-sm .form-control-static { + height: 32px; + min-height: 30px; + padding: 7px 9px; + font-size: 12px; + line-height: 1.5; +} +.input-lg { + height: 61px; + padding: 18px 27px; + font-size: 17px; + line-height: 1.33; + border-radius: 6px; +} +select.input-lg { + height: 61px; + line-height: 61px; +} +textarea.input-lg, +select[multiple].input-lg { + height: auto; +} +.form-group-lg .form-control { + height: 61px; + padding: 18px 27px; + font-size: 17px; + line-height: 1.33; + border-radius: 6px; +} +.form-group-lg select.form-control { + height: 61px; + line-height: 61px; +} +.form-group-lg textarea.form-control, +.form-group-lg select[multiple].form-control { + height: auto; +} +.form-group-lg .form-control-static { + height: 61px; + min-height: 35px; + padding: 19px 27px; + font-size: 17px; + line-height: 1.33; +} +.has-feedback { + position: relative; +} +.has-feedback .form-control { + padding-right: 37.5px; +} +.form-control-feedback { + position: absolute; + top: 0; + right: 0; + z-index: 2; + display: block; + width: 30px; + height: 30px; + line-height: 30px; + text-align: center; + pointer-events: none; +} +.input-lg + .form-control-feedback, +.input-group-lg + .form-control-feedback, +.form-group-lg .form-control + .form-control-feedback { + width: 61px; + height: 61px; + line-height: 61px; +} +.input-sm + .form-control-feedback, +.input-group-sm + .form-control-feedback, +.form-group-sm .form-control + .form-control-feedback { + width: 32px; + height: 32px; + line-height: 32px; +} +.has-success .help-block, +.has-success .control-label, +.has-success .radio, +.has-success .checkbox, +.has-success .radio-inline, +.has-success .checkbox-inline, +.has-success.radio label, +.has-success.checkbox label, +.has-success.radio-inline label, +.has-success.checkbox-inline label { + color: #ffffff; +} +.has-success .form-control { + border-color: #ffffff; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} +.has-success .form-control:focus { + border-color: #e6e6e6; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; +} +.has-success .input-group-addon { + color: #ffffff; + border-color: #ffffff; + background-color: #31c471; +} +.has-success .form-control-feedback { + color: #ffffff; +} +.has-warning .help-block, +.has-warning .control-label, +.has-warning .radio, +.has-warning .checkbox, +.has-warning .radio-inline, +.has-warning .checkbox-inline, +.has-warning.radio label, +.has-warning.checkbox label, +.has-warning.radio-inline label, +.has-warning.checkbox-inline label { + color: #ffffff; +} +.has-warning .form-control { + border-color: #ffffff; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} +.has-warning .form-control:focus { + border-color: #e6e6e6; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; +} +.has-warning .input-group-addon { + color: #ffffff; + border-color: #ffffff; + background-color: #f39c12; +} +.has-warning .form-control-feedback { + color: #ffffff; +} +.has-error .help-block, +.has-error .control-label, +.has-error .radio, +.has-error .checkbox, +.has-error .radio-inline, +.has-error .checkbox-inline, +.has-error.radio label, +.has-error.checkbox label, +.has-error.radio-inline label, +.has-error.checkbox-inline label { + color: #ffffff; +} +.has-error .form-control { + border-color: #ffffff; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); +} +.has-error .form-control:focus { + border-color: #e6e6e6; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; +} +.has-error .input-group-addon { + color: #ffffff; + border-color: #ffffff; + background-color: #e74c3c; +} +.has-error .form-control-feedback { + color: #ffffff; +} +.has-feedback label ~ .form-control-feedback { + top: 23px; +} +.has-feedback label.sr-only ~ .form-control-feedback { + top: 0; +} +.help-block { + display: block; + margin-top: 5px; + margin-bottom: 10px; + color: #848484; +} +@media (min-width: 768px) { + .form-inline .form-group { + display: inline-block; + margin-bottom: 0; + vertical-align: middle; + } + .form-inline .form-control { + display: inline-block; + width: auto; + vertical-align: middle; + } + .form-inline .form-control-static { + display: inline-block; + } + .form-inline .input-group { + display: inline-table; + vertical-align: middle; + } + .form-inline .input-group .input-group-addon, + .form-inline .input-group .input-group-btn, + .form-inline .input-group .form-control { + width: auto; + } + .form-inline .input-group > .form-control { + width: 100%; + } + .form-inline .control-label { + margin-bottom: 0; + vertical-align: middle; + } + .form-inline .radio, + .form-inline .checkbox { + display: inline-block; + margin-top: 0; + margin-bottom: 0; + vertical-align: middle; + } + .form-inline .radio label, + .form-inline .checkbox label { + padding-left: 0; + } + .form-inline .radio input[type="radio"], + .form-inline .checkbox input[type="checkbox"] { + position: relative; + margin-left: 0; + } + .form-inline .has-feedback .form-control-feedback { + top: 0; + } +} +.form-horizontal .radio, +.form-horizontal .checkbox, +.form-horizontal .radio-inline, +.form-horizontal .checkbox-inline { + margin-top: 0; + margin-bottom: 0; + padding-top: 6px; +} +.form-horizontal .radio, +.form-horizontal .checkbox { + min-height: 24px; +} +.form-horizontal .form-group { + margin-left: -15px; + margin-right: -15px; +} +@media (min-width: 768px) { + .form-horizontal .control-label { + text-align: right; + margin-bottom: 0; + padding-top: 6px; + } +} +.form-horizontal .has-feedback .form-control-feedback { + right: 15px; +} +@media (min-width: 768px) { + .form-horizontal .form-group-lg .control-label { + padding-top: 24.94px; + font-size: 17px; + } +} +@media (min-width: 768px) { + .form-horizontal .form-group-sm .control-label { + padding-top: 7px; + font-size: 12px; + } +} +.btn { + display: inline-block; + margin-bottom: 0; + font-weight: normal; + text-align: center; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + background-image: none; + border: 1px solid transparent; + white-space: nowrap; + padding: 5px 15px; + font-size: 13px; + line-height: 1.42857143; + border-radius: 4px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.btn:focus, +.btn:active:focus, +.btn.active:focus, +.btn.focus, +.btn:active.focus, +.btn.active.focus { + outline: thin dotted; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} +.btn:hover, +.btn:focus, +.btn.focus { + color: #ffffff; + text-decoration: none; +} +.btn:active, +.btn.active { + outline: 0; + background-image: none; + box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); +} +.btn.disabled, +.btn[disabled], +fieldset[disabled] .btn { + cursor: not-allowed; + opacity: 0.65; + filter: alpha(opacity=65); + box-shadow: none; +} +a.btn.disabled, +fieldset[disabled] a.btn { + pointer-events: none; +} +.btn-default { + color: #ffffff; + background-color: #95a5a6; + border-color: #95a5a6; +} +.btn-default:focus, +.btn-default.focus { + color: #ffffff; + background-color: #798d8f; + border-color: #566566; +} +.btn-default:hover { + color: #ffffff; + background-color: #798d8f; + border-color: #74898a; +} +.btn-default:active, +.btn-default.active, +.open > .dropdown-toggle.btn-default { + color: #ffffff; + background-color: #798d8f; + border-color: #74898a; +} +.btn-default:active:hover, +.btn-default.active:hover, +.open > .dropdown-toggle.btn-default:hover, +.btn-default:active:focus, +.btn-default.active:focus, +.open > .dropdown-toggle.btn-default:focus, +.btn-default:active.focus, +.btn-default.active.focus, +.open > .dropdown-toggle.btn-default.focus { + color: #ffffff; + background-color: #687b7c; + border-color: #566566; +} +.btn-default:active, +.btn-default.active, +.open > .dropdown-toggle.btn-default { + background-image: none; +} +.btn-default.disabled, +.btn-default[disabled], +fieldset[disabled] .btn-default, +.btn-default.disabled:hover, +.btn-default[disabled]:hover, +fieldset[disabled] .btn-default:hover, +.btn-default.disabled:focus, +.btn-default[disabled]:focus, +fieldset[disabled] .btn-default:focus, +.btn-default.disabled.focus, +.btn-default[disabled].focus, +fieldset[disabled] .btn-default.focus, +.btn-default.disabled:active, +.btn-default[disabled]:active, +fieldset[disabled] .btn-default:active, +.btn-default.disabled.active, +.btn-default[disabled].active, +fieldset[disabled] .btn-default.active { + background-color: #95a5a6; + border-color: #95a5a6; +} +.btn-default .badge { + color: #95a5a6; + background-color: #ffffff; +} +.btn-primary { + color: #ffffff; + background-color: #444444; + border-color: #444444; +} +.btn-primary:focus, +.btn-primary.focus { + color: #ffffff; + background-color: #2b2b2b; + border-color: #040404; +} +.btn-primary:hover { + color: #ffffff; + background-color: #2b2b2b; + border-color: #252525; +} +.btn-primary:active, +.btn-primary.active, +.open > .dropdown-toggle.btn-primary { + color: #ffffff; + background-color: #2b2b2b; + border-color: #252525; +} +.btn-primary:active:hover, +.btn-primary.active:hover, +.open > .dropdown-toggle.btn-primary:hover, +.btn-primary:active:focus, +.btn-primary.active:focus, +.open > .dropdown-toggle.btn-primary:focus, +.btn-primary:active.focus, +.btn-primary.active.focus, +.open > .dropdown-toggle.btn-primary.focus { + color: #ffffff; + background-color: #191919; + border-color: #040404; +} +.btn-primary:active, +.btn-primary.active, +.open > .dropdown-toggle.btn-primary { + background-image: none; +} +.btn-primary.disabled, +.btn-primary[disabled], +fieldset[disabled] .btn-primary, +.btn-primary.disabled:hover, +.btn-primary[disabled]:hover, +fieldset[disabled] .btn-primary:hover, +.btn-primary.disabled:focus, +.btn-primary[disabled]:focus, +fieldset[disabled] .btn-primary:focus, +.btn-primary.disabled.focus, +.btn-primary[disabled].focus, +fieldset[disabled] .btn-primary.focus, +.btn-primary.disabled:active, +.btn-primary[disabled]:active, +fieldset[disabled] .btn-primary:active, +.btn-primary.disabled.active, +.btn-primary[disabled].active, +fieldset[disabled] .btn-primary.active { + background-color: #444444; + border-color: #444444; +} +.btn-primary .badge { + color: #444444; + background-color: #ffffff; +} +.btn-success { + color: #ffffff; + background-color: #31c471; + border-color: #31c471; +} +.btn-success:focus, +.btn-success.focus { + color: #ffffff; + background-color: #279b59; + border-color: #185e36; +} +.btn-success:hover { + color: #ffffff; + background-color: #279b59; + border-color: #259355; +} +.btn-success:active, +.btn-success.active, +.open > .dropdown-toggle.btn-success { + color: #ffffff; + background-color: #279b59; + border-color: #259355; +} +.btn-success:active:hover, +.btn-success.active:hover, +.open > .dropdown-toggle.btn-success:hover, +.btn-success:active:focus, +.btn-success.active:focus, +.open > .dropdown-toggle.btn-success:focus, +.btn-success:active.focus, +.btn-success.active.focus, +.open > .dropdown-toggle.btn-success.focus { + color: #ffffff; + background-color: #207f49; + border-color: #185e36; +} +.btn-success:active, +.btn-success.active, +.open > .dropdown-toggle.btn-success { + background-image: none; +} +.btn-success.disabled, +.btn-success[disabled], +fieldset[disabled] .btn-success, +.btn-success.disabled:hover, +.btn-success[disabled]:hover, +fieldset[disabled] .btn-success:hover, +.btn-success.disabled:focus, +.btn-success[disabled]:focus, +fieldset[disabled] .btn-success:focus, +.btn-success.disabled.focus, +.btn-success[disabled].focus, +fieldset[disabled] .btn-success.focus, +.btn-success.disabled:active, +.btn-success[disabled]:active, +fieldset[disabled] .btn-success:active, +.btn-success.disabled.active, +.btn-success[disabled].active, +fieldset[disabled] .btn-success.active { + background-color: #31c471; + border-color: #31c471; +} +.btn-success .badge { + color: #31c471; + background-color: #ffffff; +} +.btn-info { + color: #ffffff; + background-color: #1f6b7a; + border-color: #1f6b7a; +} +.btn-info:focus, +.btn-info.focus { + color: #ffffff; + background-color: #154751; + border-color: #051214; +} +.btn-info:hover { + color: #ffffff; + background-color: #154751; + border-color: #134049; +} +.btn-info:active, +.btn-info.active, +.open > .dropdown-toggle.btn-info { + color: #ffffff; + background-color: #154751; + border-color: #134049; +} +.btn-info:active:hover, +.btn-info.active:hover, +.open > .dropdown-toggle.btn-info:hover, +.btn-info:active:focus, +.btn-info.active:focus, +.open > .dropdown-toggle.btn-info:focus, +.btn-info:active.focus, +.btn-info.active.focus, +.open > .dropdown-toggle.btn-info.focus { + color: #ffffff; + background-color: #0d2e35; + border-color: #051214; +} +.btn-info:active, +.btn-info.active, +.open > .dropdown-toggle.btn-info { + background-image: none; +} +.btn-info.disabled, +.btn-info[disabled], +fieldset[disabled] .btn-info, +.btn-info.disabled:hover, +.btn-info[disabled]:hover, +fieldset[disabled] .btn-info:hover, +.btn-info.disabled:focus, +.btn-info[disabled]:focus, +fieldset[disabled] .btn-info:focus, +.btn-info.disabled.focus, +.btn-info[disabled].focus, +fieldset[disabled] .btn-info.focus, +.btn-info.disabled:active, +.btn-info[disabled]:active, +fieldset[disabled] .btn-info:active, +.btn-info.disabled.active, +.btn-info[disabled].active, +fieldset[disabled] .btn-info.active { + background-color: #1f6b7a; + border-color: #1f6b7a; +} +.btn-info .badge { + color: #1f6b7a; + background-color: #ffffff; +} +.btn-warning { + color: #ffffff; + background-color: #f39c12; + border-color: #f39c12; +} +.btn-warning:focus, +.btn-warning.focus { + color: #ffffff; + background-color: #c87f0a; + border-color: #7f5006; +} +.btn-warning:hover { + color: #ffffff; + background-color: #c87f0a; + border-color: #be780a; +} +.btn-warning:active, +.btn-warning.active, +.open > .dropdown-toggle.btn-warning { + color: #ffffff; + background-color: #c87f0a; + border-color: #be780a; +} +.btn-warning:active:hover, +.btn-warning.active:hover, +.open > .dropdown-toggle.btn-warning:hover, +.btn-warning:active:focus, +.btn-warning.active:focus, +.open > .dropdown-toggle.btn-warning:focus, +.btn-warning:active.focus, +.btn-warning.active.focus, +.open > .dropdown-toggle.btn-warning.focus { + color: #ffffff; + background-color: #a66908; + border-color: #7f5006; +} +.btn-warning:active, +.btn-warning.active, +.open > .dropdown-toggle.btn-warning { + background-image: none; +} +.btn-warning.disabled, +.btn-warning[disabled], +fieldset[disabled] .btn-warning, +.btn-warning.disabled:hover, +.btn-warning[disabled]:hover, +fieldset[disabled] .btn-warning:hover, +.btn-warning.disabled:focus, +.btn-warning[disabled]:focus, +fieldset[disabled] .btn-warning:focus, +.btn-warning.disabled.focus, +.btn-warning[disabled].focus, +fieldset[disabled] .btn-warning.focus, +.btn-warning.disabled:active, +.btn-warning[disabled]:active, +fieldset[disabled] .btn-warning:active, +.btn-warning.disabled.active, +.btn-warning[disabled].active, +fieldset[disabled] .btn-warning.active { + background-color: #f39c12; + border-color: #f39c12; +} +.btn-warning .badge { + color: #f39c12; + background-color: #ffffff; +} +.btn-danger { + color: #ffffff; + background-color: #e74c3c; + border-color: #e74c3c; +} +.btn-danger:focus, +.btn-danger.focus { + color: #ffffff; + background-color: #d62c1a; + border-color: #921e12; +} +.btn-danger:hover { + color: #ffffff; + background-color: #d62c1a; + border-color: #cd2a19; +} +.btn-danger:active, +.btn-danger.active, +.open > .dropdown-toggle.btn-danger { + color: #ffffff; + background-color: #d62c1a; + border-color: #cd2a19; +} +.btn-danger:active:hover, +.btn-danger.active:hover, +.open > .dropdown-toggle.btn-danger:hover, +.btn-danger:active:focus, +.btn-danger.active:focus, +.open > .dropdown-toggle.btn-danger:focus, +.btn-danger:active.focus, +.btn-danger.active.focus, +.open > .dropdown-toggle.btn-danger.focus { + color: #ffffff; + background-color: #b62516; + border-color: #921e12; +} +.btn-danger:active, +.btn-danger.active, +.open > .dropdown-toggle.btn-danger { + background-image: none; +} +.btn-danger.disabled, +.btn-danger[disabled], +fieldset[disabled] .btn-danger, +.btn-danger.disabled:hover, +.btn-danger[disabled]:hover, +fieldset[disabled] .btn-danger:hover, +.btn-danger.disabled:focus, +.btn-danger[disabled]:focus, +fieldset[disabled] .btn-danger:focus, +.btn-danger.disabled.focus, +.btn-danger[disabled].focus, +fieldset[disabled] .btn-danger.focus, +.btn-danger.disabled:active, +.btn-danger[disabled]:active, +fieldset[disabled] .btn-danger:active, +.btn-danger.disabled.active, +.btn-danger[disabled].active, +fieldset[disabled] .btn-danger.active { + background-color: #e74c3c; + border-color: #e74c3c; +} +.btn-danger .badge { + color: #e74c3c; + background-color: #ffffff; +} +.btn-link { + color: #1f6b7a; + font-weight: normal; + border-radius: 0; +} +.btn-link, +.btn-link:active, +.btn-link.active, +.btn-link[disabled], +fieldset[disabled] .btn-link { + background-color: transparent; + box-shadow: none; +} +.btn-link, +.btn-link:hover, +.btn-link:focus, +.btn-link:active { + border-color: transparent; +} +.btn-link:hover, +.btn-link:focus { + color: #298fa3; + text-decoration: none; + background-color: transparent; +} +.btn-link[disabled]:hover, +fieldset[disabled] .btn-link:hover, +.btn-link[disabled]:focus, +fieldset[disabled] .btn-link:focus { + color: #b4bcc2; + text-decoration: none; +} +.btn-lg, +.btn-group-lg > .btn { + padding: 18px 27px; + font-size: 17px; + line-height: 1.33; + border-radius: 6px; +} +.btn-sm, +.btn-group-sm > .btn { + padding: 6px 9px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +.btn-xs, +.btn-group-xs > .btn { + padding: 1px 5px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +.btn-block { + display: block; + width: 100%; +} +.btn-block + .btn-block { + margin-top: 5px; +} +input[type="submit"].btn-block, +input[type="reset"].btn-block, +input[type="button"].btn-block { + width: 100%; +} +.fade { + opacity: 0; + -webkit-transition: opacity 0.15s linear; + transition: opacity 0.15s linear; +} +.fade.in { + opacity: 1; +} +.collapse { + display: none; +} +.collapse.in { + display: block; +} +tr.collapse.in { + display: table-row; +} +tbody.collapse.in { + display: table-row-group; +} +.collapsing { + position: relative; + height: 0; + overflow: hidden; + -webkit-transition-property: height, visibility; + transition-property: height, visibility; + -webkit-transition-duration: 0.35s; + transition-duration: 0.35s; + -webkit-transition-timing-function: ease; + transition-timing-function: ease; +} +.caret { + display: inline-block; + width: 0; + height: 0; + margin-left: 2px; + vertical-align: middle; + border-top: 4px dashed; + border-top: 4px solid \9; + border-right: 4px solid transparent; + border-left: 4px solid transparent; +} +.dropup, +.dropdown { + position: relative; +} +.dropdown-toggle:focus { + outline: 0; +} +.dropdown-menu { + position: absolute; + top: 100%; + left: 0; + z-index: 1000; + display: none; + float: left; + min-width: 160px; + padding: 5px 0; + margin: 2px 0 0; + list-style: none; + font-size: 13px; + text-align: left; + background-color: #ffffff; + border: 1px solid #dddddd; + border: 1px solid rgba(0, 0, 0, 0.15); + border-radius: 4px; + box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); + background-clip: padding-box; +} +.dropdown-menu.pull-right { + right: 0; + left: auto; +} +.dropdown-menu .divider { + height: 1px; + margin: 8px 0; + overflow: hidden; + background-color: #e5e5e5; +} +.dropdown-menu > li > a { + display: block; + padding: 3px 20px; + clear: both; + font-weight: normal; + line-height: 1.42857143; + color: #7b8a8b; + white-space: nowrap; +} +.dropdown-menu > li > a:hover, +.dropdown-menu > li > a:focus { + text-decoration: none; + color: #ffffff; + background-color: #444444; +} +.dropdown-menu > .active > a, +.dropdown-menu > .active > a:hover, +.dropdown-menu > .active > a:focus { + color: #ffffff; + text-decoration: none; + outline: 0; + background-color: #444444; +} +.dropdown-menu > .disabled > a, +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + color: #b4bcc2; +} +.dropdown-menu > .disabled > a:hover, +.dropdown-menu > .disabled > a:focus { + text-decoration: none; + background-color: transparent; + background-image: none; + filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); + cursor: not-allowed; +} +.open > .dropdown-menu { + display: block; +} +.open > a { + outline: 0; +} +.dropdown-menu-right { + left: auto; + right: 0; +} +.dropdown-menu-left { + left: 0; + right: auto; +} +.dropdown-header { + display: block; + padding: 3px 20px; + font-size: 12px; + line-height: 1.42857143; + color: #b4bcc2; + white-space: nowrap; +} +.dropdown-backdrop { + position: fixed; + left: 0; + right: 0; + bottom: 0; + top: 0; + z-index: 990; +} +.pull-right > .dropdown-menu { + right: 0; + left: auto; +} +.dropup .caret, +.navbar-fixed-bottom .dropdown .caret { + border-top: 0; + border-bottom: 4px dashed; + border-bottom: 4px solid \9; + content: ""; +} +.dropup .dropdown-menu, +.navbar-fixed-bottom .dropdown .dropdown-menu { + top: auto; + bottom: 100%; + margin-bottom: 2px; +} +@media (min-width: 768px) { + .navbar-right .dropdown-menu { + left: auto; + right: 0; + } + .navbar-right .dropdown-menu-left { + left: 0; + right: auto; + } +} +.btn-group, +.btn-group-vertical { + position: relative; + display: inline-block; + vertical-align: middle; +} +.btn-group > .btn, +.btn-group-vertical > .btn { + position: relative; + float: left; +} +.btn-group > .btn:hover, +.btn-group-vertical > .btn:hover, +.btn-group > .btn:focus, +.btn-group-vertical > .btn:focus, +.btn-group > .btn:active, +.btn-group-vertical > .btn:active, +.btn-group > .btn.active, +.btn-group-vertical > .btn.active { + z-index: 2; +} +.btn-group .btn + .btn, +.btn-group .btn + .btn-group, +.btn-group .btn-group + .btn, +.btn-group .btn-group + .btn-group { + margin-left: -1px; +} +.btn-toolbar { + margin-left: -5px; +} +.btn-toolbar .btn, +.btn-toolbar .btn-group, +.btn-toolbar .input-group { + float: left; +} +.btn-toolbar > .btn, +.btn-toolbar > .btn-group, +.btn-toolbar > .input-group { + margin-left: 5px; +} +.btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) { + border-radius: 0; +} +.btn-group > .btn:first-child { + margin-left: 0; +} +.btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) { + border-bottom-right-radius: 0; + border-top-right-radius: 0; +} +.btn-group > .btn:last-child:not(:first-child), +.btn-group > .dropdown-toggle:not(:first-child) { + border-bottom-left-radius: 0; + border-top-left-radius: 0; +} +.btn-group > .btn-group { + float: left; +} +.btn-group > .btn-group:not(:first-child):not(:last-child) > .btn { + border-radius: 0; +} +.btn-group > .btn-group:first-child:not(:last-child) > .btn:last-child, +.btn-group > .btn-group:first-child:not(:last-child) > .dropdown-toggle { + border-bottom-right-radius: 0; + border-top-right-radius: 0; +} +.btn-group > .btn-group:last-child:not(:first-child) > .btn:first-child { + border-bottom-left-radius: 0; + border-top-left-radius: 0; +} +.btn-group .dropdown-toggle:active, +.btn-group.open .dropdown-toggle { + outline: 0; +} +.btn-group > .btn + .dropdown-toggle { + padding-left: 8px; + padding-right: 8px; +} +.btn-group > .btn-lg + .dropdown-toggle { + padding-left: 12px; + padding-right: 12px; +} +.btn-group.open .dropdown-toggle { + box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); +} +.btn-group.open .dropdown-toggle.btn-link { + box-shadow: none; +} +.btn .caret { + margin-left: 0; +} +.btn-lg .caret { + border-width: 5px 5px 0; + border-bottom-width: 0; +} +.dropup .btn-lg .caret { + border-width: 0 5px 5px; +} +.btn-group-vertical > .btn, +.btn-group-vertical > .btn-group, +.btn-group-vertical > .btn-group > .btn { + display: block; + float: none; + width: 100%; + max-width: 100%; +} +.btn-group-vertical > .btn-group > .btn { + float: none; +} +.btn-group-vertical > .btn + .btn, +.btn-group-vertical > .btn + .btn-group, +.btn-group-vertical > .btn-group + .btn, +.btn-group-vertical > .btn-group + .btn-group { + margin-top: -1px; + margin-left: 0; +} +.btn-group-vertical > .btn:not(:first-child):not(:last-child) { + border-radius: 0; +} +.btn-group-vertical > .btn:first-child:not(:last-child) { + border-top-right-radius: 4px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} +.btn-group-vertical > .btn:last-child:not(:first-child) { + border-bottom-left-radius: 4px; + border-top-right-radius: 0; + border-top-left-radius: 0; +} +.btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn { + border-radius: 0; +} +.btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child, +.btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle { + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} +.btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child { + border-top-right-radius: 0; + border-top-left-radius: 0; +} +.btn-group-justified { + display: table; + width: 100%; + table-layout: fixed; + border-collapse: separate; +} +.btn-group-justified > .btn, +.btn-group-justified > .btn-group { + float: none; + display: table-cell; + width: 1%; +} +.btn-group-justified > .btn-group .btn { + width: 100%; +} +.btn-group-justified > .btn-group .dropdown-menu { + left: auto; +} +[data-toggle="buttons"] > .btn input[type="radio"], +[data-toggle="buttons"] > .btn-group > .btn input[type="radio"], +[data-toggle="buttons"] > .btn input[type="checkbox"], +[data-toggle="buttons"] > .btn-group > .btn input[type="checkbox"] { + position: absolute; + clip: rect(0, 0, 0, 0); + pointer-events: none; +} +.input-group { + position: relative; + display: table; + border-collapse: separate; +} +.input-group[class*="col-"] { + float: none; + padding-left: 0; + padding-right: 0; +} +.input-group .form-control { + position: relative; + z-index: 2; + float: left; + width: 100%; + margin-bottom: 0; +} +.input-group-lg > .form-control, +.input-group-lg > .input-group-addon, +.input-group-lg > .input-group-btn > .btn { + height: 61px; + padding: 18px 27px; + font-size: 17px; + line-height: 1.33; + border-radius: 6px; +} +select.input-group-lg > .form-control, +select.input-group-lg > .input-group-addon, +select.input-group-lg > .input-group-btn > .btn { + height: 61px; + line-height: 61px; +} +textarea.input-group-lg > .form-control, +textarea.input-group-lg > .input-group-addon, +textarea.input-group-lg > .input-group-btn > .btn, +select[multiple].input-group-lg > .form-control, +select[multiple].input-group-lg > .input-group-addon, +select[multiple].input-group-lg > .input-group-btn > .btn { + height: auto; +} +.input-group-sm > .form-control, +.input-group-sm > .input-group-addon, +.input-group-sm > .input-group-btn > .btn { + height: 32px; + padding: 6px 9px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +select.input-group-sm > .form-control, +select.input-group-sm > .input-group-addon, +select.input-group-sm > .input-group-btn > .btn { + height: 32px; + line-height: 32px; +} +textarea.input-group-sm > .form-control, +textarea.input-group-sm > .input-group-addon, +textarea.input-group-sm > .input-group-btn > .btn, +select[multiple].input-group-sm > .form-control, +select[multiple].input-group-sm > .input-group-addon, +select[multiple].input-group-sm > .input-group-btn > .btn { + height: auto; +} +.input-group-addon, +.input-group-btn, +.input-group .form-control { + display: table-cell; +} +.input-group-addon:not(:first-child):not(:last-child), +.input-group-btn:not(:first-child):not(:last-child), +.input-group .form-control:not(:first-child):not(:last-child) { + border-radius: 0; +} +.input-group-addon, +.input-group-btn { + width: 1%; + white-space: nowrap; + vertical-align: middle; +} +.input-group-addon { + padding: 5px 15px; + font-size: 13px; + font-weight: normal; + line-height: 1; + color: #444444; + text-align: center; + background-color: #ecf0f1; + border: 1px solid #ecf0f1; + border-radius: 4px; +} +.input-group-addon.input-sm { + padding: 6px 9px; + font-size: 12px; + border-radius: 3px; +} +.input-group-addon.input-lg { + padding: 18px 27px; + font-size: 17px; + border-radius: 6px; +} +.input-group-addon input[type="radio"], +.input-group-addon input[type="checkbox"] { + margin-top: 0; +} +.input-group .form-control:first-child, +.input-group-addon:first-child, +.input-group-btn:first-child > .btn, +.input-group-btn:first-child > .btn-group > .btn, +.input-group-btn:first-child > .dropdown-toggle, +.input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle), +.input-group-btn:last-child > .btn-group:not(:last-child) > .btn { + border-bottom-right-radius: 0; + border-top-right-radius: 0; +} +.input-group-addon:first-child { + border-right: 0; +} +.input-group .form-control:last-child, +.input-group-addon:last-child, +.input-group-btn:last-child > .btn, +.input-group-btn:last-child > .btn-group > .btn, +.input-group-btn:last-child > .dropdown-toggle, +.input-group-btn:first-child > .btn:not(:first-child), +.input-group-btn:first-child > .btn-group:not(:first-child) > .btn { + border-bottom-left-radius: 0; + border-top-left-radius: 0; +} +.input-group-addon:last-child { + border-left: 0; +} +.input-group-btn { + position: relative; + font-size: 0; + white-space: nowrap; +} +.input-group-btn > .btn { + position: relative; +} +.input-group-btn > .btn + .btn { + margin-left: -1px; +} +.input-group-btn > .btn:hover, +.input-group-btn > .btn:focus, +.input-group-btn > .btn:active { + z-index: 2; +} +.input-group-btn:first-child > .btn, +.input-group-btn:first-child > .btn-group { + margin-right: -1px; +} +.input-group-btn:last-child > .btn, +.input-group-btn:last-child > .btn-group { + z-index: 2; + margin-left: -1px; +} +.nav { + margin-bottom: 0; + padding-left: 0; + list-style: none; +} +.nav > li { + position: relative; + display: block; +} +.nav > li > a { + position: relative; + display: block; + padding: 10px 15px; +} +.nav > li > a:hover, +.nav > li > a:focus { + text-decoration: none; + background-color: #ecf0f1; +} +.nav > li.disabled > a { + color: #b4bcc2; +} +.nav > li.disabled > a:hover, +.nav > li.disabled > a:focus { + color: #b4bcc2; + text-decoration: none; + background-color: transparent; + cursor: not-allowed; +} +.nav .open > a, +.nav .open > a:hover, +.nav .open > a:focus { + background-color: #ecf0f1; + border-color: #1f6b7a; +} +.nav .nav-divider { + height: 1px; + margin: 8px 0; + overflow: hidden; + background-color: #e5e5e5; +} +.nav > li > a > img { + max-width: none; +} +.nav-tabs { + border-bottom: 1px solid #ecf0f1; +} +.nav-tabs > li { + float: left; + margin-bottom: -1px; +} +.nav-tabs > li > a { + margin-right: 2px; + line-height: 1.42857143; + border: 1px solid transparent; + border-radius: 4px 4px 0 0; +} +.nav-tabs > li > a:hover { + border-color: #ecf0f1 #ecf0f1 #ecf0f1; +} +.nav-tabs > li.active > a, +.nav-tabs > li.active > a:hover, +.nav-tabs > li.active > a:focus { + color: #444444; + background-color: #ffffff; + border: 1px solid #ecf0f1; + border-bottom-color: transparent; + cursor: default; +} +.nav-tabs.nav-justified { + width: 100%; + border-bottom: 0; +} +.nav-tabs.nav-justified > li { + float: none; +} +.nav-tabs.nav-justified > li > a { + text-align: center; + margin-bottom: 5px; +} +.nav-tabs.nav-justified > .dropdown .dropdown-menu { + top: auto; + left: auto; +} +@media (min-width: 768px) { + .nav-tabs.nav-justified > li { + display: table-cell; + width: 1%; + } + .nav-tabs.nav-justified > li > a { + margin-bottom: 0; + } +} +.nav-tabs.nav-justified > li > a { + margin-right: 0; + border-radius: 4px; +} +.nav-tabs.nav-justified > .active > a, +.nav-tabs.nav-justified > .active > a:hover, +.nav-tabs.nav-justified > .active > a:focus { + border: 1px solid #ecf0f1; +} +@media (min-width: 768px) { + .nav-tabs.nav-justified > li > a { + border-bottom: 1px solid #ecf0f1; + border-radius: 4px 4px 0 0; + } + .nav-tabs.nav-justified > .active > a, + .nav-tabs.nav-justified > .active > a:hover, + .nav-tabs.nav-justified > .active > a:focus { + border-bottom-color: #ffffff; + } +} +.nav-pills > li { + float: left; +} +.nav-pills > li > a { + border-radius: 4px; +} +.nav-pills > li + li { + margin-left: 2px; +} +.nav-pills > li.active > a, +.nav-pills > li.active > a:hover, +.nav-pills > li.active > a:focus { + color: #ffffff; + background-color: #444444; +} +.nav-stacked > li { + float: none; +} +.nav-stacked > li + li { + margin-top: 2px; + margin-left: 0; +} +.nav-justified { + width: 100%; +} +.nav-justified > li { + float: none; +} +.nav-justified > li > a { + text-align: center; + margin-bottom: 5px; +} +.nav-justified > .dropdown .dropdown-menu { + top: auto; + left: auto; +} +@media (min-width: 768px) { + .nav-justified > li { + display: table-cell; + width: 1%; + } + .nav-justified > li > a { + margin-bottom: 0; + } +} +.nav-tabs-justified { + border-bottom: 0; +} +.nav-tabs-justified > li > a { + margin-right: 0; + border-radius: 4px; +} +.nav-tabs-justified > .active > a, +.nav-tabs-justified > .active > a:hover, +.nav-tabs-justified > .active > a:focus { + border: 1px solid #ecf0f1; +} +@media (min-width: 768px) { + .nav-tabs-justified > li > a { + border-bottom: 1px solid #ecf0f1; + border-radius: 4px 4px 0 0; + } + .nav-tabs-justified > .active > a, + .nav-tabs-justified > .active > a:hover, + .nav-tabs-justified > .active > a:focus { + border-bottom-color: #ffffff; + } +} +.tab-content > .tab-pane { + display: none; +} +.tab-content > .active { + display: block; +} +.nav-tabs .dropdown-menu { + margin-top: -1px; + border-top-right-radius: 0; + border-top-left-radius: 0; +} +.navbar { + position: relative; + min-height: 45px; + margin-bottom: 0px; + border: 1px solid transparent; +} +@media (min-width: 768px) { + .navbar { + border-radius: 4px; + } +} +@media (min-width: 768px) { + .navbar-header { + float: left; + } +} +.navbar-collapse { + overflow-x: visible; + padding-right: 15px; + padding-left: 15px; + border-top: 1px solid transparent; + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1); + -webkit-overflow-scrolling: touch; +} +.navbar-collapse.in { + overflow-y: auto; +} +@media (min-width: 768px) { + .navbar-collapse { + width: auto; + border-top: 0; + box-shadow: none; + } + .navbar-collapse.collapse { + display: block !important; + height: auto !important; + padding-bottom: 0; + overflow: visible !important; + } + .navbar-collapse.in { + overflow-y: visible; + } + .navbar-fixed-top .navbar-collapse, + .navbar-static-top .navbar-collapse, + .navbar-fixed-bottom .navbar-collapse { + padding-left: 0; + padding-right: 0; + } +} +.navbar-fixed-top .navbar-collapse, +.navbar-fixed-bottom .navbar-collapse { + max-height: 340px; +} +@media (max-device-width: 480px) and (orientation: landscape) { + .navbar-fixed-top .navbar-collapse, + .navbar-fixed-bottom .navbar-collapse { + max-height: 200px; + } +} +.container > .navbar-header, +.container-fluid > .navbar-header, +.container > .navbar-collapse, +.container-fluid > .navbar-collapse { + margin-right: -15px; + margin-left: -15px; +} +@media (min-width: 768px) { + .container > .navbar-header, + .container-fluid > .navbar-header, + .container > .navbar-collapse, + .container-fluid > .navbar-collapse { + margin-right: 0; + margin-left: 0; + } +} +.navbar-static-top { + z-index: 1000; + border-width: 0 0 1px; +} +@media (min-width: 768px) { + .navbar-static-top { + border-radius: 0; + } +} +.navbar-fixed-top, +.navbar-fixed-bottom { + position: fixed; + right: 0; + left: 0; + z-index: 1050; +} +@media (min-width: 768px) { + .navbar-fixed-top, + .navbar-fixed-bottom { + border-radius: 0; + } +} +.navbar-fixed-top { + top: 0; + border-width: 0 0 1px; +} +.navbar-fixed-bottom { + bottom: 0; + margin-bottom: 0; + border-width: 1px 0 0; +} +.navbar-brand { + float: left; + padding: 13.5px 15px; + font-size: 17px; + line-height: 18px; + height: 45px; +} +.navbar-brand:hover, +.navbar-brand:focus { + text-decoration: none; +} +.navbar-brand > img { + display: block; +} +@media (min-width: 768px) { + .navbar > .container .navbar-brand, + .navbar > .container-fluid .navbar-brand { + margin-left: -15px; + } +} +.navbar-toggle { + position: relative; + float: right; + margin-right: 15px; + padding: 9px 10px; + margin-top: 5.5px; + margin-bottom: 5.5px; + background-color: transparent; + background-image: none; + border: 1px solid transparent; + border-radius: 4px; +} +.navbar-toggle:focus { + outline: 0; +} +.navbar-toggle .icon-bar { + display: block; + width: 22px; + height: 2px; + border-radius: 1px; +} +.navbar-toggle .icon-bar + .icon-bar { + margin-top: 4px; +} +@media (min-width: 768px) { + .navbar-toggle { + display: none; + } +} +.navbar-nav { + margin: 6.75px -15px; +} +.navbar-nav > li > a { + padding-top: 10px; + padding-bottom: 10px; + line-height: 18px; +} +@media (max-width: 767px) { + .navbar-nav .open .dropdown-menu { + position: static; + float: none; + width: auto; + margin-top: 0; + background-color: transparent; + border: 0; + box-shadow: none; + } + .navbar-nav .open .dropdown-menu > li > a, + .navbar-nav .open .dropdown-menu .dropdown-header { + padding: 5px 15px 5px 25px; + } + .navbar-nav .open .dropdown-menu > li > a { + line-height: 18px; + } + .navbar-nav .open .dropdown-menu > li > a:hover, + .navbar-nav .open .dropdown-menu > li > a:focus { + background-image: none; + } +} +@media (min-width: 768px) { + .navbar-nav { + float: left; + margin: 0; + } + .navbar-nav > li { + float: left; + } + .navbar-nav > li > a { + padding-top: 13.5px; + padding-bottom: 13.5px; + } +} +.navbar-form { + margin-left: -15px; + margin-right: -15px; + padding: 10px 15px; + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1); + margin-top: 7.5px; + margin-bottom: 7.5px; +} +@media (min-width: 768px) { + .navbar-form .form-group { + display: inline-block; + margin-bottom: 0; + vertical-align: middle; + } + .navbar-form .form-control { + display: inline-block; + width: auto; + vertical-align: middle; + } + .navbar-form .form-control-static { + display: inline-block; + } + .navbar-form .input-group { + display: inline-table; + vertical-align: middle; + } + .navbar-form .input-group .input-group-addon, + .navbar-form .input-group .input-group-btn, + .navbar-form .input-group .form-control { + width: auto; + } + .navbar-form .input-group > .form-control { + width: 100%; + } + .navbar-form .control-label { + margin-bottom: 0; + vertical-align: middle; + } + .navbar-form .radio, + .navbar-form .checkbox { + display: inline-block; + margin-top: 0; + margin-bottom: 0; + vertical-align: middle; + } + .navbar-form .radio label, + .navbar-form .checkbox label { + padding-left: 0; + } + .navbar-form .radio input[type="radio"], + .navbar-form .checkbox input[type="checkbox"] { + position: relative; + margin-left: 0; + } + .navbar-form .has-feedback .form-control-feedback { + top: 0; + } +} +@media (max-width: 767px) { + .navbar-form .form-group { + margin-bottom: 5px; + } + .navbar-form .form-group:last-child { + margin-bottom: 0; + } +} +@media (min-width: 768px) { + .navbar-form { + width: auto; + border: 0; + margin-left: 0; + margin-right: 0; + padding-top: 0; + padding-bottom: 0; + box-shadow: none; + } +} +.navbar-nav > li > .dropdown-menu { + margin-top: 0; + border-top-right-radius: 0; + border-top-left-radius: 0; +} +.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu { + margin-bottom: 0; + border-top-right-radius: 4px; + border-top-left-radius: 4px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} +.navbar-btn { + margin-top: 7.5px; + margin-bottom: 7.5px; +} +.navbar-btn.btn-sm { + margin-top: 6.5px; + margin-bottom: 6.5px; +} +.navbar-btn.btn-xs { + margin-top: 11.5px; + margin-bottom: 11.5px; +} +.navbar-text { + margin-top: 13.5px; + margin-bottom: 13.5px; +} +@media (min-width: 768px) { + .navbar-text { + float: left; + margin-left: 15px; + margin-right: 15px; + } +} +@media (min-width: 768px) { + .navbar-left { + float: left !important; + float: left; + } + .navbar-right { + float: right !important; + float: right; + margin-right: -15px; + } + .navbar-right ~ .navbar-right { + margin-right: 0; + } +} +.navbar-default { + background-color: #656a76; + border-color: #4d515b; +} +.navbar-default .navbar-brand { + color: #ecf0f1; +} +.navbar-default .navbar-brand:hover, +.navbar-default .navbar-brand:focus { + color: #ffffff; + background-color: transparent; +} +.navbar-default .navbar-text { + color: #ffffff; +} +.navbar-default .navbar-nav > li > a { + color: #ecf0f1; +} +.navbar-default .navbar-nav > li > a:hover, +.navbar-default .navbar-nav > li > a:focus { + color: #ffffff; + background-color: transparent; +} +.navbar-default .navbar-nav > .active > a, +.navbar-default .navbar-nav > .active > a:hover, +.navbar-default .navbar-nav > .active > a:focus { + color: #ffffff; + background-color: #4d515b; +} +.navbar-default .navbar-nav > .disabled > a, +.navbar-default .navbar-nav > .disabled > a:hover, +.navbar-default .navbar-nav > .disabled > a:focus { + color: #cccccc; + background-color: transparent; +} +.navbar-default .navbar-toggle { + border-color: #4d515b; +} +.navbar-default .navbar-toggle:hover, +.navbar-default .navbar-toggle:focus { + background-color: #4d515b; +} +.navbar-default .navbar-toggle .icon-bar { + background-color: #ffffff; +} +.navbar-default .navbar-collapse, +.navbar-default .navbar-form { + border-color: #4d515b; +} +.navbar-default .navbar-nav > .open > a, +.navbar-default .navbar-nav > .open > a:hover, +.navbar-default .navbar-nav > .open > a:focus { + background-color: #4d515b; + color: #ffffff; +} +@media (max-width: 767px) { + .navbar-default .navbar-nav .open .dropdown-menu > li > a { + color: #ecf0f1; + } + .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover, + .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus { + color: #ffffff; + background-color: transparent; + } + .navbar-default .navbar-nav .open .dropdown-menu > .active > a, + .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover, + .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus { + color: #ffffff; + background-color: #4d515b; + } + .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a, + .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover, + .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus { + color: #cccccc; + background-color: transparent; + } +} +.navbar-default .navbar-link { + color: #ecf0f1; +} +.navbar-default .navbar-link:hover { + color: #ffffff; +} +.navbar-default .btn-link { + color: #ecf0f1; +} +.navbar-default .btn-link:hover, +.navbar-default .btn-link:focus { + color: #ffffff; +} +.navbar-default .btn-link[disabled]:hover, +fieldset[disabled] .navbar-default .btn-link:hover, +.navbar-default .btn-link[disabled]:focus, +fieldset[disabled] .navbar-default .btn-link:focus { + color: #cccccc; +} +.navbar-inverse { + background-color: #222222; + border-color: #080808; +} +.navbar-inverse .navbar-brand { + color: #ffffff; +} +.navbar-inverse .navbar-brand:hover, +.navbar-inverse .navbar-brand:focus { + color: #ffffff; + background-color: #3c3c3c; +} +.navbar-inverse .navbar-text { + color: #ffffff; +} +.navbar-inverse .navbar-nav > li > a { + color: #ecf0f1; +} +.navbar-inverse .navbar-nav > li > a:hover, +.navbar-inverse .navbar-nav > li > a:focus { + color: #ffffff; + background-color: #555555; +} +.navbar-inverse .navbar-nav > .active > a, +.navbar-inverse .navbar-nav > .active > a:hover, +.navbar-inverse .navbar-nav > .active > a:focus { + color: #ffffff; + background-color: #41454c; +} +.navbar-inverse .navbar-nav > .disabled > a, +.navbar-inverse .navbar-nav > .disabled > a:hover, +.navbar-inverse .navbar-nav > .disabled > a:focus { + color: #b4bcc2; + background-color: transparent; +} +.navbar-inverse .navbar-toggle { + border-color: #080808; +} +.navbar-inverse .navbar-toggle:hover, +.navbar-inverse .navbar-toggle:focus { + background-color: #080808; +} +.navbar-inverse .navbar-toggle .icon-bar { + background-color: #ffffff; +} +.navbar-inverse .navbar-collapse, +.navbar-inverse .navbar-form { + border-color: #101010; +} +.navbar-inverse .navbar-nav > .open > a, +.navbar-inverse .navbar-nav > .open > a:hover, +.navbar-inverse .navbar-nav > .open > a:focus { + background-color: #41454c; + color: #ffffff; +} +@media (max-width: 767px) { + .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header { + border-color: #080808; + } + .navbar-inverse .navbar-nav .open .dropdown-menu .divider { + background-color: #080808; + } + .navbar-inverse .navbar-nav .open .dropdown-menu > li > a { + color: #ecf0f1; + } + .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover, + .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus { + color: #ffffff; + background-color: #555555; + } + .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a, + .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover, + .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus { + color: #ffffff; + background-color: #41454c; + } + .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a, + .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover, + .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus { + color: #b4bcc2; + background-color: transparent; + } +} +.navbar-inverse .navbar-link { + color: #ecf0f1; +} +.navbar-inverse .navbar-link:hover { + color: #ffffff; +} +.navbar-inverse .btn-link { + color: #ecf0f1; +} +.navbar-inverse .btn-link:hover, +.navbar-inverse .btn-link:focus { + color: #ffffff; +} +.navbar-inverse .btn-link[disabled]:hover, +fieldset[disabled] .navbar-inverse .btn-link:hover, +.navbar-inverse .btn-link[disabled]:focus, +fieldset[disabled] .navbar-inverse .btn-link:focus { + color: #b4bcc2; +} +.breadcrumb { + padding: 8px 15px; + margin-bottom: 18px; + list-style: none; + background-color: #ecf0f1; + border-radius: 4px; +} +.breadcrumb > li { + display: inline-block; +} +.breadcrumb > li + li:before { + content: "/\A0"; + padding: 0 5px; + color: #cccccc; +} +.breadcrumb > .active { + color: #95a5a6; +} +.pagination { + display: inline-block; + padding-left: 0; + margin: 18px 0; + border-radius: 4px; +} +.pagination > li { + display: inline; +} +.pagination > li > a, +.pagination > li > span { + position: relative; + float: left; + padding: 5px 15px; + line-height: 1.42857143; + text-decoration: none; + color: #1f6b7a; + background-color: transparent; + border: 1px solid transparent; + margin-left: -1px; +} +.pagination > li:first-child > a, +.pagination > li:first-child > span { + margin-left: 0; + border-bottom-left-radius: 4px; + border-top-left-radius: 4px; +} +.pagination > li:last-child > a, +.pagination > li:last-child > span { + border-bottom-right-radius: 4px; + border-top-right-radius: 4px; +} +.pagination > li > a:hover, +.pagination > li > span:hover, +.pagination > li > a:focus, +.pagination > li > span:focus { + z-index: 3; + color: #1f6b7a; + background-color: rgba(0, 0, 0, 0); + border-color: transparent; +} +.pagination > .active > a, +.pagination > .active > span, +.pagination > .active > a:hover, +.pagination > .active > span:hover, +.pagination > .active > a:focus, +.pagination > .active > span:focus { + z-index: 2; + color: #444444; + background-color: rgba(0, 0, 0, 0); + border-color: transparent; + cursor: default; +} +.pagination > .disabled > span, +.pagination > .disabled > span:hover, +.pagination > .disabled > span:focus, +.pagination > .disabled > a, +.pagination > .disabled > a:hover, +.pagination > .disabled > a:focus { + color: #222222; + background-color: rgba(38, 38, 38, 0); + border-color: transparent; + cursor: not-allowed; +} +.pagination-lg > li > a, +.pagination-lg > li > span { + padding: 18px 27px; + font-size: 17px; + line-height: 1.33; +} +.pagination-lg > li:first-child > a, +.pagination-lg > li:first-child > span { + border-bottom-left-radius: 6px; + border-top-left-radius: 6px; +} +.pagination-lg > li:last-child > a, +.pagination-lg > li:last-child > span { + border-bottom-right-radius: 6px; + border-top-right-radius: 6px; +} +.pagination-sm > li > a, +.pagination-sm > li > span { + padding: 6px 9px; + font-size: 12px; + line-height: 1.5; +} +.pagination-sm > li:first-child > a, +.pagination-sm > li:first-child > span { + border-bottom-left-radius: 3px; + border-top-left-radius: 3px; +} +.pagination-sm > li:last-child > a, +.pagination-sm > li:last-child > span { + border-bottom-right-radius: 3px; + border-top-right-radius: 3px; +} +.pager { + padding-left: 0; + margin: 18px 0; + list-style: none; + text-align: center; +} +.pager li { + display: inline; +} +.pager li > a, +.pager li > span { + display: inline-block; + padding: 5px 14px; + background-color: transparent; + border: 1px solid transparent; + border-radius: 0px; +} +.pager li > a:hover, +.pager li > a:focus { + text-decoration: none; + background-color: rgba(0, 0, 0, 0); +} +.pager .next > a, +.pager .next > span { + float: right; +} +.pager .previous > a, +.pager .previous > span { + float: left; +} +.pager .disabled > a, +.pager .disabled > a:hover, +.pager .disabled > a:focus, +.pager .disabled > span { + color: #ffffff; + background-color: transparent; + cursor: not-allowed; +} +.label { + display: inline; + padding: .2em .6em .3em; + font-size: 75%; + font-weight: bold; + line-height: 1; + color: #ffffff; + text-align: center; + white-space: nowrap; + vertical-align: baseline; + border-radius: .25em; +} +a.label:hover, +a.label:focus { + color: #ffffff; + text-decoration: none; + cursor: pointer; +} +.label:empty { + display: none; +} +.btn .label { + position: relative; + top: -1px; +} +.label-default { + background-color: #95a5a6; +} +.label-default[href]:hover, +.label-default[href]:focus { + background-color: #798d8f; +} +.label-primary { + background-color: #444444; +} +.label-primary[href]:hover, +.label-primary[href]:focus { + background-color: #2b2b2b; +} +.label-success { + background-color: #31c471; +} +.label-success[href]:hover, +.label-success[href]:focus { + background-color: #279b59; +} +.label-info { + background-color: #1f6b7a; +} +.label-info[href]:hover, +.label-info[href]:focus { + background-color: #154751; +} +.label-warning { + background-color: #f39c12; +} +.label-warning[href]:hover, +.label-warning[href]:focus { + background-color: #c87f0a; +} +.label-danger { + background-color: #e74c3c; +} +.label-danger[href]:hover, +.label-danger[href]:focus { + background-color: #d62c1a; +} +.badge { + display: inline-block; + min-width: 10px; + padding: 3px 7px; + font-size: 12px; + font-weight: bold; + color: #ffffff; + line-height: 1; + vertical-align: middle; + white-space: nowrap; + text-align: center; + background-color: #444444; + border-radius: 10px; +} +.badge:empty { + display: none; +} +.btn .badge { + position: relative; + top: -1px; +} +.btn-xs .badge, +.btn-group-xs > .btn .badge { + top: 0; + padding: 1px 5px; +} +a.badge:hover, +a.badge:focus { + color: #ffffff; + text-decoration: none; + cursor: pointer; +} +.list-group-item.active > .badge, +.nav-pills > .active > a > .badge { + color: #444444; + background-color: #ffffff; +} +.list-group-item > .badge { + float: right; +} +.list-group-item > .badge + .badge { + margin-right: 5px; +} +.nav-pills > li > a > .badge { + margin-left: 3px; +} +.jumbotron { + padding-top: 30px; + padding-bottom: 30px; + margin-bottom: 30px; + color: inherit; + background-color: #ecf0f1; +} +.jumbotron h1, +.jumbotron .h1 { + color: inherit; +} +.jumbotron p { + margin-bottom: 15px; + font-size: 20px; + font-weight: 200; +} +.jumbotron > hr { + border-top-color: #cfd9db; +} +.container .jumbotron, +.container-fluid .jumbotron { + border-radius: 6px; +} +.jumbotron .container { + max-width: 100%; +} +@media screen and (min-width: 768px) { + .jumbotron { + padding-top: 48px; + padding-bottom: 48px; + } + .container .jumbotron, + .container-fluid .jumbotron { + padding-left: 60px; + padding-right: 60px; + } + .jumbotron h1, + .jumbotron .h1 { + font-size: 59px; + } +} +.thumbnail { + display: block; + padding: 4px; + margin-bottom: 18px; + line-height: 1.42857143; + background-color: #ffffff; + border: 1px solid #ecf0f1; + border-radius: 4px; + -webkit-transition: border 0.2s ease-in-out; + transition: border 0.2s ease-in-out; +} +.thumbnail > img, +.thumbnail a > img { + margin-left: auto; + margin-right: auto; +} +a.thumbnail:hover, +a.thumbnail:focus, +a.thumbnail.active { + border-color: #1f6b7a; +} +.thumbnail .caption { + padding: 9px; + color: #444444; +} +.alert { + padding: 15px; + margin-bottom: 18px; + border: 1px solid transparent; + border-radius: 4px; +} +.alert h4 { + margin-top: 0; + color: inherit; +} +.alert .alert-link { + font-weight: bold; +} +.alert > p, +.alert > ul { + margin-bottom: 0; +} +.alert > p + p { + margin-top: 5px; +} +.alert-dismissable, +.alert-dismissible { + padding-right: 35px; +} +.alert-dismissable .close, +.alert-dismissible .close { + position: relative; + top: -2px; + right: -21px; + color: inherit; +} +.alert-success { + background-color: #31c471; + border-color: #279b59; + color: #ffffff; +} +.alert-success hr { + border-top-color: #22874e; +} +.alert-success .alert-link { + color: #e6e6e6; +} +.alert-info { + background-color: #1f6b7a; + border-color: #154751; + color: #ffffff; +} +.alert-info hr { + border-top-color: #0f353d; +} +.alert-info .alert-link { + color: #e6e6e6; +} +.alert-warning { + background-color: #f39c12; + border-color: #c87f0a; + color: #ffffff; +} +.alert-warning hr { + border-top-color: #b06f09; +} +.alert-warning .alert-link { + color: #e6e6e6; +} +.alert-danger { + background-color: #e74c3c; + border-color: #d62c1a; + color: #ffffff; +} +.alert-danger hr { + border-top-color: #bf2718; +} +.alert-danger .alert-link { + color: #e6e6e6; +} +@-webkit-keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} +@keyframes progress-bar-stripes { + from { + background-position: 40px 0; + } + to { + background-position: 0 0; + } +} +.progress { + overflow: hidden; + height: 18px; + margin-bottom: 18px; + background-color: #ecf0f1; + border-radius: 4px; + box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); +} +.progress-bar { + float: left; + width: 0%; + height: 100%; + font-size: 12px; + line-height: 18px; + color: #ffffff; + text-align: center; + background-color: #444444; + box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); + -webkit-transition: width 0.6s ease; + transition: width 0.6s ease; +} +.progress-striped .progress-bar, +.progress-bar-striped { + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-size: 40px 40px; +} +.progress.active .progress-bar, +.progress-bar.active { + -webkit-animation: progress-bar-stripes 2s linear infinite; + animation: progress-bar-stripes 2s linear infinite; +} +.progress-bar-success { + background-color: #31c471; +} +.progress-striped .progress-bar-success { + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} +.progress-bar-info { + background-color: #1f6b7a; +} +.progress-striped .progress-bar-info { + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} +.progress-bar-warning { + background-color: #f39c12; +} +.progress-striped .progress-bar-warning { + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} +.progress-bar-danger { + background-color: #e74c3c; +} +.progress-striped .progress-bar-danger { + background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); + background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); +} +.media { + margin-top: 15px; +} +.media:first-child { + margin-top: 0; +} +.media, +.media-body { + zoom: 1; + overflow: hidden; +} +.media-body { + width: 10000px; +} +.media-object { + display: block; +} +.media-object.img-thumbnail { + max-width: none; +} +.media-right, +.media > .pull-right { + padding-left: 10px; +} +.media-left, +.media > .pull-left { + padding-right: 10px; +} +.media-left, +.media-right, +.media-body { + display: table-cell; + vertical-align: top; +} +.media-middle { + vertical-align: middle; +} +.media-bottom { + vertical-align: bottom; +} +.media-heading { + margin-top: 0; + margin-bottom: 5px; +} +.media-list { + padding-left: 0; + list-style: none; +} +.list-group { + margin-bottom: 20px; + padding-left: 0; +} +.list-group-item { + position: relative; + display: block; + padding: 10px 15px; + margin-bottom: -1px; + background-color: #ffffff; + border: 1px solid #dddddd; +} +.list-group-item:first-child { + border-top-right-radius: 4px; + border-top-left-radius: 4px; +} +.list-group-item:last-child { + margin-bottom: 0; + border-bottom-right-radius: 4px; + border-bottom-left-radius: 4px; +} +a.list-group-item, +button.list-group-item { + color: #555555; +} +a.list-group-item .list-group-item-heading, +button.list-group-item .list-group-item-heading { + color: #333333; +} +a.list-group-item:hover, +button.list-group-item:hover, +a.list-group-item:focus, +button.list-group-item:focus { + text-decoration: none; + color: #555555; + background-color: #f5f5f5; +} +button.list-group-item { + width: 100%; + text-align: left; +} +.list-group-item.disabled, +.list-group-item.disabled:hover, +.list-group-item.disabled:focus { + background-color: #ecf0f1; + color: #b4bcc2; + cursor: not-allowed; +} +.list-group-item.disabled .list-group-item-heading, +.list-group-item.disabled:hover .list-group-item-heading, +.list-group-item.disabled:focus .list-group-item-heading { + color: inherit; +} +.list-group-item.disabled .list-group-item-text, +.list-group-item.disabled:hover .list-group-item-text, +.list-group-item.disabled:focus .list-group-item-text { + color: #b4bcc2; +} +.list-group-item.active, +.list-group-item.active:hover, +.list-group-item.active:focus { + z-index: 2; + color: #444444; + background-color: #444444; + border-color: #444444; +} +.list-group-item.active .list-group-item-heading, +.list-group-item.active:hover .list-group-item-heading, +.list-group-item.active:focus .list-group-item-heading, +.list-group-item.active .list-group-item-heading > small, +.list-group-item.active:hover .list-group-item-heading > small, +.list-group-item.active:focus .list-group-item-heading > small, +.list-group-item.active .list-group-item-heading > .small, +.list-group-item.active:hover .list-group-item-heading > .small, +.list-group-item.active:focus .list-group-item-heading > .small { + color: inherit; +} +.list-group-item.active .list-group-item-text, +.list-group-item.active:hover .list-group-item-text, +.list-group-item.active:focus .list-group-item-text { + color: #aaaaaa; +} +.list-group-item-success { + color: #ffffff; + background-color: #31c471; +} +a.list-group-item-success, +button.list-group-item-success { + color: #ffffff; +} +a.list-group-item-success .list-group-item-heading, +button.list-group-item-success .list-group-item-heading { + color: inherit; +} +a.list-group-item-success:hover, +button.list-group-item-success:hover, +a.list-group-item-success:focus, +button.list-group-item-success:focus { + color: #ffffff; + background-color: #2cb065; +} +a.list-group-item-success.active, +button.list-group-item-success.active, +a.list-group-item-success.active:hover, +button.list-group-item-success.active:hover, +a.list-group-item-success.active:focus, +button.list-group-item-success.active:focus { + color: #fff; + background-color: #ffffff; + border-color: #ffffff; +} +.list-group-item-info { + color: #ffffff; + background-color: #1f6b7a; +} +a.list-group-item-info, +button.list-group-item-info { + color: #ffffff; +} +a.list-group-item-info .list-group-item-heading, +button.list-group-item-info .list-group-item-heading { + color: inherit; +} +a.list-group-item-info:hover, +button.list-group-item-info:hover, +a.list-group-item-info:focus, +button.list-group-item-info:focus { + color: #ffffff; + background-color: #1a5966; +} +a.list-group-item-info.active, +button.list-group-item-info.active, +a.list-group-item-info.active:hover, +button.list-group-item-info.active:hover, +a.list-group-item-info.active:focus, +button.list-group-item-info.active:focus { + color: #fff; + background-color: #ffffff; + border-color: #ffffff; +} +.list-group-item-warning { + color: #ffffff; + background-color: #f39c12; +} +a.list-group-item-warning, +button.list-group-item-warning { + color: #ffffff; +} +a.list-group-item-warning .list-group-item-heading, +button.list-group-item-warning .list-group-item-heading { + color: inherit; +} +a.list-group-item-warning:hover, +button.list-group-item-warning:hover, +a.list-group-item-warning:focus, +button.list-group-item-warning:focus { + color: #ffffff; + background-color: #e08e0b; +} +a.list-group-item-warning.active, +button.list-group-item-warning.active, +a.list-group-item-warning.active:hover, +button.list-group-item-warning.active:hover, +a.list-group-item-warning.active:focus, +button.list-group-item-warning.active:focus { + color: #fff; + background-color: #ffffff; + border-color: #ffffff; +} +.list-group-item-danger { + color: #ffffff; + background-color: #e74c3c; +} +a.list-group-item-danger, +button.list-group-item-danger { + color: #ffffff; +} +a.list-group-item-danger .list-group-item-heading, +button.list-group-item-danger .list-group-item-heading { + color: inherit; +} +a.list-group-item-danger:hover, +button.list-group-item-danger:hover, +a.list-group-item-danger:focus, +button.list-group-item-danger:focus { + color: #ffffff; + background-color: #e43725; +} +a.list-group-item-danger.active, +button.list-group-item-danger.active, +a.list-group-item-danger.active:hover, +button.list-group-item-danger.active:hover, +a.list-group-item-danger.active:focus, +button.list-group-item-danger.active:focus { + color: #fff; + background-color: #ffffff; + border-color: #ffffff; +} +.list-group-item-heading { + margin-top: 0; + margin-bottom: 5px; +} +.list-group-item-text { + margin-bottom: 0; + line-height: 1.3; +} +.panel { + margin-bottom: 18px; + background-color: #ffffff; + border: 1px solid transparent; + border-radius: 4px; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); +} +.panel-body { + padding: 15px; +} +.panel-heading { + padding: 10px 15px; + border-bottom: 1px solid transparent; + border-top-right-radius: 3px; + border-top-left-radius: 3px; +} +.panel-heading > .dropdown .dropdown-toggle { + color: inherit; +} +.panel-title { + margin-top: 0; + margin-bottom: 0; + font-size: 15px; + color: inherit; +} +.panel-title > a, +.panel-title > small, +.panel-title > .small, +.panel-title > small > a, +.panel-title > .small > a { + color: inherit; +} +.panel-footer { + padding: 10px 15px; + background-color: #f5f5f5; + border-top: 1px solid #dddddd; + border-bottom-right-radius: 3px; + border-bottom-left-radius: 3px; +} +.panel > .list-group, +.panel > .panel-collapse > .list-group { + margin-bottom: 0; +} +.panel > .list-group .list-group-item, +.panel > .panel-collapse > .list-group .list-group-item { + border-width: 1px 0; + border-radius: 0; +} +.panel > .list-group:first-child .list-group-item:first-child, +.panel > .panel-collapse > .list-group:first-child .list-group-item:first-child { + border-top: 0; + border-top-right-radius: 3px; + border-top-left-radius: 3px; +} +.panel > .list-group:last-child .list-group-item:last-child, +.panel > .panel-collapse > .list-group:last-child .list-group-item:last-child { + border-bottom: 0; + border-bottom-right-radius: 3px; + border-bottom-left-radius: 3px; +} +.panel > .panel-heading + .panel-collapse > .list-group .list-group-item:first-child { + border-top-right-radius: 0; + border-top-left-radius: 0; +} +.panel-heading + .list-group .list-group-item:first-child { + border-top-width: 0; +} +.list-group + .panel-footer { + border-top-width: 0; +} +.panel > .table, +.panel > .table-responsive > .table, +.panel > .panel-collapse > .table { + margin-bottom: 0; +} +.panel > .table caption, +.panel > .table-responsive > .table caption, +.panel > .panel-collapse > .table caption { + padding-left: 15px; + padding-right: 15px; +} +.panel > .table:first-child, +.panel > .table-responsive:first-child > .table:first-child { + border-top-right-radius: 3px; + border-top-left-radius: 3px; +} +.panel > .table:first-child > thead:first-child > tr:first-child, +.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child, +.panel > .table:first-child > tbody:first-child > tr:first-child, +.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child { + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} +.panel > .table:first-child > thead:first-child > tr:first-child td:first-child, +.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:first-child, +.panel > .table:first-child > tbody:first-child > tr:first-child td:first-child, +.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:first-child, +.panel > .table:first-child > thead:first-child > tr:first-child th:first-child, +.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:first-child, +.panel > .table:first-child > tbody:first-child > tr:first-child th:first-child, +.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:first-child { + border-top-left-radius: 3px; +} +.panel > .table:first-child > thead:first-child > tr:first-child td:last-child, +.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:last-child, +.panel > .table:first-child > tbody:first-child > tr:first-child td:last-child, +.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:last-child, +.panel > .table:first-child > thead:first-child > tr:first-child th:last-child, +.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:last-child, +.panel > .table:first-child > tbody:first-child > tr:first-child th:last-child, +.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:last-child { + border-top-right-radius: 3px; +} +.panel > .table:last-child, +.panel > .table-responsive:last-child > .table:last-child { + border-bottom-right-radius: 3px; + border-bottom-left-radius: 3px; +} +.panel > .table:last-child > tbody:last-child > tr:last-child, +.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child, +.panel > .table:last-child > tfoot:last-child > tr:last-child, +.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child { + border-bottom-left-radius: 3px; + border-bottom-right-radius: 3px; +} +.panel > .table:last-child > tbody:last-child > tr:last-child td:first-child, +.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:first-child, +.panel > .table:last-child > tfoot:last-child > tr:last-child td:first-child, +.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:first-child, +.panel > .table:last-child > tbody:last-child > tr:last-child th:first-child, +.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:first-child, +.panel > .table:last-child > tfoot:last-child > tr:last-child th:first-child, +.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:first-child { + border-bottom-left-radius: 3px; +} +.panel > .table:last-child > tbody:last-child > tr:last-child td:last-child, +.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:last-child, +.panel > .table:last-child > tfoot:last-child > tr:last-child td:last-child, +.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:last-child, +.panel > .table:last-child > tbody:last-child > tr:last-child th:last-child, +.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:last-child, +.panel > .table:last-child > tfoot:last-child > tr:last-child th:last-child, +.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:last-child { + border-bottom-right-radius: 3px; +} +.panel > .panel-body + .table, +.panel > .panel-body + .table-responsive, +.panel > .table + .panel-body, +.panel > .table-responsive + .panel-body { + border-top: 1px solid #ecf0f1; +} +.panel > .table > tbody:first-child > tr:first-child th, +.panel > .table > tbody:first-child > tr:first-child td { + border-top: 0; +} +.panel > .table-bordered, +.panel > .table-responsive > .table-bordered { + border: 0; +} +.panel > .table-bordered > thead > tr > th:first-child, +.panel > .table-responsive > .table-bordered > thead > tr > th:first-child, +.panel > .table-bordered > tbody > tr > th:first-child, +.panel > .table-responsive > .table-bordered > tbody > tr > th:first-child, +.panel > .table-bordered > tfoot > tr > th:first-child, +.panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child, +.panel > .table-bordered > thead > tr > td:first-child, +.panel > .table-responsive > .table-bordered > thead > tr > td:first-child, +.panel > .table-bordered > tbody > tr > td:first-child, +.panel > .table-responsive > .table-bordered > tbody > tr > td:first-child, +.panel > .table-bordered > tfoot > tr > td:first-child, +.panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child { + border-left: 0; +} +.panel > .table-bordered > thead > tr > th:last-child, +.panel > .table-responsive > .table-bordered > thead > tr > th:last-child, +.panel > .table-bordered > tbody > tr > th:last-child, +.panel > .table-responsive > .table-bordered > tbody > tr > th:last-child, +.panel > .table-bordered > tfoot > tr > th:last-child, +.panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child, +.panel > .table-bordered > thead > tr > td:last-child, +.panel > .table-responsive > .table-bordered > thead > tr > td:last-child, +.panel > .table-bordered > tbody > tr > td:last-child, +.panel > .table-responsive > .table-bordered > tbody > tr > td:last-child, +.panel > .table-bordered > tfoot > tr > td:last-child, +.panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child { + border-right: 0; +} +.panel > .table-bordered > thead > tr:first-child > td, +.panel > .table-responsive > .table-bordered > thead > tr:first-child > td, +.panel > .table-bordered > tbody > tr:first-child > td, +.panel > .table-responsive > .table-bordered > tbody > tr:first-child > td, +.panel > .table-bordered > thead > tr:first-child > th, +.panel > .table-responsive > .table-bordered > thead > tr:first-child > th, +.panel > .table-bordered > tbody > tr:first-child > th, +.panel > .table-responsive > .table-bordered > tbody > tr:first-child > th { + border-bottom: 0; +} +.panel > .table-bordered > tbody > tr:last-child > td, +.panel > .table-responsive > .table-bordered > tbody > tr:last-child > td, +.panel > .table-bordered > tfoot > tr:last-child > td, +.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td, +.panel > .table-bordered > tbody > tr:last-child > th, +.panel > .table-responsive > .table-bordered > tbody > tr:last-child > th, +.panel > .table-bordered > tfoot > tr:last-child > th, +.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th { + border-bottom: 0; +} +.panel > .table-responsive { + border: 0; + margin-bottom: 0; +} +.panel-group { + margin-bottom: 18px; +} +.panel-group .panel { + margin-bottom: 0; + border-radius: 4px; +} +.panel-group .panel + .panel { + margin-top: 5px; +} +.panel-group .panel-heading { + border-bottom: 0; +} +.panel-group .panel-heading + .panel-collapse > .panel-body, +.panel-group .panel-heading + .panel-collapse > .list-group { + border-top: 1px solid #dddddd; +} +.panel-group .panel-footer { + border-top: 0; +} +.panel-group .panel-footer + .panel-collapse .panel-body { + border-bottom: 1px solid #dddddd; +} +.panel-default { + border-color: #dddddd; +} +.panel-default > .panel-heading { + color: #7b8a8b; + background-color: #f5f5f5; + border-color: #dddddd; +} +.panel-default > .panel-heading + .panel-collapse > .panel-body { + border-top-color: #dddddd; +} +.panel-default > .panel-heading .badge { + color: #f5f5f5; + background-color: #7b8a8b; +} +.panel-default > .panel-footer + .panel-collapse > .panel-body { + border-bottom-color: #dddddd; +} +.panel-primary { + border-color: #444444; +} +.panel-primary > .panel-heading { + color: #ffffff; + background-color: #444444; + border-color: #444444; +} +.panel-primary > .panel-heading + .panel-collapse > .panel-body { + border-top-color: #444444; +} +.panel-primary > .panel-heading .badge { + color: #444444; + background-color: #ffffff; +} +.panel-primary > .panel-footer + .panel-collapse > .panel-body { + border-bottom-color: #444444; +} +.panel-success { + border-color: #279b59; +} +.panel-success > .panel-heading { + color: #ffffff; + background-color: #31c471; + border-color: #279b59; +} +.panel-success > .panel-heading + .panel-collapse > .panel-body { + border-top-color: #279b59; +} +.panel-success > .panel-heading .badge { + color: #31c471; + background-color: #ffffff; +} +.panel-success > .panel-footer + .panel-collapse > .panel-body { + border-bottom-color: #279b59; +} +.panel-info { + border-color: #154751; +} +.panel-info > .panel-heading { + color: #ffffff; + background-color: #1f6b7a; + border-color: #154751; +} +.panel-info > .panel-heading + .panel-collapse > .panel-body { + border-top-color: #154751; +} +.panel-info > .panel-heading .badge { + color: #1f6b7a; + background-color: #ffffff; +} +.panel-info > .panel-footer + .panel-collapse > .panel-body { + border-bottom-color: #154751; +} +.panel-warning { + border-color: #c87f0a; +} +.panel-warning > .panel-heading { + color: #ffffff; + background-color: #f39c12; + border-color: #c87f0a; +} +.panel-warning > .panel-heading + .panel-collapse > .panel-body { + border-top-color: #c87f0a; +} +.panel-warning > .panel-heading .badge { + color: #f39c12; + background-color: #ffffff; +} +.panel-warning > .panel-footer + .panel-collapse > .panel-body { + border-bottom-color: #c87f0a; +} +.panel-danger { + border-color: #d62c1a; +} +.panel-danger > .panel-heading { + color: #ffffff; + background-color: #e74c3c; + border-color: #d62c1a; +} +.panel-danger > .panel-heading + .panel-collapse > .panel-body { + border-top-color: #d62c1a; +} +.panel-danger > .panel-heading .badge { + color: #e74c3c; + background-color: #ffffff; +} +.panel-danger > .panel-footer + .panel-collapse > .panel-body { + border-bottom-color: #d62c1a; +} +.embed-responsive { + position: relative; + display: block; + height: 0; + padding: 0; + overflow: hidden; +} +.embed-responsive .embed-responsive-item, +.embed-responsive iframe, +.embed-responsive embed, +.embed-responsive object, +.embed-responsive video { + position: absolute; + top: 0; + left: 0; + bottom: 0; + height: 100%; + width: 100%; + border: 0; +} +.embed-responsive-16by9 { + padding-bottom: 56.25%; +} +.embed-responsive-4by3 { + padding-bottom: 75%; +} +.well { + min-height: 20px; + padding: 19px; + margin-bottom: 20px; + background-color: #ecf0f1; + border: 1px solid transparent; + border-radius: 4px; + box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); +} +.well blockquote { + border-color: #ddd; + border-color: rgba(0, 0, 0, 0.15); +} +.well-lg { + padding: 24px; + border-radius: 6px; +} +.well-sm { + padding: 9px; + border-radius: 3px; +} +.close { + float: right; + font-size: 19.5px; + font-weight: bold; + line-height: 1; + color: #000000; + text-shadow: none; + opacity: 0.2; + filter: alpha(opacity=20); +} +.close:hover, +.close:focus { + color: #000000; + text-decoration: none; + cursor: pointer; + opacity: 0.5; + filter: alpha(opacity=50); +} +button.close { + padding: 0; + cursor: pointer; + background: transparent; + border: 0; + -webkit-appearance: none; +} +.modal-open { + overflow: hidden; +} +.modal { + display: none; + overflow: hidden; + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 1070; + -webkit-overflow-scrolling: touch; + outline: 0; +} +.modal.fade .modal-dialog { + -webkit-transform: translate(0, -25%); + transform: translate(0, -25%); + -webkit-transition: -webkit-transform 0.3s ease-out; + transition: transform 0.3s ease-out; +} +.modal.in .modal-dialog { + -webkit-transform: translate(0, 0); + transform: translate(0, 0); +} +.modal-open .modal { + overflow-x: hidden; + overflow-y: auto; +} +.modal-dialog { + position: relative; + width: auto; + margin: 10px; +} +.modal-content { + position: relative; + background-color: #ffffff; + border: 1px solid #999999; + border: 1px solid rgba(0, 0, 0, 0.2); + border-radius: 6px; + box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); + background-clip: padding-box; + outline: 0; +} +.modal-backdrop { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 1060; + background-color: #000000; +} +.modal-backdrop.fade { + opacity: 0; + filter: alpha(opacity=0); +} +.modal-backdrop.in { + opacity: 0.5; + filter: alpha(opacity=50); +} +.modal-header { + padding: 15px; + border-bottom: 1px solid #e5e5e5; + min-height: 16.42857143px; +} +.modal-header .close { + margin-top: -2px; +} +.modal-title { + margin: 0; + line-height: 1.42857143; +} +.modal-body { + position: relative; + padding: 20px; +} +.modal-footer { + padding: 20px; + text-align: right; + border-top: 1px solid #e5e5e5; +} +.modal-footer .btn + .btn { + margin-left: 5px; + margin-bottom: 0; +} +.modal-footer .btn-group .btn + .btn { + margin-left: -1px; +} +.modal-footer .btn-block + .btn-block { + margin-left: 0; +} +.modal-scrollbar-measure { + position: absolute; + top: -9999px; + width: 50px; + height: 50px; + overflow: scroll; +} +@media (min-width: 768px) { + .modal-dialog { + width: 600px; + margin: 30px auto; + } + .modal-content { + box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); + } + .modal-sm { + width: 300px; + } +} +@media (min-width: 992px) { + .modal-lg { + width: 900px; + } +} +.tooltip { + position: absolute; + z-index: 1040; + display: block; + font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-style: normal; + font-weight: normal; + letter-spacing: normal; + line-break: auto; + line-height: 1.42857143; + text-align: left; + text-align: start; + text-decoration: none; + text-shadow: none; + text-transform: none; + white-space: normal; + word-break: normal; + word-spacing: normal; + word-wrap: normal; + font-size: 12px; + opacity: 0; + filter: alpha(opacity=0); +} +.tooltip.in { + opacity: 0.9; + filter: alpha(opacity=90); +} +.tooltip.top { + margin-top: -3px; + padding: 5px 0; +} +.tooltip.right { + margin-left: 3px; + padding: 0 5px; +} +.tooltip.bottom { + margin-top: 3px; + padding: 5px 0; +} +.tooltip.left { + margin-left: -3px; + padding: 0 5px; +} +.tooltip-inner { + max-width: 200px; + padding: 3px 8px; + color: #ecf0f1; + text-align: center; + background-color: rgba(34, 34, 34, 0.93); + border-radius: 4px; +} +.tooltip-arrow { + position: absolute; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; +} +.tooltip.top .tooltip-arrow { + bottom: 0; + left: 50%; + margin-left: -5px; + border-width: 5px 5px 0; + border-top-color: rgba(34, 34, 34, 0.93); +} +.tooltip.top-left .tooltip-arrow { + bottom: 0; + right: 5px; + margin-bottom: -5px; + border-width: 5px 5px 0; + border-top-color: rgba(34, 34, 34, 0.93); +} +.tooltip.top-right .tooltip-arrow { + bottom: 0; + left: 5px; + margin-bottom: -5px; + border-width: 5px 5px 0; + border-top-color: rgba(34, 34, 34, 0.93); +} +.tooltip.right .tooltip-arrow { + top: 50%; + left: 0; + margin-top: -5px; + border-width: 5px 5px 5px 0; + border-right-color: rgba(34, 34, 34, 0.93); +} +.tooltip.left .tooltip-arrow { + top: 50%; + right: 0; + margin-top: -5px; + border-width: 5px 0 5px 5px; + border-left-color: rgba(34, 34, 34, 0.93); +} +.tooltip.bottom .tooltip-arrow { + top: 0; + left: 50%; + margin-left: -5px; + border-width: 0 5px 5px; + border-bottom-color: rgba(34, 34, 34, 0.93); +} +.tooltip.bottom-left .tooltip-arrow { + top: 0; + right: 5px; + margin-top: -5px; + border-width: 0 5px 5px; + border-bottom-color: rgba(34, 34, 34, 0.93); +} +.tooltip.bottom-right .tooltip-arrow { + top: 0; + left: 5px; + margin-top: -5px; + border-width: 0 5px 5px; + border-bottom-color: rgba(34, 34, 34, 0.93); +} +.popover { + position: absolute; + top: 0; + left: 0; + z-index: 1010; + display: none; + max-width: 276px; + padding: 1px; + font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; + font-style: normal; + font-weight: normal; + letter-spacing: normal; + line-break: auto; + line-height: 1.42857143; + text-align: left; + text-align: start; + text-decoration: none; + text-shadow: none; + text-transform: none; + white-space: normal; + word-break: normal; + word-spacing: normal; + word-wrap: normal; + font-size: 13px; + background-color: #ffffff; + background-clip: padding-box; + border: 1px solid #cccccc; + border: 1px solid rgba(0, 0, 0, 0.2); + border-radius: 6px; + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); +} +.popover.top { + margin-top: -10px; +} +.popover.right { + margin-left: 10px; +} +.popover.bottom { + margin-top: 10px; +} +.popover.left { + margin-left: -10px; +} +.popover-title { + margin: 0; + padding: 8px 14px; + font-size: 13px; + background-color: #f7f7f7; + border-bottom: 1px solid #ebebeb; + border-radius: 5px 5px 0 0; +} +.popover-content { + padding: 9px 14px; +} +.popover > .arrow, +.popover > .arrow:after { + position: absolute; + display: block; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; +} +.popover > .arrow { + border-width: 11px; +} +.popover > .arrow:after { + border-width: 10px; + content: ""; +} +.popover.top > .arrow { + left: 50%; + margin-left: -11px; + border-bottom-width: 0; + border-top-color: #999999; + border-top-color: rgba(0, 0, 0, 0.25); + bottom: -11px; +} +.popover.top > .arrow:after { + content: " "; + bottom: 1px; + margin-left: -10px; + border-bottom-width: 0; + border-top-color: #ffffff; +} +.popover.right > .arrow { + top: 50%; + left: -11px; + margin-top: -11px; + border-left-width: 0; + border-right-color: #999999; + border-right-color: rgba(0, 0, 0, 0.25); +} +.popover.right > .arrow:after { + content: " "; + left: 1px; + bottom: -10px; + border-left-width: 0; + border-right-color: #ffffff; +} +.popover.bottom > .arrow { + left: 50%; + margin-left: -11px; + border-top-width: 0; + border-bottom-color: #999999; + border-bottom-color: rgba(0, 0, 0, 0.25); + top: -11px; +} +.popover.bottom > .arrow:after { + content: " "; + top: 1px; + margin-left: -10px; + border-top-width: 0; + border-bottom-color: #ffffff; +} +.popover.left > .arrow { + top: 50%; + right: -11px; + margin-top: -11px; + border-right-width: 0; + border-left-color: #999999; + border-left-color: rgba(0, 0, 0, 0.25); +} +.popover.left > .arrow:after { + content: " "; + right: 1px; + border-right-width: 0; + border-left-color: #ffffff; + bottom: -10px; +} +.carousel { + position: relative; +} +.carousel-inner { + position: relative; + overflow: hidden; + width: 100%; +} +.carousel-inner > .item { + display: none; + position: relative; + -webkit-transition: 0.6s ease-in-out left; + transition: 0.6s ease-in-out left; +} +.carousel-inner > .item > img, +.carousel-inner > .item > a > img { + line-height: 1; +} +@media all and (transform-3d), (-webkit-transform-3d) { + .carousel-inner > .item { + -webkit-transition: -webkit-transform 0.6s ease-in-out; + transition: transform 0.6s ease-in-out; + -webkit-backface-visibility: hidden; + backface-visibility: hidden; + -webkit-perspective: 1000px; + perspective: 1000px; + } + .carousel-inner > .item.next, + .carousel-inner > .item.active.right { + -webkit-transform: translate3d(100%, 0, 0); + transform: translate3d(100%, 0, 0); + left: 0; + } + .carousel-inner > .item.prev, + .carousel-inner > .item.active.left { + -webkit-transform: translate3d(-100%, 0, 0); + transform: translate3d(-100%, 0, 0); + left: 0; + } + .carousel-inner > .item.next.left, + .carousel-inner > .item.prev.right, + .carousel-inner > .item.active { + -webkit-transform: translate3d(0, 0, 0); + transform: translate3d(0, 0, 0); + left: 0; + } +} +.carousel-inner > .active, +.carousel-inner > .next, +.carousel-inner > .prev { + display: block; +} +.carousel-inner > .active { + left: 0; +} +.carousel-inner > .next, +.carousel-inner > .prev { + position: absolute; + top: 0; + width: 100%; +} +.carousel-inner > .next { + left: 100%; +} +.carousel-inner > .prev { + left: -100%; +} +.carousel-inner > .next.left, +.carousel-inner > .prev.right { + left: 0; +} +.carousel-inner > .active.left { + left: -100%; +} +.carousel-inner > .active.right { + left: 100%; +} +.carousel-control { + position: absolute; + top: 0; + left: 0; + bottom: 0; + width: 15%; + opacity: 0.5; + filter: alpha(opacity=50); + font-size: 20px; + color: #ffffff; + text-align: center; + text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); +} +.carousel-control.left { + background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%); + background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1); +} +.carousel-control.right { + left: auto; + right: 0; + background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%); + background-image: linear-gradient(to right, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1); +} +.carousel-control:hover, +.carousel-control:focus { + outline: 0; + color: #ffffff; + text-decoration: none; + opacity: 0.9; + filter: alpha(opacity=90); +} +.carousel-control .icon-prev, +.carousel-control .icon-next, +.carousel-control .glyphicon-chevron-left, +.carousel-control .glyphicon-chevron-right { + position: absolute; + top: 50%; + margin-top: -10px; + z-index: 5; + display: inline-block; +} +.carousel-control .icon-prev, +.carousel-control .glyphicon-chevron-left { + left: 50%; + margin-left: -10px; +} +.carousel-control .icon-next, +.carousel-control .glyphicon-chevron-right { + right: 50%; + margin-right: -10px; +} +.carousel-control .icon-prev, +.carousel-control .icon-next { + width: 20px; + height: 20px; + line-height: 1; + font-family: serif; +} +.carousel-control .icon-prev:before { + content: '\2039'; +} +.carousel-control .icon-next:before { + content: '\203A'; +} +.carousel-indicators { + position: absolute; + bottom: 10px; + left: 50%; + z-index: 15; + width: 60%; + margin-left: -30%; + padding-left: 0; + list-style: none; + text-align: center; +} +.carousel-indicators li { + display: inline-block; + width: 10px; + height: 10px; + margin: 1px; + text-indent: -999px; + border: 1px solid #ffffff; + border-radius: 10px; + cursor: pointer; + background-color: #000 \9; + background-color: rgba(0, 0, 0, 0); +} +.carousel-indicators .active { + margin: 0; + width: 12px; + height: 12px; + background-color: #ffffff; +} +.carousel-caption { + position: absolute; + left: 15%; + right: 15%; + bottom: 20px; + z-index: 10; + padding-top: 20px; + padding-bottom: 20px; + color: #ffffff; + text-align: center; + text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); +} +.carousel-caption .btn { + text-shadow: none; +} +@media screen and (min-width: 768px) { + .carousel-control .glyphicon-chevron-left, + .carousel-control .glyphicon-chevron-right, + .carousel-control .icon-prev, + .carousel-control .icon-next { + width: 30px; + height: 30px; + margin-top: -15px; + font-size: 30px; + } + .carousel-control .glyphicon-chevron-left, + .carousel-control .icon-prev { + margin-left: -15px; + } + .carousel-control .glyphicon-chevron-right, + .carousel-control .icon-next { + margin-right: -15px; + } + .carousel-caption { + left: 20%; + right: 20%; + padding-bottom: 30px; + } + .carousel-indicators { + bottom: 20px; + } +} +.clearfix:before, +.clearfix:after, +.dl-horizontal dd:before, +.dl-horizontal dd:after, +.container:before, +.container:after, +.container-fluid:before, +.container-fluid:after, +.row:before, +.row:after, +.form-horizontal .form-group:before, +.form-horizontal .form-group:after, +.btn-toolbar:before, +.btn-toolbar:after, +.btn-group-vertical > .btn-group:before, +.btn-group-vertical > .btn-group:after, +.nav:before, +.nav:after, +.navbar:before, +.navbar:after, +.navbar-header:before, +.navbar-header:after, +.navbar-collapse:before, +.navbar-collapse:after, +.pager:before, +.pager:after, +.panel-body:before, +.panel-body:after, +.modal-footer:before, +.modal-footer:after { + content: " "; + display: table; +} +.clearfix:after, +.dl-horizontal dd:after, +.container:after, +.container-fluid:after, +.row:after, +.form-horizontal .form-group:after, +.btn-toolbar:after, +.btn-group-vertical > .btn-group:after, +.nav:after, +.navbar:after, +.navbar-header:after, +.navbar-collapse:after, +.pager:after, +.panel-body:after, +.modal-footer:after { + clear: both; +} +.center-block { + display: block; + margin-left: auto; + margin-right: auto; +} +.pull-right { + float: right !important; +} +.pull-left { + float: left !important; +} +.hide { + display: none !important; +} +.show { + display: block !important; +} +.invisible { + visibility: hidden; +} +.text-hide { + font: 0/0 a; + color: transparent; + text-shadow: none; + background-color: transparent; + border: 0; +} +.hidden { + display: none !important; +} +.affix { + position: fixed; +} +@-ms-viewport { + width: device-width; +} +.visible-xs, +.visible-sm, +.visible-md, +.visible-lg { + display: none !important; +} +.visible-xs-block, +.visible-xs-inline, +.visible-xs-inline-block, +.visible-sm-block, +.visible-sm-inline, +.visible-sm-inline-block, +.visible-md-block, +.visible-md-inline, +.visible-md-inline-block, +.visible-lg-block, +.visible-lg-inline, +.visible-lg-inline-block { + display: none !important; +} +@media (max-width: 767px) { + .visible-xs { + display: block !important; + } + table.visible-xs { + display: table !important; + } + tr.visible-xs { + display: table-row !important; + } + th.visible-xs, + td.visible-xs { + display: table-cell !important; + } +} +@media (max-width: 767px) { + .visible-xs-block { + display: block !important; + } +} +@media (max-width: 767px) { + .visible-xs-inline { + display: inline !important; + } +} +@media (max-width: 767px) { + .visible-xs-inline-block { + display: inline-block !important; + } +} +@media (min-width: 768px) and (max-width: 991px) { + .visible-sm { + display: block !important; + } + table.visible-sm { + display: table !important; + } + tr.visible-sm { + display: table-row !important; + } + th.visible-sm, + td.visible-sm { + display: table-cell !important; + } +} +@media (min-width: 768px) and (max-width: 991px) { + .visible-sm-block { + display: block !important; + } +} +@media (min-width: 768px) and (max-width: 991px) { + .visible-sm-inline { + display: inline !important; + } +} +@media (min-width: 768px) and (max-width: 991px) { + .visible-sm-inline-block { + display: inline-block !important; + } +} +@media (min-width: 992px) and (max-width: 1199px) { + .visible-md { + display: block !important; + } + table.visible-md { + display: table !important; + } + tr.visible-md { + display: table-row !important; + } + th.visible-md, + td.visible-md { + display: table-cell !important; + } +} +@media (min-width: 992px) and (max-width: 1199px) { + .visible-md-block { + display: block !important; + } +} +@media (min-width: 992px) and (max-width: 1199px) { + .visible-md-inline { + display: inline !important; + } +} +@media (min-width: 992px) and (max-width: 1199px) { + .visible-md-inline-block { + display: inline-block !important; + } +} +@media (min-width: 1200px) { + .visible-lg { + display: block !important; + } + table.visible-lg { + display: table !important; + } + tr.visible-lg { + display: table-row !important; + } + th.visible-lg, + td.visible-lg { + display: table-cell !important; + } +} +@media (min-width: 1200px) { + .visible-lg-block { + display: block !important; + } +} +@media (min-width: 1200px) { + .visible-lg-inline { + display: inline !important; + } +} +@media (min-width: 1200px) { + .visible-lg-inline-block { + display: inline-block !important; + } +} +@media (max-width: 767px) { + .hidden-xs { + display: none !important; + } +} +@media (min-width: 768px) and (max-width: 991px) { + .hidden-sm { + display: none !important; + } +} +@media (min-width: 992px) and (max-width: 1199px) { + .hidden-md { + display: none !important; + } +} +@media (min-width: 1200px) { + .hidden-lg { + display: none !important; + } +} +.visible-print { + display: none !important; +} +@media print { + .visible-print { + display: block !important; + } + table.visible-print { + display: table !important; + } + tr.visible-print { + display: table-row !important; + } + th.visible-print, + td.visible-print { + display: table-cell !important; + } +} +.visible-print-block { + display: none !important; +} +@media print { + .visible-print-block { + display: block !important; + } +} +.visible-print-inline { + display: none !important; +} +@media print { + .visible-print-inline { + display: inline !important; + } +} +.visible-print-inline-block { + display: none !important; +} +@media print { + .visible-print-inline-block { + display: inline-block !important; + } +} +@media print { + .hidden-print { + display: none !important; + } +} +/*! + * Font Awesome 4.4.0 by @davegandy - http://fontawesome.io - @fontawesome + * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) + */ +/* FONT PATH + * -------------------------- */ +@font-face { + font-family: 'FontAwesome'; + src: url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.eot); + src: url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.eot?#iefix&v=4.4.0) format('embedded-opentype'), url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.woff2) format('woff2'), url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.woff) format('woff'), url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.ttf) format('truetype'), url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.svg#fontawesomeregular) format('svg'); + font-weight: normal; + font-style: normal; +} +.fa { + display: inline-block; + font: normal normal normal 14px/1 FontAwesome; + font-size: inherit; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} +/* makes the font 33% larger relative to the icon container */ +.fa-lg { + font-size: 1.33333333em; + line-height: 0.75em; + vertical-align: -15%; +} +.fa-2x { + font-size: 2em; +} +.fa-3x { + font-size: 3em; +} +.fa-4x { + font-size: 4em; +} +.fa-5x { + font-size: 5em; +} +.fa-fw { + width: 1.28571429em; + text-align: center; +} +.fa-ul { + padding-left: 0; + margin-left: 2.14285714em; + list-style-type: none; +} +.fa-ul > li { + position: relative; +} +.fa-li { + position: absolute; + left: -2.14285714em; + width: 2.14285714em; + top: 0.14285714em; + text-align: center; +} +.fa-li.fa-lg { + left: -1.85714286em; +} +.fa-border { + padding: .2em .25em .15em; + border: solid 0.08em #eeeeee; + border-radius: .1em; +} +.fa-pull-left { + float: left; +} +.fa-pull-right { + float: right; +} +.fa.fa-pull-left { + margin-right: .3em; +} +.fa.fa-pull-right { + margin-left: .3em; +} +/* Deprecated as of 4.4.0 */ +.pull-right { + float: right; +} +.pull-left { + float: left; +} +.fa.pull-left { + margin-right: .3em; +} +.fa.pull-right { + margin-left: .3em; +} +.fa-spin { + -webkit-animation: fa-spin 2s infinite linear; + animation: fa-spin 2s infinite linear; +} +.fa-pulse { + -webkit-animation: fa-spin 1s infinite steps(8); + animation: fa-spin 1s infinite steps(8); +} +@-webkit-keyframes fa-spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@keyframes fa-spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +.fa-rotate-90 { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1); + -webkit-transform: rotate(90deg); + transform: rotate(90deg); +} +.fa-rotate-180 { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2); + -webkit-transform: rotate(180deg); + transform: rotate(180deg); +} +.fa-rotate-270 { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); + -webkit-transform: rotate(270deg); + transform: rotate(270deg); +} +.fa-flip-horizontal { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1); + -webkit-transform: scale(-1, 1); + transform: scale(-1, 1); +} +.fa-flip-vertical { + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1); + -webkit-transform: scale(1, -1); + transform: scale(1, -1); +} +:root .fa-rotate-90, +:root .fa-rotate-180, +:root .fa-rotate-270, +:root .fa-flip-horizontal, +:root .fa-flip-vertical { + -webkit-filter: none; + filter: none; +} +.fa-stack { + position: relative; + display: inline-block; + width: 2em; + height: 2em; + line-height: 2em; + vertical-align: middle; +} +.fa-stack-1x, +.fa-stack-2x { + position: absolute; + left: 0; + width: 100%; + text-align: center; +} +.fa-stack-1x { + line-height: inherit; +} +.fa-stack-2x { + font-size: 2em; +} +.fa-inverse { + color: #ffffff; +} +/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen + readers do not read off random characters that represent icons */ +.fa-glass:before { + content: "\F000"; +} +.fa-music:before { + content: "\F001"; +} +.fa-search:before { + content: "\F002"; +} +.fa-envelope-o:before { + content: "\F003"; +} +.fa-heart:before { + content: "\F004"; +} +.fa-star:before { + content: "\F005"; +} +.fa-star-o:before { + content: "\F006"; +} +.fa-user:before { + content: "\F007"; +} +.fa-film:before { + content: "\F008"; +} +.fa-th-large:before { + content: "\F009"; +} +.fa-th:before { + content: "\F00A"; +} +.fa-th-list:before { + content: "\F00B"; +} +.fa-check:before { + content: "\F00C"; +} +.fa-remove:before, +.fa-close:before, +.fa-times:before { + content: "\F00D"; +} +.fa-search-plus:before { + content: "\F00E"; +} +.fa-search-minus:before { + content: "\F010"; +} +.fa-power-off:before { + content: "\F011"; +} +.fa-signal:before { + content: "\F012"; +} +.fa-gear:before, +.fa-cog:before { + content: "\F013"; +} +.fa-trash-o:before { + content: "\F014"; +} +.fa-home:before { + content: "\F015"; +} +.fa-file-o:before { + content: "\F016"; +} +.fa-clock-o:before { + content: "\F017"; +} +.fa-road:before { + content: "\F018"; +} +.fa-download:before { + content: "\F019"; +} +.fa-arrow-circle-o-down:before { + content: "\F01A"; +} +.fa-arrow-circle-o-up:before { + content: "\F01B"; +} +.fa-inbox:before { + content: "\F01C"; +} +.fa-play-circle-o:before { + content: "\F01D"; +} +.fa-rotate-right:before, +.fa-repeat:before { + content: "\F01E"; +} +.fa-refresh:before { + content: "\F021"; +} +.fa-list-alt:before { + content: "\F022"; +} +.fa-lock:before { + content: "\F023"; +} +.fa-flag:before { + content: "\F024"; +} +.fa-headphones:before { + content: "\F025"; +} +.fa-volume-off:before { + content: "\F026"; +} +.fa-volume-down:before { + content: "\F027"; +} +.fa-volume-up:before { + content: "\F028"; +} +.fa-qrcode:before { + content: "\F029"; +} +.fa-barcode:before { + content: "\F02A"; +} +.fa-tag:before { + content: "\F02B"; +} +.fa-tags:before { + content: "\F02C"; +} +.fa-book:before { + content: "\F02D"; +} +.fa-bookmark:before { + content: "\F02E"; +} +.fa-print:before { + content: "\F02F"; +} +.fa-camera:before { + content: "\F030"; +} +.fa-font:before { + content: "\F031"; +} +.fa-bold:before { + content: "\F032"; +} +.fa-italic:before { + content: "\F033"; +} +.fa-text-height:before { + content: "\F034"; +} +.fa-text-width:before { + content: "\F035"; +} +.fa-align-left:before { + content: "\F036"; +} +.fa-align-center:before { + content: "\F037"; +} +.fa-align-right:before { + content: "\F038"; +} +.fa-align-justify:before { + content: "\F039"; +} +.fa-list:before { + content: "\F03A"; +} +.fa-dedent:before, +.fa-outdent:before { + content: "\F03B"; +} +.fa-indent:before { + content: "\F03C"; +} +.fa-video-camera:before { + content: "\F03D"; +} +.fa-photo:before, +.fa-image:before, +.fa-picture-o:before { + content: "\F03E"; +} +.fa-pencil:before { + content: "\F040"; +} +.fa-map-marker:before { + content: "\F041"; +} +.fa-adjust:before { + content: "\F042"; +} +.fa-tint:before { + content: "\F043"; +} +.fa-edit:before, +.fa-pencil-square-o:before { + content: "\F044"; +} +.fa-share-square-o:before { + content: "\F045"; +} +.fa-check-square-o:before { + content: "\F046"; +} +.fa-arrows:before { + content: "\F047"; +} +.fa-step-backward:before { + content: "\F048"; +} +.fa-fast-backward:before { + content: "\F049"; +} +.fa-backward:before { + content: "\F04A"; +} +.fa-play:before { + content: "\F04B"; +} +.fa-pause:before { + content: "\F04C"; +} +.fa-stop:before { + content: "\F04D"; +} +.fa-forward:before { + content: "\F04E"; +} +.fa-fast-forward:before { + content: "\F050"; +} +.fa-step-forward:before { + content: "\F051"; +} +.fa-eject:before { + content: "\F052"; +} +.fa-chevron-left:before { + content: "\F053"; +} +.fa-chevron-right:before { + content: "\F054"; +} +.fa-plus-circle:before { + content: "\F055"; +} +.fa-minus-circle:before { + content: "\F056"; +} +.fa-times-circle:before { + content: "\F057"; +} +.fa-check-circle:before { + content: "\F058"; +} +.fa-question-circle:before { + content: "\F059"; +} +.fa-info-circle:before { + content: "\F05A"; +} +.fa-crosshairs:before { + content: "\F05B"; +} +.fa-times-circle-o:before { + content: "\F05C"; +} +.fa-check-circle-o:before { + content: "\F05D"; +} +.fa-ban:before { + content: "\F05E"; +} +.fa-arrow-left:before { + content: "\F060"; +} +.fa-arrow-right:before { + content: "\F061"; +} +.fa-arrow-up:before { + content: "\F062"; +} +.fa-arrow-down:before { + content: "\F063"; +} +.fa-mail-forward:before, +.fa-share:before { + content: "\F064"; +} +.fa-expand:before { + content: "\F065"; +} +.fa-compress:before { + content: "\F066"; +} +.fa-plus:before { + content: "\F067"; +} +.fa-minus:before { + content: "\F068"; +} +.fa-asterisk:before { + content: "\F069"; +} +.fa-exclamation-circle:before { + content: "\F06A"; +} +.fa-gift:before { + content: "\F06B"; +} +.fa-leaf:before { + content: "\F06C"; +} +.fa-fire:before { + content: "\F06D"; +} +.fa-eye:before { + content: "\F06E"; +} +.fa-eye-slash:before { + content: "\F070"; +} +.fa-warning:before, +.fa-exclamation-triangle:before { + content: "\F071"; +} +.fa-plane:before { + content: "\F072"; +} +.fa-calendar:before { + content: "\F073"; +} +.fa-random:before { + content: "\F074"; +} +.fa-comment:before { + content: "\F075"; +} +.fa-magnet:before { + content: "\F076"; +} +.fa-chevron-up:before { + content: "\F077"; +} +.fa-chevron-down:before { + content: "\F078"; +} +.fa-retweet:before { + content: "\F079"; +} +.fa-shopping-cart:before { + content: "\F07A"; +} +.fa-folder:before { + content: "\F07B"; +} +.fa-folder-open:before { + content: "\F07C"; +} +.fa-arrows-v:before { + content: "\F07D"; +} +.fa-arrows-h:before { + content: "\F07E"; +} +.fa-bar-chart-o:before, +.fa-bar-chart:before { + content: "\F080"; +} +.fa-twitter-square:before { + content: "\F081"; +} +.fa-facebook-square:before { + content: "\F082"; +} +.fa-camera-retro:before { + content: "\F083"; +} +.fa-key:before { + content: "\F084"; +} +.fa-gears:before, +.fa-cogs:before { + content: "\F085"; +} +.fa-comments:before { + content: "\F086"; +} +.fa-thumbs-o-up:before { + content: "\F087"; +} +.fa-thumbs-o-down:before { + content: "\F088"; +} +.fa-star-half:before { + content: "\F089"; +} +.fa-heart-o:before { + content: "\F08A"; +} +.fa-sign-out:before { + content: "\F08B"; +} +.fa-linkedin-square:before { + content: "\F08C"; +} +.fa-thumb-tack:before { + content: "\F08D"; +} +.fa-external-link:before { + content: "\F08E"; +} +.fa-sign-in:before { + content: "\F090"; +} +.fa-trophy:before { + content: "\F091"; +} +.fa-github-square:before { + content: "\F092"; +} +.fa-upload:before { + content: "\F093"; +} +.fa-lemon-o:before { + content: "\F094"; +} +.fa-phone:before { + content: "\F095"; +} +.fa-square-o:before { + content: "\F096"; +} +.fa-bookmark-o:before { + content: "\F097"; +} +.fa-phone-square:before { + content: "\F098"; +} +.fa-twitter:before { + content: "\F099"; +} +.fa-facebook-f:before, +.fa-facebook:before { + content: "\F09A"; +} +.fa-github:before { + content: "\F09B"; +} +.fa-unlock:before { + content: "\F09C"; +} +.fa-credit-card:before { + content: "\F09D"; +} +.fa-feed:before, +.fa-rss:before { + content: "\F09E"; +} +.fa-hdd-o:before { + content: "\F0A0"; +} +.fa-bullhorn:before { + content: "\F0A1"; +} +.fa-bell:before { + content: "\F0F3"; +} +.fa-certificate:before { + content: "\F0A3"; +} +.fa-hand-o-right:before { + content: "\F0A4"; +} +.fa-hand-o-left:before { + content: "\F0A5"; +} +.fa-hand-o-up:before { + content: "\F0A6"; +} +.fa-hand-o-down:before { + content: "\F0A7"; +} +.fa-arrow-circle-left:before { + content: "\F0A8"; +} +.fa-arrow-circle-right:before { + content: "\F0A9"; +} +.fa-arrow-circle-up:before { + content: "\F0AA"; +} +.fa-arrow-circle-down:before { + content: "\F0AB"; +} +.fa-globe:before { + content: "\F0AC"; +} +.fa-wrench:before { + content: "\F0AD"; +} +.fa-tasks:before { + content: "\F0AE"; +} +.fa-filter:before { + content: "\F0B0"; +} +.fa-briefcase:before { + content: "\F0B1"; +} +.fa-arrows-alt:before { + content: "\F0B2"; +} +.fa-group:before, +.fa-users:before { + content: "\F0C0"; +} +.fa-chain:before, +.fa-link:before { + content: "\F0C1"; +} +.fa-cloud:before { + content: "\F0C2"; +} +.fa-flask:before { + content: "\F0C3"; +} +.fa-cut:before, +.fa-scissors:before { + content: "\F0C4"; +} +.fa-copy:before, +.fa-files-o:before { + content: "\F0C5"; +} +.fa-paperclip:before { + content: "\F0C6"; +} +.fa-save:before, +.fa-floppy-o:before { + content: "\F0C7"; +} +.fa-square:before { + content: "\F0C8"; +} +.fa-navicon:before, +.fa-reorder:before, +.fa-bars:before { + content: "\F0C9"; +} +.fa-list-ul:before { + content: "\F0CA"; +} +.fa-list-ol:before { + content: "\F0CB"; +} +.fa-strikethrough:before { + content: "\F0CC"; +} +.fa-underline:before { + content: "\F0CD"; +} +.fa-table:before { + content: "\F0CE"; +} +.fa-magic:before { + content: "\F0D0"; +} +.fa-truck:before { + content: "\F0D1"; +} +.fa-pinterest:before { + content: "\F0D2"; +} +.fa-pinterest-square:before { + content: "\F0D3"; +} +.fa-google-plus-square:before { + content: "\F0D4"; +} +.fa-google-plus:before { + content: "\F0D5"; +} +.fa-money:before { + content: "\F0D6"; +} +.fa-caret-down:before { + content: "\F0D7"; +} +.fa-caret-up:before { + content: "\F0D8"; +} +.fa-caret-left:before { + content: "\F0D9"; +} +.fa-caret-right:before { + content: "\F0DA"; +} +.fa-columns:before { + content: "\F0DB"; +} +.fa-unsorted:before, +.fa-sort:before { + content: "\F0DC"; +} +.fa-sort-down:before, +.fa-sort-desc:before { + content: "\F0DD"; +} +.fa-sort-up:before, +.fa-sort-asc:before { + content: "\F0DE"; +} +.fa-envelope:before { + content: "\F0E0"; +} +.fa-linkedin:before { + content: "\F0E1"; +} +.fa-rotate-left:before, +.fa-undo:before { + content: "\F0E2"; +} +.fa-legal:before, +.fa-gavel:before { + content: "\F0E3"; +} +.fa-dashboard:before, +.fa-tachometer:before { + content: "\F0E4"; +} +.fa-comment-o:before { + content: "\F0E5"; +} +.fa-comments-o:before { + content: "\F0E6"; +} +.fa-flash:before, +.fa-bolt:before { + content: "\F0E7"; +} +.fa-sitemap:before { + content: "\F0E8"; +} +.fa-umbrella:before { + content: "\F0E9"; +} +.fa-paste:before, +.fa-clipboard:before { + content: "\F0EA"; +} +.fa-lightbulb-o:before { + content: "\F0EB"; +} +.fa-exchange:before { + content: "\F0EC"; +} +.fa-cloud-download:before { + content: "\F0ED"; +} +.fa-cloud-upload:before { + content: "\F0EE"; +} +.fa-user-md:before { + content: "\F0F0"; +} +.fa-stethoscope:before { + content: "\F0F1"; +} +.fa-suitcase:before { + content: "\F0F2"; +} +.fa-bell-o:before { + content: "\F0A2"; +} +.fa-coffee:before { + content: "\F0F4"; +} +.fa-cutlery:before { + content: "\F0F5"; +} +.fa-file-text-o:before { + content: "\F0F6"; +} +.fa-building-o:before { + content: "\F0F7"; +} +.fa-hospital-o:before { + content: "\F0F8"; +} +.fa-ambulance:before { + content: "\F0F9"; +} +.fa-medkit:before { + content: "\F0FA"; +} +.fa-fighter-jet:before { + content: "\F0FB"; +} +.fa-beer:before { + content: "\F0FC"; +} +.fa-h-square:before { + content: "\F0FD"; +} +.fa-plus-square:before { + content: "\F0FE"; +} +.fa-angle-double-left:before { + content: "\F100"; +} +.fa-angle-double-right:before { + content: "\F101"; +} +.fa-angle-double-up:before { + content: "\F102"; +} +.fa-angle-double-down:before { + content: "\F103"; +} +.fa-angle-left:before { + content: "\F104"; +} +.fa-angle-right:before { + content: "\F105"; +} +.fa-angle-up:before { + content: "\F106"; +} +.fa-angle-down:before { + content: "\F107"; +} +.fa-desktop:before { + content: "\F108"; +} +.fa-laptop:before { + content: "\F109"; +} +.fa-tablet:before { + content: "\F10A"; +} +.fa-mobile-phone:before, +.fa-mobile:before { + content: "\F10B"; +} +.fa-circle-o:before { + content: "\F10C"; +} +.fa-quote-left:before { + content: "\F10D"; +} +.fa-quote-right:before { + content: "\F10E"; +} +.fa-spinner:before { + content: "\F110"; +} +.fa-circle:before { + content: "\F111"; +} +.fa-mail-reply:before, +.fa-reply:before { + content: "\F112"; +} +.fa-github-alt:before { + content: "\F113"; +} +.fa-folder-o:before { + content: "\F114"; +} +.fa-folder-open-o:before { + content: "\F115"; +} +.fa-smile-o:before { + content: "\F118"; +} +.fa-frown-o:before { + content: "\F119"; +} +.fa-meh-o:before { + content: "\F11A"; +} +.fa-gamepad:before { + content: "\F11B"; +} +.fa-keyboard-o:before { + content: "\F11C"; +} +.fa-flag-o:before { + content: "\F11D"; +} +.fa-flag-checkered:before { + content: "\F11E"; +} +.fa-terminal:before { + content: "\F120"; +} +.fa-code:before { + content: "\F121"; +} +.fa-mail-reply-all:before, +.fa-reply-all:before { + content: "\F122"; +} +.fa-star-half-empty:before, +.fa-star-half-full:before, +.fa-star-half-o:before { + content: "\F123"; +} +.fa-location-arrow:before { + content: "\F124"; +} +.fa-crop:before { + content: "\F125"; +} +.fa-code-fork:before { + content: "\F126"; +} +.fa-unlink:before, +.fa-chain-broken:before { + content: "\F127"; +} +.fa-question:before { + content: "\F128"; +} +.fa-info:before { + content: "\F129"; +} +.fa-exclamation:before { + content: "\F12A"; +} +.fa-superscript:before { + content: "\F12B"; +} +.fa-subscript:before { + content: "\F12C"; +} +.fa-eraser:before { + content: "\F12D"; +} +.fa-puzzle-piece:before { + content: "\F12E"; +} +.fa-microphone:before { + content: "\F130"; +} +.fa-microphone-slash:before { + content: "\F131"; +} +.fa-shield:before { + content: "\F132"; +} +.fa-calendar-o:before { + content: "\F133"; +} +.fa-fire-extinguisher:before { + content: "\F134"; +} +.fa-rocket:before { + content: "\F135"; +} +.fa-maxcdn:before { + content: "\F136"; +} +.fa-chevron-circle-left:before { + content: "\F137"; +} +.fa-chevron-circle-right:before { + content: "\F138"; +} +.fa-chevron-circle-up:before { + content: "\F139"; +} +.fa-chevron-circle-down:before { + content: "\F13A"; +} +.fa-html5:before { + content: "\F13B"; +} +.fa-css3:before { + content: "\F13C"; +} +.fa-anchor:before { + content: "\F13D"; +} +.fa-unlock-alt:before { + content: "\F13E"; +} +.fa-bullseye:before { + content: "\F140"; +} +.fa-ellipsis-h:before { + content: "\F141"; +} +.fa-ellipsis-v:before { + content: "\F142"; +} +.fa-rss-square:before { + content: "\F143"; +} +.fa-play-circle:before { + content: "\F144"; +} +.fa-ticket:before { + content: "\F145"; +} +.fa-minus-square:before { + content: "\F146"; +} +.fa-minus-square-o:before { + content: "\F147"; +} +.fa-level-up:before { + content: "\F148"; +} +.fa-level-down:before { + content: "\F149"; +} +.fa-check-square:before { + content: "\F14A"; +} +.fa-pencil-square:before { + content: "\F14B"; +} +.fa-external-link-square:before { + content: "\F14C"; +} +.fa-share-square:before { + content: "\F14D"; +} +.fa-compass:before { + content: "\F14E"; +} +.fa-toggle-down:before, +.fa-caret-square-o-down:before { + content: "\F150"; +} +.fa-toggle-up:before, +.fa-caret-square-o-up:before { + content: "\F151"; +} +.fa-toggle-right:before, +.fa-caret-square-o-right:before { + content: "\F152"; +} +.fa-euro:before, +.fa-eur:before { + content: "\F153"; +} +.fa-gbp:before { + content: "\F154"; +} +.fa-dollar:before, +.fa-usd:before { + content: "\F155"; +} +.fa-rupee:before, +.fa-inr:before { + content: "\F156"; +} +.fa-cny:before, +.fa-rmb:before, +.fa-yen:before, +.fa-jpy:before { + content: "\F157"; +} +.fa-ruble:before, +.fa-rouble:before, +.fa-rub:before { + content: "\F158"; +} +.fa-won:before, +.fa-krw:before { + content: "\F159"; +} +.fa-bitcoin:before, +.fa-btc:before { + content: "\F15A"; +} +.fa-file:before { + content: "\F15B"; +} +.fa-file-text:before { + content: "\F15C"; +} +.fa-sort-alpha-asc:before { + content: "\F15D"; +} +.fa-sort-alpha-desc:before { + content: "\F15E"; +} +.fa-sort-amount-asc:before { + content: "\F160"; +} +.fa-sort-amount-desc:before { + content: "\F161"; +} +.fa-sort-numeric-asc:before { + content: "\F162"; +} +.fa-sort-numeric-desc:before { + content: "\F163"; +} +.fa-thumbs-up:before { + content: "\F164"; +} +.fa-thumbs-down:before { + content: "\F165"; +} +.fa-youtube-square:before { + content: "\F166"; +} +.fa-youtube:before { + content: "\F167"; +} +.fa-xing:before { + content: "\F168"; +} +.fa-xing-square:before { + content: "\F169"; +} +.fa-youtube-play:before { + content: "\F16A"; +} +.fa-dropbox:before { + content: "\F16B"; +} +.fa-stack-overflow:before { + content: "\F16C"; +} +.fa-instagram:before { + content: "\F16D"; +} +.fa-flickr:before { + content: "\F16E"; +} +.fa-adn:before { + content: "\F170"; +} +.fa-bitbucket:before { + content: "\F171"; +} +.fa-bitbucket-square:before { + content: "\F172"; +} +.fa-tumblr:before { + content: "\F173"; +} +.fa-tumblr-square:before { + content: "\F174"; +} +.fa-long-arrow-down:before { + content: "\F175"; +} +.fa-long-arrow-up:before { + content: "\F176"; +} +.fa-long-arrow-left:before { + content: "\F177"; +} +.fa-long-arrow-right:before { + content: "\F178"; +} +.fa-apple:before { + content: "\F179"; +} +.fa-windows:before { + content: "\F17A"; +} +.fa-android:before { + content: "\F17B"; +} +.fa-linux:before { + content: "\F17C"; +} +.fa-dribbble:before { + content: "\F17D"; +} +.fa-skype:before { + content: "\F17E"; +} +.fa-foursquare:before { + content: "\F180"; +} +.fa-trello:before { + content: "\F181"; +} +.fa-female:before { + content: "\F182"; +} +.fa-male:before { + content: "\F183"; +} +.fa-gittip:before, +.fa-gratipay:before { + content: "\F184"; +} +.fa-sun-o:before { + content: "\F185"; +} +.fa-moon-o:before { + content: "\F186"; +} +.fa-archive:before { + content: "\F187"; +} +.fa-bug:before { + content: "\F188"; +} +.fa-vk:before { + content: "\F189"; +} +.fa-weibo:before { + content: "\F18A"; +} +.fa-renren:before { + content: "\F18B"; +} +.fa-pagelines:before { + content: "\F18C"; +} +.fa-stack-exchange:before { + content: "\F18D"; +} +.fa-arrow-circle-o-right:before { + content: "\F18E"; +} +.fa-arrow-circle-o-left:before { + content: "\F190"; +} +.fa-toggle-left:before, +.fa-caret-square-o-left:before { + content: "\F191"; +} +.fa-dot-circle-o:before { + content: "\F192"; +} +.fa-wheelchair:before { + content: "\F193"; +} +.fa-vimeo-square:before { + content: "\F194"; +} +.fa-turkish-lira:before, +.fa-try:before { + content: "\F195"; +} +.fa-plus-square-o:before { + content: "\F196"; +} +.fa-space-shuttle:before { + content: "\F197"; +} +.fa-slack:before { + content: "\F198"; +} +.fa-envelope-square:before { + content: "\F199"; +} +.fa-wordpress:before { + content: "\F19A"; +} +.fa-openid:before { + content: "\F19B"; +} +.fa-institution:before, +.fa-bank:before, +.fa-university:before { + content: "\F19C"; +} +.fa-mortar-board:before, +.fa-graduation-cap:before { + content: "\F19D"; +} +.fa-yahoo:before { + content: "\F19E"; +} +.fa-google:before { + content: "\F1A0"; +} +.fa-reddit:before { + content: "\F1A1"; +} +.fa-reddit-square:before { + content: "\F1A2"; +} +.fa-stumbleupon-circle:before { + content: "\F1A3"; +} +.fa-stumbleupon:before { + content: "\F1A4"; +} +.fa-delicious:before { + content: "\F1A5"; +} +.fa-digg:before { + content: "\F1A6"; +} +.fa-pied-piper:before { + content: "\F1A7"; +} +.fa-pied-piper-alt:before { + content: "\F1A8"; +} +.fa-drupal:before { + content: "\F1A9"; +} +.fa-joomla:before { + content: "\F1AA"; +} +.fa-language:before { + content: "\F1AB"; +} +.fa-fax:before { + content: "\F1AC"; +} +.fa-building:before { + content: "\F1AD"; +} +.fa-child:before { + content: "\F1AE"; +} +.fa-paw:before { + content: "\F1B0"; +} +.fa-spoon:before { + content: "\F1B1"; +} +.fa-cube:before { + content: "\F1B2"; +} +.fa-cubes:before { + content: "\F1B3"; +} +.fa-behance:before { + content: "\F1B4"; +} +.fa-behance-square:before { + content: "\F1B5"; +} +.fa-steam:before { + content: "\F1B6"; +} +.fa-steam-square:before { + content: "\F1B7"; +} +.fa-recycle:before { + content: "\F1B8"; +} +.fa-automobile:before, +.fa-car:before { + content: "\F1B9"; +} +.fa-cab:before, +.fa-taxi:before { + content: "\F1BA"; +} +.fa-tree:before { + content: "\F1BB"; +} +.fa-spotify:before { + content: "\F1BC"; +} +.fa-deviantart:before { + content: "\F1BD"; +} +.fa-soundcloud:before { + content: "\F1BE"; +} +.fa-database:before { + content: "\F1C0"; +} +.fa-file-pdf-o:before { + content: "\F1C1"; +} +.fa-file-word-o:before { + content: "\F1C2"; +} +.fa-file-excel-o:before { + content: "\F1C3"; +} +.fa-file-powerpoint-o:before { + content: "\F1C4"; +} +.fa-file-photo-o:before, +.fa-file-picture-o:before, +.fa-file-image-o:before { + content: "\F1C5"; +} +.fa-file-zip-o:before, +.fa-file-archive-o:before { + content: "\F1C6"; +} +.fa-file-sound-o:before, +.fa-file-audio-o:before { + content: "\F1C7"; +} +.fa-file-movie-o:before, +.fa-file-video-o:before { + content: "\F1C8"; +} +.fa-file-code-o:before { + content: "\F1C9"; +} +.fa-vine:before { + content: "\F1CA"; +} +.fa-codepen:before { + content: "\F1CB"; +} +.fa-jsfiddle:before { + content: "\F1CC"; +} +.fa-life-bouy:before, +.fa-life-buoy:before, +.fa-life-saver:before, +.fa-support:before, +.fa-life-ring:before { + content: "\F1CD"; +} +.fa-circle-o-notch:before { + content: "\F1CE"; +} +.fa-ra:before, +.fa-rebel:before { + content: "\F1D0"; +} +.fa-ge:before, +.fa-empire:before { + content: "\F1D1"; +} +.fa-git-square:before { + content: "\F1D2"; +} +.fa-git:before { + content: "\F1D3"; +} +.fa-y-combinator-square:before, +.fa-yc-square:before, +.fa-hacker-news:before { + content: "\F1D4"; +} +.fa-tencent-weibo:before { + content: "\F1D5"; +} +.fa-qq:before { + content: "\F1D6"; +} +.fa-wechat:before, +.fa-weixin:before { + content: "\F1D7"; +} +.fa-send:before, +.fa-paper-plane:before { + content: "\F1D8"; +} +.fa-send-o:before, +.fa-paper-plane-o:before { + content: "\F1D9"; +} +.fa-history:before { + content: "\F1DA"; +} +.fa-circle-thin:before { + content: "\F1DB"; +} +.fa-header:before { + content: "\F1DC"; +} +.fa-paragraph:before { + content: "\F1DD"; +} +.fa-sliders:before { + content: "\F1DE"; +} +.fa-share-alt:before { + content: "\F1E0"; +} +.fa-share-alt-square:before { + content: "\F1E1"; +} +.fa-bomb:before { + content: "\F1E2"; +} +.fa-soccer-ball-o:before, +.fa-futbol-o:before { + content: "\F1E3"; +} +.fa-tty:before { + content: "\F1E4"; +} +.fa-binoculars:before { + content: "\F1E5"; +} +.fa-plug:before { + content: "\F1E6"; +} +.fa-slideshare:before { + content: "\F1E7"; +} +.fa-twitch:before { + content: "\F1E8"; +} +.fa-yelp:before { + content: "\F1E9"; +} +.fa-newspaper-o:before { + content: "\F1EA"; +} +.fa-wifi:before { + content: "\F1EB"; +} +.fa-calculator:before { + content: "\F1EC"; +} +.fa-paypal:before { + content: "\F1ED"; +} +.fa-google-wallet:before { + content: "\F1EE"; +} +.fa-cc-visa:before { + content: "\F1F0"; +} +.fa-cc-mastercard:before { + content: "\F1F1"; +} +.fa-cc-discover:before { + content: "\F1F2"; +} +.fa-cc-amex:before { + content: "\F1F3"; +} +.fa-cc-paypal:before { + content: "\F1F4"; +} +.fa-cc-stripe:before { + content: "\F1F5"; +} +.fa-bell-slash:before { + content: "\F1F6"; +} +.fa-bell-slash-o:before { + content: "\F1F7"; +} +.fa-trash:before { + content: "\F1F8"; +} +.fa-copyright:before { + content: "\F1F9"; +} +.fa-at:before { + content: "\F1FA"; +} +.fa-eyedropper:before { + content: "\F1FB"; +} +.fa-paint-brush:before { + content: "\F1FC"; +} +.fa-birthday-cake:before { + content: "\F1FD"; +} +.fa-area-chart:before { + content: "\F1FE"; +} +.fa-pie-chart:before { + content: "\F200"; +} +.fa-line-chart:before { + content: "\F201"; +} +.fa-lastfm:before { + content: "\F202"; +} +.fa-lastfm-square:before { + content: "\F203"; +} +.fa-toggle-off:before { + content: "\F204"; +} +.fa-toggle-on:before { + content: "\F205"; +} +.fa-bicycle:before { + content: "\F206"; +} +.fa-bus:before { + content: "\F207"; +} +.fa-ioxhost:before { + content: "\F208"; +} +.fa-angellist:before { + content: "\F209"; +} +.fa-cc:before { + content: "\F20A"; +} +.fa-shekel:before, +.fa-sheqel:before, +.fa-ils:before { + content: "\F20B"; +} +.fa-meanpath:before { + content: "\F20C"; +} +.fa-buysellads:before { + content: "\F20D"; +} +.fa-connectdevelop:before { + content: "\F20E"; +} +.fa-dashcube:before { + content: "\F210"; +} +.fa-forumbee:before { + content: "\F211"; +} +.fa-leanpub:before { + content: "\F212"; +} +.fa-sellsy:before { + content: "\F213"; +} +.fa-shirtsinbulk:before { + content: "\F214"; +} +.fa-simplybuilt:before { + content: "\F215"; +} +.fa-skyatlas:before { + content: "\F216"; +} +.fa-cart-plus:before { + content: "\F217"; +} +.fa-cart-arrow-down:before { + content: "\F218"; +} +.fa-diamond:before { + content: "\F219"; +} +.fa-ship:before { + content: "\F21A"; +} +.fa-user-secret:before { + content: "\F21B"; +} +.fa-motorcycle:before { + content: "\F21C"; +} +.fa-street-view:before { + content: "\F21D"; +} +.fa-heartbeat:before { + content: "\F21E"; +} +.fa-venus:before { + content: "\F221"; +} +.fa-mars:before { + content: "\F222"; +} +.fa-mercury:before { + content: "\F223"; +} +.fa-intersex:before, +.fa-transgender:before { + content: "\F224"; +} +.fa-transgender-alt:before { + content: "\F225"; +} +.fa-venus-double:before { + content: "\F226"; +} +.fa-mars-double:before { + content: "\F227"; +} +.fa-venus-mars:before { + content: "\F228"; +} +.fa-mars-stroke:before { + content: "\F229"; +} +.fa-mars-stroke-v:before { + content: "\F22A"; +} +.fa-mars-stroke-h:before { + content: "\F22B"; +} +.fa-neuter:before { + content: "\F22C"; +} +.fa-genderless:before { + content: "\F22D"; +} +.fa-facebook-official:before { + content: "\F230"; +} +.fa-pinterest-p:before { + content: "\F231"; +} +.fa-whatsapp:before { + content: "\F232"; +} +.fa-server:before { + content: "\F233"; +} +.fa-user-plus:before { + content: "\F234"; +} +.fa-user-times:before { + content: "\F235"; +} +.fa-hotel:before, +.fa-bed:before { + content: "\F236"; +} +.fa-viacoin:before { + content: "\F237"; +} +.fa-train:before { + content: "\F238"; +} +.fa-subway:before { + content: "\F239"; +} +.fa-medium:before { + content: "\F23A"; +} +.fa-yc:before, +.fa-y-combinator:before { + content: "\F23B"; +} +.fa-optin-monster:before { + content: "\F23C"; +} +.fa-opencart:before { + content: "\F23D"; +} +.fa-expeditedssl:before { + content: "\F23E"; +} +.fa-battery-4:before, +.fa-battery-full:before { + content: "\F240"; +} +.fa-battery-3:before, +.fa-battery-three-quarters:before { + content: "\F241"; +} +.fa-battery-2:before, +.fa-battery-half:before { + content: "\F242"; +} +.fa-battery-1:before, +.fa-battery-quarter:before { + content: "\F243"; +} +.fa-battery-0:before, +.fa-battery-empty:before { + content: "\F244"; +} +.fa-mouse-pointer:before { + content: "\F245"; +} +.fa-i-cursor:before { + content: "\F246"; +} +.fa-object-group:before { + content: "\F247"; +} +.fa-object-ungroup:before { + content: "\F248"; +} +.fa-sticky-note:before { + content: "\F249"; +} +.fa-sticky-note-o:before { + content: "\F24A"; +} +.fa-cc-jcb:before { + content: "\F24B"; +} +.fa-cc-diners-club:before { + content: "\F24C"; +} +.fa-clone:before { + content: "\F24D"; +} +.fa-balance-scale:before { + content: "\F24E"; +} +.fa-hourglass-o:before { + content: "\F250"; +} +.fa-hourglass-1:before, +.fa-hourglass-start:before { + content: "\F251"; +} +.fa-hourglass-2:before, +.fa-hourglass-half:before { + content: "\F252"; +} +.fa-hourglass-3:before, +.fa-hourglass-end:before { + content: "\F253"; +} +.fa-hourglass:before { + content: "\F254"; +} +.fa-hand-grab-o:before, +.fa-hand-rock-o:before { + content: "\F255"; +} +.fa-hand-stop-o:before, +.fa-hand-paper-o:before { + content: "\F256"; +} +.fa-hand-scissors-o:before { + content: "\F257"; +} +.fa-hand-lizard-o:before { + content: "\F258"; +} +.fa-hand-spock-o:before { + content: "\F259"; +} +.fa-hand-pointer-o:before { + content: "\F25A"; +} +.fa-hand-peace-o:before { + content: "\F25B"; +} +.fa-trademark:before { + content: "\F25C"; +} +.fa-registered:before { + content: "\F25D"; +} +.fa-creative-commons:before { + content: "\F25E"; +} +.fa-gg:before { + content: "\F260"; +} +.fa-gg-circle:before { + content: "\F261"; +} +.fa-tripadvisor:before { + content: "\F262"; +} +.fa-odnoklassniki:before { + content: "\F263"; +} +.fa-odnoklassniki-square:before { + content: "\F264"; +} +.fa-get-pocket:before { + content: "\F265"; +} +.fa-wikipedia-w:before { + content: "\F266"; +} +.fa-safari:before { + content: "\F267"; +} +.fa-chrome:before { + content: "\F268"; +} +.fa-firefox:before { + content: "\F269"; +} +.fa-opera:before { + content: "\F26A"; +} +.fa-internet-explorer:before { + content: "\F26B"; +} +.fa-tv:before, +.fa-television:before { + content: "\F26C"; +} +.fa-contao:before { + content: "\F26D"; +} +.fa-500px:before { + content: "\F26E"; +} +.fa-amazon:before { + content: "\F270"; +} +.fa-calendar-plus-o:before { + content: "\F271"; +} +.fa-calendar-minus-o:before { + content: "\F272"; +} +.fa-calendar-times-o:before { + content: "\F273"; +} +.fa-calendar-check-o:before { + content: "\F274"; +} +.fa-industry:before { + content: "\F275"; +} +.fa-map-pin:before { + content: "\F276"; +} +.fa-map-signs:before { + content: "\F277"; +} +.fa-map-o:before { + content: "\F278"; +} +.fa-map:before { + content: "\F279"; +} +.fa-commenting:before { + content: "\F27A"; +} +.fa-commenting-o:before { + content: "\F27B"; +} +.fa-houzz:before { + content: "\F27C"; +} +.fa-vimeo:before { + content: "\F27D"; +} +.fa-black-tie:before { + content: "\F27E"; +} +.fa-fonticons:before { + content: "\F280"; +} +.fa-file-new-o:before { + content: "\F016"; +} +.fa-file-new-o:after { + content: "\F067"; + position: relative; + margin-left: -1em; + font-size: 0.5em; +} +.fa-success:before { + content: "\F00C"; +} +.fa-danger:before { + content: "\F06A"; +} +.navbar { + border-width: 0; + box-shadow: inset 0 -10px 10px -12px #333333; + -moz-box-shadow: inset 0 -10px 10px -12px #333333; + -webkit-box-shadow: inset 0 -10px 10px -12px #333333; +} +.navbar-btn-link { + height: 45px; + margin: 0; + border-radius: 0; +} +@media (max-width: 768px) { + .navbar-btn-link { + width: 100%; + text-align: left; + } +} +.navbar-default .badge { + background-color: #ffffff; + color: #656a76; +} +.navbar-inverse .logo { + height: 45px; + width: 150px; + background-color: #3c3c3c; +} +.navbar-inverse .logo-small { + height: 45px; + width: 45px; + background-color: #3c3c3c; +} +.navbar-inverse .badge { + background-color: #ffffff; + color: #3c3c3c; +} +.navbar .navbar-nav > .active > a { + border-bottom-color: #ffffff; +} +.navbar .navbar-nav > .active > a:before { + content: ""; + display: inline-block; + position: absolute; + border: 7px solid transparent; + border-bottom-color: inherit; + top: 31px; + left: 0; + right: 0; + margin: 0 auto; + width: 0; + height: 0; +} +@media (max-width: 768px) { + .navbar .navbar-nav > .active > a:before { + display: none !important; + } +} +.navbar-brand { + cursor: default; + font-size: 1.8em; + background-color: #3c3c3c; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.navbar-nav { + font-size: 12px; +} +.navbar-toggle { + margin-top: 4px; +} +.btn:active { + box-shadow: none; +} +.btn-group.open .dropdown-toggle { + box-shadow: none; +} +/* Small devices (tablets, 768px and smaller) */ +@media (max-width: 768px) { + .btn { + /* Fixes an issue with buttons not respecting the bounds of the screen */ + white-space: normal; + } +} +.text-primary, +.text-primary:hover { + color: #444444; +} +.text-success, +.text-success:hover { + color: #31c471; +} +.text-danger, +.text-danger:hover { + color: #e74c3c; +} +.text-warning, +.text-warning:hover { + color: #f39c12; +} +.text-info, +.text-info:hover { + color: #1f6b7a; +} +table a, +.table a { + text-decoration: underline; +} +table .success, +.table .success, +table .warning, +.table .warning, +table .danger, +.table .danger, +table .info, +.table .info { + color: #ffffff; +} +table .success a, +.table .success a, +table .warning a, +.table .warning a, +table .danger a, +.table .danger a, +table .info a, +.table .info a { + color: #ffffff; +} +table-bordered > thead > tr > th, +.table-bordered > thead > tr > th, +table-bordered > tbody > tr > th, +.table-bordered > tbody > tr > th, +table-bordered > tfoot > tr > th, +.table-bordered > tfoot > tr > th, +table-bordered > thead > tr > td, +.table-bordered > thead > tr > td, +table-bordered > tbody > tr > td, +.table-bordered > tbody > tr > td, +table-bordered > tfoot > tr > td, +.table-bordered > tfoot > tr > td { + border: 1px solid #ecf0f1; +} +.form-control, +input { + border-width: 2px; + box-shadow: none; +} +.form-control:focus, +input:focus { + box-shadow: none; +} +.has-warning .help-block, +.has-warning .control-label, +.has-warning .radio, +.has-warning .checkbox, +.has-warning .radio-inline, +.has-warning .checkbox-inline, +.has-warning .form-control-feedback { + color: #f39c12; +} +.has-warning .form-control, +.has-warning .form-control:focus { + border: 2px solid; + border-color: #f39c12; +} +.has-warning .input-group-addon { + border-color: #f39c12; +} +.has-error .help-block, +.has-error .control-label, +.has-error .radio, +.has-error .checkbox, +.has-error .radio-inline, +.has-error .checkbox-inline, +.has-error .form-control-feedback { + color: #e74c3c; +} +.has-error .form-control, +.has-error .form-control:focus { + border: 2px solid; + border-color: #e74c3c; +} +.has-error .input-group-addon { + border-color: #e74c3c; +} +.has-success .help-block, +.has-success .control-label, +.has-success .radio, +.has-success .checkbox, +.has-success .radio-inline, +.has-success .checkbox-inline, +.has-success .form-control-feedback { + color: #31c471; +} +.has-success .form-control, +.has-success .form-control:focus { + border: solid #31c471; +} +.has-success .input-group-addon { + border-color: #31c471; +} +.nav .open > a, +.nav .open > a:hover, +.nav .open > a:focus { + border-color: transparent; +} +.pager a, +.pager a:hover { + color: #ffffff; +} +.pager .disabled > a, +.pager .disabled > a:hover, +.pager .disabled > a:focus, +.pager .disabled > span { + background-color: rgba(38, 38, 38, 0); +} +.panel { + border-radius: 0; + box-shadow: 0 0 0 rgba(0, 0, 0, 0); +} +.alert a, +.alert .alert-link { + color: #ffffff; + text-decoration: underline; +} +.alert .close { + color: #ffffff; + text-decoration: none; + opacity: 0.4; +} +.alert .close:hover, +.alert .close:focus { + color: #ffffff; + opacity: 1; +} +.progress { + box-shadow: none; +} +.progress .progress-bar { + font-size: 10px; + line-height: 10px; +} +.well { + box-shadow: none; +} +.thumbnail > img, +.thumbnail a > img, +.carousel-inner > .item > img, +.carousel-inner > .item > a > img { + display: block; + max-width: 100%; + height: auto; +} +.btn-group-lg > .btn { + padding: 18px 27px; + font-size: 17px; + line-height: 1.33; + border-radius: 6px; +} +.btn-group-sm > .btn { + padding: 6px 9px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +.btn-group-xs > .btn { + padding: 1px 5px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +.dl-horizontal dd:before, +.dl-horizontal dd:after, +.container:before, +.container:after, +.container-fluid:before, +.container-fluid:after, +.row:before, +.row:after, +.form-horizontal .form-group:before, +.form-horizontal .form-group:after, +.btn-toolbar:before, +.btn-toolbar:after, +.btn-group-vertical > .btn-group:before, +.btn-group-vertical > .btn-group:after, +.nav:before, +.nav:after, +.navbar:before, +.navbar:after, +.navbar-header:before, +.navbar-header:after, +.navbar-collapse:before, +.navbar-collapse:after, +.pager:before, +.pager:after, +.panel-body:before, +.panel-body:after, +.modal-footer:before, +.modal-footer:after { + content: " "; + display: table; +} +.dl-horizontal dd:after, +.container:after, +.container-fluid:after, +.row:after, +.form-horizontal .form-group:after, +.btn-toolbar:after, +.btn-group-vertical > .btn-group:after, +.nav:after, +.navbar:after, +.navbar-header:after, +.navbar-collapse:after, +.pager:after, +.panel-body:after, +.modal-footer:after { + clear: both; +} +html, +body { + -webkit-box-flex: 1; + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + height: 100%; + margin: 0px; +} +html > *, +body > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +label > small { + font-weight: normal; +} +button { + display: inline-block; + margin-bottom: 0; + font-weight: normal; + text-align: center; + vertical-align: middle; + -ms-touch-action: manipulation; + touch-action: manipulation; + cursor: pointer; + background-image: none; + border: 1px solid transparent; + white-space: nowrap; + padding: 5px 15px; + font-size: 13px; + line-height: 1.42857143; + border-radius: 4px; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +button:focus, +button:active:focus, +button.active:focus, +button.focus, +button:active.focus, +button.active.focus { + outline: thin dotted; + outline: 5px auto -webkit-focus-ring-color; + outline-offset: -2px; +} +button:hover, +button:focus, +button.focus { + color: #ffffff; + text-decoration: none; +} +button:active, +button.active { + outline: 0; + background-image: none; + box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); +} +button.disabled, +button[disabled], +fieldset[disabled] button { + cursor: not-allowed; + opacity: 0.65; + filter: alpha(opacity=65); + box-shadow: none; +} +abutton.disabled, +fieldset[disabled] abutton { + pointer-events: none; +} +.small { + font-size: 0.9em !important; +} +.smaller { + font-size: 0.8em !important; +} +.smallest { + font-size: 0.7em !important; +} +.text-color-primary { + color: #444444; +} +.text-color-info { + color: #1f6b7a; +} +.text-color-success { + color: #31c471; +} +.text-color-warning { + color: #f39c12; +} +.text-color-danger { + color: #e74c3c; +} +.text-monospace { + font-family: Menlo, Monaco, Consolas, "Courier New", monospace; +} +code { + word-break: break-all; + word-wrap: break-word; +} +ul.navbar-inline li { + display: inline; +} +.tooltip { + font-size: 8pt; + font-weight: normal; + opacity: 90%; +} +.tooltip-inner { + word-break: normal; + word-wrap: break-word; + white-space: normal; +} +.content { + -webkit-box-flex: 1; + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + position: relative; + z-index: 0; +} +.content > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +.content > nav { + position: relative; + z-index: 1; +} +.content > nav .navbar-right { + margin-right: 0; +} +.application { + -webkit-box-flex: 1; + -webkit-flex: 1 0 auto; + -ms-flex: 1 0 auto; + flex: 1 0 auto; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + position: relative; + z-index: 0; +} +.application > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +.top-fixed { + position: fixed; + bottom: 0px; +} +.checkbox label { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + padding-left: 0; +} +.checkbox label input[type="checkbox"] { + float: none; + margin: 0 4px; + position: static; +} +notifications { + z-index: 1; +} +.navbar { + margin-bottom: 0px!important; +} +a { + cursor: default; +} +[ng-click], +[clip-copy], +[href], +[confirm-click] { + cursor: pointer; +} +.app-container > * { + position: relative; + z-index: 0; +} +.app-container > config { + z-index: 1; +} +.app-container > nav, +.app-container > navbar { + z-index: 2 !important; +} +.nav-condensed > li > a { + padding-top: 2px; + padding-bottom: 2px; +} +.navbar > .container-fluid > .navbar-nav:not(.pull-right):first-child, +.navbar > .container-fluid > .navbar-form:not(.pull-right):first-child { + margin-left: -15px; +} +.navbtn { + color: #ffffff; + background-color: #656a76; + border-color: #4d515b; +} +.navbtn:focus, +.navbtn.focus { + color: #ffffff; + background-color: #4d515b; + border-color: #131416; +} +.navbtn:hover { + color: #ffffff; + background-color: #4d515b; + border-color: #31343a; +} +.navbtn:active, +.navbtn.active, +.open > .dropdown-toggle.navbtn { + color: #ffffff; + background-color: #4d515b; + border-color: #31343a; +} +.navbtn:active:hover, +.navbtn.active:hover, +.open > .dropdown-toggle.navbtn:hover, +.navbtn:active:focus, +.navbtn.active:focus, +.open > .dropdown-toggle.navbtn:focus, +.navbtn:active.focus, +.navbtn.active.focus, +.open > .dropdown-toggle.navbtn.focus { + color: #ffffff; + background-color: #3d4047; + border-color: #131416; +} +.navbtn:active, +.navbtn.active, +.open > .dropdown-toggle.navbtn { + background-image: none; +} +.navbtn.disabled, +.navbtn[disabled], +fieldset[disabled] .navbtn, +.navbtn.disabled:hover, +.navbtn[disabled]:hover, +fieldset[disabled] .navbtn:hover, +.navbtn.disabled:focus, +.navbtn[disabled]:focus, +fieldset[disabled] .navbtn:focus, +.navbtn.disabled.focus, +.navbtn[disabled].focus, +fieldset[disabled] .navbtn.focus, +.navbtn.disabled:active, +.navbtn[disabled]:active, +fieldset[disabled] .navbtn:active, +.navbtn.disabled.active, +.navbtn[disabled].active, +fieldset[disabled] .navbtn.active { + background-color: #656a76; + border-color: #4d515b; +} +.navbtn .badge { + color: #656a76; + background-color: #ffffff; +} +.navbtn-inverse { + color: #ffffff; + background-color: #656a76; + border-color: #4d515b; +} +.navbtn-inverse:focus, +.navbtn-inverse.focus { + color: #ffffff; + background-color: #4d515b; + border-color: #131416; +} +.navbtn-inverse:hover { + color: #ffffff; + background-color: #4d515b; + border-color: #31343a; +} +.navbtn-inverse:active, +.navbtn-inverse.active, +.open > .dropdown-toggle.navbtn-inverse { + color: #ffffff; + background-color: #4d515b; + border-color: #31343a; +} +.navbtn-inverse:active:hover, +.navbtn-inverse.active:hover, +.open > .dropdown-toggle.navbtn-inverse:hover, +.navbtn-inverse:active:focus, +.navbtn-inverse.active:focus, +.open > .dropdown-toggle.navbtn-inverse:focus, +.navbtn-inverse:active.focus, +.navbtn-inverse.active.focus, +.open > .dropdown-toggle.navbtn-inverse.focus { + color: #ffffff; + background-color: #3d4047; + border-color: #131416; +} +.navbtn-inverse:active, +.navbtn-inverse.active, +.open > .dropdown-toggle.navbtn-inverse { + background-image: none; +} +.navbtn-inverse.disabled, +.navbtn-inverse[disabled], +fieldset[disabled] .navbtn-inverse, +.navbtn-inverse.disabled:hover, +.navbtn-inverse[disabled]:hover, +fieldset[disabled] .navbtn-inverse:hover, +.navbtn-inverse.disabled:focus, +.navbtn-inverse[disabled]:focus, +fieldset[disabled] .navbtn-inverse:focus, +.navbtn-inverse.disabled.focus, +.navbtn-inverse[disabled].focus, +fieldset[disabled] .navbtn-inverse.focus, +.navbtn-inverse.disabled:active, +.navbtn-inverse[disabled]:active, +fieldset[disabled] .navbtn-inverse:active, +.navbtn-inverse.disabled.active, +.navbtn-inverse[disabled].active, +fieldset[disabled] .navbtn-inverse.active { + background-color: #656a76; + border-color: #4d515b; +} +.navbtn-inverse .badge { + color: #656a76; + background-color: #ffffff; +} +.navbar-static-top .navbar-right { + font-size: 12px; +} +.navbar-static-top .navbar-right .loading-spinner { + color: #ffffff; + vertical-align: middle; +} +.navbar-timepicker > li > a { + padding-left: 7px !important; + padding-right: 7px !important; +} +.navbar-timepicker-time-desc > .fa-clock-o { + padding-right: 5px; +} +.navbar-timepicker .fa { + font-size: 16px; + vertical-align: middle; +} +kbn-info i { + cursor: help; +} +.kbn-timepicker .btn-default { + background: transparent; + color: #444444; + border: 0px; + box-shadow: none; + text-shadow: none; +} +.kbn-timepicker .btn-info { + color: #ffffff; + background-color: #1f6b7a; + border-color: #1f6b7a; + text-shadow: none; +} +.kbn-timepicker .btn-info:focus, +.kbn-timepicker .btn-info.focus { + color: #ffffff; + background-color: #154751; + border-color: #051214; +} +.kbn-timepicker .btn-info:hover { + color: #ffffff; + background-color: #154751; + border-color: #134049; +} +.kbn-timepicker .btn-info:active, +.kbn-timepicker .btn-info.active, +.open > .dropdown-toggle.kbn-timepicker .btn-info { + color: #ffffff; + background-color: #154751; + border-color: #134049; +} +.kbn-timepicker .btn-info:active:hover, +.kbn-timepicker .btn-info.active:hover, +.open > .dropdown-toggle.kbn-timepicker .btn-info:hover, +.kbn-timepicker .btn-info:active:focus, +.kbn-timepicker .btn-info.active:focus, +.open > .dropdown-toggle.kbn-timepicker .btn-info:focus, +.kbn-timepicker .btn-info:active.focus, +.kbn-timepicker .btn-info.active.focus, +.open > .dropdown-toggle.kbn-timepicker .btn-info.focus { + color: #ffffff; + background-color: #0d2e35; + border-color: #051214; +} +.kbn-timepicker .btn-info:active, +.kbn-timepicker .btn-info.active, +.open > .dropdown-toggle.kbn-timepicker .btn-info { + background-image: none; +} +.kbn-timepicker .btn-info.disabled, +.kbn-timepicker .btn-info[disabled], +fieldset[disabled] .kbn-timepicker .btn-info, +.kbn-timepicker .btn-info.disabled:hover, +.kbn-timepicker .btn-info[disabled]:hover, +fieldset[disabled] .kbn-timepicker .btn-info:hover, +.kbn-timepicker .btn-info.disabled:focus, +.kbn-timepicker .btn-info[disabled]:focus, +fieldset[disabled] .kbn-timepicker .btn-info:focus, +.kbn-timepicker .btn-info.disabled.focus, +.kbn-timepicker .btn-info[disabled].focus, +fieldset[disabled] .kbn-timepicker .btn-info.focus, +.kbn-timepicker .btn-info.disabled:active, +.kbn-timepicker .btn-info[disabled]:active, +fieldset[disabled] .kbn-timepicker .btn-info:active, +.kbn-timepicker .btn-info.disabled.active, +.kbn-timepicker .btn-info[disabled].active, +fieldset[disabled] .kbn-timepicker .btn-info.active { + background-color: #1f6b7a; + border-color: #1f6b7a; +} +.kbn-timepicker .btn-info .badge { + color: #1f6b7a; + background-color: #ffffff; +} +.kbn-timepicker .btn-info .text-info { + color: #ffffff; +} +.kbn-timepicker .refresh-interval { + padding: 0.2em 0.4em; + border-radius: 3px; +} +.kbn-timepicker .refresh-interval-active { + background-color: #1f6b7a; + color: #ffffff; +} +kbn-table, +.kbn-table { + font-size: 12px; +} +kbn-table th, +.kbn-table th { + white-space: nowrap; + padding-right: 10px; +} +kbn-table th .table-header-move, +.kbn-table th .table-header-move, +kbn-table th .table-header-sortchange, +.kbn-table th .table-header-sortchange { + visibility: hidden; +} +kbn-table th .fa, +.kbn-table th .fa { + font-size: 1.1em; +} +kbn-table th:hover .table-header-move, +.kbn-table th:hover .table-header-move, +kbn-table th:hover .table-header-sortchange, +.kbn-table th:hover .table-header-sortchange { + visibility: visible; +} +table td .fa { + line-height: 1.42857143; +} +saved-object-finder .form-group { + margin-bottom: 0; +} +saved-object-finder .form-group input { + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} +saved-object-finder .list-group-item a { + color: #1f6b7a !important; +} +saved-object-finder .list-group-item a i { + color: #154751 !important; +} +saved-object-finder .list-group-item:first-child { + border-top-right-radius: 0 !important; + border-top-left-radius: 0 !important; +} +saved-object-finder .list-group-item.list-group-no-results p { + margin-bottom: 0 !important; +} +saved-object-finder div.finder-form { + position: relative; +} +saved-object-finder div.finder-form-options { + -webkit-box-flex: 1; + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-box-pack: end; + -webkit-justify-content: flex-end; + -ms-flex-pack: end; + justify-content: flex-end; +} +saved-object-finder div.finder-form-options > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +saved-object-finder span.finder-hit-count { + position: absolute; + right: 10px; + top: 25px; + font-size: 0.85em; +} +saved-object-finder .finder-options { + max-height: 300px; + overflow: auto; + padding: 0; + border-top-right-radius: 0; + border-top-left-radius: 0; +} +saved-object-finder .finder-options > * { + padding: 5px 15px; + margin: 0; +} +saved-object-finder .finder-options > li { + margin-top: -ceil(2.5px); +} +saved-object-finder .finder-options > li:first-child { + margin: 0; +} +saved-object-finder .finder-options > li.active { + background-color: #444444; + color: #ffffff; +} +saved-object-finder .finder-options > li.active a { + color: #ffffff; +} +.config saved-object-finder .finder-options { + margin-bottom: 0; + background: #ffffff; +} +.media-object { + width: 65px; + height: 65px; +} +.input-datetime-format { + font-size: 12px; + color: #b4bcc2; + padding: 5px 15px; +} +button[disabled] { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.form-control[disabled], +.form-control[readonly], +fieldset[disabled] .form-control { + cursor: default; + opacity: .8; +} +.fatal-body { + white-space: pre-wrap; +} +input.ng-invalid.ng-dirty, +input.ng-invalid.ng-touched, +textarea.ng-invalid.ng-dirty, +textarea.ng-invalid.ng-touched, +select.ng-invalid.ng-dirty, +select.ng-invalid.ng-touched { + border-color: #e74c3c !important; +} +input[type="radio"][disabled], +input[type="checkbox"][disabled], +.radio[disabled], +.radio-inline[disabled], +.checkbox[disabled], +.checkbox-inline[disabled], +fieldset[disabled] input[type="radio"], +fieldset[disabled] input[type="checkbox"], +fieldset[disabled] .radio, +fieldset[disabled] .radio-inline, +fieldset[disabled] .checkbox, +fieldset[disabled] .checkbox-inline { + cursor: default; + opacity: .8; +} +textarea { + resize: vertical; +} +.field-collapse-toggle { + color: #999999; + margin-left: 10px !important; +} +style-compile { + display: none; +} +.tooltip-inner { + white-space: pre-wrap !important; +} +filter-bar .confirm { + padding: 8px 10px 4px; + background: #ecf0f1; + border-bottom: 1px solid; + border-bottom-color: #cccccc; +} +filter-bar .confirm ul { + margin-bottom: 0px; +} +filter-bar .confirm li { + display: inline-block; +} +filter-bar .confirm li:first-child { + font-weight: bold; + font-size: 1.2em; +} +filter-bar .confirm li button { + font-size: 0.9em; + padding: 2px 8px; +} +filter-bar .confirm .filter { + position: relative; + display: inline-block; + text-align: center; + min-width: calc(5*(1.414em + 13px)); + font-size: 12px; + background-color: #b4bcc2; + color: #333333; + margin-right: 4px; + margin-bottom: 4px; + max-width: 100%; + padding: 4px 8px; + border-radius: 12px; +} +filter-bar .bar { + padding: 6px 6px 4px 6px; + background: #ecf0f1; + border-bottom: 1px solid; + border-bottom-color: #cccccc; +} +filter-bar .bar-condensed { + padding: 2px 6px 0px 6px !important; + font-size: 0.9em; + background: #dde4e6; +} +filter-bar .bar .ace_editor { + height: 175px; + margin: 15px 0; +} +filter-bar .bar .filter-edit-alias { + margin-top: 15px; +} +filter-bar .bar .filter-link { + position: relative; + display: inline-block; + border: 4px solid transparent; + margin-bottom: 4px; +} +filter-bar .bar .filter-description { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; +} +filter-bar .bar .filter { + position: relative; + display: inline-block; + text-align: center; + min-width: calc(5*(1.414em + 13px)); + font-size: 12px; + background-color: #569f76; + color: #ffffff; + margin-right: 4px; + margin-bottom: 4px; + max-width: 100%; + padding: 4px 8px; + border-radius: 12px; +} +filter-bar .bar .filter:hover > .filter-actions { + display: block; +} +filter-bar .bar .filter:hover > .filter-description { + opacity: 0.15; + background: transparent; + overflow: hidden; +} +filter-bar .bar .filter > .filter-actions { + font-size: 1.1em; + line-height: 1.4em; + position: absolute; + padding: 4px 8px; + top: 0; + left: 0; + width: 100%; + display: none; + text-align: center; + white-space: nowrap; +} +filter-bar .bar .filter > .filter-actions > * { + border-right: 1px solid rgba(255, 255, 255, 0.4); + padding-right: 0; + margin-right: 5px; +} +filter-bar .bar .filter > .filter-actions > *:last-child { + border-right: 0; + padding-right: 0; + margin-right: 0; +} +filter-bar .bar .filter > .filter-actions > * .unpinned { + opacity: 0.7; + filter: alpha(opacity=70); +} +filter-bar .bar .filter.negate { + background-color: #c6675d; +} +filter-bar .bar .filter a { + color: #ffffff; +} +filter-bar .bar .filter.disabled { + opacity: 0.6; + background-image: -webkit-repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 255, 255, 0.3) 10px, rgba(255, 255, 255, 0.3) 20px); + background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 255, 255, 0.3) 10px, rgba(255, 255, 255, 0.3) 20px); +} +filter-bar .bar .filter.disabled:hover span { + text-decoration: none; +} +.cell-hover { + background-color: white; +} +.cell-hover-show { + visibility: hidden; +} +.cell-hover:hover { + background-color: #ecf0f1; + cursor: cell; +} +.cell-hover:hover .cell-hover-show { + visibility: visible; +} +mark, +.mark { + background-color: #fce571; +} +fieldset { + margin: 15px; + padding: 15px; + border: 1px solid #ecf0f1; + border-radius: 4px; +} +[fixed-scroll] { + overflow-x: auto; + padding-bottom: 0px; +} +[fixed-scroll] + .fixed-scroll-scroller { + position: fixed; + bottom: 0px; + overflow-x: auto; + overflow-y: hidden; +} +.list-group .list-group-item.active, +.list-group .list-group-item.active:hover, +.list-group .list-group-item.active:focus { + background-color: #ecf0f1; + cursor: default; +} +.bs-callout-primary { + display: block; + margin: 20px 0; + padding: 15px 30px 15px 15px; + border-left: 5px solid #444444; + background-color: #b7b7b7; +} +.bs-callout-primary h1, +.bs-callout-primary h2, +.bs-callout-primary h3, +.bs-callout-primary h4, +.bs-callout-primary h5, +.bs-callout-primary h6 { + margin-top: 0; + color: #444444; +} +.bs-callout-primary p:last-child { + margin-bottom: 0; +} +.bs-callout-primary code, +.bs-callout-primary .highlight { + background-color: #fff; +} +.bs-callout-danger { + display: block; + margin: 20px 0; + padding: 15px 30px 15px 15px; + border-left: 5px solid #e74c3c; + background-color: #fbdedb; +} +.bs-callout-danger h1, +.bs-callout-danger h2, +.bs-callout-danger h3, +.bs-callout-danger h4, +.bs-callout-danger h5, +.bs-callout-danger h6 { + margin-top: 0; + color: #e74c3c; +} +.bs-callout-danger p:last-child { + margin-bottom: 0; +} +.bs-callout-danger code, +.bs-callout-danger .highlight { + background-color: #fff; +} +.bs-callout-warning { + display: block; + margin: 20px 0; + padding: 15px 30px 15px 15px; + border-left: 5px solid #f39c12; + background-color: #fad9a4; +} +.bs-callout-warning h1, +.bs-callout-warning h2, +.bs-callout-warning h3, +.bs-callout-warning h4, +.bs-callout-warning h5, +.bs-callout-warning h6 { + margin-top: 0; + color: #f39c12; +} +.bs-callout-warning p:last-child { + margin-bottom: 0; +} +.bs-callout-warning code, +.bs-callout-warning .highlight { + background-color: #fff; +} +.bs-callout-info { + display: block; + margin: 20px 0; + padding: 15px 30px 15px 15px; + border-left: 5px solid #1f6b7a; + background-color: #71c9db; +} +.bs-callout-info h1, +.bs-callout-info h2, +.bs-callout-info h3, +.bs-callout-info h4, +.bs-callout-info h5, +.bs-callout-info h6 { + margin-top: 0; + color: #1f6b7a; +} +.bs-callout-info p:last-child { + margin-bottom: 0; +} +.bs-callout-info code, +.bs-callout-info .highlight { + background-color: #fff; +} +.bs-callout-success { + display: block; + margin: 20px 0; + padding: 15px 30px 15px 15px; + border-left: 5px solid #31c471; + background-color: #baeed0; +} +.bs-callout-success h1, +.bs-callout-success h2, +.bs-callout-success h3, +.bs-callout-success h4, +.bs-callout-success h5, +.bs-callout-success h6 { + margin-top: 0; + color: #31c471; +} +.bs-callout-success p:last-child { + margin-bottom: 0; +} +.bs-callout-success code, +.bs-callout-success .highlight { + background-color: #fff; +} +.thumbnail > img, +.thumbnail a > img, +.carousel-inner > .item > img, +.carousel-inner > .item > a > img { + display: block; + max-width: 100%; + height: auto; +} +.btn-group-lg > .btn { + padding: 18px 27px; + font-size: 17px; + line-height: 1.33; + border-radius: 6px; +} +.btn-group-sm > .btn { + padding: 6px 9px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +.btn-group-xs > .btn { + padding: 1px 5px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +.dl-horizontal dd:before, +.dl-horizontal dd:after, +.container:before, +.container:after, +.container-fluid:before, +.container-fluid:after, +.row:before, +.row:after, +.form-horizontal .form-group:before, +.form-horizontal .form-group:after, +.btn-toolbar:before, +.btn-toolbar:after, +.btn-group-vertical > .btn-group:before, +.btn-group-vertical > .btn-group:after, +.nav:before, +.nav:after, +.navbar:before, +.navbar:after, +.navbar-header:before, +.navbar-header:after, +.navbar-collapse:before, +.navbar-collapse:after, +.pager:before, +.pager:after, +.panel-body:before, +.panel-body:after, +.modal-footer:before, +.modal-footer:after, +.config:before, +.config:after { + content: " "; + display: table; +} +.dl-horizontal dd:after, +.container:after, +.container-fluid:after, +.row:after, +.form-horizontal .form-group:after, +.btn-toolbar:after, +.btn-group-vertical > .btn-group:after, +.nav:after, +.navbar:after, +.navbar-header:after, +.navbar-collapse:after, +.pager:after, +.panel-body:after, +.modal-footer:after, +.config:after { + clear: both; +} +.config { + position: relative; + min-height: 45px; + margin-bottom: 0px; + border: 1px solid transparent; + border-width: 0; + box-shadow: inset 0 -10px 10px -12px #333333; + -moz-box-shadow: inset 0 -10px 10px -12px #333333; + -webkit-box-shadow: inset 0 -10px 10px -12px #333333; + background-color: #656a76; + border-color: #4d515b; + z-index: 1000; + border-width: 0 0 1px; + border-bottom: 1px solid; + border-bottom-color: #e6e6e6; +} +@media (min-width: 768px) { + .config { + border-radius: 4px; + } +} +.config-btn-link { + height: 45px; + margin: 0; + border-radius: 0; +} +@media (max-width: 768px) { + .config-btn-link { + width: 100%; + text-align: left; + } +} +.config-default .badge { + background-color: #ffffff; + color: #656a76; +} +.config-inverse .logo { + height: 45px; + width: 252px; + background-color: #3c3c3c; +} +.config-inverse .logo-small { + height: 45px; + width: 45px; + background-color: #3c3c3c; +} +.config-inverse .badge { + background-color: #ffffff; + color: #3c3c3c; +} +.config .navbar-nav > .active > a { + border-bottom-color: #ffffff; +} +.config .navbar-nav > .active > a:before { + content: ""; + display: inline-block; + position: absolute; + border: 7px solid transparent; + border-bottom-color: inherit; + top: 31px; + left: 0; + right: 0; + margin: 0 auto; + width: 0; + height: 0; +} +@media (max-width: 768px) { + .config .navbar-nav > .active > a:before { + display: none !important; + } +} +.config-brand { + cursor: default; + font-size: 1.8em; + background-color: #3c3c3c; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +.config-nav { + font-size: 12px; +} +.config-toggle { + margin-top: 4px; +} +.config .navbar-brand { + color: #ecf0f1; +} +.config .navbar-brand:hover, +.config .navbar-brand:focus { + color: #ffffff; + background-color: transparent; +} +.config .navbar-text { + color: #ffffff; +} +.config .navbar-nav > li > a { + color: #ecf0f1; +} +.config .navbar-nav > li > a:hover, +.config .navbar-nav > li > a:focus { + color: #ffffff; + background-color: transparent; +} +.config .navbar-nav > .active > a, +.config .navbar-nav > .active > a:hover, +.config .navbar-nav > .active > a:focus { + color: #ffffff; + background-color: #4d515b; +} +.config .navbar-nav > .disabled > a, +.config .navbar-nav > .disabled > a:hover, +.config .navbar-nav > .disabled > a:focus { + color: #cccccc; + background-color: transparent; +} +.config .navbar-toggle { + border-color: #4d515b; +} +.config .navbar-toggle:hover, +.config .navbar-toggle:focus { + background-color: #4d515b; +} +.config .navbar-toggle .icon-bar { + background-color: #ffffff; +} +.config .navbar-collapse, +.config .navbar-form { + border-color: #4d515b; +} +.config .navbar-nav > .open > a, +.config .navbar-nav > .open > a:hover, +.config .navbar-nav > .open > a:focus { + background-color: #4d515b; + color: #ffffff; +} +@media (max-width: 767px) { + .config .navbar-nav .open .dropdown-menu > li > a { + color: #ecf0f1; + } + .config .navbar-nav .open .dropdown-menu > li > a:hover, + .config .navbar-nav .open .dropdown-menu > li > a:focus { + color: #ffffff; + background-color: transparent; + } + .config .navbar-nav .open .dropdown-menu > .active > a, + .config .navbar-nav .open .dropdown-menu > .active > a:hover, + .config .navbar-nav .open .dropdown-menu > .active > a:focus { + color: #ffffff; + background-color: #4d515b; + } + .config .navbar-nav .open .dropdown-menu > .disabled > a, + .config .navbar-nav .open .dropdown-menu > .disabled > a:hover, + .config .navbar-nav .open .dropdown-menu > .disabled > a:focus { + color: #cccccc; + background-color: transparent; + } +} +.config .navbar-link { + color: #ecf0f1; +} +.config .navbar-link:hover { + color: #ffffff; +} +.config .btn-link { + color: #ecf0f1; +} +.config .btn-link:hover, +.config .btn-link:focus { + color: #ffffff; +} +.config .btn-link[disabled]:hover, +fieldset[disabled] .config .btn-link:hover, +.config .btn-link[disabled]:focus, +fieldset[disabled] .config .btn-link:focus { + color: #cccccc; +} +@media (min-width: 768px) { + .config { + border-radius: 0; + } +} +.config .config-close { + width: 100%; + background-color: #ecf0f1; + border-radius: 0; + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 5px rgba(0, 0, 0, 0.075); + text-align: center; +} +.config .container-fluid { + padding: 10px 10px; + background-color: #ffffff; +} +.control-group { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-flex-wrap: wrap; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + -webkit-box-align: stretch; + -webkit-align-items: stretch; + -ms-flex-align: stretch; + align-items: stretch; + padding: 5px 15px; + /*** + * components + ***/ +} +.control-group > * { + padding-right: 15px; + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; +} +.control-group > *:last-child { + padding-right: 0; +} +.control-group button { + padding: 5px 15px; + font-size: 13px; + color: #1f6b7a; + background-color: inherit; +} +.control-group button:hover { + color: #ecf0f1; + background-color: #5e5e5e; +} +.control-group button .active, +.control-group button:active, +.control-group button:focus { + color: #b4bcc2; + background-color: #5e5e5e; +} +.control-group button[disabled] { + color: #b4bcc2; + background-color: transparent; +} +.control-group button:focus { + outline-offset: -4px; +} +.control-group .button-group, +.control-group .inline-form .input-group { + margin-bottom: 0px; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; +} +.control-group .button-group > *, +.control-group .inline-form .input-group > * { + border-radius: 0; +} +.control-group .button-group > :first-child, +.control-group .inline-form .input-group > :first-child { + border-bottom-left-radius: 4px; + border-top-left-radius: 4px; +} +.control-group .button-group > :last-child, +.control-group .inline-form .input-group > :last-child { + border-bottom-right-radius: 4px; + border-top-right-radius: 4px; +} +.control-group .inline-form { + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; +} +.control-group .inline-form > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +.control-group .inline-form > .typeahead { + -webkit-box-flex: 1; + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; +} +.control-group .inline-form > .typeahead > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +.control-group .inline-form > .typeahead > .input-group { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-flex: 1; + -webkit-flex: 1 0 auto; + -ms-flex: 1 0 auto; + flex: 1 0 auto; +} +.control-group .inline-form > .typeahead > .input-group > * { + float: none; + height: auto; + width: auto; + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; +} +.control-group .inline-form > .typeahead > .input-group input[type="text"] { + -webkit-box-flex: 1; + -webkit-flex: 1 1 100%; + -ms-flex: 1 1 100%; + flex: 1 1 100%; +} +.control-group > .fill { + -webkit-box-flex: 1; + -webkit-flex: 1 1 1%; + -ms-flex: 1 1 1%; + flex: 1 1 1%; +} +.nav-controls .column { + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; +} +.tab-dashboard.theme-dark { + color: #cecece; + background-color: #1e1b1e; +} +.tab-dashboard.theme-dark a { + color: #b7e2ea; +} +.tab-dashboard.theme-dark a:hover, +.tab-dashboard.theme-dark a:focus { + color: #def2f6; +} +.tab-dashboard.theme-dark .form-control { + color: #cecece; + background-color: #444444; + border-color: #666666; +} +.tab-dashboard.theme-dark .form-control[disabled], +.tab-dashboard.theme-dark .form-control[readonly], +fieldset[disabled] .tab-dashboard.theme-dark .form-control { + background-color: #333333; +} +.tab-dashboard.theme-dark .panel { + background-color: #343434; +} +.tab-dashboard.theme-dark .table > thead > tr > th, +.tab-dashboard.theme-dark .table > tbody > tr > th, +.tab-dashboard.theme-dark .table > tfoot > tr > th, +.tab-dashboard.theme-dark .table > thead > tr > td, +.tab-dashboard.theme-dark .table > tbody > tr > td, +.tab-dashboard.theme-dark .table > tfoot > tr > td { + border-top-color: #5c5c5c; +} +.tab-dashboard.theme-dark .table > thead > tr > th { + border-bottom-color: #5c5c5c; +} +.tab-dashboard.theme-dark .table > tbody + tbody { + border-top-color: #5c5c5c; +} +.tab-dashboard.theme-dark .table .table { + background-color: transparent; +} +.tab-dashboard.theme-dark table th i.fa-sort { + color: #666666; +} +.tab-dashboard.theme-dark table th i.fa-sort-asc, +.tab-dashboard.theme-dark table th i.fa-sort-down { + color: #bbbbbb; +} +.tab-dashboard.theme-dark table th i.fa-sort-desc, +.tab-dashboard.theme-dark table th i.fa-sort-up { + color: #bbbbbb; +} +.tab-dashboard.theme-dark .btn:hover, +.tab-dashboard.theme-dark .btn:focus, +.tab-dashboard.theme-dark .btn.focus { + color: #ffffff; +} +.tab-dashboard.theme-dark .btn .findme { + font-weight: bold; +} +.tab-dashboard.theme-dark .btn-default { + color: #ffffff; + background-color: #777777; + border-color: #777777; +} +.tab-dashboard.theme-dark .btn-default:focus, +.tab-dashboard.theme-dark .btn-default.focus { + color: #ffffff; + background-color: #5e5e5e; + border-color: #373737; +} +.tab-dashboard.theme-dark .btn-default:hover { + color: #ffffff; + background-color: #5e5e5e; + border-color: #585858; +} +.tab-dashboard.theme-dark .btn-default:active, +.tab-dashboard.theme-dark .btn-default.active, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default { + color: #ffffff; + background-color: #5e5e5e; + border-color: #585858; +} +.tab-dashboard.theme-dark .btn-default:active:hover, +.tab-dashboard.theme-dark .btn-default.active:hover, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default:hover, +.tab-dashboard.theme-dark .btn-default:active:focus, +.tab-dashboard.theme-dark .btn-default.active:focus, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default:focus, +.tab-dashboard.theme-dark .btn-default:active.focus, +.tab-dashboard.theme-dark .btn-default.active.focus, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default.focus { + color: #ffffff; + background-color: #4c4c4c; + border-color: #373737; +} +.tab-dashboard.theme-dark .btn-default:active, +.tab-dashboard.theme-dark .btn-default.active, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default { + background-image: none; +} +.tab-dashboard.theme-dark .btn-default.disabled, +.tab-dashboard.theme-dark .btn-default[disabled], +fieldset[disabled] .tab-dashboard.theme-dark .btn-default, +.tab-dashboard.theme-dark .btn-default.disabled:hover, +.tab-dashboard.theme-dark .btn-default[disabled]:hover, +fieldset[disabled] .tab-dashboard.theme-dark .btn-default:hover, +.tab-dashboard.theme-dark .btn-default.disabled:focus, +.tab-dashboard.theme-dark .btn-default[disabled]:focus, +fieldset[disabled] .tab-dashboard.theme-dark .btn-default:focus, +.tab-dashboard.theme-dark .btn-default.disabled.focus, +.tab-dashboard.theme-dark .btn-default[disabled].focus, +fieldset[disabled] .tab-dashboard.theme-dark .btn-default.focus, +.tab-dashboard.theme-dark .btn-default.disabled:active, +.tab-dashboard.theme-dark .btn-default[disabled]:active, +fieldset[disabled] .tab-dashboard.theme-dark .btn-default:active, +.tab-dashboard.theme-dark .btn-default.disabled.active, +.tab-dashboard.theme-dark .btn-default[disabled].active, +fieldset[disabled] .tab-dashboard.theme-dark .btn-default.active { + background-color: #777777; + border-color: #777777; +} +.tab-dashboard.theme-dark .btn-default .badge { + color: #777777; + background-color: #ffffff; +} +.tab-dashboard.theme-dark .btn-primary { + color: #ffffff; + background-color: #777777; + border-color: #777777; +} +.tab-dashboard.theme-dark .btn-primary:focus, +.tab-dashboard.theme-dark .btn-primary.focus { + color: #ffffff; + background-color: #5e5e5e; + border-color: #373737; +} +.tab-dashboard.theme-dark .btn-primary:hover { + color: #ffffff; + background-color: #5e5e5e; + border-color: #585858; +} +.tab-dashboard.theme-dark .btn-primary:active, +.tab-dashboard.theme-dark .btn-primary.active, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary { + color: #ffffff; + background-color: #5e5e5e; + border-color: #585858; +} +.tab-dashboard.theme-dark .btn-primary:active:hover, +.tab-dashboard.theme-dark .btn-primary.active:hover, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary:hover, +.tab-dashboard.theme-dark .btn-primary:active:focus, +.tab-dashboard.theme-dark .btn-primary.active:focus, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary:focus, +.tab-dashboard.theme-dark .btn-primary:active.focus, +.tab-dashboard.theme-dark .btn-primary.active.focus, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary.focus { + color: #ffffff; + background-color: #4c4c4c; + border-color: #373737; +} +.tab-dashboard.theme-dark .btn-primary:active, +.tab-dashboard.theme-dark .btn-primary.active, +.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary { + background-image: none; +} +.tab-dashboard.theme-dark .btn-primary.disabled, +.tab-dashboard.theme-dark .btn-primary[disabled], +fieldset[disabled] .tab-dashboard.theme-dark .btn-primary, +.tab-dashboard.theme-dark .btn-primary.disabled:hover, +.tab-dashboard.theme-dark .btn-primary[disabled]:hover, +fieldset[disabled] .tab-dashboard.theme-dark .btn-primary:hover, +.tab-dashboard.theme-dark .btn-primary.disabled:focus, +.tab-dashboard.theme-dark .btn-primary[disabled]:focus, +fieldset[disabled] .tab-dashboard.theme-dark .btn-primary:focus, +.tab-dashboard.theme-dark .btn-primary.disabled.focus, +.tab-dashboard.theme-dark .btn-primary[disabled].focus, +fieldset[disabled] .tab-dashboard.theme-dark .btn-primary.focus, +.tab-dashboard.theme-dark .btn-primary.disabled:active, +.tab-dashboard.theme-dark .btn-primary[disabled]:active, +fieldset[disabled] .tab-dashboard.theme-dark .btn-primary:active, +.tab-dashboard.theme-dark .btn-primary.disabled.active, +.tab-dashboard.theme-dark .btn-primary[disabled].active, +fieldset[disabled] .tab-dashboard.theme-dark .btn-primary.active { + background-color: #777777; + border-color: #777777; +} +.tab-dashboard.theme-dark .btn-primary .badge { + color: #777777; + background-color: #ffffff; +} +.tab-dashboard.theme-dark .list-group-item { + background-color: #333333; + border-color: #777777; +} +.tab-dashboard.theme-dark a.list-group-item, +.tab-dashboard.theme-dark button.list-group-item { + color: #555555; +} +.tab-dashboard.theme-dark a.list-group-item .list-group-item-heading, +.tab-dashboard.theme-dark button.list-group-item .list-group-item-heading { + color: #333333; +} +.tab-dashboard.theme-dark a.list-group-item:hover, +.tab-dashboard.theme-dark button.list-group-item:hover, +.tab-dashboard.theme-dark a.list-group-item:focus, +.tab-dashboard.theme-dark button.list-group-item:focus { + color: #555555; + background-color: #eeeeee; +} +.tab-dashboard.theme-dark .panel > .panel-body + .table, +.tab-dashboard.theme-dark .panel > .panel-body + .table-responsive, +.tab-dashboard.theme-dark .panel > .table + .panel-body, +.tab-dashboard.theme-dark .panel > .table-responsive + .panel-body { + border-top-color: #5c5c5c; +} +.tab-dashboard.theme-dark .panel-group .panel-heading + .panel-collapse > .panel-body, +.tab-dashboard.theme-dark .panel-group .panel-heading + .panel-collapse > .list-group { + border-top-color: #dddddd; +} +.tab-dashboard.theme-dark .panel-group .panel-footer { + border-top: 0; +} +.tab-dashboard.theme-dark .panel-group .panel-footer + .panel-collapse .panel-body { + border-bottom-color: #dddddd; +} +.tab-dashboard.theme-dark .panel-default { + border-color: #5c5c5c; +} +.tab-dashboard.theme-dark .panel-default > .panel-heading { + color: #eeeeee; + background-color: #272727; + border-color: #5c5c5c; +} +.tab-dashboard.theme-dark .panel-default > .panel-heading + .panel-collapse > .panel-body { + border-top-color: #5c5c5c; +} +.tab-dashboard.theme-dark .panel-default > .panel-heading .badge { + color: #272727; + background-color: #eeeeee; +} +.tab-dashboard.theme-dark .panel-default > .panel-footer + .panel-collapse > .panel-body { + border-bottom-color: #5c5c5c; +} +.tab-dashboard.theme-dark .nav > li > a:hover, +.tab-dashboard.theme-dark .nav > li > a:focus { + background-color: #666666; +} +.tab-dashboard.theme-dark .nav-tabs { + border-bottom: 1px solid #666666; +} +.tab-dashboard.theme-dark .nav-tabs > li > a:hover { + border-color: #777777 #777777 #666666; +} +.tab-dashboard.theme-dark .nav-tabs > li.active > a, +.tab-dashboard.theme-dark .nav-tabs > li.active > a:hover, +.tab-dashboard.theme-dark .nav-tabs > li.active > a:focus { + color: #eeeeee; + background-color: #333333; + border-color: #777777; +} +.tab-dashboard.theme-dark navbar { + color: #ffffff; + background-color: #333333; + border-color: #1a1a1a; +} +.tab-dashboard.theme-dark saved-object-finder .list-group-item a { + color: #cecece !important; +} +.tab-dashboard.theme-dark saved-object-finder .list-group-item a i { + color: #b5b5b5 !important; +} +.tab-dashboard.theme-dark saved-object-finder .finder-options > li.active { + background-color: #999999; + color: #555555; +} +.tab-dashboard.theme-dark saved-object-finder .finder-options > li.active a { + color: #555555; +} +.tab-dashboard.theme-dark .cell-hover { + background-color: transparent; +} +.tab-dashboard.theme-dark .cell-hover:hover { + background-color: #666666; +} +.tab-dashboard.theme-dark .spinner > div { + background-color: #ffffff; +} +.tab-dashboard.theme-dark .agg-table-paginated tr:hover td { + background-color: #707070; +} +.tab-dashboard.theme-dark .agg-table-paginated .cell-hover:hover { + background-color: #666666; +} +.tab-dashboard.theme-dark visualize-spy .visualize-show-spy { + border-top-color: #5c5c5c; +} +.tab-dashboard.theme-dark visualize-spy .visualize-show-spy-tab { + border-color: #5c5c5c; + background: #343434; + color: #888888; +} +.tab-dashboard.theme-dark visualize-spy .visualize-show-spy-tab:hover { + background-color: #666666; + color: #333333; +} +.tab-dashboard.theme-dark .axis line, +.tab-dashboard.theme-dark .axis path { + stroke: #888888; +} +.tab-dashboard.theme-dark .tick text { + fill: #aaaaaa; +} +.tab-dashboard.theme-dark .brush .extent { + stroke: #ffffff; +} +.tab-dashboard.theme-dark .endzone { + fill: #ffffff; +} +.tab-dashboard.theme-dark .legend-col-wrapper .legend-toggle { + background-color: #777777; +} +.tab-dashboard.theme-dark .legend-col-wrapper .legend-toggle:hover { + color: #cecece; + background-color: #6a6a6a; +} +.tab-dashboard.theme-dark .legend-col-wrapper .legend-ul { + border-left-color: #777777; + color: #aaaaaa; +} +.tab-dashboard.theme-dark .legend-value-title { + padding: 3px; +} +.tab-dashboard.theme-dark .legend-value-title:hover { + background-color: #6a6a6a; +} +.tab-dashboard.theme-dark .legend-value-full { + background-color: #6a6a6a; +} +.tab-dashboard.theme-dark .legend-value-details { + border-bottom: 1px solid #777777; +} +.tab-dashboard.theme-dark .legend-value-details .filter-button { + background-color: #777777; +} +.tab-dashboard.theme-dark .legend-value-details .filter-button:hover { + background-color: #6a6a6a; +} +.tab-dashboard.theme-dark .y-axis-title text, +.tab-dashboard.theme-dark .x-axis-title text { + fill: #aaaaaa; +} +.tab-dashboard.theme-dark .chart-title text { + fill: #aaaaaa; +} +.tab-dashboard.theme-dark .tilemap { + border-color: #dddddd; +} +.tab-dashboard.theme-dark .tilemap-legend { + background: #333333; + color: #cccccc; +} +.tab-dashboard.theme-dark .tilemap-legend i { + border-color: #999999; + background: #aaaaaa; +} +.tab-dashboard.theme-dark .tilemap-info { + background: #ffffff; + background: rgba(255, 255, 255, 0.92); +} +.tab-dashboard.theme-dark .tilemap-info h2 { + color: #444444; +} +.tab-dashboard.theme-dark .leaflet-control-fit { + background: #ffffff; + outline: 1px #000000; +} +.tab-dashboard.theme-dark .leaflet-container { + background: #333333 !important; +} +.tab-dashboard.theme-dark .leaflet-popup-content-wrapper { + background: rgba(68, 68, 68, 0.93) !important; + color: #eeeeee !important; +} +.tab-dashboard.theme-dark .leaflet-popup-content table thead tr { + border-bottom-color: #999999; +} +.tab-dashboard.theme-dark .leaflet-popup-content table tbody tr { + border-top-color: #999999; +} +.tab-dashboard.theme-dark img.leaflet-tile { + -webkit-filter: invert(1) brightness(1.75) grayscale(1) contrast(1); + filter: invert(1) brightness(1.75) grayscale(1) contrast(1); +} +.tab-dashboard.theme-dark .leaflet-control-attribution { + background-color: rgba(51, 51, 51, 0.8) !important; + color: #cccccc !important; +} +.tab-dashboard.theme-dark .leaflet-left .leaflet-control a, +.tab-dashboard.theme-dark .leaflet-left .leaflet-control a:hover { + color: #000000; +} +.tab-dashboard.theme-dark .leaflet-left .leaflet-draw-actions a { + background-color: #bbbbbb; +} +.tab-dashboard.theme-dark filter-bar .confirm { + background: #333333; + border-bottom-color: #000000; +} +.tab-dashboard.theme-dark filter-bar .confirm .filter { + background-color: #cccccc; + color: #333333; +} +.tab-dashboard.theme-dark filter-bar .bar { + background: #333333; + border-bottom-color: #000000; +} +.tab-dashboard.theme-dark filter-bar .bar-condensed { + background: #262626; +} +.tab-dashboard.theme-dark filter-bar .bar .filter { + background-color: #569f76; + color: #ffffff; +} +.tab-dashboard.theme-dark filter-bar .bar .filter.negate { + background-color: #c6675d; +} +.tab-dashboard.theme-dark filter-bar .bar .filter a { + color: #ffffff; +} +.tab-dashboard.theme-dark .config { + border-bottom-color: #444444; +} +.tab-dashboard.theme-dark .config .config-close { + background-color: #444444; +} +.tab-dashboard.theme-dark .config .container-fluid { + background-color: #333333; +} +.tab-dashboard.theme-dark .list-group-menu.select-mode a { + color: #b7e2ea; +} +.tab-dashboard.theme-dark .list-group-menu .list-group-menu-item { + color: #cecece; +} +.tab-dashboard.theme-dark .list-group-menu .list-group-menu-item.active { + background-color: #444444; +} +.tab-dashboard.theme-dark .list-group-menu .list-group-menu-item:hover { + background-color: #444444; +} +.tab-dashboard.theme-dark .list-group-menu .list-group-menu-item li { + color: #cecece; +} +.tab-dashboard.theme-dark select { + color: #cecece; + background-color: #444444; +} +.tab-dashboard.theme-dark paginate paginate-controls .pagination-other-pages-list > li.active a { + color: #999999; +} +.tab-dashboard.theme-dark .start-screen { + background-color: #1e1b1e; +} +.tab-dashboard.theme-dark .gridster { + background-color: #1e1b1e; +} +.tab-dashboard.theme-dark .gridster dashboard-panel { + background: #343434; + color: #cecece; +} +.tab-dashboard.theme-dark .gridster dashboard-panel .panel .panel-heading a { + color: #a6a6a6; +} +.tab-dashboard.theme-dark .gridster dashboard-panel .panel .panel-heading a:hover { + color: #a6a6a6; +} +.tab-dashboard.theme-dark .gridster dashboard-panel .panel .panel-heading span.panel-title { + color: #a6a6a6; +} +.tab-dashboard.theme-dark .gridster dashboard-panel .panel .panel-heading i { + color: #a6a6a6; + opacity: 1; +} +.tab-dashboard.theme-dark .gridster dashboard-panel .panel .load-error .fa-exclamation-triangle { + color: #e74c3c; +} +.hintbox { + padding: 10px 12px; + border-radius: 5px; + margin-bottom: 10px; + background-color: #ecf0f1; +} +.hintbox a { + color: #1f6b7a !important; +} +.hintbox a:hover { + color: #444444 !important; +} +.hintbox pre { + background-color: #ffffff; +} +.hintbox-label, +.hintbox-label[ng-click] { + cursor: help; +} +.hintbox ul, +.hintbox ol { + padding-left: 25px; +} +.hintbox > * { + margin: 0; +} +.hintbox > * + * { + margin-top: 10px; +} +.hintbox .table-bordered { + border: 1px solid #bfc9ca; +} +.hintbox .table-bordered > thead > tr > th, +.hintbox .table-bordered > tbody > tr > th, +.hintbox .table-bordered > tfoot > tr > th, +.hintbox .table-bordered > thead > tr > td, +.hintbox .table-bordered > tbody > tr > td, +.hintbox .table-bordered > tfoot > tr > td { + border: 1px solid #bfc9ca; +} +.hintbox .table-bordered > thead > tr > th, +.hintbox .table-bordered > thead > tr > td { + border-bottom-width: 2px; +} +i.input-error { + position: absolute; + margin-left: -25px; + color: #e74c3c; + margin-top: 10px; + z-index: 5; +} +select { + color: #444444; + background-color: #ffffff; +} +.thumbnail > img, +.thumbnail a > img, +.carousel-inner > .item > img, +.carousel-inner > .item > a > img { + display: block; + max-width: 100%; + height: auto; +} +.btn-group-lg > .btn { + padding: 18px 27px; + font-size: 17px; + line-height: 1.33; + border-radius: 6px; +} +.btn-group-sm > .btn { + padding: 6px 9px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +.btn-group-xs > .btn { + padding: 1px 5px; + font-size: 12px; + line-height: 1.5; + border-radius: 3px; +} +.dl-horizontal dd:before, +.dl-horizontal dd:after, +.container:before, +.container:after, +.container-fluid:before, +.container-fluid:after, +.row:before, +.row:after, +.form-horizontal .form-group:before, +.form-horizontal .form-group:after, +.btn-toolbar:before, +.btn-toolbar:after, +.btn-group-vertical > .btn-group:before, +.btn-group-vertical > .btn-group:after, +.nav:before, +.nav:after, +.navbar:before, +.navbar:after, +.navbar-header:before, +.navbar-header:after, +.navbar-collapse:before, +.navbar-collapse:after, +.pager:before, +.pager:after, +.panel-body:before, +.panel-body:after, +.modal-footer:before, +.modal-footer:after { + content: " "; + display: table; +} +.dl-horizontal dd:after, +.container:after, +.container-fluid:after, +.row:after, +.form-horizontal .form-group:after, +.btn-toolbar:after, +.btn-group-vertical > .btn-group:after, +.nav:after, +.navbar:after, +.navbar-header:after, +.navbar-collapse:after, +.pager:after, +.panel-body:after, +.modal-footer:after { + clear: both; +} +.list-group-menu.select-mode a { + outline: none; + color: #1f6b7a; +} +.list-group-menu .list-group-menu-item { + list-style: none; + color: #1f6b7a; +} +.list-group-menu .list-group-menu-item.active { + font-weight: bold; + background-color: #ecf0f1; +} +.list-group-menu .list-group-menu-item:hover { + background-color: #ecf0f1; +} +.list-group-menu .list-group-menu-item li { + list-style: none; + color: #1f6b7a; +} +.control-group { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-flex-wrap: wrap; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + -webkit-box-align: stretch; + -webkit-align-items: stretch; + -ms-flex-align: stretch; + align-items: stretch; + padding: 5px 15px; + /*** + * components + ***/ +} +.control-group > * { + padding-right: 15px; + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; +} +.control-group > *:last-child { + padding-right: 0; +} +.control-group button { + padding: 5px 15px; + font-size: 13px; + color: #1f6b7a; + background-color: inherit; +} +.control-group button:hover { + color: #ecf0f1; + background-color: #5e5e5e; +} +.control-group button .active, +.control-group button:active, +.control-group button:focus { + color: #b4bcc2; + background-color: #5e5e5e; +} +.control-group button[disabled] { + color: #b4bcc2; + background-color: transparent; +} +.control-group button:focus { + outline-offset: -4px; +} +.control-group .button-group, +.control-group .inline-form .input-group { + margin-bottom: 0px; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; +} +.control-group .button-group > *, +.control-group .inline-form .input-group > * { + border-radius: 0; +} +.control-group .button-group > :first-child, +.control-group .inline-form .input-group > :first-child { + border-bottom-left-radius: 4px; + border-top-left-radius: 4px; +} +.control-group .button-group > :last-child, +.control-group .inline-form .input-group > :last-child { + border-bottom-right-radius: 4px; + border-top-right-radius: 4px; +} +.control-group .inline-form { + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; +} +.control-group .inline-form > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +.control-group .inline-form > .typeahead { + -webkit-box-flex: 1; + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; +} +.control-group .inline-form > .typeahead > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +.control-group .inline-form > .typeahead > .input-group { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-flex: 1; + -webkit-flex: 1 0 auto; + -ms-flex: 1 0 auto; + flex: 1 0 auto; +} +.control-group .inline-form > .typeahead > .input-group > * { + float: none; + height: auto; + width: auto; + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; +} +.control-group .inline-form > .typeahead > .input-group input[type="text"] { + -webkit-box-flex: 1; + -webkit-flex: 1 1 100%; + -ms-flex: 1 1 100%; + flex: 1 1 100%; +} +.control-group > .fill { + -webkit-box-flex: 1; + -webkit-flex: 1 1 1%; + -ms-flex: 1 1 1%; + flex: 1 1 1%; +} +.nav-controls .column { + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; +} +navbar { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; + -webkit-box-orient: horizontal; + -webkit-box-direction: normal; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; + -webkit-flex-wrap: wrap; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + -webkit-box-align: stretch; + -webkit-align-items: stretch; + -ms-flex-align: stretch; + align-items: stretch; + /*** + * components + ***/ + max-height: 340px; + margin-bottom: 0px; + padding: 5px 15px; + color: #ffffff; + background-color: #656a76; + border-style: solid; + border-color: #4d515b; + border-width: 0 0 1px; + z-index: 1000; + /*** + * components + ***/ + /*** + * responsive modifications + ***/ +} +navbar > * { + padding-right: 15px; + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; +} +navbar > *:last-child { + padding-right: 0; +} +navbar button { + padding: 5px 15px; + font-size: 13px; + color: #1f6b7a; + background-color: inherit; +} +navbar button:hover { + color: #ecf0f1; + background-color: #5e5e5e; +} +navbar button .active, +navbar button:active, +navbar button:focus { + color: #b4bcc2; + background-color: #5e5e5e; +} +navbar button[disabled] { + color: #b4bcc2; + background-color: transparent; +} +navbar button:focus { + outline-offset: -4px; +} +navbar .button-group, +navbar .inline-form .input-group { + margin-bottom: 0px; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; +} +navbar .button-group > *, +navbar .inline-form .input-group > * { + border-radius: 0; +} +navbar .button-group > :first-child, +navbar .inline-form .input-group > :first-child { + border-bottom-left-radius: 4px; + border-top-left-radius: 4px; +} +navbar .button-group > :last-child, +navbar .inline-form .input-group > :last-child { + border-bottom-right-radius: 4px; + border-top-right-radius: 4px; +} +navbar .inline-form { + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; +} +navbar .inline-form > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +navbar .inline-form > .typeahead { + -webkit-box-flex: 1; + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; +} +navbar .inline-form > .typeahead > * { + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; +} +navbar .inline-form > .typeahead > .input-group { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-flex: 1; + -webkit-flex: 1 0 auto; + -ms-flex: 1 0 auto; + flex: 1 0 auto; +} +navbar .inline-form > .typeahead > .input-group > * { + float: none; + height: auto; + width: auto; + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; +} +navbar .inline-form > .typeahead > .input-group input[type="text"] { + -webkit-box-flex: 1; + -webkit-flex: 1 1 100%; + -ms-flex: 1 1 100%; + flex: 1 1 100%; +} +navbar > .fill { + -webkit-box-flex: 1; + -webkit-flex: 1 1 1%; + -ms-flex: 1 1 1%; + flex: 1 1 1%; +} +navbar > * { + padding-right: 15px; +} +navbar > .name { + -webkit-align-self: center; + -ms-flex-item-align: center; + align-self: center; + font-size: 17px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} +navbar button { + color: #ecf0f1; + background-color: transparent; +} +navbar button:hover { + color: #ffffff; + background-color: transparent; +} +navbar button:focus { + color: #ecf0f1; + background-color: transparent; +} +navbar button:active, +navbar button.active { + color: #ffffff; + background-color: #4d515b; +} +navbar button[disabled] { + color: #cccccc; + background-color: transparent; +} +navbar .inline-form .input-group button { + color: #444444; + background-color: #ecf0f1; + border: 2px solid; + border-left: 0; + border-color: #ecf0f1; +} +@media (min-width: 992px) { + navbar > .name { + max-width: 500px; + } +} +@media (max-width: 992px) { + navbar > .fill { + -webkit-box-flex: 1; + -webkit-flex: 1 1 992px; + -ms-flex: 1 1 992px; + flex: 1 1 992px; + } +} +@media (max-width: 768px) { + navbar > .name { + max-width: 100%; + } +} +.toaster-container { + visibility: visible; + width: 100%; +} +.toaster-container .toaster { + margin: 0; + padding: 0; + list-style: none; +} +.toaster-container .alert { + padding: 0 15px; + margin: 0; + border-radius: 0; + border: 0px; +} +.toaster-container .toast { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; +} +.toaster-container .toast > * { + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; +} +.toaster-container .toast > *:not(:last-child) { + margin-right: 4px; +} +.toaster-container .toast-message { + -webkit-box-flex: 1; + -webkit-flex: 1 1 auto; + -ms-flex: 1 1 auto; + flex: 1 1 auto; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + line-height: normal; +} +.toaster-container .toast-stack { + padding-bottom: 10px; +} +.toaster-container .toast-stack pre { + display: inline-block; + width: 100%; + margin: 10px 0; + word-break: normal; + word-wrap: normal; + white-space: pre-wrap; +} +.toaster-container .toast-controls { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; +} +.toaster-container .toast-controls button { + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; + border: 0; + border-radius: 0; + padding: 10px 15px; +} +.toaster-container .alert-success .badge { + background: #185e36; +} +.toaster-container .alert-info .badge { + background: #051214; +} +.toaster-container .alert-warning .badge { + background: #7f5006; +} +.toaster-container .alert-danger .badge { + background: #921e12; +} +paginate { + display: block; +} +paginate paginate-controls { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -webkit-align-items: center; + -ms-flex-align: center; + align-items: center; + padding: 5px 5px 10px; + text-align: center; +} +paginate paginate-controls .pagination-other-pages { + -webkit-box-flex: 1; + -webkit-flex: 1 0 auto; + -ms-flex: 1 0 auto; + flex: 1 0 auto; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; +} +paginate paginate-controls .pagination-other-pages-list { + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + padding: 0; + margin: 0; + list-style: none; +} +paginate paginate-controls .pagination-other-pages-list > li { + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} +paginate paginate-controls .pagination-other-pages-list > li a { + text-decoration: none; +} +paginate paginate-controls .pagination-other-pages-list > li a:hover { + text-decoration: underline; +} +paginate paginate-controls .pagination-other-pages-list > li.active a { + text-decoration: none !important; + font-weight: bold; + color: #444444; +} +paginate paginate-controls .pagination-size { + -webkit-box-flex: 0; + -webkit-flex: 0 0 auto; + -ms-flex: 0 0 auto; + flex: 0 0 auto; +} +paginate paginate-controls .pagination-size input[type=number] { + width: 3em; +} +.sidebar-container { + padding-left: 0px !important; + padding-right: 0px !important; + background-color: #ecf0f1; + border-right-color: transparent; + border-bottom-color: transparent; +} +.sidebar-container .sidebar-well { + background-color: #dde4e6; +} +.sidebar-container .sidebar-list ul { + list-style: none; + margin-bottom: 0px; +} +.sidebar-container .sidebar-list-header { + padding-left: 10px; + padding-right: 10px; + color: #444444; + border: 1px solid; + border-color: transparent; +} +.sidebar-container .sidebar-list .sidebar-item { + border-top-color: transparent; + font-size: 12px; +} +.sidebar-container .sidebar-list .sidebar-item a:not(.sidebar-item-button) { + color: #444444; +} +.sidebar-container .sidebar-list .sidebar-item a:not(.sidebar-item-button):hover { + color: #444444; + text-decoration: none; +} +.sidebar-container .sidebar-list .sidebar-item-title, +.sidebar-container .sidebar-list .sidebar-item-text, +.sidebar-container .sidebar-list .sidebar-item-button { + margin: 0; + padding: 5px 10px; + text-align: center; + width: 100%; + border: none; + border-radius: 0; +} +.sidebar-container .sidebar-list .sidebar-item-title { + text-align: left; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} +.sidebar-container .sidebar-list .sidebar-item-title.full-title { + white-space: normal; +} +.sidebar-container .sidebar-list .sidebar-item-title:hover, +.sidebar-container .sidebar-list .sidebar-item-title:hover .text-muted { + color: #444444; + background-color: #cfd9db; +} +.sidebar-container .sidebar-list .sidebar-item-text { + background: #ffffff; +} +.sidebar-container .sidebar-list .sidebar-item-button { + font-size: inherit; + display: block; +} +.sidebar-container .sidebar-list .sidebar-item-button[disabled] { + opacity: 0.65; + cursor: default; +} +.sidebar-container .sidebar-list .sidebar-item-button.primary { + background-color: #444444; + color: #ffffff; +} +.sidebar-container .sidebar-list .sidebar-item-button.info { + background-color: #1f6b7a; + color: #ffffff; +} +.sidebar-container .sidebar-list .sidebar-item-button.success { + background-color: #31c471; + color: #ffffff; +} +.sidebar-container .sidebar-list .sidebar-item-button.warning { + background-color: #f39c12; + color: #ffffff; +} +.sidebar-container .sidebar-list .sidebar-item-button.danger { + background-color: #e74c3c; + color: #ffffff; +} +.sidebar-container .sidebar-list .sidebar-item-button.default { + color: #ffffff; + background-color: #95a5a6; + border-color: #95a5a6; +} +.sidebar-container .sidebar-list .sidebar-item-button.default:focus, +.sidebar-container .sidebar-list .sidebar-item-button.default.focus { + color: #ffffff; + background-color: #798d8f; + border-color: #566566; +} +.sidebar-container .sidebar-list .sidebar-item-button.default:hover { + color: #ffffff; + background-color: #798d8f; + border-color: #74898a; +} +.sidebar-container .sidebar-list .sidebar-item-button.default:active, +.sidebar-container .sidebar-list .sidebar-item-button.default.active, +.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default { + color: #ffffff; + background-color: #798d8f; + border-color: #74898a; +} +.sidebar-container .sidebar-list .sidebar-item-button.default:active:hover, +.sidebar-container .sidebar-list .sidebar-item-button.default.active:hover, +.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default:hover, +.sidebar-container .sidebar-list .sidebar-item-button.default:active:focus, +.sidebar-container .sidebar-list .sidebar-item-button.default.active:focus, +.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default:focus, +.sidebar-container .sidebar-list .sidebar-item-button.default:active.focus, +.sidebar-container .sidebar-list .sidebar-item-button.default.active.focus, +.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default.focus { + color: #ffffff; + background-color: #687b7c; + border-color: #566566; +} +.sidebar-container .sidebar-list .sidebar-item-button.default:active, +.sidebar-container .sidebar-list .sidebar-item-button.default.active, +.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default { + background-image: none; +} +.sidebar-container .sidebar-list .sidebar-item-button.default.disabled, +.sidebar-container .sidebar-list .sidebar-item-button.default[disabled], +fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default, +.sidebar-container .sidebar-list .sidebar-item-button.default.disabled:hover, +.sidebar-container .sidebar-list .sidebar-item-button.default[disabled]:hover, +fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default:hover, +.sidebar-container .sidebar-list .sidebar-item-button.default.disabled:focus, +.sidebar-container .sidebar-list .sidebar-item-button.default[disabled]:focus, +fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default:focus, +.sidebar-container .sidebar-list .sidebar-item-button.default.disabled.focus, +.sidebar-container .sidebar-list .sidebar-item-button.default[disabled].focus, +fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default.focus, +.sidebar-container .sidebar-list .sidebar-item-button.default.disabled:active, +.sidebar-container .sidebar-list .sidebar-item-button.default[disabled]:active, +fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default:active, +.sidebar-container .sidebar-list .sidebar-item-button.default.disabled.active, +.sidebar-container .sidebar-list .sidebar-item-button.default[disabled].active, +fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default.active { + background-color: #95a5a6; + border-color: #95a5a6; +} +.sidebar-container .sidebar-list .sidebar-item-button.default .badge { + color: #95a5a6; + background-color: #ffffff; +} +.sidebar-container .sidebar-list .sidebar-item .active { + background-color: #444444 !important; + color: #ffffff; +} +.sidebar-container .sidebar-list .sidebar-item .active:hover, +.sidebar-container .sidebar-list .sidebar-item .active:hover .text-muted { + color: #ffffff; + background-color: #444444; +} +.sidebar-container .index-pattern { + background-color: #444444; + font-weight: bold; + padding: 5px 10px; + color: #ffffff; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: justify; + -webkit-justify-content: space-between; + -ms-flex-pack: justify; + justify-content: space-between; +} +.sidebar-container .index-pattern > * { + -webkit-box-flex: 0; + -webkit-flex: 0 1 auto; + -ms-flex: 0 1 auto; + flex: 0 1 auto; +} +.sidebar-container .index-pattern-selection .sidebar-item-title { + background-color: #ffffff; +} +.spinner { + margin: 0px auto 0; + white-space: nowrap; + text-align: center; + display: inline; +} +.spinner > div { + width: 10px; + height: 10px; + background-color: #444444; + border-radius: 100%; + display: inline-block; + -webkit-animation: bouncedelay 1s infinite ease-in-out; + animation: bouncedelay 1s infinite ease-in-out; + /* Prevent first frame from flickering when animation starts */ + -webkit-animation-fill-mode: both; + animation-fill-mode: both; +} +.navbar .spinner > div { + background-color: #ecf0f1; +} +.spinner.large > div { + width: 24px; + height: 24px; +} +.spinner .bounce1 { + -webkit-animation-delay: -0.32s; + animation-delay: -0.32s; +} +.spinner .bounce2 { + -webkit-animation-delay: -0.16s; + animation-delay: -0.16s; +} +@-webkit-keyframes bouncedelay { + 0%, + 80%, + 100% { + -webkit-transform: scale(0); + } + 40% { + -webkit-transform: scale(1); + } +} +@keyframes bouncedelay { + 0%, + 80%, + 100% { + transform: scale(0); + -webkit-transform: scale(0); + } + 40% { + transform: scale(1); + -webkit-transform: scale(1); + } +} +.table .table { + background-color: #ffffff; +} +kbn-table .table .table, +.kbn-table .table .table, +tbody[kbn-rows] .table .table { + margin-bottom: 0px; +} +kbn-table .table .table tr:first-child > td, +.kbn-table .table .table tr:first-child > td, +tbody[kbn-rows] .table .table tr:first-child > td { + border-top: none; +} +kbn-table .table .table td.field-name, +.kbn-table .table .table td.field-name, +tbody[kbn-rows] .table .table td.field-name { + font-weight: bold; +} +kbn-table dl.source, +.kbn-table dl.source, +tbody[kbn-rows] dl.source { + margin-bottom: 0; + line-height: 2em; + word-break: break-all; +} +kbn-table dl.source dt, +.kbn-table dl.source dt, +tbody[kbn-rows] dl.source dt, +kbn-table dl.source dd, +.kbn-table dl.source dd, +tbody[kbn-rows] dl.source dd { + display: inline; +} +kbn-table dl.source dt, +.kbn-table dl.source dt, +tbody[kbn-rows] dl.source dt { + background: #ecf0f1; + color: #444444; + padding: 1px 5px; + margin-right: 5px; + font-family: monospace; + word-break: normal; +} +table th i.fa-sort { + color: #b4bcc2; +} +table th i.fa-sort-asc, +table th i.fa-sort-down { + color: #b4bcc2; +} +table th i.fa-sort-desc, +table th i.fa-sort-up { + color: #b4bcc2; +} +.truncate-by-height { + position: relative; + overflow: hidden; +} +.truncate-by-height:before { + content: " "; + width: 100%; + height: 15px; + position: absolute; + left: 0; + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(1%, rgba(255, 255, 255, 0.01)), color-stop(99%, rgba(255, 255, 255, 0.99)), color-stop(100%, #ffffff)); + background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.01) 1%, rgba(255, 255, 255, 0.99) 99%, #ffffff 100%); + background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.01) 1%, rgba(255, 255, 255, 0.99) 99%, #ffffff 100%); +} diff --git a/metron-docker/mysql/Dockerfile b/metron-docker/mysql/Dockerfile new file mode 100644 index 0000000000..bb2392c506 --- /dev/null +++ b/metron-docker/mysql/Dockerfile @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM mysql:5.7 + +ARG METRON_VERSION + +ENV METRON_VERSION $METRON_VERSION +ENV METRON_HOME /usr/metron/$METRON_VERSION/ + +ADD http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLiteCity-latest.tar.xz /tmp/geoip/GeoLiteCity-latest.tar.xz +ADD ./bin /usr/local/bin +ADD ./enrichment /enrichment + +RUN apt-get update +RUN apt-get install xz-utils +RUN tar xf /tmp/geoip/GeoLiteCity-latest.tar.xz -C /tmp/geoip/ +RUN cp /tmp/geoip/GeoLiteCity_*/* /var/lib/mysql-files +RUN mkdir -p $METRON_HOME +RUN tar -xzf /enrichment/metron-enrichment-$METRON_VERSION-archive.tar.gz -C /usr/metron/$METRON_VERSION/ + +WORKDIR /usr/local +CMD ./bin/start.sh diff --git a/metron-docker/mysql/bin/init-mysql.sh b/metron-docker/mysql/bin/init-mysql.sh new file mode 100755 index 0000000000..8aab2b5842 --- /dev/null +++ b/metron-docker/mysql/bin/init-mysql.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS metronconfig" +mysql -uroot -proot < /usr/metron/$METRON_VERSION/ddl/geoip_ddl.sql diff --git a/metron-docker/mysql/bin/start.sh b/metron-docker/mysql/bin/start.sh new file mode 100755 index 0000000000..26f65f7fb1 --- /dev/null +++ b/metron-docker/mysql/bin/start.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +./bin/docker-entrypoint.sh mysqld & +./bin/wait-for-it.sh localhost:3306 +./bin/init-mysql.sh +tail -f /dev/null \ No newline at end of file diff --git a/metron-docker/mysql/bin/wait-for-it.sh b/metron-docker/mysql/bin/wait-for-it.sh new file mode 100755 index 0000000000..eca6c3b9c8 --- /dev/null +++ b/metron-docker/mysql/bin/wait-for-it.sh @@ -0,0 +1,161 @@ +#!/usr/bin/env bash +# Use this script to test if a given TCP host/port are available + +cmdname=$(basename $0) + +echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } + +usage() +{ + cat << USAGE >&2 +Usage: + $cmdname host:port [-s] [-t timeout] [-- command args] + -h HOST | --host=HOST Host or IP under test + -p PORT | --port=PORT TCP port under test + Alternatively, you specify the host and port as host:port + -s | --strict Only execute subcommand if the test succeeds + -q | --quiet Don't output any status messages + -t TIMEOUT | --timeout=TIMEOUT + Timeout in seconds, zero for no timeout + -- COMMAND ARGS Execute command with args after the test finishes +USAGE + exit 1 +} + +wait_for() +{ + if [[ $TIMEOUT -gt 0 ]]; then + echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" + else + echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" + fi + start_ts=$(date +%s) + while : + do + (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 + result=$? + if [[ $result -eq 0 ]]; then + end_ts=$(date +%s) + echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" + break + fi + sleep 1 + done + return $result +} + +wait_for_wrapper() +{ + # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 + if [[ $QUIET -eq 1 ]]; then + timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & + else + timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & + fi + PID=$! + trap "kill -INT -$PID" INT + wait $PID + RESULT=$? + if [[ $RESULT -ne 0 ]]; then + echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" + fi + return $RESULT +} + +# process arguments +while [[ $# -gt 0 ]] +do + case "$1" in + *:* ) + hostport=(${1//:/ }) + HOST=${hostport[0]} + PORT=${hostport[1]} + shift 1 + ;; + --child) + CHILD=1 + shift 1 + ;; + -q | --quiet) + QUIET=1 + shift 1 + ;; + -s | --strict) + STRICT=1 + shift 1 + ;; + -h) + HOST="$2" + if [[ $HOST == "" ]]; then break; fi + shift 2 + ;; + --host=*) + HOST="${1#*=}" + shift 1 + ;; + -p) + PORT="$2" + if [[ $PORT == "" ]]; then break; fi + shift 2 + ;; + --port=*) + PORT="${1#*=}" + shift 1 + ;; + -t) + TIMEOUT="$2" + if [[ $TIMEOUT == "" ]]; then break; fi + shift 2 + ;; + --timeout=*) + TIMEOUT="${1#*=}" + shift 1 + ;; + --) + shift + CLI="$@" + break + ;; + --help) + usage + ;; + *) + echoerr "Unknown argument: $1" + usage + ;; + esac +done + +if [[ "$HOST" == "" || "$PORT" == "" ]]; then + echoerr "Error: you need to provide a host and port to test." + usage +fi + +TIMEOUT=${TIMEOUT:-15} +STRICT=${STRICT:-0} +CHILD=${CHILD:-0} +QUIET=${QUIET:-0} + +if [[ $CHILD -gt 0 ]]; then + wait_for + RESULT=$? + exit $RESULT +else + if [[ $TIMEOUT -gt 0 ]]; then + wait_for_wrapper + RESULT=$? + else + wait_for + RESULT=$? + fi +fi + +if [[ $CLI != "" ]]; then + if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then + echoerr "$cmdname: strict mode, refusing to execute subprocess" + exit $RESULT + fi + exec $CLI +else + exit $RESULT +fi diff --git a/metron-docker/storm/Dockerfile b/metron-docker/storm/Dockerfile new file mode 100644 index 0000000000..a9fd1de5b0 --- /dev/null +++ b/metron-docker/storm/Dockerfile @@ -0,0 +1,58 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +FROM fhuz/docker-storm:latest + +ARG METRON_VERSION + +ENV METRON_VERSION $METRON_VERSION +ENV METRON_HOME /usr/metron/$METRON_VERSION/ + +ADD ./bin /usr/local/bin +ADD ./parser /parser +ADD ./enrichment /enrichment +ADD ./indexing /indexing +ADD ./elasticsearch /elasticsearch +RUN mkdir -p $METRON_HOME +RUN tar -xzf /parser/metron-parsers-$METRON_VERSION-archive.tar.gz -C /usr/metron/$METRON_VERSION/ + +RUN tar -xzf /enrichment/metron-enrichment-$METRON_VERSION-archive.tar.gz -C /usr/metron/$METRON_VERSION/ +RUN sed -i -e "s/kafka.zk=.*:/kafka.zk=kafkazk:/g" /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN sed -i -e "s/kafka.broker=.*/kafka.broker=kafkazk:9092/g" /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN sed -i -e "s/mysql.ip=.*/mysql.ip=mysql/g" /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN sed -i -e "s/mysql.password=.*/mysql.password=root/g" /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN sed -i -e "s/threat.intel.tracker.table=.*/threat.intel.tracker.table=access_tracker/g" /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN sed -i -e "s/threat.intel.tracker.cf=.*/threat.intel.tracker.cf=cf/g" /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN sed -i -e "s/threat.intel.ip.table=.*/threat.intel.ip.table=ip/g" /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN sed -i -e "s/threat.intel.ip.cf=.*/threat.intel.ip.cf=cf/g" /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN echo "threat.intel.simple.hbase.table=threatintel" >> /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN echo "threat.intel.simple.hbase.cf=cf" >> /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN echo "enrichment.simple.hbase.table=enrichment" >> /usr/metron/$METRON_VERSION/config/enrichment.properties +RUN echo "enrichment.simple.hbase.cf=cf\n" >> /usr/metron/$METRON_VERSION/config/enrichment.properties + +RUN tar -xzf /indexing/metron-indexing-$METRON_VERSION-archive.tar.gz -C /usr/metron/$METRON_VERSION/ + +RUN tar -xzf /elasticsearch/metron-elasticsearch-$METRON_VERSION-archive.tar.gz -C /usr/metron/$METRON_VERSION/ +RUN sed -i -e "s/kafka.zk=.*:/kafka.zk=kafkazk:/g" /usr/metron/$METRON_VERSION/config/elasticsearch.properties +RUN sed -i -e "s/kafka.broker=.*/kafka.broker=kafkazk:9092/g" /usr/metron/$METRON_VERSION/config/elasticsearch.properties +RUN sed -i -e "s/es.ip=.*/es.ip=metron-elasticsearch/g" /usr/metron/$METRON_VERSION/config/elasticsearch.properties +RUN sed -i -e "s/bolt.hdfs.file.system.url=.*:8020/bolt.hdfs.file.system.url=file\:\/\/\//g" /usr/metron/$METRON_VERSION/config/elasticsearch.properties + +EXPOSE 8080 8000 +EXPOSE 8081 8081 + +WORKDIR /usr/local +ENTRYPOINT ["/bin/bash", "./bin/start.sh"] diff --git a/metron-docker/storm/bin/init-storm.sh b/metron-docker/storm/bin/init-storm.sh new file mode 100755 index 0000000000..9c1916b574 --- /dev/null +++ b/metron-docker/storm/bin/init-storm.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +METRON_VERSION=0.3.0 +cd /opt/hbase-1.1.6/conf && jar uf $METRON_HOME/lib/metron-enrichment-$METRON_VERSION-uber.jar hbase-site.xml diff --git a/metron-docker/storm/bin/start.sh b/metron-docker/storm/bin/start.sh new file mode 100755 index 0000000000..e77bb8d6c6 --- /dev/null +++ b/metron-docker/storm/bin/start.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +cd /opt/hbase-1.1.6/conf && jar uf $METRON_HOME/lib/metron-enrichment-$METRON_VERSION-uber.jar hbase-site.xml +/home/storm/entrypoint.sh $@ From d9ea03eeafb6971390899c93bad73ee00216b3f6 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 18 Nov 2016 17:19:13 -0600 Subject: [PATCH 05/54] Cleaned up comments and added newlines to the end of files --- metron-docker/.env | 2 +- metron-docker/.gitignore | 2 +- metron-docker/docker-compose.yml | 13 ------------- metron-docker/hbase/conf/enrichment-extractor.json | 2 +- metron-docker/hbase/conf/hbase-site.docker.xml | 2 +- metron-docker/hbase/conf/threatintel-extractor.json | 2 +- metron-docker/mysql/bin/start.sh | 2 +- 7 files changed, 6 insertions(+), 19 deletions(-) diff --git a/metron-docker/.env b/metron-docker/.env index 95e14bb5c8..fa9dc932a6 100644 --- a/metron-docker/.env +++ b/metron-docker/.env @@ -1,2 +1,2 @@ METRON_VERSION=0.3.0 -COMPOSE_PROJECT_NAME=metron \ No newline at end of file +COMPOSE_PROJECT_NAME=metron diff --git a/metron-docker/.gitignore b/metron-docker/.gitignore index 001e46c9d3..7488ceca74 100644 --- a/metron-docker/.gitignore +++ b/metron-docker/.gitignore @@ -3,4 +3,4 @@ /storm/elasticsearch /storm/enrichment /storm/parser -/storm/indexing \ No newline at end of file +/storm/indexing diff --git a/metron-docker/docker-compose.yml b/metron-docker/docker-compose.yml index 1e2da2bcff..6161eca0c7 100644 --- a/metron-docker/docker-compose.yml +++ b/metron-docker/docker-compose.yml @@ -1,7 +1,6 @@ version: '2' services: mysql: - #container_name: metron-mysql build: context: ./mysql args: @@ -10,10 +9,7 @@ services: - "3306:3306" environment: MYSQL_ROOT_PASSWORD: root -# networks: -# - metron-network kafkazk: - #container_name: metron-kafkazk build: context: ./kafkazk args: @@ -21,10 +17,7 @@ services: ports: - "9092:9092" - "2181:2181" -# networks: -# - metron-network hbase: - # container_name: metron-hbase build: context: ./hbase args: @@ -33,12 +26,9 @@ services: - "16010:16010" volumes: - "/opt/hbase-1.1.6/conf" -# networks: -# - metron-network depends_on: - kafkazk storm: - # container_name: metron-storm build: context: ./storm args: @@ -56,11 +46,8 @@ services: - kafkazk - hbase - elasticsearch -# networks: -# - metron-network command: --daemon nimbus supervisor ui logviewer elasticsearch: - # container_name: metron-elasticsearch image: elasticsearch:2.3 ports: - "9200:9200" diff --git a/metron-docker/hbase/conf/enrichment-extractor.json b/metron-docker/hbase/conf/enrichment-extractor.json index f00b3cf599..322dbfdbb3 100644 --- a/metron-docker/hbase/conf/enrichment-extractor.json +++ b/metron-docker/hbase/conf/enrichment-extractor.json @@ -9,4 +9,4 @@ ,"separator" : "," } ,"extractor" : "CSV" -} \ No newline at end of file +} diff --git a/metron-docker/hbase/conf/hbase-site.docker.xml b/metron-docker/hbase/conf/hbase-site.docker.xml index 2db8b26bed..16a9c65328 100644 --- a/metron-docker/hbase/conf/hbase-site.docker.xml +++ b/metron-docker/hbase/conf/hbase-site.docker.xml @@ -38,4 +38,4 @@ Comma separated list of servers in the ZooKeeper Quorum. - \ No newline at end of file + diff --git a/metron-docker/hbase/conf/threatintel-extractor.json b/metron-docker/hbase/conf/threatintel-extractor.json index 490ef61421..9e32d67aaf 100644 --- a/metron-docker/hbase/conf/threatintel-extractor.json +++ b/metron-docker/hbase/conf/threatintel-extractor.json @@ -8,4 +8,4 @@ "separator": "," }, "extractor": "CSV" -} \ No newline at end of file +} diff --git a/metron-docker/mysql/bin/start.sh b/metron-docker/mysql/bin/start.sh index 26f65f7fb1..e007ed0326 100755 --- a/metron-docker/mysql/bin/start.sh +++ b/metron-docker/mysql/bin/start.sh @@ -18,4 +18,4 @@ ./bin/docker-entrypoint.sh mysqld & ./bin/wait-for-it.sh localhost:3306 ./bin/init-mysql.sh -tail -f /dev/null \ No newline at end of file +tail -f /dev/null From d4ff4703fcc9c84f646bf00653af43a74df3fe9d Mon Sep 17 00:00:00 2001 From: rmerriman Date: Tue, 29 Nov 2016 07:52:24 -0600 Subject: [PATCH 06/54] Initial middleware commit --- metron-interface/metron-rest/pom.xml | 115 ++++++- .../metron/rest/audit/UserRevEntity.java | 31 ++ .../rest/audit/UserRevisionListener.java | 37 ++ .../apache/metron/rest/config/GrokConfig.java | 36 ++ .../metron/rest/config/HadoopConfig.java | 40 +++ .../metron/rest/config/KafkaConfig.java | 60 ++++ .../apache/metron/rest/config/MvcConfig.java | 31 ++ .../rest/config/RestTemplateConfig.java | 34 ++ .../metron/rest/config/StormConfig.java | 45 +++ .../metron/rest/config/SwaggerConfig.java | 39 +++ .../metron/rest/config/WebSecurityConfig.java | 89 +++++ .../metron/rest/config/ZookeeperConfig.java | 9 + .../controller/GlobalConfigController.java | 61 ++++ .../rest/controller/GrokController.java | 48 +++ .../rest/controller/KafkaController.java | 78 +++++ .../SensorEnrichmentConfigController.java | 74 ++++ .../SensorParserConfigController.java | 26 +- .../SensorParserConfigHistoryController.java | 58 ++++ .../rest/controller/StormController.java | 142 ++++++++ .../controller/TransformationController.java | 66 ++++ .../rest/controller/UserController.java | 32 ++ .../metron/rest/model/GrokValidation.java | 51 +++ .../apache/metron/rest/model/KafkaTopic.java | 60 ++++ .../rest/model/ParseMessageRequest.java | 42 +++ .../rest/model/SensorParserConfigHistory.java | 77 +++++ .../rest/model/SensorParserConfigVersion.java | 51 +++ .../model/StellarFunctionDescription.java | 49 +++ .../metron/rest/model/TopologyResponse.java | 42 +++ .../metron/rest/model/TopologyStatus.java | 76 +++++ .../metron/rest/model/TopologyStatusCode.java | 32 ++ .../metron/rest/model/TopologySummary.java | 31 ++ .../rest/model/TransformationValidation.java | 44 +++ .../SensorParserConfigVersionRepository.java | 24 ++ .../rest/service/DockerStormCLIWrapper.java | 70 ++++ .../rest/service/GlobalConfigService.java | 62 ++++ .../metron/rest/service/GrokService.java | 138 ++++++++ .../metron/rest/service/HdfsService.java | 57 ++++ .../metron/rest/service/KafkaService.java | 112 ++++++ .../SensorEnrichmentConfigService.java | 92 +++++ .../SensorParserConfigHistoryService.java | 136 ++++++++ .../service/SensorParserConfigService.java | 94 ++++- .../metron/rest/service/StormCLIWrapper.java | 144 ++++++++ .../metron/rest/service/StormService.java | 183 ++++++++++ .../rest/service/TransformationService.java | 111 ++++++ .../src/main/resources/application-docker.yml | 62 ++++ .../src/main/resources/application-test.yml | 30 +- .../src/main/resources/application.yml | 8 +- .../src/main/resources/log4j.properties | 4 + .../src/main/resources/schema-h2.sql | 30 ++ .../src/main/resources/schema-mysql.sql | 30 ++ .../apache/metron/rest/config/TestConfig.java | 129 +++++++ ...GlobalConfigControllerIntegrationTest.java | 105 ++++++ .../GrokControllerIntegrationTest.java | 112 ++++++ .../KafkaControllerIntegrationTest.java | 186 ++++++++++ ...chmentConfigControllerIntegrationTest.java | 225 ++++++++++++ ...ParserConfigControllerIntegrationTest.java | 213 +++++++----- ...onfigHistoryControllerIntegrationTest.java | 252 ++++++++++++++ .../StormControllerIntegrationTest.java | 320 ++++++++++++++++++ ...ansformationControllerIntegrationTest.java | 120 +++++++ .../UserControllerIntegrationTest.java | 64 ++++ .../rest/generator/SampleDataGenerator.java | 170 ++++++++++ .../rest/mock/MockStormCLIClientWrapper.java | 177 ++++++++++ .../rest/mock/MockStormRestTemplate.java | 116 +++++++ .../metron/rest/service/HdfsServiceTest.java | 115 +++++++ .../rest/service/SensorParserConfigTest.java | 44 ++- metron-interface/pom.xml | 7 +- 66 files changed, 5317 insertions(+), 131 deletions(-) create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevEntity.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevisionListener.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/GrokConfig.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HadoopConfig.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/MvcConfig.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/RestTemplateConfig.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/SwaggerConfig.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/WebSecurityConfig.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/GrokValidation.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/KafkaTopic.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyResponse.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatus.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatusCode.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologySummary.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TransformationValidation.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/repository/SensorParserConfigVersionRepository.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/DockerStormCLIWrapper.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java create mode 100644 metron-interface/metron-rest/src/main/resources/application-docker.yml create mode 100644 metron-interface/metron-rest/src/main/resources/log4j.properties create mode 100644 metron-interface/metron-rest/src/main/resources/schema-h2.sql create mode 100644 metron-interface/metron-rest/src/main/resources/schema-mysql.sql create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorEnrichmentConfigControllerIntegrationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StormControllerIntegrationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/generator/SampleDataGenerator.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index dd84a0c907..066ecff01c 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -18,7 +18,7 @@ org.apache.metron metron-interface - 0.2.1BETA + 0.3.0 metron-rest ${project.parent.version} @@ -30,6 +30,10 @@ 2.7.1 1.6.4 1.4.1.RELEASE + 2.5.0 + 5.1.36 + 2.9.4 + 5.0.9.Final @@ -46,6 +50,19 @@ + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-data-jpa + + + mysql + mysql-connector-java + ${mysql.client.version} + org.apache.curator curator-recipes @@ -61,10 +78,78 @@ antlr4-runtime ${antlr.version} + + com.fasterxml.jackson.core + jackson-databind + 2.8.3 + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + 2.8.1 + org.apache.metron metron-common ${project.parent.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + org.apache.metron + metron-parsers + ${project.parent.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + org.apache.kafka + kafka_2.10 + ${global_kafka_version} + + + joda-time + joda-time + ${joda.time.version} + + + org.hibernate + hibernate-envers + ${hibernate.envers.version} + + + io.thekraken + grok + 0.1.0 + + + org.reflections + reflections + 0.9.10 + + + com.google.code.findbugs + annotations + + @@ -72,6 +157,16 @@ spring-boot-starter-test test + + com.h2database + h2 + test + + + org.springframework.security + spring-security-test + test + org.powermock powermock-module-junit4 @@ -100,6 +195,19 @@ + + org.apache.kafka + kafka-clients + ${global_kafka_version} + test + test + + + log4j + log4j + + + @@ -127,11 +235,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 2.19.1 - org.codehaus.mojo emma-maven-plugin diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevEntity.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevEntity.java new file mode 100644 index 0000000000..972b567eb4 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevEntity.java @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.audit; + +import org.hibernate.envers.DefaultRevisionEntity; +import org.hibernate.envers.RevisionEntity; + +import javax.persistence.Entity; + +@Entity +@RevisionEntity(UserRevisionListener.class) +public class UserRevEntity extends DefaultRevisionEntity { + private String username; + public String getUsername() { return username; } + public void setUsername(String username) { this.username = username; } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevisionListener.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevisionListener.java new file mode 100644 index 0000000000..89a8a34c92 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevisionListener.java @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.audit; + +import org.hibernate.envers.RevisionListener; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.User; + +public class UserRevisionListener implements RevisionListener { + + @Override + public void newRevision(Object revisionEntity) { + String username = null; + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication != null && authentication.isAuthenticated()) { + username = ((User) authentication.getPrincipal()).getUsername(); + } + UserRevEntity userRevEntity = (UserRevEntity) revisionEntity; + userRevEntity.setUsername(username); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/GrokConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/GrokConfig.java new file mode 100644 index 0000000000..1166e9cd26 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/GrokConfig.java @@ -0,0 +1,36 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import oi.thekraken.grok.api.Grok; +import oi.thekraken.grok.api.exception.GrokException; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.io.InputStreamReader; + +@Configuration +public class GrokConfig { + + @Bean + public Grok commonGrok() throws GrokException { + Grok grok = new Grok(); + grok.addPatternFromReader(new InputStreamReader(getClass().getResourceAsStream("/patterns/common"))); + return grok; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HadoopConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HadoopConfig.java new file mode 100644 index 0000000000..59d4f21c0b --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HadoopConfig.java @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; + +@Configuration +public class HadoopConfig { + + public static final String HDFS_URL_SPRING_PROPERTY = "hdfs.namenode.url"; + public static final String DEFAULT_HDFS_URL = "file:///"; + + @Autowired + private Environment environment; + + @Bean + public org.apache.hadoop.conf.Configuration configuration() { + org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration(); + configuration.set("fs.defaultFS", environment.getProperty(HDFS_URL_SPRING_PROPERTY, DEFAULT_HDFS_URL)); + return configuration; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java new file mode 100644 index 0000000000..48696a18d4 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import kafka.utils.ZkUtils; +import org.I0Itec.zkclient.ZkClient; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; + +import java.util.Properties; + +@Configuration +@Profile("!test") +public class KafkaConfig { + + public static final String KAFKA_BROKER_URL_SPRING_PROPERTY = "kafka.broker.url"; + + @Autowired + private Environment environment; + + @Autowired + private ZkClient zkClient; + + @Bean + public ZkUtils zkUtils() { + return ZkUtils.apply(zkClient, false); + } + + @Bean(destroyMethod="close") + public KafkaConsumer kafkaConsumer() { + Properties props = new Properties(); + props.put("bootstrap.servers", environment.getProperty(KAFKA_BROKER_URL_SPRING_PROPERTY)); + props.put("group.id", "metron-config"); + props.put("enable.auto.commit", "false"); + props.put("auto.commit.interval.ms", "1000"); + props.put("session.timeout.ms", "30000"); + props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + return new KafkaConsumer<>(props); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/MvcConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/MvcConfig.java new file mode 100644 index 0000000000..ed8216460a --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/MvcConfig.java @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; + +@Configuration +public class MvcConfig extends WebMvcConfigurerAdapter { + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**"); + } +} \ No newline at end of file diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/RestTemplateConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/RestTemplateConfig.java new file mode 100644 index 0000000000..923c83bd1c --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/RestTemplateConfig.java @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.web.client.RestTemplate; + +@Configuration +@Profile("!test") +public class RestTemplateConfig { + + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java new file mode 100644 index 0000000000..066b70c342 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java @@ -0,0 +1,45 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import org.apache.metron.rest.service.DockerStormCLIWrapper; +import org.apache.metron.rest.service.StormCLIWrapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.core.env.Environment; + +import java.util.Arrays; + +@Configuration +@Profile("!test") +public class StormConfig { + + @Autowired + private Environment environment; + + @Bean + public StormCLIWrapper stormCLIClientWrapper() { + if (Arrays.asList(environment.getActiveProfiles()).contains("docker")) { + return new DockerStormCLIWrapper(); + } else { + return new StormCLIWrapper(); + } + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/SwaggerConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/SwaggerConfig.java new file mode 100644 index 0000000000..9e82196132 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/SwaggerConfig.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/WebSecurityConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/WebSecurityConfig.java new file mode 100644 index 0000000000..79dc4504dc --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/WebSecurityConfig.java @@ -0,0 +1,89 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler; +import org.springframework.security.web.csrf.CookieCsrfTokenRepository; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +import javax.sql.DataSource; +import java.util.Arrays; + +@Configuration +@EnableWebSecurity +@Controller +public class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + private static final String CSRF_ENABLE_PROFILE = "csrf-enable"; + + @Autowired + private Environment environment; + + @RequestMapping({"/login", "/logout", "/sensors", "/sensors*/**"}) + public String handleNGRequests() { + return "forward:/index.html"; + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .antMatchers("/", "/home", "/login").permitAll() + .antMatchers("/app/**").permitAll() + .antMatchers("/vendor/**").permitAll() + .antMatchers("/fonts/**").permitAll() + .antMatchers("/assets/images/**").permitAll() + .antMatchers("/*.js").permitAll() + .antMatchers("/*.ttf").permitAll() + .antMatchers("/*.woff2").permitAll() + .anyRequest().authenticated() + .and().httpBasic() + .and() + .logout() + .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()) + .invalidateHttpSession(true) + .deleteCookies("JSESSIONID"); + if (Arrays.asList(environment.getActiveProfiles()).contains(CSRF_ENABLE_PROFILE)) { + http.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()); + } else { + http.csrf().disable(); + } + } + + @Autowired + private DataSource dataSource; + + @Autowired + public void configureJdbc(AuthenticationManagerBuilder auth) throws Exception { + auth + .jdbcAuthentication() + .dataSource(dataSource) + .withUser("user").password("password").roles("USER").and() + .withUser("user1").password("password").roles("USER").and() + .withUser("user2").password("password").roles("USER").and() + .withUser("admin").password("password").roles("USER", "ADMIN"); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java index 7091f9b74e..81d5833b31 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java @@ -17,15 +17,19 @@ */ package org.apache.metron.rest.config; +import kafka.utils.ZKStringSerializer$; +import org.I0Itec.zkclient.ZkClient; import org.apache.curator.RetryPolicy; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.ExponentialBackoffRetry; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; @Configuration +@Profile("!test") public class ZookeeperConfig { public static final String ZK_URL_SPRING_PROPERTY = "zookeeper.url"; @@ -35,4 +39,9 @@ public CuratorFramework client(Environment environment) { RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3); return CuratorFrameworkFactory.newClient(environment.getProperty(ZK_URL_SPRING_PROPERTY), retryPolicy); } + + @Bean(destroyMethod="close") + public ZkClient zkClient(Environment environment) { + return new ZkClient(environment.getProperty(ZK_URL_SPRING_PROPERTY), 10000, 10000, ZKStringSerializer$.MODULE$); + } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java new file mode 100644 index 0000000000..03af1b09c8 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java @@ -0,0 +1,61 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.rest.service.GlobalConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +@RequestMapping("/globalConfig") +public class GlobalConfigController { + + @Autowired + private GlobalConfigService globalConfigService; + + @RequestMapping(method = RequestMethod.POST) + ResponseEntity> save(@RequestBody Map globalConfig) throws Exception { + return new ResponseEntity<>(globalConfigService.save(globalConfig), HttpStatus.CREATED); + } + + @RequestMapping(method = RequestMethod.GET) + ResponseEntity> get() throws Exception { + Map globalConfig = globalConfigService.get(); + if (globalConfig != null) { + return new ResponseEntity<>(globalConfig, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + @RequestMapping(method = RequestMethod.DELETE) + ResponseEntity delete() throws Exception { + if (globalConfigService.delete()) { + return new ResponseEntity<>(HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java new file mode 100644 index 0000000000..e67f13f99c --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.rest.model.GrokValidation; +import org.apache.metron.rest.service.GrokService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +@RequestMapping("/grok") +public class GrokController { + + @Autowired + private GrokService grokService; + + @RequestMapping(value = "/validate", method = RequestMethod.POST) + ResponseEntity post(@RequestBody GrokValidation grokValidation) throws Exception { + return new ResponseEntity<>(grokService.validateGrokStatement(grokValidation), HttpStatus.OK); + } + + @RequestMapping(value = "/list", method = RequestMethod.GET) + ResponseEntity> list() throws Exception { + return new ResponseEntity<>(grokService.getCommonGrokPatterns(), HttpStatus.OK); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java new file mode 100644 index 0000000000..019847bddc --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.rest.model.KafkaTopic; +import org.apache.metron.rest.service.KafkaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Set; + +@RestController +@RequestMapping("/kafka") +public class KafkaController { + + @Autowired + private KafkaService kafkaService; + + @RequestMapping(value = "/topic", method = RequestMethod.POST) + ResponseEntity save(@RequestBody KafkaTopic topic) throws Exception { + return new ResponseEntity<>(kafkaService.createTopic(topic), HttpStatus.CREATED); + } + + @RequestMapping(value = "/topic/{name}", method = RequestMethod.GET) + ResponseEntity get(@PathVariable String name) throws Exception { + KafkaTopic kafkaTopic = kafkaService.getTopic(name); + if (kafkaTopic != null) { + return new ResponseEntity<>(kafkaTopic, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + @RequestMapping(value = "/topic", method = RequestMethod.GET) + ResponseEntity> list() throws Exception { + return new ResponseEntity<>(kafkaService.listTopics(), HttpStatus.OK); + } + + @RequestMapping(value = "/topic/{name}", method = RequestMethod.DELETE) + ResponseEntity delete(@PathVariable String name) throws Exception { + if (kafkaService.deleteTopic(name)) { + return new ResponseEntity<>(HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + @RequestMapping(value = "/topic/{name}/sample", method = RequestMethod.GET) + ResponseEntity getSample(@PathVariable String name) throws Exception { + String sampleMessage = kafkaService.getSampleMessage(name); + if (sampleMessage != null) { + return new ResponseEntity<>(sampleMessage, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java new file mode 100644 index 0000000000..e265fac4c2 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; +import org.apache.metron.rest.service.SensorEnrichmentConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/sensorEnrichmentConfig") +public class SensorEnrichmentConfigController { + + @Autowired + private SensorEnrichmentConfigService sensorEnrichmentConfigService; + + @RequestMapping(value = "/{name}", method = RequestMethod.POST) + ResponseEntity save(@PathVariable String name, @RequestBody SensorEnrichmentConfig sensorEnrichmentConfig) throws Exception { + return new ResponseEntity<>(sensorEnrichmentConfigService.save(name, sensorEnrichmentConfig), HttpStatus.CREATED); + } + + @RequestMapping(value = "/{name}", method = RequestMethod.GET) + ResponseEntity findOne(@PathVariable String name) throws Exception { + SensorEnrichmentConfig sensorEnrichmentConfig = sensorEnrichmentConfigService.findOne(name); + if (sensorEnrichmentConfig != null) { + return new ResponseEntity<>(sensorEnrichmentConfig, HttpStatus.OK); + } + + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + + @RequestMapping(method = RequestMethod.GET) + ResponseEntity> getAll() throws Exception { + return new ResponseEntity<>(sensorEnrichmentConfigService.getAll(), HttpStatus.OK); + } + + @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) + ResponseEntity delete(@PathVariable String name) throws Exception { + if (sensorEnrichmentConfigService.delete(name)) { + return new ResponseEntity<>(HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + @RequestMapping(value = "/list/available", method = RequestMethod.GET) + ResponseEntity> getAvailable() throws Exception { + return new ResponseEntity<>(sensorEnrichmentConfigService.getAvailableEnrichments(), HttpStatus.OK); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java index 0bd01bcbf7..8f65a56212 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java @@ -18,7 +18,9 @@ package org.apache.metron.rest.controller; import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.model.ParseMessageRequest; import org.apache.metron.rest.service.SensorParserConfigService; +import org.json.simple.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -26,9 +28,12 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; -@org.springframework.web.bind.annotation.RestController -@RequestMapping("/sensorParserConfigs") +import java.util.Map; + +@RestController +@RequestMapping("/sensorParserConfig") public class SensorParserConfigController { @Autowired @@ -51,7 +56,7 @@ ResponseEntity findOne(@PathVariable String name) throws Exc @RequestMapping(method = RequestMethod.GET) ResponseEntity> findAll() throws Exception { - return new ResponseEntity<>(sensorParserConfigService.findAll(), HttpStatus.OK); + return new ResponseEntity<>(sensorParserConfigService.getAll(), HttpStatus.OK); } @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) @@ -62,4 +67,19 @@ ResponseEntity delete(@PathVariable String name) throws Exception { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } } + + @RequestMapping(value = "/list/available", method = RequestMethod.GET) + ResponseEntity> getAvailable() throws Exception { + return new ResponseEntity<>(sensorParserConfigService.getAvailableParsers(), HttpStatus.OK); + } + + @RequestMapping(value = "/reload/available", method = RequestMethod.GET) + ResponseEntity> reloadAvailable() throws Exception { + return new ResponseEntity<>(sensorParserConfigService.reloadAvailableParsers(), HttpStatus.OK); + } + + @RequestMapping(value = "/parseMessage", method = RequestMethod.POST) + ResponseEntity parseMessage(@RequestBody ParseMessageRequest parseMessageRequest) throws Exception { + return new ResponseEntity<>(sensorParserConfigService.parseMessage(parseMessageRequest), HttpStatus.OK); + } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java new file mode 100644 index 0000000000..88827d58c1 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.rest.model.SensorParserConfigHistory; +import org.apache.metron.rest.service.SensorParserConfigHistoryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequestMapping("/sensorParserConfigHistory") +public class SensorParserConfigHistoryController { + + @Autowired + private SensorParserConfigHistoryService sensorParserHistoryService; + + @RequestMapping(value = "/{name}", method = RequestMethod.GET) + ResponseEntity findOne(@PathVariable String name) throws Exception { + SensorParserConfigHistory sensorParserConfigHistory = sensorParserHistoryService.findOne(name); + if (sensorParserConfigHistory != null) { + return new ResponseEntity<>(sensorParserHistoryService.findOne(name), HttpStatus.OK); + } + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + + @RequestMapping(method = RequestMethod.GET) + ResponseEntity> getall() throws Exception { + return new ResponseEntity<>(sensorParserHistoryService.getAll(), HttpStatus.OK); + } + + @RequestMapping(value = "/history/{name}", method = RequestMethod.GET) + ResponseEntity> history(@PathVariable String name) throws Exception { + return new ResponseEntity<>(sensorParserHistoryService.history(name), HttpStatus.OK); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java new file mode 100644 index 0000000000..51e3926dfc --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java @@ -0,0 +1,142 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.rest.model.TopologyResponse; +import org.apache.metron.rest.model.TopologyStatus; +import org.apache.metron.rest.service.StormService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/storm") +public class StormController { + + @Autowired + private StormService stormService; + + @RequestMapping(method = RequestMethod.GET) + ResponseEntity> getAll() throws Exception { + return new ResponseEntity<>(stormService.getAllTopologyStatus(), HttpStatus.OK); + } + + @RequestMapping(value = "/{name}", method = RequestMethod.GET) + ResponseEntity get(@PathVariable String name) throws Exception { + TopologyStatus sensorParserStatus = stormService.getTopologyStatus(name); + if (sensorParserStatus != null) { + return new ResponseEntity<>(sensorParserStatus, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + @RequestMapping(value = "/parser/start/{name}", method = RequestMethod.GET) + ResponseEntity start(@PathVariable String name) throws Exception { + return new ResponseEntity<>(stormService.startParserTopology(name), HttpStatus.OK); + } + + @RequestMapping(value = "/parser/stop/{name}", method = RequestMethod.GET) + ResponseEntity stop(@PathVariable String name, @RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { + return new ResponseEntity<>(stormService.stopParserTopology(name, stopNow), HttpStatus.OK); + } + + @RequestMapping(value = "/parser/activate/{name}", method = RequestMethod.GET) + ResponseEntity activate(@PathVariable String name) throws Exception { + return new ResponseEntity<>(stormService.activateTopology(name), HttpStatus.OK); + } + + @RequestMapping(value = "/parser/deactivate/{name}", method = RequestMethod.GET) + ResponseEntity deactivate(@PathVariable String name) throws Exception { + return new ResponseEntity<>(stormService.deactivateTopology(name), HttpStatus.OK); + } + + @RequestMapping(value = "/enrichment", method = RequestMethod.GET) + ResponseEntity getEnrichment() throws Exception { + TopologyStatus sensorParserStatus = stormService.getTopologyStatus(StormService.ENRICHMENT_TOPOLOGY_NAME); + if (sensorParserStatus != null) { + return new ResponseEntity<>(sensorParserStatus, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + @RequestMapping(value = "/enrichment/start", method = RequestMethod.GET) + ResponseEntity startEnrichment() throws Exception { + return new ResponseEntity<>(stormService.startEnrichmentTopology(), HttpStatus.OK); + } + + @RequestMapping(value = "/enrichment/stop", method = RequestMethod.GET) + ResponseEntity stopEnrichment(@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { + return new ResponseEntity<>(stormService.stopEnrichmentTopology(stopNow), HttpStatus.OK); + } + + @RequestMapping(value = "/enrichment/activate", method = RequestMethod.GET) + ResponseEntity activateEnrichment() throws Exception { + return new ResponseEntity<>(stormService.activateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); + } + + @RequestMapping(value = "/enrichment/deactivate", method = RequestMethod.GET) + ResponseEntity deactivateEnrichment() throws Exception { + return new ResponseEntity<>(stormService.deactivateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); + } + + @RequestMapping(value = "/indexing", method = RequestMethod.GET) + ResponseEntity getIndexing() throws Exception { + TopologyStatus sensorParserStatus = stormService.getTopologyStatus(StormService.INDEXING_TOPOLOGY_NAME); + if (sensorParserStatus != null) { + return new ResponseEntity<>(sensorParserStatus, HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } + + @RequestMapping(value = "/indexing/start", method = RequestMethod.GET) + ResponseEntity startIndexing() throws Exception { + return new ResponseEntity<>(stormService.startIndexingTopology(), HttpStatus.OK); + } + + @RequestMapping(value = "/indexing/stop", method = RequestMethod.GET) + ResponseEntity stopIndexing(@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { + return new ResponseEntity<>(stormService.stopIndexingTopology(stopNow), HttpStatus.OK); + } + + @RequestMapping(value = "/indexing/activate", method = RequestMethod.GET) + ResponseEntity activateIndexing() throws Exception { + return new ResponseEntity<>(stormService.activateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); + } + + @RequestMapping(value = "/indexing/deactivate", method = RequestMethod.GET) + ResponseEntity deactivateIndexing() throws Exception { + return new ResponseEntity<>(stormService.deactivateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); + } + + @RequestMapping(value = "/client/status", method = RequestMethod.GET) + ResponseEntity> clientStatus() throws Exception { + return new ResponseEntity<>(stormService.getStormClientStatus(), HttpStatus.OK); + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java new file mode 100644 index 0000000000..5f29e5ce3d --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java @@ -0,0 +1,66 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.common.field.transformation.FieldTransformations; +import org.apache.metron.rest.model.StellarFunctionDescription; +import org.apache.metron.rest.model.TransformationValidation; +import org.apache.metron.rest.service.TransformationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("/transformation") +public class TransformationController { + + @Autowired + private TransformationService transformationService; + + @RequestMapping(value = "/validate/rules", method = RequestMethod.POST) + ResponseEntity> validateRule(@RequestBody List rules) throws Exception { + return new ResponseEntity<>(transformationService.validateRules(rules), HttpStatus.OK); + } + + @RequestMapping(value = "/validate", method = RequestMethod.POST) + ResponseEntity> validateTransformation(@RequestBody TransformationValidation transformationValidation) throws Exception { + return new ResponseEntity<>(transformationService.validateTransformation(transformationValidation), HttpStatus.OK); + } + + @RequestMapping(value = "/list", method = RequestMethod.GET) + ResponseEntity list() throws Exception { + return new ResponseEntity<>(transformationService.getTransformations(), HttpStatus.OK); + } + + @RequestMapping(value = "/list/functions", method = RequestMethod.GET) + ResponseEntity> listFunctions() throws Exception { + return new ResponseEntity<>(transformationService.getStellarFunctions(), HttpStatus.OK); + } + + @RequestMapping(value = "/list/simple/functions", method = RequestMethod.GET) + ResponseEntity> listSimpleFunctions() throws Exception { + return new ResponseEntity<>(transformationService.getSimpleStellarFunctions(), HttpStatus.OK); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java new file mode 100644 index 0000000000..579936d50f --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.security.Principal; + +@RestController +public class UserController { + + @RequestMapping("/user") + public String user(Principal user) { + return user.getName(); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/GrokValidation.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/GrokValidation.java new file mode 100644 index 0000000000..ef62cc7c41 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/GrokValidation.java @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +import java.util.Map; + +public class GrokValidation { + + private String statement; + private String sampleData; + private Map results; + + public String getStatement() { + return statement; + } + + public void setStatement(String statement) { + this.statement = statement; + } + + public String getSampleData() { + return sampleData; + } + + public void setSampleData(String sampleData) { + this.sampleData = sampleData; + } + + public Map getResults() { + return results; + } + + public void setResults(Map results) { + this.results = results; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/KafkaTopic.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/KafkaTopic.java new file mode 100644 index 0000000000..c8db9f64fb --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/KafkaTopic.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +import java.util.Properties; + +public class KafkaTopic { + + private String name; + private int numPartitions; + private int replicationFactor; + private Properties properties = new Properties(); + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getNumPartitions() { + return numPartitions; + } + + public void setNumPartitions(int numPartitions) { + this.numPartitions = numPartitions; + } + + public int getReplicationFactor() { + return replicationFactor; + } + + public void setReplicationFactor(int replicationFactor) { + this.replicationFactor = replicationFactor; + } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java new file mode 100644 index 0000000000..8dfe17b695 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +import org.apache.metron.common.configuration.SensorParserConfig; + +public class ParseMessageRequest { + + private SensorParserConfig sensorParserConfig; + private String sampleData; + + public SensorParserConfig getSensorParserConfig() { + return sensorParserConfig; + } + + public void setSensorParserConfig(SensorParserConfig sensorParserConfig) { + this.sensorParserConfig = sensorParserConfig; + } + + public String getSampleData() { + return sampleData; + } + + public void setSampleData(String sampleData) { + this.sampleData = sampleData; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java new file mode 100644 index 0000000000..4f35b7dbba --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java @@ -0,0 +1,77 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.metron.common.configuration.SensorParserConfig; +import org.joda.time.DateTime; + +public class SensorParserConfigHistory { + + public SensorParserConfig config; + private String createdBy; + private String modifiedBy; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private DateTime createdDate; + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private DateTime modifiedByDate; + + public SensorParserConfig getConfig() { + return config; + } + + public void setConfig(SensorParserConfig config) { + this.config = config; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public DateTime getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(DateTime createdDate) { + this.createdDate = createdDate; + } + + public DateTime getModifiedByDate() { + return modifiedByDate; + } + + public void setModifiedByDate(DateTime modifiedByDate) { + this.modifiedByDate = modifiedByDate; + } +} + + diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java new file mode 100644 index 0000000000..f43bf5ca5b --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +import org.hibernate.envers.Audited; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +@Audited +public class SensorParserConfigVersion { + + @Id + private String name; + + @Column(length = 10000) + private String config; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getConfig() { + return config; + } + + public void setConfig(String config) { + this.config = config; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java new file mode 100644 index 0000000000..43e158c00c --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +public class StellarFunctionDescription { + + private String name; + private String description; + private String[] params; + private String returns; + + public StellarFunctionDescription(String name, String description, String[] params, String returns) { + this.name = name; + this.description = description; + this.params = params; + this.returns = returns; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public String[] getParams() { + return params; + } + + public String getReturns() { + return returns; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyResponse.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyResponse.java new file mode 100644 index 0000000000..ab43fb4a1f --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyResponse.java @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +public class TopologyResponse { + + private String status; + private String message; + + public String getStatus() { + return status; + } + + public String getMessage() { + return message; + } + + public void setSuccessMessage(String message) { + this.status = "success"; + this.message = message; + } + + public void setErrorMessage(String message) { + this.status = "error"; + this.message = message; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatus.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatus.java new file mode 100644 index 0000000000..0e2d28a40d --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatus.java @@ -0,0 +1,76 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +import java.util.List; +import java.util.Map; + +public class TopologyStatus { + + private String id; + private String name; + private TopologyStatusCode status; + private Map[] topologyStats; + private double latency = 0; + private double throughput = 0; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public TopologyStatusCode getStatus() { + return status; + } + + public void setStatus(TopologyStatusCode status) { + this.status = status; + } + + public double getLatency() { + return latency; + } + + public double getThroughput() { + return throughput; + } + + public void setTopologyStats(List> topologyStats) { + for(Map topologyStatsItem: topologyStats) { + if ("600".equals(topologyStatsItem.get("window"))) { + latency = Double.parseDouble((String) topologyStatsItem.get("completeLatency")); + int acked = 0; + if (topologyStatsItem.get("acked") != null) { + acked = (int) topologyStatsItem.get("acked"); + } + throughput = acked / 600.00; + } + } + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatusCode.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatusCode.java new file mode 100644 index 0000000000..461a4ab448 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatusCode.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +public enum TopologyStatusCode { + + STARTED, + STOPPED, + ACTIVE, + INACTIVE, + KILLED, + GLOBAL_CONFIG_MISSING, + SENSOR_PARSER_CONFIG_MISSING, + START_ERROR, + STOP_ERROR, + TOPOLOGY_NOT_FOUND; +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologySummary.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologySummary.java new file mode 100644 index 0000000000..5af9b57b5e --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologySummary.java @@ -0,0 +1,31 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +public class TopologySummary { + + private TopologyStatus[] topologies; + + public TopologyStatus[] getTopologies() { + return topologies; + } + + public void setTopologies(TopologyStatus[] topologies) { + this.topologies = topologies; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TransformationValidation.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TransformationValidation.java new file mode 100644 index 0000000000..d40697ce32 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TransformationValidation.java @@ -0,0 +1,44 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +import org.apache.metron.common.configuration.SensorParserConfig; + +import java.util.Map; + +public class TransformationValidation { + + private Map sampleData; + private SensorParserConfig sensorParserConfig; + + public Map getSampleData() { + return sampleData; + } + + public void setSampleData(Map sampleData) { + this.sampleData = sampleData; + } + + public SensorParserConfig getSensorParserConfig() { + return sensorParserConfig; + } + + public void setSensorParserConfig(SensorParserConfig sensorParserConfig) { + this.sensorParserConfig = sensorParserConfig; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/repository/SensorParserConfigVersionRepository.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/repository/SensorParserConfigVersionRepository.java new file mode 100644 index 0000000000..686cff97a7 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/repository/SensorParserConfigVersionRepository.java @@ -0,0 +1,24 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.repository; + +import org.apache.metron.rest.model.SensorParserConfigVersion; +import org.springframework.data.repository.CrudRepository; + +public interface SensorParserConfigVersionRepository extends CrudRepository { +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/DockerStormCLIWrapper.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/DockerStormCLIWrapper.java new file mode 100644 index 0000000000..25be4bac2c --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/DockerStormCLIWrapper.java @@ -0,0 +1,70 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.commons.lang3.ArrayUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Map; + +public class DockerStormCLIWrapper extends StormCLIWrapper { + + private Logger LOG = LoggerFactory.getLogger(DockerStormCLIWrapper.class); + + @Autowired + private Environment environment; + + @Override + protected ProcessBuilder getProcessBuilder(String... command) { + String[] dockerCommand = {"docker-compose", "-f", environment.getProperty("docker.compose.path"), "-p", "metron", "exec", "storm"}; + ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(dockerCommand, command)); + Map pbEnvironment = pb.environment(); + pbEnvironment.put("METRON_VERSION", environment.getProperty("metron.version")); + setDockerEnvironment(pbEnvironment); + return pb; + } + + protected void setDockerEnvironment(Map environmentVariables) { + ProcessBuilder pb = getDockerEnvironmentProcessBuilder(); + try { + Process process = pb.start(); + BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while((line = inputStream.readLine()) != null) { + if (line.startsWith("export")) { + String[] parts = line.replaceFirst("export ", "").split("="); + environmentVariables.put(parts[0], parts[1].replaceAll("\"", "")); + } + } + process.waitFor(); + } catch (IOException | InterruptedException e) { + LOG.error(e.getMessage(), e); + } + } + + protected ProcessBuilder getDockerEnvironmentProcessBuilder() { + String[] command = {"docker-machine", "env", "metron-machine"}; + return new ProcessBuilder(command); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java new file mode 100644 index 0000000000..46124f7deb --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java @@ -0,0 +1,62 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import com.fasterxml.jackson.core.type.TypeReference; +import org.apache.curator.framework.CuratorFramework; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.ConfigurationsUtils; +import org.apache.metron.common.utils.JSONUtils; +import org.apache.zookeeper.KeeperException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.ByteArrayInputStream; +import java.util.Map; + +@Service +public class GlobalConfigService { + + @Autowired + private CuratorFramework client; + + public Map save(Map globalConfig) throws Exception { + ConfigurationsUtils.writeGlobalConfigToZookeeper(globalConfig, client); + return globalConfig; + } + + public Map get() throws Exception { + Map globalConfig; + try { + byte[] globalConfigBytes = ConfigurationsUtils.readGlobalConfigBytesFromZookeeper(client); + globalConfig = JSONUtils.INSTANCE.load(new ByteArrayInputStream(globalConfigBytes), new TypeReference>(){}); + } catch (KeeperException.NoNodeException e) { + return null; + } + return globalConfig; + } + + public boolean delete() throws Exception { + try { + client.delete().forPath(ConfigurationType.GLOBAL.getZookeeperRoot()); + } catch (KeeperException.NoNodeException e) { + return false; + } + return true; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java new file mode 100644 index 0000000000..f5cb511590 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java @@ -0,0 +1,138 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import oi.thekraken.grok.api.Grok; +import oi.thekraken.grok.api.Match; +import org.apache.hadoop.fs.Path; +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.model.GrokValidation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.StringReader; +import java.util.HashMap; +import java.util.Map; + +@Service +public class GrokService { + + public static final String GROK_PATH_SPRING_PROPERTY = "grok.path"; + public static final String GROK_CLASS_NAME = "org.apache.metron.parsers.GrokParser"; + public static final String GROK_PATH_KEY = "grokPath"; + public static final String GROK_STATEMENT_KEY = "grokStatement"; + public static final String GROK_PATTERN_LABEL_KEY = "patternLabel"; + + @Autowired + private Environment environment; + + @Autowired + private Grok commonGrok; + + @Autowired + private HdfsService hdfsService; + + public Map getCommonGrokPatterns() { + return commonGrok.getPatterns(); + } + + public GrokValidation validateGrokStatement(GrokValidation grokValidation) { + Map results = new HashMap<>(); + try { + Grok grok = new Grok(); + grok.addPatternFromReader(new InputStreamReader(getClass().getResourceAsStream("/patterns/common"))); + grok.addPatternFromReader(new StringReader(grokValidation.getStatement())); + String patternLabel = grokValidation.getStatement().substring(0, grokValidation.getStatement().indexOf(" ")); + String grokPattern = "%{" + patternLabel + "}"; + grok.compile(grokPattern); + Match gm = grok.match(grokValidation.getSampleData()); + gm.captures(); + results = gm.toMap(); + results.remove(patternLabel); + } catch (StringIndexOutOfBoundsException e) { + results.put("error", "A pattern label must be included (ex. PATTERN_LABEL ${PATTERN:field} ...)"); + } catch (Exception e) { + results.put("error", e.getMessage()); + } + grokValidation.setResults(results); + return grokValidation; + } + + public boolean isGrokConfig(SensorParserConfig sensorParserConfig) { + return GROK_CLASS_NAME.equals(sensorParserConfig.getParserClassName()); + } + + public void addGrokStatementToConfig(SensorParserConfig sensorParserConfig) throws IOException { + String grokStatement = ""; + String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); + if (grokPath != null) { + try { + grokStatement = getGrokStatement(grokPath); + } catch(FileNotFoundException e) {} + } + sensorParserConfig.getParserConfig().put(GROK_STATEMENT_KEY, grokStatement); + } + + public void addGrokPathToConfig(SensorParserConfig sensorParserConfig) { + String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); + if (grokStatement != null) { + sensorParserConfig.getParserConfig().put(GROK_PATH_KEY, getGrokPath(sensorParserConfig.getSensorTopic()).toString()); + } + } + + public String getGrokStatement(String path) throws IOException { + return new String(hdfsService.read(new Path(path))); + } + + public void saveGrokStatement(SensorParserConfig sensorParserConfig) throws IOException { + saveGrokStatement(sensorParserConfig, false); + } + + public void saveTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws IOException { + saveGrokStatement(sensorParserConfig, true); + } + + private void saveGrokStatement(SensorParserConfig sensorParserConfig, boolean isTemporary) throws IOException { + String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); + if (grokStatement != null) { + if (!isTemporary) { + hdfsService.write(getGrokPath(sensorParserConfig.getSensorTopic()), grokStatement.getBytes()); + } else { + hdfsService.write(getTempGrokPath(sensorParserConfig.getSensorTopic()), grokStatement.getBytes()); + } + } + } + + public Path getGrokPath(String name) { + return new Path(environment.getProperty(GROK_PATH_SPRING_PROPERTY), name); + } + + public Path getTempGrokPath(String name) { + return new Path(environment.getProperty(GROK_PATH_SPRING_PROPERTY) + "/temp", name); + } + + public void deleteTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws IOException { + hdfsService.delete(getTempGrokPath(sensorParserConfig.getSensorTopic()), false); + } + + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java new file mode 100644 index 0000000000..298bb2b2bf --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +@Service +public class HdfsService { + + @Autowired + private Configuration configuration; + + public byte[] read(Path path) throws IOException { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + IOUtils.copyBytes(FileSystem.get(configuration).open(path), byteArrayOutputStream, configuration); + return byteArrayOutputStream.toByteArray(); + } + + public void write(Path path, byte[] contents) throws IOException { + FSDataOutputStream fsDataOutputStream = FileSystem.get(configuration).create(path, true); + fsDataOutputStream.write(contents); + fsDataOutputStream.close(); + } + + public FileStatus[] list(Path path) throws IOException { + return FileSystem.get(configuration).listStatus(path); + } + + public boolean delete(Path path, boolean recursive) throws IOException { + return FileSystem.get(configuration).delete(path, recursive); + } + } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java new file mode 100644 index 0000000000..0fc57685f7 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java @@ -0,0 +1,112 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import kafka.admin.AdminUtils; +import kafka.admin.RackAwareMode; +import kafka.utils.ZkUtils; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.common.PartitionInfo; +import org.apache.kafka.common.TopicPartition; +import org.apache.metron.rest.model.KafkaTopic; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@Service +public class KafkaService { + + @Autowired + private ZkUtils zkUtils; + + @Autowired + private KafkaConsumer kafkaConsumer; + + private String offsetTopic = "__consumer_offsets"; + + public KafkaTopic createTopic(KafkaTopic topic) { + if (!listTopics().contains(topic.getName())) { + AdminUtils.createTopic(zkUtils, topic.getName(), topic.getNumPartitions(), topic.getReplicationFactor(), topic.getProperties(), RackAwareMode.Disabled$.MODULE$); + } + return topic; + } + + public boolean deleteTopic(String name) { + if (listTopics().contains(name)) { + AdminUtils.deleteTopic(zkUtils, name); + return true; + } else { + return false; + } + } + + public KafkaTopic getTopic(String name) { + KafkaTopic kafkaTopic = null; + if (listTopics().contains(name)) { + List partitionInfos = kafkaConsumer.partitionsFor(name); + if (partitionInfos.size() > 0) { + PartitionInfo partitionInfo = partitionInfos.get(0); + kafkaTopic = new KafkaTopic(); + kafkaTopic.setName(name); + kafkaTopic.setNumPartitions(partitionInfos.size()); + kafkaTopic.setReplicationFactor(partitionInfo.replicas().length); + } + } + return kafkaTopic; + } + + public Set listTopics() { + Set topics; + synchronized (this) { + topics = kafkaConsumer.listTopics().keySet(); + topics.remove(offsetTopic); + } + return topics; + } + + public String getSampleMessage(String topic) { + String message = null; + if (listTopics().contains(topic)) { + synchronized (this) { + kafkaConsumer.assign(kafkaConsumer.partitionsFor(topic).stream().map(partitionInfo -> + new TopicPartition(topic, partitionInfo.partition())).collect(Collectors.toList())); + for (TopicPartition topicPartition : kafkaConsumer.assignment()) { + long offset = kafkaConsumer.position(topicPartition) - 1; + if (offset >= 0) { + kafkaConsumer.seek(topicPartition, offset); + } + } + ConsumerRecords records = kafkaConsumer.poll(100); + Iterator> iterator = records.iterator(); + if (iterator.hasNext()) { + ConsumerRecord record = iterator.next(); + message = record.value(); + } + kafkaConsumer.unsubscribe(); + } + } + return message; + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java new file mode 100644 index 0000000000..ec745733c3 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java @@ -0,0 +1,92 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.curator.framework.CuratorFramework; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.ConfigurationsUtils; +import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; +import org.apache.zookeeper.KeeperException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class SensorEnrichmentConfigService { + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private CuratorFramework client; + + public SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnrichmentConfig) throws Exception { + ConfigurationsUtils.writeSensorEnrichmentConfigToZookeeper(name, objectMapper.writeValueAsString(sensorEnrichmentConfig).getBytes(), client); + return sensorEnrichmentConfig; + } + + public SensorEnrichmentConfig findOne(String name) throws Exception { + SensorEnrichmentConfig sensorEnrichmentConfig = null; + try { + sensorEnrichmentConfig = ConfigurationsUtils.readSensorEnrichmentConfigFromZookeeper(name, client); + } catch (KeeperException.NoNodeException e) { + } + return sensorEnrichmentConfig; + } + + public List getAll() throws Exception { + List sensorEnrichmentConfigs = new ArrayList<>(); + List sensorNames = getAllTypes(); + for (String name : sensorNames) { + sensorEnrichmentConfigs.add(findOne(name)); + } + return sensorEnrichmentConfigs; + } + + public List getAllTypes() throws Exception { + List types; + try { + types = client.getChildren().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot()); + } catch (KeeperException.NoNodeException e) { + types = new ArrayList<>(); + } + return types; + } + + public boolean delete(String name) throws Exception { + try { + client.delete().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/" + name); + } catch (KeeperException.NoNodeException e) { + return false; + } + return true; + } + + public List getAvailableEnrichments() { + return new ArrayList() {{ + add("geo"); + add("host"); + add("whois"); + add("sample"); + }}; + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java new file mode 100644 index 0000000000..0be71431e0 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java @@ -0,0 +1,136 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.audit.UserRevEntity; +import org.apache.metron.rest.model.SensorParserConfigVersion; +import org.apache.metron.rest.model.SensorParserConfigHistory; +import org.hibernate.envers.AuditReader; +import org.hibernate.envers.AuditReaderFactory; +import org.hibernate.envers.query.AuditEntity; +import org.joda.time.DateTime; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.persistence.EntityManager; +import javax.persistence.NoResultException; +import javax.persistence.PersistenceContext; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +@Service +public class SensorParserConfigHistoryService { + + @Autowired + private ObjectMapper objectMapper; + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private GrokService grokService; + + @Autowired + private SensorParserConfigService sensorParserConfigService; + + public SensorParserConfigHistory findOne(String name) throws Exception { + SensorParserConfigHistory sensorParserConfigHistory = null; + AuditReader reader = AuditReaderFactory.get(entityManager); + try{ + Object[] latestResults = (Object[]) reader.createQuery().forRevisionsOfEntity(SensorParserConfigVersion.class, false, true) + .add(AuditEntity.property("name").eq(name)) + .addOrder(AuditEntity.revisionNumber().desc()) + .setMaxResults(1) + .getSingleResult(); + SensorParserConfigVersion sensorParserConfigVersion = (SensorParserConfigVersion) latestResults[0]; + sensorParserConfigHistory = new SensorParserConfigHistory(); + sensorParserConfigHistory.setConfig(deserializeSensorParserConfig(sensorParserConfigVersion.getConfig())); + + UserRevEntity latestUserRevEntity = (UserRevEntity) latestResults[1]; + sensorParserConfigHistory.setModifiedBy(latestUserRevEntity.getUsername()); + sensorParserConfigHistory.setModifiedByDate(new DateTime(latestUserRevEntity.getTimestamp())); + + if (grokService.isGrokConfig(sensorParserConfigHistory.getConfig())) { + grokService.addGrokStatementToConfig(sensorParserConfigHistory.getConfig()); + } + + Object[] firstResults = (Object[]) reader.createQuery().forRevisionsOfEntity(SensorParserConfigVersion.class, false, true) + .add(AuditEntity.property("name").eq(name)) + .addOrder(AuditEntity.revisionNumber().asc()) + .setMaxResults(1) + .getSingleResult(); + UserRevEntity firstUserRevEntity = (UserRevEntity) firstResults[1]; + sensorParserConfigHistory.setCreatedBy(firstUserRevEntity.getUsername()); + sensorParserConfigHistory.setCreatedDate(new DateTime(firstUserRevEntity.getTimestamp())); + + } catch (NoResultException e){ + } + return sensorParserConfigHistory; + } + + public List getAll() throws Exception { + List historyList = new ArrayList<>(); + for(String sensorType: sensorParserConfigService.getAllTypes()) { + historyList.add(findOne(sensorType)); + } + return historyList; + } + + public List history(String name) throws Exception { + List historyList = new ArrayList<>(); + AuditReader reader = AuditReaderFactory.get(entityManager); + List results = reader.createQuery().forRevisionsOfEntity(SensorParserConfigVersion.class, false, true) + .add(AuditEntity.property("name").eq(name)) + .addOrder(AuditEntity.revisionNumber().asc()) + .getResultList(); + String createdBy = ""; + DateTime createdDate = null; + for(int i = 0; i < results.size(); i++) { + Object[] revision = (Object[]) results.get(i); + SensorParserConfigVersion sensorParserConfigVersion = (SensorParserConfigVersion) revision[0]; + UserRevEntity userRevEntity = (UserRevEntity) revision[1]; + String username = userRevEntity.getUsername(); + DateTime dateTime = new DateTime(userRevEntity.getTimestamp()); + if (i == 0) { + createdBy = username; + createdDate = dateTime; + } + SensorParserConfigHistory sensorParserInfo = new SensorParserConfigHistory(); + String config = sensorParserConfigVersion.getConfig(); + if (config != null) { + sensorParserInfo.setConfig(deserializeSensorParserConfig(config)); + } else { + sensorParserInfo.setConfig(null); + } + sensorParserInfo.setCreatedBy(createdBy); + sensorParserInfo.setCreatedDate(createdDate); + sensorParserInfo.setModifiedBy(username); + sensorParserInfo.setModifiedByDate(dateTime); + historyList.add(0, sensorParserInfo); + } + return historyList; + } + + private SensorParserConfig deserializeSensorParserConfig(String config) throws IOException { + return objectMapper.readValue(config, new TypeReference() {}); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java index 31b09b7349..474cd76415 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -17,21 +17,33 @@ */ package org.apache.metron.rest.service; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.curator.framework.CuratorFramework; import org.apache.metron.common.configuration.ConfigurationType; import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.configuration.SensorParserConfig; -import org.apache.metron.common.utils.JSONUtils; +import org.apache.metron.parsers.interfaces.MessageParser; +import org.apache.metron.rest.model.ParseMessageRequest; +import org.apache.metron.rest.model.SensorParserConfigVersion; +import org.apache.metron.rest.repository.SensorParserConfigVersionRepository; import org.apache.zookeeper.KeeperException; +import org.json.simple.JSONObject; +import org.reflections.Reflections; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Set; @Service public class SensorParserConfigService { + @Autowired + private ObjectMapper objectMapper; + private CuratorFramework client; @Autowired @@ -39,22 +51,52 @@ public void setClient(CuratorFramework client) { this.client = client; } + @Autowired + private GrokService grokService; + + @Autowired + private SensorParserConfigVersionRepository sensorParserRepository; + + private Map availableParsers; + public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws Exception { - ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), JSONUtils.INSTANCE.toJSON(sensorParserConfig), client); + String serializedConfig; + if (grokService.isGrokConfig(sensorParserConfig)) { + grokService.addGrokPathToConfig(sensorParserConfig); + String statement = (String) sensorParserConfig.getParserConfig().remove(GrokService.GROK_STATEMENT_KEY); + serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); + ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), serializedConfig.getBytes(), client); + sensorParserConfig.getParserConfig().put(GrokService.GROK_STATEMENT_KEY, statement); + sensorParserConfig.getParserConfig().put(GrokService.GROK_PATTERN_LABEL_KEY, sensorParserConfig.getSensorTopic().toUpperCase()); + grokService.saveGrokStatement(sensorParserConfig); + } else { + serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); + ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), serializedConfig.getBytes(), client); + } + saveVersion(sensorParserConfig.getSensorTopic(), serializedConfig); return sensorParserConfig; } + private void saveVersion(String name, String config) { + SensorParserConfigVersion sensorParser = new SensorParserConfigVersion(); + sensorParser.setName(name); + sensorParser.setConfig(config); + sensorParserRepository.save(sensorParser); + } + public SensorParserConfig findOne(String name) throws Exception{ - SensorParserConfig sensorParserConfig; + SensorParserConfig sensorParserConfig = null; try { sensorParserConfig = ConfigurationsUtils.readSensorParserConfigFromZookeeper(name, client); + if (grokService.isGrokConfig(sensorParserConfig)) { + grokService.addGrokStatementToConfig(sensorParserConfig); + } } catch (KeeperException.NoNodeException e) { - sensorParserConfig = null; } return sensorParserConfig; } - public Iterable findAll() throws Exception { + public Iterable getAll() throws Exception { List sensorParserConfigs = new ArrayList<>(); List sensorNames = getAllTypes(); for (String name : sensorNames) { @@ -66,6 +108,7 @@ public Iterable findAll() throws Exception { public boolean delete(String name) throws Exception { try { client.delete().forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/" + name); + sensorParserRepository.delete(name); } catch (KeeperException.NoNodeException e) { return false; } @@ -81,4 +124,45 @@ public List getAllTypes() throws Exception { } return types; } + + public Map getAvailableParsers() { + if (availableParsers == null) { + availableParsers = new HashMap<>(); + Set> parserClasses = getParserClasses(); + parserClasses.forEach(parserClass -> { + if (!"BasicParser".equals(parserClass.getSimpleName())) { + availableParsers.put(parserClass.getSimpleName().replaceAll("Basic|Parser", ""), parserClass.getName()); + } + }); + } + return availableParsers; + } + + public Map reloadAvailableParsers() { + availableParsers = null; + return getAvailableParsers(); + } + + private Set> getParserClasses() { + Reflections reflections = new Reflections("org.apache.metron.parsers"); + return reflections.getSubTypesOf(MessageParser.class); + } + + public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws Exception { + SensorParserConfig sensorParserConfig = parseMessageRequest.getSensorParserConfig(); + if (sensorParserConfig == null) { + throw new Exception("Could not find parser config"); + } else if (sensorParserConfig.getParserClassName() == null) { + throw new Exception("Could not find parser class name"); + } else { + MessageParser parser = (MessageParser) Class.forName(sensorParserConfig.getParserClassName()).newInstance(); + sensorParserConfig.getParserConfig().put(GrokService.GROK_PATTERN_LABEL_KEY, sensorParserConfig.getSensorTopic().toUpperCase()); + sensorParserConfig.getParserConfig().put(GrokService.GROK_PATH_KEY, grokService.getTempGrokPath(sensorParserConfig.getSensorTopic()).toString()); + grokService.saveTemporaryGrokStatement(sensorParserConfig); + parser.configure(sensorParserConfig.getParserConfig()); + JSONObject results = parser.parse(parseMessageRequest.getSampleData().getBytes()).get(0); + grokService.deleteTemporaryGrokStatement(sensorParserConfig); + return results; + } + } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java new file mode 100644 index 0000000000..692d058ec7 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java @@ -0,0 +1,144 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.metron.rest.config.KafkaConfig; +import org.apache.metron.rest.config.ZookeeperConfig; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static java.util.stream.Collectors.toList; +import static org.apache.metron.rest.service.StormService.ENRICHMENT_TOPOLOGY_NAME; +import static org.apache.metron.rest.service.StormService.INDEXING_TOPOLOGY_NAME; + +public class StormCLIWrapper { + + public static final String PARSER_SCRIPT_PATH_SPRING_PROPERTY = "storm.parser.script.path"; + public static final String ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY = "storm.enrichment.script.path"; + public static final String INDEXING_SCRIPT_PATH_SPRING_PROPERTY = "storm.indexing.script.path"; + + @Autowired + private Environment environment; + + public int startParserTopology(String name) throws IOException, InterruptedException { + return runCommand(getParserStartCommand(name)); + } + + public int stopParserTopology(String name, boolean stopNow) throws IOException, InterruptedException { + return runCommand(getStopCommand(name, stopNow)); + } + + public int startEnrichmentTopology() throws IOException, InterruptedException { + return runCommand(getEnrichmentStartCommand()); + } + + public int stopEnrichmentTopology(boolean stopNow) throws IOException, InterruptedException { + return runCommand(getStopCommand(ENRICHMENT_TOPOLOGY_NAME, stopNow)); + } + + public int startIndexingTopology() throws IOException, InterruptedException { + return runCommand(getIndexingStartCommand()); + } + + public int stopIndexingTopology(boolean stopNow) throws IOException, InterruptedException { + return runCommand(getStopCommand(INDEXING_TOPOLOGY_NAME, stopNow)); + } + + protected int runCommand(String[] command) throws IOException, InterruptedException { + ProcessBuilder pb = getProcessBuilder(command); + pb.inheritIO(); + Process process = pb.start(); + process.waitFor(); + return process.exitValue(); + } + + protected String[] getParserStartCommand(String name) { + String[] command = new String[7]; + command[0] = environment.getProperty(PARSER_SCRIPT_PATH_SPRING_PROPERTY); + command[1] = "-k"; + command[2] = environment.getProperty(KafkaConfig.KAFKA_BROKER_URL_SPRING_PROPERTY); + command[3] = "-z"; + command[4] = environment.getProperty(ZookeeperConfig.ZK_URL_SPRING_PROPERTY); + command[5] = "-s"; + command[6] = name; + return command; + } + + protected String[] getEnrichmentStartCommand() { + String[] command = new String[1]; + command[0] = environment.getProperty(ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY); + return command; + } + + protected String[] getIndexingStartCommand() { + String[] command = new String[1]; + command[0] = environment.getProperty(INDEXING_SCRIPT_PATH_SPRING_PROPERTY); + return command; + } + + protected String[] getStopCommand(String name, boolean stopNow) { + String[] command; + if (stopNow) { + command = new String[5]; + command[3] = "-w"; + command[4] = "0"; + } else { + command = new String[3]; + } + command[0] = "storm"; + command[1] = "kill"; + command[2] = name; + return command; + } + + protected ProcessBuilder getProcessBuilder(String... command) { + return new ProcessBuilder(command); + } + + public Map getStormClientStatus() throws IOException { + Map status = new HashMap<>(); + status.put("parserScriptPath", environment.getProperty(PARSER_SCRIPT_PATH_SPRING_PROPERTY)); + status.put("enrichmentScriptPath", environment.getProperty(ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY)); + status.put("indexingScriptPath", environment.getProperty(INDEXING_SCRIPT_PATH_SPRING_PROPERTY)); + status.put("stormClientVersionInstalled", stormClientVersionInstalled()); + return status; + } + + protected String stormClientVersionInstalled() throws IOException { + String stormClientVersionInstalled = "Storm client is not installed"; + ProcessBuilder pb = getProcessBuilder("storm", "version"); + pb.redirectErrorStream(true); + Process p = pb.start(); + BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); + List lines = reader.lines().collect(toList()); + lines.forEach(System.out::println); + if (lines.size() > 0) { + stormClientVersionInstalled = lines.get(1).replaceFirst("Storm ", ""); + } + return stormClientVersionInstalled; + } + + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java new file mode 100644 index 0000000000..29d2d4f05f --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java @@ -0,0 +1,183 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.metron.rest.model.TopologyResponse; +import org.apache.metron.rest.model.TopologyStatus; +import org.apache.metron.rest.model.TopologyStatusCode; +import org.apache.metron.rest.model.TopologySummary; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Service +public class StormService { + + public static final String STORM_UI_SPRING_PROPERTY = "storm.ui.url"; + public static final String TOPOLOGY_SUMMARY_URL = "/api/v1/topology/summary"; + public static final String TOPOLOGY_URL = "/api/v1/topology"; + public static final String ENRICHMENT_TOPOLOGY_NAME = "enrichment"; + public static final String INDEXING_TOPOLOGY_NAME = "indexing"; + + @Autowired + private Environment environment; + + private RestTemplate restTemplate; + + @Autowired + public void setRestTemplate(RestTemplate restTemplate) { + this.restTemplate = restTemplate; + } + + private StormCLIWrapper stormCLIClientWrapper; + + @Autowired + public void setStormCLIClientWrapper(StormCLIWrapper stormCLIClientWrapper) { + this.stormCLIClientWrapper = stormCLIClientWrapper; + } + + @Autowired + private GlobalConfigService globalConfigService; + + @Autowired + private SensorParserConfigService sensorParserConfigService; + + public TopologySummary getTopologySummary() { + return restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_SUMMARY_URL, TopologySummary.class); + } + + public TopologyStatus getTopologyStatus(String name) { + TopologyStatus topologyResponse = null; + String id = null; + for (TopologyStatus topology : getTopologySummary().getTopologies()) { + if (name.equals(topology.getName())) { + id = topology.getId(); + break; + } + } + if (id != null) { + topologyResponse = restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + id, TopologyStatus.class); + } + return topologyResponse; + } + + public List getAllTopologyStatus() { + List topologyStatus = new ArrayList<>(); + for (TopologyStatus topology : getTopologySummary().getTopologies()) { + topologyStatus.add(restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + topology.getId(), TopologyStatus.class)); + } + return topologyStatus; + } + + public TopologyResponse activateTopology(String name) { + TopologyResponse topologyResponse = new TopologyResponse(); + String id = null; + for (TopologyStatus topology : getTopologySummary().getTopologies()) { + if (name.equals(topology.getName())) { + id = topology.getId(); + break; + } + } + if (id != null) { + Map result = restTemplate.postForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + id + "/activate", null, Map.class); + if("success".equals(result.get("status"))) { + topologyResponse.setSuccessMessage(TopologyStatusCode.ACTIVE.toString()); + } else { + topologyResponse.setErrorMessage((String) result.get("status")); + } + } else { + topologyResponse.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString()); + } + return topologyResponse; + } + + public TopologyResponse deactivateTopology(String name) { + TopologyResponse topologyResponse = new TopologyResponse(); + String id = null; + for (TopologyStatus topology : getTopologySummary().getTopologies()) { + if (name.equals(topology.getName())) { + id = topology.getId(); + break; + } + } + if (id != null) { + Map result = restTemplate.postForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + id + "/deactivate", null, Map.class); + if("success".equals(result.get("status"))) { + topologyResponse.setSuccessMessage(TopologyStatusCode.INACTIVE.toString()); + } else { + topologyResponse.setErrorMessage((String) result.get("status")); + } + } else { + topologyResponse.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString()); + } + return topologyResponse; + } + + public TopologyResponse startParserTopology(String name) throws Exception { + TopologyResponse topologyResponse = new TopologyResponse(); + if (globalConfigService.get() == null) { + topologyResponse.setErrorMessage(TopologyStatusCode.GLOBAL_CONFIG_MISSING.toString()); + } else if (sensorParserConfigService.findOne(name) == null) { + topologyResponse.setErrorMessage(TopologyStatusCode.SENSOR_PARSER_CONFIG_MISSING.toString()); + } else { + topologyResponse = createResponse(stormCLIClientWrapper.startParserTopology(name), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); + } + return topologyResponse; + } + + public TopologyResponse stopParserTopology(String name, boolean stopNow) throws IOException, InterruptedException { + return createResponse(stormCLIClientWrapper.stopParserTopology(name, stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); + } + + public TopologyResponse startEnrichmentTopology() throws IOException, InterruptedException { + return createResponse(stormCLIClientWrapper.startEnrichmentTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); + } + + public TopologyResponse stopEnrichmentTopology(boolean stopNow) throws IOException, InterruptedException { + return createResponse(stormCLIClientWrapper.stopEnrichmentTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); + } + + public TopologyResponse startIndexingTopology() throws IOException, InterruptedException { + return createResponse(stormCLIClientWrapper.startIndexingTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); + } + + public TopologyResponse stopIndexingTopology(boolean stopNow) throws IOException, InterruptedException { + return createResponse(stormCLIClientWrapper.stopIndexingTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); + } + + protected TopologyResponse createResponse(int responseCode, TopologyStatusCode successMessage, TopologyStatusCode errorMessage) { + TopologyResponse topologyResponse = new TopologyResponse(); + if (responseCode == 0) { + topologyResponse.setSuccessMessage(successMessage.toString()); + } else { + topologyResponse.setErrorMessage(errorMessage.toString()); + } + return topologyResponse; + } + + public Map getStormClientStatus() throws IOException { + return stormCLIClientWrapper.getStormClientStatus(); + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java new file mode 100644 index 0000000000..d4a6a0f036 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java @@ -0,0 +1,111 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.metron.common.dsl.Context; +import org.apache.metron.common.dsl.FunctionResolverSingleton; +import org.apache.metron.common.dsl.ParseException; +import org.apache.metron.common.dsl.StellarFunctionInfo; +import org.apache.metron.common.field.transformation.FieldTransformations; +import org.apache.metron.common.stellar.StellarProcessor; +import org.apache.metron.rest.model.StellarFunctionDescription; +import org.apache.metron.rest.model.TransformationValidation; +import org.json.simple.JSONObject; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +public class TransformationService { + + public Map validateRules(List rules) { + Map results = new HashMap<>(); + StellarProcessor stellarProcessor = new StellarProcessor(); + for(String rule: rules) { + try { + boolean result = stellarProcessor.validate(rule, Context.EMPTY_CONTEXT()); + results.put(rule, result); + } catch (ParseException e) { + results.put(rule, false); + } + } + return results; + } + + public Map validateTransformation(TransformationValidation transformationValidation) { + JSONObject sampleJson = new JSONObject(transformationValidation.getSampleData()); + transformationValidation.getSensorParserConfig().getFieldTransformations().forEach(fieldTransformer -> { + fieldTransformer.transformAndUpdate(sampleJson, transformationValidation.getSensorParserConfig().getParserConfig(), Context.EMPTY_CONTEXT()); + } + ); + return sampleJson; + } + + public FieldTransformations[] getTransformations() { + return FieldTransformations.values(); + } + + public List getStellarFunctions() { + List stellarFunctionDescriptions = new ArrayList<>(); + Iterable stellarFunctionsInfo = FunctionResolverSingleton.getInstance().getFunctionInfo(); + stellarFunctionsInfo.forEach(stellarFunctionInfo -> { + stellarFunctionDescriptions.add(new StellarFunctionDescription( + stellarFunctionInfo.getName(), + stellarFunctionInfo.getDescription(), + stellarFunctionInfo.getParams(), + stellarFunctionInfo.getReturns())); + }); + return stellarFunctionDescriptions; + } + + private List simpleFunctionNames = Arrays.asList( + "DOMAIN_REMOVE_SUBDOMAINS", + "DOMAIN_REMOVE_TLD", + "DOMAIN_TO_TLD", + "IS_DOMAIN", + "IS_EMAIL", + "IS_EMPTY", + "LENGTH", + "PROTOCOL_TO_NAME", + "TO_INTEGER", + "TO_LOWER", + "TO_STRING", + "TO_UPPER", + "TRIM", + "URL_TO_HOST", + "URL_TO_PATH", + "URL_TO_PORT", + "URL_TO_PROTOCOL", + "WEEK_OF_MONTH", + "WEEK_OF_YEAR", + "YEAR" + ); + + public List getSimpleStellarFunctions() { + List stellarFunctionDescriptions = getStellarFunctions(); + return stellarFunctionDescriptions.stream().filter(stellarFunctionDescription -> + simpleFunctionNames.contains(stellarFunctionDescription.getName())).collect(Collectors.toList()); + } + + +} diff --git a/metron-interface/metron-rest/src/main/resources/application-docker.yml b/metron-interface/metron-rest/src/main/resources/application-docker.yml new file mode 100644 index 0000000000..918fb0788f --- /dev/null +++ b/metron-interface/metron-rest/src/main/resources/application-docker.yml @@ -0,0 +1,62 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +docker: + host: + address: 192.168.99.107 + compose: + path: ../../metron-docker/docker-compose.yml + +spring: + datasource: + driverClassName: com.mysql.jdbc.Driver + url: jdbc:mysql://${docker.host.address}:3306/metronconfig + username: root + password: root + platform: mysql + jpa: + hibernate: + ddl-auto: update + +logging: + level: + root: ERROR + +server: + contextPath: /api/v1 + +zookeeper: + url: ${docker.host.address}:2181 + +kafka: + broker: + url: ${docker.host.address}:9092 + +hdfs: + namenode: + url: file:/// + +grok: + path: target/patterns + +storm: + ui: + url: ${docker.host.address}:8080 + parser: + script.path: /usr/metron/${metron.version}/bin/start_parser_topology.sh + enrichment: + script.path: /usr/metron/${metron.version}/bin/start_enrichment_topology.sh + indexing: + script.path: /usr/metron/${metron.version}/bin/start_elasticsearch_topology.sh diff --git a/metron-interface/metron-rest/src/main/resources/application-test.yml b/metron-interface/metron-rest/src/main/resources/application-test.yml index 8fe6d9ac69..2731592b35 100644 --- a/metron-interface/metron-rest/src/main/resources/application-test.yml +++ b/metron-interface/metron-rest/src/main/resources/application-test.yml @@ -13,12 +13,28 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -logging: - level: - root: ERROR +spring: + datasource: + driverClassName: org.h2.Driver + url: jdbc:h2:mem:testdb + username: sa + password: + platform: h2 + jpa: + hibernate: + ddl-auto: create-drop + main: + banner-mode: off -server: - contextPath: /api/v1 +grok: + path: target/patterns -zookeeper: - url: localhost:2181 \ No newline at end of file +storm: + ui: + url: stormUITestUrl + parser: + script.path: /usr/metron/${metron.version}/bin/start_parser_topology.sh + enrichment: + script.path: /usr/metron/${metron.version}/bin/start_enrichment_topology.sh + indexing: + script.path: /usr/metron/${metron.version}/bin/start_elasticsearch_topology.sh \ No newline at end of file diff --git a/metron-interface/metron-rest/src/main/resources/application.yml b/metron-interface/metron-rest/src/main/resources/application.yml index 32375f936e..2615510cca 100644 --- a/metron-interface/metron-rest/src/main/resources/application.yml +++ b/metron-interface/metron-rest/src/main/resources/application.yml @@ -13,6 +13,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +metron: + version: 0.3.0 + logging: level: root: ERROR @@ -20,5 +23,6 @@ logging: server: contextPath: /api/v1 -zookeeper: - url: node1:2181 +spring: + jackson: + date-format: yyyy-MM-dd HH:mm:ss diff --git a/metron-interface/metron-rest/src/main/resources/log4j.properties b/metron-interface/metron-rest/src/main/resources/log4j.properties new file mode 100644 index 0000000000..ffc66d622b --- /dev/null +++ b/metron-interface/metron-rest/src/main/resources/log4j.properties @@ -0,0 +1,4 @@ +log4j.rootLogger=ERROR, stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS} %-5p [%c] - %m%n \ No newline at end of file diff --git a/metron-interface/metron-rest/src/main/resources/schema-h2.sql b/metron-interface/metron-rest/src/main/resources/schema-h2.sql new file mode 100644 index 0000000000..986b652cf2 --- /dev/null +++ b/metron-interface/metron-rest/src/main/resources/schema-h2.sql @@ -0,0 +1,30 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +drop table if exists authorities; +drop table if exists users; + +create table if not exists users( + username varchar(50) not null primary key, + password varchar(50) not null, + enabled boolean not null +); +create table authorities ( + username varchar(50) not null, + authority varchar(50) not null, + constraint fk_authorities_users foreign key(username) references users(username) +); +create unique index ix_auth_username on authorities (username,authority); \ No newline at end of file diff --git a/metron-interface/metron-rest/src/main/resources/schema-mysql.sql b/metron-interface/metron-rest/src/main/resources/schema-mysql.sql new file mode 100644 index 0000000000..986b652cf2 --- /dev/null +++ b/metron-interface/metron-rest/src/main/resources/schema-mysql.sql @@ -0,0 +1,30 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ +drop table if exists authorities; +drop table if exists users; + +create table if not exists users( + username varchar(50) not null primary key, + password varchar(50) not null, + enabled boolean not null +); +create table authorities ( + username varchar(50) not null, + authority varchar(50) not null, + constraint fk_authorities_users foreign key(username) references users(username) +); +create unique index ix_auth_username on authorities (username,authority); \ No newline at end of file diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java new file mode 100644 index 0000000000..2e1127f91f --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java @@ -0,0 +1,129 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.config; + +import com.google.common.base.Function; +import kafka.utils.ZKStringSerializer$; +import kafka.utils.ZkUtils; +import org.I0Itec.zkclient.ZkClient; +import org.apache.curator.RetryPolicy; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; +import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.metron.integration.ComponentRunner; +import org.apache.metron.integration.UnableToStartException; +import org.apache.metron.integration.components.KafkaComponent; +import org.apache.metron.integration.components.ZKServerComponent; +import org.apache.metron.rest.mock.MockStormCLIClientWrapper; +import org.apache.metron.rest.mock.MockStormRestTemplate; +import org.apache.metron.rest.service.StormCLIWrapper; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.web.client.RestTemplate; + +import javax.annotation.Nullable; +import java.util.Properties; + +@Configuration +@Profile("test") +public class TestConfig { + + @Bean + public Properties zkProperties() { + return new Properties(); + } + + @Bean + public ZKServerComponent zkServerComponent(Properties zkProperties) { + return new ZKServerComponent() + .withPostStartCallback(new Function() { + @Nullable + @Override + public Void apply(@Nullable ZKServerComponent zkComponent) { + zkProperties.setProperty(ZKServerComponent.ZOOKEEPER_PROPERTY, zkComponent.getConnectionString()); + return null; + } + }); + } + + @Bean + public KafkaComponent kafkaWithZKComponent(Properties zkProperties) { + return new KafkaComponent().withTopologyProperties(zkProperties); + } + + //@Bean(destroyMethod = "stop") + @Bean + public ComponentRunner componentRunner(ZKServerComponent zkServerComponent, KafkaComponent kafkaWithZKComponent) { + ComponentRunner runner = new ComponentRunner.Builder() + .withComponent("zk", zkServerComponent) + .withComponent("kafka", kafkaWithZKComponent) + .withCustomShutdownOrder(new String[] {"kafka","zk"}) + .build(); + try { + runner.start(); + } catch (UnableToStartException e) { + e.printStackTrace(); + } + return runner; + } + + @Bean(initMethod = "start", destroyMethod="close") + public CuratorFramework client(ComponentRunner componentRunner) { + RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3); + ZKServerComponent zkServerComponent = componentRunner.getComponent("zk", ZKServerComponent.class); + return CuratorFrameworkFactory.newClient(zkServerComponent.getConnectionString(), retryPolicy); + } + + @Bean(destroyMethod="close") + public ZkClient zkClient(ComponentRunner componentRunner) { + ZKServerComponent zkServerComponent = componentRunner.getComponent("zk", ZKServerComponent.class); + return new ZkClient(zkServerComponent.getConnectionString(), 10000, 10000, ZKStringSerializer$.MODULE$); + } + + @Bean + public ZkUtils zkUtils(ZkClient zkClient) { + return ZkUtils.apply(zkClient, false); + } + + @Bean(destroyMethod="close") + public KafkaConsumer kafkaConsumer(KafkaComponent kafkaWithZKComponent) { + Properties props = new Properties(); + props.put("bootstrap.servers", kafkaWithZKComponent.getBrokerList()); + props.put("group.id", "metron-config"); + props.put("enable.auto.commit", "false"); + props.put("auto.commit.interval.ms", "1000"); + props.put("session.timeout.ms", "30000"); + props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); + return new KafkaConsumer<>(props); + } + + @Bean + public StormCLIWrapper stormCLIClientWrapper() { + return new MockStormCLIClientWrapper(); + } + + @Bean + public RestTemplate restTemplate(StormCLIWrapper stormCLIClientWrapper) { + MockStormRestTemplate restTemplate = new MockStormRestTemplate(); + restTemplate.setMockStormCLIClientWrapper((MockStormCLIClientWrapper) stormCLIClientWrapper); + return restTemplate; + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java new file mode 100644 index 0000000000..20039fb7b3 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java @@ -0,0 +1,105 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.adrianwalker.multilinestring.Multiline; +import org.apache.metron.rest.service.GlobalConfigService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class GlobalConfigControllerIntegrationTest { + + /** + { + "solr.zookeeper": "solr:2181", + "solr.collection": "metron", + "solr.numShards": 1, + "solr.replicationFactor": 1 + } + */ + @Multiline + public static String globalJson; + + @Autowired + private WebApplicationContext wac; + + @Autowired + private GlobalConfigService globalConfigService; + + private MockMvc mockMvc; + + private String user = "user"; + private String password = "password"; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(post("/globalConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/globalConfig")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(delete("/globalConfig").with(csrf())) + .andExpect(status().isUnauthorized()); + } + + @Test + public void test() throws Exception { + this.mockMvc.perform(get("/globalConfig").with(httpBasic(user,password))) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(post("/globalConfig").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))); + + this.mockMvc.perform(get("/globalConfig").with(httpBasic(user,password))) + .andExpect(status().isOk()); + + this.mockMvc.perform(delete("/globalConfig").with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isOk()); + + this.mockMvc.perform(delete("/globalConfig").with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isNotFound()); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java new file mode 100644 index 0000000000..8261e3db60 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java @@ -0,0 +1,112 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.adrianwalker.multilinestring.Multiline; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class GrokControllerIntegrationTest { + + /** + { + "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html", + "statement":"SQUID %{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}" + } + */ + @Multiline + public static String grokValidationJson; + + /** + { + "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html", + "statement":"" + } + */ + @Multiline + public static String badGrokValidationJson; + + @Autowired + private WebApplicationContext wac; + + private MockMvc mockMvc; + + private String user = "user"; + private String password = "password"; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(post("/grok/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/grok/list")) + .andExpect(status().isUnauthorized()); + } + + @Test + public void test() throws Exception { + this.mockMvc.perform(post("/grok/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.results.action").value("TCP_MISS")) + .andExpect(jsonPath("$.results.bytes").value(337891)) + .andExpect(jsonPath("$.results.code").value(200)) + .andExpect(jsonPath("$.results.elapsed").value(415)) + .andExpect(jsonPath("$.results.ip_dst_addr").value("207.109.73.154")) + .andExpect(jsonPath("$.results.ip_src_addr").value("127.0.0.1")) + .andExpect(jsonPath("$.results.method").value("GET")) + .andExpect(jsonPath("$.results.timestamp").value("1467011157.401")) + .andExpect(jsonPath("$.results.url").value("http://www.aliexpress.com/af/shoes.html?")); + + this.mockMvc.perform(post("/grok/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(badGrokValidationJson)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.results.error").exists()); + + this.mockMvc.perform(get("/grok/list").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$").isNotEmpty()); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java new file mode 100644 index 0000000000..cbfe84ff0a --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java @@ -0,0 +1,186 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.adrianwalker.multilinestring.Multiline; +import org.apache.metron.integration.components.KafkaComponent; +import org.apache.metron.rest.generator.SampleDataGenerator; +import org.apache.metron.rest.service.KafkaService; +import org.hamcrest.Matchers; +import org.json.simple.parser.ParseException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import java.io.IOException; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class KafkaControllerIntegrationTest { + + @Autowired + private KafkaComponent kafkaWithZKComponent; + + class SampleDataRunner implements Runnable { + + private boolean stop = false; + private String path = "../../metron-platform/metron-integration-test/src/main/sample/data/bro/raw/BroExampleOutput"; + + @Override + public void run() { + SampleDataGenerator broSampleDataGenerator = new SampleDataGenerator(); + broSampleDataGenerator.setBrokerUrl(kafkaWithZKComponent.getBrokerList()); + broSampleDataGenerator.setNum(1); + broSampleDataGenerator.setSelectedSensorType("bro"); + broSampleDataGenerator.setDelay(0); + try { + while(!stop) { + broSampleDataGenerator.generateSampleData(path); + } + } catch (IOException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } + } + + public void stop() { + stop = true; + } + } + + private SampleDataRunner sampleDataRunner = new SampleDataRunner(); + private Thread sampleDataThread = new Thread(sampleDataRunner); + + /** + { + "name": "bro", + "numPartitions": 1, + "properties": {}, + "replicationFactor": 1 + } + */ + @Multiline + public static String broTopic; + + @Autowired + private WebApplicationContext wac; + + @Autowired + private KafkaService kafkaService; + + private MockMvc mockMvc; + + private String user = "user"; + private String password = "password"; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(post("/kafka/topic").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/kafka/topic/bro")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/kafka/topic")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/kafka/topic/bro/sample")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(delete("/kafka/topic/bro").with(csrf())) + .andExpect(status().isUnauthorized()); + } + + @Test + public void test() throws Exception { + this.kafkaService.deleteTopic("bro"); + this.kafkaService.deleteTopic("someTopic"); + Thread.sleep(1000); + + this.mockMvc.perform(delete("/kafka/topic/bro").with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(post("/kafka/topic").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.name").value("bro")) + .andExpect(jsonPath("$.numPartitions").value(1)) + .andExpect(jsonPath("$.replicationFactor").value(1)); + + sampleDataThread.start(); + Thread.sleep(1000); + + this.mockMvc.perform(get("/kafka/topic/bro").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.name").value("bro")) + .andExpect(jsonPath("$.numPartitions").value(1)) + .andExpect(jsonPath("$.replicationFactor").value(1)); + + this.mockMvc.perform(get("/kafka/topic/someTopic").with(httpBasic(user,password))) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(get("/kafka/topic").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$", Matchers.hasItem("bro"))); + + + this.mockMvc.perform(get("/kafka/topic/bro/sample").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("text/plain;charset=UTF-8"))) + .andExpect(jsonPath("$").isNotEmpty()); + + this.mockMvc.perform(get("/kafka/topic/someTopic/sample").with(httpBasic(user,password))) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(delete("/kafka/topic/bro").with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isOk()); + } + + @After + public void tearDown() { + sampleDataRunner.stop(); + } +} 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 new file mode 100644 index 0000000000..6ba292149c --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorEnrichmentConfigControllerIntegrationTest.java @@ -0,0 +1,225 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.adrianwalker.multilinestring.Multiline; +import org.apache.metron.rest.service.SensorEnrichmentConfigService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class SensorEnrichmentConfigControllerIntegrationTest { + + /** + { + "index": "broTest", + "batchSize": 1, + "enrichment": { + "fieldMap": { + "geo": [ + "ip_dst_addr" + ], + "host": [ + "ip_dst_addr" + ], + "hbaseEnrichment": [ + "ip_src_addr" + ], + "stellar": { + "config": { + "group1": { + "foo": "1 + 1", + "bar": "foo" + }, + "group2": { + "ALL_CAPS": "TO_UPPER(source.type)" + } + } + } + }, + "fieldToTypeMap": { + "ip_src_addr": [ + "sample" + ] + } + }, + "threatIntel": { + "fieldMap": { + "hbaseThreatIntel": [ + "ip_src_addr", + "ip_dst_addr" + ] + }, + "fieldToTypeMap": { + "ip_src_addr": [ + "malicious_ip" + ], + "ip_dst_addr": [ + "malicious_ip" + ] + }, + "triageConfig": { + "riskLevelRules": { + "ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'": 10 + }, + "aggregator": "MAX" + } + } + } + */ + @Multiline + public static String broJson; + + @Autowired + private SensorEnrichmentConfigService sensorEnrichmentConfigService; + + @Autowired + private WebApplicationContext wac; + + private MockMvc mockMvc; + + private String user = "user"; + private String password = "password"; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(post("/sensorEnrichmentConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/sensorEnrichmentConfig/broTest")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/sensorEnrichmentConfig")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(delete("/sensorEnrichmentConfig/broTest").with(csrf())) + .andExpect(status().isUnauthorized()); + } + + @Test + public void test() throws Exception { + sensorEnrichmentConfigService.delete("broTest"); + + this.mockMvc.perform(post("/sensorEnrichmentConfig/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.index").value("broTest")) + .andExpect(jsonPath("$.batchSize").value(1)) + .andExpect(jsonPath("$.enrichment.fieldMap.geo[0]").value("ip_dst_addr")) + .andExpect(jsonPath("$.enrichment.fieldMap.host[0]").value("ip_dst_addr")) + .andExpect(jsonPath("$.enrichment.fieldMap.hbaseEnrichment[0]").value("ip_src_addr")) + .andExpect(jsonPath("$.enrichment.fieldToTypeMap.ip_src_addr[0]").value("sample")) + .andExpect(jsonPath("$.enrichment.fieldMap.stellar.config.group1.foo").value("1 + 1")) + .andExpect(jsonPath("$.enrichment.fieldMap.stellar.config.group1.bar").value("foo")) + .andExpect(jsonPath("$.enrichment.fieldMap.stellar.config.group2.ALL_CAPS").value("TO_UPPER(source.type)")) + .andExpect(jsonPath("$.threatIntel.fieldMap.hbaseThreatIntel[0]").value("ip_src_addr")) + .andExpect(jsonPath("$.threatIntel.fieldMap.hbaseThreatIntel[1]").value("ip_dst_addr")) + .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_src_addr[0]").value("malicious_ip")) + .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_dst_addr[0]").value("malicious_ip")) + .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) + .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); + + this.mockMvc.perform(get("/sensorEnrichmentConfig/broTest").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.index").value("broTest")) + .andExpect(jsonPath("$.batchSize").value(1)) + .andExpect(jsonPath("$.enrichment.fieldMap.geo[0]").value("ip_dst_addr")) + .andExpect(jsonPath("$.enrichment.fieldMap.host[0]").value("ip_dst_addr")) + .andExpect(jsonPath("$.enrichment.fieldMap.hbaseEnrichment[0]").value("ip_src_addr")) + .andExpect(jsonPath("$.enrichment.fieldToTypeMap.ip_src_addr[0]").value("sample")) + .andExpect(jsonPath("$.enrichment.fieldMap.stellar.config.group1.foo").value("1 + 1")) + .andExpect(jsonPath("$.enrichment.fieldMap.stellar.config.group1.bar").value("foo")) + .andExpect(jsonPath("$.enrichment.fieldMap.stellar.config.group2.ALL_CAPS").value("TO_UPPER(source.type)")) + .andExpect(jsonPath("$.threatIntel.fieldMap.hbaseThreatIntel[0]").value("ip_src_addr")) + .andExpect(jsonPath("$.threatIntel.fieldMap.hbaseThreatIntel[1]").value("ip_dst_addr")) + .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_src_addr[0]").value("malicious_ip")) + .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_dst_addr[0]").value("malicious_ip")) + .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) + .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); + + this.mockMvc.perform(get("/sensorEnrichmentConfig").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[?(@.index == 'broTest' &&" + + "@.batchSize == 1 &&" + + "@.enrichment.fieldMap.geo[0] == 'ip_dst_addr' &&" + + "@.enrichment.fieldMap.host[0] == 'ip_dst_addr' &&" + + "@.enrichment.fieldMap.hbaseEnrichment[0] == 'ip_src_addr' &&" + + "@.enrichment.fieldToTypeMap.ip_src_addr[0] == 'sample' &&" + + "@.enrichment.fieldMap.stellar.config.group1.foo == '1 + 1' &&" + + "@.enrichment.fieldMap.stellar.config.group1.bar == 'foo' &&" + + "@.enrichment.fieldMap.stellar.config.group2.ALL_CAPS == 'TO_UPPER(source.type)' &&" + + "@.threatIntel.fieldMap.hbaseThreatIntel[0] == 'ip_src_addr' &&" + + "@.threatIntel.fieldMap.hbaseThreatIntel[1] == 'ip_dst_addr' &&" + + "@.threatIntel.fieldToTypeMap.ip_src_addr[0] == 'malicious_ip' &&" + + "@.threatIntel.fieldToTypeMap.ip_dst_addr[0] == 'malicious_ip' &&" + + "@.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"] == 10 &&" + + "@.threatIntel.triageConfig.aggregator == 'MAX'" + + ")]").exists()); + + this.mockMvc.perform(delete("/sensorEnrichmentConfig/broTest").with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isOk()); + + this.mockMvc.perform(get("/sensorEnrichmentConfig/broTest").with(httpBasic(user,password))) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(delete("/sensorEnrichmentConfig/broTest").with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(get("/sensorEnrichmentConfig").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").doesNotExist()); + + this.mockMvc.perform(get("/sensorEnrichmentConfig/list/available").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")) + .andExpect(jsonPath("$[3]").value("sample")); + } +} + diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java index 5bd96cf4ec..7de0c9aef7 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -17,14 +17,7 @@ */ package org.apache.metron.rest.controller; -import com.google.common.base.Function; import org.adrianwalker.multilinestring.Multiline; -import org.apache.curator.RetryPolicy; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.CuratorFrameworkFactory; -import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.metron.integration.ComponentRunner; -import org.apache.metron.integration.components.KafkaWithZKComponent; import org.apache.metron.rest.service.SensorParserConfigService; import org.junit.Before; import org.junit.Test; @@ -39,12 +32,15 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import javax.annotation.Nullable; - -import static org.hamcrest.Matchers.hasSize; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -54,10 +50,9 @@ public class SensorParserConfigControllerIntegrationTest { /** { "parserClassName": "org.apache.metron.parsers.GrokParser", - "sensorTopic": "squid", + "sensorTopic": "squidTest", "parserConfig": { - "grokPath": "/patterns/squid", - "patternLabel": "SQUID_DELIMITED", + "grokStatement": "SQUID %{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", "timestampField": "timestamp" }, "fieldTransformations" : [ @@ -78,52 +73,75 @@ public class SensorParserConfigControllerIntegrationTest { /** { "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", - "sensorTopic":"bro", + "sensorTopic":"broTest", "parserConfig": {} } */ @Multiline public static String broJson; + /** + { + "sensorParserConfig": + { + "parserClassName": "org.apache.metron.parsers.GrokParser", + "sensorTopic": "squid", + "parserConfig": { + "grokStatement": "SQUID %{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", + "patternLabel": "SQUID", + "timestampField": "timestamp" + } + }, + "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html" + } + */ + @Multiline + public static String parseRequest; + + @Autowired + private SensorParserConfigService sensorParserConfigService; + @Autowired private WebApplicationContext wac; + @Autowired + private ApplicationContext applicationContext; + private MockMvc mockMvc; + private String user = "user"; + private String password = "password"; + @Before public void setup() throws Exception { - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); } - @Autowired - private ApplicationContext applicationContext; + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(post("/sensorParserConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/sensorParserConfig/squidTest")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/sensorParserConfig")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(delete("/sensorParserConfig/squidTest").with(csrf())) + .andExpect(status().isUnauthorized()); + } @Test public void test() throws Exception { - final KafkaWithZKComponent kafkaWithZKComponent = new KafkaWithZKComponent().withPostStartCallback(new Function() { - @Nullable - @Override - public Void apply(@Nullable KafkaWithZKComponent kafkaWithZKComponent) { - SensorParserConfigService sensorParserConfigService = (SensorParserConfigService) applicationContext.getBean("sensorParserConfigService"); - RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3); - CuratorFramework client = CuratorFrameworkFactory.newClient(kafkaWithZKComponent.getZookeeperConnect(), retryPolicy); - client.start(); - sensorParserConfigService.setClient(client); - return null; - } - }); - ComponentRunner runner = new ComponentRunner.Builder() - .withComponent("kafka", kafkaWithZKComponent) - .build(); - runner.start(); - - this.mockMvc.perform(post("/sensorParserConfigs").contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) + + this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.GrokParser")) - .andExpect(jsonPath("$.sensorTopic").value("squid")) - .andExpect(jsonPath("$.parserConfig.grokPath").value("/patterns/squid")) - .andExpect(jsonPath("$.parserConfig.patternLabel").value("SQUID_DELIMITED")) + .andExpect(jsonPath("$.sensorTopic").value("squidTest")) + .andExpect(jsonPath("$.parserConfig.grokPath").value("target/patterns/squidTest")) + .andExpect(jsonPath("$.parserConfig.patternLabel").value("SQUIDTEST")) .andExpect(jsonPath("$.parserConfig.timestampField").value("timestamp")) .andExpect(jsonPath("$.fieldTransformations[0].transformation").value("STELLAR")) .andExpect(jsonPath("$.fieldTransformations[0].output[0]").value("full_hostname")) @@ -131,13 +149,12 @@ public Void apply(@Nullable KafkaWithZKComponent kafkaWithZKComponent) { .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); - this.mockMvc.perform(get("/sensorParserConfigs/squid")) + this.mockMvc.perform(get("/sensorParserConfig/squidTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.GrokParser")) - .andExpect(jsonPath("$.sensorTopic").value("squid")) - .andExpect(jsonPath("$.parserConfig.grokPath").value("/patterns/squid")) - .andExpect(jsonPath("$.parserConfig.patternLabel").value("SQUID_DELIMITED")) + .andExpect(jsonPath("$.sensorTopic").value("squidTest")) + .andExpect(jsonPath("$.parserConfig.grokPath").value("target/patterns/squidTest")) .andExpect(jsonPath("$.parserConfig.timestampField").value("timestamp")) .andExpect(jsonPath("$.fieldTransformations[0].transformation").value("STELLAR")) .andExpect(jsonPath("$.fieldTransformations[0].output[0]").value("full_hostname")) @@ -145,74 +162,94 @@ public Void apply(@Nullable KafkaWithZKComponent kafkaWithZKComponent) { .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); - this.mockMvc.perform(get("/sensorParserConfigs")) + this.mockMvc.perform(get("/sensorParserConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$", hasSize(1))) - .andExpect(jsonPath("$[0].parserClassName").value("org.apache.metron.parsers.GrokParser")) - .andExpect(jsonPath("$[0].sensorTopic").value("squid")) - .andExpect(jsonPath("$[0].parserConfig.grokPath").value("/patterns/squid")) - .andExpect(jsonPath("$[0].parserConfig.patternLabel").value("SQUID_DELIMITED")) - .andExpect(jsonPath("$[0].parserConfig.timestampField").value("timestamp")) - .andExpect(jsonPath("$[0].fieldTransformations[0].transformation").value("STELLAR")) - .andExpect(jsonPath("$[0].fieldTransformations[0].output[0]").value("full_hostname")) - .andExpect(jsonPath("$[0].fieldTransformations[0].output[1]").value("domain_without_subdomains")) - .andExpect(jsonPath("$[0].fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) - .andExpect(jsonPath("$[0].fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); - - this.mockMvc.perform(post("/sensorParserConfigs").contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + .andExpect(jsonPath("$[?(@.parserClassName == 'org.apache.metron.parsers.GrokParser' &&" + + "@.sensorTopic == 'squidTest' &&" + + "@.parserConfig.grokPath == 'target/patterns/squidTest' &&" + + "@.parserConfig.timestampField == 'timestamp' &&" + + "@.fieldTransformations[0].transformation == 'STELLAR' &&" + + "@.fieldTransformations[0].output[0] == 'full_hostname' &&" + + "@.fieldTransformations[0].output[1] == 'domain_without_subdomains' &&" + + "@.fieldTransformations[0].config.full_hostname == 'URL_TO_HOST(url)' &&" + + "@.fieldTransformations[0].config.domain_without_subdomains == 'DOMAIN_REMOVE_SUBDOMAINS(full_hostname)')]").exists()); + + this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) - .andExpect(jsonPath("$.sensorTopic").value("bro")) + .andExpect(jsonPath("$.sensorTopic").value("broTest")) .andExpect(jsonPath("$.parserConfig").isEmpty()); - this.mockMvc.perform(get("/sensorParserConfigs")) + this.mockMvc.perform(get("/sensorParserConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$", hasSize(2))) - .andExpect(jsonPath("$[0].parserClassName").value("org.apache.metron.parsers.GrokParser")) - .andExpect(jsonPath("$[0].sensorTopic").value("squid")) - .andExpect(jsonPath("$[0].parserConfig.grokPath").value("/patterns/squid")) - .andExpect(jsonPath("$[0].parserConfig.patternLabel").value("SQUID_DELIMITED")) - .andExpect(jsonPath("$[0].parserConfig.timestampField").value("timestamp")) - .andExpect(jsonPath("$[0].fieldTransformations[0].transformation").value("STELLAR")) - .andExpect(jsonPath("$[0].fieldTransformations[0].output[0]").value("full_hostname")) - .andExpect(jsonPath("$[0].fieldTransformations[0].output[1]").value("domain_without_subdomains")) - .andExpect(jsonPath("$[0].fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) - .andExpect(jsonPath("$[0].fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")) - .andExpect(jsonPath("$[1].parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) - .andExpect(jsonPath("$[1].sensorTopic").value("bro")) - .andExpect(jsonPath("$[1].parserConfig").isEmpty()); - - this.mockMvc.perform(delete("/sensorParserConfigs/squid")) + .andExpect(jsonPath("$[?(@.parserClassName == 'org.apache.metron.parsers.GrokParser' &&" + + "@.sensorTopic == 'squidTest' &&" + + "@.parserConfig.grokPath == 'target/patterns/squidTest' &&" + + "@.parserConfig.timestampField == 'timestamp' &&" + + "@.fieldTransformations[0].transformation == 'STELLAR' &&" + + "@.fieldTransformations[0].output[0] == 'full_hostname' &&" + + "@.fieldTransformations[0].output[1] == 'domain_without_subdomains' &&" + + "@.fieldTransformations[0].config.full_hostname == 'URL_TO_HOST(url)' &&" + + "@.fieldTransformations[0].config.domain_without_subdomains == 'DOMAIN_REMOVE_SUBDOMAINS(full_hostname)')]").exists()) + .andExpect(jsonPath("$[?(@.parserClassName == 'org.apache.metron.parsers.bro.BasicBroParser' && " + + "@.sensorTopic == 'broTest')]").exists()); + + this.mockMvc.perform(delete("/sensorParserConfig/squidTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(get("/sensorParserConfigs/squid")) + this.mockMvc.perform(get("/sensorParserConfig/squidTest").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(delete("/sensorParserConfigw/squid")) + this.mockMvc.perform(delete("/sensorParserConfig/squidTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/sensorParserConfigs")) + this.mockMvc.perform(get("/sensorParserConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$[0].parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) - .andExpect(jsonPath("$[0].sensorTopic").value("bro")) - .andExpect(jsonPath("$[0].parserConfig").isEmpty()); + .andExpect(jsonPath("$[?(@.sensorTopic == 'squidTest')]").doesNotExist()) + .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").exists()); - this.mockMvc.perform(delete("/sensorParserConfigs/bro")) + this.mockMvc.perform(delete("/sensorParserConfig/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(delete("/sensorParserConfigs/bro")) + this.mockMvc.perform(delete("/sensorParserConfig/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/sensorParserConfigs")) + this.mockMvc.perform(get("/sensorParserConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$", hasSize(0))); + .andExpect(jsonPath("$[?(@.sensorTopic == 'squidTest')]").doesNotExist()) + .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").doesNotExist()); - runner.stop(); + this.mockMvc.perform(get("/sensorParserConfig/list/available").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.Bro").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$.Grok").value("org.apache.metron.parsers.GrokParser")); + + this.mockMvc.perform(get("/sensorParserConfig/reload/available").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.Bro").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$.Grok").value("org.apache.metron.parsers.GrokParser")); + + this.mockMvc.perform(post("/sensorParserConfig/parseMessage").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(parseRequest)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.elapsed").value(415)) + .andExpect(jsonPath("$.code").value(200)) + .andExpect(jsonPath("$.ip_dst_addr").value("207.109.73.154")) + .andExpect(jsonPath("$.method").value("GET")) + .andExpect(jsonPath("$.bytes").value(337891)) + .andExpect(jsonPath("$.action").value("TCP_MISS")) + .andExpect(jsonPath("$.ip_src_addr").value("127.0.0.1")) + .andExpect(jsonPath("$.url").value("http://www.aliexpress.com/af/shoes.html?")) + .andExpect(jsonPath("$.timestamp").value(1467011157401L)); + + //runner.stop(); } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java new file mode 100644 index 0000000000..fb72c4ea71 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java @@ -0,0 +1,252 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.adrianwalker.multilinestring.Multiline; +import org.apache.commons.io.FileUtils; +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.repository.SensorParserConfigVersionRepository; +import org.apache.metron.rest.service.GrokService; +import org.apache.metron.rest.service.SensorParserConfigService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import javax.sql.DataSource; +import java.io.File; +import java.io.IOException; +import java.util.Map; + +import static org.hamcrest.Matchers.isEmptyOrNullString; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class SensorParserConfigHistoryControllerIntegrationTest { + + /** + { + "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", + "sensorTopic":"broTest", + "parserConfig": { + "version":1 + } + } + */ + @Multiline + public static String broJson1; + + /** + { + "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", + "sensorTopic":"broTest", + "parserConfig": { + "version":2 + } + } + */ + @Multiline + public static String broJson2; + + /** + { + "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", + "sensorTopic":"broTest", + "parserConfig": { + "version":3 + } + } + */ + @Multiline + public static String broJson3; + + @Autowired + private Environment environment; + + @Autowired + private WebApplicationContext wac; + + @Autowired + private DataSource dataSource; + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private SensorParserConfigService sensorParserConfigService; + + @Autowired + private SensorParserConfigVersionRepository sensorParserConfigVersionRepository; + + private MockMvc mockMvc; + + private String user1 = "user1"; + private String user2 = "user2"; + private String password = "password"; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(get("/sensorParserInfo/broTest")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/sensorParserInfo/getall")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/sensorParserInfo/history/bro")) + .andExpect(status().isUnauthorized()); + } + + @Test + public void test() throws Exception { + cleanFileSystem(); + resetConfigs(); + resetAuditTables(); + SensorParserConfig bro3 = fromJson(broJson3); + SensorParserConfig bro2 = fromJson(broJson2); + + this.mockMvc.perform(get("/sensorParserConfigHistory/broTest").with(httpBasic(user1,password))) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson1)); + Thread.sleep(1000); + this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson2)); + Thread.sleep(1000); + this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user2,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson3)); + + assertEquals(bro3.getParserConfig().get("version"), fromJson(sensorParserConfigVersionRepository.findOne("broTest").getConfig()).getParserConfig().get("version")); + + String json = this.mockMvc.perform(get("/sensorParserConfigHistory/broTest").with(httpBasic(user1,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$.config.sensorTopic").value("broTest")) + .andExpect(jsonPath("$.config.parserConfig.version").value(3)) + .andExpect(jsonPath("$.createdBy").value(user1)) + .andExpect(jsonPath("$.modifiedBy").value(user2)) + .andReturn().getResponse().getContentAsString(); + + Map result = objectMapper.readValue(json, new TypeReference>() {}); + validateCreateModifiedByDate(result, false); + + this.mockMvc.perform(get("/sensorParserConfigHistory").with(httpBasic(user1,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[?(@.config.sensorTopic == 'broTest')]").exists()); + + this.mockMvc.perform(delete("/sensorParserConfig/broTest").with(httpBasic(user2,password)).with(csrf())); + + json = this.mockMvc.perform(get("/sensorParserConfigHistory/history/broTest").with(httpBasic(user1,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[0].config", isEmptyOrNullString())) + .andExpect(jsonPath("$[0].createdBy").value(user1)) + .andExpect(jsonPath("$[0].modifiedBy").value(user2)) + .andExpect(jsonPath("$[1].config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$[1].config.sensorTopic").value("broTest")) + .andExpect(jsonPath("$[1].config.parserConfig.version").value(3)) + .andExpect(jsonPath("$[1].createdBy").value(user1)) + .andExpect(jsonPath("$[1].modifiedBy").value(user2)) + .andExpect(jsonPath("$[2].config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$[2].config.sensorTopic").value("broTest")) + .andExpect(jsonPath("$[2].config.parserConfig.version").value(2)) + .andExpect(jsonPath("$[2].createdBy").value(user1)) + .andExpect(jsonPath("$[2].modifiedBy").value(user1)) + .andExpect(jsonPath("$[3].config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$[3].config.sensorTopic").value("broTest")) + .andExpect(jsonPath("$[3].config.parserConfig.version").value(1)) + .andExpect(jsonPath("$[3].createdBy").value(user1)) + .andExpect(jsonPath("$[3].modifiedBy").value(user1)) + .andReturn().getResponse().getContentAsString(); + + Map[] historyResults = objectMapper.readValue(json, new TypeReference[]>() {}); + validateCreateModifiedByDate(historyResults[0], false); + validateCreateModifiedByDate(historyResults[1], false); + validateCreateModifiedByDate(historyResults[2], false); + validateCreateModifiedByDate(historyResults[3], true); + + assertNull(sensorParserConfigVersionRepository.findOne("broTest")); + } + + private void validateCreateModifiedByDate(Map result, boolean shouldBeEqual) { + String createdDate = (String) result.get("createdDate"); + assertTrue("createdDate is not empty", createdDate != null && !"".equals(createdDate)); + String modifiedByDate = (String) result.get("modifiedByDate"); + assertTrue("modifiedByDate is not empty", modifiedByDate != null && !"".equals(modifiedByDate)); + if (shouldBeEqual) { + assertTrue("createdDate and modifiedByDate should be equal", createdDate.equals(modifiedByDate)); + } else { + assertTrue("createdDate and modifiedByDate should be different", !createdDate.equals(modifiedByDate)); + } + } + + private void cleanFileSystem() throws IOException { + File grokPath = new File(environment.getProperty(GrokService.GROK_PATH_SPRING_PROPERTY)); + if (grokPath.exists()) { + FileUtils.cleanDirectory(grokPath); + FileUtils.deleteDirectory(grokPath); + } + } + + private void resetConfigs() throws Exception { + for(SensorParserConfig sensorParserConfig: sensorParserConfigService.getAll()) { + sensorParserConfigService.delete(sensorParserConfig.getSensorTopic()); + } + } + + private void resetAuditTables() { + JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); + jdbcTemplate.execute("SET FOREIGN_KEY_CHECKS = 0"); + jdbcTemplate.execute("truncate table sensor_parser_config_version_aud"); + jdbcTemplate.execute("truncate table user_rev_entity"); + jdbcTemplate.execute("truncate table sensor_parser_config_version"); + jdbcTemplate.execute("SET FOREIGN_KEY_CHECKS = 1"); + } + + private SensorParserConfig fromJson(String json) throws IOException { + return objectMapper.readValue(json, new TypeReference() {}); + } +} 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 new file mode 100644 index 0000000000..203d3ad9f7 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StormControllerIntegrationTest.java @@ -0,0 +1,320 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.model.TopologyStatus; +import org.apache.metron.rest.model.TopologyStatusCode; +import org.apache.metron.rest.service.GlobalConfigService; +import org.apache.metron.rest.service.SensorParserConfigService; +import org.apache.metron.rest.service.StormService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.core.env.Environment; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasSize; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class StormControllerIntegrationTest { + + @Autowired + private Environment environment; + + @Autowired + private WebApplicationContext wac; + + @Autowired + private GlobalConfigService globalConfigService; + + @Autowired + private SensorParserConfigService sensorParserConfigService; + + private MockMvc mockMvc; + + private String user = "user"; + private String password = "password"; + + private String metronVersion; + + @Before + public void setup() throws Exception { + this.metronVersion = this.environment.getProperty("metron.version"); + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(get("/storm")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/broTest")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/parser/start/broTest")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/parser/stop/broTest")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/parser/activate/broTest")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/parser/deactivate/broTest")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/enrichment")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/enrichment/start")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/enrichment/stop")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/enrichment/activate")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/enrichment/deactivate")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/indexing")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/indexing/start")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/indexing/stop")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/indexing/activate")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/storm/indexing/deactivate")) + .andExpect(status().isUnauthorized()); + } + + @Test + public void test() throws Exception { + this.mockMvc.perform(get("/storm").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$", hasSize(0))); + + this.mockMvc.perform(get("/storm/broTest").with(httpBasic(user,password))) + .andExpect(status().isNotFound()); + + Map globalConfig = globalConfigService.get(); + if (globalConfig == null) { + globalConfig = new HashMap<>(); + } + globalConfigService.delete(); + sensorParserConfigService.delete("broTest"); + + this.mockMvc.perform(get("/storm/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); + + this.mockMvc.perform(get("/storm/parser/activate/broTest").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); + + this.mockMvc.perform(get("/storm/parser/deactivate/broTest").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); + + this.mockMvc.perform(get("/storm/parser/start/broTest").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.GLOBAL_CONFIG_MISSING.name())); + + globalConfigService.save(globalConfig); + + this.mockMvc.perform(get("/storm/parser/start/broTest").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.SENSOR_PARSER_CONFIG_MISSING.name())); + + SensorParserConfig sensorParserConfig = new SensorParserConfig(); + sensorParserConfig.setParserClassName("org.apache.metron.parsers.bro.BasicBroParser"); + sensorParserConfig.setSensorTopic("broTest"); + sensorParserConfigService.save(sensorParserConfig); + + this.mockMvc.perform(get("/storm/parser/start/broTest").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.name())); + + this.mockMvc.perform(get("/storm/broTest").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.name").value("broTest")) + .andExpect(jsonPath("$.id", containsString("broTest"))) + .andExpect(jsonPath("$.status").value("ACTIVE")) + .andExpect(jsonPath("$.latency").exists()) + .andExpect(jsonPath("$.throughput").exists()); + + this.mockMvc.perform(get("/storm").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[?(@.name == 'broTest' && @.status == 'ACTIVE')]").exists()); + + this.mockMvc.perform(get("/storm/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); + + this.mockMvc.perform(get("/storm/enrichment").with(httpBasic(user,password))) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(get("/storm/enrichment/activate").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); + + this.mockMvc.perform(get("/storm/enrichment/deactivate").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); + + this.mockMvc.perform(get("/storm/enrichment/stop?stopNow=true").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); + + this.mockMvc.perform(get("/storm/enrichment/start").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.toString())); + + this.mockMvc.perform(get("/storm/enrichment/deactivate").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); + + this.mockMvc.perform(get("/storm/enrichment/deactivate").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); + + this.mockMvc.perform(get("/storm/enrichment/activate").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.ACTIVE.name())); + + this.mockMvc.perform(get("/storm/enrichment").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.name").value("enrichment")) + .andExpect(jsonPath("$.id", containsString("enrichment"))) + .andExpect(jsonPath("$.status").value("ACTIVE")) + .andExpect(jsonPath("$.latency").exists()) + .andExpect(jsonPath("$.throughput").exists()); + + this.mockMvc.perform(get("/storm").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[?(@.name == 'enrichment' && @.status == 'ACTIVE')]").exists()); + + this.mockMvc.perform(get("/storm/enrichment/stop").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); + + this.mockMvc.perform(get("/storm/indexing").with(httpBasic(user,password))) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(get("/storm/indexing/activate").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); + + this.mockMvc.perform(get("/storm/indexing/deactivate").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); + + this.mockMvc.perform(get("/storm/indexing/stop?stopNow=true").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); + + this.mockMvc.perform(get("/storm/indexing/start").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.toString())); + + this.mockMvc.perform(get("/storm/indexing/deactivate").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); + + this.mockMvc.perform(get("/storm/indexing/activate").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.ACTIVE.name())); + + this.mockMvc.perform(get("/storm/indexing").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.name").value("indexing")) + .andExpect(jsonPath("$.id", containsString("indexing"))) + .andExpect(jsonPath("$.status").value("ACTIVE")) + .andExpect(jsonPath("$.latency").exists()) + .andExpect(jsonPath("$.throughput").exists()); + + this.mockMvc.perform(get("/storm").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[?(@.name == 'indexing' && @.status == 'ACTIVE')]").exists()); + + this.mockMvc.perform(get("/storm/indexing/stop").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); + + this.mockMvc.perform(get("/storm/client/status").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.stormClientVersionInstalled").value("1.0.1")) + .andExpect(jsonPath("$.parserScriptPath").value("/usr/metron/" + metronVersion + "/bin/start_parser_topology.sh")) + .andExpect(jsonPath("$.enrichmentScriptPath").value("/usr/metron/" + metronVersion + "/bin/start_enrichment_topology.sh")) + .andExpect(jsonPath("$.indexingScriptPath").value("/usr/metron/" + metronVersion + "/bin/start_elasticsearch_topology.sh")); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java new file mode 100644 index 0000000000..e9d1b77df4 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java @@ -0,0 +1,120 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.adrianwalker.multilinestring.Multiline; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.hasSize; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class TransformationControllerIntegrationTest { + + private String valid = "TO_LOWER(test)"; + private String invalid = "BAD_FUNCTION(test)"; + private String rulesJson = "[\"" + valid + "\",\"" + invalid + "\"]"; + + /** + { + "sensorParserConfig": { "fieldTransformations" : [{"transformation" : "STELLAR","output" : ["url_host"],"config" : {"url_host" : "TO_LOWER(URL_TO_HOST(url))"}}]}, + "sampleData": {"url": "https://caseystella.com/blog"} + } + */ + @Multiline + public static String sensorParseConfigJson; + + + @Autowired + private WebApplicationContext wac; + + private MockMvc mockMvc; + + private String user = "user"; + private String password = "password"; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(post("/transformation/validate/rules").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(post("/transformation/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/transformation/list")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/transformation/list/functions")) + .andExpect(status().isUnauthorized()); + } + + @Test + public void test() throws Exception { + this.mockMvc.perform(post("/transformation/validate/rules").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.['" + valid + "']").value(Boolean.TRUE)) + .andExpect(jsonPath("$.['" + invalid + "']").value(Boolean.FALSE)); + + this.mockMvc.perform(post("/transformation/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.url").value("https://caseystella.com/blog")) + .andExpect(jsonPath("$.url_host").value("caseystella.com")); + + this.mockMvc.perform(get("/transformation/list").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$", hasSize(greaterThan(0)))); + + this.mockMvc.perform(get("/transformation/list/functions").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$", hasSize(greaterThan(0)))); + + this.mockMvc.perform(get("/transformation/list/simple/functions").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$", hasSize(greaterThan(0)))); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java new file mode 100644 index 0000000000..0e24483893 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java @@ -0,0 +1,64 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class UserControllerIntegrationTest { + + private MockMvc mockMvc; + + @Autowired + private WebApplicationContext wac; + + private String user = "user"; + private String password = "password"; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void test() throws Exception { + this.mockMvc.perform(get("/user")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get("/user").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().string(user)); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/generator/SampleDataGenerator.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/generator/SampleDataGenerator.java new file mode 100644 index 0000000000..8557035f5c --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/generator/SampleDataGenerator.java @@ -0,0 +1,170 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.generator; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.PosixParser; +import org.apache.commons.io.FileUtils; +import org.apache.kafka.clients.producer.KafkaProducer; +import org.apache.kafka.clients.producer.ProducerRecord; +import org.json.simple.parser.ParseException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SampleDataGenerator { + + private Logger LOG = LoggerFactory.getLogger(SampleDataGenerator.class); + + private Map> sampleData = new HashMap<>(); + private Map indexes = new HashMap<>(); + private KafkaProducer kafkaProducer; + private String brokerUrl; + private Integer num = -1; + private String selectedSensorType = null; + private Integer delay = 1000; + + public void setBrokerUrl(String brokerUrl) { + this.brokerUrl = brokerUrl; + } + + public void setNum(Integer num) { + this.num = num; + } + + public void setSelectedSensorType(String selectedSensorType) { + this.selectedSensorType = selectedSensorType; + } + + public void setDelay(Integer delay) { + this.delay = delay; + } + + public static void main(String[] args) throws org.apache.commons.cli.ParseException, IOException, ParseException { + CommandLineParser parser = new PosixParser(); + CommandLine cli = parser.parse(getOptions(), args); + Integer num = Integer.parseInt(cli.getOptionValue("n", "-1")); + String selectedSensorType = cli.getOptionValue("s"); + Integer delay = Integer.parseInt(cli.getOptionValue("d", "1000")); + String path = cli.getOptionValue("p"); + if (selectedSensorType == null || path == null) { + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp( "sample_data_generator", getOptions()); + } else { + SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(); + sampleDataGenerator.setNum(num); + sampleDataGenerator.setSelectedSensorType(selectedSensorType); + sampleDataGenerator.setDelay(delay); + sampleDataGenerator.generateSampleData(path); + } + + } + + private static Options getOptions() { + Options options = new Options(); + options.addOption("b", "brokerUrl", true, "Kafka Broker Url"); + options.addOption("n", "num", false, "Number of messages to emit"); + options.addOption("s", "sensorType", true, "Emit messages to this topic"); + options.addOption("d", "delay", false, "Number of milliseconds to wait between each message. Defaults to 1 second"); + options.addOption("p", "path", true, "Local path to data file"); + return options; + } + + public void generateSampleData(String path) throws IOException, ParseException { + loadData(path); + startClients(); + try { + emitData(num, selectedSensorType, delay); + } finally { + stopClients(); + } + } + + private void loadData(String sampleDataPath) throws IOException, ParseException { + sampleData.put(selectedSensorType, FileUtils.readLines(new File(sampleDataPath))); + indexes.put(selectedSensorType, 0); + } + + private void emitData(int num, String selectedSensorType, int delay) { + int count = 0; + boolean continueEmitting = false; + do { + for (String sensorType : sampleData.keySet()) { + if (selectedSensorType == null || selectedSensorType.equals(sensorType)) { + List sensorData = sampleData.get(sensorType); + int index = indexes.get(sensorType); + String message = sensorData.get(index++); + emitSensorData(sensorType, message, delay); + if (num != -1 && ++count >= num) { + continueEmitting = false; + break; + } + continueEmitting = true; + if (index == sensorData.size()) { + index = 0; + } + indexes.put(sensorType, index); + } + } + } while (continueEmitting); + } + + private void emitSensorData(String sensorType, String message, int delay) { + try { + Thread.sleep(delay); + } catch (InterruptedException e) { + e.printStackTrace(); + } + LOG.info("Emitting " + sensorType + " message " + message); + emitToKafka(sensorType, message); + } + + private void startClients() { + startKafka(); + } + + private void startKafka() { + Map producerConfig = new HashMap<>(); + producerConfig.put("bootstrap.servers", brokerUrl); + producerConfig.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); + producerConfig.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); + kafkaProducer = new KafkaProducer<>(producerConfig); + } + + private void stopClients() { + stopKafka(); + } + + private void stopKafka() { + LOG.info("Stopping Kafka producer"); + kafkaProducer.close(); + } + + private void emitToKafka(String topic, String message) { + kafkaProducer.send(new ProducerRecord(topic, message)); + } + +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java new file mode 100644 index 0000000000..26f5af5c54 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java @@ -0,0 +1,177 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.mock; + +import org.apache.metron.rest.model.TopologyStatusCode; +import org.apache.metron.rest.service.StormCLIWrapper; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class MockStormCLIClientWrapper extends StormCLIWrapper { + + private final Map parsersStatus = new HashMap<>(); + private TopologyStatusCode enrichmentStatus = TopologyStatusCode.TOPOLOGY_NOT_FOUND; + private TopologyStatusCode indexingStatus = TopologyStatusCode.TOPOLOGY_NOT_FOUND; + + public Set getParserTopologyNames() { + return parsersStatus.keySet(); + } + + public TopologyStatusCode getParserStatus(String name) { + TopologyStatusCode parserStatus = parsersStatus.get(name); + if (parserStatus == null) { + return TopologyStatusCode.TOPOLOGY_NOT_FOUND; + } else { + return parserStatus; + } + } + + @Override + public int startParserTopology(String name) throws IOException, InterruptedException { + TopologyStatusCode parserStatus = parsersStatus.get(name); + if (parserStatus == null || parserStatus == TopologyStatusCode.TOPOLOGY_NOT_FOUND) { + parsersStatus.put(name, TopologyStatusCode.ACTIVE); + return 0; + } else { + return 1; + } + } + + @Override + public int stopParserTopology(String name, boolean stopNow) throws IOException, InterruptedException { + TopologyStatusCode parserStatus = parsersStatus.get(name); + if (parserStatus == TopologyStatusCode.ACTIVE) { + parsersStatus.put(name, TopologyStatusCode.TOPOLOGY_NOT_FOUND); + return 0; + } else { + return 1; + } + } + + public int activateParserTopology(String name) { + TopologyStatusCode parserStatus = parsersStatus.get(name); + if (parserStatus == TopologyStatusCode.INACTIVE || parserStatus == TopologyStatusCode.ACTIVE) { + parsersStatus.put(name, TopologyStatusCode.ACTIVE); + return 0; + } else { + return 1; + } + } + + public int deactivateParserTopology(String name) { + TopologyStatusCode parserStatus = parsersStatus.get(name); + if (parserStatus == TopologyStatusCode.INACTIVE || parserStatus == TopologyStatusCode.ACTIVE) { + parsersStatus.put(name, TopologyStatusCode.INACTIVE); + return 0; + } else { + return 1; + } + } + + public TopologyStatusCode getEnrichmentStatus() { + return enrichmentStatus; + } + + @Override + public int startEnrichmentTopology() throws IOException, InterruptedException { + if (enrichmentStatus == TopologyStatusCode.TOPOLOGY_NOT_FOUND) { + enrichmentStatus = TopologyStatusCode.ACTIVE; + return 0; + } else { + return 1; + } + } + + @Override + public int stopEnrichmentTopology(boolean stopNow) throws IOException, InterruptedException { + if (enrichmentStatus == TopologyStatusCode.ACTIVE) { + enrichmentStatus = TopologyStatusCode.TOPOLOGY_NOT_FOUND; + return 0; + } else { + return 1; + } + } + + public int activateEnrichmentTopology() { + if (enrichmentStatus == TopologyStatusCode.INACTIVE || enrichmentStatus == TopologyStatusCode.ACTIVE) { + enrichmentStatus = TopologyStatusCode.ACTIVE; + return 0; + } else { + return 1; + } + } + + public int deactivateEnrichmentTopology() { + if (enrichmentStatus == TopologyStatusCode.INACTIVE || enrichmentStatus == TopologyStatusCode.ACTIVE) { + enrichmentStatus = TopologyStatusCode.INACTIVE; + return 0; + } else { + return 1; + } + } + + public TopologyStatusCode getIndexingStatus() { + return indexingStatus; + } + + @Override + public int startIndexingTopology() throws IOException, InterruptedException { + if (indexingStatus == TopologyStatusCode.TOPOLOGY_NOT_FOUND) { + indexingStatus = TopologyStatusCode.ACTIVE; + return 0; + } else { + return 1; + } + } + + @Override + public int stopIndexingTopology(boolean stopNow) throws IOException, InterruptedException { + if (indexingStatus == TopologyStatusCode.ACTIVE) { + indexingStatus = TopologyStatusCode.TOPOLOGY_NOT_FOUND; + return 0; + } else { + return 1; + } + } + + public int activateIndexingTopology() { + if (indexingStatus == TopologyStatusCode.INACTIVE || indexingStatus == TopologyStatusCode.ACTIVE) { + indexingStatus = TopologyStatusCode.ACTIVE; + return 0; + } else { + return 1; + } + } + + public int deactivateIndexingTopology() { + if (indexingStatus == TopologyStatusCode.INACTIVE || indexingStatus == TopologyStatusCode.ACTIVE) { + indexingStatus = TopologyStatusCode.INACTIVE; + return 0; + } else { + return 1; + } + } + + @Override + protected String stormClientVersionInstalled() throws IOException { + return "1.0.1"; + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java new file mode 100644 index 0000000000..88486af60e --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java @@ -0,0 +1,116 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.mock; + +import org.apache.metron.rest.model.TopologyStatus; +import org.apache.metron.rest.model.TopologyStatusCode; +import org.apache.metron.rest.model.TopologySummary; +import org.apache.metron.rest.service.StormService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.web.client.RestClientException; +import org.springframework.web.client.RestTemplate; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MockStormRestTemplate extends RestTemplate { + + @Autowired + private Environment environment; + + private MockStormCLIClientWrapper mockStormCLIClientWrapper; + + public void setMockStormCLIClientWrapper(MockStormCLIClientWrapper mockStormCLIClientWrapper) { + this.mockStormCLIClientWrapper = mockStormCLIClientWrapper; + } + + @Override + public Object getForObject(String url, Class responseType, Object... urlVariables) throws RestClientException { + Object response = null; + if (url.equals("http://" + environment.getProperty(StormService.STORM_UI_SPRING_PROPERTY) + StormService.TOPOLOGY_SUMMARY_URL)) { + TopologySummary topologySummary = new TopologySummary(); + List topologyStatusList = new ArrayList<>(); + for(String name: mockStormCLIClientWrapper.getParserTopologyNames()) { + topologyStatusList.add(getTopologyStatus(name)); + } + TopologyStatusCode enrichmentStatus = mockStormCLIClientWrapper.getEnrichmentStatus(); + if (enrichmentStatus != TopologyStatusCode.TOPOLOGY_NOT_FOUND) { + topologyStatusList.add(getTopologyStatus("enrichment")); + } + TopologyStatusCode indexingStatus = mockStormCLIClientWrapper.getIndexingStatus(); + if (indexingStatus != TopologyStatusCode.TOPOLOGY_NOT_FOUND) { + topologyStatusList.add(getTopologyStatus("indexing")); + } + topologySummary.setTopologies(topologyStatusList.toArray(new TopologyStatus[topologyStatusList.size()])); + response = topologySummary; + } else if (url.startsWith("http://" + environment.getProperty(StormService.STORM_UI_SPRING_PROPERTY) + StormService.TOPOLOGY_URL + "/")){ + String name = url.substring(url.lastIndexOf('/') + 1, url.length()).replaceFirst("-id", ""); + response = getTopologyStatus(name); + } + return response; + } + + private TopologyStatus getTopologyStatus(String name) { + TopologyStatus topologyStatus = new TopologyStatus(); + topologyStatus.setName(name); + topologyStatus.setId(name + "-id"); + if ("enrichment".equals(name)) { + topologyStatus.setStatus(mockStormCLIClientWrapper.getEnrichmentStatus()); + } else if ("indexing".equals(name)) { + topologyStatus.setStatus(mockStormCLIClientWrapper.getIndexingStatus()); + } else { + topologyStatus.setStatus(mockStormCLIClientWrapper.getParserStatus(name)); + } + return topologyStatus; + } + + @Override + public Object postForObject(String url, Object request, Class responseType, Object... uriVariables) throws RestClientException { + Map result = new HashMap<>(); + String[] urlParts = url.split("/"); + String name = urlParts[urlParts.length - 2].replaceFirst("-id", ""); + String action = urlParts[urlParts.length - 1]; + int returnCode = 0; + if (action.equals("activate")) { + if (name.equals("enrichment")) { + returnCode = mockStormCLIClientWrapper.activateEnrichmentTopology(); + } else if (name.equals("indexing")) { + returnCode = mockStormCLIClientWrapper.activateIndexingTopology(); + } else { + returnCode = mockStormCLIClientWrapper.activateParserTopology(name); + } + } else if (action.equals("deactivate")){ + if (name.equals("enrichment")) { + returnCode = mockStormCLIClientWrapper.deactivateEnrichmentTopology(); + } else if (name.equals("indexing")) { + returnCode = mockStormCLIClientWrapper.deactivateIndexingTopology(); + } else { + returnCode = mockStormCLIClientWrapper.deactivateParserTopology(name); + } + } + if (returnCode == 0) { + result.put("status", "success"); + } else { + result.put("status", "error"); + } + return result; + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java new file mode 100644 index 0000000000..ce50827664 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java @@ -0,0 +1,115 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.commons.io.FileUtils; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.Path; +import org.apache.metron.rest.config.HadoopConfig; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import java.io.File; +import java.io.IOException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes={HadoopConfig.class, HdfsServiceTest.HdfsServiceTestContextConfiguration.class}) +@ActiveProfiles("test") +public class HdfsServiceTest { + + @Configuration + @Profile("test") + static class HdfsServiceTestContextConfiguration { + + @Bean + public HdfsService hdfsService() { + return new HdfsService(); + } + } + + @Autowired + private HdfsService hdfsService; + + @Test + public void test() throws IOException { + String rootDir = "./src/test/tmp"; + File rootFile = new File(rootDir); + Path rootPath = new Path(rootDir); + if (rootFile.exists()) { + FileUtils.cleanDirectory(rootFile); + FileUtils.deleteDirectory(rootFile); + } + assertEquals(true, rootFile.mkdir()); + String fileName1 = "fileName1"; + String fileName2 = "fileName2"; + Path path1 = new Path(rootDir, fileName1); + String value1 = "value1"; + String value2 = "value2"; + Path path2 = new Path(rootDir, fileName2); + String invalidFile = "invalidFile"; + Path pathInvalidFile = new Path(rootDir, invalidFile); + + FileStatus[] fileStatuses = hdfsService.list(new Path(rootDir)); + assertEquals(0, fileStatuses.length); + + + hdfsService.write(path1, value1.getBytes()); + assertEquals(value1, FileUtils.readFileToString(new File(rootDir, fileName1))); + assertEquals(value1, new String(hdfsService.read(path1))); + + fileStatuses = hdfsService.list(rootPath); + assertEquals(1, fileStatuses.length); + assertEquals(fileName1, fileStatuses[0].getPath().getName()); + + hdfsService.write(path2, value2.getBytes()); + assertEquals(value2, FileUtils.readFileToString(new File(rootDir, fileName2))); + assertEquals(value2, new String(hdfsService.read(path2))); + + fileStatuses = hdfsService.list(rootPath); + assertEquals(2, fileStatuses.length); + assertEquals(fileName1, fileStatuses[0].getPath().getName()); + assertEquals(fileName1, fileStatuses[0].getPath().getName()); + + assertEquals(true, hdfsService.delete(path1, false)); + fileStatuses = hdfsService.list(rootPath); + assertEquals(1, fileStatuses.length); + assertEquals(fileName2, fileStatuses[0].getPath().getName()); + assertEquals(true, hdfsService.delete(path2, false)); + fileStatuses = hdfsService.list(rootPath); + assertEquals(0, fileStatuses.length); + + try { + hdfsService.read(pathInvalidFile); + fail("Exception should be thrown when reading invalid file name"); + } catch(IOException e) { + } + assertEquals(false, hdfsService.delete(pathInvalidFile, false)); + + FileUtils.deleteDirectory(new File(rootDir)); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java index 0d1242ce2b..ec6c2a0565 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java @@ -17,6 +17,7 @@ */ package org.apache.metron.rest.service; +import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.DeleteBuilder; import org.apache.curator.framework.api.GetChildrenBuilder; @@ -24,6 +25,7 @@ import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.configuration.SensorParserConfig; import org.apache.metron.common.utils.JSONUtils; +import org.apache.metron.rest.repository.SensorParserConfigVersionRepository; import org.apache.zookeeper.KeeperException; import org.junit.Before; import org.junit.Test; @@ -39,7 +41,9 @@ import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.mockStatic; @@ -55,9 +59,18 @@ public class SensorParserConfigTest { @Mock private DeleteBuilder deleteBuilder; + @Mock + private ObjectMapper objectMapper; + @Mock private CuratorFramework client; + @Mock + private GrokService grokService; + + @Mock + private SensorParserConfigVersionRepository sensorParserRepository; + @InjectMocks private SensorParserConfigService sensorParserConfigService; @@ -66,6 +79,7 @@ public void setUp() throws Exception { MockitoAnnotations.initMocks(this); Mockito.when(client.getChildren()).thenReturn(getChildrenBuilder); Mockito.when(client.delete()).thenReturn(deleteBuilder); + } @Test @@ -73,32 +87,34 @@ public void test() throws Exception { mockStatic(ConfigurationsUtils.class); SensorParserConfig broParserConfig = new SensorParserConfig(); broParserConfig.setParserClassName("org.apache.metron.parsers.bro.BasicBroParser"); - broParserConfig.setSensorTopic("bro"); + broParserConfig.setSensorTopic("broTest"); + Mockito.when(objectMapper.writeValueAsString(broParserConfig)).thenReturn(new String(JSONUtils.INSTANCE.toJSON(broParserConfig))); + Mockito.when(grokService.isGrokConfig(broParserConfig)).thenReturn(false); sensorParserConfigService.save(broParserConfig); verifyStatic(times(1)); - ConfigurationsUtils.writeSensorParserConfigToZookeeper("bro", JSONUtils.INSTANCE.toJSON(broParserConfig), client); + ConfigurationsUtils.writeSensorParserConfigToZookeeper("broTest", JSONUtils.INSTANCE.toJSON(broParserConfig), client); - PowerMockito.when(ConfigurationsUtils.readSensorParserConfigFromZookeeper("bro", client)).thenReturn(broParserConfig); - assertEquals(broParserConfig, sensorParserConfigService.findOne("bro")); + PowerMockito.when(ConfigurationsUtils.readSensorParserConfigFromZookeeper("broTest", client)).thenReturn(broParserConfig); + assertEquals(broParserConfig, sensorParserConfigService.findOne("broTest")); SensorParserConfig squidParserConfig = new SensorParserConfig(); squidParserConfig.setParserClassName("org.apache.metron.parsers.GrokParser"); squidParserConfig.setSensorTopic("squid"); - PowerMockito.when(ConfigurationsUtils.readSensorParserConfigFromZookeeper("squid", client)).thenReturn(squidParserConfig); + PowerMockito.when(ConfigurationsUtils.readSensorParserConfigFromZookeeper("squidTest", client)).thenReturn(squidParserConfig); List allTypes = new ArrayList() {{ - add("bro"); - add("squid"); + add("broTest"); + add("squidTest"); }}; Mockito.when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())).thenReturn(allTypes); - assertEquals(new ArrayList() {{ add(broParserConfig); add(squidParserConfig); }}, sensorParserConfigService.findAll()); + assertEquals(new ArrayList() {{ add(broParserConfig); add(squidParserConfig); }}, sensorParserConfigService.getAll()); Mockito.when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())).thenThrow(new KeeperException.NoNodeException()); - assertEquals(new ArrayList<>(), sensorParserConfigService.findAll()); + assertEquals(new ArrayList<>(), sensorParserConfigService.getAll()); - assertTrue(sensorParserConfigService.delete("bro")); - verify(deleteBuilder, times(1)).forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro"); - Mockito.when(deleteBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenThrow(new KeeperException.NoNodeException()); - assertFalse(sensorParserConfigService.delete("bro")); + assertTrue(sensorParserConfigService.delete("broTest")); + verify(deleteBuilder, times(1)).forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/broTest"); + Mockito.when(deleteBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/broTest")).thenThrow(new KeeperException.NoNodeException()); + assertFalse(sensorParserConfigService.delete("broTest")); } } diff --git a/metron-interface/pom.xml b/metron-interface/pom.xml index 07d6e1c1c1..99e83fc0b8 100644 --- a/metron-interface/pom.xml +++ b/metron-interface/pom.xml @@ -21,7 +21,7 @@ org.apache.metron Metron - 0.2.1BETA + 0.3.0 Interfaces for Metron https://metron.incubator.apache.org/ @@ -61,11 +61,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 2.18 - org.apache.maven.plugins maven-pmd-plugin From 50b4cf4aeb5a084d43a2c70d9a364dc81b7c3a42 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Wed, 30 Nov 2016 12:38:10 -0600 Subject: [PATCH 07/54] Added start script and fixed Maven issues --- metron-interface/metron-rest/pom.xml | 12 +++++++++ .../src/main/resources/application-docker.yml | 9 +------ .../metron-rest/src/main/scripts/start.sh | 26 +++++++++++++++++++ 3 files changed, 39 insertions(+), 8 deletions(-) create mode 100755 metron-interface/metron-rest/src/main/scripts/start.sh diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index 066ecff01c..7f48c6ebf3 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -108,6 +108,14 @@ com.fasterxml.jackson.core jackson-databind + + org.apache.metron + metron-profiler-client + + + org.apache.metron + metron-writer + @@ -193,6 +201,10 @@ org.slf4j log4j-over-slf4j + + javax.servlet + servlet-api + diff --git a/metron-interface/metron-rest/src/main/resources/application-docker.yml b/metron-interface/metron-rest/src/main/resources/application-docker.yml index 918fb0788f..bab191899c 100644 --- a/metron-interface/metron-rest/src/main/resources/application-docker.yml +++ b/metron-interface/metron-rest/src/main/resources/application-docker.yml @@ -15,7 +15,7 @@ # limitations under the License. docker: host: - address: 192.168.99.107 + address: 192.168.99.100 compose: path: ../../metron-docker/docker-compose.yml @@ -30,13 +30,6 @@ spring: hibernate: ddl-auto: update -logging: - level: - root: ERROR - -server: - contextPath: /api/v1 - zookeeper: url: ${docker.host.address}:2181 diff --git a/metron-interface/metron-rest/src/main/scripts/start.sh b/metron-interface/metron-rest/src/main/scripts/start.sh new file mode 100755 index 0000000000..890215648b --- /dev/null +++ b/metron-interface/metron-rest/src/main/scripts/start.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +METRON_VERSION=0.3.0 +SCRIPTS_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_ROOT=$SCRIPTS_ROOT/../../.. +if [ "$#" -ne 1 ]; then + echo "Usage: start.sh " + echo "Path can be absolute or relative to $PROJECT_ROOT" +else + cd $PROJECT_ROOT && java -jar $PROJECT_ROOT/target/metron-rest-$METRON_VERSION.jar --spring.config.location=$1 +fi \ No newline at end of file From 46d0ff32c5317f5a6c55363cac0e948893bbf755 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Thu, 1 Dec 2016 18:02:37 -0600 Subject: [PATCH 08/54] Fixed pattern label bug --- .../apache/metron/rest/service/SensorParserConfigService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java index 474cd76415..330060e011 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -63,11 +63,11 @@ public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws Exc String serializedConfig; if (grokService.isGrokConfig(sensorParserConfig)) { grokService.addGrokPathToConfig(sensorParserConfig); + sensorParserConfig.getParserConfig().putIfAbsent(GrokService.GROK_PATTERN_LABEL_KEY, sensorParserConfig.getSensorTopic().toUpperCase()); String statement = (String) sensorParserConfig.getParserConfig().remove(GrokService.GROK_STATEMENT_KEY); serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), serializedConfig.getBytes(), client); sensorParserConfig.getParserConfig().put(GrokService.GROK_STATEMENT_KEY, statement); - sensorParserConfig.getParserConfig().put(GrokService.GROK_PATTERN_LABEL_KEY, sensorParserConfig.getSensorTopic().toUpperCase()); grokService.saveGrokStatement(sensorParserConfig); } else { serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); From 53c33409916d9bfb74bb928debbe60bba18349e6 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 5 Dec 2016 12:47:08 -0600 Subject: [PATCH 09/54] Fixes to parseMessage service. Now writes temporary grok statement to local filesystem. Also fixed some corner cases for sensorParserConfigHistoryService (history doesn't exist, deleting a history that doesn't exist, etc). Added context path to integration tests. --- metron-interface/metron-rest/README.md | 43 ++++++++ .../metron/rest/service/GrokService.java | 36 ++++--- .../SensorParserConfigHistoryService.java | 21 ++-- .../service/SensorParserConfigService.java | 5 +- .../src/main/resources/application-docker.yml | 2 +- .../src/main/resources/application.yml | 3 - ...GlobalConfigControllerIntegrationTest.java | 16 +-- .../GrokControllerIntegrationTest.java | 10 +- .../KafkaControllerIntegrationTest.java | 26 ++--- ...chmentConfigControllerIntegrationTest.java | 24 ++--- ...ParserConfigControllerIntegrationTest.java | 53 +++++---- ...onfigHistoryControllerIntegrationTest.java | 23 ++-- .../StormControllerIntegrationTest.java | 102 +++++++++--------- ...ansformationControllerIntegrationTest.java | 18 ++-- .../UserControllerIntegrationTest.java | 4 +- 15 files changed, 222 insertions(+), 164 deletions(-) create mode 100644 metron-interface/metron-rest/README.md diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md new file mode 100644 index 0000000000..20484048cf --- /dev/null +++ b/metron-interface/metron-rest/README.md @@ -0,0 +1,43 @@ +# Metron REST and Configuration UI + +This UI exposes and aids in sensor configuration. + +# Prerequisites + +* A running Metron cluster. +* A running instance of MySQL +* Java 8 installed + +# Installation + +1. Unpack RPM. This will create this directory structure: + +* bin + * start.sh +* lib + * metron-rest-.jar + +2. Create a MySQL user for the Config UI (http://dev.mysql.com/doc/refman/5.7/en/adding-users.html). + +3. Create a Config UI database in MySQL with this command: + + ``` +CREATE DATABASE IF NOT EXISTS metronrest + ``` + +4. Create an "application.yml" file with the contents of src/main/resource/application-docker.yml + +5. Update the configuration file in step 4: + +* substitute the appropriate Metron service urls (Kafka, Zookeeper, Storm, etc) in properties containing ${docker.host.address} +* update the "spring.datasource.username" and "spring.datasource.password" properties using credentials from step 2 + +6. Start the UI with this command: + + ``` +./bin/start.sh path_to_config_file_from_step_4 + ``` + +# Usage + +The exposed REST endpoints can be accessed at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. \ No newline at end of file diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java index f5cb511590..ce218aca5c 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java @@ -26,7 +26,9 @@ import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; +import java.io.File; import java.io.FileNotFoundException; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.StringReader; @@ -86,16 +88,21 @@ public void addGrokStatementToConfig(SensorParserConfig sensorParserConfig) thro String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); if (grokPath != null) { try { - grokStatement = getGrokStatement(grokPath); + String fullGrokStatement = getGrokStatement(grokPath); + String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); + grokStatement = fullGrokStatement.replaceFirst(patternLabel + " ", ""); } catch(FileNotFoundException e) {} } sensorParserConfig.getParserConfig().put(GROK_STATEMENT_KEY, grokStatement); } public void addGrokPathToConfig(SensorParserConfig sensorParserConfig) { - String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); - if (grokStatement != null) { - sensorParserConfig.getParserConfig().put(GROK_PATH_KEY, getGrokPath(sensorParserConfig.getSensorTopic()).toString()); + if (sensorParserConfig.getParserConfig().get(GROK_PATH_KEY) == null) { + String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); + if (grokStatement != null) { + sensorParserConfig.getParserConfig().put(GROK_PATH_KEY, + new Path(environment.getProperty(GROK_PATH_SPRING_PROPERTY), sensorParserConfig.getSensorTopic()).toString()); + } } } @@ -112,26 +119,25 @@ public void saveTemporaryGrokStatement(SensorParserConfig sensorParserConfig) th } private void saveGrokStatement(SensorParserConfig sensorParserConfig, boolean isTemporary) throws IOException { + String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); + String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); + String fullGrokStatement = patternLabel + " " + grokStatement; if (grokStatement != null) { if (!isTemporary) { - hdfsService.write(getGrokPath(sensorParserConfig.getSensorTopic()), grokStatement.getBytes()); + hdfsService.write(new Path(grokPath), fullGrokStatement.getBytes()); } else { - hdfsService.write(getTempGrokPath(sensorParserConfig.getSensorTopic()), grokStatement.getBytes()); + FileWriter fileWriter = new FileWriter(new File(grokPath)); + fileWriter.write(fullGrokStatement); + fileWriter.close(); } } } - public Path getGrokPath(String name) { - return new Path(environment.getProperty(GROK_PATH_SPRING_PROPERTY), name); - } - - public Path getTempGrokPath(String name) { - return new Path(environment.getProperty(GROK_PATH_SPRING_PROPERTY) + "/temp", name); - } - public void deleteTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws IOException { - hdfsService.delete(getTempGrokPath(sensorParserConfig.getSensorTopic()), false); + String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); + File file = new File(grokPath); + file.delete(); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java index 0be71431e0..4ef392fd40 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java @@ -63,16 +63,18 @@ public SensorParserConfigHistory findOne(String name) throws Exception { .getSingleResult(); SensorParserConfigVersion sensorParserConfigVersion = (SensorParserConfigVersion) latestResults[0]; sensorParserConfigHistory = new SensorParserConfigHistory(); - sensorParserConfigHistory.setConfig(deserializeSensorParserConfig(sensorParserConfigVersion.getConfig())); - + String config = sensorParserConfigVersion.getConfig(); + if (config != null) { + sensorParserConfigHistory.setConfig(deserializeSensorParserConfig(config)); + if (grokService.isGrokConfig(sensorParserConfigHistory.getConfig())) { + grokService.addGrokStatementToConfig(sensorParserConfigHistory.getConfig()); + } + } else { + sensorParserConfigHistory.setConfig(null); + } UserRevEntity latestUserRevEntity = (UserRevEntity) latestResults[1]; sensorParserConfigHistory.setModifiedBy(latestUserRevEntity.getUsername()); sensorParserConfigHistory.setModifiedByDate(new DateTime(latestUserRevEntity.getTimestamp())); - - if (grokService.isGrokConfig(sensorParserConfigHistory.getConfig())) { - grokService.addGrokStatementToConfig(sensorParserConfigHistory.getConfig()); - } - Object[] firstResults = (Object[]) reader.createQuery().forRevisionsOfEntity(SensorParserConfigVersion.class, false, true) .add(AuditEntity.property("name").eq(name)) .addOrder(AuditEntity.revisionNumber().asc()) @@ -83,6 +85,11 @@ public SensorParserConfigHistory findOne(String name) throws Exception { sensorParserConfigHistory.setCreatedDate(new DateTime(firstUserRevEntity.getTimestamp())); } catch (NoResultException e){ + SensorParserConfig sensorParserConfig = sensorParserConfigService.findOne(name); + if (sensorParserConfig != null) { + sensorParserConfigHistory = new SensorParserConfigHistory(); + sensorParserConfigHistory.setConfig(sensorParserConfig); + } } return sensorParserConfigHistory; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java index 330060e011..981d4d84c9 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -30,6 +30,7 @@ import org.json.simple.JSONObject; import org.reflections.Reflections; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -111,6 +112,8 @@ public boolean delete(String name) throws Exception { sensorParserRepository.delete(name); } catch (KeeperException.NoNodeException e) { return false; + } catch (EmptyResultDataAccessException e) { + return true; } return true; } @@ -156,8 +159,6 @@ public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws E throw new Exception("Could not find parser class name"); } else { MessageParser parser = (MessageParser) Class.forName(sensorParserConfig.getParserClassName()).newInstance(); - sensorParserConfig.getParserConfig().put(GrokService.GROK_PATTERN_LABEL_KEY, sensorParserConfig.getSensorTopic().toUpperCase()); - sensorParserConfig.getParserConfig().put(GrokService.GROK_PATH_KEY, grokService.getTempGrokPath(sensorParserConfig.getSensorTopic()).toString()); grokService.saveTemporaryGrokStatement(sensorParserConfig); parser.configure(sensorParserConfig.getParserConfig()); JSONObject results = parser.parse(parseMessageRequest.getSampleData().getBytes()).get(0); diff --git a/metron-interface/metron-rest/src/main/resources/application-docker.yml b/metron-interface/metron-rest/src/main/resources/application-docker.yml index bab191899c..7958b1bc2d 100644 --- a/metron-interface/metron-rest/src/main/resources/application-docker.yml +++ b/metron-interface/metron-rest/src/main/resources/application-docker.yml @@ -22,7 +22,7 @@ docker: spring: datasource: driverClassName: com.mysql.jdbc.Driver - url: jdbc:mysql://${docker.host.address}:3306/metronconfig + url: jdbc:mysql://${docker.host.address}:3306/metronrest username: root password: root platform: mysql diff --git a/metron-interface/metron-rest/src/main/resources/application.yml b/metron-interface/metron-rest/src/main/resources/application.yml index 2615510cca..6e078cd62f 100644 --- a/metron-interface/metron-rest/src/main/resources/application.yml +++ b/metron-interface/metron-rest/src/main/resources/application.yml @@ -20,9 +20,6 @@ logging: level: root: ERROR -server: - contextPath: /api/v1 - spring: jackson: date-format: yyyy-MM-dd HH:mm:ss diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java index 20039fb7b3..b90e49afc8 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java @@ -74,32 +74,32 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/globalConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) + this.mockMvc.perform(post("/api/v1/globalConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/globalConfig")) + this.mockMvc.perform(get("/api/v1/globalConfig")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(delete("/globalConfig").with(csrf())) + this.mockMvc.perform(delete("/api/v1/globalConfig").with(csrf())) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(get("/globalConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/globalConfig").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(post("/globalConfig").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) + this.mockMvc.perform(post("/api/v1/globalConfig").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))); - this.mockMvc.perform(get("/globalConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/globalConfig").with(httpBasic(user,password))) .andExpect(status().isOk()); - this.mockMvc.perform(delete("/globalConfig").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/globalConfig").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(delete("/globalConfig").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/globalConfig").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java index 8261e3db60..7b5c25d34a 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java @@ -77,16 +77,16 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/grok/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) + this.mockMvc.perform(post("/api/v1/grok/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/grok/list")) + this.mockMvc.perform(get("/api/v1/grok/list")) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(post("/grok/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) + this.mockMvc.perform(post("/api/v1/grok/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.results.action").value("TCP_MISS")) @@ -99,12 +99,12 @@ public void test() throws Exception { .andExpect(jsonPath("$.results.timestamp").value("1467011157.401")) .andExpect(jsonPath("$.results.url").value("http://www.aliexpress.com/af/shoes.html?")); - this.mockMvc.perform(post("/grok/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(badGrokValidationJson)) + this.mockMvc.perform(post("/api/v1/grok/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(badGrokValidationJson)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.results.error").exists()); - this.mockMvc.perform(get("/grok/list").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/grok/list").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$").isNotEmpty()); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java index cbfe84ff0a..e325728973 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java @@ -116,19 +116,19 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/kafka/topic").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) + this.mockMvc.perform(post("/api/v1/kafka/topic").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/kafka/topic/bro")) + this.mockMvc.perform(get("/api/v1/kafka/topic/bro")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/kafka/topic")) + this.mockMvc.perform(get("/api/v1/kafka/topic")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/kafka/topic/bro/sample")) + this.mockMvc.perform(get("/api/v1/kafka/topic/bro/sample")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(delete("/kafka/topic/bro").with(csrf())) + this.mockMvc.perform(delete("/api/v1/kafka/topic/bro").with(csrf())) .andExpect(status().isUnauthorized()); } @@ -138,10 +138,10 @@ public void test() throws Exception { this.kafkaService.deleteTopic("someTopic"); Thread.sleep(1000); - this.mockMvc.perform(delete("/kafka/topic/bro").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/kafka/topic/bro").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(post("/kafka/topic").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) + this.mockMvc.perform(post("/api/v1/kafka/topic").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("bro")) @@ -151,31 +151,31 @@ public void test() throws Exception { sampleDataThread.start(); Thread.sleep(1000); - this.mockMvc.perform(get("/kafka/topic/bro").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/kafka/topic/bro").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("bro")) .andExpect(jsonPath("$.numPartitions").value(1)) .andExpect(jsonPath("$.replicationFactor").value(1)); - this.mockMvc.perform(get("/kafka/topic/someTopic").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/kafka/topic/someTopic").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/kafka/topic").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/kafka/topic").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", Matchers.hasItem("bro"))); - this.mockMvc.perform(get("/kafka/topic/bro/sample").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/kafka/topic/bro/sample").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("text/plain;charset=UTF-8"))) .andExpect(jsonPath("$").isNotEmpty()); - this.mockMvc.perform(get("/kafka/topic/someTopic/sample").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/kafka/topic/someTopic/sample").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(delete("/kafka/topic/bro").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/kafka/topic/bro").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); } 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 6ba292149c..75a328df65 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 @@ -124,16 +124,16 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/sensorEnrichmentConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + this.mockMvc.perform(post("/api/v1/sensorEnrichmentConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/sensorEnrichmentConfig/broTest")) + this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/sensorEnrichmentConfig")) + this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(delete("/sensorEnrichmentConfig/broTest").with(csrf())) + this.mockMvc.perform(delete("/api/v1/sensorEnrichmentConfig/broTest").with(csrf())) .andExpect(status().isUnauthorized()); } @@ -141,7 +141,7 @@ public void testSecurity() throws Exception { public void test() throws Exception { sensorEnrichmentConfigService.delete("broTest"); - this.mockMvc.perform(post("/sensorEnrichmentConfig/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + this.mockMvc.perform(post("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.index").value("broTest")) @@ -160,7 +160,7 @@ public void test() throws Exception { .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); - this.mockMvc.perform(get("/sensorEnrichmentConfig/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.index").value("broTest")) @@ -179,7 +179,7 @@ public void test() throws Exception { .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); - this.mockMvc.perform(get("/sensorEnrichmentConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.index == 'broTest' &&" + @@ -199,21 +199,21 @@ public void test() throws Exception { "@.threatIntel.triageConfig.aggregator == 'MAX'" + ")]").exists()); - this.mockMvc.perform(delete("/sensorEnrichmentConfig/broTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(get("/sensorEnrichmentConfig/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(delete("/sensorEnrichmentConfig/broTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/sensorEnrichmentConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").doesNotExist()); - this.mockMvc.perform(get("/sensorEnrichmentConfig/list/available").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig/list/available").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[0]").value("geo")) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java index 7de0c9aef7..625b0344de 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -52,7 +52,8 @@ public class SensorParserConfigControllerIntegrationTest { "parserClassName": "org.apache.metron.parsers.GrokParser", "sensorTopic": "squidTest", "parserConfig": { - "grokStatement": "SQUID %{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", + "patternLabel": "SQUIDTEST", + "grokStatement": "%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", "timestampField": "timestamp" }, "fieldTransformations" : [ @@ -85,10 +86,11 @@ public class SensorParserConfigControllerIntegrationTest { "sensorParserConfig": { "parserClassName": "org.apache.metron.parsers.GrokParser", - "sensorTopic": "squid", + "sensorTopic": "squidTest", "parserConfig": { - "grokStatement": "SQUID %{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", - "patternLabel": "SQUID", + "grokStatement": "%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", + "patternLabel": "SQUIDTEST", + "grokPath":"./squidTest", "timestampField": "timestamp" } }, @@ -119,29 +121,30 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/sensorParserConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) + this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/sensorParserConfig/squidTest")) + this.mockMvc.perform(get("/api/v1/sensorParserConfig/squidTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/sensorParserConfig")) + this.mockMvc.perform(get("/api/v1/sensorParserConfig")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(delete("/sensorParserConfig/squidTest").with(csrf())) + this.mockMvc.perform(delete("/api/v1/sensorParserConfig/squidTest").with(csrf())) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) + this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.GrokParser")) .andExpect(jsonPath("$.sensorTopic").value("squidTest")) .andExpect(jsonPath("$.parserConfig.grokPath").value("target/patterns/squidTest")) .andExpect(jsonPath("$.parserConfig.patternLabel").value("SQUIDTEST")) + .andExpect(jsonPath("$.parserConfig.grokStatement").value("%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}/%{WORD:UNWANTED}")) .andExpect(jsonPath("$.parserConfig.timestampField").value("timestamp")) .andExpect(jsonPath("$.fieldTransformations[0].transformation").value("STELLAR")) .andExpect(jsonPath("$.fieldTransformations[0].output[0]").value("full_hostname")) @@ -149,12 +152,14 @@ public void test() throws Exception { .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); - this.mockMvc.perform(get("/sensorParserConfig/squidTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfig/squidTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.GrokParser")) .andExpect(jsonPath("$.sensorTopic").value("squidTest")) .andExpect(jsonPath("$.parserConfig.grokPath").value("target/patterns/squidTest")) + .andExpect(jsonPath("$.parserConfig.patternLabel").value("SQUIDTEST")) + .andExpect(jsonPath("$.parserConfig.grokStatement").value("%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}/%{WORD:UNWANTED}")) .andExpect(jsonPath("$.parserConfig.timestampField").value("timestamp")) .andExpect(jsonPath("$.fieldTransformations[0].transformation").value("STELLAR")) .andExpect(jsonPath("$.fieldTransformations[0].output[0]").value("full_hostname")) @@ -162,12 +167,13 @@ public void test() throws Exception { .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); - this.mockMvc.perform(get("/sensorParserConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.parserClassName == 'org.apache.metron.parsers.GrokParser' &&" + "@.sensorTopic == 'squidTest' &&" + "@.parserConfig.grokPath == 'target/patterns/squidTest' &&" + + "@.parserConfig.patternLabel == 'SQUIDTEST' &&" + "@.parserConfig.timestampField == 'timestamp' &&" + "@.fieldTransformations[0].transformation == 'STELLAR' &&" + "@.fieldTransformations[0].output[0] == 'full_hostname' &&" + @@ -175,19 +181,20 @@ public void test() throws Exception { "@.fieldTransformations[0].config.full_hostname == 'URL_TO_HOST(url)' &&" + "@.fieldTransformations[0].config.domain_without_subdomains == 'DOMAIN_REMOVE_SUBDOMAINS(full_hostname)')]").exists()); - this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) .andExpect(jsonPath("$.sensorTopic").value("broTest")) .andExpect(jsonPath("$.parserConfig").isEmpty()); - this.mockMvc.perform(get("/sensorParserConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.parserClassName == 'org.apache.metron.parsers.GrokParser' &&" + "@.sensorTopic == 'squidTest' &&" + "@.parserConfig.grokPath == 'target/patterns/squidTest' &&" + + "@.parserConfig.patternLabel == 'SQUIDTEST' &&" + "@.parserConfig.timestampField == 'timestamp' &&" + "@.fieldTransformations[0].transformation == 'STELLAR' &&" + "@.fieldTransformations[0].output[0] == 'full_hostname' &&" + @@ -197,46 +204,46 @@ public void test() throws Exception { .andExpect(jsonPath("$[?(@.parserClassName == 'org.apache.metron.parsers.bro.BasicBroParser' && " + "@.sensorTopic == 'broTest')]").exists()); - this.mockMvc.perform(delete("/sensorParserConfig/squidTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/sensorParserConfig/squidTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(get("/sensorParserConfig/squidTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfig/squidTest").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(delete("/sensorParserConfig/squidTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/sensorParserConfig/squidTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/sensorParserConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.sensorTopic == 'squidTest')]").doesNotExist()) .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").exists()); - this.mockMvc.perform(delete("/sensorParserConfig/broTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/sensorParserConfig/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(delete("/sensorParserConfig/broTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete("/api/v1/sensorParserConfig/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/sensorParserConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfig").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.sensorTopic == 'squidTest')]").doesNotExist()) .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").doesNotExist()); - this.mockMvc.perform(get("/sensorParserConfig/list/available").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfig/list/available").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.Bro").value("org.apache.metron.parsers.bro.BasicBroParser")) .andExpect(jsonPath("$.Grok").value("org.apache.metron.parsers.GrokParser")); - this.mockMvc.perform(get("/sensorParserConfig/reload/available").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfig/reload/available").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.Bro").value("org.apache.metron.parsers.bro.BasicBroParser")) .andExpect(jsonPath("$.Grok").value("org.apache.metron.parsers.GrokParser")); - this.mockMvc.perform(post("/sensorParserConfig/parseMessage").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(parseRequest)) + this.mockMvc.perform(post("/api/v1/sensorParserConfig/parseMessage").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(parseRequest)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.elapsed").value(415)) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java index fb72c4ea71..68251b55ca 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java @@ -130,13 +130,13 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(get("/sensorParserInfo/broTest")) + this.mockMvc.perform(get("/api/v1/sensorParserInfo/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/sensorParserInfo/getall")) + this.mockMvc.perform(get("/api/v1/sensorParserInfo/getall")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/sensorParserInfo/history/bro")) + this.mockMvc.perform(get("/api/v1/sensorParserInfo/history/bro")) .andExpect(status().isUnauthorized()); } @@ -146,20 +146,19 @@ public void test() throws Exception { resetConfigs(); resetAuditTables(); SensorParserConfig bro3 = fromJson(broJson3); - SensorParserConfig bro2 = fromJson(broJson2); - this.mockMvc.perform(get("/sensorParserConfigHistory/broTest").with(httpBasic(user1,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfigHistory/broTest").with(httpBasic(user1,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson1)); + this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson1)); Thread.sleep(1000); - this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson2)); + this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson2)); Thread.sleep(1000); - this.mockMvc.perform(post("/sensorParserConfig").with(httpBasic(user2,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson3)); + this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user2,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson3)); assertEquals(bro3.getParserConfig().get("version"), fromJson(sensorParserConfigVersionRepository.findOne("broTest").getConfig()).getParserConfig().get("version")); - String json = this.mockMvc.perform(get("/sensorParserConfigHistory/broTest").with(httpBasic(user1,password))) + String json = this.mockMvc.perform(get("/api/v1/sensorParserConfigHistory/broTest").with(httpBasic(user1,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) @@ -172,14 +171,14 @@ public void test() throws Exception { Map result = objectMapper.readValue(json, new TypeReference>() {}); validateCreateModifiedByDate(result, false); - this.mockMvc.perform(get("/sensorParserConfigHistory").with(httpBasic(user1,password))) + this.mockMvc.perform(get("/api/v1/sensorParserConfigHistory").with(httpBasic(user1,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.config.sensorTopic == 'broTest')]").exists()); - this.mockMvc.perform(delete("/sensorParserConfig/broTest").with(httpBasic(user2,password)).with(csrf())); + this.mockMvc.perform(delete("/api/v1/sensorParserConfig/broTest").with(httpBasic(user2,password)).with(csrf())); - json = this.mockMvc.perform(get("/sensorParserConfigHistory/history/broTest").with(httpBasic(user1,password))) + json = this.mockMvc.perform(get("/api/v1/sensorParserConfigHistory/history/broTest").with(httpBasic(user1,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[0].config", isEmptyOrNullString())) 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 203d3ad9f7..8a4995a247 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 @@ -18,11 +18,9 @@ package org.apache.metron.rest.controller; import org.apache.metron.common.configuration.SensorParserConfig; -import org.apache.metron.rest.model.TopologyStatus; import org.apache.metron.rest.model.TopologyStatusCode; import org.apache.metron.rest.service.GlobalConfigService; import org.apache.metron.rest.service.SensorParserConfigService; -import org.apache.metron.rest.service.StormService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -37,16 +35,16 @@ import org.springframework.web.context.WebApplicationContext; import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasSize; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -80,62 +78,62 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(get("/storm")) + this.mockMvc.perform(get("/api/v1/storm")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/broTest")) + this.mockMvc.perform(get("/api/v1/storm/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/parser/start/broTest")) + this.mockMvc.perform(get("/api/v1/storm/parser/start/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/parser/stop/broTest")) + this.mockMvc.perform(get("/api/v1/storm/parser/stop/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/parser/activate/broTest")) + this.mockMvc.perform(get("/api/v1/storm/parser/activate/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/parser/deactivate/broTest")) + this.mockMvc.perform(get("/api/v1/storm/parser/deactivate/broTest")) .andExpect(status().isUnauthorized()); this.mockMvc.perform(get("/enrichment")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/enrichment/start")) + this.mockMvc.perform(get("/api/v1/storm/enrichment/start")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/enrichment/stop")) + this.mockMvc.perform(get("/api/v1/storm/enrichment/stop")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/enrichment/activate")) + this.mockMvc.perform(get("/api/v1/storm/enrichment/activate")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/enrichment/deactivate")) + this.mockMvc.perform(get("/api/v1/storm/enrichment/deactivate")) .andExpect(status().isUnauthorized()); this.mockMvc.perform(get("/indexing")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/indexing/start")) + this.mockMvc.perform(get("/api/v1/storm/indexing/start")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/indexing/stop")) + this.mockMvc.perform(get("/api/v1/storm/indexing/stop")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/indexing/activate")) + this.mockMvc.perform(get("/api/v1/storm/indexing/activate")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/storm/indexing/deactivate")) + this.mockMvc.perform(get("/api/v1/storm/indexing/deactivate")) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(get("/storm").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$", hasSize(0))); - this.mockMvc.perform(get("/storm/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/broTest").with(httpBasic(user,password))) .andExpect(status().isNotFound()); Map globalConfig = globalConfigService.get(); @@ -145,29 +143,29 @@ public void test() throws Exception { globalConfigService.delete(); sensorParserConfigService.delete("broTest"); - this.mockMvc.perform(get("/storm/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); - this.mockMvc.perform(get("/storm/parser/activate/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/parser/activate/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/storm/parser/deactivate/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/parser/deactivate/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/storm/parser/start/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/parser/start/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.GLOBAL_CONFIG_MISSING.name())); globalConfigService.save(globalConfig); - this.mockMvc.perform(get("/storm/parser/start/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/parser/start/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.SENSOR_PARSER_CONFIG_MISSING.name())); @@ -177,12 +175,12 @@ public void test() throws Exception { sensorParserConfig.setSensorTopic("broTest"); sensorParserConfigService.save(sensorParserConfig); - this.mockMvc.perform(get("/storm/parser/start/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/parser/start/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.name())); - this.mockMvc.perform(get("/storm/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("broTest")) @@ -191,55 +189,55 @@ public void test() throws Exception { .andExpect(jsonPath("$.latency").exists()) .andExpect(jsonPath("$.throughput").exists()); - this.mockMvc.perform(get("/storm").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.name == 'broTest' && @.status == 'ACTIVE')]").exists()); - this.mockMvc.perform(get("/storm/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); - this.mockMvc.perform(get("/storm/enrichment").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/storm/enrichment/activate").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/storm/enrichment/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/storm/enrichment/stop?stopNow=true").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment/stop?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); - this.mockMvc.perform(get("/storm/enrichment/start").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment/start").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.toString())); - this.mockMvc.perform(get("/storm/enrichment/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); - this.mockMvc.perform(get("/storm/enrichment/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); - this.mockMvc.perform(get("/storm/enrichment/activate").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.ACTIVE.name())); - this.mockMvc.perform(get("/storm/enrichment").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("enrichment")) @@ -248,50 +246,50 @@ public void test() throws Exception { .andExpect(jsonPath("$.latency").exists()) .andExpect(jsonPath("$.throughput").exists()); - this.mockMvc.perform(get("/storm").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.name == 'enrichment' && @.status == 'ACTIVE')]").exists()); - this.mockMvc.perform(get("/storm/enrichment/stop").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/enrichment/stop").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); - this.mockMvc.perform(get("/storm/indexing").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/indexing").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/storm/indexing/activate").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/indexing/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/storm/indexing/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/indexing/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/storm/indexing/stop?stopNow=true").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/indexing/stop?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); - this.mockMvc.perform(get("/storm/indexing/start").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/indexing/start").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.toString())); - this.mockMvc.perform(get("/storm/indexing/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/indexing/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); - this.mockMvc.perform(get("/storm/indexing/activate").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/indexing/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.ACTIVE.name())); - this.mockMvc.perform(get("/storm/indexing").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/indexing").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("indexing")) @@ -300,17 +298,17 @@ public void test() throws Exception { .andExpect(jsonPath("$.latency").exists()) .andExpect(jsonPath("$.throughput").exists()); - this.mockMvc.perform(get("/storm").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.name == 'indexing' && @.status == 'ACTIVE')]").exists()); - this.mockMvc.perform(get("/storm/indexing/stop").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/indexing/stop").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); - this.mockMvc.perform(get("/storm/client/status").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/storm/client/status").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.stormClientVersionInstalled").value("1.0.1")) .andExpect(jsonPath("$.parserScriptPath").value("/usr/metron/" + metronVersion + "/bin/start_parser_topology.sh")) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java index e9d1b77df4..ef39d53d52 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java @@ -75,44 +75,44 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/transformation/validate/rules").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) + this.mockMvc.perform(post("/api/v1/transformation/validate/rules").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(post("/transformation/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) + this.mockMvc.perform(post("/api/v1/transformation/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/transformation/list")) + this.mockMvc.perform(get("/api/v1/transformation/list")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/transformation/list/functions")) + this.mockMvc.perform(get("/api/v1/transformation/list/functions")) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(post("/transformation/validate/rules").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) + this.mockMvc.perform(post("/api/v1/transformation/validate/rules").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.['" + valid + "']").value(Boolean.TRUE)) .andExpect(jsonPath("$.['" + invalid + "']").value(Boolean.FALSE)); - this.mockMvc.perform(post("/transformation/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) + this.mockMvc.perform(post("/api/v1/transformation/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.url").value("https://caseystella.com/blog")) .andExpect(jsonPath("$.url_host").value("caseystella.com")); - this.mockMvc.perform(get("/transformation/list").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/transformation/list").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", hasSize(greaterThan(0)))); - this.mockMvc.perform(get("/transformation/list/functions").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/transformation/list/functions").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", hasSize(greaterThan(0)))); - this.mockMvc.perform(get("/transformation/list/simple/functions").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/transformation/list/simple/functions").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", hasSize(greaterThan(0)))); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java index 0e24483893..d2052d3c2b 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java @@ -54,10 +54,10 @@ public void setup() throws Exception { @Test public void test() throws Exception { - this.mockMvc.perform(get("/user")) + this.mockMvc.perform(get("/api/v1/user")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/user").with(httpBasic(user,password))) + this.mockMvc.perform(get("/api/v1/user").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().string(user)); } From 7db0810f76ca36b1bb9c8d98c21038175ffed117 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 5 Dec 2016 18:00:09 -0600 Subject: [PATCH 10/54] Resolved licensing issues --- LICENSE | 13 + metron-docker/kibana/Dockerfile | 1 - metron-docker/kibana/images/metron.svg | 15 + metron-docker/kibana/styles/commons.style.css | 11944 ---------------- pom.xml | 5 + 5 files changed, 33 insertions(+), 11945 deletions(-) delete mode 100644 metron-docker/kibana/styles/commons.style.css diff --git a/LICENSE b/LICENSE index ad3562c019..9d2a8df0f8 100644 --- a/LICENSE +++ b/LICENSE @@ -203,3 +203,16 @@ Apache License ------------------------------------------------------------------------------------ This product bundles some test examples from the Stix project (metron-platform/metron-data-management/src/test/resources/stix_example.xml and metron-platform/metron-data-management/src/test/resources/stix_example_wo_conditions.xml), which is available under a BSD license. For details, see http://stix.mitre.org/about/termsofuse.html + +------------------------------------------------------------------------------------ + MIT +------------------------------------------------------------------------------------ + +This product bundles wait-for-it.sh, which is available under a "MIT Software License" license. For details, see https://github.com/vishnubob/wait-for-it + + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/metron-docker/kibana/Dockerfile b/metron-docker/kibana/Dockerfile index 1047a3471d..3bd0640ab0 100644 --- a/metron-docker/kibana/Dockerfile +++ b/metron-docker/kibana/Dockerfile @@ -17,4 +17,3 @@ FROM kibana:4.5.3 ADD /images/metron.svg /opt/kibana/optimize/bundles/src/ui/public/images/kibana.svg -ADD /styles/commons.style.css /opt/kibana/optimize/bundles/commons.style.css diff --git a/metron-docker/kibana/images/metron.svg b/metron-docker/kibana/images/metron.svg index 6be05f1570..caec4d1733 100644 --- a/metron-docker/kibana/images/metron.svg +++ b/metron-docker/kibana/images/metron.svg @@ -1,4 +1,19 @@ + .caret, - .dropup > .btn > .caret { - border-top-color: #000 !important; - } - .label { - border: 1px solid #000; - } - .table { - border-collapse: collapse !important; - } - .table td, - .table th { - background-color: #fff !important; - } - .table-bordered th, - .table-bordered td { - border: 1px solid #ddd !important; - } -} -@font-face { - font-family: 'Glyphicons Halflings'; - src: url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.eot); - src: url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.eot?#iefix) format('embedded-opentype'), url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.woff2) format('woff2'), url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.woff) format('woff'), url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.ttf) format('truetype'), url(/bundles/node_modules/bootstrap/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular) format('svg'); -} -.glyphicon { - position: relative; - top: 1px; - display: inline-block; - font-family: 'Glyphicons Halflings'; - font-style: normal; - font-weight: normal; - line-height: 1; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} -.glyphicon-asterisk:before { - content: "*"; -} -.glyphicon-plus:before { - content: "+"; -} -.glyphicon-euro:before, -.glyphicon-eur:before { - content: "\20AC"; -} -.glyphicon-minus:before { - content: "\2212"; -} -.glyphicon-cloud:before { - content: "\2601"; -} -.glyphicon-envelope:before { - content: "\2709"; -} -.glyphicon-pencil:before { - content: "\270F"; -} -.glyphicon-glass:before { - content: "\E001"; -} -.glyphicon-music:before { - content: "\E002"; -} -.glyphicon-search:before { - content: "\E003"; -} -.glyphicon-heart:before { - content: "\E005"; -} -.glyphicon-star:before { - content: "\E006"; -} -.glyphicon-star-empty:before { - content: "\E007"; -} -.glyphicon-user:before { - content: "\E008"; -} -.glyphicon-film:before { - content: "\E009"; -} -.glyphicon-th-large:before { - content: "\E010"; -} -.glyphicon-th:before { - content: "\E011"; -} -.glyphicon-th-list:before { - content: "\E012"; -} -.glyphicon-ok:before { - content: "\E013"; -} -.glyphicon-remove:before { - content: "\E014"; -} -.glyphicon-zoom-in:before { - content: "\E015"; -} -.glyphicon-zoom-out:before { - content: "\E016"; -} -.glyphicon-off:before { - content: "\E017"; -} -.glyphicon-signal:before { - content: "\E018"; -} -.glyphicon-cog:before { - content: "\E019"; -} -.glyphicon-trash:before { - content: "\E020"; -} -.glyphicon-home:before { - content: "\E021"; -} -.glyphicon-file:before { - content: "\E022"; -} -.glyphicon-time:before { - content: "\E023"; -} -.glyphicon-road:before { - content: "\E024"; -} -.glyphicon-download-alt:before { - content: "\E025"; -} -.glyphicon-download:before { - content: "\E026"; -} -.glyphicon-upload:before { - content: "\E027"; -} -.glyphicon-inbox:before { - content: "\E028"; -} -.glyphicon-play-circle:before { - content: "\E029"; -} -.glyphicon-repeat:before { - content: "\E030"; -} -.glyphicon-refresh:before { - content: "\E031"; -} -.glyphicon-list-alt:before { - content: "\E032"; -} -.glyphicon-lock:before { - content: "\E033"; -} -.glyphicon-flag:before { - content: "\E034"; -} -.glyphicon-headphones:before { - content: "\E035"; -} -.glyphicon-volume-off:before { - content: "\E036"; -} -.glyphicon-volume-down:before { - content: "\E037"; -} -.glyphicon-volume-up:before { - content: "\E038"; -} -.glyphicon-qrcode:before { - content: "\E039"; -} -.glyphicon-barcode:before { - content: "\E040"; -} -.glyphicon-tag:before { - content: "\E041"; -} -.glyphicon-tags:before { - content: "\E042"; -} -.glyphicon-book:before { - content: "\E043"; -} -.glyphicon-bookmark:before { - content: "\E044"; -} -.glyphicon-print:before { - content: "\E045"; -} -.glyphicon-camera:before { - content: "\E046"; -} -.glyphicon-font:before { - content: "\E047"; -} -.glyphicon-bold:before { - content: "\E048"; -} -.glyphicon-italic:before { - content: "\E049"; -} -.glyphicon-text-height:before { - content: "\E050"; -} -.glyphicon-text-width:before { - content: "\E051"; -} -.glyphicon-align-left:before { - content: "\E052"; -} -.glyphicon-align-center:before { - content: "\E053"; -} -.glyphicon-align-right:before { - content: "\E054"; -} -.glyphicon-align-justify:before { - content: "\E055"; -} -.glyphicon-list:before { - content: "\E056"; -} -.glyphicon-indent-left:before { - content: "\E057"; -} -.glyphicon-indent-right:before { - content: "\E058"; -} -.glyphicon-facetime-video:before { - content: "\E059"; -} -.glyphicon-picture:before { - content: "\E060"; -} -.glyphicon-map-marker:before { - content: "\E062"; -} -.glyphicon-adjust:before { - content: "\E063"; -} -.glyphicon-tint:before { - content: "\E064"; -} -.glyphicon-edit:before { - content: "\E065"; -} -.glyphicon-share:before { - content: "\E066"; -} -.glyphicon-check:before { - content: "\E067"; -} -.glyphicon-move:before { - content: "\E068"; -} -.glyphicon-step-backward:before { - content: "\E069"; -} -.glyphicon-fast-backward:before { - content: "\E070"; -} -.glyphicon-backward:before { - content: "\E071"; -} -.glyphicon-play:before { - content: "\E072"; -} -.glyphicon-pause:before { - content: "\E073"; -} -.glyphicon-stop:before { - content: "\E074"; -} -.glyphicon-forward:before { - content: "\E075"; -} -.glyphicon-fast-forward:before { - content: "\E076"; -} -.glyphicon-step-forward:before { - content: "\E077"; -} -.glyphicon-eject:before { - content: "\E078"; -} -.glyphicon-chevron-left:before { - content: "\E079"; -} -.glyphicon-chevron-right:before { - content: "\E080"; -} -.glyphicon-plus-sign:before { - content: "\E081"; -} -.glyphicon-minus-sign:before { - content: "\E082"; -} -.glyphicon-remove-sign:before { - content: "\E083"; -} -.glyphicon-ok-sign:before { - content: "\E084"; -} -.glyphicon-question-sign:before { - content: "\E085"; -} -.glyphicon-info-sign:before { - content: "\E086"; -} -.glyphicon-screenshot:before { - content: "\E087"; -} -.glyphicon-remove-circle:before { - content: "\E088"; -} -.glyphicon-ok-circle:before { - content: "\E089"; -} -.glyphicon-ban-circle:before { - content: "\E090"; -} -.glyphicon-arrow-left:before { - content: "\E091"; -} -.glyphicon-arrow-right:before { - content: "\E092"; -} -.glyphicon-arrow-up:before { - content: "\E093"; -} -.glyphicon-arrow-down:before { - content: "\E094"; -} -.glyphicon-share-alt:before { - content: "\E095"; -} -.glyphicon-resize-full:before { - content: "\E096"; -} -.glyphicon-resize-small:before { - content: "\E097"; -} -.glyphicon-exclamation-sign:before { - content: "\E101"; -} -.glyphicon-gift:before { - content: "\E102"; -} -.glyphicon-leaf:before { - content: "\E103"; -} -.glyphicon-fire:before { - content: "\E104"; -} -.glyphicon-eye-open:before { - content: "\E105"; -} -.glyphicon-eye-close:before { - content: "\E106"; -} -.glyphicon-warning-sign:before { - content: "\E107"; -} -.glyphicon-plane:before { - content: "\E108"; -} -.glyphicon-calendar:before { - content: "\E109"; -} -.glyphicon-random:before { - content: "\E110"; -} -.glyphicon-comment:before { - content: "\E111"; -} -.glyphicon-magnet:before { - content: "\E112"; -} -.glyphicon-chevron-up:before { - content: "\E113"; -} -.glyphicon-chevron-down:before { - content: "\E114"; -} -.glyphicon-retweet:before { - content: "\E115"; -} -.glyphicon-shopping-cart:before { - content: "\E116"; -} -.glyphicon-folder-close:before { - content: "\E117"; -} -.glyphicon-folder-open:before { - content: "\E118"; -} -.glyphicon-resize-vertical:before { - content: "\E119"; -} -.glyphicon-resize-horizontal:before { - content: "\E120"; -} -.glyphicon-hdd:before { - content: "\E121"; -} -.glyphicon-bullhorn:before { - content: "\E122"; -} -.glyphicon-bell:before { - content: "\E123"; -} -.glyphicon-certificate:before { - content: "\E124"; -} -.glyphicon-thumbs-up:before { - content: "\E125"; -} -.glyphicon-thumbs-down:before { - content: "\E126"; -} -.glyphicon-hand-right:before { - content: "\E127"; -} -.glyphicon-hand-left:before { - content: "\E128"; -} -.glyphicon-hand-up:before { - content: "\E129"; -} -.glyphicon-hand-down:before { - content: "\E130"; -} -.glyphicon-circle-arrow-right:before { - content: "\E131"; -} -.glyphicon-circle-arrow-left:before { - content: "\E132"; -} -.glyphicon-circle-arrow-up:before { - content: "\E133"; -} -.glyphicon-circle-arrow-down:before { - content: "\E134"; -} -.glyphicon-globe:before { - content: "\E135"; -} -.glyphicon-wrench:before { - content: "\E136"; -} -.glyphicon-tasks:before { - content: "\E137"; -} -.glyphicon-filter:before { - content: "\E138"; -} -.glyphicon-briefcase:before { - content: "\E139"; -} -.glyphicon-fullscreen:before { - content: "\E140"; -} -.glyphicon-dashboard:before { - content: "\E141"; -} -.glyphicon-paperclip:before { - content: "\E142"; -} -.glyphicon-heart-empty:before { - content: "\E143"; -} -.glyphicon-link:before { - content: "\E144"; -} -.glyphicon-phone:before { - content: "\E145"; -} -.glyphicon-pushpin:before { - content: "\E146"; -} -.glyphicon-usd:before { - content: "\E148"; -} -.glyphicon-gbp:before { - content: "\E149"; -} -.glyphicon-sort:before { - content: "\E150"; -} -.glyphicon-sort-by-alphabet:before { - content: "\E151"; -} -.glyphicon-sort-by-alphabet-alt:before { - content: "\E152"; -} -.glyphicon-sort-by-order:before { - content: "\E153"; -} -.glyphicon-sort-by-order-alt:before { - content: "\E154"; -} -.glyphicon-sort-by-attributes:before { - content: "\E155"; -} -.glyphicon-sort-by-attributes-alt:before { - content: "\E156"; -} -.glyphicon-unchecked:before { - content: "\E157"; -} -.glyphicon-expand:before { - content: "\E158"; -} -.glyphicon-collapse-down:before { - content: "\E159"; -} -.glyphicon-collapse-up:before { - content: "\E160"; -} -.glyphicon-log-in:before { - content: "\E161"; -} -.glyphicon-flash:before { - content: "\E162"; -} -.glyphicon-log-out:before { - content: "\E163"; -} -.glyphicon-new-window:before { - content: "\E164"; -} -.glyphicon-record:before { - content: "\E165"; -} -.glyphicon-save:before { - content: "\E166"; -} -.glyphicon-open:before { - content: "\E167"; -} -.glyphicon-saved:before { - content: "\E168"; -} -.glyphicon-import:before { - content: "\E169"; -} -.glyphicon-export:before { - content: "\E170"; -} -.glyphicon-send:before { - content: "\E171"; -} -.glyphicon-floppy-disk:before { - content: "\E172"; -} -.glyphicon-floppy-saved:before { - content: "\E173"; -} -.glyphicon-floppy-remove:before { - content: "\E174"; -} -.glyphicon-floppy-save:before { - content: "\E175"; -} -.glyphicon-floppy-open:before { - content: "\E176"; -} -.glyphicon-credit-card:before { - content: "\E177"; -} -.glyphicon-transfer:before { - content: "\E178"; -} -.glyphicon-cutlery:before { - content: "\E179"; -} -.glyphicon-header:before { - content: "\E180"; -} -.glyphicon-compressed:before { - content: "\E181"; -} -.glyphicon-earphone:before { - content: "\E182"; -} -.glyphicon-phone-alt:before { - content: "\E183"; -} -.glyphicon-tower:before { - content: "\E184"; -} -.glyphicon-stats:before { - content: "\E185"; -} -.glyphicon-sd-video:before { - content: "\E186"; -} -.glyphicon-hd-video:before { - content: "\E187"; -} -.glyphicon-subtitles:before { - content: "\E188"; -} -.glyphicon-sound-stereo:before { - content: "\E189"; -} -.glyphicon-sound-dolby:before { - content: "\E190"; -} -.glyphicon-sound-5-1:before { - content: "\E191"; -} -.glyphicon-sound-6-1:before { - content: "\E192"; -} -.glyphicon-sound-7-1:before { - content: "\E193"; -} -.glyphicon-copyright-mark:before { - content: "\E194"; -} -.glyphicon-registration-mark:before { - content: "\E195"; -} -.glyphicon-cloud-download:before { - content: "\E197"; -} -.glyphicon-cloud-upload:before { - content: "\E198"; -} -.glyphicon-tree-conifer:before { - content: "\E199"; -} -.glyphicon-tree-deciduous:before { - content: "\E200"; -} -.glyphicon-cd:before { - content: "\E201"; -} -.glyphicon-save-file:before { - content: "\E202"; -} -.glyphicon-open-file:before { - content: "\E203"; -} -.glyphicon-level-up:before { - content: "\E204"; -} -.glyphicon-copy:before { - content: "\E205"; -} -.glyphicon-paste:before { - content: "\E206"; -} -.glyphicon-alert:before { - content: "\E209"; -} -.glyphicon-equalizer:before { - content: "\E210"; -} -.glyphicon-king:before { - content: "\E211"; -} -.glyphicon-queen:before { - content: "\E212"; -} -.glyphicon-pawn:before { - content: "\E213"; -} -.glyphicon-bishop:before { - content: "\E214"; -} -.glyphicon-knight:before { - content: "\E215"; -} -.glyphicon-baby-formula:before { - content: "\E216"; -} -.glyphicon-tent:before { - content: "\26FA"; -} -.glyphicon-blackboard:before { - content: "\E218"; -} -.glyphicon-bed:before { - content: "\E219"; -} -.glyphicon-apple:before { - content: "\F8FF"; -} -.glyphicon-erase:before { - content: "\E221"; -} -.glyphicon-hourglass:before { - content: "\231B"; -} -.glyphicon-lamp:before { - content: "\E223"; -} -.glyphicon-duplicate:before { - content: "\E224"; -} -.glyphicon-piggy-bank:before { - content: "\E225"; -} -.glyphicon-scissors:before { - content: "\E226"; -} -.glyphicon-bitcoin:before { - content: "\E227"; -} -.glyphicon-btc:before { - content: "\E227"; -} -.glyphicon-xbt:before { - content: "\E227"; -} -.glyphicon-yen:before { - content: "\A5"; -} -.glyphicon-jpy:before { - content: "\A5"; -} -.glyphicon-ruble:before { - content: "\20BD"; -} -.glyphicon-rub:before { - content: "\20BD"; -} -.glyphicon-scale:before { - content: "\E230"; -} -.glyphicon-ice-lolly:before { - content: "\E231"; -} -.glyphicon-ice-lolly-tasted:before { - content: "\E232"; -} -.glyphicon-education:before { - content: "\E233"; -} -.glyphicon-option-horizontal:before { - content: "\E234"; -} -.glyphicon-option-vertical:before { - content: "\E235"; -} -.glyphicon-menu-hamburger:before { - content: "\E236"; -} -.glyphicon-modal-window:before { - content: "\E237"; -} -.glyphicon-oil:before { - content: "\E238"; -} -.glyphicon-grain:before { - content: "\E239"; -} -.glyphicon-sunglasses:before { - content: "\E240"; -} -.glyphicon-text-size:before { - content: "\E241"; -} -.glyphicon-text-color:before { - content: "\E242"; -} -.glyphicon-text-background:before { - content: "\E243"; -} -.glyphicon-object-align-top:before { - content: "\E244"; -} -.glyphicon-object-align-bottom:before { - content: "\E245"; -} -.glyphicon-object-align-horizontal:before { - content: "\E246"; -} -.glyphicon-object-align-left:before { - content: "\E247"; -} -.glyphicon-object-align-vertical:before { - content: "\E248"; -} -.glyphicon-object-align-right:before { - content: "\E249"; -} -.glyphicon-triangle-right:before { - content: "\E250"; -} -.glyphicon-triangle-left:before { - content: "\E251"; -} -.glyphicon-triangle-bottom:before { - content: "\E252"; -} -.glyphicon-triangle-top:before { - content: "\E253"; -} -.glyphicon-console:before { - content: "\E254"; -} -.glyphicon-superscript:before { - content: "\E255"; -} -.glyphicon-subscript:before { - content: "\E256"; -} -.glyphicon-menu-left:before { - content: "\E257"; -} -.glyphicon-menu-right:before { - content: "\E258"; -} -.glyphicon-menu-down:before { - content: "\E259"; -} -.glyphicon-menu-up:before { - content: "\E260"; -} -* { - box-sizing: border-box; -} -*:before, -*:after { - box-sizing: border-box; -} -html { - font-size: 10px; - -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -} -body { - font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 13px; - line-height: 1.42857143; - color: #444444; - background-color: #ffffff; -} -input, -button, -select, -textarea { - font-family: inherit; - font-size: inherit; - line-height: inherit; -} -a { - color: #1f6b7a; - text-decoration: none; -} -a:hover, -a:focus { - color: #298fa3; - text-decoration: none; -} -a:focus { - outline: thin dotted; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} -figure { - margin: 0; -} -img { - vertical-align: middle; -} -.img-responsive, -.thumbnail > img, -.thumbnail a > img, -.carousel-inner > .item > img, -.carousel-inner > .item > a > img { - display: block; - max-width: 100%; - height: auto; -} -.img-rounded { - border-radius: 6px; -} -.img-thumbnail { - padding: 4px; - line-height: 1.42857143; - background-color: #ffffff; - border: 1px solid #ecf0f1; - border-radius: 4px; - -webkit-transition: all 0.2s ease-in-out; - transition: all 0.2s ease-in-out; - display: inline-block; - max-width: 100%; - height: auto; -} -.img-circle { - border-radius: 50%; -} -hr { - margin-top: 18px; - margin-bottom: 18px; - border: 0; - border-top: 1px solid #ecf0f1; -} -.sr-only { - position: absolute; - width: 1px; - height: 1px; - margin: -1px; - padding: 0; - overflow: hidden; - clip: rect(0, 0, 0, 0); - border: 0; -} -.sr-only-focusable:active, -.sr-only-focusable:focus { - position: static; - width: auto; - height: auto; - margin: 0; - overflow: visible; - clip: auto; -} -[role="button"] { - cursor: pointer; -} -h1, -h2, -h3, -h4, -h5, -h6, -.h1, -.h2, -.h3, -.h4, -.h5, -.h6 { - font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; - font-weight: 400; - line-height: 1.1; - color: inherit; -} -h1 small, -h2 small, -h3 small, -h4 small, -h5 small, -h6 small, -.h1 small, -.h2 small, -.h3 small, -.h4 small, -.h5 small, -.h6 small, -h1 .small, -h2 .small, -h3 .small, -h4 .small, -h5 .small, -h6 .small, -.h1 .small, -.h2 .small, -.h3 .small, -.h4 .small, -.h5 .small, -.h6 .small { - font-weight: normal; - line-height: 1; - color: #b4bcc2; -} -h1, -.h1, -h2, -.h2, -h3, -.h3 { - margin-top: 18px; - margin-bottom: 9px; -} -h1 small, -.h1 small, -h2 small, -.h2 small, -h3 small, -.h3 small, -h1 .small, -.h1 .small, -h2 .small, -.h2 .small, -h3 .small, -.h3 .small { - font-size: 65%; -} -h4, -.h4, -h5, -.h5, -h6, -.h6 { - margin-top: 9px; - margin-bottom: 9px; -} -h4 small, -.h4 small, -h5 small, -.h5 small, -h6 small, -.h6 small, -h4 .small, -.h4 .small, -h5 .small, -.h5 .small, -h6 .small, -.h6 .small { - font-size: 75%; -} -h1, -.h1 { - font-size: 33px; -} -h2, -.h2 { - font-size: 27px; -} -h3, -.h3 { - font-size: 23px; -} -h4, -.h4 { - font-size: 17px; -} -h5, -.h5 { - font-size: 13px; -} -h6, -.h6 { - font-size: 12px; -} -p { - margin: 0 0 9px; -} -.lead { - margin-bottom: 18px; - font-size: 14px; - font-weight: 300; - line-height: 1.4; -} -@media (min-width: 768px) { - .lead { - font-size: 19.5px; - } -} -small, -.small { - font-size: 92%; -} -mark, -.mark { - background-color: #f39c12; - padding: .2em; -} -.text-left { - text-align: left; -} -.text-right { - text-align: right; -} -.text-center { - text-align: center; -} -.text-justify { - text-align: justify; -} -.text-nowrap { - white-space: nowrap; -} -.text-lowercase { - text-transform: lowercase; -} -.text-uppercase { - text-transform: uppercase; -} -.text-capitalize { - text-transform: capitalize; -} -.text-muted { - color: #b4bcc2; -} -.text-primary { - color: #444444; -} -a.text-primary:hover, -a.text-primary:focus { - color: #2b2b2b; -} -.text-success { - color: #ffffff; -} -a.text-success:hover, -a.text-success:focus { - color: #e6e6e6; -} -.text-info { - color: #ffffff; -} -a.text-info:hover, -a.text-info:focus { - color: #e6e6e6; -} -.text-warning { - color: #ffffff; -} -a.text-warning:hover, -a.text-warning:focus { - color: #e6e6e6; -} -.text-danger { - color: #ffffff; -} -a.text-danger:hover, -a.text-danger:focus { - color: #e6e6e6; -} -.bg-primary { - color: #fff; - background-color: #444444; -} -a.bg-primary:hover, -a.bg-primary:focus { - background-color: #2b2b2b; -} -.bg-success { - background-color: #31c471; -} -a.bg-success:hover, -a.bg-success:focus { - background-color: #279b59; -} -.bg-info { - background-color: #1f6b7a; -} -a.bg-info:hover, -a.bg-info:focus { - background-color: #154751; -} -.bg-warning { - background-color: #f39c12; -} -a.bg-warning:hover, -a.bg-warning:focus { - background-color: #c87f0a; -} -.bg-danger { - background-color: #e74c3c; -} -a.bg-danger:hover, -a.bg-danger:focus { - background-color: #d62c1a; -} -.page-header { - padding-bottom: 8px; - margin: 36px 0 18px; - border-bottom: 1px solid transparent; -} -ul, -ol { - margin-top: 0; - margin-bottom: 9px; -} -ul ul, -ol ul, -ul ol, -ol ol { - margin-bottom: 0; -} -.list-unstyled { - padding-left: 0; - list-style: none; -} -.list-inline { - padding-left: 0; - list-style: none; - margin-left: -5px; -} -.list-inline > li { - display: inline-block; - padding-left: 5px; - padding-right: 5px; -} -dl { - margin-top: 0; - margin-bottom: 18px; -} -dt, -dd { - line-height: 1.42857143; -} -dt { - font-weight: bold; -} -dd { - margin-left: 0; -} -@media (min-width: 768px) { - .dl-horizontal dt { - float: left; - width: 160px; - clear: left; - text-align: right; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } - .dl-horizontal dd { - margin-left: 180px; - } -} -abbr[title], -abbr[data-original-title] { - cursor: help; - border-bottom: 1px dotted #b4bcc2; -} -.initialism { - font-size: 90%; - text-transform: uppercase; -} -blockquote { - padding: 9px 18px; - margin: 0 0 18px; - font-size: 16.25px; - border-left: 5px solid #ecf0f1; -} -blockquote p:last-child, -blockquote ul:last-child, -blockquote ol:last-child { - margin-bottom: 0; -} -blockquote footer, -blockquote small, -blockquote .small { - display: block; - font-size: 80%; - line-height: 1.42857143; - color: #b4bcc2; -} -blockquote footer:before, -blockquote small:before, -blockquote .small:before { - content: '\2014 \A0'; -} -.blockquote-reverse, -blockquote.pull-right { - padding-right: 15px; - padding-left: 0; - border-right: 5px solid #ecf0f1; - border-left: 0; - text-align: right; -} -.blockquote-reverse footer:before, -blockquote.pull-right footer:before, -.blockquote-reverse small:before, -blockquote.pull-right small:before, -.blockquote-reverse .small:before, -blockquote.pull-right .small:before { - content: ''; -} -.blockquote-reverse footer:after, -blockquote.pull-right footer:after, -.blockquote-reverse small:after, -blockquote.pull-right small:after, -.blockquote-reverse .small:after, -blockquote.pull-right .small:after { - content: '\A0 \2014'; -} -address { - margin-bottom: 18px; - font-style: normal; - line-height: 1.42857143; -} -code, -kbd, -pre, -samp { - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; -} -code { - padding: 2px 4px; - font-size: 90%; - color: #c7254e; - background-color: #f9f2f4; - border-radius: 4px; -} -kbd { - padding: 2px 4px; - font-size: 90%; - color: #ffffff; - background-color: #333333; - border-radius: 3px; - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25); -} -kbd kbd { - padding: 0; - font-size: 100%; - font-weight: bold; - box-shadow: none; -} -pre { - display: block; - padding: 8.5px; - margin: 0 0 9px; - font-size: 12px; - line-height: 1.42857143; - word-break: break-all; - word-wrap: break-word; - color: #7b8a8b; - background-color: #ecf0f1; - border: 1px solid #cccccc; - border-radius: 4px; -} -pre code { - padding: 0; - font-size: inherit; - color: inherit; - white-space: pre-wrap; - background-color: transparent; - border-radius: 0; -} -.pre-scrollable { - max-height: 340px; - overflow-y: scroll; -} -.container { - margin-right: auto; - margin-left: auto; - padding-left: 15px; - padding-right: 15px; -} -@media (min-width: 768px) { - .container { - width: 750px; - } -} -@media (min-width: 992px) { - .container { - width: 970px; - } -} -@media (min-width: 1200px) { - .container { - width: 1170px; - } -} -.container-fluid { - margin-right: auto; - margin-left: auto; - padding-left: 15px; - padding-right: 15px; -} -.row { - margin-left: -15px; - margin-right: -15px; -} -.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 { - position: relative; - min-height: 1px; - padding-left: 15px; - padding-right: 15px; -} -.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 { - float: left; -} -.col-xs-12 { - width: 100%; -} -.col-xs-11 { - width: 91.66666667%; -} -.col-xs-10 { - width: 83.33333333%; -} -.col-xs-9 { - width: 75%; -} -.col-xs-8 { - width: 66.66666667%; -} -.col-xs-7 { - width: 58.33333333%; -} -.col-xs-6 { - width: 50%; -} -.col-xs-5 { - width: 41.66666667%; -} -.col-xs-4 { - width: 33.33333333%; -} -.col-xs-3 { - width: 25%; -} -.col-xs-2 { - width: 16.66666667%; -} -.col-xs-1 { - width: 8.33333333%; -} -.col-xs-pull-12 { - right: 100%; -} -.col-xs-pull-11 { - right: 91.66666667%; -} -.col-xs-pull-10 { - right: 83.33333333%; -} -.col-xs-pull-9 { - right: 75%; -} -.col-xs-pull-8 { - right: 66.66666667%; -} -.col-xs-pull-7 { - right: 58.33333333%; -} -.col-xs-pull-6 { - right: 50%; -} -.col-xs-pull-5 { - right: 41.66666667%; -} -.col-xs-pull-4 { - right: 33.33333333%; -} -.col-xs-pull-3 { - right: 25%; -} -.col-xs-pull-2 { - right: 16.66666667%; -} -.col-xs-pull-1 { - right: 8.33333333%; -} -.col-xs-pull-0 { - right: auto; -} -.col-xs-push-12 { - left: 100%; -} -.col-xs-push-11 { - left: 91.66666667%; -} -.col-xs-push-10 { - left: 83.33333333%; -} -.col-xs-push-9 { - left: 75%; -} -.col-xs-push-8 { - left: 66.66666667%; -} -.col-xs-push-7 { - left: 58.33333333%; -} -.col-xs-push-6 { - left: 50%; -} -.col-xs-push-5 { - left: 41.66666667%; -} -.col-xs-push-4 { - left: 33.33333333%; -} -.col-xs-push-3 { - left: 25%; -} -.col-xs-push-2 { - left: 16.66666667%; -} -.col-xs-push-1 { - left: 8.33333333%; -} -.col-xs-push-0 { - left: auto; -} -.col-xs-offset-12 { - margin-left: 100%; -} -.col-xs-offset-11 { - margin-left: 91.66666667%; -} -.col-xs-offset-10 { - margin-left: 83.33333333%; -} -.col-xs-offset-9 { - margin-left: 75%; -} -.col-xs-offset-8 { - margin-left: 66.66666667%; -} -.col-xs-offset-7 { - margin-left: 58.33333333%; -} -.col-xs-offset-6 { - margin-left: 50%; -} -.col-xs-offset-5 { - margin-left: 41.66666667%; -} -.col-xs-offset-4 { - margin-left: 33.33333333%; -} -.col-xs-offset-3 { - margin-left: 25%; -} -.col-xs-offset-2 { - margin-left: 16.66666667%; -} -.col-xs-offset-1 { - margin-left: 8.33333333%; -} -.col-xs-offset-0 { - margin-left: 0%; -} -@media (min-width: 768px) { - .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12 { - float: left; - } - .col-sm-12 { - width: 100%; - } - .col-sm-11 { - width: 91.66666667%; - } - .col-sm-10 { - width: 83.33333333%; - } - .col-sm-9 { - width: 75%; - } - .col-sm-8 { - width: 66.66666667%; - } - .col-sm-7 { - width: 58.33333333%; - } - .col-sm-6 { - width: 50%; - } - .col-sm-5 { - width: 41.66666667%; - } - .col-sm-4 { - width: 33.33333333%; - } - .col-sm-3 { - width: 25%; - } - .col-sm-2 { - width: 16.66666667%; - } - .col-sm-1 { - width: 8.33333333%; - } - .col-sm-pull-12 { - right: 100%; - } - .col-sm-pull-11 { - right: 91.66666667%; - } - .col-sm-pull-10 { - right: 83.33333333%; - } - .col-sm-pull-9 { - right: 75%; - } - .col-sm-pull-8 { - right: 66.66666667%; - } - .col-sm-pull-7 { - right: 58.33333333%; - } - .col-sm-pull-6 { - right: 50%; - } - .col-sm-pull-5 { - right: 41.66666667%; - } - .col-sm-pull-4 { - right: 33.33333333%; - } - .col-sm-pull-3 { - right: 25%; - } - .col-sm-pull-2 { - right: 16.66666667%; - } - .col-sm-pull-1 { - right: 8.33333333%; - } - .col-sm-pull-0 { - right: auto; - } - .col-sm-push-12 { - left: 100%; - } - .col-sm-push-11 { - left: 91.66666667%; - } - .col-sm-push-10 { - left: 83.33333333%; - } - .col-sm-push-9 { - left: 75%; - } - .col-sm-push-8 { - left: 66.66666667%; - } - .col-sm-push-7 { - left: 58.33333333%; - } - .col-sm-push-6 { - left: 50%; - } - .col-sm-push-5 { - left: 41.66666667%; - } - .col-sm-push-4 { - left: 33.33333333%; - } - .col-sm-push-3 { - left: 25%; - } - .col-sm-push-2 { - left: 16.66666667%; - } - .col-sm-push-1 { - left: 8.33333333%; - } - .col-sm-push-0 { - left: auto; - } - .col-sm-offset-12 { - margin-left: 100%; - } - .col-sm-offset-11 { - margin-left: 91.66666667%; - } - .col-sm-offset-10 { - margin-left: 83.33333333%; - } - .col-sm-offset-9 { - margin-left: 75%; - } - .col-sm-offset-8 { - margin-left: 66.66666667%; - } - .col-sm-offset-7 { - margin-left: 58.33333333%; - } - .col-sm-offset-6 { - margin-left: 50%; - } - .col-sm-offset-5 { - margin-left: 41.66666667%; - } - .col-sm-offset-4 { - margin-left: 33.33333333%; - } - .col-sm-offset-3 { - margin-left: 25%; - } - .col-sm-offset-2 { - margin-left: 16.66666667%; - } - .col-sm-offset-1 { - margin-left: 8.33333333%; - } - .col-sm-offset-0 { - margin-left: 0%; - } -} -@media (min-width: 992px) { - .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 { - float: left; - } - .col-md-12 { - width: 100%; - } - .col-md-11 { - width: 91.66666667%; - } - .col-md-10 { - width: 83.33333333%; - } - .col-md-9 { - width: 75%; - } - .col-md-8 { - width: 66.66666667%; - } - .col-md-7 { - width: 58.33333333%; - } - .col-md-6 { - width: 50%; - } - .col-md-5 { - width: 41.66666667%; - } - .col-md-4 { - width: 33.33333333%; - } - .col-md-3 { - width: 25%; - } - .col-md-2 { - width: 16.66666667%; - } - .col-md-1 { - width: 8.33333333%; - } - .col-md-pull-12 { - right: 100%; - } - .col-md-pull-11 { - right: 91.66666667%; - } - .col-md-pull-10 { - right: 83.33333333%; - } - .col-md-pull-9 { - right: 75%; - } - .col-md-pull-8 { - right: 66.66666667%; - } - .col-md-pull-7 { - right: 58.33333333%; - } - .col-md-pull-6 { - right: 50%; - } - .col-md-pull-5 { - right: 41.66666667%; - } - .col-md-pull-4 { - right: 33.33333333%; - } - .col-md-pull-3 { - right: 25%; - } - .col-md-pull-2 { - right: 16.66666667%; - } - .col-md-pull-1 { - right: 8.33333333%; - } - .col-md-pull-0 { - right: auto; - } - .col-md-push-12 { - left: 100%; - } - .col-md-push-11 { - left: 91.66666667%; - } - .col-md-push-10 { - left: 83.33333333%; - } - .col-md-push-9 { - left: 75%; - } - .col-md-push-8 { - left: 66.66666667%; - } - .col-md-push-7 { - left: 58.33333333%; - } - .col-md-push-6 { - left: 50%; - } - .col-md-push-5 { - left: 41.66666667%; - } - .col-md-push-4 { - left: 33.33333333%; - } - .col-md-push-3 { - left: 25%; - } - .col-md-push-2 { - left: 16.66666667%; - } - .col-md-push-1 { - left: 8.33333333%; - } - .col-md-push-0 { - left: auto; - } - .col-md-offset-12 { - margin-left: 100%; - } - .col-md-offset-11 { - margin-left: 91.66666667%; - } - .col-md-offset-10 { - margin-left: 83.33333333%; - } - .col-md-offset-9 { - margin-left: 75%; - } - .col-md-offset-8 { - margin-left: 66.66666667%; - } - .col-md-offset-7 { - margin-left: 58.33333333%; - } - .col-md-offset-6 { - margin-left: 50%; - } - .col-md-offset-5 { - margin-left: 41.66666667%; - } - .col-md-offset-4 { - margin-left: 33.33333333%; - } - .col-md-offset-3 { - margin-left: 25%; - } - .col-md-offset-2 { - margin-left: 16.66666667%; - } - .col-md-offset-1 { - margin-left: 8.33333333%; - } - .col-md-offset-0 { - margin-left: 0%; - } -} -@media (min-width: 1200px) { - .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12 { - float: left; - } - .col-lg-12 { - width: 100%; - } - .col-lg-11 { - width: 91.66666667%; - } - .col-lg-10 { - width: 83.33333333%; - } - .col-lg-9 { - width: 75%; - } - .col-lg-8 { - width: 66.66666667%; - } - .col-lg-7 { - width: 58.33333333%; - } - .col-lg-6 { - width: 50%; - } - .col-lg-5 { - width: 41.66666667%; - } - .col-lg-4 { - width: 33.33333333%; - } - .col-lg-3 { - width: 25%; - } - .col-lg-2 { - width: 16.66666667%; - } - .col-lg-1 { - width: 8.33333333%; - } - .col-lg-pull-12 { - right: 100%; - } - .col-lg-pull-11 { - right: 91.66666667%; - } - .col-lg-pull-10 { - right: 83.33333333%; - } - .col-lg-pull-9 { - right: 75%; - } - .col-lg-pull-8 { - right: 66.66666667%; - } - .col-lg-pull-7 { - right: 58.33333333%; - } - .col-lg-pull-6 { - right: 50%; - } - .col-lg-pull-5 { - right: 41.66666667%; - } - .col-lg-pull-4 { - right: 33.33333333%; - } - .col-lg-pull-3 { - right: 25%; - } - .col-lg-pull-2 { - right: 16.66666667%; - } - .col-lg-pull-1 { - right: 8.33333333%; - } - .col-lg-pull-0 { - right: auto; - } - .col-lg-push-12 { - left: 100%; - } - .col-lg-push-11 { - left: 91.66666667%; - } - .col-lg-push-10 { - left: 83.33333333%; - } - .col-lg-push-9 { - left: 75%; - } - .col-lg-push-8 { - left: 66.66666667%; - } - .col-lg-push-7 { - left: 58.33333333%; - } - .col-lg-push-6 { - left: 50%; - } - .col-lg-push-5 { - left: 41.66666667%; - } - .col-lg-push-4 { - left: 33.33333333%; - } - .col-lg-push-3 { - left: 25%; - } - .col-lg-push-2 { - left: 16.66666667%; - } - .col-lg-push-1 { - left: 8.33333333%; - } - .col-lg-push-0 { - left: auto; - } - .col-lg-offset-12 { - margin-left: 100%; - } - .col-lg-offset-11 { - margin-left: 91.66666667%; - } - .col-lg-offset-10 { - margin-left: 83.33333333%; - } - .col-lg-offset-9 { - margin-left: 75%; - } - .col-lg-offset-8 { - margin-left: 66.66666667%; - } - .col-lg-offset-7 { - margin-left: 58.33333333%; - } - .col-lg-offset-6 { - margin-left: 50%; - } - .col-lg-offset-5 { - margin-left: 41.66666667%; - } - .col-lg-offset-4 { - margin-left: 33.33333333%; - } - .col-lg-offset-3 { - margin-left: 25%; - } - .col-lg-offset-2 { - margin-left: 16.66666667%; - } - .col-lg-offset-1 { - margin-left: 8.33333333%; - } - .col-lg-offset-0 { - margin-left: 0%; - } -} -table { - background-color: transparent; -} -caption { - padding-top: 8px; - padding-bottom: 8px; - color: #b4bcc2; - text-align: left; -} -th { - text-align: left; -} -.table { - width: 100%; - max-width: 100%; - margin-bottom: 18px; -} -.table > thead > tr > th, -.table > tbody > tr > th, -.table > tfoot > tr > th, -.table > thead > tr > td, -.table > tbody > tr > td, -.table > tfoot > tr > td { - padding: 8px; - line-height: 1.42857143; - vertical-align: top; - border-top: 1px solid #ecf0f1; -} -.table > thead > tr > th { - vertical-align: bottom; - border-bottom: 2px solid #ecf0f1; -} -.table > caption + thead > tr:first-child > th, -.table > colgroup + thead > tr:first-child > th, -.table > thead:first-child > tr:first-child > th, -.table > caption + thead > tr:first-child > td, -.table > colgroup + thead > tr:first-child > td, -.table > thead:first-child > tr:first-child > td { - border-top: 0; -} -.table > tbody + tbody { - border-top: 2px solid #ecf0f1; -} -.table .table { - background-color: #ffffff; -} -.table-condensed > thead > tr > th, -.table-condensed > tbody > tr > th, -.table-condensed > tfoot > tr > th, -.table-condensed > thead > tr > td, -.table-condensed > tbody > tr > td, -.table-condensed > tfoot > tr > td { - padding: 5px; -} -.table-bordered { - border: 1px solid #ecf0f1; -} -.table-bordered > thead > tr > th, -.table-bordered > tbody > tr > th, -.table-bordered > tfoot > tr > th, -.table-bordered > thead > tr > td, -.table-bordered > tbody > tr > td, -.table-bordered > tfoot > tr > td { - border: 1px solid #ecf0f1; -} -.table-bordered > thead > tr > th, -.table-bordered > thead > tr > td { - border-bottom-width: 2px; -} -.table-striped > tbody > tr:nth-of-type(odd) { - background-color: #f9f9f9; -} -.table-hover > tbody > tr:hover { - background-color: #ecf0f1; -} -table col[class*="col-"] { - position: static; - float: none; - display: table-column; -} -table td[class*="col-"], -table th[class*="col-"] { - position: static; - float: none; - display: table-cell; -} -.table > thead > tr > td.active, -.table > tbody > tr > td.active, -.table > tfoot > tr > td.active, -.table > thead > tr > th.active, -.table > tbody > tr > th.active, -.table > tfoot > tr > th.active, -.table > thead > tr.active > td, -.table > tbody > tr.active > td, -.table > tfoot > tr.active > td, -.table > thead > tr.active > th, -.table > tbody > tr.active > th, -.table > tfoot > tr.active > th { - background-color: #ecf0f1; -} -.table-hover > tbody > tr > td.active:hover, -.table-hover > tbody > tr > th.active:hover, -.table-hover > tbody > tr.active:hover > td, -.table-hover > tbody > tr:hover > .active, -.table-hover > tbody > tr.active:hover > th { - background-color: #dde4e6; -} -.table > thead > tr > td.success, -.table > tbody > tr > td.success, -.table > tfoot > tr > td.success, -.table > thead > tr > th.success, -.table > tbody > tr > th.success, -.table > tfoot > tr > th.success, -.table > thead > tr.success > td, -.table > tbody > tr.success > td, -.table > tfoot > tr.success > td, -.table > thead > tr.success > th, -.table > tbody > tr.success > th, -.table > tfoot > tr.success > th { - background-color: #31c471; -} -.table-hover > tbody > tr > td.success:hover, -.table-hover > tbody > tr > th.success:hover, -.table-hover > tbody > tr.success:hover > td, -.table-hover > tbody > tr:hover > .success, -.table-hover > tbody > tr.success:hover > th { - background-color: #2cb065; -} -.table > thead > tr > td.info, -.table > tbody > tr > td.info, -.table > tfoot > tr > td.info, -.table > thead > tr > th.info, -.table > tbody > tr > th.info, -.table > tfoot > tr > th.info, -.table > thead > tr.info > td, -.table > tbody > tr.info > td, -.table > tfoot > tr.info > td, -.table > thead > tr.info > th, -.table > tbody > tr.info > th, -.table > tfoot > tr.info > th { - background-color: #1f6b7a; -} -.table-hover > tbody > tr > td.info:hover, -.table-hover > tbody > tr > th.info:hover, -.table-hover > tbody > tr.info:hover > td, -.table-hover > tbody > tr:hover > .info, -.table-hover > tbody > tr.info:hover > th { - background-color: #1a5966; -} -.table > thead > tr > td.warning, -.table > tbody > tr > td.warning, -.table > tfoot > tr > td.warning, -.table > thead > tr > th.warning, -.table > tbody > tr > th.warning, -.table > tfoot > tr > th.warning, -.table > thead > tr.warning > td, -.table > tbody > tr.warning > td, -.table > tfoot > tr.warning > td, -.table > thead > tr.warning > th, -.table > tbody > tr.warning > th, -.table > tfoot > tr.warning > th { - background-color: #f39c12; -} -.table-hover > tbody > tr > td.warning:hover, -.table-hover > tbody > tr > th.warning:hover, -.table-hover > tbody > tr.warning:hover > td, -.table-hover > tbody > tr:hover > .warning, -.table-hover > tbody > tr.warning:hover > th { - background-color: #e08e0b; -} -.table > thead > tr > td.danger, -.table > tbody > tr > td.danger, -.table > tfoot > tr > td.danger, -.table > thead > tr > th.danger, -.table > tbody > tr > th.danger, -.table > tfoot > tr > th.danger, -.table > thead > tr.danger > td, -.table > tbody > tr.danger > td, -.table > tfoot > tr.danger > td, -.table > thead > tr.danger > th, -.table > tbody > tr.danger > th, -.table > tfoot > tr.danger > th { - background-color: #e74c3c; -} -.table-hover > tbody > tr > td.danger:hover, -.table-hover > tbody > tr > th.danger:hover, -.table-hover > tbody > tr.danger:hover > td, -.table-hover > tbody > tr:hover > .danger, -.table-hover > tbody > tr.danger:hover > th { - background-color: #e43725; -} -.table-responsive { - overflow-x: auto; - min-height: 0.01%; -} -@media screen and (max-width: 767px) { - .table-responsive { - width: 100%; - margin-bottom: 13.5px; - overflow-y: hidden; - -ms-overflow-style: -ms-autohiding-scrollbar; - border: 1px solid #ecf0f1; - } - .table-responsive > .table { - margin-bottom: 0; - } - .table-responsive > .table > thead > tr > th, - .table-responsive > .table > tbody > tr > th, - .table-responsive > .table > tfoot > tr > th, - .table-responsive > .table > thead > tr > td, - .table-responsive > .table > tbody > tr > td, - .table-responsive > .table > tfoot > tr > td { - white-space: nowrap; - } - .table-responsive > .table-bordered { - border: 0; - } - .table-responsive > .table-bordered > thead > tr > th:first-child, - .table-responsive > .table-bordered > tbody > tr > th:first-child, - .table-responsive > .table-bordered > tfoot > tr > th:first-child, - .table-responsive > .table-bordered > thead > tr > td:first-child, - .table-responsive > .table-bordered > tbody > tr > td:first-child, - .table-responsive > .table-bordered > tfoot > tr > td:first-child { - border-left: 0; - } - .table-responsive > .table-bordered > thead > tr > th:last-child, - .table-responsive > .table-bordered > tbody > tr > th:last-child, - .table-responsive > .table-bordered > tfoot > tr > th:last-child, - .table-responsive > .table-bordered > thead > tr > td:last-child, - .table-responsive > .table-bordered > tbody > tr > td:last-child, - .table-responsive > .table-bordered > tfoot > tr > td:last-child { - border-right: 0; - } - .table-responsive > .table-bordered > tbody > tr:last-child > th, - .table-responsive > .table-bordered > tfoot > tr:last-child > th, - .table-responsive > .table-bordered > tbody > tr:last-child > td, - .table-responsive > .table-bordered > tfoot > tr:last-child > td { - border-bottom: 0; - } -} -fieldset { - padding: 0; - margin: 0; - border: 0; - min-width: 0; -} -legend { - display: block; - width: 100%; - padding: 0; - margin-bottom: 18px; - font-size: 19.5px; - line-height: inherit; - color: #444444; - border: 0; - border-bottom: 1px solid transparent; -} -label { - display: inline-block; - max-width: 100%; - margin-bottom: 5px; - font-weight: bold; -} -input[type="search"] { - box-sizing: border-box; -} -input[type="radio"], -input[type="checkbox"] { - margin: 4px 0 0; - margin-top: 1px \9; - line-height: normal; -} -input[type="file"] { - display: block; -} -input[type="range"] { - display: block; - width: 100%; -} -select[multiple], -select[size] { - height: auto; -} -input[type="file"]:focus, -input[type="radio"]:focus, -input[type="checkbox"]:focus { - outline: thin dotted; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} -output { - display: block; - padding-top: 6px; - font-size: 13px; - line-height: 1.42857143; - color: #444444; -} -.form-control { - display: block; - width: 100%; - height: 30px; - padding: 5px 15px; - font-size: 13px; - line-height: 1.42857143; - color: #444444; - background-color: #ffffff; - background-image: none; - border: 1px solid #ecf0f1; - border-radius: 4px; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; - transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; -} -.form-control:focus { - border-color: #b4bcc2; - outline: 0; - box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(180, 188, 194, 0.6); -} -.form-control::-moz-placeholder { - color: #acb6c0; - opacity: 1; -} -.form-control:-ms-input-placeholder { - color: #acb6c0; -} -.form-control::-webkit-input-placeholder { - color: #acb6c0; -} -.form-control[disabled], -.form-control[readonly], -fieldset[disabled] .form-control { - background-color: #ecf0f1; - opacity: 1; -} -.form-control[disabled], -fieldset[disabled] .form-control { - cursor: not-allowed; -} -textarea.form-control { - height: auto; -} -input[type="search"] { - -webkit-appearance: none; -} -@media screen and (-webkit-min-device-pixel-ratio: 0) { - input[type="date"].form-control, - input[type="time"].form-control, - input[type="datetime-local"].form-control, - input[type="month"].form-control { - line-height: 30px; - } - input[type="date"].input-sm, - input[type="time"].input-sm, - input[type="datetime-local"].input-sm, - input[type="month"].input-sm, - .input-group-sm input[type="date"], - .input-group-sm input[type="time"], - .input-group-sm input[type="datetime-local"], - .input-group-sm input[type="month"] { - line-height: 32px; - } - input[type="date"].input-lg, - input[type="time"].input-lg, - input[type="datetime-local"].input-lg, - input[type="month"].input-lg, - .input-group-lg input[type="date"], - .input-group-lg input[type="time"], - .input-group-lg input[type="datetime-local"], - .input-group-lg input[type="month"] { - line-height: 61px; - } -} -.form-group { - margin-bottom: 15px; -} -.radio, -.checkbox { - position: relative; - display: block; - margin-top: 10px; - margin-bottom: 10px; -} -.radio label, -.checkbox label { - min-height: 18px; - padding-left: 20px; - margin-bottom: 0; - font-weight: normal; - cursor: pointer; -} -.radio input[type="radio"], -.radio-inline input[type="radio"], -.checkbox input[type="checkbox"], -.checkbox-inline input[type="checkbox"] { - position: absolute; - margin-left: -20px; - margin-top: 4px \9; -} -.radio + .radio, -.checkbox + .checkbox { - margin-top: -5px; -} -.radio-inline, -.checkbox-inline { - position: relative; - display: inline-block; - padding-left: 20px; - margin-bottom: 0; - vertical-align: middle; - font-weight: normal; - cursor: pointer; -} -.radio-inline + .radio-inline, -.checkbox-inline + .checkbox-inline { - margin-top: 0; - margin-left: 10px; -} -input[type="radio"][disabled], -input[type="checkbox"][disabled], -input[type="radio"].disabled, -input[type="checkbox"].disabled, -fieldset[disabled] input[type="radio"], -fieldset[disabled] input[type="checkbox"] { - cursor: not-allowed; -} -.radio-inline.disabled, -.checkbox-inline.disabled, -fieldset[disabled] .radio-inline, -fieldset[disabled] .checkbox-inline { - cursor: not-allowed; -} -.radio.disabled label, -.checkbox.disabled label, -fieldset[disabled] .radio label, -fieldset[disabled] .checkbox label { - cursor: not-allowed; -} -.form-control-static { - padding-top: 6px; - padding-bottom: 6px; - margin-bottom: 0; - min-height: 31px; -} -.form-control-static.input-lg, -.form-control-static.input-sm { - padding-left: 0; - padding-right: 0; -} -.input-sm { - height: 32px; - padding: 6px 9px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -select.input-sm { - height: 32px; - line-height: 32px; -} -textarea.input-sm, -select[multiple].input-sm { - height: auto; -} -.form-group-sm .form-control { - height: 32px; - padding: 6px 9px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.form-group-sm select.form-control { - height: 32px; - line-height: 32px; -} -.form-group-sm textarea.form-control, -.form-group-sm select[multiple].form-control { - height: auto; -} -.form-group-sm .form-control-static { - height: 32px; - min-height: 30px; - padding: 7px 9px; - font-size: 12px; - line-height: 1.5; -} -.input-lg { - height: 61px; - padding: 18px 27px; - font-size: 17px; - line-height: 1.33; - border-radius: 6px; -} -select.input-lg { - height: 61px; - line-height: 61px; -} -textarea.input-lg, -select[multiple].input-lg { - height: auto; -} -.form-group-lg .form-control { - height: 61px; - padding: 18px 27px; - font-size: 17px; - line-height: 1.33; - border-radius: 6px; -} -.form-group-lg select.form-control { - height: 61px; - line-height: 61px; -} -.form-group-lg textarea.form-control, -.form-group-lg select[multiple].form-control { - height: auto; -} -.form-group-lg .form-control-static { - height: 61px; - min-height: 35px; - padding: 19px 27px; - font-size: 17px; - line-height: 1.33; -} -.has-feedback { - position: relative; -} -.has-feedback .form-control { - padding-right: 37.5px; -} -.form-control-feedback { - position: absolute; - top: 0; - right: 0; - z-index: 2; - display: block; - width: 30px; - height: 30px; - line-height: 30px; - text-align: center; - pointer-events: none; -} -.input-lg + .form-control-feedback, -.input-group-lg + .form-control-feedback, -.form-group-lg .form-control + .form-control-feedback { - width: 61px; - height: 61px; - line-height: 61px; -} -.input-sm + .form-control-feedback, -.input-group-sm + .form-control-feedback, -.form-group-sm .form-control + .form-control-feedback { - width: 32px; - height: 32px; - line-height: 32px; -} -.has-success .help-block, -.has-success .control-label, -.has-success .radio, -.has-success .checkbox, -.has-success .radio-inline, -.has-success .checkbox-inline, -.has-success.radio label, -.has-success.checkbox label, -.has-success.radio-inline label, -.has-success.checkbox-inline label { - color: #ffffff; -} -.has-success .form-control { - border-color: #ffffff; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.has-success .form-control:focus { - border-color: #e6e6e6; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; -} -.has-success .input-group-addon { - color: #ffffff; - border-color: #ffffff; - background-color: #31c471; -} -.has-success .form-control-feedback { - color: #ffffff; -} -.has-warning .help-block, -.has-warning .control-label, -.has-warning .radio, -.has-warning .checkbox, -.has-warning .radio-inline, -.has-warning .checkbox-inline, -.has-warning.radio label, -.has-warning.checkbox label, -.has-warning.radio-inline label, -.has-warning.checkbox-inline label { - color: #ffffff; -} -.has-warning .form-control { - border-color: #ffffff; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.has-warning .form-control:focus { - border-color: #e6e6e6; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; -} -.has-warning .input-group-addon { - color: #ffffff; - border-color: #ffffff; - background-color: #f39c12; -} -.has-warning .form-control-feedback { - color: #ffffff; -} -.has-error .help-block, -.has-error .control-label, -.has-error .radio, -.has-error .checkbox, -.has-error .radio-inline, -.has-error .checkbox-inline, -.has-error.radio label, -.has-error.checkbox label, -.has-error.radio-inline label, -.has-error.checkbox-inline label { - color: #ffffff; -} -.has-error .form-control { - border-color: #ffffff; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.has-error .form-control:focus { - border-color: #e6e6e6; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ffffff; -} -.has-error .input-group-addon { - color: #ffffff; - border-color: #ffffff; - background-color: #e74c3c; -} -.has-error .form-control-feedback { - color: #ffffff; -} -.has-feedback label ~ .form-control-feedback { - top: 23px; -} -.has-feedback label.sr-only ~ .form-control-feedback { - top: 0; -} -.help-block { - display: block; - margin-top: 5px; - margin-bottom: 10px; - color: #848484; -} -@media (min-width: 768px) { - .form-inline .form-group { - display: inline-block; - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .form-control { - display: inline-block; - width: auto; - vertical-align: middle; - } - .form-inline .form-control-static { - display: inline-block; - } - .form-inline .input-group { - display: inline-table; - vertical-align: middle; - } - .form-inline .input-group .input-group-addon, - .form-inline .input-group .input-group-btn, - .form-inline .input-group .form-control { - width: auto; - } - .form-inline .input-group > .form-control { - width: 100%; - } - .form-inline .control-label { - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .radio, - .form-inline .checkbox { - display: inline-block; - margin-top: 0; - margin-bottom: 0; - vertical-align: middle; - } - .form-inline .radio label, - .form-inline .checkbox label { - padding-left: 0; - } - .form-inline .radio input[type="radio"], - .form-inline .checkbox input[type="checkbox"] { - position: relative; - margin-left: 0; - } - .form-inline .has-feedback .form-control-feedback { - top: 0; - } -} -.form-horizontal .radio, -.form-horizontal .checkbox, -.form-horizontal .radio-inline, -.form-horizontal .checkbox-inline { - margin-top: 0; - margin-bottom: 0; - padding-top: 6px; -} -.form-horizontal .radio, -.form-horizontal .checkbox { - min-height: 24px; -} -.form-horizontal .form-group { - margin-left: -15px; - margin-right: -15px; -} -@media (min-width: 768px) { - .form-horizontal .control-label { - text-align: right; - margin-bottom: 0; - padding-top: 6px; - } -} -.form-horizontal .has-feedback .form-control-feedback { - right: 15px; -} -@media (min-width: 768px) { - .form-horizontal .form-group-lg .control-label { - padding-top: 24.94px; - font-size: 17px; - } -} -@media (min-width: 768px) { - .form-horizontal .form-group-sm .control-label { - padding-top: 7px; - font-size: 12px; - } -} -.btn { - display: inline-block; - margin-bottom: 0; - font-weight: normal; - text-align: center; - vertical-align: middle; - -ms-touch-action: manipulation; - touch-action: manipulation; - cursor: pointer; - background-image: none; - border: 1px solid transparent; - white-space: nowrap; - padding: 5px 15px; - font-size: 13px; - line-height: 1.42857143; - border-radius: 4px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.btn:focus, -.btn:active:focus, -.btn.active:focus, -.btn.focus, -.btn:active.focus, -.btn.active.focus { - outline: thin dotted; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} -.btn:hover, -.btn:focus, -.btn.focus { - color: #ffffff; - text-decoration: none; -} -.btn:active, -.btn.active { - outline: 0; - background-image: none; - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} -.btn.disabled, -.btn[disabled], -fieldset[disabled] .btn { - cursor: not-allowed; - opacity: 0.65; - filter: alpha(opacity=65); - box-shadow: none; -} -a.btn.disabled, -fieldset[disabled] a.btn { - pointer-events: none; -} -.btn-default { - color: #ffffff; - background-color: #95a5a6; - border-color: #95a5a6; -} -.btn-default:focus, -.btn-default.focus { - color: #ffffff; - background-color: #798d8f; - border-color: #566566; -} -.btn-default:hover { - color: #ffffff; - background-color: #798d8f; - border-color: #74898a; -} -.btn-default:active, -.btn-default.active, -.open > .dropdown-toggle.btn-default { - color: #ffffff; - background-color: #798d8f; - border-color: #74898a; -} -.btn-default:active:hover, -.btn-default.active:hover, -.open > .dropdown-toggle.btn-default:hover, -.btn-default:active:focus, -.btn-default.active:focus, -.open > .dropdown-toggle.btn-default:focus, -.btn-default:active.focus, -.btn-default.active.focus, -.open > .dropdown-toggle.btn-default.focus { - color: #ffffff; - background-color: #687b7c; - border-color: #566566; -} -.btn-default:active, -.btn-default.active, -.open > .dropdown-toggle.btn-default { - background-image: none; -} -.btn-default.disabled, -.btn-default[disabled], -fieldset[disabled] .btn-default, -.btn-default.disabled:hover, -.btn-default[disabled]:hover, -fieldset[disabled] .btn-default:hover, -.btn-default.disabled:focus, -.btn-default[disabled]:focus, -fieldset[disabled] .btn-default:focus, -.btn-default.disabled.focus, -.btn-default[disabled].focus, -fieldset[disabled] .btn-default.focus, -.btn-default.disabled:active, -.btn-default[disabled]:active, -fieldset[disabled] .btn-default:active, -.btn-default.disabled.active, -.btn-default[disabled].active, -fieldset[disabled] .btn-default.active { - background-color: #95a5a6; - border-color: #95a5a6; -} -.btn-default .badge { - color: #95a5a6; - background-color: #ffffff; -} -.btn-primary { - color: #ffffff; - background-color: #444444; - border-color: #444444; -} -.btn-primary:focus, -.btn-primary.focus { - color: #ffffff; - background-color: #2b2b2b; - border-color: #040404; -} -.btn-primary:hover { - color: #ffffff; - background-color: #2b2b2b; - border-color: #252525; -} -.btn-primary:active, -.btn-primary.active, -.open > .dropdown-toggle.btn-primary { - color: #ffffff; - background-color: #2b2b2b; - border-color: #252525; -} -.btn-primary:active:hover, -.btn-primary.active:hover, -.open > .dropdown-toggle.btn-primary:hover, -.btn-primary:active:focus, -.btn-primary.active:focus, -.open > .dropdown-toggle.btn-primary:focus, -.btn-primary:active.focus, -.btn-primary.active.focus, -.open > .dropdown-toggle.btn-primary.focus { - color: #ffffff; - background-color: #191919; - border-color: #040404; -} -.btn-primary:active, -.btn-primary.active, -.open > .dropdown-toggle.btn-primary { - background-image: none; -} -.btn-primary.disabled, -.btn-primary[disabled], -fieldset[disabled] .btn-primary, -.btn-primary.disabled:hover, -.btn-primary[disabled]:hover, -fieldset[disabled] .btn-primary:hover, -.btn-primary.disabled:focus, -.btn-primary[disabled]:focus, -fieldset[disabled] .btn-primary:focus, -.btn-primary.disabled.focus, -.btn-primary[disabled].focus, -fieldset[disabled] .btn-primary.focus, -.btn-primary.disabled:active, -.btn-primary[disabled]:active, -fieldset[disabled] .btn-primary:active, -.btn-primary.disabled.active, -.btn-primary[disabled].active, -fieldset[disabled] .btn-primary.active { - background-color: #444444; - border-color: #444444; -} -.btn-primary .badge { - color: #444444; - background-color: #ffffff; -} -.btn-success { - color: #ffffff; - background-color: #31c471; - border-color: #31c471; -} -.btn-success:focus, -.btn-success.focus { - color: #ffffff; - background-color: #279b59; - border-color: #185e36; -} -.btn-success:hover { - color: #ffffff; - background-color: #279b59; - border-color: #259355; -} -.btn-success:active, -.btn-success.active, -.open > .dropdown-toggle.btn-success { - color: #ffffff; - background-color: #279b59; - border-color: #259355; -} -.btn-success:active:hover, -.btn-success.active:hover, -.open > .dropdown-toggle.btn-success:hover, -.btn-success:active:focus, -.btn-success.active:focus, -.open > .dropdown-toggle.btn-success:focus, -.btn-success:active.focus, -.btn-success.active.focus, -.open > .dropdown-toggle.btn-success.focus { - color: #ffffff; - background-color: #207f49; - border-color: #185e36; -} -.btn-success:active, -.btn-success.active, -.open > .dropdown-toggle.btn-success { - background-image: none; -} -.btn-success.disabled, -.btn-success[disabled], -fieldset[disabled] .btn-success, -.btn-success.disabled:hover, -.btn-success[disabled]:hover, -fieldset[disabled] .btn-success:hover, -.btn-success.disabled:focus, -.btn-success[disabled]:focus, -fieldset[disabled] .btn-success:focus, -.btn-success.disabled.focus, -.btn-success[disabled].focus, -fieldset[disabled] .btn-success.focus, -.btn-success.disabled:active, -.btn-success[disabled]:active, -fieldset[disabled] .btn-success:active, -.btn-success.disabled.active, -.btn-success[disabled].active, -fieldset[disabled] .btn-success.active { - background-color: #31c471; - border-color: #31c471; -} -.btn-success .badge { - color: #31c471; - background-color: #ffffff; -} -.btn-info { - color: #ffffff; - background-color: #1f6b7a; - border-color: #1f6b7a; -} -.btn-info:focus, -.btn-info.focus { - color: #ffffff; - background-color: #154751; - border-color: #051214; -} -.btn-info:hover { - color: #ffffff; - background-color: #154751; - border-color: #134049; -} -.btn-info:active, -.btn-info.active, -.open > .dropdown-toggle.btn-info { - color: #ffffff; - background-color: #154751; - border-color: #134049; -} -.btn-info:active:hover, -.btn-info.active:hover, -.open > .dropdown-toggle.btn-info:hover, -.btn-info:active:focus, -.btn-info.active:focus, -.open > .dropdown-toggle.btn-info:focus, -.btn-info:active.focus, -.btn-info.active.focus, -.open > .dropdown-toggle.btn-info.focus { - color: #ffffff; - background-color: #0d2e35; - border-color: #051214; -} -.btn-info:active, -.btn-info.active, -.open > .dropdown-toggle.btn-info { - background-image: none; -} -.btn-info.disabled, -.btn-info[disabled], -fieldset[disabled] .btn-info, -.btn-info.disabled:hover, -.btn-info[disabled]:hover, -fieldset[disabled] .btn-info:hover, -.btn-info.disabled:focus, -.btn-info[disabled]:focus, -fieldset[disabled] .btn-info:focus, -.btn-info.disabled.focus, -.btn-info[disabled].focus, -fieldset[disabled] .btn-info.focus, -.btn-info.disabled:active, -.btn-info[disabled]:active, -fieldset[disabled] .btn-info:active, -.btn-info.disabled.active, -.btn-info[disabled].active, -fieldset[disabled] .btn-info.active { - background-color: #1f6b7a; - border-color: #1f6b7a; -} -.btn-info .badge { - color: #1f6b7a; - background-color: #ffffff; -} -.btn-warning { - color: #ffffff; - background-color: #f39c12; - border-color: #f39c12; -} -.btn-warning:focus, -.btn-warning.focus { - color: #ffffff; - background-color: #c87f0a; - border-color: #7f5006; -} -.btn-warning:hover { - color: #ffffff; - background-color: #c87f0a; - border-color: #be780a; -} -.btn-warning:active, -.btn-warning.active, -.open > .dropdown-toggle.btn-warning { - color: #ffffff; - background-color: #c87f0a; - border-color: #be780a; -} -.btn-warning:active:hover, -.btn-warning.active:hover, -.open > .dropdown-toggle.btn-warning:hover, -.btn-warning:active:focus, -.btn-warning.active:focus, -.open > .dropdown-toggle.btn-warning:focus, -.btn-warning:active.focus, -.btn-warning.active.focus, -.open > .dropdown-toggle.btn-warning.focus { - color: #ffffff; - background-color: #a66908; - border-color: #7f5006; -} -.btn-warning:active, -.btn-warning.active, -.open > .dropdown-toggle.btn-warning { - background-image: none; -} -.btn-warning.disabled, -.btn-warning[disabled], -fieldset[disabled] .btn-warning, -.btn-warning.disabled:hover, -.btn-warning[disabled]:hover, -fieldset[disabled] .btn-warning:hover, -.btn-warning.disabled:focus, -.btn-warning[disabled]:focus, -fieldset[disabled] .btn-warning:focus, -.btn-warning.disabled.focus, -.btn-warning[disabled].focus, -fieldset[disabled] .btn-warning.focus, -.btn-warning.disabled:active, -.btn-warning[disabled]:active, -fieldset[disabled] .btn-warning:active, -.btn-warning.disabled.active, -.btn-warning[disabled].active, -fieldset[disabled] .btn-warning.active { - background-color: #f39c12; - border-color: #f39c12; -} -.btn-warning .badge { - color: #f39c12; - background-color: #ffffff; -} -.btn-danger { - color: #ffffff; - background-color: #e74c3c; - border-color: #e74c3c; -} -.btn-danger:focus, -.btn-danger.focus { - color: #ffffff; - background-color: #d62c1a; - border-color: #921e12; -} -.btn-danger:hover { - color: #ffffff; - background-color: #d62c1a; - border-color: #cd2a19; -} -.btn-danger:active, -.btn-danger.active, -.open > .dropdown-toggle.btn-danger { - color: #ffffff; - background-color: #d62c1a; - border-color: #cd2a19; -} -.btn-danger:active:hover, -.btn-danger.active:hover, -.open > .dropdown-toggle.btn-danger:hover, -.btn-danger:active:focus, -.btn-danger.active:focus, -.open > .dropdown-toggle.btn-danger:focus, -.btn-danger:active.focus, -.btn-danger.active.focus, -.open > .dropdown-toggle.btn-danger.focus { - color: #ffffff; - background-color: #b62516; - border-color: #921e12; -} -.btn-danger:active, -.btn-danger.active, -.open > .dropdown-toggle.btn-danger { - background-image: none; -} -.btn-danger.disabled, -.btn-danger[disabled], -fieldset[disabled] .btn-danger, -.btn-danger.disabled:hover, -.btn-danger[disabled]:hover, -fieldset[disabled] .btn-danger:hover, -.btn-danger.disabled:focus, -.btn-danger[disabled]:focus, -fieldset[disabled] .btn-danger:focus, -.btn-danger.disabled.focus, -.btn-danger[disabled].focus, -fieldset[disabled] .btn-danger.focus, -.btn-danger.disabled:active, -.btn-danger[disabled]:active, -fieldset[disabled] .btn-danger:active, -.btn-danger.disabled.active, -.btn-danger[disabled].active, -fieldset[disabled] .btn-danger.active { - background-color: #e74c3c; - border-color: #e74c3c; -} -.btn-danger .badge { - color: #e74c3c; - background-color: #ffffff; -} -.btn-link { - color: #1f6b7a; - font-weight: normal; - border-radius: 0; -} -.btn-link, -.btn-link:active, -.btn-link.active, -.btn-link[disabled], -fieldset[disabled] .btn-link { - background-color: transparent; - box-shadow: none; -} -.btn-link, -.btn-link:hover, -.btn-link:focus, -.btn-link:active { - border-color: transparent; -} -.btn-link:hover, -.btn-link:focus { - color: #298fa3; - text-decoration: none; - background-color: transparent; -} -.btn-link[disabled]:hover, -fieldset[disabled] .btn-link:hover, -.btn-link[disabled]:focus, -fieldset[disabled] .btn-link:focus { - color: #b4bcc2; - text-decoration: none; -} -.btn-lg, -.btn-group-lg > .btn { - padding: 18px 27px; - font-size: 17px; - line-height: 1.33; - border-radius: 6px; -} -.btn-sm, -.btn-group-sm > .btn { - padding: 6px 9px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.btn-xs, -.btn-group-xs > .btn { - padding: 1px 5px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.btn-block { - display: block; - width: 100%; -} -.btn-block + .btn-block { - margin-top: 5px; -} -input[type="submit"].btn-block, -input[type="reset"].btn-block, -input[type="button"].btn-block { - width: 100%; -} -.fade { - opacity: 0; - -webkit-transition: opacity 0.15s linear; - transition: opacity 0.15s linear; -} -.fade.in { - opacity: 1; -} -.collapse { - display: none; -} -.collapse.in { - display: block; -} -tr.collapse.in { - display: table-row; -} -tbody.collapse.in { - display: table-row-group; -} -.collapsing { - position: relative; - height: 0; - overflow: hidden; - -webkit-transition-property: height, visibility; - transition-property: height, visibility; - -webkit-transition-duration: 0.35s; - transition-duration: 0.35s; - -webkit-transition-timing-function: ease; - transition-timing-function: ease; -} -.caret { - display: inline-block; - width: 0; - height: 0; - margin-left: 2px; - vertical-align: middle; - border-top: 4px dashed; - border-top: 4px solid \9; - border-right: 4px solid transparent; - border-left: 4px solid transparent; -} -.dropup, -.dropdown { - position: relative; -} -.dropdown-toggle:focus { - outline: 0; -} -.dropdown-menu { - position: absolute; - top: 100%; - left: 0; - z-index: 1000; - display: none; - float: left; - min-width: 160px; - padding: 5px 0; - margin: 2px 0 0; - list-style: none; - font-size: 13px; - text-align: left; - background-color: #ffffff; - border: 1px solid #dddddd; - border: 1px solid rgba(0, 0, 0, 0.15); - border-radius: 4px; - box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); - background-clip: padding-box; -} -.dropdown-menu.pull-right { - right: 0; - left: auto; -} -.dropdown-menu .divider { - height: 1px; - margin: 8px 0; - overflow: hidden; - background-color: #e5e5e5; -} -.dropdown-menu > li > a { - display: block; - padding: 3px 20px; - clear: both; - font-weight: normal; - line-height: 1.42857143; - color: #7b8a8b; - white-space: nowrap; -} -.dropdown-menu > li > a:hover, -.dropdown-menu > li > a:focus { - text-decoration: none; - color: #ffffff; - background-color: #444444; -} -.dropdown-menu > .active > a, -.dropdown-menu > .active > a:hover, -.dropdown-menu > .active > a:focus { - color: #ffffff; - text-decoration: none; - outline: 0; - background-color: #444444; -} -.dropdown-menu > .disabled > a, -.dropdown-menu > .disabled > a:hover, -.dropdown-menu > .disabled > a:focus { - color: #b4bcc2; -} -.dropdown-menu > .disabled > a:hover, -.dropdown-menu > .disabled > a:focus { - text-decoration: none; - background-color: transparent; - background-image: none; - filter: progid:DXImageTransform.Microsoft.gradient(enabled = false); - cursor: not-allowed; -} -.open > .dropdown-menu { - display: block; -} -.open > a { - outline: 0; -} -.dropdown-menu-right { - left: auto; - right: 0; -} -.dropdown-menu-left { - left: 0; - right: auto; -} -.dropdown-header { - display: block; - padding: 3px 20px; - font-size: 12px; - line-height: 1.42857143; - color: #b4bcc2; - white-space: nowrap; -} -.dropdown-backdrop { - position: fixed; - left: 0; - right: 0; - bottom: 0; - top: 0; - z-index: 990; -} -.pull-right > .dropdown-menu { - right: 0; - left: auto; -} -.dropup .caret, -.navbar-fixed-bottom .dropdown .caret { - border-top: 0; - border-bottom: 4px dashed; - border-bottom: 4px solid \9; - content: ""; -} -.dropup .dropdown-menu, -.navbar-fixed-bottom .dropdown .dropdown-menu { - top: auto; - bottom: 100%; - margin-bottom: 2px; -} -@media (min-width: 768px) { - .navbar-right .dropdown-menu { - left: auto; - right: 0; - } - .navbar-right .dropdown-menu-left { - left: 0; - right: auto; - } -} -.btn-group, -.btn-group-vertical { - position: relative; - display: inline-block; - vertical-align: middle; -} -.btn-group > .btn, -.btn-group-vertical > .btn { - position: relative; - float: left; -} -.btn-group > .btn:hover, -.btn-group-vertical > .btn:hover, -.btn-group > .btn:focus, -.btn-group-vertical > .btn:focus, -.btn-group > .btn:active, -.btn-group-vertical > .btn:active, -.btn-group > .btn.active, -.btn-group-vertical > .btn.active { - z-index: 2; -} -.btn-group .btn + .btn, -.btn-group .btn + .btn-group, -.btn-group .btn-group + .btn, -.btn-group .btn-group + .btn-group { - margin-left: -1px; -} -.btn-toolbar { - margin-left: -5px; -} -.btn-toolbar .btn, -.btn-toolbar .btn-group, -.btn-toolbar .input-group { - float: left; -} -.btn-toolbar > .btn, -.btn-toolbar > .btn-group, -.btn-toolbar > .input-group { - margin-left: 5px; -} -.btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) { - border-radius: 0; -} -.btn-group > .btn:first-child { - margin-left: 0; -} -.btn-group > .btn:first-child:not(:last-child):not(.dropdown-toggle) { - border-bottom-right-radius: 0; - border-top-right-radius: 0; -} -.btn-group > .btn:last-child:not(:first-child), -.btn-group > .dropdown-toggle:not(:first-child) { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} -.btn-group > .btn-group { - float: left; -} -.btn-group > .btn-group:not(:first-child):not(:last-child) > .btn { - border-radius: 0; -} -.btn-group > .btn-group:first-child:not(:last-child) > .btn:last-child, -.btn-group > .btn-group:first-child:not(:last-child) > .dropdown-toggle { - border-bottom-right-radius: 0; - border-top-right-radius: 0; -} -.btn-group > .btn-group:last-child:not(:first-child) > .btn:first-child { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} -.btn-group .dropdown-toggle:active, -.btn-group.open .dropdown-toggle { - outline: 0; -} -.btn-group > .btn + .dropdown-toggle { - padding-left: 8px; - padding-right: 8px; -} -.btn-group > .btn-lg + .dropdown-toggle { - padding-left: 12px; - padding-right: 12px; -} -.btn-group.open .dropdown-toggle { - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} -.btn-group.open .dropdown-toggle.btn-link { - box-shadow: none; -} -.btn .caret { - margin-left: 0; -} -.btn-lg .caret { - border-width: 5px 5px 0; - border-bottom-width: 0; -} -.dropup .btn-lg .caret { - border-width: 0 5px 5px; -} -.btn-group-vertical > .btn, -.btn-group-vertical > .btn-group, -.btn-group-vertical > .btn-group > .btn { - display: block; - float: none; - width: 100%; - max-width: 100%; -} -.btn-group-vertical > .btn-group > .btn { - float: none; -} -.btn-group-vertical > .btn + .btn, -.btn-group-vertical > .btn + .btn-group, -.btn-group-vertical > .btn-group + .btn, -.btn-group-vertical > .btn-group + .btn-group { - margin-top: -1px; - margin-left: 0; -} -.btn-group-vertical > .btn:not(:first-child):not(:last-child) { - border-radius: 0; -} -.btn-group-vertical > .btn:first-child:not(:last-child) { - border-top-right-radius: 4px; - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} -.btn-group-vertical > .btn:last-child:not(:first-child) { - border-bottom-left-radius: 4px; - border-top-right-radius: 0; - border-top-left-radius: 0; -} -.btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn { - border-radius: 0; -} -.btn-group-vertical > .btn-group:first-child:not(:last-child) > .btn:last-child, -.btn-group-vertical > .btn-group:first-child:not(:last-child) > .dropdown-toggle { - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} -.btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child { - border-top-right-radius: 0; - border-top-left-radius: 0; -} -.btn-group-justified { - display: table; - width: 100%; - table-layout: fixed; - border-collapse: separate; -} -.btn-group-justified > .btn, -.btn-group-justified > .btn-group { - float: none; - display: table-cell; - width: 1%; -} -.btn-group-justified > .btn-group .btn { - width: 100%; -} -.btn-group-justified > .btn-group .dropdown-menu { - left: auto; -} -[data-toggle="buttons"] > .btn input[type="radio"], -[data-toggle="buttons"] > .btn-group > .btn input[type="radio"], -[data-toggle="buttons"] > .btn input[type="checkbox"], -[data-toggle="buttons"] > .btn-group > .btn input[type="checkbox"] { - position: absolute; - clip: rect(0, 0, 0, 0); - pointer-events: none; -} -.input-group { - position: relative; - display: table; - border-collapse: separate; -} -.input-group[class*="col-"] { - float: none; - padding-left: 0; - padding-right: 0; -} -.input-group .form-control { - position: relative; - z-index: 2; - float: left; - width: 100%; - margin-bottom: 0; -} -.input-group-lg > .form-control, -.input-group-lg > .input-group-addon, -.input-group-lg > .input-group-btn > .btn { - height: 61px; - padding: 18px 27px; - font-size: 17px; - line-height: 1.33; - border-radius: 6px; -} -select.input-group-lg > .form-control, -select.input-group-lg > .input-group-addon, -select.input-group-lg > .input-group-btn > .btn { - height: 61px; - line-height: 61px; -} -textarea.input-group-lg > .form-control, -textarea.input-group-lg > .input-group-addon, -textarea.input-group-lg > .input-group-btn > .btn, -select[multiple].input-group-lg > .form-control, -select[multiple].input-group-lg > .input-group-addon, -select[multiple].input-group-lg > .input-group-btn > .btn { - height: auto; -} -.input-group-sm > .form-control, -.input-group-sm > .input-group-addon, -.input-group-sm > .input-group-btn > .btn { - height: 32px; - padding: 6px 9px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -select.input-group-sm > .form-control, -select.input-group-sm > .input-group-addon, -select.input-group-sm > .input-group-btn > .btn { - height: 32px; - line-height: 32px; -} -textarea.input-group-sm > .form-control, -textarea.input-group-sm > .input-group-addon, -textarea.input-group-sm > .input-group-btn > .btn, -select[multiple].input-group-sm > .form-control, -select[multiple].input-group-sm > .input-group-addon, -select[multiple].input-group-sm > .input-group-btn > .btn { - height: auto; -} -.input-group-addon, -.input-group-btn, -.input-group .form-control { - display: table-cell; -} -.input-group-addon:not(:first-child):not(:last-child), -.input-group-btn:not(:first-child):not(:last-child), -.input-group .form-control:not(:first-child):not(:last-child) { - border-radius: 0; -} -.input-group-addon, -.input-group-btn { - width: 1%; - white-space: nowrap; - vertical-align: middle; -} -.input-group-addon { - padding: 5px 15px; - font-size: 13px; - font-weight: normal; - line-height: 1; - color: #444444; - text-align: center; - background-color: #ecf0f1; - border: 1px solid #ecf0f1; - border-radius: 4px; -} -.input-group-addon.input-sm { - padding: 6px 9px; - font-size: 12px; - border-radius: 3px; -} -.input-group-addon.input-lg { - padding: 18px 27px; - font-size: 17px; - border-radius: 6px; -} -.input-group-addon input[type="radio"], -.input-group-addon input[type="checkbox"] { - margin-top: 0; -} -.input-group .form-control:first-child, -.input-group-addon:first-child, -.input-group-btn:first-child > .btn, -.input-group-btn:first-child > .btn-group > .btn, -.input-group-btn:first-child > .dropdown-toggle, -.input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle), -.input-group-btn:last-child > .btn-group:not(:last-child) > .btn { - border-bottom-right-radius: 0; - border-top-right-radius: 0; -} -.input-group-addon:first-child { - border-right: 0; -} -.input-group .form-control:last-child, -.input-group-addon:last-child, -.input-group-btn:last-child > .btn, -.input-group-btn:last-child > .btn-group > .btn, -.input-group-btn:last-child > .dropdown-toggle, -.input-group-btn:first-child > .btn:not(:first-child), -.input-group-btn:first-child > .btn-group:not(:first-child) > .btn { - border-bottom-left-radius: 0; - border-top-left-radius: 0; -} -.input-group-addon:last-child { - border-left: 0; -} -.input-group-btn { - position: relative; - font-size: 0; - white-space: nowrap; -} -.input-group-btn > .btn { - position: relative; -} -.input-group-btn > .btn + .btn { - margin-left: -1px; -} -.input-group-btn > .btn:hover, -.input-group-btn > .btn:focus, -.input-group-btn > .btn:active { - z-index: 2; -} -.input-group-btn:first-child > .btn, -.input-group-btn:first-child > .btn-group { - margin-right: -1px; -} -.input-group-btn:last-child > .btn, -.input-group-btn:last-child > .btn-group { - z-index: 2; - margin-left: -1px; -} -.nav { - margin-bottom: 0; - padding-left: 0; - list-style: none; -} -.nav > li { - position: relative; - display: block; -} -.nav > li > a { - position: relative; - display: block; - padding: 10px 15px; -} -.nav > li > a:hover, -.nav > li > a:focus { - text-decoration: none; - background-color: #ecf0f1; -} -.nav > li.disabled > a { - color: #b4bcc2; -} -.nav > li.disabled > a:hover, -.nav > li.disabled > a:focus { - color: #b4bcc2; - text-decoration: none; - background-color: transparent; - cursor: not-allowed; -} -.nav .open > a, -.nav .open > a:hover, -.nav .open > a:focus { - background-color: #ecf0f1; - border-color: #1f6b7a; -} -.nav .nav-divider { - height: 1px; - margin: 8px 0; - overflow: hidden; - background-color: #e5e5e5; -} -.nav > li > a > img { - max-width: none; -} -.nav-tabs { - border-bottom: 1px solid #ecf0f1; -} -.nav-tabs > li { - float: left; - margin-bottom: -1px; -} -.nav-tabs > li > a { - margin-right: 2px; - line-height: 1.42857143; - border: 1px solid transparent; - border-radius: 4px 4px 0 0; -} -.nav-tabs > li > a:hover { - border-color: #ecf0f1 #ecf0f1 #ecf0f1; -} -.nav-tabs > li.active > a, -.nav-tabs > li.active > a:hover, -.nav-tabs > li.active > a:focus { - color: #444444; - background-color: #ffffff; - border: 1px solid #ecf0f1; - border-bottom-color: transparent; - cursor: default; -} -.nav-tabs.nav-justified { - width: 100%; - border-bottom: 0; -} -.nav-tabs.nav-justified > li { - float: none; -} -.nav-tabs.nav-justified > li > a { - text-align: center; - margin-bottom: 5px; -} -.nav-tabs.nav-justified > .dropdown .dropdown-menu { - top: auto; - left: auto; -} -@media (min-width: 768px) { - .nav-tabs.nav-justified > li { - display: table-cell; - width: 1%; - } - .nav-tabs.nav-justified > li > a { - margin-bottom: 0; - } -} -.nav-tabs.nav-justified > li > a { - margin-right: 0; - border-radius: 4px; -} -.nav-tabs.nav-justified > .active > a, -.nav-tabs.nav-justified > .active > a:hover, -.nav-tabs.nav-justified > .active > a:focus { - border: 1px solid #ecf0f1; -} -@media (min-width: 768px) { - .nav-tabs.nav-justified > li > a { - border-bottom: 1px solid #ecf0f1; - border-radius: 4px 4px 0 0; - } - .nav-tabs.nav-justified > .active > a, - .nav-tabs.nav-justified > .active > a:hover, - .nav-tabs.nav-justified > .active > a:focus { - border-bottom-color: #ffffff; - } -} -.nav-pills > li { - float: left; -} -.nav-pills > li > a { - border-radius: 4px; -} -.nav-pills > li + li { - margin-left: 2px; -} -.nav-pills > li.active > a, -.nav-pills > li.active > a:hover, -.nav-pills > li.active > a:focus { - color: #ffffff; - background-color: #444444; -} -.nav-stacked > li { - float: none; -} -.nav-stacked > li + li { - margin-top: 2px; - margin-left: 0; -} -.nav-justified { - width: 100%; -} -.nav-justified > li { - float: none; -} -.nav-justified > li > a { - text-align: center; - margin-bottom: 5px; -} -.nav-justified > .dropdown .dropdown-menu { - top: auto; - left: auto; -} -@media (min-width: 768px) { - .nav-justified > li { - display: table-cell; - width: 1%; - } - .nav-justified > li > a { - margin-bottom: 0; - } -} -.nav-tabs-justified { - border-bottom: 0; -} -.nav-tabs-justified > li > a { - margin-right: 0; - border-radius: 4px; -} -.nav-tabs-justified > .active > a, -.nav-tabs-justified > .active > a:hover, -.nav-tabs-justified > .active > a:focus { - border: 1px solid #ecf0f1; -} -@media (min-width: 768px) { - .nav-tabs-justified > li > a { - border-bottom: 1px solid #ecf0f1; - border-radius: 4px 4px 0 0; - } - .nav-tabs-justified > .active > a, - .nav-tabs-justified > .active > a:hover, - .nav-tabs-justified > .active > a:focus { - border-bottom-color: #ffffff; - } -} -.tab-content > .tab-pane { - display: none; -} -.tab-content > .active { - display: block; -} -.nav-tabs .dropdown-menu { - margin-top: -1px; - border-top-right-radius: 0; - border-top-left-radius: 0; -} -.navbar { - position: relative; - min-height: 45px; - margin-bottom: 0px; - border: 1px solid transparent; -} -@media (min-width: 768px) { - .navbar { - border-radius: 4px; - } -} -@media (min-width: 768px) { - .navbar-header { - float: left; - } -} -.navbar-collapse { - overflow-x: visible; - padding-right: 15px; - padding-left: 15px; - border-top: 1px solid transparent; - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1); - -webkit-overflow-scrolling: touch; -} -.navbar-collapse.in { - overflow-y: auto; -} -@media (min-width: 768px) { - .navbar-collapse { - width: auto; - border-top: 0; - box-shadow: none; - } - .navbar-collapse.collapse { - display: block !important; - height: auto !important; - padding-bottom: 0; - overflow: visible !important; - } - .navbar-collapse.in { - overflow-y: visible; - } - .navbar-fixed-top .navbar-collapse, - .navbar-static-top .navbar-collapse, - .navbar-fixed-bottom .navbar-collapse { - padding-left: 0; - padding-right: 0; - } -} -.navbar-fixed-top .navbar-collapse, -.navbar-fixed-bottom .navbar-collapse { - max-height: 340px; -} -@media (max-device-width: 480px) and (orientation: landscape) { - .navbar-fixed-top .navbar-collapse, - .navbar-fixed-bottom .navbar-collapse { - max-height: 200px; - } -} -.container > .navbar-header, -.container-fluid > .navbar-header, -.container > .navbar-collapse, -.container-fluid > .navbar-collapse { - margin-right: -15px; - margin-left: -15px; -} -@media (min-width: 768px) { - .container > .navbar-header, - .container-fluid > .navbar-header, - .container > .navbar-collapse, - .container-fluid > .navbar-collapse { - margin-right: 0; - margin-left: 0; - } -} -.navbar-static-top { - z-index: 1000; - border-width: 0 0 1px; -} -@media (min-width: 768px) { - .navbar-static-top { - border-radius: 0; - } -} -.navbar-fixed-top, -.navbar-fixed-bottom { - position: fixed; - right: 0; - left: 0; - z-index: 1050; -} -@media (min-width: 768px) { - .navbar-fixed-top, - .navbar-fixed-bottom { - border-radius: 0; - } -} -.navbar-fixed-top { - top: 0; - border-width: 0 0 1px; -} -.navbar-fixed-bottom { - bottom: 0; - margin-bottom: 0; - border-width: 1px 0 0; -} -.navbar-brand { - float: left; - padding: 13.5px 15px; - font-size: 17px; - line-height: 18px; - height: 45px; -} -.navbar-brand:hover, -.navbar-brand:focus { - text-decoration: none; -} -.navbar-brand > img { - display: block; -} -@media (min-width: 768px) { - .navbar > .container .navbar-brand, - .navbar > .container-fluid .navbar-brand { - margin-left: -15px; - } -} -.navbar-toggle { - position: relative; - float: right; - margin-right: 15px; - padding: 9px 10px; - margin-top: 5.5px; - margin-bottom: 5.5px; - background-color: transparent; - background-image: none; - border: 1px solid transparent; - border-radius: 4px; -} -.navbar-toggle:focus { - outline: 0; -} -.navbar-toggle .icon-bar { - display: block; - width: 22px; - height: 2px; - border-radius: 1px; -} -.navbar-toggle .icon-bar + .icon-bar { - margin-top: 4px; -} -@media (min-width: 768px) { - .navbar-toggle { - display: none; - } -} -.navbar-nav { - margin: 6.75px -15px; -} -.navbar-nav > li > a { - padding-top: 10px; - padding-bottom: 10px; - line-height: 18px; -} -@media (max-width: 767px) { - .navbar-nav .open .dropdown-menu { - position: static; - float: none; - width: auto; - margin-top: 0; - background-color: transparent; - border: 0; - box-shadow: none; - } - .navbar-nav .open .dropdown-menu > li > a, - .navbar-nav .open .dropdown-menu .dropdown-header { - padding: 5px 15px 5px 25px; - } - .navbar-nav .open .dropdown-menu > li > a { - line-height: 18px; - } - .navbar-nav .open .dropdown-menu > li > a:hover, - .navbar-nav .open .dropdown-menu > li > a:focus { - background-image: none; - } -} -@media (min-width: 768px) { - .navbar-nav { - float: left; - margin: 0; - } - .navbar-nav > li { - float: left; - } - .navbar-nav > li > a { - padding-top: 13.5px; - padding-bottom: 13.5px; - } -} -.navbar-form { - margin-left: -15px; - margin-right: -15px; - padding: 10px 15px; - border-top: 1px solid transparent; - border-bottom: 1px solid transparent; - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 0 rgba(255, 255, 255, 0.1); - margin-top: 7.5px; - margin-bottom: 7.5px; -} -@media (min-width: 768px) { - .navbar-form .form-group { - display: inline-block; - margin-bottom: 0; - vertical-align: middle; - } - .navbar-form .form-control { - display: inline-block; - width: auto; - vertical-align: middle; - } - .navbar-form .form-control-static { - display: inline-block; - } - .navbar-form .input-group { - display: inline-table; - vertical-align: middle; - } - .navbar-form .input-group .input-group-addon, - .navbar-form .input-group .input-group-btn, - .navbar-form .input-group .form-control { - width: auto; - } - .navbar-form .input-group > .form-control { - width: 100%; - } - .navbar-form .control-label { - margin-bottom: 0; - vertical-align: middle; - } - .navbar-form .radio, - .navbar-form .checkbox { - display: inline-block; - margin-top: 0; - margin-bottom: 0; - vertical-align: middle; - } - .navbar-form .radio label, - .navbar-form .checkbox label { - padding-left: 0; - } - .navbar-form .radio input[type="radio"], - .navbar-form .checkbox input[type="checkbox"] { - position: relative; - margin-left: 0; - } - .navbar-form .has-feedback .form-control-feedback { - top: 0; - } -} -@media (max-width: 767px) { - .navbar-form .form-group { - margin-bottom: 5px; - } - .navbar-form .form-group:last-child { - margin-bottom: 0; - } -} -@media (min-width: 768px) { - .navbar-form { - width: auto; - border: 0; - margin-left: 0; - margin-right: 0; - padding-top: 0; - padding-bottom: 0; - box-shadow: none; - } -} -.navbar-nav > li > .dropdown-menu { - margin-top: 0; - border-top-right-radius: 0; - border-top-left-radius: 0; -} -.navbar-fixed-bottom .navbar-nav > li > .dropdown-menu { - margin-bottom: 0; - border-top-right-radius: 4px; - border-top-left-radius: 4px; - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} -.navbar-btn { - margin-top: 7.5px; - margin-bottom: 7.5px; -} -.navbar-btn.btn-sm { - margin-top: 6.5px; - margin-bottom: 6.5px; -} -.navbar-btn.btn-xs { - margin-top: 11.5px; - margin-bottom: 11.5px; -} -.navbar-text { - margin-top: 13.5px; - margin-bottom: 13.5px; -} -@media (min-width: 768px) { - .navbar-text { - float: left; - margin-left: 15px; - margin-right: 15px; - } -} -@media (min-width: 768px) { - .navbar-left { - float: left !important; - float: left; - } - .navbar-right { - float: right !important; - float: right; - margin-right: -15px; - } - .navbar-right ~ .navbar-right { - margin-right: 0; - } -} -.navbar-default { - background-color: #656a76; - border-color: #4d515b; -} -.navbar-default .navbar-brand { - color: #ecf0f1; -} -.navbar-default .navbar-brand:hover, -.navbar-default .navbar-brand:focus { - color: #ffffff; - background-color: transparent; -} -.navbar-default .navbar-text { - color: #ffffff; -} -.navbar-default .navbar-nav > li > a { - color: #ecf0f1; -} -.navbar-default .navbar-nav > li > a:hover, -.navbar-default .navbar-nav > li > a:focus { - color: #ffffff; - background-color: transparent; -} -.navbar-default .navbar-nav > .active > a, -.navbar-default .navbar-nav > .active > a:hover, -.navbar-default .navbar-nav > .active > a:focus { - color: #ffffff; - background-color: #4d515b; -} -.navbar-default .navbar-nav > .disabled > a, -.navbar-default .navbar-nav > .disabled > a:hover, -.navbar-default .navbar-nav > .disabled > a:focus { - color: #cccccc; - background-color: transparent; -} -.navbar-default .navbar-toggle { - border-color: #4d515b; -} -.navbar-default .navbar-toggle:hover, -.navbar-default .navbar-toggle:focus { - background-color: #4d515b; -} -.navbar-default .navbar-toggle .icon-bar { - background-color: #ffffff; -} -.navbar-default .navbar-collapse, -.navbar-default .navbar-form { - border-color: #4d515b; -} -.navbar-default .navbar-nav > .open > a, -.navbar-default .navbar-nav > .open > a:hover, -.navbar-default .navbar-nav > .open > a:focus { - background-color: #4d515b; - color: #ffffff; -} -@media (max-width: 767px) { - .navbar-default .navbar-nav .open .dropdown-menu > li > a { - color: #ecf0f1; - } - .navbar-default .navbar-nav .open .dropdown-menu > li > a:hover, - .navbar-default .navbar-nav .open .dropdown-menu > li > a:focus { - color: #ffffff; - background-color: transparent; - } - .navbar-default .navbar-nav .open .dropdown-menu > .active > a, - .navbar-default .navbar-nav .open .dropdown-menu > .active > a:hover, - .navbar-default .navbar-nav .open .dropdown-menu > .active > a:focus { - color: #ffffff; - background-color: #4d515b; - } - .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a, - .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:hover, - .navbar-default .navbar-nav .open .dropdown-menu > .disabled > a:focus { - color: #cccccc; - background-color: transparent; - } -} -.navbar-default .navbar-link { - color: #ecf0f1; -} -.navbar-default .navbar-link:hover { - color: #ffffff; -} -.navbar-default .btn-link { - color: #ecf0f1; -} -.navbar-default .btn-link:hover, -.navbar-default .btn-link:focus { - color: #ffffff; -} -.navbar-default .btn-link[disabled]:hover, -fieldset[disabled] .navbar-default .btn-link:hover, -.navbar-default .btn-link[disabled]:focus, -fieldset[disabled] .navbar-default .btn-link:focus { - color: #cccccc; -} -.navbar-inverse { - background-color: #222222; - border-color: #080808; -} -.navbar-inverse .navbar-brand { - color: #ffffff; -} -.navbar-inverse .navbar-brand:hover, -.navbar-inverse .navbar-brand:focus { - color: #ffffff; - background-color: #3c3c3c; -} -.navbar-inverse .navbar-text { - color: #ffffff; -} -.navbar-inverse .navbar-nav > li > a { - color: #ecf0f1; -} -.navbar-inverse .navbar-nav > li > a:hover, -.navbar-inverse .navbar-nav > li > a:focus { - color: #ffffff; - background-color: #555555; -} -.navbar-inverse .navbar-nav > .active > a, -.navbar-inverse .navbar-nav > .active > a:hover, -.navbar-inverse .navbar-nav > .active > a:focus { - color: #ffffff; - background-color: #41454c; -} -.navbar-inverse .navbar-nav > .disabled > a, -.navbar-inverse .navbar-nav > .disabled > a:hover, -.navbar-inverse .navbar-nav > .disabled > a:focus { - color: #b4bcc2; - background-color: transparent; -} -.navbar-inverse .navbar-toggle { - border-color: #080808; -} -.navbar-inverse .navbar-toggle:hover, -.navbar-inverse .navbar-toggle:focus { - background-color: #080808; -} -.navbar-inverse .navbar-toggle .icon-bar { - background-color: #ffffff; -} -.navbar-inverse .navbar-collapse, -.navbar-inverse .navbar-form { - border-color: #101010; -} -.navbar-inverse .navbar-nav > .open > a, -.navbar-inverse .navbar-nav > .open > a:hover, -.navbar-inverse .navbar-nav > .open > a:focus { - background-color: #41454c; - color: #ffffff; -} -@media (max-width: 767px) { - .navbar-inverse .navbar-nav .open .dropdown-menu > .dropdown-header { - border-color: #080808; - } - .navbar-inverse .navbar-nav .open .dropdown-menu .divider { - background-color: #080808; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > li > a { - color: #ecf0f1; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover, - .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus { - color: #ffffff; - background-color: #555555; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a, - .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover, - .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus { - color: #ffffff; - background-color: #41454c; - } - .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a, - .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:hover, - .navbar-inverse .navbar-nav .open .dropdown-menu > .disabled > a:focus { - color: #b4bcc2; - background-color: transparent; - } -} -.navbar-inverse .navbar-link { - color: #ecf0f1; -} -.navbar-inverse .navbar-link:hover { - color: #ffffff; -} -.navbar-inverse .btn-link { - color: #ecf0f1; -} -.navbar-inverse .btn-link:hover, -.navbar-inverse .btn-link:focus { - color: #ffffff; -} -.navbar-inverse .btn-link[disabled]:hover, -fieldset[disabled] .navbar-inverse .btn-link:hover, -.navbar-inverse .btn-link[disabled]:focus, -fieldset[disabled] .navbar-inverse .btn-link:focus { - color: #b4bcc2; -} -.breadcrumb { - padding: 8px 15px; - margin-bottom: 18px; - list-style: none; - background-color: #ecf0f1; - border-radius: 4px; -} -.breadcrumb > li { - display: inline-block; -} -.breadcrumb > li + li:before { - content: "/\A0"; - padding: 0 5px; - color: #cccccc; -} -.breadcrumb > .active { - color: #95a5a6; -} -.pagination { - display: inline-block; - padding-left: 0; - margin: 18px 0; - border-radius: 4px; -} -.pagination > li { - display: inline; -} -.pagination > li > a, -.pagination > li > span { - position: relative; - float: left; - padding: 5px 15px; - line-height: 1.42857143; - text-decoration: none; - color: #1f6b7a; - background-color: transparent; - border: 1px solid transparent; - margin-left: -1px; -} -.pagination > li:first-child > a, -.pagination > li:first-child > span { - margin-left: 0; - border-bottom-left-radius: 4px; - border-top-left-radius: 4px; -} -.pagination > li:last-child > a, -.pagination > li:last-child > span { - border-bottom-right-radius: 4px; - border-top-right-radius: 4px; -} -.pagination > li > a:hover, -.pagination > li > span:hover, -.pagination > li > a:focus, -.pagination > li > span:focus { - z-index: 3; - color: #1f6b7a; - background-color: rgba(0, 0, 0, 0); - border-color: transparent; -} -.pagination > .active > a, -.pagination > .active > span, -.pagination > .active > a:hover, -.pagination > .active > span:hover, -.pagination > .active > a:focus, -.pagination > .active > span:focus { - z-index: 2; - color: #444444; - background-color: rgba(0, 0, 0, 0); - border-color: transparent; - cursor: default; -} -.pagination > .disabled > span, -.pagination > .disabled > span:hover, -.pagination > .disabled > span:focus, -.pagination > .disabled > a, -.pagination > .disabled > a:hover, -.pagination > .disabled > a:focus { - color: #222222; - background-color: rgba(38, 38, 38, 0); - border-color: transparent; - cursor: not-allowed; -} -.pagination-lg > li > a, -.pagination-lg > li > span { - padding: 18px 27px; - font-size: 17px; - line-height: 1.33; -} -.pagination-lg > li:first-child > a, -.pagination-lg > li:first-child > span { - border-bottom-left-radius: 6px; - border-top-left-radius: 6px; -} -.pagination-lg > li:last-child > a, -.pagination-lg > li:last-child > span { - border-bottom-right-radius: 6px; - border-top-right-radius: 6px; -} -.pagination-sm > li > a, -.pagination-sm > li > span { - padding: 6px 9px; - font-size: 12px; - line-height: 1.5; -} -.pagination-sm > li:first-child > a, -.pagination-sm > li:first-child > span { - border-bottom-left-radius: 3px; - border-top-left-radius: 3px; -} -.pagination-sm > li:last-child > a, -.pagination-sm > li:last-child > span { - border-bottom-right-radius: 3px; - border-top-right-radius: 3px; -} -.pager { - padding-left: 0; - margin: 18px 0; - list-style: none; - text-align: center; -} -.pager li { - display: inline; -} -.pager li > a, -.pager li > span { - display: inline-block; - padding: 5px 14px; - background-color: transparent; - border: 1px solid transparent; - border-radius: 0px; -} -.pager li > a:hover, -.pager li > a:focus { - text-decoration: none; - background-color: rgba(0, 0, 0, 0); -} -.pager .next > a, -.pager .next > span { - float: right; -} -.pager .previous > a, -.pager .previous > span { - float: left; -} -.pager .disabled > a, -.pager .disabled > a:hover, -.pager .disabled > a:focus, -.pager .disabled > span { - color: #ffffff; - background-color: transparent; - cursor: not-allowed; -} -.label { - display: inline; - padding: .2em .6em .3em; - font-size: 75%; - font-weight: bold; - line-height: 1; - color: #ffffff; - text-align: center; - white-space: nowrap; - vertical-align: baseline; - border-radius: .25em; -} -a.label:hover, -a.label:focus { - color: #ffffff; - text-decoration: none; - cursor: pointer; -} -.label:empty { - display: none; -} -.btn .label { - position: relative; - top: -1px; -} -.label-default { - background-color: #95a5a6; -} -.label-default[href]:hover, -.label-default[href]:focus { - background-color: #798d8f; -} -.label-primary { - background-color: #444444; -} -.label-primary[href]:hover, -.label-primary[href]:focus { - background-color: #2b2b2b; -} -.label-success { - background-color: #31c471; -} -.label-success[href]:hover, -.label-success[href]:focus { - background-color: #279b59; -} -.label-info { - background-color: #1f6b7a; -} -.label-info[href]:hover, -.label-info[href]:focus { - background-color: #154751; -} -.label-warning { - background-color: #f39c12; -} -.label-warning[href]:hover, -.label-warning[href]:focus { - background-color: #c87f0a; -} -.label-danger { - background-color: #e74c3c; -} -.label-danger[href]:hover, -.label-danger[href]:focus { - background-color: #d62c1a; -} -.badge { - display: inline-block; - min-width: 10px; - padding: 3px 7px; - font-size: 12px; - font-weight: bold; - color: #ffffff; - line-height: 1; - vertical-align: middle; - white-space: nowrap; - text-align: center; - background-color: #444444; - border-radius: 10px; -} -.badge:empty { - display: none; -} -.btn .badge { - position: relative; - top: -1px; -} -.btn-xs .badge, -.btn-group-xs > .btn .badge { - top: 0; - padding: 1px 5px; -} -a.badge:hover, -a.badge:focus { - color: #ffffff; - text-decoration: none; - cursor: pointer; -} -.list-group-item.active > .badge, -.nav-pills > .active > a > .badge { - color: #444444; - background-color: #ffffff; -} -.list-group-item > .badge { - float: right; -} -.list-group-item > .badge + .badge { - margin-right: 5px; -} -.nav-pills > li > a > .badge { - margin-left: 3px; -} -.jumbotron { - padding-top: 30px; - padding-bottom: 30px; - margin-bottom: 30px; - color: inherit; - background-color: #ecf0f1; -} -.jumbotron h1, -.jumbotron .h1 { - color: inherit; -} -.jumbotron p { - margin-bottom: 15px; - font-size: 20px; - font-weight: 200; -} -.jumbotron > hr { - border-top-color: #cfd9db; -} -.container .jumbotron, -.container-fluid .jumbotron { - border-radius: 6px; -} -.jumbotron .container { - max-width: 100%; -} -@media screen and (min-width: 768px) { - .jumbotron { - padding-top: 48px; - padding-bottom: 48px; - } - .container .jumbotron, - .container-fluid .jumbotron { - padding-left: 60px; - padding-right: 60px; - } - .jumbotron h1, - .jumbotron .h1 { - font-size: 59px; - } -} -.thumbnail { - display: block; - padding: 4px; - margin-bottom: 18px; - line-height: 1.42857143; - background-color: #ffffff; - border: 1px solid #ecf0f1; - border-radius: 4px; - -webkit-transition: border 0.2s ease-in-out; - transition: border 0.2s ease-in-out; -} -.thumbnail > img, -.thumbnail a > img { - margin-left: auto; - margin-right: auto; -} -a.thumbnail:hover, -a.thumbnail:focus, -a.thumbnail.active { - border-color: #1f6b7a; -} -.thumbnail .caption { - padding: 9px; - color: #444444; -} -.alert { - padding: 15px; - margin-bottom: 18px; - border: 1px solid transparent; - border-radius: 4px; -} -.alert h4 { - margin-top: 0; - color: inherit; -} -.alert .alert-link { - font-weight: bold; -} -.alert > p, -.alert > ul { - margin-bottom: 0; -} -.alert > p + p { - margin-top: 5px; -} -.alert-dismissable, -.alert-dismissible { - padding-right: 35px; -} -.alert-dismissable .close, -.alert-dismissible .close { - position: relative; - top: -2px; - right: -21px; - color: inherit; -} -.alert-success { - background-color: #31c471; - border-color: #279b59; - color: #ffffff; -} -.alert-success hr { - border-top-color: #22874e; -} -.alert-success .alert-link { - color: #e6e6e6; -} -.alert-info { - background-color: #1f6b7a; - border-color: #154751; - color: #ffffff; -} -.alert-info hr { - border-top-color: #0f353d; -} -.alert-info .alert-link { - color: #e6e6e6; -} -.alert-warning { - background-color: #f39c12; - border-color: #c87f0a; - color: #ffffff; -} -.alert-warning hr { - border-top-color: #b06f09; -} -.alert-warning .alert-link { - color: #e6e6e6; -} -.alert-danger { - background-color: #e74c3c; - border-color: #d62c1a; - color: #ffffff; -} -.alert-danger hr { - border-top-color: #bf2718; -} -.alert-danger .alert-link { - color: #e6e6e6; -} -@-webkit-keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } -} -@keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } -} -.progress { - overflow: hidden; - height: 18px; - margin-bottom: 18px; - background-color: #ecf0f1; - border-radius: 4px; - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); -} -.progress-bar { - float: left; - width: 0%; - height: 100%; - font-size: 12px; - line-height: 18px; - color: #ffffff; - text-align: center; - background-color: #444444; - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - -webkit-transition: width 0.6s ease; - transition: width 0.6s ease; -} -.progress-striped .progress-bar, -.progress-bar-striped { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-size: 40px 40px; -} -.progress.active .progress-bar, -.progress-bar.active { - -webkit-animation: progress-bar-stripes 2s linear infinite; - animation: progress-bar-stripes 2s linear infinite; -} -.progress-bar-success { - background-color: #31c471; -} -.progress-striped .progress-bar-success { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.progress-bar-info { - background-color: #1f6b7a; -} -.progress-striped .progress-bar-info { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.progress-bar-warning { - background-color: #f39c12; -} -.progress-striped .progress-bar-warning { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.progress-bar-danger { - background-color: #e74c3c; -} -.progress-striped .progress-bar-danger { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.media { - margin-top: 15px; -} -.media:first-child { - margin-top: 0; -} -.media, -.media-body { - zoom: 1; - overflow: hidden; -} -.media-body { - width: 10000px; -} -.media-object { - display: block; -} -.media-object.img-thumbnail { - max-width: none; -} -.media-right, -.media > .pull-right { - padding-left: 10px; -} -.media-left, -.media > .pull-left { - padding-right: 10px; -} -.media-left, -.media-right, -.media-body { - display: table-cell; - vertical-align: top; -} -.media-middle { - vertical-align: middle; -} -.media-bottom { - vertical-align: bottom; -} -.media-heading { - margin-top: 0; - margin-bottom: 5px; -} -.media-list { - padding-left: 0; - list-style: none; -} -.list-group { - margin-bottom: 20px; - padding-left: 0; -} -.list-group-item { - position: relative; - display: block; - padding: 10px 15px; - margin-bottom: -1px; - background-color: #ffffff; - border: 1px solid #dddddd; -} -.list-group-item:first-child { - border-top-right-radius: 4px; - border-top-left-radius: 4px; -} -.list-group-item:last-child { - margin-bottom: 0; - border-bottom-right-radius: 4px; - border-bottom-left-radius: 4px; -} -a.list-group-item, -button.list-group-item { - color: #555555; -} -a.list-group-item .list-group-item-heading, -button.list-group-item .list-group-item-heading { - color: #333333; -} -a.list-group-item:hover, -button.list-group-item:hover, -a.list-group-item:focus, -button.list-group-item:focus { - text-decoration: none; - color: #555555; - background-color: #f5f5f5; -} -button.list-group-item { - width: 100%; - text-align: left; -} -.list-group-item.disabled, -.list-group-item.disabled:hover, -.list-group-item.disabled:focus { - background-color: #ecf0f1; - color: #b4bcc2; - cursor: not-allowed; -} -.list-group-item.disabled .list-group-item-heading, -.list-group-item.disabled:hover .list-group-item-heading, -.list-group-item.disabled:focus .list-group-item-heading { - color: inherit; -} -.list-group-item.disabled .list-group-item-text, -.list-group-item.disabled:hover .list-group-item-text, -.list-group-item.disabled:focus .list-group-item-text { - color: #b4bcc2; -} -.list-group-item.active, -.list-group-item.active:hover, -.list-group-item.active:focus { - z-index: 2; - color: #444444; - background-color: #444444; - border-color: #444444; -} -.list-group-item.active .list-group-item-heading, -.list-group-item.active:hover .list-group-item-heading, -.list-group-item.active:focus .list-group-item-heading, -.list-group-item.active .list-group-item-heading > small, -.list-group-item.active:hover .list-group-item-heading > small, -.list-group-item.active:focus .list-group-item-heading > small, -.list-group-item.active .list-group-item-heading > .small, -.list-group-item.active:hover .list-group-item-heading > .small, -.list-group-item.active:focus .list-group-item-heading > .small { - color: inherit; -} -.list-group-item.active .list-group-item-text, -.list-group-item.active:hover .list-group-item-text, -.list-group-item.active:focus .list-group-item-text { - color: #aaaaaa; -} -.list-group-item-success { - color: #ffffff; - background-color: #31c471; -} -a.list-group-item-success, -button.list-group-item-success { - color: #ffffff; -} -a.list-group-item-success .list-group-item-heading, -button.list-group-item-success .list-group-item-heading { - color: inherit; -} -a.list-group-item-success:hover, -button.list-group-item-success:hover, -a.list-group-item-success:focus, -button.list-group-item-success:focus { - color: #ffffff; - background-color: #2cb065; -} -a.list-group-item-success.active, -button.list-group-item-success.active, -a.list-group-item-success.active:hover, -button.list-group-item-success.active:hover, -a.list-group-item-success.active:focus, -button.list-group-item-success.active:focus { - color: #fff; - background-color: #ffffff; - border-color: #ffffff; -} -.list-group-item-info { - color: #ffffff; - background-color: #1f6b7a; -} -a.list-group-item-info, -button.list-group-item-info { - color: #ffffff; -} -a.list-group-item-info .list-group-item-heading, -button.list-group-item-info .list-group-item-heading { - color: inherit; -} -a.list-group-item-info:hover, -button.list-group-item-info:hover, -a.list-group-item-info:focus, -button.list-group-item-info:focus { - color: #ffffff; - background-color: #1a5966; -} -a.list-group-item-info.active, -button.list-group-item-info.active, -a.list-group-item-info.active:hover, -button.list-group-item-info.active:hover, -a.list-group-item-info.active:focus, -button.list-group-item-info.active:focus { - color: #fff; - background-color: #ffffff; - border-color: #ffffff; -} -.list-group-item-warning { - color: #ffffff; - background-color: #f39c12; -} -a.list-group-item-warning, -button.list-group-item-warning { - color: #ffffff; -} -a.list-group-item-warning .list-group-item-heading, -button.list-group-item-warning .list-group-item-heading { - color: inherit; -} -a.list-group-item-warning:hover, -button.list-group-item-warning:hover, -a.list-group-item-warning:focus, -button.list-group-item-warning:focus { - color: #ffffff; - background-color: #e08e0b; -} -a.list-group-item-warning.active, -button.list-group-item-warning.active, -a.list-group-item-warning.active:hover, -button.list-group-item-warning.active:hover, -a.list-group-item-warning.active:focus, -button.list-group-item-warning.active:focus { - color: #fff; - background-color: #ffffff; - border-color: #ffffff; -} -.list-group-item-danger { - color: #ffffff; - background-color: #e74c3c; -} -a.list-group-item-danger, -button.list-group-item-danger { - color: #ffffff; -} -a.list-group-item-danger .list-group-item-heading, -button.list-group-item-danger .list-group-item-heading { - color: inherit; -} -a.list-group-item-danger:hover, -button.list-group-item-danger:hover, -a.list-group-item-danger:focus, -button.list-group-item-danger:focus { - color: #ffffff; - background-color: #e43725; -} -a.list-group-item-danger.active, -button.list-group-item-danger.active, -a.list-group-item-danger.active:hover, -button.list-group-item-danger.active:hover, -a.list-group-item-danger.active:focus, -button.list-group-item-danger.active:focus { - color: #fff; - background-color: #ffffff; - border-color: #ffffff; -} -.list-group-item-heading { - margin-top: 0; - margin-bottom: 5px; -} -.list-group-item-text { - margin-bottom: 0; - line-height: 1.3; -} -.panel { - margin-bottom: 18px; - background-color: #ffffff; - border: 1px solid transparent; - border-radius: 4px; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); -} -.panel-body { - padding: 15px; -} -.panel-heading { - padding: 10px 15px; - border-bottom: 1px solid transparent; - border-top-right-radius: 3px; - border-top-left-radius: 3px; -} -.panel-heading > .dropdown .dropdown-toggle { - color: inherit; -} -.panel-title { - margin-top: 0; - margin-bottom: 0; - font-size: 15px; - color: inherit; -} -.panel-title > a, -.panel-title > small, -.panel-title > .small, -.panel-title > small > a, -.panel-title > .small > a { - color: inherit; -} -.panel-footer { - padding: 10px 15px; - background-color: #f5f5f5; - border-top: 1px solid #dddddd; - border-bottom-right-radius: 3px; - border-bottom-left-radius: 3px; -} -.panel > .list-group, -.panel > .panel-collapse > .list-group { - margin-bottom: 0; -} -.panel > .list-group .list-group-item, -.panel > .panel-collapse > .list-group .list-group-item { - border-width: 1px 0; - border-radius: 0; -} -.panel > .list-group:first-child .list-group-item:first-child, -.panel > .panel-collapse > .list-group:first-child .list-group-item:first-child { - border-top: 0; - border-top-right-radius: 3px; - border-top-left-radius: 3px; -} -.panel > .list-group:last-child .list-group-item:last-child, -.panel > .panel-collapse > .list-group:last-child .list-group-item:last-child { - border-bottom: 0; - border-bottom-right-radius: 3px; - border-bottom-left-radius: 3px; -} -.panel > .panel-heading + .panel-collapse > .list-group .list-group-item:first-child { - border-top-right-radius: 0; - border-top-left-radius: 0; -} -.panel-heading + .list-group .list-group-item:first-child { - border-top-width: 0; -} -.list-group + .panel-footer { - border-top-width: 0; -} -.panel > .table, -.panel > .table-responsive > .table, -.panel > .panel-collapse > .table { - margin-bottom: 0; -} -.panel > .table caption, -.panel > .table-responsive > .table caption, -.panel > .panel-collapse > .table caption { - padding-left: 15px; - padding-right: 15px; -} -.panel > .table:first-child, -.panel > .table-responsive:first-child > .table:first-child { - border-top-right-radius: 3px; - border-top-left-radius: 3px; -} -.panel > .table:first-child > thead:first-child > tr:first-child, -.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child, -.panel > .table:first-child > tbody:first-child > tr:first-child, -.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child { - border-top-left-radius: 3px; - border-top-right-radius: 3px; -} -.panel > .table:first-child > thead:first-child > tr:first-child td:first-child, -.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:first-child, -.panel > .table:first-child > tbody:first-child > tr:first-child td:first-child, -.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:first-child, -.panel > .table:first-child > thead:first-child > tr:first-child th:first-child, -.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:first-child, -.panel > .table:first-child > tbody:first-child > tr:first-child th:first-child, -.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:first-child { - border-top-left-radius: 3px; -} -.panel > .table:first-child > thead:first-child > tr:first-child td:last-child, -.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child td:last-child, -.panel > .table:first-child > tbody:first-child > tr:first-child td:last-child, -.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child td:last-child, -.panel > .table:first-child > thead:first-child > tr:first-child th:last-child, -.panel > .table-responsive:first-child > .table:first-child > thead:first-child > tr:first-child th:last-child, -.panel > .table:first-child > tbody:first-child > tr:first-child th:last-child, -.panel > .table-responsive:first-child > .table:first-child > tbody:first-child > tr:first-child th:last-child { - border-top-right-radius: 3px; -} -.panel > .table:last-child, -.panel > .table-responsive:last-child > .table:last-child { - border-bottom-right-radius: 3px; - border-bottom-left-radius: 3px; -} -.panel > .table:last-child > tbody:last-child > tr:last-child, -.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child, -.panel > .table:last-child > tfoot:last-child > tr:last-child, -.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child { - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; -} -.panel > .table:last-child > tbody:last-child > tr:last-child td:first-child, -.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:first-child, -.panel > .table:last-child > tfoot:last-child > tr:last-child td:first-child, -.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:first-child, -.panel > .table:last-child > tbody:last-child > tr:last-child th:first-child, -.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:first-child, -.panel > .table:last-child > tfoot:last-child > tr:last-child th:first-child, -.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:first-child { - border-bottom-left-radius: 3px; -} -.panel > .table:last-child > tbody:last-child > tr:last-child td:last-child, -.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child td:last-child, -.panel > .table:last-child > tfoot:last-child > tr:last-child td:last-child, -.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child td:last-child, -.panel > .table:last-child > tbody:last-child > tr:last-child th:last-child, -.panel > .table-responsive:last-child > .table:last-child > tbody:last-child > tr:last-child th:last-child, -.panel > .table:last-child > tfoot:last-child > tr:last-child th:last-child, -.panel > .table-responsive:last-child > .table:last-child > tfoot:last-child > tr:last-child th:last-child { - border-bottom-right-radius: 3px; -} -.panel > .panel-body + .table, -.panel > .panel-body + .table-responsive, -.panel > .table + .panel-body, -.panel > .table-responsive + .panel-body { - border-top: 1px solid #ecf0f1; -} -.panel > .table > tbody:first-child > tr:first-child th, -.panel > .table > tbody:first-child > tr:first-child td { - border-top: 0; -} -.panel > .table-bordered, -.panel > .table-responsive > .table-bordered { - border: 0; -} -.panel > .table-bordered > thead > tr > th:first-child, -.panel > .table-responsive > .table-bordered > thead > tr > th:first-child, -.panel > .table-bordered > tbody > tr > th:first-child, -.panel > .table-responsive > .table-bordered > tbody > tr > th:first-child, -.panel > .table-bordered > tfoot > tr > th:first-child, -.panel > .table-responsive > .table-bordered > tfoot > tr > th:first-child, -.panel > .table-bordered > thead > tr > td:first-child, -.panel > .table-responsive > .table-bordered > thead > tr > td:first-child, -.panel > .table-bordered > tbody > tr > td:first-child, -.panel > .table-responsive > .table-bordered > tbody > tr > td:first-child, -.panel > .table-bordered > tfoot > tr > td:first-child, -.panel > .table-responsive > .table-bordered > tfoot > tr > td:first-child { - border-left: 0; -} -.panel > .table-bordered > thead > tr > th:last-child, -.panel > .table-responsive > .table-bordered > thead > tr > th:last-child, -.panel > .table-bordered > tbody > tr > th:last-child, -.panel > .table-responsive > .table-bordered > tbody > tr > th:last-child, -.panel > .table-bordered > tfoot > tr > th:last-child, -.panel > .table-responsive > .table-bordered > tfoot > tr > th:last-child, -.panel > .table-bordered > thead > tr > td:last-child, -.panel > .table-responsive > .table-bordered > thead > tr > td:last-child, -.panel > .table-bordered > tbody > tr > td:last-child, -.panel > .table-responsive > .table-bordered > tbody > tr > td:last-child, -.panel > .table-bordered > tfoot > tr > td:last-child, -.panel > .table-responsive > .table-bordered > tfoot > tr > td:last-child { - border-right: 0; -} -.panel > .table-bordered > thead > tr:first-child > td, -.panel > .table-responsive > .table-bordered > thead > tr:first-child > td, -.panel > .table-bordered > tbody > tr:first-child > td, -.panel > .table-responsive > .table-bordered > tbody > tr:first-child > td, -.panel > .table-bordered > thead > tr:first-child > th, -.panel > .table-responsive > .table-bordered > thead > tr:first-child > th, -.panel > .table-bordered > tbody > tr:first-child > th, -.panel > .table-responsive > .table-bordered > tbody > tr:first-child > th { - border-bottom: 0; -} -.panel > .table-bordered > tbody > tr:last-child > td, -.panel > .table-responsive > .table-bordered > tbody > tr:last-child > td, -.panel > .table-bordered > tfoot > tr:last-child > td, -.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > td, -.panel > .table-bordered > tbody > tr:last-child > th, -.panel > .table-responsive > .table-bordered > tbody > tr:last-child > th, -.panel > .table-bordered > tfoot > tr:last-child > th, -.panel > .table-responsive > .table-bordered > tfoot > tr:last-child > th { - border-bottom: 0; -} -.panel > .table-responsive { - border: 0; - margin-bottom: 0; -} -.panel-group { - margin-bottom: 18px; -} -.panel-group .panel { - margin-bottom: 0; - border-radius: 4px; -} -.panel-group .panel + .panel { - margin-top: 5px; -} -.panel-group .panel-heading { - border-bottom: 0; -} -.panel-group .panel-heading + .panel-collapse > .panel-body, -.panel-group .panel-heading + .panel-collapse > .list-group { - border-top: 1px solid #dddddd; -} -.panel-group .panel-footer { - border-top: 0; -} -.panel-group .panel-footer + .panel-collapse .panel-body { - border-bottom: 1px solid #dddddd; -} -.panel-default { - border-color: #dddddd; -} -.panel-default > .panel-heading { - color: #7b8a8b; - background-color: #f5f5f5; - border-color: #dddddd; -} -.panel-default > .panel-heading + .panel-collapse > .panel-body { - border-top-color: #dddddd; -} -.panel-default > .panel-heading .badge { - color: #f5f5f5; - background-color: #7b8a8b; -} -.panel-default > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: #dddddd; -} -.panel-primary { - border-color: #444444; -} -.panel-primary > .panel-heading { - color: #ffffff; - background-color: #444444; - border-color: #444444; -} -.panel-primary > .panel-heading + .panel-collapse > .panel-body { - border-top-color: #444444; -} -.panel-primary > .panel-heading .badge { - color: #444444; - background-color: #ffffff; -} -.panel-primary > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: #444444; -} -.panel-success { - border-color: #279b59; -} -.panel-success > .panel-heading { - color: #ffffff; - background-color: #31c471; - border-color: #279b59; -} -.panel-success > .panel-heading + .panel-collapse > .panel-body { - border-top-color: #279b59; -} -.panel-success > .panel-heading .badge { - color: #31c471; - background-color: #ffffff; -} -.panel-success > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: #279b59; -} -.panel-info { - border-color: #154751; -} -.panel-info > .panel-heading { - color: #ffffff; - background-color: #1f6b7a; - border-color: #154751; -} -.panel-info > .panel-heading + .panel-collapse > .panel-body { - border-top-color: #154751; -} -.panel-info > .panel-heading .badge { - color: #1f6b7a; - background-color: #ffffff; -} -.panel-info > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: #154751; -} -.panel-warning { - border-color: #c87f0a; -} -.panel-warning > .panel-heading { - color: #ffffff; - background-color: #f39c12; - border-color: #c87f0a; -} -.panel-warning > .panel-heading + .panel-collapse > .panel-body { - border-top-color: #c87f0a; -} -.panel-warning > .panel-heading .badge { - color: #f39c12; - background-color: #ffffff; -} -.panel-warning > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: #c87f0a; -} -.panel-danger { - border-color: #d62c1a; -} -.panel-danger > .panel-heading { - color: #ffffff; - background-color: #e74c3c; - border-color: #d62c1a; -} -.panel-danger > .panel-heading + .panel-collapse > .panel-body { - border-top-color: #d62c1a; -} -.panel-danger > .panel-heading .badge { - color: #e74c3c; - background-color: #ffffff; -} -.panel-danger > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: #d62c1a; -} -.embed-responsive { - position: relative; - display: block; - height: 0; - padding: 0; - overflow: hidden; -} -.embed-responsive .embed-responsive-item, -.embed-responsive iframe, -.embed-responsive embed, -.embed-responsive object, -.embed-responsive video { - position: absolute; - top: 0; - left: 0; - bottom: 0; - height: 100%; - width: 100%; - border: 0; -} -.embed-responsive-16by9 { - padding-bottom: 56.25%; -} -.embed-responsive-4by3 { - padding-bottom: 75%; -} -.well { - min-height: 20px; - padding: 19px; - margin-bottom: 20px; - background-color: #ecf0f1; - border: 1px solid transparent; - border-radius: 4px; - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05); -} -.well blockquote { - border-color: #ddd; - border-color: rgba(0, 0, 0, 0.15); -} -.well-lg { - padding: 24px; - border-radius: 6px; -} -.well-sm { - padding: 9px; - border-radius: 3px; -} -.close { - float: right; - font-size: 19.5px; - font-weight: bold; - line-height: 1; - color: #000000; - text-shadow: none; - opacity: 0.2; - filter: alpha(opacity=20); -} -.close:hover, -.close:focus { - color: #000000; - text-decoration: none; - cursor: pointer; - opacity: 0.5; - filter: alpha(opacity=50); -} -button.close { - padding: 0; - cursor: pointer; - background: transparent; - border: 0; - -webkit-appearance: none; -} -.modal-open { - overflow: hidden; -} -.modal { - display: none; - overflow: hidden; - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 1070; - -webkit-overflow-scrolling: touch; - outline: 0; -} -.modal.fade .modal-dialog { - -webkit-transform: translate(0, -25%); - transform: translate(0, -25%); - -webkit-transition: -webkit-transform 0.3s ease-out; - transition: transform 0.3s ease-out; -} -.modal.in .modal-dialog { - -webkit-transform: translate(0, 0); - transform: translate(0, 0); -} -.modal-open .modal { - overflow-x: hidden; - overflow-y: auto; -} -.modal-dialog { - position: relative; - width: auto; - margin: 10px; -} -.modal-content { - position: relative; - background-color: #ffffff; - border: 1px solid #999999; - border: 1px solid rgba(0, 0, 0, 0.2); - border-radius: 6px; - box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5); - background-clip: padding-box; - outline: 0; -} -.modal-backdrop { - position: fixed; - top: 0; - right: 0; - bottom: 0; - left: 0; - z-index: 1060; - background-color: #000000; -} -.modal-backdrop.fade { - opacity: 0; - filter: alpha(opacity=0); -} -.modal-backdrop.in { - opacity: 0.5; - filter: alpha(opacity=50); -} -.modal-header { - padding: 15px; - border-bottom: 1px solid #e5e5e5; - min-height: 16.42857143px; -} -.modal-header .close { - margin-top: -2px; -} -.modal-title { - margin: 0; - line-height: 1.42857143; -} -.modal-body { - position: relative; - padding: 20px; -} -.modal-footer { - padding: 20px; - text-align: right; - border-top: 1px solid #e5e5e5; -} -.modal-footer .btn + .btn { - margin-left: 5px; - margin-bottom: 0; -} -.modal-footer .btn-group .btn + .btn { - margin-left: -1px; -} -.modal-footer .btn-block + .btn-block { - margin-left: 0; -} -.modal-scrollbar-measure { - position: absolute; - top: -9999px; - width: 50px; - height: 50px; - overflow: scroll; -} -@media (min-width: 768px) { - .modal-dialog { - width: 600px; - margin: 30px auto; - } - .modal-content { - box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5); - } - .modal-sm { - width: 300px; - } -} -@media (min-width: 992px) { - .modal-lg { - width: 900px; - } -} -.tooltip { - position: absolute; - z-index: 1040; - display: block; - font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; - font-style: normal; - font-weight: normal; - letter-spacing: normal; - line-break: auto; - line-height: 1.42857143; - text-align: left; - text-align: start; - text-decoration: none; - text-shadow: none; - text-transform: none; - white-space: normal; - word-break: normal; - word-spacing: normal; - word-wrap: normal; - font-size: 12px; - opacity: 0; - filter: alpha(opacity=0); -} -.tooltip.in { - opacity: 0.9; - filter: alpha(opacity=90); -} -.tooltip.top { - margin-top: -3px; - padding: 5px 0; -} -.tooltip.right { - margin-left: 3px; - padding: 0 5px; -} -.tooltip.bottom { - margin-top: 3px; - padding: 5px 0; -} -.tooltip.left { - margin-left: -3px; - padding: 0 5px; -} -.tooltip-inner { - max-width: 200px; - padding: 3px 8px; - color: #ecf0f1; - text-align: center; - background-color: rgba(34, 34, 34, 0.93); - border-radius: 4px; -} -.tooltip-arrow { - position: absolute; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; -} -.tooltip.top .tooltip-arrow { - bottom: 0; - left: 50%; - margin-left: -5px; - border-width: 5px 5px 0; - border-top-color: rgba(34, 34, 34, 0.93); -} -.tooltip.top-left .tooltip-arrow { - bottom: 0; - right: 5px; - margin-bottom: -5px; - border-width: 5px 5px 0; - border-top-color: rgba(34, 34, 34, 0.93); -} -.tooltip.top-right .tooltip-arrow { - bottom: 0; - left: 5px; - margin-bottom: -5px; - border-width: 5px 5px 0; - border-top-color: rgba(34, 34, 34, 0.93); -} -.tooltip.right .tooltip-arrow { - top: 50%; - left: 0; - margin-top: -5px; - border-width: 5px 5px 5px 0; - border-right-color: rgba(34, 34, 34, 0.93); -} -.tooltip.left .tooltip-arrow { - top: 50%; - right: 0; - margin-top: -5px; - border-width: 5px 0 5px 5px; - border-left-color: rgba(34, 34, 34, 0.93); -} -.tooltip.bottom .tooltip-arrow { - top: 0; - left: 50%; - margin-left: -5px; - border-width: 0 5px 5px; - border-bottom-color: rgba(34, 34, 34, 0.93); -} -.tooltip.bottom-left .tooltip-arrow { - top: 0; - right: 5px; - margin-top: -5px; - border-width: 0 5px 5px; - border-bottom-color: rgba(34, 34, 34, 0.93); -} -.tooltip.bottom-right .tooltip-arrow { - top: 0; - left: 5px; - margin-top: -5px; - border-width: 0 5px 5px; - border-bottom-color: rgba(34, 34, 34, 0.93); -} -.popover { - position: absolute; - top: 0; - left: 0; - z-index: 1010; - display: none; - max-width: 276px; - padding: 1px; - font-family: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; - font-style: normal; - font-weight: normal; - letter-spacing: normal; - line-break: auto; - line-height: 1.42857143; - text-align: left; - text-align: start; - text-decoration: none; - text-shadow: none; - text-transform: none; - white-space: normal; - word-break: normal; - word-spacing: normal; - word-wrap: normal; - font-size: 13px; - background-color: #ffffff; - background-clip: padding-box; - border: 1px solid #cccccc; - border: 1px solid rgba(0, 0, 0, 0.2); - border-radius: 6px; - box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); -} -.popover.top { - margin-top: -10px; -} -.popover.right { - margin-left: 10px; -} -.popover.bottom { - margin-top: 10px; -} -.popover.left { - margin-left: -10px; -} -.popover-title { - margin: 0; - padding: 8px 14px; - font-size: 13px; - background-color: #f7f7f7; - border-bottom: 1px solid #ebebeb; - border-radius: 5px 5px 0 0; -} -.popover-content { - padding: 9px 14px; -} -.popover > .arrow, -.popover > .arrow:after { - position: absolute; - display: block; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; -} -.popover > .arrow { - border-width: 11px; -} -.popover > .arrow:after { - border-width: 10px; - content: ""; -} -.popover.top > .arrow { - left: 50%; - margin-left: -11px; - border-bottom-width: 0; - border-top-color: #999999; - border-top-color: rgba(0, 0, 0, 0.25); - bottom: -11px; -} -.popover.top > .arrow:after { - content: " "; - bottom: 1px; - margin-left: -10px; - border-bottom-width: 0; - border-top-color: #ffffff; -} -.popover.right > .arrow { - top: 50%; - left: -11px; - margin-top: -11px; - border-left-width: 0; - border-right-color: #999999; - border-right-color: rgba(0, 0, 0, 0.25); -} -.popover.right > .arrow:after { - content: " "; - left: 1px; - bottom: -10px; - border-left-width: 0; - border-right-color: #ffffff; -} -.popover.bottom > .arrow { - left: 50%; - margin-left: -11px; - border-top-width: 0; - border-bottom-color: #999999; - border-bottom-color: rgba(0, 0, 0, 0.25); - top: -11px; -} -.popover.bottom > .arrow:after { - content: " "; - top: 1px; - margin-left: -10px; - border-top-width: 0; - border-bottom-color: #ffffff; -} -.popover.left > .arrow { - top: 50%; - right: -11px; - margin-top: -11px; - border-right-width: 0; - border-left-color: #999999; - border-left-color: rgba(0, 0, 0, 0.25); -} -.popover.left > .arrow:after { - content: " "; - right: 1px; - border-right-width: 0; - border-left-color: #ffffff; - bottom: -10px; -} -.carousel { - position: relative; -} -.carousel-inner { - position: relative; - overflow: hidden; - width: 100%; -} -.carousel-inner > .item { - display: none; - position: relative; - -webkit-transition: 0.6s ease-in-out left; - transition: 0.6s ease-in-out left; -} -.carousel-inner > .item > img, -.carousel-inner > .item > a > img { - line-height: 1; -} -@media all and (transform-3d), (-webkit-transform-3d) { - .carousel-inner > .item { - -webkit-transition: -webkit-transform 0.6s ease-in-out; - transition: transform 0.6s ease-in-out; - -webkit-backface-visibility: hidden; - backface-visibility: hidden; - -webkit-perspective: 1000px; - perspective: 1000px; - } - .carousel-inner > .item.next, - .carousel-inner > .item.active.right { - -webkit-transform: translate3d(100%, 0, 0); - transform: translate3d(100%, 0, 0); - left: 0; - } - .carousel-inner > .item.prev, - .carousel-inner > .item.active.left { - -webkit-transform: translate3d(-100%, 0, 0); - transform: translate3d(-100%, 0, 0); - left: 0; - } - .carousel-inner > .item.next.left, - .carousel-inner > .item.prev.right, - .carousel-inner > .item.active { - -webkit-transform: translate3d(0, 0, 0); - transform: translate3d(0, 0, 0); - left: 0; - } -} -.carousel-inner > .active, -.carousel-inner > .next, -.carousel-inner > .prev { - display: block; -} -.carousel-inner > .active { - left: 0; -} -.carousel-inner > .next, -.carousel-inner > .prev { - position: absolute; - top: 0; - width: 100%; -} -.carousel-inner > .next { - left: 100%; -} -.carousel-inner > .prev { - left: -100%; -} -.carousel-inner > .next.left, -.carousel-inner > .prev.right { - left: 0; -} -.carousel-inner > .active.left { - left: -100%; -} -.carousel-inner > .active.right { - left: 100%; -} -.carousel-control { - position: absolute; - top: 0; - left: 0; - bottom: 0; - width: 15%; - opacity: 0.5; - filter: alpha(opacity=50); - font-size: 20px; - color: #ffffff; - text-align: center; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); -} -.carousel-control.left { - background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%); - background-image: linear-gradient(to right, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.0001) 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1); -} -.carousel-control.right { - left: auto; - right: 0; - background-image: -webkit-linear-gradient(left, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%); - background-image: linear-gradient(to right, rgba(0, 0, 0, 0.0001) 0%, rgba(0, 0, 0, 0.5) 100%); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00000000', endColorstr='#80000000', GradientType=1); -} -.carousel-control:hover, -.carousel-control:focus { - outline: 0; - color: #ffffff; - text-decoration: none; - opacity: 0.9; - filter: alpha(opacity=90); -} -.carousel-control .icon-prev, -.carousel-control .icon-next, -.carousel-control .glyphicon-chevron-left, -.carousel-control .glyphicon-chevron-right { - position: absolute; - top: 50%; - margin-top: -10px; - z-index: 5; - display: inline-block; -} -.carousel-control .icon-prev, -.carousel-control .glyphicon-chevron-left { - left: 50%; - margin-left: -10px; -} -.carousel-control .icon-next, -.carousel-control .glyphicon-chevron-right { - right: 50%; - margin-right: -10px; -} -.carousel-control .icon-prev, -.carousel-control .icon-next { - width: 20px; - height: 20px; - line-height: 1; - font-family: serif; -} -.carousel-control .icon-prev:before { - content: '\2039'; -} -.carousel-control .icon-next:before { - content: '\203A'; -} -.carousel-indicators { - position: absolute; - bottom: 10px; - left: 50%; - z-index: 15; - width: 60%; - margin-left: -30%; - padding-left: 0; - list-style: none; - text-align: center; -} -.carousel-indicators li { - display: inline-block; - width: 10px; - height: 10px; - margin: 1px; - text-indent: -999px; - border: 1px solid #ffffff; - border-radius: 10px; - cursor: pointer; - background-color: #000 \9; - background-color: rgba(0, 0, 0, 0); -} -.carousel-indicators .active { - margin: 0; - width: 12px; - height: 12px; - background-color: #ffffff; -} -.carousel-caption { - position: absolute; - left: 15%; - right: 15%; - bottom: 20px; - z-index: 10; - padding-top: 20px; - padding-bottom: 20px; - color: #ffffff; - text-align: center; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); -} -.carousel-caption .btn { - text-shadow: none; -} -@media screen and (min-width: 768px) { - .carousel-control .glyphicon-chevron-left, - .carousel-control .glyphicon-chevron-right, - .carousel-control .icon-prev, - .carousel-control .icon-next { - width: 30px; - height: 30px; - margin-top: -15px; - font-size: 30px; - } - .carousel-control .glyphicon-chevron-left, - .carousel-control .icon-prev { - margin-left: -15px; - } - .carousel-control .glyphicon-chevron-right, - .carousel-control .icon-next { - margin-right: -15px; - } - .carousel-caption { - left: 20%; - right: 20%; - padding-bottom: 30px; - } - .carousel-indicators { - bottom: 20px; - } -} -.clearfix:before, -.clearfix:after, -.dl-horizontal dd:before, -.dl-horizontal dd:after, -.container:before, -.container:after, -.container-fluid:before, -.container-fluid:after, -.row:before, -.row:after, -.form-horizontal .form-group:before, -.form-horizontal .form-group:after, -.btn-toolbar:before, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:before, -.btn-group-vertical > .btn-group:after, -.nav:before, -.nav:after, -.navbar:before, -.navbar:after, -.navbar-header:before, -.navbar-header:after, -.navbar-collapse:before, -.navbar-collapse:after, -.pager:before, -.pager:after, -.panel-body:before, -.panel-body:after, -.modal-footer:before, -.modal-footer:after { - content: " "; - display: table; -} -.clearfix:after, -.dl-horizontal dd:after, -.container:after, -.container-fluid:after, -.row:after, -.form-horizontal .form-group:after, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:after, -.nav:after, -.navbar:after, -.navbar-header:after, -.navbar-collapse:after, -.pager:after, -.panel-body:after, -.modal-footer:after { - clear: both; -} -.center-block { - display: block; - margin-left: auto; - margin-right: auto; -} -.pull-right { - float: right !important; -} -.pull-left { - float: left !important; -} -.hide { - display: none !important; -} -.show { - display: block !important; -} -.invisible { - visibility: hidden; -} -.text-hide { - font: 0/0 a; - color: transparent; - text-shadow: none; - background-color: transparent; - border: 0; -} -.hidden { - display: none !important; -} -.affix { - position: fixed; -} -@-ms-viewport { - width: device-width; -} -.visible-xs, -.visible-sm, -.visible-md, -.visible-lg { - display: none !important; -} -.visible-xs-block, -.visible-xs-inline, -.visible-xs-inline-block, -.visible-sm-block, -.visible-sm-inline, -.visible-sm-inline-block, -.visible-md-block, -.visible-md-inline, -.visible-md-inline-block, -.visible-lg-block, -.visible-lg-inline, -.visible-lg-inline-block { - display: none !important; -} -@media (max-width: 767px) { - .visible-xs { - display: block !important; - } - table.visible-xs { - display: table !important; - } - tr.visible-xs { - display: table-row !important; - } - th.visible-xs, - td.visible-xs { - display: table-cell !important; - } -} -@media (max-width: 767px) { - .visible-xs-block { - display: block !important; - } -} -@media (max-width: 767px) { - .visible-xs-inline { - display: inline !important; - } -} -@media (max-width: 767px) { - .visible-xs-inline-block { - display: inline-block !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .visible-sm { - display: block !important; - } - table.visible-sm { - display: table !important; - } - tr.visible-sm { - display: table-row !important; - } - th.visible-sm, - td.visible-sm { - display: table-cell !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .visible-sm-block { - display: block !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .visible-sm-inline { - display: inline !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .visible-sm-inline-block { - display: inline-block !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .visible-md { - display: block !important; - } - table.visible-md { - display: table !important; - } - tr.visible-md { - display: table-row !important; - } - th.visible-md, - td.visible-md { - display: table-cell !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .visible-md-block { - display: block !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .visible-md-inline { - display: inline !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .visible-md-inline-block { - display: inline-block !important; - } -} -@media (min-width: 1200px) { - .visible-lg { - display: block !important; - } - table.visible-lg { - display: table !important; - } - tr.visible-lg { - display: table-row !important; - } - th.visible-lg, - td.visible-lg { - display: table-cell !important; - } -} -@media (min-width: 1200px) { - .visible-lg-block { - display: block !important; - } -} -@media (min-width: 1200px) { - .visible-lg-inline { - display: inline !important; - } -} -@media (min-width: 1200px) { - .visible-lg-inline-block { - display: inline-block !important; - } -} -@media (max-width: 767px) { - .hidden-xs { - display: none !important; - } -} -@media (min-width: 768px) and (max-width: 991px) { - .hidden-sm { - display: none !important; - } -} -@media (min-width: 992px) and (max-width: 1199px) { - .hidden-md { - display: none !important; - } -} -@media (min-width: 1200px) { - .hidden-lg { - display: none !important; - } -} -.visible-print { - display: none !important; -} -@media print { - .visible-print { - display: block !important; - } - table.visible-print { - display: table !important; - } - tr.visible-print { - display: table-row !important; - } - th.visible-print, - td.visible-print { - display: table-cell !important; - } -} -.visible-print-block { - display: none !important; -} -@media print { - .visible-print-block { - display: block !important; - } -} -.visible-print-inline { - display: none !important; -} -@media print { - .visible-print-inline { - display: inline !important; - } -} -.visible-print-inline-block { - display: none !important; -} -@media print { - .visible-print-inline-block { - display: inline-block !important; - } -} -@media print { - .hidden-print { - display: none !important; - } -} -/*! - * Font Awesome 4.4.0 by @davegandy - http://fontawesome.io - @fontawesome - * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */ -/* FONT PATH - * -------------------------- */ -@font-face { - font-family: 'FontAwesome'; - src: url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.eot); - src: url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.eot?#iefix&v=4.4.0) format('embedded-opentype'), url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.woff2) format('woff2'), url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.woff) format('woff'), url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.ttf) format('truetype'), url(/bundles/node_modules/font-awesome/fonts/fontawesome-webfont.svg#fontawesomeregular) format('svg'); - font-weight: normal; - font-style: normal; -} -.fa { - display: inline-block; - font: normal normal normal 14px/1 FontAwesome; - font-size: inherit; - text-rendering: auto; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} -/* makes the font 33% larger relative to the icon container */ -.fa-lg { - font-size: 1.33333333em; - line-height: 0.75em; - vertical-align: -15%; -} -.fa-2x { - font-size: 2em; -} -.fa-3x { - font-size: 3em; -} -.fa-4x { - font-size: 4em; -} -.fa-5x { - font-size: 5em; -} -.fa-fw { - width: 1.28571429em; - text-align: center; -} -.fa-ul { - padding-left: 0; - margin-left: 2.14285714em; - list-style-type: none; -} -.fa-ul > li { - position: relative; -} -.fa-li { - position: absolute; - left: -2.14285714em; - width: 2.14285714em; - top: 0.14285714em; - text-align: center; -} -.fa-li.fa-lg { - left: -1.85714286em; -} -.fa-border { - padding: .2em .25em .15em; - border: solid 0.08em #eeeeee; - border-radius: .1em; -} -.fa-pull-left { - float: left; -} -.fa-pull-right { - float: right; -} -.fa.fa-pull-left { - margin-right: .3em; -} -.fa.fa-pull-right { - margin-left: .3em; -} -/* Deprecated as of 4.4.0 */ -.pull-right { - float: right; -} -.pull-left { - float: left; -} -.fa.pull-left { - margin-right: .3em; -} -.fa.pull-right { - margin-left: .3em; -} -.fa-spin { - -webkit-animation: fa-spin 2s infinite linear; - animation: fa-spin 2s infinite linear; -} -.fa-pulse { - -webkit-animation: fa-spin 1s infinite steps(8); - animation: fa-spin 1s infinite steps(8); -} -@-webkit-keyframes fa-spin { - 0% { - -webkit-transform: rotate(0deg); - transform: rotate(0deg); - } - 100% { - -webkit-transform: rotate(359deg); - transform: rotate(359deg); - } -} -@keyframes fa-spin { - 0% { - -webkit-transform: rotate(0deg); - transform: rotate(0deg); - } - 100% { - -webkit-transform: rotate(359deg); - transform: rotate(359deg); - } -} -.fa-rotate-90 { - filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1); - -webkit-transform: rotate(90deg); - transform: rotate(90deg); -} -.fa-rotate-180 { - filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2); - -webkit-transform: rotate(180deg); - transform: rotate(180deg); -} -.fa-rotate-270 { - filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); - -webkit-transform: rotate(270deg); - transform: rotate(270deg); -} -.fa-flip-horizontal { - filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1); - -webkit-transform: scale(-1, 1); - transform: scale(-1, 1); -} -.fa-flip-vertical { - filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1); - -webkit-transform: scale(1, -1); - transform: scale(1, -1); -} -:root .fa-rotate-90, -:root .fa-rotate-180, -:root .fa-rotate-270, -:root .fa-flip-horizontal, -:root .fa-flip-vertical { - -webkit-filter: none; - filter: none; -} -.fa-stack { - position: relative; - display: inline-block; - width: 2em; - height: 2em; - line-height: 2em; - vertical-align: middle; -} -.fa-stack-1x, -.fa-stack-2x { - position: absolute; - left: 0; - width: 100%; - text-align: center; -} -.fa-stack-1x { - line-height: inherit; -} -.fa-stack-2x { - font-size: 2em; -} -.fa-inverse { - color: #ffffff; -} -/* Font Awesome uses the Unicode Private Use Area (PUA) to ensure screen - readers do not read off random characters that represent icons */ -.fa-glass:before { - content: "\F000"; -} -.fa-music:before { - content: "\F001"; -} -.fa-search:before { - content: "\F002"; -} -.fa-envelope-o:before { - content: "\F003"; -} -.fa-heart:before { - content: "\F004"; -} -.fa-star:before { - content: "\F005"; -} -.fa-star-o:before { - content: "\F006"; -} -.fa-user:before { - content: "\F007"; -} -.fa-film:before { - content: "\F008"; -} -.fa-th-large:before { - content: "\F009"; -} -.fa-th:before { - content: "\F00A"; -} -.fa-th-list:before { - content: "\F00B"; -} -.fa-check:before { - content: "\F00C"; -} -.fa-remove:before, -.fa-close:before, -.fa-times:before { - content: "\F00D"; -} -.fa-search-plus:before { - content: "\F00E"; -} -.fa-search-minus:before { - content: "\F010"; -} -.fa-power-off:before { - content: "\F011"; -} -.fa-signal:before { - content: "\F012"; -} -.fa-gear:before, -.fa-cog:before { - content: "\F013"; -} -.fa-trash-o:before { - content: "\F014"; -} -.fa-home:before { - content: "\F015"; -} -.fa-file-o:before { - content: "\F016"; -} -.fa-clock-o:before { - content: "\F017"; -} -.fa-road:before { - content: "\F018"; -} -.fa-download:before { - content: "\F019"; -} -.fa-arrow-circle-o-down:before { - content: "\F01A"; -} -.fa-arrow-circle-o-up:before { - content: "\F01B"; -} -.fa-inbox:before { - content: "\F01C"; -} -.fa-play-circle-o:before { - content: "\F01D"; -} -.fa-rotate-right:before, -.fa-repeat:before { - content: "\F01E"; -} -.fa-refresh:before { - content: "\F021"; -} -.fa-list-alt:before { - content: "\F022"; -} -.fa-lock:before { - content: "\F023"; -} -.fa-flag:before { - content: "\F024"; -} -.fa-headphones:before { - content: "\F025"; -} -.fa-volume-off:before { - content: "\F026"; -} -.fa-volume-down:before { - content: "\F027"; -} -.fa-volume-up:before { - content: "\F028"; -} -.fa-qrcode:before { - content: "\F029"; -} -.fa-barcode:before { - content: "\F02A"; -} -.fa-tag:before { - content: "\F02B"; -} -.fa-tags:before { - content: "\F02C"; -} -.fa-book:before { - content: "\F02D"; -} -.fa-bookmark:before { - content: "\F02E"; -} -.fa-print:before { - content: "\F02F"; -} -.fa-camera:before { - content: "\F030"; -} -.fa-font:before { - content: "\F031"; -} -.fa-bold:before { - content: "\F032"; -} -.fa-italic:before { - content: "\F033"; -} -.fa-text-height:before { - content: "\F034"; -} -.fa-text-width:before { - content: "\F035"; -} -.fa-align-left:before { - content: "\F036"; -} -.fa-align-center:before { - content: "\F037"; -} -.fa-align-right:before { - content: "\F038"; -} -.fa-align-justify:before { - content: "\F039"; -} -.fa-list:before { - content: "\F03A"; -} -.fa-dedent:before, -.fa-outdent:before { - content: "\F03B"; -} -.fa-indent:before { - content: "\F03C"; -} -.fa-video-camera:before { - content: "\F03D"; -} -.fa-photo:before, -.fa-image:before, -.fa-picture-o:before { - content: "\F03E"; -} -.fa-pencil:before { - content: "\F040"; -} -.fa-map-marker:before { - content: "\F041"; -} -.fa-adjust:before { - content: "\F042"; -} -.fa-tint:before { - content: "\F043"; -} -.fa-edit:before, -.fa-pencil-square-o:before { - content: "\F044"; -} -.fa-share-square-o:before { - content: "\F045"; -} -.fa-check-square-o:before { - content: "\F046"; -} -.fa-arrows:before { - content: "\F047"; -} -.fa-step-backward:before { - content: "\F048"; -} -.fa-fast-backward:before { - content: "\F049"; -} -.fa-backward:before { - content: "\F04A"; -} -.fa-play:before { - content: "\F04B"; -} -.fa-pause:before { - content: "\F04C"; -} -.fa-stop:before { - content: "\F04D"; -} -.fa-forward:before { - content: "\F04E"; -} -.fa-fast-forward:before { - content: "\F050"; -} -.fa-step-forward:before { - content: "\F051"; -} -.fa-eject:before { - content: "\F052"; -} -.fa-chevron-left:before { - content: "\F053"; -} -.fa-chevron-right:before { - content: "\F054"; -} -.fa-plus-circle:before { - content: "\F055"; -} -.fa-minus-circle:before { - content: "\F056"; -} -.fa-times-circle:before { - content: "\F057"; -} -.fa-check-circle:before { - content: "\F058"; -} -.fa-question-circle:before { - content: "\F059"; -} -.fa-info-circle:before { - content: "\F05A"; -} -.fa-crosshairs:before { - content: "\F05B"; -} -.fa-times-circle-o:before { - content: "\F05C"; -} -.fa-check-circle-o:before { - content: "\F05D"; -} -.fa-ban:before { - content: "\F05E"; -} -.fa-arrow-left:before { - content: "\F060"; -} -.fa-arrow-right:before { - content: "\F061"; -} -.fa-arrow-up:before { - content: "\F062"; -} -.fa-arrow-down:before { - content: "\F063"; -} -.fa-mail-forward:before, -.fa-share:before { - content: "\F064"; -} -.fa-expand:before { - content: "\F065"; -} -.fa-compress:before { - content: "\F066"; -} -.fa-plus:before { - content: "\F067"; -} -.fa-minus:before { - content: "\F068"; -} -.fa-asterisk:before { - content: "\F069"; -} -.fa-exclamation-circle:before { - content: "\F06A"; -} -.fa-gift:before { - content: "\F06B"; -} -.fa-leaf:before { - content: "\F06C"; -} -.fa-fire:before { - content: "\F06D"; -} -.fa-eye:before { - content: "\F06E"; -} -.fa-eye-slash:before { - content: "\F070"; -} -.fa-warning:before, -.fa-exclamation-triangle:before { - content: "\F071"; -} -.fa-plane:before { - content: "\F072"; -} -.fa-calendar:before { - content: "\F073"; -} -.fa-random:before { - content: "\F074"; -} -.fa-comment:before { - content: "\F075"; -} -.fa-magnet:before { - content: "\F076"; -} -.fa-chevron-up:before { - content: "\F077"; -} -.fa-chevron-down:before { - content: "\F078"; -} -.fa-retweet:before { - content: "\F079"; -} -.fa-shopping-cart:before { - content: "\F07A"; -} -.fa-folder:before { - content: "\F07B"; -} -.fa-folder-open:before { - content: "\F07C"; -} -.fa-arrows-v:before { - content: "\F07D"; -} -.fa-arrows-h:before { - content: "\F07E"; -} -.fa-bar-chart-o:before, -.fa-bar-chart:before { - content: "\F080"; -} -.fa-twitter-square:before { - content: "\F081"; -} -.fa-facebook-square:before { - content: "\F082"; -} -.fa-camera-retro:before { - content: "\F083"; -} -.fa-key:before { - content: "\F084"; -} -.fa-gears:before, -.fa-cogs:before { - content: "\F085"; -} -.fa-comments:before { - content: "\F086"; -} -.fa-thumbs-o-up:before { - content: "\F087"; -} -.fa-thumbs-o-down:before { - content: "\F088"; -} -.fa-star-half:before { - content: "\F089"; -} -.fa-heart-o:before { - content: "\F08A"; -} -.fa-sign-out:before { - content: "\F08B"; -} -.fa-linkedin-square:before { - content: "\F08C"; -} -.fa-thumb-tack:before { - content: "\F08D"; -} -.fa-external-link:before { - content: "\F08E"; -} -.fa-sign-in:before { - content: "\F090"; -} -.fa-trophy:before { - content: "\F091"; -} -.fa-github-square:before { - content: "\F092"; -} -.fa-upload:before { - content: "\F093"; -} -.fa-lemon-o:before { - content: "\F094"; -} -.fa-phone:before { - content: "\F095"; -} -.fa-square-o:before { - content: "\F096"; -} -.fa-bookmark-o:before { - content: "\F097"; -} -.fa-phone-square:before { - content: "\F098"; -} -.fa-twitter:before { - content: "\F099"; -} -.fa-facebook-f:before, -.fa-facebook:before { - content: "\F09A"; -} -.fa-github:before { - content: "\F09B"; -} -.fa-unlock:before { - content: "\F09C"; -} -.fa-credit-card:before { - content: "\F09D"; -} -.fa-feed:before, -.fa-rss:before { - content: "\F09E"; -} -.fa-hdd-o:before { - content: "\F0A0"; -} -.fa-bullhorn:before { - content: "\F0A1"; -} -.fa-bell:before { - content: "\F0F3"; -} -.fa-certificate:before { - content: "\F0A3"; -} -.fa-hand-o-right:before { - content: "\F0A4"; -} -.fa-hand-o-left:before { - content: "\F0A5"; -} -.fa-hand-o-up:before { - content: "\F0A6"; -} -.fa-hand-o-down:before { - content: "\F0A7"; -} -.fa-arrow-circle-left:before { - content: "\F0A8"; -} -.fa-arrow-circle-right:before { - content: "\F0A9"; -} -.fa-arrow-circle-up:before { - content: "\F0AA"; -} -.fa-arrow-circle-down:before { - content: "\F0AB"; -} -.fa-globe:before { - content: "\F0AC"; -} -.fa-wrench:before { - content: "\F0AD"; -} -.fa-tasks:before { - content: "\F0AE"; -} -.fa-filter:before { - content: "\F0B0"; -} -.fa-briefcase:before { - content: "\F0B1"; -} -.fa-arrows-alt:before { - content: "\F0B2"; -} -.fa-group:before, -.fa-users:before { - content: "\F0C0"; -} -.fa-chain:before, -.fa-link:before { - content: "\F0C1"; -} -.fa-cloud:before { - content: "\F0C2"; -} -.fa-flask:before { - content: "\F0C3"; -} -.fa-cut:before, -.fa-scissors:before { - content: "\F0C4"; -} -.fa-copy:before, -.fa-files-o:before { - content: "\F0C5"; -} -.fa-paperclip:before { - content: "\F0C6"; -} -.fa-save:before, -.fa-floppy-o:before { - content: "\F0C7"; -} -.fa-square:before { - content: "\F0C8"; -} -.fa-navicon:before, -.fa-reorder:before, -.fa-bars:before { - content: "\F0C9"; -} -.fa-list-ul:before { - content: "\F0CA"; -} -.fa-list-ol:before { - content: "\F0CB"; -} -.fa-strikethrough:before { - content: "\F0CC"; -} -.fa-underline:before { - content: "\F0CD"; -} -.fa-table:before { - content: "\F0CE"; -} -.fa-magic:before { - content: "\F0D0"; -} -.fa-truck:before { - content: "\F0D1"; -} -.fa-pinterest:before { - content: "\F0D2"; -} -.fa-pinterest-square:before { - content: "\F0D3"; -} -.fa-google-plus-square:before { - content: "\F0D4"; -} -.fa-google-plus:before { - content: "\F0D5"; -} -.fa-money:before { - content: "\F0D6"; -} -.fa-caret-down:before { - content: "\F0D7"; -} -.fa-caret-up:before { - content: "\F0D8"; -} -.fa-caret-left:before { - content: "\F0D9"; -} -.fa-caret-right:before { - content: "\F0DA"; -} -.fa-columns:before { - content: "\F0DB"; -} -.fa-unsorted:before, -.fa-sort:before { - content: "\F0DC"; -} -.fa-sort-down:before, -.fa-sort-desc:before { - content: "\F0DD"; -} -.fa-sort-up:before, -.fa-sort-asc:before { - content: "\F0DE"; -} -.fa-envelope:before { - content: "\F0E0"; -} -.fa-linkedin:before { - content: "\F0E1"; -} -.fa-rotate-left:before, -.fa-undo:before { - content: "\F0E2"; -} -.fa-legal:before, -.fa-gavel:before { - content: "\F0E3"; -} -.fa-dashboard:before, -.fa-tachometer:before { - content: "\F0E4"; -} -.fa-comment-o:before { - content: "\F0E5"; -} -.fa-comments-o:before { - content: "\F0E6"; -} -.fa-flash:before, -.fa-bolt:before { - content: "\F0E7"; -} -.fa-sitemap:before { - content: "\F0E8"; -} -.fa-umbrella:before { - content: "\F0E9"; -} -.fa-paste:before, -.fa-clipboard:before { - content: "\F0EA"; -} -.fa-lightbulb-o:before { - content: "\F0EB"; -} -.fa-exchange:before { - content: "\F0EC"; -} -.fa-cloud-download:before { - content: "\F0ED"; -} -.fa-cloud-upload:before { - content: "\F0EE"; -} -.fa-user-md:before { - content: "\F0F0"; -} -.fa-stethoscope:before { - content: "\F0F1"; -} -.fa-suitcase:before { - content: "\F0F2"; -} -.fa-bell-o:before { - content: "\F0A2"; -} -.fa-coffee:before { - content: "\F0F4"; -} -.fa-cutlery:before { - content: "\F0F5"; -} -.fa-file-text-o:before { - content: "\F0F6"; -} -.fa-building-o:before { - content: "\F0F7"; -} -.fa-hospital-o:before { - content: "\F0F8"; -} -.fa-ambulance:before { - content: "\F0F9"; -} -.fa-medkit:before { - content: "\F0FA"; -} -.fa-fighter-jet:before { - content: "\F0FB"; -} -.fa-beer:before { - content: "\F0FC"; -} -.fa-h-square:before { - content: "\F0FD"; -} -.fa-plus-square:before { - content: "\F0FE"; -} -.fa-angle-double-left:before { - content: "\F100"; -} -.fa-angle-double-right:before { - content: "\F101"; -} -.fa-angle-double-up:before { - content: "\F102"; -} -.fa-angle-double-down:before { - content: "\F103"; -} -.fa-angle-left:before { - content: "\F104"; -} -.fa-angle-right:before { - content: "\F105"; -} -.fa-angle-up:before { - content: "\F106"; -} -.fa-angle-down:before { - content: "\F107"; -} -.fa-desktop:before { - content: "\F108"; -} -.fa-laptop:before { - content: "\F109"; -} -.fa-tablet:before { - content: "\F10A"; -} -.fa-mobile-phone:before, -.fa-mobile:before { - content: "\F10B"; -} -.fa-circle-o:before { - content: "\F10C"; -} -.fa-quote-left:before { - content: "\F10D"; -} -.fa-quote-right:before { - content: "\F10E"; -} -.fa-spinner:before { - content: "\F110"; -} -.fa-circle:before { - content: "\F111"; -} -.fa-mail-reply:before, -.fa-reply:before { - content: "\F112"; -} -.fa-github-alt:before { - content: "\F113"; -} -.fa-folder-o:before { - content: "\F114"; -} -.fa-folder-open-o:before { - content: "\F115"; -} -.fa-smile-o:before { - content: "\F118"; -} -.fa-frown-o:before { - content: "\F119"; -} -.fa-meh-o:before { - content: "\F11A"; -} -.fa-gamepad:before { - content: "\F11B"; -} -.fa-keyboard-o:before { - content: "\F11C"; -} -.fa-flag-o:before { - content: "\F11D"; -} -.fa-flag-checkered:before { - content: "\F11E"; -} -.fa-terminal:before { - content: "\F120"; -} -.fa-code:before { - content: "\F121"; -} -.fa-mail-reply-all:before, -.fa-reply-all:before { - content: "\F122"; -} -.fa-star-half-empty:before, -.fa-star-half-full:before, -.fa-star-half-o:before { - content: "\F123"; -} -.fa-location-arrow:before { - content: "\F124"; -} -.fa-crop:before { - content: "\F125"; -} -.fa-code-fork:before { - content: "\F126"; -} -.fa-unlink:before, -.fa-chain-broken:before { - content: "\F127"; -} -.fa-question:before { - content: "\F128"; -} -.fa-info:before { - content: "\F129"; -} -.fa-exclamation:before { - content: "\F12A"; -} -.fa-superscript:before { - content: "\F12B"; -} -.fa-subscript:before { - content: "\F12C"; -} -.fa-eraser:before { - content: "\F12D"; -} -.fa-puzzle-piece:before { - content: "\F12E"; -} -.fa-microphone:before { - content: "\F130"; -} -.fa-microphone-slash:before { - content: "\F131"; -} -.fa-shield:before { - content: "\F132"; -} -.fa-calendar-o:before { - content: "\F133"; -} -.fa-fire-extinguisher:before { - content: "\F134"; -} -.fa-rocket:before { - content: "\F135"; -} -.fa-maxcdn:before { - content: "\F136"; -} -.fa-chevron-circle-left:before { - content: "\F137"; -} -.fa-chevron-circle-right:before { - content: "\F138"; -} -.fa-chevron-circle-up:before { - content: "\F139"; -} -.fa-chevron-circle-down:before { - content: "\F13A"; -} -.fa-html5:before { - content: "\F13B"; -} -.fa-css3:before { - content: "\F13C"; -} -.fa-anchor:before { - content: "\F13D"; -} -.fa-unlock-alt:before { - content: "\F13E"; -} -.fa-bullseye:before { - content: "\F140"; -} -.fa-ellipsis-h:before { - content: "\F141"; -} -.fa-ellipsis-v:before { - content: "\F142"; -} -.fa-rss-square:before { - content: "\F143"; -} -.fa-play-circle:before { - content: "\F144"; -} -.fa-ticket:before { - content: "\F145"; -} -.fa-minus-square:before { - content: "\F146"; -} -.fa-minus-square-o:before { - content: "\F147"; -} -.fa-level-up:before { - content: "\F148"; -} -.fa-level-down:before { - content: "\F149"; -} -.fa-check-square:before { - content: "\F14A"; -} -.fa-pencil-square:before { - content: "\F14B"; -} -.fa-external-link-square:before { - content: "\F14C"; -} -.fa-share-square:before { - content: "\F14D"; -} -.fa-compass:before { - content: "\F14E"; -} -.fa-toggle-down:before, -.fa-caret-square-o-down:before { - content: "\F150"; -} -.fa-toggle-up:before, -.fa-caret-square-o-up:before { - content: "\F151"; -} -.fa-toggle-right:before, -.fa-caret-square-o-right:before { - content: "\F152"; -} -.fa-euro:before, -.fa-eur:before { - content: "\F153"; -} -.fa-gbp:before { - content: "\F154"; -} -.fa-dollar:before, -.fa-usd:before { - content: "\F155"; -} -.fa-rupee:before, -.fa-inr:before { - content: "\F156"; -} -.fa-cny:before, -.fa-rmb:before, -.fa-yen:before, -.fa-jpy:before { - content: "\F157"; -} -.fa-ruble:before, -.fa-rouble:before, -.fa-rub:before { - content: "\F158"; -} -.fa-won:before, -.fa-krw:before { - content: "\F159"; -} -.fa-bitcoin:before, -.fa-btc:before { - content: "\F15A"; -} -.fa-file:before { - content: "\F15B"; -} -.fa-file-text:before { - content: "\F15C"; -} -.fa-sort-alpha-asc:before { - content: "\F15D"; -} -.fa-sort-alpha-desc:before { - content: "\F15E"; -} -.fa-sort-amount-asc:before { - content: "\F160"; -} -.fa-sort-amount-desc:before { - content: "\F161"; -} -.fa-sort-numeric-asc:before { - content: "\F162"; -} -.fa-sort-numeric-desc:before { - content: "\F163"; -} -.fa-thumbs-up:before { - content: "\F164"; -} -.fa-thumbs-down:before { - content: "\F165"; -} -.fa-youtube-square:before { - content: "\F166"; -} -.fa-youtube:before { - content: "\F167"; -} -.fa-xing:before { - content: "\F168"; -} -.fa-xing-square:before { - content: "\F169"; -} -.fa-youtube-play:before { - content: "\F16A"; -} -.fa-dropbox:before { - content: "\F16B"; -} -.fa-stack-overflow:before { - content: "\F16C"; -} -.fa-instagram:before { - content: "\F16D"; -} -.fa-flickr:before { - content: "\F16E"; -} -.fa-adn:before { - content: "\F170"; -} -.fa-bitbucket:before { - content: "\F171"; -} -.fa-bitbucket-square:before { - content: "\F172"; -} -.fa-tumblr:before { - content: "\F173"; -} -.fa-tumblr-square:before { - content: "\F174"; -} -.fa-long-arrow-down:before { - content: "\F175"; -} -.fa-long-arrow-up:before { - content: "\F176"; -} -.fa-long-arrow-left:before { - content: "\F177"; -} -.fa-long-arrow-right:before { - content: "\F178"; -} -.fa-apple:before { - content: "\F179"; -} -.fa-windows:before { - content: "\F17A"; -} -.fa-android:before { - content: "\F17B"; -} -.fa-linux:before { - content: "\F17C"; -} -.fa-dribbble:before { - content: "\F17D"; -} -.fa-skype:before { - content: "\F17E"; -} -.fa-foursquare:before { - content: "\F180"; -} -.fa-trello:before { - content: "\F181"; -} -.fa-female:before { - content: "\F182"; -} -.fa-male:before { - content: "\F183"; -} -.fa-gittip:before, -.fa-gratipay:before { - content: "\F184"; -} -.fa-sun-o:before { - content: "\F185"; -} -.fa-moon-o:before { - content: "\F186"; -} -.fa-archive:before { - content: "\F187"; -} -.fa-bug:before { - content: "\F188"; -} -.fa-vk:before { - content: "\F189"; -} -.fa-weibo:before { - content: "\F18A"; -} -.fa-renren:before { - content: "\F18B"; -} -.fa-pagelines:before { - content: "\F18C"; -} -.fa-stack-exchange:before { - content: "\F18D"; -} -.fa-arrow-circle-o-right:before { - content: "\F18E"; -} -.fa-arrow-circle-o-left:before { - content: "\F190"; -} -.fa-toggle-left:before, -.fa-caret-square-o-left:before { - content: "\F191"; -} -.fa-dot-circle-o:before { - content: "\F192"; -} -.fa-wheelchair:before { - content: "\F193"; -} -.fa-vimeo-square:before { - content: "\F194"; -} -.fa-turkish-lira:before, -.fa-try:before { - content: "\F195"; -} -.fa-plus-square-o:before { - content: "\F196"; -} -.fa-space-shuttle:before { - content: "\F197"; -} -.fa-slack:before { - content: "\F198"; -} -.fa-envelope-square:before { - content: "\F199"; -} -.fa-wordpress:before { - content: "\F19A"; -} -.fa-openid:before { - content: "\F19B"; -} -.fa-institution:before, -.fa-bank:before, -.fa-university:before { - content: "\F19C"; -} -.fa-mortar-board:before, -.fa-graduation-cap:before { - content: "\F19D"; -} -.fa-yahoo:before { - content: "\F19E"; -} -.fa-google:before { - content: "\F1A0"; -} -.fa-reddit:before { - content: "\F1A1"; -} -.fa-reddit-square:before { - content: "\F1A2"; -} -.fa-stumbleupon-circle:before { - content: "\F1A3"; -} -.fa-stumbleupon:before { - content: "\F1A4"; -} -.fa-delicious:before { - content: "\F1A5"; -} -.fa-digg:before { - content: "\F1A6"; -} -.fa-pied-piper:before { - content: "\F1A7"; -} -.fa-pied-piper-alt:before { - content: "\F1A8"; -} -.fa-drupal:before { - content: "\F1A9"; -} -.fa-joomla:before { - content: "\F1AA"; -} -.fa-language:before { - content: "\F1AB"; -} -.fa-fax:before { - content: "\F1AC"; -} -.fa-building:before { - content: "\F1AD"; -} -.fa-child:before { - content: "\F1AE"; -} -.fa-paw:before { - content: "\F1B0"; -} -.fa-spoon:before { - content: "\F1B1"; -} -.fa-cube:before { - content: "\F1B2"; -} -.fa-cubes:before { - content: "\F1B3"; -} -.fa-behance:before { - content: "\F1B4"; -} -.fa-behance-square:before { - content: "\F1B5"; -} -.fa-steam:before { - content: "\F1B6"; -} -.fa-steam-square:before { - content: "\F1B7"; -} -.fa-recycle:before { - content: "\F1B8"; -} -.fa-automobile:before, -.fa-car:before { - content: "\F1B9"; -} -.fa-cab:before, -.fa-taxi:before { - content: "\F1BA"; -} -.fa-tree:before { - content: "\F1BB"; -} -.fa-spotify:before { - content: "\F1BC"; -} -.fa-deviantart:before { - content: "\F1BD"; -} -.fa-soundcloud:before { - content: "\F1BE"; -} -.fa-database:before { - content: "\F1C0"; -} -.fa-file-pdf-o:before { - content: "\F1C1"; -} -.fa-file-word-o:before { - content: "\F1C2"; -} -.fa-file-excel-o:before { - content: "\F1C3"; -} -.fa-file-powerpoint-o:before { - content: "\F1C4"; -} -.fa-file-photo-o:before, -.fa-file-picture-o:before, -.fa-file-image-o:before { - content: "\F1C5"; -} -.fa-file-zip-o:before, -.fa-file-archive-o:before { - content: "\F1C6"; -} -.fa-file-sound-o:before, -.fa-file-audio-o:before { - content: "\F1C7"; -} -.fa-file-movie-o:before, -.fa-file-video-o:before { - content: "\F1C8"; -} -.fa-file-code-o:before { - content: "\F1C9"; -} -.fa-vine:before { - content: "\F1CA"; -} -.fa-codepen:before { - content: "\F1CB"; -} -.fa-jsfiddle:before { - content: "\F1CC"; -} -.fa-life-bouy:before, -.fa-life-buoy:before, -.fa-life-saver:before, -.fa-support:before, -.fa-life-ring:before { - content: "\F1CD"; -} -.fa-circle-o-notch:before { - content: "\F1CE"; -} -.fa-ra:before, -.fa-rebel:before { - content: "\F1D0"; -} -.fa-ge:before, -.fa-empire:before { - content: "\F1D1"; -} -.fa-git-square:before { - content: "\F1D2"; -} -.fa-git:before { - content: "\F1D3"; -} -.fa-y-combinator-square:before, -.fa-yc-square:before, -.fa-hacker-news:before { - content: "\F1D4"; -} -.fa-tencent-weibo:before { - content: "\F1D5"; -} -.fa-qq:before { - content: "\F1D6"; -} -.fa-wechat:before, -.fa-weixin:before { - content: "\F1D7"; -} -.fa-send:before, -.fa-paper-plane:before { - content: "\F1D8"; -} -.fa-send-o:before, -.fa-paper-plane-o:before { - content: "\F1D9"; -} -.fa-history:before { - content: "\F1DA"; -} -.fa-circle-thin:before { - content: "\F1DB"; -} -.fa-header:before { - content: "\F1DC"; -} -.fa-paragraph:before { - content: "\F1DD"; -} -.fa-sliders:before { - content: "\F1DE"; -} -.fa-share-alt:before { - content: "\F1E0"; -} -.fa-share-alt-square:before { - content: "\F1E1"; -} -.fa-bomb:before { - content: "\F1E2"; -} -.fa-soccer-ball-o:before, -.fa-futbol-o:before { - content: "\F1E3"; -} -.fa-tty:before { - content: "\F1E4"; -} -.fa-binoculars:before { - content: "\F1E5"; -} -.fa-plug:before { - content: "\F1E6"; -} -.fa-slideshare:before { - content: "\F1E7"; -} -.fa-twitch:before { - content: "\F1E8"; -} -.fa-yelp:before { - content: "\F1E9"; -} -.fa-newspaper-o:before { - content: "\F1EA"; -} -.fa-wifi:before { - content: "\F1EB"; -} -.fa-calculator:before { - content: "\F1EC"; -} -.fa-paypal:before { - content: "\F1ED"; -} -.fa-google-wallet:before { - content: "\F1EE"; -} -.fa-cc-visa:before { - content: "\F1F0"; -} -.fa-cc-mastercard:before { - content: "\F1F1"; -} -.fa-cc-discover:before { - content: "\F1F2"; -} -.fa-cc-amex:before { - content: "\F1F3"; -} -.fa-cc-paypal:before { - content: "\F1F4"; -} -.fa-cc-stripe:before { - content: "\F1F5"; -} -.fa-bell-slash:before { - content: "\F1F6"; -} -.fa-bell-slash-o:before { - content: "\F1F7"; -} -.fa-trash:before { - content: "\F1F8"; -} -.fa-copyright:before { - content: "\F1F9"; -} -.fa-at:before { - content: "\F1FA"; -} -.fa-eyedropper:before { - content: "\F1FB"; -} -.fa-paint-brush:before { - content: "\F1FC"; -} -.fa-birthday-cake:before { - content: "\F1FD"; -} -.fa-area-chart:before { - content: "\F1FE"; -} -.fa-pie-chart:before { - content: "\F200"; -} -.fa-line-chart:before { - content: "\F201"; -} -.fa-lastfm:before { - content: "\F202"; -} -.fa-lastfm-square:before { - content: "\F203"; -} -.fa-toggle-off:before { - content: "\F204"; -} -.fa-toggle-on:before { - content: "\F205"; -} -.fa-bicycle:before { - content: "\F206"; -} -.fa-bus:before { - content: "\F207"; -} -.fa-ioxhost:before { - content: "\F208"; -} -.fa-angellist:before { - content: "\F209"; -} -.fa-cc:before { - content: "\F20A"; -} -.fa-shekel:before, -.fa-sheqel:before, -.fa-ils:before { - content: "\F20B"; -} -.fa-meanpath:before { - content: "\F20C"; -} -.fa-buysellads:before { - content: "\F20D"; -} -.fa-connectdevelop:before { - content: "\F20E"; -} -.fa-dashcube:before { - content: "\F210"; -} -.fa-forumbee:before { - content: "\F211"; -} -.fa-leanpub:before { - content: "\F212"; -} -.fa-sellsy:before { - content: "\F213"; -} -.fa-shirtsinbulk:before { - content: "\F214"; -} -.fa-simplybuilt:before { - content: "\F215"; -} -.fa-skyatlas:before { - content: "\F216"; -} -.fa-cart-plus:before { - content: "\F217"; -} -.fa-cart-arrow-down:before { - content: "\F218"; -} -.fa-diamond:before { - content: "\F219"; -} -.fa-ship:before { - content: "\F21A"; -} -.fa-user-secret:before { - content: "\F21B"; -} -.fa-motorcycle:before { - content: "\F21C"; -} -.fa-street-view:before { - content: "\F21D"; -} -.fa-heartbeat:before { - content: "\F21E"; -} -.fa-venus:before { - content: "\F221"; -} -.fa-mars:before { - content: "\F222"; -} -.fa-mercury:before { - content: "\F223"; -} -.fa-intersex:before, -.fa-transgender:before { - content: "\F224"; -} -.fa-transgender-alt:before { - content: "\F225"; -} -.fa-venus-double:before { - content: "\F226"; -} -.fa-mars-double:before { - content: "\F227"; -} -.fa-venus-mars:before { - content: "\F228"; -} -.fa-mars-stroke:before { - content: "\F229"; -} -.fa-mars-stroke-v:before { - content: "\F22A"; -} -.fa-mars-stroke-h:before { - content: "\F22B"; -} -.fa-neuter:before { - content: "\F22C"; -} -.fa-genderless:before { - content: "\F22D"; -} -.fa-facebook-official:before { - content: "\F230"; -} -.fa-pinterest-p:before { - content: "\F231"; -} -.fa-whatsapp:before { - content: "\F232"; -} -.fa-server:before { - content: "\F233"; -} -.fa-user-plus:before { - content: "\F234"; -} -.fa-user-times:before { - content: "\F235"; -} -.fa-hotel:before, -.fa-bed:before { - content: "\F236"; -} -.fa-viacoin:before { - content: "\F237"; -} -.fa-train:before { - content: "\F238"; -} -.fa-subway:before { - content: "\F239"; -} -.fa-medium:before { - content: "\F23A"; -} -.fa-yc:before, -.fa-y-combinator:before { - content: "\F23B"; -} -.fa-optin-monster:before { - content: "\F23C"; -} -.fa-opencart:before { - content: "\F23D"; -} -.fa-expeditedssl:before { - content: "\F23E"; -} -.fa-battery-4:before, -.fa-battery-full:before { - content: "\F240"; -} -.fa-battery-3:before, -.fa-battery-three-quarters:before { - content: "\F241"; -} -.fa-battery-2:before, -.fa-battery-half:before { - content: "\F242"; -} -.fa-battery-1:before, -.fa-battery-quarter:before { - content: "\F243"; -} -.fa-battery-0:before, -.fa-battery-empty:before { - content: "\F244"; -} -.fa-mouse-pointer:before { - content: "\F245"; -} -.fa-i-cursor:before { - content: "\F246"; -} -.fa-object-group:before { - content: "\F247"; -} -.fa-object-ungroup:before { - content: "\F248"; -} -.fa-sticky-note:before { - content: "\F249"; -} -.fa-sticky-note-o:before { - content: "\F24A"; -} -.fa-cc-jcb:before { - content: "\F24B"; -} -.fa-cc-diners-club:before { - content: "\F24C"; -} -.fa-clone:before { - content: "\F24D"; -} -.fa-balance-scale:before { - content: "\F24E"; -} -.fa-hourglass-o:before { - content: "\F250"; -} -.fa-hourglass-1:before, -.fa-hourglass-start:before { - content: "\F251"; -} -.fa-hourglass-2:before, -.fa-hourglass-half:before { - content: "\F252"; -} -.fa-hourglass-3:before, -.fa-hourglass-end:before { - content: "\F253"; -} -.fa-hourglass:before { - content: "\F254"; -} -.fa-hand-grab-o:before, -.fa-hand-rock-o:before { - content: "\F255"; -} -.fa-hand-stop-o:before, -.fa-hand-paper-o:before { - content: "\F256"; -} -.fa-hand-scissors-o:before { - content: "\F257"; -} -.fa-hand-lizard-o:before { - content: "\F258"; -} -.fa-hand-spock-o:before { - content: "\F259"; -} -.fa-hand-pointer-o:before { - content: "\F25A"; -} -.fa-hand-peace-o:before { - content: "\F25B"; -} -.fa-trademark:before { - content: "\F25C"; -} -.fa-registered:before { - content: "\F25D"; -} -.fa-creative-commons:before { - content: "\F25E"; -} -.fa-gg:before { - content: "\F260"; -} -.fa-gg-circle:before { - content: "\F261"; -} -.fa-tripadvisor:before { - content: "\F262"; -} -.fa-odnoklassniki:before { - content: "\F263"; -} -.fa-odnoklassniki-square:before { - content: "\F264"; -} -.fa-get-pocket:before { - content: "\F265"; -} -.fa-wikipedia-w:before { - content: "\F266"; -} -.fa-safari:before { - content: "\F267"; -} -.fa-chrome:before { - content: "\F268"; -} -.fa-firefox:before { - content: "\F269"; -} -.fa-opera:before { - content: "\F26A"; -} -.fa-internet-explorer:before { - content: "\F26B"; -} -.fa-tv:before, -.fa-television:before { - content: "\F26C"; -} -.fa-contao:before { - content: "\F26D"; -} -.fa-500px:before { - content: "\F26E"; -} -.fa-amazon:before { - content: "\F270"; -} -.fa-calendar-plus-o:before { - content: "\F271"; -} -.fa-calendar-minus-o:before { - content: "\F272"; -} -.fa-calendar-times-o:before { - content: "\F273"; -} -.fa-calendar-check-o:before { - content: "\F274"; -} -.fa-industry:before { - content: "\F275"; -} -.fa-map-pin:before { - content: "\F276"; -} -.fa-map-signs:before { - content: "\F277"; -} -.fa-map-o:before { - content: "\F278"; -} -.fa-map:before { - content: "\F279"; -} -.fa-commenting:before { - content: "\F27A"; -} -.fa-commenting-o:before { - content: "\F27B"; -} -.fa-houzz:before { - content: "\F27C"; -} -.fa-vimeo:before { - content: "\F27D"; -} -.fa-black-tie:before { - content: "\F27E"; -} -.fa-fonticons:before { - content: "\F280"; -} -.fa-file-new-o:before { - content: "\F016"; -} -.fa-file-new-o:after { - content: "\F067"; - position: relative; - margin-left: -1em; - font-size: 0.5em; -} -.fa-success:before { - content: "\F00C"; -} -.fa-danger:before { - content: "\F06A"; -} -.navbar { - border-width: 0; - box-shadow: inset 0 -10px 10px -12px #333333; - -moz-box-shadow: inset 0 -10px 10px -12px #333333; - -webkit-box-shadow: inset 0 -10px 10px -12px #333333; -} -.navbar-btn-link { - height: 45px; - margin: 0; - border-radius: 0; -} -@media (max-width: 768px) { - .navbar-btn-link { - width: 100%; - text-align: left; - } -} -.navbar-default .badge { - background-color: #ffffff; - color: #656a76; -} -.navbar-inverse .logo { - height: 45px; - width: 150px; - background-color: #3c3c3c; -} -.navbar-inverse .logo-small { - height: 45px; - width: 45px; - background-color: #3c3c3c; -} -.navbar-inverse .badge { - background-color: #ffffff; - color: #3c3c3c; -} -.navbar .navbar-nav > .active > a { - border-bottom-color: #ffffff; -} -.navbar .navbar-nav > .active > a:before { - content: ""; - display: inline-block; - position: absolute; - border: 7px solid transparent; - border-bottom-color: inherit; - top: 31px; - left: 0; - right: 0; - margin: 0 auto; - width: 0; - height: 0; -} -@media (max-width: 768px) { - .navbar .navbar-nav > .active > a:before { - display: none !important; - } -} -.navbar-brand { - cursor: default; - font-size: 1.8em; - background-color: #3c3c3c; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.navbar-nav { - font-size: 12px; -} -.navbar-toggle { - margin-top: 4px; -} -.btn:active { - box-shadow: none; -} -.btn-group.open .dropdown-toggle { - box-shadow: none; -} -/* Small devices (tablets, 768px and smaller) */ -@media (max-width: 768px) { - .btn { - /* Fixes an issue with buttons not respecting the bounds of the screen */ - white-space: normal; - } -} -.text-primary, -.text-primary:hover { - color: #444444; -} -.text-success, -.text-success:hover { - color: #31c471; -} -.text-danger, -.text-danger:hover { - color: #e74c3c; -} -.text-warning, -.text-warning:hover { - color: #f39c12; -} -.text-info, -.text-info:hover { - color: #1f6b7a; -} -table a, -.table a { - text-decoration: underline; -} -table .success, -.table .success, -table .warning, -.table .warning, -table .danger, -.table .danger, -table .info, -.table .info { - color: #ffffff; -} -table .success a, -.table .success a, -table .warning a, -.table .warning a, -table .danger a, -.table .danger a, -table .info a, -.table .info a { - color: #ffffff; -} -table-bordered > thead > tr > th, -.table-bordered > thead > tr > th, -table-bordered > tbody > tr > th, -.table-bordered > tbody > tr > th, -table-bordered > tfoot > tr > th, -.table-bordered > tfoot > tr > th, -table-bordered > thead > tr > td, -.table-bordered > thead > tr > td, -table-bordered > tbody > tr > td, -.table-bordered > tbody > tr > td, -table-bordered > tfoot > tr > td, -.table-bordered > tfoot > tr > td { - border: 1px solid #ecf0f1; -} -.form-control, -input { - border-width: 2px; - box-shadow: none; -} -.form-control:focus, -input:focus { - box-shadow: none; -} -.has-warning .help-block, -.has-warning .control-label, -.has-warning .radio, -.has-warning .checkbox, -.has-warning .radio-inline, -.has-warning .checkbox-inline, -.has-warning .form-control-feedback { - color: #f39c12; -} -.has-warning .form-control, -.has-warning .form-control:focus { - border: 2px solid; - border-color: #f39c12; -} -.has-warning .input-group-addon { - border-color: #f39c12; -} -.has-error .help-block, -.has-error .control-label, -.has-error .radio, -.has-error .checkbox, -.has-error .radio-inline, -.has-error .checkbox-inline, -.has-error .form-control-feedback { - color: #e74c3c; -} -.has-error .form-control, -.has-error .form-control:focus { - border: 2px solid; - border-color: #e74c3c; -} -.has-error .input-group-addon { - border-color: #e74c3c; -} -.has-success .help-block, -.has-success .control-label, -.has-success .radio, -.has-success .checkbox, -.has-success .radio-inline, -.has-success .checkbox-inline, -.has-success .form-control-feedback { - color: #31c471; -} -.has-success .form-control, -.has-success .form-control:focus { - border: solid #31c471; -} -.has-success .input-group-addon { - border-color: #31c471; -} -.nav .open > a, -.nav .open > a:hover, -.nav .open > a:focus { - border-color: transparent; -} -.pager a, -.pager a:hover { - color: #ffffff; -} -.pager .disabled > a, -.pager .disabled > a:hover, -.pager .disabled > a:focus, -.pager .disabled > span { - background-color: rgba(38, 38, 38, 0); -} -.panel { - border-radius: 0; - box-shadow: 0 0 0 rgba(0, 0, 0, 0); -} -.alert a, -.alert .alert-link { - color: #ffffff; - text-decoration: underline; -} -.alert .close { - color: #ffffff; - text-decoration: none; - opacity: 0.4; -} -.alert .close:hover, -.alert .close:focus { - color: #ffffff; - opacity: 1; -} -.progress { - box-shadow: none; -} -.progress .progress-bar { - font-size: 10px; - line-height: 10px; -} -.well { - box-shadow: none; -} -.thumbnail > img, -.thumbnail a > img, -.carousel-inner > .item > img, -.carousel-inner > .item > a > img { - display: block; - max-width: 100%; - height: auto; -} -.btn-group-lg > .btn { - padding: 18px 27px; - font-size: 17px; - line-height: 1.33; - border-radius: 6px; -} -.btn-group-sm > .btn { - padding: 6px 9px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.btn-group-xs > .btn { - padding: 1px 5px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.dl-horizontal dd:before, -.dl-horizontal dd:after, -.container:before, -.container:after, -.container-fluid:before, -.container-fluid:after, -.row:before, -.row:after, -.form-horizontal .form-group:before, -.form-horizontal .form-group:after, -.btn-toolbar:before, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:before, -.btn-group-vertical > .btn-group:after, -.nav:before, -.nav:after, -.navbar:before, -.navbar:after, -.navbar-header:before, -.navbar-header:after, -.navbar-collapse:before, -.navbar-collapse:after, -.pager:before, -.pager:after, -.panel-body:before, -.panel-body:after, -.modal-footer:before, -.modal-footer:after { - content: " "; - display: table; -} -.dl-horizontal dd:after, -.container:after, -.container-fluid:after, -.row:after, -.form-horizontal .form-group:after, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:after, -.nav:after, -.navbar:after, -.navbar-header:after, -.navbar-collapse:after, -.pager:after, -.panel-body:after, -.modal-footer:after { - clear: both; -} -html, -body { - -webkit-box-flex: 1; - -webkit-flex: 1 1 auto; - -ms-flex: 1 1 auto; - flex: 1 1 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - height: 100%; - margin: 0px; -} -html > *, -body > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -label > small { - font-weight: normal; -} -button { - display: inline-block; - margin-bottom: 0; - font-weight: normal; - text-align: center; - vertical-align: middle; - -ms-touch-action: manipulation; - touch-action: manipulation; - cursor: pointer; - background-image: none; - border: 1px solid transparent; - white-space: nowrap; - padding: 5px 15px; - font-size: 13px; - line-height: 1.42857143; - border-radius: 4px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -button:focus, -button:active:focus, -button.active:focus, -button.focus, -button:active.focus, -button.active.focus { - outline: thin dotted; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} -button:hover, -button:focus, -button.focus { - color: #ffffff; - text-decoration: none; -} -button:active, -button.active { - outline: 0; - background-image: none; - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} -button.disabled, -button[disabled], -fieldset[disabled] button { - cursor: not-allowed; - opacity: 0.65; - filter: alpha(opacity=65); - box-shadow: none; -} -abutton.disabled, -fieldset[disabled] abutton { - pointer-events: none; -} -.small { - font-size: 0.9em !important; -} -.smaller { - font-size: 0.8em !important; -} -.smallest { - font-size: 0.7em !important; -} -.text-color-primary { - color: #444444; -} -.text-color-info { - color: #1f6b7a; -} -.text-color-success { - color: #31c471; -} -.text-color-warning { - color: #f39c12; -} -.text-color-danger { - color: #e74c3c; -} -.text-monospace { - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; -} -code { - word-break: break-all; - word-wrap: break-word; -} -ul.navbar-inline li { - display: inline; -} -.tooltip { - font-size: 8pt; - font-weight: normal; - opacity: 90%; -} -.tooltip-inner { - word-break: normal; - word-wrap: break-word; - white-space: normal; -} -.content { - -webkit-box-flex: 1; - -webkit-flex: 1 1 auto; - -ms-flex: 1 1 auto; - flex: 1 1 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - position: relative; - z-index: 0; -} -.content > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -.content > nav { - position: relative; - z-index: 1; -} -.content > nav .navbar-right { - margin-right: 0; -} -.application { - -webkit-box-flex: 1; - -webkit-flex: 1 0 auto; - -ms-flex: 1 0 auto; - flex: 1 0 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - position: relative; - z-index: 0; -} -.application > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -.top-fixed { - position: fixed; - bottom: 0px; -} -.checkbox label { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-align: center; - -webkit-align-items: center; - -ms-flex-align: center; - align-items: center; - padding-left: 0; -} -.checkbox label input[type="checkbox"] { - float: none; - margin: 0 4px; - position: static; -} -notifications { - z-index: 1; -} -.navbar { - margin-bottom: 0px!important; -} -a { - cursor: default; -} -[ng-click], -[clip-copy], -[href], -[confirm-click] { - cursor: pointer; -} -.app-container > * { - position: relative; - z-index: 0; -} -.app-container > config { - z-index: 1; -} -.app-container > nav, -.app-container > navbar { - z-index: 2 !important; -} -.nav-condensed > li > a { - padding-top: 2px; - padding-bottom: 2px; -} -.navbar > .container-fluid > .navbar-nav:not(.pull-right):first-child, -.navbar > .container-fluid > .navbar-form:not(.pull-right):first-child { - margin-left: -15px; -} -.navbtn { - color: #ffffff; - background-color: #656a76; - border-color: #4d515b; -} -.navbtn:focus, -.navbtn.focus { - color: #ffffff; - background-color: #4d515b; - border-color: #131416; -} -.navbtn:hover { - color: #ffffff; - background-color: #4d515b; - border-color: #31343a; -} -.navbtn:active, -.navbtn.active, -.open > .dropdown-toggle.navbtn { - color: #ffffff; - background-color: #4d515b; - border-color: #31343a; -} -.navbtn:active:hover, -.navbtn.active:hover, -.open > .dropdown-toggle.navbtn:hover, -.navbtn:active:focus, -.navbtn.active:focus, -.open > .dropdown-toggle.navbtn:focus, -.navbtn:active.focus, -.navbtn.active.focus, -.open > .dropdown-toggle.navbtn.focus { - color: #ffffff; - background-color: #3d4047; - border-color: #131416; -} -.navbtn:active, -.navbtn.active, -.open > .dropdown-toggle.navbtn { - background-image: none; -} -.navbtn.disabled, -.navbtn[disabled], -fieldset[disabled] .navbtn, -.navbtn.disabled:hover, -.navbtn[disabled]:hover, -fieldset[disabled] .navbtn:hover, -.navbtn.disabled:focus, -.navbtn[disabled]:focus, -fieldset[disabled] .navbtn:focus, -.navbtn.disabled.focus, -.navbtn[disabled].focus, -fieldset[disabled] .navbtn.focus, -.navbtn.disabled:active, -.navbtn[disabled]:active, -fieldset[disabled] .navbtn:active, -.navbtn.disabled.active, -.navbtn[disabled].active, -fieldset[disabled] .navbtn.active { - background-color: #656a76; - border-color: #4d515b; -} -.navbtn .badge { - color: #656a76; - background-color: #ffffff; -} -.navbtn-inverse { - color: #ffffff; - background-color: #656a76; - border-color: #4d515b; -} -.navbtn-inverse:focus, -.navbtn-inverse.focus { - color: #ffffff; - background-color: #4d515b; - border-color: #131416; -} -.navbtn-inverse:hover { - color: #ffffff; - background-color: #4d515b; - border-color: #31343a; -} -.navbtn-inverse:active, -.navbtn-inverse.active, -.open > .dropdown-toggle.navbtn-inverse { - color: #ffffff; - background-color: #4d515b; - border-color: #31343a; -} -.navbtn-inverse:active:hover, -.navbtn-inverse.active:hover, -.open > .dropdown-toggle.navbtn-inverse:hover, -.navbtn-inverse:active:focus, -.navbtn-inverse.active:focus, -.open > .dropdown-toggle.navbtn-inverse:focus, -.navbtn-inverse:active.focus, -.navbtn-inverse.active.focus, -.open > .dropdown-toggle.navbtn-inverse.focus { - color: #ffffff; - background-color: #3d4047; - border-color: #131416; -} -.navbtn-inverse:active, -.navbtn-inverse.active, -.open > .dropdown-toggle.navbtn-inverse { - background-image: none; -} -.navbtn-inverse.disabled, -.navbtn-inverse[disabled], -fieldset[disabled] .navbtn-inverse, -.navbtn-inverse.disabled:hover, -.navbtn-inverse[disabled]:hover, -fieldset[disabled] .navbtn-inverse:hover, -.navbtn-inverse.disabled:focus, -.navbtn-inverse[disabled]:focus, -fieldset[disabled] .navbtn-inverse:focus, -.navbtn-inverse.disabled.focus, -.navbtn-inverse[disabled].focus, -fieldset[disabled] .navbtn-inverse.focus, -.navbtn-inverse.disabled:active, -.navbtn-inverse[disabled]:active, -fieldset[disabled] .navbtn-inverse:active, -.navbtn-inverse.disabled.active, -.navbtn-inverse[disabled].active, -fieldset[disabled] .navbtn-inverse.active { - background-color: #656a76; - border-color: #4d515b; -} -.navbtn-inverse .badge { - color: #656a76; - background-color: #ffffff; -} -.navbar-static-top .navbar-right { - font-size: 12px; -} -.navbar-static-top .navbar-right .loading-spinner { - color: #ffffff; - vertical-align: middle; -} -.navbar-timepicker > li > a { - padding-left: 7px !important; - padding-right: 7px !important; -} -.navbar-timepicker-time-desc > .fa-clock-o { - padding-right: 5px; -} -.navbar-timepicker .fa { - font-size: 16px; - vertical-align: middle; -} -kbn-info i { - cursor: help; -} -.kbn-timepicker .btn-default { - background: transparent; - color: #444444; - border: 0px; - box-shadow: none; - text-shadow: none; -} -.kbn-timepicker .btn-info { - color: #ffffff; - background-color: #1f6b7a; - border-color: #1f6b7a; - text-shadow: none; -} -.kbn-timepicker .btn-info:focus, -.kbn-timepicker .btn-info.focus { - color: #ffffff; - background-color: #154751; - border-color: #051214; -} -.kbn-timepicker .btn-info:hover { - color: #ffffff; - background-color: #154751; - border-color: #134049; -} -.kbn-timepicker .btn-info:active, -.kbn-timepicker .btn-info.active, -.open > .dropdown-toggle.kbn-timepicker .btn-info { - color: #ffffff; - background-color: #154751; - border-color: #134049; -} -.kbn-timepicker .btn-info:active:hover, -.kbn-timepicker .btn-info.active:hover, -.open > .dropdown-toggle.kbn-timepicker .btn-info:hover, -.kbn-timepicker .btn-info:active:focus, -.kbn-timepicker .btn-info.active:focus, -.open > .dropdown-toggle.kbn-timepicker .btn-info:focus, -.kbn-timepicker .btn-info:active.focus, -.kbn-timepicker .btn-info.active.focus, -.open > .dropdown-toggle.kbn-timepicker .btn-info.focus { - color: #ffffff; - background-color: #0d2e35; - border-color: #051214; -} -.kbn-timepicker .btn-info:active, -.kbn-timepicker .btn-info.active, -.open > .dropdown-toggle.kbn-timepicker .btn-info { - background-image: none; -} -.kbn-timepicker .btn-info.disabled, -.kbn-timepicker .btn-info[disabled], -fieldset[disabled] .kbn-timepicker .btn-info, -.kbn-timepicker .btn-info.disabled:hover, -.kbn-timepicker .btn-info[disabled]:hover, -fieldset[disabled] .kbn-timepicker .btn-info:hover, -.kbn-timepicker .btn-info.disabled:focus, -.kbn-timepicker .btn-info[disabled]:focus, -fieldset[disabled] .kbn-timepicker .btn-info:focus, -.kbn-timepicker .btn-info.disabled.focus, -.kbn-timepicker .btn-info[disabled].focus, -fieldset[disabled] .kbn-timepicker .btn-info.focus, -.kbn-timepicker .btn-info.disabled:active, -.kbn-timepicker .btn-info[disabled]:active, -fieldset[disabled] .kbn-timepicker .btn-info:active, -.kbn-timepicker .btn-info.disabled.active, -.kbn-timepicker .btn-info[disabled].active, -fieldset[disabled] .kbn-timepicker .btn-info.active { - background-color: #1f6b7a; - border-color: #1f6b7a; -} -.kbn-timepicker .btn-info .badge { - color: #1f6b7a; - background-color: #ffffff; -} -.kbn-timepicker .btn-info .text-info { - color: #ffffff; -} -.kbn-timepicker .refresh-interval { - padding: 0.2em 0.4em; - border-radius: 3px; -} -.kbn-timepicker .refresh-interval-active { - background-color: #1f6b7a; - color: #ffffff; -} -kbn-table, -.kbn-table { - font-size: 12px; -} -kbn-table th, -.kbn-table th { - white-space: nowrap; - padding-right: 10px; -} -kbn-table th .table-header-move, -.kbn-table th .table-header-move, -kbn-table th .table-header-sortchange, -.kbn-table th .table-header-sortchange { - visibility: hidden; -} -kbn-table th .fa, -.kbn-table th .fa { - font-size: 1.1em; -} -kbn-table th:hover .table-header-move, -.kbn-table th:hover .table-header-move, -kbn-table th:hover .table-header-sortchange, -.kbn-table th:hover .table-header-sortchange { - visibility: visible; -} -table td .fa { - line-height: 1.42857143; -} -saved-object-finder .form-group { - margin-bottom: 0; -} -saved-object-finder .form-group input { - border-bottom-right-radius: 0; - border-bottom-left-radius: 0; -} -saved-object-finder .list-group-item a { - color: #1f6b7a !important; -} -saved-object-finder .list-group-item a i { - color: #154751 !important; -} -saved-object-finder .list-group-item:first-child { - border-top-right-radius: 0 !important; - border-top-left-radius: 0 !important; -} -saved-object-finder .list-group-item.list-group-no-results p { - margin-bottom: 0 !important; -} -saved-object-finder div.finder-form { - position: relative; -} -saved-object-finder div.finder-form-options { - -webkit-box-flex: 1; - -webkit-flex: 1 1 auto; - -ms-flex: 1 1 auto; - flex: 1 1 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-box-pack: end; - -webkit-justify-content: flex-end; - -ms-flex-pack: end; - justify-content: flex-end; -} -saved-object-finder div.finder-form-options > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -saved-object-finder span.finder-hit-count { - position: absolute; - right: 10px; - top: 25px; - font-size: 0.85em; -} -saved-object-finder .finder-options { - max-height: 300px; - overflow: auto; - padding: 0; - border-top-right-radius: 0; - border-top-left-radius: 0; -} -saved-object-finder .finder-options > * { - padding: 5px 15px; - margin: 0; -} -saved-object-finder .finder-options > li { - margin-top: -ceil(2.5px); -} -saved-object-finder .finder-options > li:first-child { - margin: 0; -} -saved-object-finder .finder-options > li.active { - background-color: #444444; - color: #ffffff; -} -saved-object-finder .finder-options > li.active a { - color: #ffffff; -} -.config saved-object-finder .finder-options { - margin-bottom: 0; - background: #ffffff; -} -.media-object { - width: 65px; - height: 65px; -} -.input-datetime-format { - font-size: 12px; - color: #b4bcc2; - padding: 5px 15px; -} -button[disabled] { - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.form-control[disabled], -.form-control[readonly], -fieldset[disabled] .form-control { - cursor: default; - opacity: .8; -} -.fatal-body { - white-space: pre-wrap; -} -input.ng-invalid.ng-dirty, -input.ng-invalid.ng-touched, -textarea.ng-invalid.ng-dirty, -textarea.ng-invalid.ng-touched, -select.ng-invalid.ng-dirty, -select.ng-invalid.ng-touched { - border-color: #e74c3c !important; -} -input[type="radio"][disabled], -input[type="checkbox"][disabled], -.radio[disabled], -.radio-inline[disabled], -.checkbox[disabled], -.checkbox-inline[disabled], -fieldset[disabled] input[type="radio"], -fieldset[disabled] input[type="checkbox"], -fieldset[disabled] .radio, -fieldset[disabled] .radio-inline, -fieldset[disabled] .checkbox, -fieldset[disabled] .checkbox-inline { - cursor: default; - opacity: .8; -} -textarea { - resize: vertical; -} -.field-collapse-toggle { - color: #999999; - margin-left: 10px !important; -} -style-compile { - display: none; -} -.tooltip-inner { - white-space: pre-wrap !important; -} -filter-bar .confirm { - padding: 8px 10px 4px; - background: #ecf0f1; - border-bottom: 1px solid; - border-bottom-color: #cccccc; -} -filter-bar .confirm ul { - margin-bottom: 0px; -} -filter-bar .confirm li { - display: inline-block; -} -filter-bar .confirm li:first-child { - font-weight: bold; - font-size: 1.2em; -} -filter-bar .confirm li button { - font-size: 0.9em; - padding: 2px 8px; -} -filter-bar .confirm .filter { - position: relative; - display: inline-block; - text-align: center; - min-width: calc(5*(1.414em + 13px)); - font-size: 12px; - background-color: #b4bcc2; - color: #333333; - margin-right: 4px; - margin-bottom: 4px; - max-width: 100%; - padding: 4px 8px; - border-radius: 12px; -} -filter-bar .bar { - padding: 6px 6px 4px 6px; - background: #ecf0f1; - border-bottom: 1px solid; - border-bottom-color: #cccccc; -} -filter-bar .bar-condensed { - padding: 2px 6px 0px 6px !important; - font-size: 0.9em; - background: #dde4e6; -} -filter-bar .bar .ace_editor { - height: 175px; - margin: 15px 0; -} -filter-bar .bar .filter-edit-alias { - margin-top: 15px; -} -filter-bar .bar .filter-link { - position: relative; - display: inline-block; - border: 4px solid transparent; - margin-bottom: 4px; -} -filter-bar .bar .filter-description { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} -filter-bar .bar .filter { - position: relative; - display: inline-block; - text-align: center; - min-width: calc(5*(1.414em + 13px)); - font-size: 12px; - background-color: #569f76; - color: #ffffff; - margin-right: 4px; - margin-bottom: 4px; - max-width: 100%; - padding: 4px 8px; - border-radius: 12px; -} -filter-bar .bar .filter:hover > .filter-actions { - display: block; -} -filter-bar .bar .filter:hover > .filter-description { - opacity: 0.15; - background: transparent; - overflow: hidden; -} -filter-bar .bar .filter > .filter-actions { - font-size: 1.1em; - line-height: 1.4em; - position: absolute; - padding: 4px 8px; - top: 0; - left: 0; - width: 100%; - display: none; - text-align: center; - white-space: nowrap; -} -filter-bar .bar .filter > .filter-actions > * { - border-right: 1px solid rgba(255, 255, 255, 0.4); - padding-right: 0; - margin-right: 5px; -} -filter-bar .bar .filter > .filter-actions > *:last-child { - border-right: 0; - padding-right: 0; - margin-right: 0; -} -filter-bar .bar .filter > .filter-actions > * .unpinned { - opacity: 0.7; - filter: alpha(opacity=70); -} -filter-bar .bar .filter.negate { - background-color: #c6675d; -} -filter-bar .bar .filter a { - color: #ffffff; -} -filter-bar .bar .filter.disabled { - opacity: 0.6; - background-image: -webkit-repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 255, 255, 0.3) 10px, rgba(255, 255, 255, 0.3) 20px); - background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 255, 255, 0.3) 10px, rgba(255, 255, 255, 0.3) 20px); -} -filter-bar .bar .filter.disabled:hover span { - text-decoration: none; -} -.cell-hover { - background-color: white; -} -.cell-hover-show { - visibility: hidden; -} -.cell-hover:hover { - background-color: #ecf0f1; - cursor: cell; -} -.cell-hover:hover .cell-hover-show { - visibility: visible; -} -mark, -.mark { - background-color: #fce571; -} -fieldset { - margin: 15px; - padding: 15px; - border: 1px solid #ecf0f1; - border-radius: 4px; -} -[fixed-scroll] { - overflow-x: auto; - padding-bottom: 0px; -} -[fixed-scroll] + .fixed-scroll-scroller { - position: fixed; - bottom: 0px; - overflow-x: auto; - overflow-y: hidden; -} -.list-group .list-group-item.active, -.list-group .list-group-item.active:hover, -.list-group .list-group-item.active:focus { - background-color: #ecf0f1; - cursor: default; -} -.bs-callout-primary { - display: block; - margin: 20px 0; - padding: 15px 30px 15px 15px; - border-left: 5px solid #444444; - background-color: #b7b7b7; -} -.bs-callout-primary h1, -.bs-callout-primary h2, -.bs-callout-primary h3, -.bs-callout-primary h4, -.bs-callout-primary h5, -.bs-callout-primary h6 { - margin-top: 0; - color: #444444; -} -.bs-callout-primary p:last-child { - margin-bottom: 0; -} -.bs-callout-primary code, -.bs-callout-primary .highlight { - background-color: #fff; -} -.bs-callout-danger { - display: block; - margin: 20px 0; - padding: 15px 30px 15px 15px; - border-left: 5px solid #e74c3c; - background-color: #fbdedb; -} -.bs-callout-danger h1, -.bs-callout-danger h2, -.bs-callout-danger h3, -.bs-callout-danger h4, -.bs-callout-danger h5, -.bs-callout-danger h6 { - margin-top: 0; - color: #e74c3c; -} -.bs-callout-danger p:last-child { - margin-bottom: 0; -} -.bs-callout-danger code, -.bs-callout-danger .highlight { - background-color: #fff; -} -.bs-callout-warning { - display: block; - margin: 20px 0; - padding: 15px 30px 15px 15px; - border-left: 5px solid #f39c12; - background-color: #fad9a4; -} -.bs-callout-warning h1, -.bs-callout-warning h2, -.bs-callout-warning h3, -.bs-callout-warning h4, -.bs-callout-warning h5, -.bs-callout-warning h6 { - margin-top: 0; - color: #f39c12; -} -.bs-callout-warning p:last-child { - margin-bottom: 0; -} -.bs-callout-warning code, -.bs-callout-warning .highlight { - background-color: #fff; -} -.bs-callout-info { - display: block; - margin: 20px 0; - padding: 15px 30px 15px 15px; - border-left: 5px solid #1f6b7a; - background-color: #71c9db; -} -.bs-callout-info h1, -.bs-callout-info h2, -.bs-callout-info h3, -.bs-callout-info h4, -.bs-callout-info h5, -.bs-callout-info h6 { - margin-top: 0; - color: #1f6b7a; -} -.bs-callout-info p:last-child { - margin-bottom: 0; -} -.bs-callout-info code, -.bs-callout-info .highlight { - background-color: #fff; -} -.bs-callout-success { - display: block; - margin: 20px 0; - padding: 15px 30px 15px 15px; - border-left: 5px solid #31c471; - background-color: #baeed0; -} -.bs-callout-success h1, -.bs-callout-success h2, -.bs-callout-success h3, -.bs-callout-success h4, -.bs-callout-success h5, -.bs-callout-success h6 { - margin-top: 0; - color: #31c471; -} -.bs-callout-success p:last-child { - margin-bottom: 0; -} -.bs-callout-success code, -.bs-callout-success .highlight { - background-color: #fff; -} -.thumbnail > img, -.thumbnail a > img, -.carousel-inner > .item > img, -.carousel-inner > .item > a > img { - display: block; - max-width: 100%; - height: auto; -} -.btn-group-lg > .btn { - padding: 18px 27px; - font-size: 17px; - line-height: 1.33; - border-radius: 6px; -} -.btn-group-sm > .btn { - padding: 6px 9px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.btn-group-xs > .btn { - padding: 1px 5px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.dl-horizontal dd:before, -.dl-horizontal dd:after, -.container:before, -.container:after, -.container-fluid:before, -.container-fluid:after, -.row:before, -.row:after, -.form-horizontal .form-group:before, -.form-horizontal .form-group:after, -.btn-toolbar:before, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:before, -.btn-group-vertical > .btn-group:after, -.nav:before, -.nav:after, -.navbar:before, -.navbar:after, -.navbar-header:before, -.navbar-header:after, -.navbar-collapse:before, -.navbar-collapse:after, -.pager:before, -.pager:after, -.panel-body:before, -.panel-body:after, -.modal-footer:before, -.modal-footer:after, -.config:before, -.config:after { - content: " "; - display: table; -} -.dl-horizontal dd:after, -.container:after, -.container-fluid:after, -.row:after, -.form-horizontal .form-group:after, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:after, -.nav:after, -.navbar:after, -.navbar-header:after, -.navbar-collapse:after, -.pager:after, -.panel-body:after, -.modal-footer:after, -.config:after { - clear: both; -} -.config { - position: relative; - min-height: 45px; - margin-bottom: 0px; - border: 1px solid transparent; - border-width: 0; - box-shadow: inset 0 -10px 10px -12px #333333; - -moz-box-shadow: inset 0 -10px 10px -12px #333333; - -webkit-box-shadow: inset 0 -10px 10px -12px #333333; - background-color: #656a76; - border-color: #4d515b; - z-index: 1000; - border-width: 0 0 1px; - border-bottom: 1px solid; - border-bottom-color: #e6e6e6; -} -@media (min-width: 768px) { - .config { - border-radius: 4px; - } -} -.config-btn-link { - height: 45px; - margin: 0; - border-radius: 0; -} -@media (max-width: 768px) { - .config-btn-link { - width: 100%; - text-align: left; - } -} -.config-default .badge { - background-color: #ffffff; - color: #656a76; -} -.config-inverse .logo { - height: 45px; - width: 252px; - background-color: #3c3c3c; -} -.config-inverse .logo-small { - height: 45px; - width: 45px; - background-color: #3c3c3c; -} -.config-inverse .badge { - background-color: #ffffff; - color: #3c3c3c; -} -.config .navbar-nav > .active > a { - border-bottom-color: #ffffff; -} -.config .navbar-nav > .active > a:before { - content: ""; - display: inline-block; - position: absolute; - border: 7px solid transparent; - border-bottom-color: inherit; - top: 31px; - left: 0; - right: 0; - margin: 0 auto; - width: 0; - height: 0; -} -@media (max-width: 768px) { - .config .navbar-nav > .active > a:before { - display: none !important; - } -} -.config-brand { - cursor: default; - font-size: 1.8em; - background-color: #3c3c3c; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -.config-nav { - font-size: 12px; -} -.config-toggle { - margin-top: 4px; -} -.config .navbar-brand { - color: #ecf0f1; -} -.config .navbar-brand:hover, -.config .navbar-brand:focus { - color: #ffffff; - background-color: transparent; -} -.config .navbar-text { - color: #ffffff; -} -.config .navbar-nav > li > a { - color: #ecf0f1; -} -.config .navbar-nav > li > a:hover, -.config .navbar-nav > li > a:focus { - color: #ffffff; - background-color: transparent; -} -.config .navbar-nav > .active > a, -.config .navbar-nav > .active > a:hover, -.config .navbar-nav > .active > a:focus { - color: #ffffff; - background-color: #4d515b; -} -.config .navbar-nav > .disabled > a, -.config .navbar-nav > .disabled > a:hover, -.config .navbar-nav > .disabled > a:focus { - color: #cccccc; - background-color: transparent; -} -.config .navbar-toggle { - border-color: #4d515b; -} -.config .navbar-toggle:hover, -.config .navbar-toggle:focus { - background-color: #4d515b; -} -.config .navbar-toggle .icon-bar { - background-color: #ffffff; -} -.config .navbar-collapse, -.config .navbar-form { - border-color: #4d515b; -} -.config .navbar-nav > .open > a, -.config .navbar-nav > .open > a:hover, -.config .navbar-nav > .open > a:focus { - background-color: #4d515b; - color: #ffffff; -} -@media (max-width: 767px) { - .config .navbar-nav .open .dropdown-menu > li > a { - color: #ecf0f1; - } - .config .navbar-nav .open .dropdown-menu > li > a:hover, - .config .navbar-nav .open .dropdown-menu > li > a:focus { - color: #ffffff; - background-color: transparent; - } - .config .navbar-nav .open .dropdown-menu > .active > a, - .config .navbar-nav .open .dropdown-menu > .active > a:hover, - .config .navbar-nav .open .dropdown-menu > .active > a:focus { - color: #ffffff; - background-color: #4d515b; - } - .config .navbar-nav .open .dropdown-menu > .disabled > a, - .config .navbar-nav .open .dropdown-menu > .disabled > a:hover, - .config .navbar-nav .open .dropdown-menu > .disabled > a:focus { - color: #cccccc; - background-color: transparent; - } -} -.config .navbar-link { - color: #ecf0f1; -} -.config .navbar-link:hover { - color: #ffffff; -} -.config .btn-link { - color: #ecf0f1; -} -.config .btn-link:hover, -.config .btn-link:focus { - color: #ffffff; -} -.config .btn-link[disabled]:hover, -fieldset[disabled] .config .btn-link:hover, -.config .btn-link[disabled]:focus, -fieldset[disabled] .config .btn-link:focus { - color: #cccccc; -} -@media (min-width: 768px) { - .config { - border-radius: 0; - } -} -.config .config-close { - width: 100%; - background-color: #ecf0f1; - border-radius: 0; - box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 5px rgba(0, 0, 0, 0.075); - text-align: center; -} -.config .container-fluid { - padding: 10px 10px; - background-color: #ffffff; -} -.control-group { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-flex-wrap: wrap; - -ms-flex-wrap: wrap; - flex-wrap: wrap; - -webkit-box-align: stretch; - -webkit-align-items: stretch; - -ms-flex-align: stretch; - align-items: stretch; - padding: 5px 15px; - /*** - * components - ***/ -} -.control-group > * { - padding-right: 15px; - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; -} -.control-group > *:last-child { - padding-right: 0; -} -.control-group button { - padding: 5px 15px; - font-size: 13px; - color: #1f6b7a; - background-color: inherit; -} -.control-group button:hover { - color: #ecf0f1; - background-color: #5e5e5e; -} -.control-group button .active, -.control-group button:active, -.control-group button:focus { - color: #b4bcc2; - background-color: #5e5e5e; -} -.control-group button[disabled] { - color: #b4bcc2; - background-color: transparent; -} -.control-group button:focus { - outline-offset: -4px; -} -.control-group .button-group, -.control-group .inline-form .input-group { - margin-bottom: 0px; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; -} -.control-group .button-group > *, -.control-group .inline-form .input-group > * { - border-radius: 0; -} -.control-group .button-group > :first-child, -.control-group .inline-form .input-group > :first-child { - border-bottom-left-radius: 4px; - border-top-left-radius: 4px; -} -.control-group .button-group > :last-child, -.control-group .inline-form .input-group > :last-child { - border-bottom-right-radius: 4px; - border-top-right-radius: 4px; -} -.control-group .inline-form { - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; -} -.control-group .inline-form > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -.control-group .inline-form > .typeahead { - -webkit-box-flex: 1; - -webkit-flex: 1 1 auto; - -ms-flex: 1 1 auto; - flex: 1 1 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; -} -.control-group .inline-form > .typeahead > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -.control-group .inline-form > .typeahead > .input-group { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-flex: 1; - -webkit-flex: 1 0 auto; - -ms-flex: 1 0 auto; - flex: 1 0 auto; -} -.control-group .inline-form > .typeahead > .input-group > * { - float: none; - height: auto; - width: auto; - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; -} -.control-group .inline-form > .typeahead > .input-group input[type="text"] { - -webkit-box-flex: 1; - -webkit-flex: 1 1 100%; - -ms-flex: 1 1 100%; - flex: 1 1 100%; -} -.control-group > .fill { - -webkit-box-flex: 1; - -webkit-flex: 1 1 1%; - -ms-flex: 1 1 1%; - flex: 1 1 1%; -} -.nav-controls .column { - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; -} -.tab-dashboard.theme-dark { - color: #cecece; - background-color: #1e1b1e; -} -.tab-dashboard.theme-dark a { - color: #b7e2ea; -} -.tab-dashboard.theme-dark a:hover, -.tab-dashboard.theme-dark a:focus { - color: #def2f6; -} -.tab-dashboard.theme-dark .form-control { - color: #cecece; - background-color: #444444; - border-color: #666666; -} -.tab-dashboard.theme-dark .form-control[disabled], -.tab-dashboard.theme-dark .form-control[readonly], -fieldset[disabled] .tab-dashboard.theme-dark .form-control { - background-color: #333333; -} -.tab-dashboard.theme-dark .panel { - background-color: #343434; -} -.tab-dashboard.theme-dark .table > thead > tr > th, -.tab-dashboard.theme-dark .table > tbody > tr > th, -.tab-dashboard.theme-dark .table > tfoot > tr > th, -.tab-dashboard.theme-dark .table > thead > tr > td, -.tab-dashboard.theme-dark .table > tbody > tr > td, -.tab-dashboard.theme-dark .table > tfoot > tr > td { - border-top-color: #5c5c5c; -} -.tab-dashboard.theme-dark .table > thead > tr > th { - border-bottom-color: #5c5c5c; -} -.tab-dashboard.theme-dark .table > tbody + tbody { - border-top-color: #5c5c5c; -} -.tab-dashboard.theme-dark .table .table { - background-color: transparent; -} -.tab-dashboard.theme-dark table th i.fa-sort { - color: #666666; -} -.tab-dashboard.theme-dark table th i.fa-sort-asc, -.tab-dashboard.theme-dark table th i.fa-sort-down { - color: #bbbbbb; -} -.tab-dashboard.theme-dark table th i.fa-sort-desc, -.tab-dashboard.theme-dark table th i.fa-sort-up { - color: #bbbbbb; -} -.tab-dashboard.theme-dark .btn:hover, -.tab-dashboard.theme-dark .btn:focus, -.tab-dashboard.theme-dark .btn.focus { - color: #ffffff; -} -.tab-dashboard.theme-dark .btn .findme { - font-weight: bold; -} -.tab-dashboard.theme-dark .btn-default { - color: #ffffff; - background-color: #777777; - border-color: #777777; -} -.tab-dashboard.theme-dark .btn-default:focus, -.tab-dashboard.theme-dark .btn-default.focus { - color: #ffffff; - background-color: #5e5e5e; - border-color: #373737; -} -.tab-dashboard.theme-dark .btn-default:hover { - color: #ffffff; - background-color: #5e5e5e; - border-color: #585858; -} -.tab-dashboard.theme-dark .btn-default:active, -.tab-dashboard.theme-dark .btn-default.active, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default { - color: #ffffff; - background-color: #5e5e5e; - border-color: #585858; -} -.tab-dashboard.theme-dark .btn-default:active:hover, -.tab-dashboard.theme-dark .btn-default.active:hover, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default:hover, -.tab-dashboard.theme-dark .btn-default:active:focus, -.tab-dashboard.theme-dark .btn-default.active:focus, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default:focus, -.tab-dashboard.theme-dark .btn-default:active.focus, -.tab-dashboard.theme-dark .btn-default.active.focus, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default.focus { - color: #ffffff; - background-color: #4c4c4c; - border-color: #373737; -} -.tab-dashboard.theme-dark .btn-default:active, -.tab-dashboard.theme-dark .btn-default.active, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-default { - background-image: none; -} -.tab-dashboard.theme-dark .btn-default.disabled, -.tab-dashboard.theme-dark .btn-default[disabled], -fieldset[disabled] .tab-dashboard.theme-dark .btn-default, -.tab-dashboard.theme-dark .btn-default.disabled:hover, -.tab-dashboard.theme-dark .btn-default[disabled]:hover, -fieldset[disabled] .tab-dashboard.theme-dark .btn-default:hover, -.tab-dashboard.theme-dark .btn-default.disabled:focus, -.tab-dashboard.theme-dark .btn-default[disabled]:focus, -fieldset[disabled] .tab-dashboard.theme-dark .btn-default:focus, -.tab-dashboard.theme-dark .btn-default.disabled.focus, -.tab-dashboard.theme-dark .btn-default[disabled].focus, -fieldset[disabled] .tab-dashboard.theme-dark .btn-default.focus, -.tab-dashboard.theme-dark .btn-default.disabled:active, -.tab-dashboard.theme-dark .btn-default[disabled]:active, -fieldset[disabled] .tab-dashboard.theme-dark .btn-default:active, -.tab-dashboard.theme-dark .btn-default.disabled.active, -.tab-dashboard.theme-dark .btn-default[disabled].active, -fieldset[disabled] .tab-dashboard.theme-dark .btn-default.active { - background-color: #777777; - border-color: #777777; -} -.tab-dashboard.theme-dark .btn-default .badge { - color: #777777; - background-color: #ffffff; -} -.tab-dashboard.theme-dark .btn-primary { - color: #ffffff; - background-color: #777777; - border-color: #777777; -} -.tab-dashboard.theme-dark .btn-primary:focus, -.tab-dashboard.theme-dark .btn-primary.focus { - color: #ffffff; - background-color: #5e5e5e; - border-color: #373737; -} -.tab-dashboard.theme-dark .btn-primary:hover { - color: #ffffff; - background-color: #5e5e5e; - border-color: #585858; -} -.tab-dashboard.theme-dark .btn-primary:active, -.tab-dashboard.theme-dark .btn-primary.active, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary { - color: #ffffff; - background-color: #5e5e5e; - border-color: #585858; -} -.tab-dashboard.theme-dark .btn-primary:active:hover, -.tab-dashboard.theme-dark .btn-primary.active:hover, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary:hover, -.tab-dashboard.theme-dark .btn-primary:active:focus, -.tab-dashboard.theme-dark .btn-primary.active:focus, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary:focus, -.tab-dashboard.theme-dark .btn-primary:active.focus, -.tab-dashboard.theme-dark .btn-primary.active.focus, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary.focus { - color: #ffffff; - background-color: #4c4c4c; - border-color: #373737; -} -.tab-dashboard.theme-dark .btn-primary:active, -.tab-dashboard.theme-dark .btn-primary.active, -.open > .dropdown-toggle.tab-dashboard.theme-dark .btn-primary { - background-image: none; -} -.tab-dashboard.theme-dark .btn-primary.disabled, -.tab-dashboard.theme-dark .btn-primary[disabled], -fieldset[disabled] .tab-dashboard.theme-dark .btn-primary, -.tab-dashboard.theme-dark .btn-primary.disabled:hover, -.tab-dashboard.theme-dark .btn-primary[disabled]:hover, -fieldset[disabled] .tab-dashboard.theme-dark .btn-primary:hover, -.tab-dashboard.theme-dark .btn-primary.disabled:focus, -.tab-dashboard.theme-dark .btn-primary[disabled]:focus, -fieldset[disabled] .tab-dashboard.theme-dark .btn-primary:focus, -.tab-dashboard.theme-dark .btn-primary.disabled.focus, -.tab-dashboard.theme-dark .btn-primary[disabled].focus, -fieldset[disabled] .tab-dashboard.theme-dark .btn-primary.focus, -.tab-dashboard.theme-dark .btn-primary.disabled:active, -.tab-dashboard.theme-dark .btn-primary[disabled]:active, -fieldset[disabled] .tab-dashboard.theme-dark .btn-primary:active, -.tab-dashboard.theme-dark .btn-primary.disabled.active, -.tab-dashboard.theme-dark .btn-primary[disabled].active, -fieldset[disabled] .tab-dashboard.theme-dark .btn-primary.active { - background-color: #777777; - border-color: #777777; -} -.tab-dashboard.theme-dark .btn-primary .badge { - color: #777777; - background-color: #ffffff; -} -.tab-dashboard.theme-dark .list-group-item { - background-color: #333333; - border-color: #777777; -} -.tab-dashboard.theme-dark a.list-group-item, -.tab-dashboard.theme-dark button.list-group-item { - color: #555555; -} -.tab-dashboard.theme-dark a.list-group-item .list-group-item-heading, -.tab-dashboard.theme-dark button.list-group-item .list-group-item-heading { - color: #333333; -} -.tab-dashboard.theme-dark a.list-group-item:hover, -.tab-dashboard.theme-dark button.list-group-item:hover, -.tab-dashboard.theme-dark a.list-group-item:focus, -.tab-dashboard.theme-dark button.list-group-item:focus { - color: #555555; - background-color: #eeeeee; -} -.tab-dashboard.theme-dark .panel > .panel-body + .table, -.tab-dashboard.theme-dark .panel > .panel-body + .table-responsive, -.tab-dashboard.theme-dark .panel > .table + .panel-body, -.tab-dashboard.theme-dark .panel > .table-responsive + .panel-body { - border-top-color: #5c5c5c; -} -.tab-dashboard.theme-dark .panel-group .panel-heading + .panel-collapse > .panel-body, -.tab-dashboard.theme-dark .panel-group .panel-heading + .panel-collapse > .list-group { - border-top-color: #dddddd; -} -.tab-dashboard.theme-dark .panel-group .panel-footer { - border-top: 0; -} -.tab-dashboard.theme-dark .panel-group .panel-footer + .panel-collapse .panel-body { - border-bottom-color: #dddddd; -} -.tab-dashboard.theme-dark .panel-default { - border-color: #5c5c5c; -} -.tab-dashboard.theme-dark .panel-default > .panel-heading { - color: #eeeeee; - background-color: #272727; - border-color: #5c5c5c; -} -.tab-dashboard.theme-dark .panel-default > .panel-heading + .panel-collapse > .panel-body { - border-top-color: #5c5c5c; -} -.tab-dashboard.theme-dark .panel-default > .panel-heading .badge { - color: #272727; - background-color: #eeeeee; -} -.tab-dashboard.theme-dark .panel-default > .panel-footer + .panel-collapse > .panel-body { - border-bottom-color: #5c5c5c; -} -.tab-dashboard.theme-dark .nav > li > a:hover, -.tab-dashboard.theme-dark .nav > li > a:focus { - background-color: #666666; -} -.tab-dashboard.theme-dark .nav-tabs { - border-bottom: 1px solid #666666; -} -.tab-dashboard.theme-dark .nav-tabs > li > a:hover { - border-color: #777777 #777777 #666666; -} -.tab-dashboard.theme-dark .nav-tabs > li.active > a, -.tab-dashboard.theme-dark .nav-tabs > li.active > a:hover, -.tab-dashboard.theme-dark .nav-tabs > li.active > a:focus { - color: #eeeeee; - background-color: #333333; - border-color: #777777; -} -.tab-dashboard.theme-dark navbar { - color: #ffffff; - background-color: #333333; - border-color: #1a1a1a; -} -.tab-dashboard.theme-dark saved-object-finder .list-group-item a { - color: #cecece !important; -} -.tab-dashboard.theme-dark saved-object-finder .list-group-item a i { - color: #b5b5b5 !important; -} -.tab-dashboard.theme-dark saved-object-finder .finder-options > li.active { - background-color: #999999; - color: #555555; -} -.tab-dashboard.theme-dark saved-object-finder .finder-options > li.active a { - color: #555555; -} -.tab-dashboard.theme-dark .cell-hover { - background-color: transparent; -} -.tab-dashboard.theme-dark .cell-hover:hover { - background-color: #666666; -} -.tab-dashboard.theme-dark .spinner > div { - background-color: #ffffff; -} -.tab-dashboard.theme-dark .agg-table-paginated tr:hover td { - background-color: #707070; -} -.tab-dashboard.theme-dark .agg-table-paginated .cell-hover:hover { - background-color: #666666; -} -.tab-dashboard.theme-dark visualize-spy .visualize-show-spy { - border-top-color: #5c5c5c; -} -.tab-dashboard.theme-dark visualize-spy .visualize-show-spy-tab { - border-color: #5c5c5c; - background: #343434; - color: #888888; -} -.tab-dashboard.theme-dark visualize-spy .visualize-show-spy-tab:hover { - background-color: #666666; - color: #333333; -} -.tab-dashboard.theme-dark .axis line, -.tab-dashboard.theme-dark .axis path { - stroke: #888888; -} -.tab-dashboard.theme-dark .tick text { - fill: #aaaaaa; -} -.tab-dashboard.theme-dark .brush .extent { - stroke: #ffffff; -} -.tab-dashboard.theme-dark .endzone { - fill: #ffffff; -} -.tab-dashboard.theme-dark .legend-col-wrapper .legend-toggle { - background-color: #777777; -} -.tab-dashboard.theme-dark .legend-col-wrapper .legend-toggle:hover { - color: #cecece; - background-color: #6a6a6a; -} -.tab-dashboard.theme-dark .legend-col-wrapper .legend-ul { - border-left-color: #777777; - color: #aaaaaa; -} -.tab-dashboard.theme-dark .legend-value-title { - padding: 3px; -} -.tab-dashboard.theme-dark .legend-value-title:hover { - background-color: #6a6a6a; -} -.tab-dashboard.theme-dark .legend-value-full { - background-color: #6a6a6a; -} -.tab-dashboard.theme-dark .legend-value-details { - border-bottom: 1px solid #777777; -} -.tab-dashboard.theme-dark .legend-value-details .filter-button { - background-color: #777777; -} -.tab-dashboard.theme-dark .legend-value-details .filter-button:hover { - background-color: #6a6a6a; -} -.tab-dashboard.theme-dark .y-axis-title text, -.tab-dashboard.theme-dark .x-axis-title text { - fill: #aaaaaa; -} -.tab-dashboard.theme-dark .chart-title text { - fill: #aaaaaa; -} -.tab-dashboard.theme-dark .tilemap { - border-color: #dddddd; -} -.tab-dashboard.theme-dark .tilemap-legend { - background: #333333; - color: #cccccc; -} -.tab-dashboard.theme-dark .tilemap-legend i { - border-color: #999999; - background: #aaaaaa; -} -.tab-dashboard.theme-dark .tilemap-info { - background: #ffffff; - background: rgba(255, 255, 255, 0.92); -} -.tab-dashboard.theme-dark .tilemap-info h2 { - color: #444444; -} -.tab-dashboard.theme-dark .leaflet-control-fit { - background: #ffffff; - outline: 1px #000000; -} -.tab-dashboard.theme-dark .leaflet-container { - background: #333333 !important; -} -.tab-dashboard.theme-dark .leaflet-popup-content-wrapper { - background: rgba(68, 68, 68, 0.93) !important; - color: #eeeeee !important; -} -.tab-dashboard.theme-dark .leaflet-popup-content table thead tr { - border-bottom-color: #999999; -} -.tab-dashboard.theme-dark .leaflet-popup-content table tbody tr { - border-top-color: #999999; -} -.tab-dashboard.theme-dark img.leaflet-tile { - -webkit-filter: invert(1) brightness(1.75) grayscale(1) contrast(1); - filter: invert(1) brightness(1.75) grayscale(1) contrast(1); -} -.tab-dashboard.theme-dark .leaflet-control-attribution { - background-color: rgba(51, 51, 51, 0.8) !important; - color: #cccccc !important; -} -.tab-dashboard.theme-dark .leaflet-left .leaflet-control a, -.tab-dashboard.theme-dark .leaflet-left .leaflet-control a:hover { - color: #000000; -} -.tab-dashboard.theme-dark .leaflet-left .leaflet-draw-actions a { - background-color: #bbbbbb; -} -.tab-dashboard.theme-dark filter-bar .confirm { - background: #333333; - border-bottom-color: #000000; -} -.tab-dashboard.theme-dark filter-bar .confirm .filter { - background-color: #cccccc; - color: #333333; -} -.tab-dashboard.theme-dark filter-bar .bar { - background: #333333; - border-bottom-color: #000000; -} -.tab-dashboard.theme-dark filter-bar .bar-condensed { - background: #262626; -} -.tab-dashboard.theme-dark filter-bar .bar .filter { - background-color: #569f76; - color: #ffffff; -} -.tab-dashboard.theme-dark filter-bar .bar .filter.negate { - background-color: #c6675d; -} -.tab-dashboard.theme-dark filter-bar .bar .filter a { - color: #ffffff; -} -.tab-dashboard.theme-dark .config { - border-bottom-color: #444444; -} -.tab-dashboard.theme-dark .config .config-close { - background-color: #444444; -} -.tab-dashboard.theme-dark .config .container-fluid { - background-color: #333333; -} -.tab-dashboard.theme-dark .list-group-menu.select-mode a { - color: #b7e2ea; -} -.tab-dashboard.theme-dark .list-group-menu .list-group-menu-item { - color: #cecece; -} -.tab-dashboard.theme-dark .list-group-menu .list-group-menu-item.active { - background-color: #444444; -} -.tab-dashboard.theme-dark .list-group-menu .list-group-menu-item:hover { - background-color: #444444; -} -.tab-dashboard.theme-dark .list-group-menu .list-group-menu-item li { - color: #cecece; -} -.tab-dashboard.theme-dark select { - color: #cecece; - background-color: #444444; -} -.tab-dashboard.theme-dark paginate paginate-controls .pagination-other-pages-list > li.active a { - color: #999999; -} -.tab-dashboard.theme-dark .start-screen { - background-color: #1e1b1e; -} -.tab-dashboard.theme-dark .gridster { - background-color: #1e1b1e; -} -.tab-dashboard.theme-dark .gridster dashboard-panel { - background: #343434; - color: #cecece; -} -.tab-dashboard.theme-dark .gridster dashboard-panel .panel .panel-heading a { - color: #a6a6a6; -} -.tab-dashboard.theme-dark .gridster dashboard-panel .panel .panel-heading a:hover { - color: #a6a6a6; -} -.tab-dashboard.theme-dark .gridster dashboard-panel .panel .panel-heading span.panel-title { - color: #a6a6a6; -} -.tab-dashboard.theme-dark .gridster dashboard-panel .panel .panel-heading i { - color: #a6a6a6; - opacity: 1; -} -.tab-dashboard.theme-dark .gridster dashboard-panel .panel .load-error .fa-exclamation-triangle { - color: #e74c3c; -} -.hintbox { - padding: 10px 12px; - border-radius: 5px; - margin-bottom: 10px; - background-color: #ecf0f1; -} -.hintbox a { - color: #1f6b7a !important; -} -.hintbox a:hover { - color: #444444 !important; -} -.hintbox pre { - background-color: #ffffff; -} -.hintbox-label, -.hintbox-label[ng-click] { - cursor: help; -} -.hintbox ul, -.hintbox ol { - padding-left: 25px; -} -.hintbox > * { - margin: 0; -} -.hintbox > * + * { - margin-top: 10px; -} -.hintbox .table-bordered { - border: 1px solid #bfc9ca; -} -.hintbox .table-bordered > thead > tr > th, -.hintbox .table-bordered > tbody > tr > th, -.hintbox .table-bordered > tfoot > tr > th, -.hintbox .table-bordered > thead > tr > td, -.hintbox .table-bordered > tbody > tr > td, -.hintbox .table-bordered > tfoot > tr > td { - border: 1px solid #bfc9ca; -} -.hintbox .table-bordered > thead > tr > th, -.hintbox .table-bordered > thead > tr > td { - border-bottom-width: 2px; -} -i.input-error { - position: absolute; - margin-left: -25px; - color: #e74c3c; - margin-top: 10px; - z-index: 5; -} -select { - color: #444444; - background-color: #ffffff; -} -.thumbnail > img, -.thumbnail a > img, -.carousel-inner > .item > img, -.carousel-inner > .item > a > img { - display: block; - max-width: 100%; - height: auto; -} -.btn-group-lg > .btn { - padding: 18px 27px; - font-size: 17px; - line-height: 1.33; - border-radius: 6px; -} -.btn-group-sm > .btn { - padding: 6px 9px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.btn-group-xs > .btn { - padding: 1px 5px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.dl-horizontal dd:before, -.dl-horizontal dd:after, -.container:before, -.container:after, -.container-fluid:before, -.container-fluid:after, -.row:before, -.row:after, -.form-horizontal .form-group:before, -.form-horizontal .form-group:after, -.btn-toolbar:before, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:before, -.btn-group-vertical > .btn-group:after, -.nav:before, -.nav:after, -.navbar:before, -.navbar:after, -.navbar-header:before, -.navbar-header:after, -.navbar-collapse:before, -.navbar-collapse:after, -.pager:before, -.pager:after, -.panel-body:before, -.panel-body:after, -.modal-footer:before, -.modal-footer:after { - content: " "; - display: table; -} -.dl-horizontal dd:after, -.container:after, -.container-fluid:after, -.row:after, -.form-horizontal .form-group:after, -.btn-toolbar:after, -.btn-group-vertical > .btn-group:after, -.nav:after, -.navbar:after, -.navbar-header:after, -.navbar-collapse:after, -.pager:after, -.panel-body:after, -.modal-footer:after { - clear: both; -} -.list-group-menu.select-mode a { - outline: none; - color: #1f6b7a; -} -.list-group-menu .list-group-menu-item { - list-style: none; - color: #1f6b7a; -} -.list-group-menu .list-group-menu-item.active { - font-weight: bold; - background-color: #ecf0f1; -} -.list-group-menu .list-group-menu-item:hover { - background-color: #ecf0f1; -} -.list-group-menu .list-group-menu-item li { - list-style: none; - color: #1f6b7a; -} -.control-group { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-flex-wrap: wrap; - -ms-flex-wrap: wrap; - flex-wrap: wrap; - -webkit-box-align: stretch; - -webkit-align-items: stretch; - -ms-flex-align: stretch; - align-items: stretch; - padding: 5px 15px; - /*** - * components - ***/ -} -.control-group > * { - padding-right: 15px; - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; -} -.control-group > *:last-child { - padding-right: 0; -} -.control-group button { - padding: 5px 15px; - font-size: 13px; - color: #1f6b7a; - background-color: inherit; -} -.control-group button:hover { - color: #ecf0f1; - background-color: #5e5e5e; -} -.control-group button .active, -.control-group button:active, -.control-group button:focus { - color: #b4bcc2; - background-color: #5e5e5e; -} -.control-group button[disabled] { - color: #b4bcc2; - background-color: transparent; -} -.control-group button:focus { - outline-offset: -4px; -} -.control-group .button-group, -.control-group .inline-form .input-group { - margin-bottom: 0px; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; -} -.control-group .button-group > *, -.control-group .inline-form .input-group > * { - border-radius: 0; -} -.control-group .button-group > :first-child, -.control-group .inline-form .input-group > :first-child { - border-bottom-left-radius: 4px; - border-top-left-radius: 4px; -} -.control-group .button-group > :last-child, -.control-group .inline-form .input-group > :last-child { - border-bottom-right-radius: 4px; - border-top-right-radius: 4px; -} -.control-group .inline-form { - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; -} -.control-group .inline-form > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -.control-group .inline-form > .typeahead { - -webkit-box-flex: 1; - -webkit-flex: 1 1 auto; - -ms-flex: 1 1 auto; - flex: 1 1 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; -} -.control-group .inline-form > .typeahead > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -.control-group .inline-form > .typeahead > .input-group { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-flex: 1; - -webkit-flex: 1 0 auto; - -ms-flex: 1 0 auto; - flex: 1 0 auto; -} -.control-group .inline-form > .typeahead > .input-group > * { - float: none; - height: auto; - width: auto; - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; -} -.control-group .inline-form > .typeahead > .input-group input[type="text"] { - -webkit-box-flex: 1; - -webkit-flex: 1 1 100%; - -ms-flex: 1 1 100%; - flex: 1 1 100%; -} -.control-group > .fill { - -webkit-box-flex: 1; - -webkit-flex: 1 1 1%; - -ms-flex: 1 1 1%; - flex: 1 1 1%; -} -.nav-controls .column { - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; -} -navbar { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - -webkit-box-orient: horizontal; - -webkit-box-direction: normal; - -webkit-flex-direction: row; - -ms-flex-direction: row; - flex-direction: row; - -webkit-flex-wrap: wrap; - -ms-flex-wrap: wrap; - flex-wrap: wrap; - -webkit-box-align: stretch; - -webkit-align-items: stretch; - -ms-flex-align: stretch; - align-items: stretch; - /*** - * components - ***/ - max-height: 340px; - margin-bottom: 0px; - padding: 5px 15px; - color: #ffffff; - background-color: #656a76; - border-style: solid; - border-color: #4d515b; - border-width: 0 0 1px; - z-index: 1000; - /*** - * components - ***/ - /*** - * responsive modifications - ***/ -} -navbar > * { - padding-right: 15px; - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; -} -navbar > *:last-child { - padding-right: 0; -} -navbar button { - padding: 5px 15px; - font-size: 13px; - color: #1f6b7a; - background-color: inherit; -} -navbar button:hover { - color: #ecf0f1; - background-color: #5e5e5e; -} -navbar button .active, -navbar button:active, -navbar button:focus { - color: #b4bcc2; - background-color: #5e5e5e; -} -navbar button[disabled] { - color: #b4bcc2; - background-color: transparent; -} -navbar button:focus { - outline-offset: -4px; -} -navbar .button-group, -navbar .inline-form .input-group { - margin-bottom: 0px; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; -} -navbar .button-group > *, -navbar .inline-form .input-group > * { - border-radius: 0; -} -navbar .button-group > :first-child, -navbar .inline-form .input-group > :first-child { - border-bottom-left-radius: 4px; - border-top-left-radius: 4px; -} -navbar .button-group > :last-child, -navbar .inline-form .input-group > :last-child { - border-bottom-right-radius: 4px; - border-top-right-radius: 4px; -} -navbar .inline-form { - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; -} -navbar .inline-form > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -navbar .inline-form > .typeahead { - -webkit-box-flex: 1; - -webkit-flex: 1 1 auto; - -ms-flex: 1 1 auto; - flex: 1 1 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-orient: vertical; - -webkit-box-direction: normal; - -webkit-flex-direction: column; - -ms-flex-direction: column; - flex-direction: column; -} -navbar .inline-form > .typeahead > * { - -webkit-flex-shrink: 0; - -ms-flex-negative: 0; - flex-shrink: 0; -} -navbar .inline-form > .typeahead > .input-group { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-flex: 1; - -webkit-flex: 1 0 auto; - -ms-flex: 1 0 auto; - flex: 1 0 auto; -} -navbar .inline-form > .typeahead > .input-group > * { - float: none; - height: auto; - width: auto; - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; -} -navbar .inline-form > .typeahead > .input-group input[type="text"] { - -webkit-box-flex: 1; - -webkit-flex: 1 1 100%; - -ms-flex: 1 1 100%; - flex: 1 1 100%; -} -navbar > .fill { - -webkit-box-flex: 1; - -webkit-flex: 1 1 1%; - -ms-flex: 1 1 1%; - flex: 1 1 1%; -} -navbar > * { - padding-right: 15px; -} -navbar > .name { - -webkit-align-self: center; - -ms-flex-item-align: center; - align-self: center; - font-size: 17px; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; -} -navbar button { - color: #ecf0f1; - background-color: transparent; -} -navbar button:hover { - color: #ffffff; - background-color: transparent; -} -navbar button:focus { - color: #ecf0f1; - background-color: transparent; -} -navbar button:active, -navbar button.active { - color: #ffffff; - background-color: #4d515b; -} -navbar button[disabled] { - color: #cccccc; - background-color: transparent; -} -navbar .inline-form .input-group button { - color: #444444; - background-color: #ecf0f1; - border: 2px solid; - border-left: 0; - border-color: #ecf0f1; -} -@media (min-width: 992px) { - navbar > .name { - max-width: 500px; - } -} -@media (max-width: 992px) { - navbar > .fill { - -webkit-box-flex: 1; - -webkit-flex: 1 1 992px; - -ms-flex: 1 1 992px; - flex: 1 1 992px; - } -} -@media (max-width: 768px) { - navbar > .name { - max-width: 100%; - } -} -.toaster-container { - visibility: visible; - width: 100%; -} -.toaster-container .toaster { - margin: 0; - padding: 0; - list-style: none; -} -.toaster-container .alert { - padding: 0 15px; - margin: 0; - border-radius: 0; - border: 0px; -} -.toaster-container .toast { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-align: center; - -webkit-align-items: center; - -ms-flex-align: center; - align-items: center; -} -.toaster-container .toast > * { - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; -} -.toaster-container .toast > *:not(:last-child) { - margin-right: 4px; -} -.toaster-container .toast-message { - -webkit-box-flex: 1; - -webkit-flex: 1 1 auto; - -ms-flex: 1 1 auto; - flex: 1 1 auto; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; - line-height: normal; -} -.toaster-container .toast-stack { - padding-bottom: 10px; -} -.toaster-container .toast-stack pre { - display: inline-block; - width: 100%; - margin: 10px 0; - word-break: normal; - word-wrap: normal; - white-space: pre-wrap; -} -.toaster-container .toast-controls { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; -} -.toaster-container .toast-controls button { - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - border: 0; - border-radius: 0; - padding: 10px 15px; -} -.toaster-container .alert-success .badge { - background: #185e36; -} -.toaster-container .alert-info .badge { - background: #051214; -} -.toaster-container .alert-warning .badge { - background: #7f5006; -} -.toaster-container .alert-danger .badge { - background: #921e12; -} -paginate { - display: block; -} -paginate paginate-controls { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-align: center; - -webkit-align-items: center; - -ms-flex-align: center; - align-items: center; - padding: 5px 5px 10px; - text-align: center; -} -paginate paginate-controls .pagination-other-pages { - -webkit-box-flex: 1; - -webkit-flex: 1 0 auto; - -ms-flex: 1 0 auto; - flex: 1 0 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: center; - -webkit-justify-content: center; - -ms-flex-pack: center; - justify-content: center; -} -paginate paginate-controls .pagination-other-pages-list { - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: center; - -webkit-justify-content: center; - -ms-flex-pack: center; - justify-content: center; - padding: 0; - margin: 0; - list-style: none; -} -paginate paginate-controls .pagination-other-pages-list > li { - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} -paginate paginate-controls .pagination-other-pages-list > li a { - text-decoration: none; -} -paginate paginate-controls .pagination-other-pages-list > li a:hover { - text-decoration: underline; -} -paginate paginate-controls .pagination-other-pages-list > li.active a { - text-decoration: none !important; - font-weight: bold; - color: #444444; -} -paginate paginate-controls .pagination-size { - -webkit-box-flex: 0; - -webkit-flex: 0 0 auto; - -ms-flex: 0 0 auto; - flex: 0 0 auto; -} -paginate paginate-controls .pagination-size input[type=number] { - width: 3em; -} -.sidebar-container { - padding-left: 0px !important; - padding-right: 0px !important; - background-color: #ecf0f1; - border-right-color: transparent; - border-bottom-color: transparent; -} -.sidebar-container .sidebar-well { - background-color: #dde4e6; -} -.sidebar-container .sidebar-list ul { - list-style: none; - margin-bottom: 0px; -} -.sidebar-container .sidebar-list-header { - padding-left: 10px; - padding-right: 10px; - color: #444444; - border: 1px solid; - border-color: transparent; -} -.sidebar-container .sidebar-list .sidebar-item { - border-top-color: transparent; - font-size: 12px; -} -.sidebar-container .sidebar-list .sidebar-item a:not(.sidebar-item-button) { - color: #444444; -} -.sidebar-container .sidebar-list .sidebar-item a:not(.sidebar-item-button):hover { - color: #444444; - text-decoration: none; -} -.sidebar-container .sidebar-list .sidebar-item-title, -.sidebar-container .sidebar-list .sidebar-item-text, -.sidebar-container .sidebar-list .sidebar-item-button { - margin: 0; - padding: 5px 10px; - text-align: center; - width: 100%; - border: none; - border-radius: 0; -} -.sidebar-container .sidebar-list .sidebar-item-title { - text-align: left; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; -} -.sidebar-container .sidebar-list .sidebar-item-title.full-title { - white-space: normal; -} -.sidebar-container .sidebar-list .sidebar-item-title:hover, -.sidebar-container .sidebar-list .sidebar-item-title:hover .text-muted { - color: #444444; - background-color: #cfd9db; -} -.sidebar-container .sidebar-list .sidebar-item-text { - background: #ffffff; -} -.sidebar-container .sidebar-list .sidebar-item-button { - font-size: inherit; - display: block; -} -.sidebar-container .sidebar-list .sidebar-item-button[disabled] { - opacity: 0.65; - cursor: default; -} -.sidebar-container .sidebar-list .sidebar-item-button.primary { - background-color: #444444; - color: #ffffff; -} -.sidebar-container .sidebar-list .sidebar-item-button.info { - background-color: #1f6b7a; - color: #ffffff; -} -.sidebar-container .sidebar-list .sidebar-item-button.success { - background-color: #31c471; - color: #ffffff; -} -.sidebar-container .sidebar-list .sidebar-item-button.warning { - background-color: #f39c12; - color: #ffffff; -} -.sidebar-container .sidebar-list .sidebar-item-button.danger { - background-color: #e74c3c; - color: #ffffff; -} -.sidebar-container .sidebar-list .sidebar-item-button.default { - color: #ffffff; - background-color: #95a5a6; - border-color: #95a5a6; -} -.sidebar-container .sidebar-list .sidebar-item-button.default:focus, -.sidebar-container .sidebar-list .sidebar-item-button.default.focus { - color: #ffffff; - background-color: #798d8f; - border-color: #566566; -} -.sidebar-container .sidebar-list .sidebar-item-button.default:hover { - color: #ffffff; - background-color: #798d8f; - border-color: #74898a; -} -.sidebar-container .sidebar-list .sidebar-item-button.default:active, -.sidebar-container .sidebar-list .sidebar-item-button.default.active, -.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default { - color: #ffffff; - background-color: #798d8f; - border-color: #74898a; -} -.sidebar-container .sidebar-list .sidebar-item-button.default:active:hover, -.sidebar-container .sidebar-list .sidebar-item-button.default.active:hover, -.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default:hover, -.sidebar-container .sidebar-list .sidebar-item-button.default:active:focus, -.sidebar-container .sidebar-list .sidebar-item-button.default.active:focus, -.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default:focus, -.sidebar-container .sidebar-list .sidebar-item-button.default:active.focus, -.sidebar-container .sidebar-list .sidebar-item-button.default.active.focus, -.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default.focus { - color: #ffffff; - background-color: #687b7c; - border-color: #566566; -} -.sidebar-container .sidebar-list .sidebar-item-button.default:active, -.sidebar-container .sidebar-list .sidebar-item-button.default.active, -.open > .dropdown-toggle.sidebar-container .sidebar-list .sidebar-item-button.default { - background-image: none; -} -.sidebar-container .sidebar-list .sidebar-item-button.default.disabled, -.sidebar-container .sidebar-list .sidebar-item-button.default[disabled], -fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default, -.sidebar-container .sidebar-list .sidebar-item-button.default.disabled:hover, -.sidebar-container .sidebar-list .sidebar-item-button.default[disabled]:hover, -fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default:hover, -.sidebar-container .sidebar-list .sidebar-item-button.default.disabled:focus, -.sidebar-container .sidebar-list .sidebar-item-button.default[disabled]:focus, -fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default:focus, -.sidebar-container .sidebar-list .sidebar-item-button.default.disabled.focus, -.sidebar-container .sidebar-list .sidebar-item-button.default[disabled].focus, -fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default.focus, -.sidebar-container .sidebar-list .sidebar-item-button.default.disabled:active, -.sidebar-container .sidebar-list .sidebar-item-button.default[disabled]:active, -fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default:active, -.sidebar-container .sidebar-list .sidebar-item-button.default.disabled.active, -.sidebar-container .sidebar-list .sidebar-item-button.default[disabled].active, -fieldset[disabled] .sidebar-container .sidebar-list .sidebar-item-button.default.active { - background-color: #95a5a6; - border-color: #95a5a6; -} -.sidebar-container .sidebar-list .sidebar-item-button.default .badge { - color: #95a5a6; - background-color: #ffffff; -} -.sidebar-container .sidebar-list .sidebar-item .active { - background-color: #444444 !important; - color: #ffffff; -} -.sidebar-container .sidebar-list .sidebar-item .active:hover, -.sidebar-container .sidebar-list .sidebar-item .active:hover .text-muted { - color: #ffffff; - background-color: #444444; -} -.sidebar-container .index-pattern { - background-color: #444444; - font-weight: bold; - padding: 5px 10px; - color: #ffffff; - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: justify; - -webkit-justify-content: space-between; - -ms-flex-pack: justify; - justify-content: space-between; -} -.sidebar-container .index-pattern > * { - -webkit-box-flex: 0; - -webkit-flex: 0 1 auto; - -ms-flex: 0 1 auto; - flex: 0 1 auto; -} -.sidebar-container .index-pattern-selection .sidebar-item-title { - background-color: #ffffff; -} -.spinner { - margin: 0px auto 0; - white-space: nowrap; - text-align: center; - display: inline; -} -.spinner > div { - width: 10px; - height: 10px; - background-color: #444444; - border-radius: 100%; - display: inline-block; - -webkit-animation: bouncedelay 1s infinite ease-in-out; - animation: bouncedelay 1s infinite ease-in-out; - /* Prevent first frame from flickering when animation starts */ - -webkit-animation-fill-mode: both; - animation-fill-mode: both; -} -.navbar .spinner > div { - background-color: #ecf0f1; -} -.spinner.large > div { - width: 24px; - height: 24px; -} -.spinner .bounce1 { - -webkit-animation-delay: -0.32s; - animation-delay: -0.32s; -} -.spinner .bounce2 { - -webkit-animation-delay: -0.16s; - animation-delay: -0.16s; -} -@-webkit-keyframes bouncedelay { - 0%, - 80%, - 100% { - -webkit-transform: scale(0); - } - 40% { - -webkit-transform: scale(1); - } -} -@keyframes bouncedelay { - 0%, - 80%, - 100% { - transform: scale(0); - -webkit-transform: scale(0); - } - 40% { - transform: scale(1); - -webkit-transform: scale(1); - } -} -.table .table { - background-color: #ffffff; -} -kbn-table .table .table, -.kbn-table .table .table, -tbody[kbn-rows] .table .table { - margin-bottom: 0px; -} -kbn-table .table .table tr:first-child > td, -.kbn-table .table .table tr:first-child > td, -tbody[kbn-rows] .table .table tr:first-child > td { - border-top: none; -} -kbn-table .table .table td.field-name, -.kbn-table .table .table td.field-name, -tbody[kbn-rows] .table .table td.field-name { - font-weight: bold; -} -kbn-table dl.source, -.kbn-table dl.source, -tbody[kbn-rows] dl.source { - margin-bottom: 0; - line-height: 2em; - word-break: break-all; -} -kbn-table dl.source dt, -.kbn-table dl.source dt, -tbody[kbn-rows] dl.source dt, -kbn-table dl.source dd, -.kbn-table dl.source dd, -tbody[kbn-rows] dl.source dd { - display: inline; -} -kbn-table dl.source dt, -.kbn-table dl.source dt, -tbody[kbn-rows] dl.source dt { - background: #ecf0f1; - color: #444444; - padding: 1px 5px; - margin-right: 5px; - font-family: monospace; - word-break: normal; -} -table th i.fa-sort { - color: #b4bcc2; -} -table th i.fa-sort-asc, -table th i.fa-sort-down { - color: #b4bcc2; -} -table th i.fa-sort-desc, -table th i.fa-sort-up { - color: #b4bcc2; -} -.truncate-by-height { - position: relative; - overflow: hidden; -} -.truncate-by-height:before { - content: " "; - width: 100%; - height: 15px; - position: absolute; - left: 0; - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(1%, rgba(255, 255, 255, 0.01)), color-stop(99%, rgba(255, 255, 255, 0.99)), color-stop(100%, #ffffff)); - background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.01) 1%, rgba(255, 255, 255, 0.99) 99%, #ffffff 100%); - background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.01) 1%, rgba(255, 255, 255, 0.99) 99%, #ffffff 100%); -} diff --git a/pom.xml b/pom.xml index 2ff7c735ed..402313ff06 100644 --- a/pom.xml +++ b/pom.xml @@ -263,6 +263,11 @@ **/packer-build/bin/** **/packer_cache/** + **/hbase/data/** + **/hbase/bin/init-commands.txt + **/kafkazk/data/** + **/wait-for-it.sh + metron-docker/kibana/styles/commons.style.css From 8825a85bfab5eaa792ea24efb1e025c90d41664b Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 5 Dec 2016 18:09:02 -0600 Subject: [PATCH 11/54] Resolved licensing issues --- dependencies_with_url.csv | 59 +++++++++++++ metron-interface/metron-rest/README.md | 14 ++-- metron-interface/metron-rest/pom.xml | 83 +++++++++++++++++++ .../rest/service/TransformationService.java | 4 +- .../src/main/resources/log4j.properties | 12 +++ .../src/test/resources/log4j.properties | 12 +++ 6 files changed, 177 insertions(+), 7 deletions(-) diff --git a/dependencies_with_url.csv b/dependencies_with_url.csv index 67b5373840..9071940225 100644 --- a/dependencies_with_url.csv +++ b/dependencies_with_url.csv @@ -7,6 +7,7 @@ org.ow2.asm:asm:jar:5.0.3:compile,BSD,http://asm.ow2.org/ org.reflections:reflections:jar:0.9.10:compile,BSD,https://github.com/ronmamo/reflections org.javassist:javassist:jar:3.19.0-GA:compile,Apache v2,https://github.com/jboss-javassist/javassist org.javassist:javassist:jar:3.17.1-GA:compile,Apache v2,https://github.com/jboss-javassist/javassist +org.javassist:javassist:jar:3.20.0-GA:compile,Apache v2,https://github.com/jboss-javassist/javassist org.fusesource.jansi:jansi:jar:1.11:compile,Apache v2,https://github.com/fusesource/jansi de.javakaffee:kryo-serializers:jar:0.38:compile,Apache v2,https://github.com/magro/kryo-serializers com.tdunning:t-digest:jar:3.1:compile,Apache v2,https://github.com/tdunning/t-digest @@ -76,6 +77,7 @@ org.slf4j:slf4j-api:jar:1.7.10:compile,MIT,http://www.slf4j.org org.slf4j:slf4j-api:jar:1.7.5:compile,MIT,http://www.slf4j.org org.slf4j:slf4j-api:jar:1.7.6:compile,MIT,http://www.slf4j.org org.slf4j:slf4j-api:jar:1.7.7:compile,MIT,http://www.slf4j.org +org.slf4j:slf4j-api:jar:1.7.21:compile,MIT,http://www.slf4j.org org.slf4j:slf4j-log4j12:jar:1.6.1:compile,MIT,http://www.slf4j.org org.slf4j:slf4j-log4j12:jar:1.7.10:compile,MIT,http://www.slf4j.org org.slf4j:slf4j-log4j12:jar:1.7.10:runtime,MIT,http://www.slf4j.org @@ -83,6 +85,8 @@ org.slf4j:slf4j-log4j12:jar:1.7.21:compile,MIT,http://www.slf4j.org org.slf4j:slf4j-log4j12:jar:1.7.5:compile,MIT,http://www.slf4j.org org.slf4j:slf4j-log4j12:jar:1.7.7:compile,MIT,http://www.slf4j.org org.slf4j:slf4j-simple:jar:1.7.7:compile,MIT,http://www.slf4j.org +org.slf4j:jcl-over-slf4j:jar:1.7.21:compile,MIT,http://www.slf4j.org +org.slf4j:jul-to-slf4j:jar:1.7.21:compile,MIT,http://www.slf4j.org aopalliance:aopalliance:jar:1.0:compile,Public Domain,http://aopalliance.sourceforge.net com.101tec:zkclient:jar:0.8:compile,The Apache Software License, Version 2.0,https://github.com/sgroschupf/zkclient com.github.stephenc.findbugs:findbugs-annotations:jar:1.3.9-1:compile,Apache License, Version 2.0,http://stephenc.github.com/findbugs-annotations @@ -95,15 +99,21 @@ com.codahale.metrics:metrics-graphite:jar:3.0.2:compile,MIT,https://github.com/c com.esotericsoftware.reflectasm:reflectasm:jar:shaded:1.07:compile,BSD,https://github.com/EsotericSoftware/reflectasm com.fasterxml.jackson.core:jackson-annotations:jar:2.2.3:compile,ASLv2,http://wiki.fasterxml.com/JacksonHome com.fasterxml.jackson.core:jackson-annotations:jar:2.7.4:compile,ASLv2,http://github.com/FasterXML/jackson +com.fasterxml.jackson.core:jackson-annotations:jar:2.8.3:compile,ASLv2,http://github.com/FasterXML/jackson com.fasterxml.jackson.core:jackson-core:jar:2.2.3:compile,ASLv2,http://wiki.fasterxml.com/JacksonHome com.fasterxml.jackson.core:jackson-core:jar:2.6.6:compile,ASLv2,https://github.com/FasterXML/jackson-core com.fasterxml.jackson.core:jackson-core:jar:2.7.4:compile,ASLv2,https://github.com/FasterXML/jackson-core +com.fasterxml.jackson.core:jackson-core:jar:2.8.3:compile,ASLv2,https://github.com/FasterXML/jackson-core com.fasterxml.jackson.core:jackson-databind:jar:2.2.3:compile,ASLv2,http://wiki.fasterxml.com/JacksonHome com.fasterxml.jackson.core:jackson-databind:jar:2.7.4:compile,ASLv2,http://github.com/FasterXML/jackson +com.fasterxml.jackson.core:jackson-databind:jar:2.8.3:compile,ASLv2,http://github.com/FasterXML/jackson com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:jar:2.6.6:compile,ASLv2,http://wiki.fasterxml.com/JacksonForCbor com.fasterxml.jackson.dataformat:jackson-dataformat-smile:jar:2.6.6:compile,ASLv2,http://wiki.fasterxml.com/JacksonForSmile com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.6.6:compile,ASLv2,https://github.com/FasterXML/jackson +com.fasterxml.jackson.datatype:jackson-datatype-joda:jar:2.8.1:compile,ASLv2,https://github.com/FasterXML/jackson-datatype-joda +com.fasterxml:classmate:jar:1.3.1:compile,ASLv2,http://github.com/cowtowncoder/java-classmate com.google.code.gson:gson:jar:2.2.4:compile,The Apache Software License, Version 2.0,http://code.google.com/p/google-gson/ +com.google.code.gson:gson:jar:2.7:compile,The Apache Software License, Version 2.0,http://code.google.com/p/google-gson/ com.google.guava:guava:jar:11.0.2:compile,ASLv2, com.google.guava:guava:jar:12.0.1:compile,ASLv2, com.google.guava:guava:jar:12.0:compile,ASLv2, @@ -126,6 +136,7 @@ commons-beanutils:commons-beanutils-core:jar:1.8.0:compile,ASLv2,http://commons. commons-beanutils:commons-beanutils-core:jar:1.8.0:provided,ASLv2,http://commons.apache.org/beanutils/ commons-beanutils:commons-beanutils:jar:1.7.0:compile,ASLv2, commons-beanutils:commons-beanutils:jar:1.8.3:compile,ASLv2,http://commons.apache.org/beanutils/ +commons-beanutils:commons-beanutils:jar:1.9.2:compile,ASLv2,http://commons.apache.org/beanutils/ commons-cli:commons-cli:jar:1.2:compile,ASLv2,http://commons.apache.org/cli/ commons-cli:commons-cli:jar:1.3.1:compile,ASLv2,http://commons.apache.org/proper/commons-cli/ commons-codec:commons-codec:jar:1.10:compile,ASLv2,http://commons.apache.org/proper/commons-codec/ @@ -139,6 +150,7 @@ commons-configuration:commons-configuration:jar:1.6:compile,The Apache Software commons-daemon:commons-daemon:jar:1.0.13:compile,ASLv2,http://commons.apache.org/daemon/ commons-digester:commons-digester:jar:1.8.1:compile,ASLv2,http://commons.apache.org/digester/ commons-digester:commons-digester:jar:1.8:compile,The Apache Software License, Version 2.0,http://jakarta.apache.org/commons/digester/ +commons-digester:commons-digester:jar:2.1:compile,ASLv2,http://commons.apache.org/digester/ commons-el:commons-el:jar:1.0:provided,The Apache Software License, Version 2.0,http://jakarta.apache.org/commons/el/ commons-el:commons-el:jar:1.0:runtime,The Apache Software License, Version 2.0,http://jakarta.apache.org/commons/el/ commons-httpclient:commons-httpclient:jar:3.1:compile,Apache License,http://jakarta.apache.org/httpcomponents/httpclient-3.x/ @@ -201,14 +213,25 @@ org.springframework.integration:spring-integration-core:jar:3.0.0.RELEASE:compil org.springframework.integration:spring-integration-http:jar:3.0.0.RELEASE:compile,The Apache Software License, Version 2.0,http://www.springintegration.org/ org.springframework.retry:spring-retry:jar:1.0.3.RELEASE:compile,Apache 2.0,http://www.springsource.org org.springframework:spring-aop:jar:3.2.6.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/SpringSource/spring-framework +org.springframework:spring-aop:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework +org.springframework:spring-aspects:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework org.springframework:spring-beans:jar:3.2.6.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/SpringSource/spring-framework +org.springframework:spring-beans:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework org.springframework:spring-context:jar:3.2.6.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/SpringSource/spring-framework +org.springframework:spring-context:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework org.springframework:spring-core:jar:3.2.6.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/SpringSource/spring-framework org.springframework:spring-core:jar:4.1.4.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework +org.springframework:spring-core:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework org.springframework:spring-expression:jar:3.2.6.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/SpringSource/spring-framework +org.springframework:spring-expression:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework +org.springframework:spring-jdbc:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework +org.springframework:spring-orm:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework org.springframework:spring-tx:jar:3.2.6.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/SpringSource/spring-framework +org.springframework:spring-tx:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework org.springframework:spring-web:jar:3.2.6.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/SpringSource/spring-framework +org.springframework:spring-web:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework org.springframework:spring-webmvc:jar:3.2.6.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/SpringSource/spring-framework +org.springframework:spring-webmvc:jar:4.3.3.RELEASE:compile,The Apache Software License, Version 2.0,https://github.com/spring-projects/spring-framework org.tukaani:xz:jar:1.0:compile,Public Domain,http://tukaani.org/xz/java.html org.xerial.snappy:snappy-java:jar:1.0.4.1:compile,The Apache Software License, Version 2.0,http://code.google.com/p/snappy-java/ org.xerial.snappy:snappy-java:jar:1.1.1.7:compile,The Apache Software License, Version 2.0,https://github.com/xerial/snappy-java @@ -218,3 +241,39 @@ org.yaml:snakeyaml:jar:1.15:compile,Apache License Version 2.0,http://www.snakey ring-cors:ring-cors:jar:0.1.5:compile,Eclipse Public License 1.0,https://github.com/r0man/ring-cors xerces:xercesImpl:jar:2.9.1:compile,ASLv2,http://xerces.apache.org/xerces2-j xml-apis:xml-apis:jar:1.3.04:compile,ASLv2,http://xml.apache.org/commons/components/external/ +xml-apis:xml-apis:jar:1.4.01:compile,ASLv2,http://xml.apache.org/commons/components/external/ +dom4j:dom4j:jar:1.6.1:compile,dom4j,https://github.com/dom4j/dom4j +io.springfox:springfox-core:jar:2.5.0:compile,ASLv2,https://github.com/springfox/springfox +io.springfox:springfox-schema:jar:2.5.0:compile,ASLv2,https://github.com/springfox/springfox +io.springfox:springfox-spi:jar:2.5.0:compile,ASLv2,https://github.com/springfox/springfox +io.springfox:springfox-spring-web:jar:2.5.0:compile,ASLv2,https://github.com/springfox/springfox +io.springfox:springfox-swagger-common:jar:2.5.0:compile,ASLv2,https://github.com/springfox/springfox +io.springfox:springfox-swagger-ui:jar:2.5.0:compile,ASLv2,https://github.com/springfox/springfox +io.springfox:springfox-swagger2:jar:2.5.0:compile,ASLv2,https://github.com/springfox/springfox +io.swagger:swagger-annotations:jar:1.5.9:compile,ASLv2,https://github.com/swagger-api/swagger-core +io.swagger:swagger-models:jar:1.5.9:compile,ASLv2,https://github.com/swagger-api/swagger-core +javax.transaction:javax.transaction-api:jar:1.2:compile,CDDL-1.0,https://java.net/projects/jta-spec/ +javax.validation:validation-api:jar:1.1.0.Final:compile,ASLv2,http://beanvalidation.org +joda-time:joda-time:jar:2.9.4:compile,ASLv2,https://github.com/JodaOrg/joda-time +org.aspectj:aspectjweaver:jar:1.8.9:compile,EPL 1.0,https://eclipse.org/aspectj +org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile,ASLv2,https://github.com/jboss-logging +org.jboss:jandex:jar:2.0.0.Final:compile,ASLv2,https://github.com/wildfly/jandex +org.mapstruct:mapstruct:jar:1.0.0.Final:compile,ASLv2,https://github.com/mapstruct/mapstruct +org.springframework.boot:spring-boot-autoconfigure:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.boot:spring-boot-starter-aop:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.boot:spring-boot-starter-logging:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.boot:spring-boot-starter-security:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.boot:spring-boot-starter-tomcat:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.boot:spring-boot-starter-web:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.boot:spring-boot-starter:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.boot:spring-boot:jar:1.4.1.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-boot +org.springframework.data:spring-data-commons:jar:1.12.3.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-data-commons +org.springframework.data:spring-data-jpa:jar:1.10.3.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-data-jpa +org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-plugin +org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-plugin +org.springframework.security:spring-security-config:jar:4.1.3.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-security +org.springframework.security:spring-security-core:jar:4.1.3.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-security +org.springframework.security:spring-security-web:jar:4.1.3.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-security +antlr:antlr:jar:2.7.7:compile,BSD 3-Clause License,http://www.antlr2.org diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index 20484048cf..c2c778e1ef 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -21,9 +21,9 @@ This UI exposes and aids in sensor configuration. 3. Create a Config UI database in MySQL with this command: - ``` +``` CREATE DATABASE IF NOT EXISTS metronrest - ``` +``` 4. Create an "application.yml" file with the contents of src/main/resource/application-docker.yml @@ -34,10 +34,14 @@ CREATE DATABASE IF NOT EXISTS metronrest 6. Start the UI with this command: - ``` +``` ./bin/start.sh path_to_config_file_from_step_4 - ``` +``` # Usage -The exposed REST endpoints can be accessed at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. \ No newline at end of file +The exposed REST endpoints can be accessed at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. + +# License + +This project depends on the Java Transaction API. See https://java.net/projects/jta-spec/ for more details. \ No newline at end of file diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index 7f48c6ebf3..c968ef5daf 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -33,6 +33,7 @@ 2.5.0 5.1.36 2.9.4 + 5.0.11.Final 5.0.9.Final @@ -48,6 +49,10 @@ org.slf4j log4j-over-slf4j + + org.hibernate + hibernate-validator + @@ -57,11 +62,28 @@ org.springframework.boot spring-boot-starter-data-jpa + + + org.hibernate + hibernate-core + + + org.hibernate + hibernate-entitymanager + + + + + org.hibernate + hibernate-core + ${hibernate.version} + provided mysql mysql-connector-java ${mysql.client.version} + provided org.apache.curator @@ -142,6 +164,7 @@ org.hibernate hibernate-envers ${hibernate.envers.version} + provided io.thekraken @@ -274,6 +297,66 @@ + + + + org.hibernate.common + hibernate-commons-annotations + + + org.hibernate + hibernate-core + + + org.hibernate + hibernate-envers + + + org.hibernate + hibernate-entitymanager + + + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + + + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + install-config-ui + prepare-package + + exec + + + bash + ./src/main/scripts + + install_config_ui.sh + + + + + + + maven-assembly-plugin + + src/main/assembly/assembly.xml + + + + make-assembly + package + + single + + + diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java index d4a6a0f036..c59620bddf 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java @@ -18,9 +18,9 @@ package org.apache.metron.rest.service; import org.apache.metron.common.dsl.Context; -import org.apache.metron.common.dsl.FunctionResolverSingleton; import org.apache.metron.common.dsl.ParseException; import org.apache.metron.common.dsl.StellarFunctionInfo; +import org.apache.metron.common.dsl.functions.resolver.SingletonFunctionResolver; import org.apache.metron.common.field.transformation.FieldTransformations; import org.apache.metron.common.stellar.StellarProcessor; import org.apache.metron.rest.model.StellarFunctionDescription; @@ -67,7 +67,7 @@ public FieldTransformations[] getTransformations() { public List getStellarFunctions() { List stellarFunctionDescriptions = new ArrayList<>(); - Iterable stellarFunctionsInfo = FunctionResolverSingleton.getInstance().getFunctionInfo(); + Iterable stellarFunctionsInfo = SingletonFunctionResolver.getInstance().getFunctionInfo(); stellarFunctionsInfo.forEach(stellarFunctionInfo -> { stellarFunctionDescriptions.add(new StellarFunctionDescription( stellarFunctionInfo.getName(), diff --git a/metron-interface/metron-rest/src/main/resources/log4j.properties b/metron-interface/metron-rest/src/main/resources/log4j.properties index ffc66d622b..492cecf9d7 100644 --- a/metron-interface/metron-rest/src/main/resources/log4j.properties +++ b/metron-interface/metron-rest/src/main/resources/log4j.properties @@ -1,3 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + log4j.rootLogger=ERROR, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout diff --git a/metron-interface/metron-rest/src/test/resources/log4j.properties b/metron-interface/metron-rest/src/test/resources/log4j.properties index ffc66d622b..492cecf9d7 100644 --- a/metron-interface/metron-rest/src/test/resources/log4j.properties +++ b/metron-interface/metron-rest/src/test/resources/log4j.properties @@ -1,3 +1,15 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + log4j.rootLogger=ERROR, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout From d38b6265b4c0806826db6f77c7c036f6115db53e Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 5 Dec 2016 18:12:38 -0600 Subject: [PATCH 12/54] Resolved licensing issues --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 402313ff06..659380c55b 100644 --- a/pom.xml +++ b/pom.xml @@ -267,7 +267,6 @@ **/hbase/bin/init-commands.txt **/kafkazk/data/** **/wait-for-it.sh - metron-docker/kibana/styles/commons.style.css From 25bc44e3f50f21b447d0217a2eccb4184f743c24 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Tue, 6 Dec 2016 11:10:37 -0600 Subject: [PATCH 13/54] Updated scripts to add Hibernate and MySQL client to classpath --- metron-interface/metron-rest/README.md | 66 ++++++++++--------- metron-interface/metron-rest/pom.xml | 10 ++- .../metron-rest/src/main/scripts/start.sh | 13 +++- 3 files changed, 52 insertions(+), 37 deletions(-) diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index c2c778e1ef..3c37b8f603 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -2,46 +2,50 @@ This UI exposes and aids in sensor configuration. -# Prerequisites +## Prerequisites -* A running Metron cluster. +* A running Metron cluster * A running instance of MySQL * Java 8 installed -# Installation - -1. Unpack RPM. This will create this directory structure: - -* bin - * start.sh -* lib - * metron-rest-.jar - -2. Create a MySQL user for the Config UI (http://dev.mysql.com/doc/refman/5.7/en/adding-users.html). - -3. Create a Config UI database in MySQL with this command: - -``` -CREATE DATABASE IF NOT EXISTS metronrest -``` +## Installation + +1. Download and Unpack RPM. The directory structure will look like: + ``` + bin + start.sh + lib + metron-rest-version.jar + ``` + +1. Install Hibernate by downloading version 5.0.11.Final from (http://hibernate.org/orm/downloads/). Unpack the archive and set the HIBERNATE_HOME environment variable to the absolute path of the top level directory. + ``` + export HIBERNATE_HOME=/path/to/hibernate-release-5.0.11.Final + ``` + +1. Install the MySQL client by downloading version 5.1.40 from (https://dev.mysql.com/downloads/connector/j/). Unpack the archive and set the MYSQL_CLIENT_HOME environment variable to the absolute path of the top level directory. + ``` + export MYSQL_CLIENT_HOME=/path/to/mysql-connector-java-5.1.40 + ``` + +1. Create a MySQL user for the Config UI (http://dev.mysql.com/doc/refman/5.7/en/adding-users.html). + +1. Create a Config UI database in MySQL with this command: + ``` + CREATE DATABASE IF NOT EXISTS metronrest + ``` -4. Create an "application.yml" file with the contents of src/main/resource/application-docker.yml - -5. Update the configuration file in step 4: - -* substitute the appropriate Metron service urls (Kafka, Zookeeper, Storm, etc) in properties containing ${docker.host.address} -* update the "spring.datasource.username" and "spring.datasource.password" properties using credentials from step 2 - -6. Start the UI with this command: +1. Create an `application.yml` file with the contents of [application-docker.yml](src/main/resource/application-docker.yml). Substitute the appropriate Metron service urls (Kafka, Zookeeper, Storm, etc) in properties containing `${docker.host.address}` and update the `spring.datasource.username` and `spring.datasource.password` properties using the MySQL credentials from step 4. -``` -./bin/start.sh path_to_config_file_from_step_4 -``` +1. Start the UI with this command: + ``` + ./bin/start.sh /path/to/application.yml + ``` -# Usage +## Usage The exposed REST endpoints can be accessed at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. -# License +## License This project depends on the Java Transaction API. See https://java.net/projects/jta-spec/ for more details. \ No newline at end of file diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index c968ef5daf..d43716f075 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -31,10 +31,9 @@ 1.6.4 1.4.1.RELEASE 2.5.0 - 5.1.36 + 5.1.40 2.9.4 5.0.11.Final - 5.0.9.Final @@ -163,7 +162,7 @@ org.hibernate hibernate-envers - ${hibernate.envers.version} + ${hibernate.version} provided @@ -298,7 +297,12 @@ + ZIP + + mysql + mysql-connector-java + org.hibernate.common hibernate-commons-annotations diff --git a/metron-interface/metron-rest/src/main/scripts/start.sh b/metron-interface/metron-rest/src/main/scripts/start.sh index 890215648b..d83a2fd846 100755 --- a/metron-interface/metron-rest/src/main/scripts/start.sh +++ b/metron-interface/metron-rest/src/main/scripts/start.sh @@ -17,10 +17,17 @@ # METRON_VERSION=0.3.0 SCRIPTS_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -PROJECT_ROOT=$SCRIPTS_ROOT/../../.. if [ "$#" -ne 1 ]; then echo "Usage: start.sh " - echo "Path can be absolute or relative to $PROJECT_ROOT" + echo "Path can be absolute or relative to $SCRIPTS_ROOT" else - cd $PROJECT_ROOT && java -jar $PROJECT_ROOT/target/metron-rest-$METRON_VERSION.jar --spring.config.location=$1 + if [ -z "$MYSQL_CLIENT_HOME" ]; then + echo MYSQL_CLIENT_HOME is not set + else + if [ -z "$HIBERNATE_HOME" ]; then + echo HIBERNATE_HOME is not set + else + java -Dloader.path=$MYSQL_CLIENT_HOME/*,$HIBERNATE_HOME/lib/envers/*,$HIBERNATE_HOME/lib/jpa/*,$HIBERNATE_HOME/lib/required/* -jar $SCRIPTS_ROOT/../lib/metron-rest-$METRON_VERSION.jar --spring.config.location=$1 + fi + fi fi \ No newline at end of file From a91ce504ed0bd5bcc0fa98e77c6953f44b58bc23 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 9 Dec 2016 14:38:23 -0600 Subject: [PATCH 14/54] Created LICENSE/NOTICE files and made small adjustment to the README. --- metron-interface/metron-rest/README.md | 4 +- .../src/main/resources/META-INF/LICENSE | 692 ++++++++++++++++++ .../src/main/resources/META-INF/NOTICE | 6 + 3 files changed, 700 insertions(+), 2 deletions(-) create mode 100644 metron-interface/metron-rest/src/main/resources/META-INF/LICENSE create mode 100644 metron-interface/metron-rest/src/main/resources/META-INF/NOTICE diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index 3c37b8f603..af9bba5e63 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -35,7 +35,7 @@ This UI exposes and aids in sensor configuration. CREATE DATABASE IF NOT EXISTS metronrest ``` -1. Create an `application.yml` file with the contents of [application-docker.yml](src/main/resource/application-docker.yml). Substitute the appropriate Metron service urls (Kafka, Zookeeper, Storm, etc) in properties containing `${docker.host.address}` and update the `spring.datasource.username` and `spring.datasource.password` properties using the MySQL credentials from step 4. +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.username` and `spring.datasource.password` properties using the MySQL credentials from step 4. 1. Start the UI with this command: ``` @@ -44,7 +44,7 @@ This UI exposes and aids in sensor configuration. ## Usage -The exposed REST endpoints can be accessed at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. +The exposed REST endpoints can be accessed at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. The Config UI can be accessed at http://host:port:8080 with credentials user/password. ## License diff --git a/metron-interface/metron-rest/src/main/resources/META-INF/LICENSE b/metron-interface/metron-rest/src/main/resources/META-INF/LICENSE new file mode 100644 index 0000000000..c9d4b53cad --- /dev/null +++ b/metron-interface/metron-rest/src/main/resources/META-INF/LICENSE @@ -0,0 +1,692 @@ +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +------------------------------------------------------------------------------------ +------------------------------------------------------------------------------------ + DOM4J +------------------------------------------------------------------------------------ + +This product bundles dom4j 1.6.1. For details, see https://github.com/dom4j/dom4j. + +Copyright 2001-2016 (C) MetaStuff, Ltd. and DOM4J contributors. All Rights Reserved. + +Redistribution and use of this software and associated documentation +("Software"), with or without modification, are permitted provided +that the following conditions are met: + +1. Redistributions of source code must retain copyright + statements and notices. Redistributions must also contain a + copy of this document. + +2. Redistributions in binary form must reproduce the + above copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +3. The name "DOM4J" must not be used to endorse or promote + products derived from this Software without prior written + permission of MetaStuff, Ltd. For written permission, + please contact dom4j-info@metastuff.com. + +4. Products derived from this Software may not be called "DOM4J" + nor may "DOM4J" appear in their names without prior written + permission of MetaStuff, Ltd. DOM4J is a registered + trademark of MetaStuff, Ltd. + +5. Due credit should be given to the DOM4J Project - https://dom4j.github.io/ + +THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS +``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +METASTUFF, LTD. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------------ + EPL +------------------------------------------------------------------------------------ + +This product bundles aspectjweaver 1.8.9, which is available under a "Eclipse Public License - v 1.0" license. For details, see https://eclipse.org/aspectj. + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT’S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i)changes to the Program, and + +ii)additions to the Program; + +where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor’s behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient’s responsibility to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. +Contributors may not remove or alter any copyright notices contained within the Program. + +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor’s responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient’s patent(s), then such Recipient’s rights granted under Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient’s rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient’s rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient’s obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. + +------------------------------------------------------------------------------------ + BSD +------------------------------------------------------------------------------------ + +This product bundles antlr 2.7.7, which is available under a "BSD Software License" license. For details, see http://www.antlr2.org + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +------------------------------------------------------------------------------------ + CDDL v1.0 +------------------------------------------------------------------------------------ + +This product bundles javax.transaction-api 1.2, which is available under a "Common Development and Distribution License v1.0" license. For details, see https://java.net/projects/jta-spec/ + +COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 + 1. Definitions. + 1.1. "Contributor" means each individual or entity that + creates or contributes to the creation of Modifications. + 1.2. "Contributor Version" means the combination of the + Original Software, prior Modifications used by a + Contributor (if any), and the Modifications made by that + particular Contributor. + 1.3. "Covered Software" means (a) the Original Software, or + (b) Modifications, or (c) the combination of files + containing Original Software with files containing + Modifications, in each case including portions thereof. + 1.4. "Executable" means the Covered Software in any form + other than Source Code. + 1.5. "Initial Developer" means the individual or entity + that first makes Original Software available under this + License. + 1.6. "Larger Work" means a work which combines Covered + Software or portions thereof with code not governed by the + terms of this License. + 1.7. "License" means this document. + 1.8. "Licensable" means having the right to grant, to the + maximum extent possible, whether at the time of the initial + grant or subsequently acquired, any and all of the rights + conveyed herein. + 1.9. "Modifications" means the Source Code and Executable + form of any of the following: + A. Any file that results from an addition to, + deletion from or modification of the contents of a + file containing Original Software or previous + Modifications; + B. Any new file that contains any part of the + Original Software or previous Modification; or + C. Any new file that is contributed or otherwise made + available under the terms of this License. + 1.10. "Original Software" means the Source Code and + Executable form of computer software code that is + originally released under this License. + 1.11. "Patent Claims" means any patent claim(s), now owned + or hereafter acquired, including without limitation, + method, process, and apparatus claims, in any patent + Licensable by grantor. + 1.12. "Source Code" means (a) the common form of computer + software code in which modifications are made and (b) + associated documentation included in or with such code. + 1.13. "You" (or "Your") means an individual or a legal + entity exercising rights under, and complying with all of + the terms of, this License. For legal entities, "You" + includes any entity which controls, is controlled by, or is + under common control with You. For purposes of this + definition, "control" means (a) the power, direct or + indirect, to cause the direction or management of such + entity, whether by contract or otherwise, or (b) ownership + of more than fifty percent (50%) of the outstanding shares + or beneficial ownership of such entity. + 2. License Grants. + 2.1. The Initial Developer Grant. + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, the + Initial Developer hereby grants You a world-wide, + royalty-free, non-exclusive license: + (a) under intellectual property rights (other than + patent or trademark) Licensable by Initial Developer, + to use, reproduce, modify, display, perform, + sublicense and distribute the Original Software (or + portions thereof), with or without Modifications, + and/or as part of a Larger Work; and + (b) under Patent Claims infringed by the making, + using or selling of Original Software, to make, have + made, use, practice, sell, and offer for sale, and/or + otherwise dispose of the Original Software (or + portions thereof). + (c) The licenses granted in Sections 2.1(a) and (b) + are effective on the date Initial Developer first + distributes or otherwise makes the Original Software + available to a third party under the terms of this + License. + (d) Notwithstanding Section 2.1(b) above, no patent + license is granted: (1) for code that You delete from + the Original Software, or (2) for infringements + caused by: (i) the modification of the Original + Software, or (ii) the combination of the Original + Software with other software or devices. + 2.2. Contributor Grant. + Conditioned upon Your compliance with Section 3.1 below and + subject to third party intellectual property claims, each + Contributor hereby grants You a world-wide, royalty-free, + non-exclusive license: + (a) under intellectual property rights (other than + patent or trademark) Licensable by Contributor to + use, reproduce, modify, display, perform, sublicense + and distribute the Modifications created by such + Contributor (or portions thereof), either on an + unmodified basis, with other Modifications, as + Covered Software and/or as part of a Larger Work; and + (b) under Patent Claims infringed by the making, + using, or selling of Modifications made by that + Contributor either alone and/or in combination with + its Contributor Version (or portions of such + combination), to make, use, sell, offer for sale, + have made, and/or otherwise dispose of: (1) + Modifications made by that Contributor (or portions + thereof); and (2) the combination of Modifications + made by that Contributor with its Contributor Version + (or portions of such combination). + (c) The licenses granted in Sections 2.2(a) and + 2.2(b) are effective on the date Contributor first + distributes or otherwise makes the Modifications + available to a third party. + (d) Notwithstanding Section 2.2(b) above, no patent + license is granted: (1) for any code that Contributor + has deleted from the Contributor Version; (2) for + infringements caused by: (i) third party + modifications of Contributor Version, or (ii) the + combination of Modifications made by that Contributor + with other software (except as part of the + Contributor Version) or other devices; or (3) under + Patent Claims infringed by Covered Software in the + absence of Modifications made by that Contributor. + 3. Distribution Obligations. + 3.1. Availability of Source Code. + Any Covered Software that You distribute or otherwise make + available in Executable form must also be made available in + Source Code form and that Source Code form must be + distributed only under the terms of this License. You must + include a copy of this License with every copy of the + Source Code form of the Covered Software You distribute or + otherwise make available. You must inform recipients of any + such Covered Software in Executable form as to how they can + obtain such Covered Software in Source Code form in a + reasonable manner on or through a medium customarily used + for software exchange. + 3.2. Modifications. + The Modifications that You create or to which You + contribute are governed by the terms of this License. You + represent that You believe Your Modifications are Your + original creation(s) and/or You have sufficient rights to + grant the rights conveyed by this License. + 3.3. Required Notices. + You must include a notice in each of Your Modifications + that identifies You as the Contributor of the Modification. + You may not remove or alter any copyright, patent or + trademark notices contained within the Covered Software, or + any notices of licensing or any descriptive text giving + attribution to any Contributor or the Initial Developer. + 3.4. Application of Additional Terms. + You may not offer or impose any terms on any Covered + Software in Source Code form that alters or restricts the + applicable version of this License or the recipients' + rights hereunder. You may choose to offer, and to charge a + fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Software. + However, you may do so only on Your own behalf, and not on + behalf of the Initial Developer or any Contributor. You + must make it absolutely clear that any such warranty, + support, indemnity or liability obligation is offered by + You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred + by the Initial Developer or such Contributor as a result of + warranty, support, indemnity or liability terms You offer. + 3.5. Distribution of Executable Versions. + You may distribute the Executable form of the Covered + Software under the terms of this License or under the terms + of a license of Your choice, which may contain terms + different from this License, provided that You are in + compliance with the terms of this License and that the + license for the Executable form does not attempt to limit + or alter the recipient's rights in the Source Code form + from the rights set forth in this License. If You + distribute the Covered Software in Executable form under a + different license, You must make it absolutely clear that + any terms which differ from this License are offered by You + alone, not by the Initial Developer or Contributor. You + hereby agree to indemnify the Initial Developer and every + Contributor for any liability incurred by the Initial + Developer or such Contributor as a result of any such terms + You offer. + 3.6. Larger Works. + You may create a Larger Work by combining Covered Software + with other code not governed by the terms of this License + and distribute the Larger Work as a single product. In such + a case, You must make sure the requirements of this License + are fulfilled for the Covered Software. + 4. Versions of the License. + 4.1. New Versions. + Sun Microsystems, Inc. is the initial license steward and + may publish revised and/or new versions of this License + from time to time. Each version will be given a + distinguishing version number. Except as provided in + Section 4.3, no one other than the license steward has the + right to modify this License. + 4.2. Effect of New Versions. + You may always continue to use, distribute or otherwise + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. If the Initial Developer includes a + notice in the Original Software prohibiting it from being + distributed or otherwise made available under any + subsequent version of the License, You must distribute and + make the Covered Software available under the terms of the + version of the License under which You originally received + the Covered Software. Otherwise, You may also choose to + use, distribute or otherwise make the Covered Software + available under the terms of any subsequent version of the + License published by the license steward. + 4.3. Modified Versions. + When You are an Initial Developer and You want to create a + new license for Your Original Software, You may create and + use a modified version of this License if You: (a) rename + the license and remove any references to the name of the + license steward (except to note that the license differs + from this License); and (b) otherwise make it clear that + the license contains terms which differ from this License. + 5. DISCLAIMER OF WARRANTY. + COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" + BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED + SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR + PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND + PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY + COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE + INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF + ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF + WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS + DISCLAIMER. + 6. TERMINATION. + 6.1. This License and the rights granted hereunder will + terminate automatically if You fail to comply with terms + herein and fail to cure such breach within 30 days of + becoming aware of the breach. Provisions which, by their + nature, must remain in effect beyond the termination of + this License shall survive. + 6.2. If You assert a patent infringement claim (excluding + declaratory judgment actions) against Initial Developer or + a Contributor (the Initial Developer or Contributor against + whom You assert such claim is referred to as "Participant") + alleging that the Participant Software (meaning the + Contributor Version where the Participant is a Contributor + or the Original Software where the Participant is the + Initial Developer) directly or indirectly infringes any + patent, then any and all rights granted directly or + indirectly to You by such Participant, the Initial + Developer (if the Initial Developer is not the Participant) + and all Contributors under Sections 2.1 and/or 2.2 of this + License shall, upon 60 days notice from Participant + terminate prospectively and automatically at the expiration + of such 60 day notice period, unless if within such 60 day + period You withdraw Your claim with respect to the + Participant Software against such Participant either + unilaterally or pursuant to a written agreement with + Participant. + 6.3. In the event of termination under Sections 6.1 or 6.2 + above, all end user licenses that have been validly granted + by You or any distributor hereunder prior to termination + (excluding licenses granted to You by any distributor) + shall survive termination. + 7. LIMITATION OF LIABILITY. + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE + INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF + COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE + LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR + CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT + LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK + STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL + INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT + APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO + NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR + CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT + APPLY TO YOU. + 8. U.S. GOVERNMENT END USERS. + The Covered Software is a "commercial item," as that term is + defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial + computer software" (as that term is defined at 48 C.F.R. ¤ + 252.227-7014(a)(1)) and "commercial computer software + documentation" as such terms are used in 48 C.F.R. 12.212 (Sept. + 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 + through 227.7202-4 (June 1995), all U.S. Government End Users + acquire Covered Software with only those rights set forth herein. + This U.S. Government Rights clause is in lieu of, and supersedes, + any other FAR, DFAR, or other clause or provision that addresses + Government rights in computer software under this License. + 9. MISCELLANEOUS. + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the + extent necessary to make it enforceable. This License shall be + governed by the law of the jurisdiction specified in a notice + contained within the Original Software (except to the extent + applicable law, if any, provides otherwise), excluding such + jurisdiction's conflict-of-law provisions. Any litigation + relating to this License shall be subject to the jurisdiction of + the courts located in the jurisdiction and venue specified in a + notice contained within the Original Software, with the losing + party responsible for costs, including, without limitation, court + costs and reasonable attorneys' fees and expenses. The + application of the United Nations Convention on Contracts for the + International Sale of Goods is expressly excluded. Any law or + regulation which provides that the language of a contract shall + be construed against the drafter shall not apply to this License. + You agree that You alone are responsible for compliance with the + United States export administration regulations (and the export + control laws and regulation of any other countries) when You use, + distribute or otherwise make available any Covered Software. + 10. RESPONSIBILITY FOR CLAIMS. + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or + indirectly, out of its utilization of rights under this License + and You agree to work with Initial Developer and Contributors to + distribute such responsibility on an equitable basis. Nothing + herein is intended or shall be deemed to constitute any admission + of liability. + +------------------------------------------------------------------------------------ + MIT +------------------------------------------------------------------------------------ + +This product bundles slf4j-api 1.7.21, which is available under a "MIT Software License" license. For details, see http://www.slf4j.org +This product bundles jcl-over-slf4j 1.7.21, which is available under a "MIT Software License" license. For details, see http://www.slf4j.org +This product bundles jul-to-slf4j 1.7.21, which is available under a "MIT Software License" license. For details, see http://www.slf4j.org +This product bundles lodash, which is available under a "MIT Software License" license. For details, see https://lodash.com/. + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/metron-interface/metron-rest/src/main/resources/META-INF/NOTICE b/metron-interface/metron-rest/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..aba445de14 --- /dev/null +++ b/metron-interface/metron-rest/src/main/resources/META-INF/NOTICE @@ -0,0 +1,6 @@ + +metron-rest +Copyright 2006-2016 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). From c91680007c2dd71ca590b615a1dc131efb6402ae Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 9 Dec 2016 15:43:52 -0600 Subject: [PATCH 15/54] Added license header to docker-compose.yml --- metron-docker/docker-compose.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/metron-docker/docker-compose.yml b/metron-docker/docker-compose.yml index 6161eca0c7..b0e026e8d9 100644 --- a/metron-docker/docker-compose.yml +++ b/metron-docker/docker-compose.yml @@ -1,3 +1,19 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# version: '2' services: mysql: From 6be6a0ac79931c3e5e55443646db5e0234818450 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 9 Dec 2016 16:34:50 -0600 Subject: [PATCH 16/54] Updated context paths and added assembly.xml file --- metron-interface/metron-rest/README.md | 8 ++- metron-interface/metron-rest/pom.xml | 21 -------- .../src/main/assembly/assembly.xml | 54 +++++++++++++++++++ .../controller/GlobalConfigController.java | 2 +- .../rest/controller/GrokController.java | 2 +- .../rest/controller/KafkaController.java | 2 +- .../SensorEnrichmentConfigController.java | 2 +- .../SensorParserConfigController.java | 2 +- .../SensorParserConfigHistoryController.java | 2 +- .../rest/controller/StormController.java | 2 +- .../controller/TransformationController.java | 2 +- .../rest/controller/UserController.java | 2 +- 12 files changed, 69 insertions(+), 32 deletions(-) create mode 100644 metron-interface/metron-rest/src/main/assembly/assembly.xml diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index af9bba5e63..33efeb9480 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -9,8 +9,12 @@ This UI exposes and aids in sensor configuration. * Java 8 installed ## Installation +1. Package the Application with Maven: + ``` + mvn clean package + ``` -1. Download and Unpack RPM. The directory structure will look like: +1. Untar the archive in the target directory. The directory structure will look like: ``` bin start.sh @@ -44,7 +48,7 @@ This UI exposes and aids in sensor configuration. ## Usage -The exposed REST endpoints can be accessed at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. The Config UI can be accessed at http://host:port:8080 with credentials user/password. +The exposed REST endpoints can be accessed at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. ## License diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index d43716f075..2c7ccd0c45 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -326,27 +326,6 @@ - - org.codehaus.mojo - exec-maven-plugin - 1.5.0 - - - install-config-ui - prepare-package - - exec - - - bash - ./src/main/scripts - - install_config_ui.sh - - - - - maven-assembly-plugin diff --git a/metron-interface/metron-rest/src/main/assembly/assembly.xml b/metron-interface/metron-rest/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..7a5dbeeb4b --- /dev/null +++ b/metron-interface/metron-rest/src/main/assembly/assembly.xml @@ -0,0 +1,54 @@ + + + + archive + + tar.gz + + false + + + ${project.basedir}/src/main/config + /config + true + + **/*.formatted + **/*.filtered + + 0644 + unix + true + + + ${project.basedir}/src/main/scripts + /bin + true + + **/*.formatted + **/*.filtered + + 0755 + unix + true + + + ${project.basedir}/target + + ${project.artifactId}-${project.version}.jar + + /lib + true + + + diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java index 03af1b09c8..4b72249433 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java @@ -29,7 +29,7 @@ import java.util.Map; @RestController -@RequestMapping("/globalConfig") +@RequestMapping("/api/v1/globalConfig") public class GlobalConfigController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java index e67f13f99c..eb75efef68 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java @@ -30,7 +30,7 @@ import java.util.Map; @RestController -@RequestMapping("/grok") +@RequestMapping("/api/v1/grok") public class GrokController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java index 019847bddc..07caf01cb7 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java @@ -31,7 +31,7 @@ import java.util.Set; @RestController -@RequestMapping("/kafka") +@RequestMapping("/api/v1/kafka") public class KafkaController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java index e265fac4c2..a8713ed4f1 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java @@ -31,7 +31,7 @@ import java.util.List; @RestController -@RequestMapping("/sensorEnrichmentConfig") +@RequestMapping("/api/v1/sensorEnrichmentConfig") public class SensorEnrichmentConfigController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java index 8f65a56212..4220ad7e54 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java @@ -33,7 +33,7 @@ import java.util.Map; @RestController -@RequestMapping("/sensorParserConfig") +@RequestMapping("/api/v1/sensorParserConfig") public class SensorParserConfigController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java index 88827d58c1..ae79b86591 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java @@ -30,7 +30,7 @@ import java.util.List; @RestController -@RequestMapping("/sensorParserConfigHistory") +@RequestMapping("/api/v1/sensorParserConfigHistory") public class SensorParserConfigHistoryController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java index 51e3926dfc..b54f9496f4 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java @@ -33,7 +33,7 @@ import java.util.Map; @RestController -@RequestMapping("/storm") +@RequestMapping("/api/v1/storm") public class StormController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java index 5f29e5ce3d..971740f358 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java @@ -33,7 +33,7 @@ import java.util.Map; @RestController -@RequestMapping("/transformation") +@RequestMapping("/api/v1/transformation") public class TransformationController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java index 579936d50f..a6257b4c93 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java @@ -25,7 +25,7 @@ @RestController public class UserController { - @RequestMapping("/user") + @RequestMapping("/api/v1/user") public String user(Principal user) { return user.getName(); } From 786aa97664fb5e2b5ab6b8ffba9ce79436c212da Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 12 Dec 2016 13:20:24 -0600 Subject: [PATCH 17/54] Changes based on PR feedback: - hbase config is now read from Storm classpath instead of hbase jar - removed global config push from kafkazk init script - added license to hbase/bin/init-commands.txt - improved data generator script and updated documentation --- metron-docker/.gitignore | 3 ++ metron-docker/README.md | 28 +++++++++++++++++-- metron-docker/docker-compose.yml | 1 + metron-docker/hbase/bin/init-commands.txt | 17 +++++++++++ metron-docker/kafkazk/bin/init-zk.sh | 1 - .../bin/output-data.sh} | 22 +++++++++++++-- metron-docker/kafkazk/bin/produce-data.sh | 23 +++++---------- metron-docker/storm/Dockerfile | 4 --- metron-docker/storm/bin/start.sh | 19 ------------- pom.xml | 1 - 10 files changed, 74 insertions(+), 45 deletions(-) rename metron-docker/{storm/bin/init-storm.sh => kafkazk/bin/output-data.sh} (75%) delete mode 100755 metron-docker/storm/bin/start.sh diff --git a/metron-docker/.gitignore b/metron-docker/.gitignore index 7488ceca74..b3119c64eb 100644 --- a/metron-docker/.gitignore +++ b/metron-docker/.gitignore @@ -4,3 +4,6 @@ /storm/enrichment /storm/parser /storm/indexing +/kafkazk/data/* +!/kafkazk/data/BroExampleOutput.txt +!/kafkazk/data/SquidExampleOutput.txt \ No newline at end of file diff --git a/metron-docker/README.md b/metron-docker/README.md index c54cb2e1c5..c5a0d1f520 100644 --- a/metron-docker/README.md +++ b/metron-docker/README.md @@ -47,7 +47,7 @@ eval "$(docker-machine env metron-machine)" Usage ----- -The Metron Docker environment lifecycle is controlled by the [docker-compose](https://docs.docker.com/compose/reference/overview/) command. For example, to build the environment run this command: +The Metron Docker environment lifecycle is controlled by the [docker-compose](https://docs.docker.com/compose/reference/overview/) command. These service names can be found in the docker-compose.yml file. For example, to build the environment run this command: ``` docker-compose up -d ``` @@ -65,4 +65,28 @@ If there is a problem with Kafka, run this command to connect and explore the Ka docker-compose exec kafkazk bash ``` -These service names can be found in the docker-compose.yml file. \ No newline at end of file +A tool for producing test data in Kafka is included with the Kafka/Zookeeper image. It loops through lines in a test data file and outputs them to Kafka at the desired frequency. Create a test data file in `./kafkazk/data/` and rebuild the Kafka/Zookeeper image: +``` +printf 'first test data\nsecond test data\nthird test data\n' > ./kafkazk/data/TestData.txt +docker-compose down +docker-compose build kafkazk +docker-compose up -d +``` + +This will deploy the test data file to the Kafka/Zookeeper container. Now that data can be streamed to a Kafka topic: +``` +docker-compose exec kafkazk ./bin/produce-data.sh +Usage: produce-data.sh data_path topic [message_delay_in_seconds] + +# Stream data in TestData.txt to the 'test' Kafka topic at a frequency of 5 seconds (default is 1 second) +docker-compose exec kafkazk ./bin/produce-data.sh /data/TestData.txt test 5 +``` + +The Kafka/Zookeeper image comes with sample Bro and Squid data: +``` +# Stream Bro test data every 1 second +docker-compose exec kafkazk ./bin/produce-data.sh /data/BroExampleOutput.txt bro + +# Stream Squid test data every 0.1 seconds +docker-compose exec kafkazk ./bin/produce-data.sh /data/SquidExampleOutput.txt squid 0.1 +``` \ No newline at end of file diff --git a/metron-docker/docker-compose.yml b/metron-docker/docker-compose.yml index b0e026e8d9..09779d2490 100644 --- a/metron-docker/docker-compose.yml +++ b/metron-docker/docker-compose.yml @@ -55,6 +55,7 @@ services: - "8081:8081" environment: ZOOKEEPER_ADDR: kafkazk + CONFIG_TOPOLOGY_CLASSPATH: /opt/hbase-1.1.6/conf volumes_from: - hbase depends_on: diff --git a/metron-docker/hbase/bin/init-commands.txt b/metron-docker/hbase/bin/init-commands.txt index 31ce0f39cf..9bdf61fdf1 100755 --- a/metron-docker/hbase/bin/init-commands.txt +++ b/metron-docker/hbase/bin/init-commands.txt @@ -1,3 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# create 'access_tracker', 'cf' create 'ip', 'cf' create 'enrichment', 'cf' diff --git a/metron-docker/kafkazk/bin/init-zk.sh b/metron-docker/kafkazk/bin/init-zk.sh index 7dd4ab214e..14e9caccd0 100755 --- a/metron-docker/kafkazk/bin/init-zk.sh +++ b/metron-docker/kafkazk/bin/init-zk.sh @@ -17,6 +17,5 @@ # echo "create /metron metron" | ./bin/zookeeper-shell.sh localhost:2181 echo "create /metron/topology topology" | ./bin/zookeeper-shell.sh localhost:2181 -echo 'create /metron/topology/global {"solr.zookeeper":"metron-kafkazk:2181","solr.collection":"metron","solr.numShards":1,"solr.replicationFactor":1,"es.clustername":"elasticsearch","es.ip":"metron-elasticsearch","es.port":"9300","es.date.format":"yyyy.MM.dd.HH"}' | ./bin/zookeeper-shell.sh localhost:2181 echo "create /metron/topology/parsers parsers" | ./bin/zookeeper-shell.sh localhost:2181 echo "create /metron/topology/enrichments enrichments" | ./bin/zookeeper-shell.sh localhost:2181 diff --git a/metron-docker/storm/bin/init-storm.sh b/metron-docker/kafkazk/bin/output-data.sh similarity index 75% rename from metron-docker/storm/bin/init-storm.sh rename to metron-docker/kafkazk/bin/output-data.sh index 9c1916b574..1ed3b37bbf 100755 --- a/metron-docker/storm/bin/init-storm.sh +++ b/metron-docker/kafkazk/bin/output-data.sh @@ -15,5 +15,23 @@ # See the License for the specific language governing permissions and # limitations under the License. # -METRON_VERSION=0.3.0 -cd /opt/hbase-1.1.6/conf && jar uf $METRON_HOME/lib/metron-enrichment-$METRON_VERSION-uber.jar hbase-site.xml +trap trapint 2 +function trapint { + exit 0 +} +if [ $# -ne 2 ] + then + echo "Usage: output-data.sh data_path [message_delay_in_seconds]" + exit 0 +fi + +FILE_PATH=$1 +DELAY=$2 +while : +do +cat $FILE_PATH | while read line +do +echo "$line" +sleep $DELAY +done +done diff --git a/metron-docker/kafkazk/bin/produce-data.sh b/metron-docker/kafkazk/bin/produce-data.sh index ff62e94bfc..e12b1bb1c6 100755 --- a/metron-docker/kafkazk/bin/produce-data.sh +++ b/metron-docker/kafkazk/bin/produce-data.sh @@ -15,23 +15,14 @@ # See the License for the specific language governing permissions and # limitations under the License. # -trap trapint 2 -function trapint { - exit 0 -} -if [ $# -ne 2 ] +if [ $# -lt 2 ] then - echo "Usage: produce-data.sh " + echo "Usage: produce-data.sh data_path topic [message_delay_in_seconds]" exit 0 fi -TOPIC=$1 -FILE_PATH=$2 -while : -do -cat $FILE_PATH | while read line -do -echo "Emitting data in $FILE_PATH to Kafka topic $TOPIC" -echo "$line" | ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic $TOPIC > /dev/null -done -done +FILE_PATH=$1 +TOPIC=$2 +DELAY=${3:-1} +echo "Emitting data in $FILE_PATH to Kafka topic $TOPIC every $DELAY second(s)" +exec ./bin/output-data.sh $FILE_PATH $DELAY | ./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic $TOPIC > /dev/null diff --git a/metron-docker/storm/Dockerfile b/metron-docker/storm/Dockerfile index a9fd1de5b0..1b576a2eb9 100644 --- a/metron-docker/storm/Dockerfile +++ b/metron-docker/storm/Dockerfile @@ -21,7 +21,6 @@ ARG METRON_VERSION ENV METRON_VERSION $METRON_VERSION ENV METRON_HOME /usr/metron/$METRON_VERSION/ -ADD ./bin /usr/local/bin ADD ./parser /parser ADD ./enrichment /enrichment ADD ./indexing /indexing @@ -53,6 +52,3 @@ RUN sed -i -e "s/bolt.hdfs.file.system.url=.*:8020/bolt.hdfs.file.system.url=fil EXPOSE 8080 8000 EXPOSE 8081 8081 - -WORKDIR /usr/local -ENTRYPOINT ["/bin/bash", "./bin/start.sh"] diff --git a/metron-docker/storm/bin/start.sh b/metron-docker/storm/bin/start.sh deleted file mode 100755 index e77bb8d6c6..0000000000 --- a/metron-docker/storm/bin/start.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -cd /opt/hbase-1.1.6/conf && jar uf $METRON_HOME/lib/metron-enrichment-$METRON_VERSION-uber.jar hbase-site.xml -/home/storm/entrypoint.sh $@ diff --git a/pom.xml b/pom.xml index 659380c55b..f2dce7470b 100644 --- a/pom.xml +++ b/pom.xml @@ -264,7 +264,6 @@ **/packer_cache/** **/hbase/data/** - **/hbase/bin/init-commands.txt **/kafkazk/data/** **/wait-for-it.sh From 385bcb0821ea1f536c6dc48881eb0eff2c7f7df4 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 12 Dec 2016 14:06:19 -0600 Subject: [PATCH 18/54] Updated flatfile_loader.sh to only depend on HBase --- metron-docker/.gitignore | 2 +- metron-docker/hbase/bin/init-hbase.sh | 5 ++--- .../src/main/scripts/flatfile_loader.sh | 9 +-------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/metron-docker/.gitignore b/metron-docker/.gitignore index b3119c64eb..c46d09aab2 100644 --- a/metron-docker/.gitignore +++ b/metron-docker/.gitignore @@ -6,4 +6,4 @@ /storm/indexing /kafkazk/data/* !/kafkazk/data/BroExampleOutput.txt -!/kafkazk/data/SquidExampleOutput.txt \ No newline at end of file +!/kafkazk/data/SquidExampleOutput.txt diff --git a/metron-docker/hbase/bin/init-hbase.sh b/metron-docker/hbase/bin/init-hbase.sh index bbe1716918..8b2d1d3db9 100755 --- a/metron-docker/hbase/bin/init-hbase.sh +++ b/metron-docker/hbase/bin/init-hbase.sh @@ -15,7 +15,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # -export HBASE_CLASSPATH=`${HBASE_HOME}/bin/hbase classpath` ./bin/hbase shell ./bin/init-commands.txt -java -cp $HBASE_CLASSPATH:/usr/metron/$METRON_VERSION/lib/metron-data-management-$METRON_VERSION.jar org.apache.metron.dataloads.nonbulk.flatfile.SimpleEnrichmentFlatFileLoader -e /conf/enrichment-extractor.json -t enrichment -c cf -i /data/enrichments.csv -java -cp $HBASE_CLASSPATH:/usr/metron/$METRON_VERSION/lib/metron-data-management-$METRON_VERSION.jar org.apache.metron.dataloads.nonbulk.flatfile.SimpleEnrichmentFlatFileLoader -e /conf/threatintel-extractor.json -t threatintel -c cf -i /data/threatintel.csv +/usr/metron/$METRON_VERSION/bin/flatfile_loader.sh -e /conf/enrichment-extractor.json -t enrichment -c cf -i /data/enrichments.csv +/usr/metron/$METRON_VERSION/bin/flatfile_loader.sh -e /conf/threatintel-extractor.json -t threatintel -c cf -i /data/threatintel.csv diff --git a/metron-platform/metron-data-management/src/main/scripts/flatfile_loader.sh b/metron-platform/metron-data-management/src/main/scripts/flatfile_loader.sh index fe366844e9..bba7f8ef24 100755 --- a/metron-platform/metron-data-management/src/main/scripts/flatfile_loader.sh +++ b/metron-platform/metron-data-management/src/main/scripts/flatfile_loader.sh @@ -32,11 +32,4 @@ export METRON_VERSION=${project.version} export METRON_HOME=/usr/metron/$METRON_VERSION export DM_JAR=${project.artifactId}-$METRON_VERSION.jar CP=$METRON_HOME/lib/$DM_JAR:/usr/metron/${METRON_VERSION}/lib/taxii-1.1.0.1.jar:`${HBASE_HOME}/bin/hbase classpath` -HADOOP_CLASSPATH=$(echo $CP ) -for jar in $(echo $HADOOP_CLASSPATH | sed 's/:/ /g');do - if [ -f $jar ];then - LIBJARS="$jar,$LIBJARS" - fi -done -export HADOOP_CLASSPATH -hadoop jar $METRON_HOME/lib/$DM_JAR org.apache.metron.dataloads.nonbulk.flatfile.SimpleEnrichmentFlatFileLoader "$@" +java -cp $CP org.apache.metron.dataloads.nonbulk.flatfile.SimpleEnrichmentFlatFileLoader "$@" From 5d86575f46b1e2b75b140a19fb088e29b55b7fd8 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 12 Dec 2016 14:15:56 -0600 Subject: [PATCH 19/54] Fixed rest database name --- metron-docker/mysql/bin/init-mysql.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metron-docker/mysql/bin/init-mysql.sh b/metron-docker/mysql/bin/init-mysql.sh index 8aab2b5842..40f085c76e 100755 --- a/metron-docker/mysql/bin/init-mysql.sh +++ b/metron-docker/mysql/bin/init-mysql.sh @@ -15,5 +15,5 @@ # See the License for the specific language governing permissions and # limitations under the License. # -mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS metronconfig" +mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS metronrest" mysql -uroot -proot < /usr/metron/$METRON_VERSION/ddl/geoip_ddl.sql From edd4b872489fce58211add6c3baa96e0e9d2c008 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 16 Dec 2016 12:32:48 -0600 Subject: [PATCH 20/54] Changes based on PR feedback --- metron-interface/metron-rest/README.md | 321 +++++++++++++++++- metron-interface/metron-rest/pom.xml | 6 + .../controller/GlobalConfigController.java | 11 +- .../rest/controller/GrokController.java | 9 +- .../rest/controller/KafkaController.java | 21 +- .../SensorEnrichmentConfigController.java | 21 +- .../SensorParserConfigController.java | 25 +- .../SensorParserConfigHistoryController.java | 14 +- .../rest/controller/StormController.java | 64 +++- .../controller/TransformationController.java | 19 +- .../rest/controller/UserController.java | 4 + .../metron/rest/service/GrokService.java | 29 +- .../SensorEnrichmentConfigService.java | 1 - .../service/SensorParserConfigService.java | 10 +- .../rest/service/TransformationService.java | 31 +- .../src/main/resources/application-docker.yml | 4 +- .../src/main/resources/application-test.yml | 4 +- .../src/main/resources/application.yml | 5 + ...chmentConfigControllerIntegrationTest.java | 3 +- ...ParserConfigControllerIntegrationTest.java | 25 +- ...onfigHistoryControllerIntegrationTest.java | 11 +- .../apache/metron/rest/utils/ReadMeUtils.java | 115 +++++++ .../metron/rest/utils/RestControllerInfo.java | 74 ++++ .../metron-rest/src/test/resources/README.vm | 89 +++++ 24 files changed, 827 insertions(+), 89 deletions(-) create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/RestControllerInfo.java create mode 100644 metron-interface/metron-rest/src/test/resources/README.vm diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index 33efeb9480..d8286d14f8 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -5,8 +5,9 @@ This UI exposes and aids in sensor configuration. ## Prerequisites * A running Metron cluster -* A running instance of MySQL +* A running instance of MySQL * Java 8 installed +* Storm CLI and Metron topology scripts (start_parser_topology.sh, start_enrichment_topology.sh, start_elasticsearch_topology.sh) installed ## Installation 1. Package the Application with Maven: @@ -14,7 +15,7 @@ This UI exposes and aids in sensor configuration. mvn clean package ``` -1. Untar the archive in the target directory. The directory structure will look like: +1. Untar the archive in the target directory. The directory structure will look like: ``` bin start.sh @@ -31,14 +32,14 @@ This UI exposes and aids in sensor configuration. ``` export MYSQL_CLIENT_HOME=/path/to/mysql-connector-java-5.1.40 ``` - + 1. Create a MySQL user for the Config UI (http://dev.mysql.com/doc/refman/5.7/en/adding-users.html). 1. Create a Config UI database in MySQL with this command: ``` CREATE DATABASE IF NOT EXISTS metronrest ``` - + 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.username` and `spring.datasource.password` properties using the MySQL credentials from step 4. 1. Start the UI with this command: @@ -48,8 +49,316 @@ This UI exposes and aids in sensor configuration. ## Usage -The exposed REST endpoints can be accessed at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. +The exposed REST endpoints can be accessed with the Swagger UI at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. Users can be added with this SQL statement: +``` +use metronrest; +insert into users (username, password, enabled) values ('your_username','your_password',1); +insert into authorities (username, authority) values ('your_username', 'ROLE_USER'); +``` +Users can be added to additional groups with this SQL statement: +``` +use metronrest; +insert into authorities (username, authority) values ('your_username', 'your_group'); +``` + +## API + +Request and Response objects are JSON formatted. The JSON schemas are available in the Swagger UI. + +| | +| ---------- | +| [ `GET /api/v1/globalConfig`](#get-/api/v1/globalconfig)| +| [ `DELETE /api/v1/globalConfig`](#delete-/api/v1/globalconfig)| +| [ `POST /api/v1/globalConfig`](#post-/api/v1/globalconfig)| +| [ `GET /api/v1/grok/list`](#get-/api/v1/grok/list)| +| [ `POST /api/v1/grok/validate`](#post-/api/v1/grok/validate)| +| [ `GET /api/v1/kafka/topic`](#get-/api/v1/kafka/topic)| +| [ `POST /api/v1/kafka/topic`](#post-/api/v1/kafka/topic)| +| [ `GET /api/v1/kafka/topic/{name}`](#get-/api/v1/kafka/topic/{name})| +| [ `DELETE /api/v1/kafka/topic/{name}`](#delete-/api/v1/kafka/topic/{name})| +| [ `GET /api/v1/kafka/topic/{name}/sample`](#get-/api/v1/kafka/topic/{name}/sample)| +| [ `GET /api/v1/sensorEnrichmentConfig`](#get-/api/v1/sensorenrichmentconfig)| +| [ `GET /api/v1/sensorEnrichmentConfig/list/available`](#get-/api/v1/sensorenrichmentconfig/list/available)| +| [ `DELETE /api/v1/sensorEnrichmentConfig/{name}`](#delete-/api/v1/sensorenrichmentconfig/{name})| +| [ `POST /api/v1/sensorEnrichmentConfig/{name}`](#post-/api/v1/sensorenrichmentconfig/{name})| +| [ `GET /api/v1/sensorEnrichmentConfig/{name}`](#get-/api/v1/sensorenrichmentconfig/{name})| +| [ `POST /api/v1/sensorParserConfig`](#post-/api/v1/sensorparserconfig)| +| [ `GET /api/v1/sensorParserConfig`](#get-/api/v1/sensorparserconfig)| +| [ `GET /api/v1/sensorParserConfig/list/available`](#get-/api/v1/sensorparserconfig/list/available)| +| [ `POST /api/v1/sensorParserConfig/parseMessage`](#post-/api/v1/sensorparserconfig/parsemessage)| +| [ `GET /api/v1/sensorParserConfig/reload/available`](#get-/api/v1/sensorparserconfig/reload/available)| +| [ `DELETE /api/v1/sensorParserConfig/{name}`](#delete-/api/v1/sensorparserconfig/{name})| +| [ `GET /api/v1/sensorParserConfig/{name}`](#get-/api/v1/sensorparserconfig/{name})| +| [ `GET /api/v1/sensorParserConfigHistory`](#get-/api/v1/sensorparserconfighistory)| +| [ `GET /api/v1/sensorParserConfigHistory/history/{name}`](#get-/api/v1/sensorparserconfighistory/history/{name})| +| [ `GET /api/v1/sensorParserConfigHistory/{name}`](#get-/api/v1/sensorparserconfighistory/{name})| +| [ `GET /api/v1/storm`](#get-/api/v1/storm)| +| [ `GET /api/v1/storm/client/status`](#get-/api/v1/storm/client/status)| +| [ `GET /api/v1/storm/enrichment`](#get-/api/v1/storm/enrichment)| +| [ `GET /api/v1/storm/enrichment/activate`](#get-/api/v1/storm/enrichment/activate)| +| [ `GET /api/v1/storm/enrichment/deactivate`](#get-/api/v1/storm/enrichment/deactivate)| +| [ `GET /api/v1/storm/enrichment/start`](#get-/api/v1/storm/enrichment/start)| +| [ `GET /api/v1/storm/enrichment/stop`](#get-/api/v1/storm/enrichment/stop)| +| [ `GET /api/v1/storm/indexing`](#get-/api/v1/storm/indexing)| +| [ `GET /api/v1/storm/indexing/activate`](#get-/api/v1/storm/indexing/activate)| +| [ `GET /api/v1/storm/indexing/deactivate`](#get-/api/v1/storm/indexing/deactivate)| +| [ `GET /api/v1/storm/indexing/start`](#get-/api/v1/storm/indexing/start)| +| [ `GET /api/v1/storm/indexing/stop`](#get-/api/v1/storm/indexing/stop)| +| [ `GET /api/v1/storm/parser/activate/{name}`](#get-/api/v1/storm/parser/activate/{name})| +| [ `GET /api/v1/storm/parser/deactivate/{name}`](#get-/api/v1/storm/parser/deactivate/{name})| +| [ `GET /api/v1/storm/parser/start/{name}`](#get-/api/v1/storm/parser/start/{name})| +| [ `GET /api/v1/storm/parser/stop/{name}`](#get-/api/v1/storm/parser/stop/{name})| +| [ `GET /api/v1/storm/{name}`](#get-/api/v1/storm/{name})| +| [ `GET /api/v1/transformation/list`](#get-/api/v1/transformation/list)| +| [ `GET /api/v1/transformation/list/functions`](#get-/api/v1/transformation/list/functions)| +| [ `GET /api/v1/transformation/list/simple/functions`](#get-/api/v1/transformation/list/simple/functions)| +| [ `POST /api/v1/transformation/validate`](#post-/api/v1/transformation/validate)| +| [ `POST /api/v1/transformation/validate/rules`](#post-/api/v1/transformation/validate/rules)| +| [ `GET /api/v1/user`](#get-/api/v1/user)| + +### `GET /api/v1/globalConfig` + * Description: Retrieves the current Global Config from Zookeeper + * Returns: Current Global Config JSON in Zookeeper + +### `DELETE /api/v1/globalConfig` + * Description: Deletes the current Global Config from Zookeeper + * Returns: No return value + +### `POST /api/v1/globalConfig` + * Description: Creates or updates the Global Config in Zookeeper + * Input: + * globalConfig - The Global Config JSON to be saved + * Returns: Saved Global Config JSON + +### `GET /api/v1/grok/list` + * Description: Lists the common Grok statements available in Metron + * Returns: JSON object containing pattern label/Grok statements key value pairs + +### `POST /api/v1/grok/validate` + * Description: Applies a Grok statement to a sample message + * Input: + * grokValidation - Object containing Grok statment and sample message + * Returns: JSON results + +### `GET /api/v1/kafka/topic` + * Description: Retrieves all Kafka topics + * Returns: A list of all Kafka topics + +### `POST /api/v1/kafka/topic` + * Description: Creates a new Kafka topic + * Input: + * topic - Kafka topic + * Returns: Saved Kafka topic + +### `GET /api/v1/kafka/topic/{name}` + * Description: Retrieves a Kafka topic + * Input: + * name - Kafka topic name + * Returns: Kafka topic + +### `DELETE /api/v1/kafka/topic/{name}` + * Description: Delets a Kafka topic + * Input: + * name - Kafka topic name + * Returns: No return value + +### `GET /api/v1/kafka/topic/{name}/sample` + * Description: Retrieves a sample message from a Kafka topic using the most recent offset + * Input: + * name - Kafka topic name + * Returns: Sample message + +### `GET /api/v1/sensorEnrichmentConfig` + * Description: Retrieves all SensorEnrichmentConfigs from Zookeeper + * Returns: All SensorEnrichmentConfigs + +### `GET /api/v1/sensorEnrichmentConfig/list/available` + * Description: Lists the available enrichments + * Returns: List of available enrichments + +### `DELETE /api/v1/sensorEnrichmentConfig/{name}` + * Description: Deletes a SensorEnrichmentConfig from Zookeeper + * Input: + * name - SensorEnrichmentConfig name + * Returns: No return value + +### `POST /api/v1/sensorEnrichmentConfig/{name}` + * Description: Updates or creates a SensorEnrichmentConfig in Zookeeper + * Input: + * sensorEnrichmentConfig - SensorEnrichmentConfig + * name - SensorEnrichmentConfig name + * Returns: Saved SensorEnrichmentConfig + +### `GET /api/v1/sensorEnrichmentConfig/{name}` + * Description: Retrieves a SensorEnrichmentConfig from Zookeeper + * Input: + * name - SensorEnrichmentConfig name + * Returns: SensorEnrichmentConfig + +### `POST /api/v1/sensorParserConfig` + * Description: Updates or creates a SensorParserConfig in Zookeeper + * Input: + * sensorParserConfig - SensorParserConfig + * Returns: Saved SensorParserConfig + +### `GET /api/v1/sensorParserConfig` + * Description: Retrieves all SensorParserConfigs from Zookeeper + * Returns: All SensorParserConfigs + +### `GET /api/v1/sensorParserConfig/list/available` + * Description: Lists the available parser classes that can be found on the classpath + * Returns: List of available parser classes + +### `POST /api/v1/sensorParserConfig/parseMessage` + * Description: Parses a sample message given a SensorParserConfig + * Input: + * parseMessageRequest - Object containing a sample message and SensorParserConfig + * Returns: Parsed message + +### `GET /api/v1/sensorParserConfig/reload/available` + * Description: Scans the classpath for available parser classes and reloads the cached parser class list + * Returns: List of available parser classes + +### `DELETE /api/v1/sensorParserConfig/{name}` + * Description: Deletes a SensorParserConfig from Zookeeper + * Input: + * name - SensorParserConfig name + * Returns: No return value + +### `GET /api/v1/sensorParserConfig/{name}` + * Description: Retrieves a SensorParserConfig from Zookeeper + * Input: + * name - SensorParserConfig name + * Returns: SensorParserConfig + +### `GET /api/v1/sensorParserConfigHistory` + * Description: Retrieves all current versions of SensorParserConfigs including audit information + * Returns: SensorParserConfigs with audit information + +### `GET /api/v1/sensorParserConfigHistory/history/{name}` + * Description: Retrieves the history of all changes made to a SensorParserConfig + * Input: + * name - SensorParserConfig name + * Returns: SensorParserConfig history + +### `GET /api/v1/sensorParserConfigHistory/{name}` + * Description: Retrieves the current version of a SensorParserConfig including audit information + * Input: + * name - SensorParserConfig name + * Returns: SensorParserConfig with audit information + +### `GET /api/v1/storm` + * Description: Retrieves the status of all Storm topologies + * Returns: List of topologies with status information + +### `GET /api/v1/storm/client/status` + * Description: Retrieves information about the Storm command line client + * Returns: Storm command line client information + +### `GET /api/v1/storm/enrichment` + * Description: Retrieves the status of the Storm enrichment topology + * Returns: Topology status information + +### `GET /api/v1/storm/enrichment/activate` + * Description: Activates a Storm enrichment topology + * Returns: Activate response message + +### `GET /api/v1/storm/enrichment/deactivate` + * Description: Deactivates a Storm enrichment topology + * Returns: Deactivate response message + +### `GET /api/v1/storm/enrichment/start` + * Description: Starts a Storm enrichment topology + * Returns: Start response message + +### `GET /api/v1/storm/enrichment/stop` + * Description: Stops a Storm enrichment topology + * Input: + * stopNow - Stop the topology immediately + * Returns: Stop response message + +### `GET /api/v1/storm/indexing` + * Description: Retrieves the status of the Storm indexing topology + * Returns: Topology status information + +### `GET /api/v1/storm/indexing/activate` + * Description: Activates a Storm indexing topology + * Returns: Activate response message + +### `GET /api/v1/storm/indexing/deactivate` + * Description: Deactivates a Storm indexing topology + * Returns: Deactivate response message + +### `GET /api/v1/storm/indexing/start` + * Description: Starts a Storm indexing topology + * Returns: Start response message + +### `GET /api/v1/storm/indexing/stop` + * Description: Stops a Storm enrichment topology + * Input: + * stopNow - Stop the topology immediately + * Returns: Stop response message + +### `GET /api/v1/storm/parser/activate/{name}` + * Description: Activates a Storm parser topology + * Input: + * name - Parser name + * Returns: Activate response message + +### `GET /api/v1/storm/parser/deactivate/{name}` + * Description: Deactivates a Storm parser topology + * Input: + * name - Parser name + * Returns: Deactivate response message + +### `GET /api/v1/storm/parser/start/{name}` + * Description: Starts a Storm parser topology + * Input: + * name - Parser name + * Returns: Start response message + +### `GET /api/v1/storm/parser/stop/{name}` + * Description: Stops a Storm parser topology + * Input: + * name - Parser name + * stopNow - Stop the topology immediately + * Returns: Stop response message + +### `GET /api/v1/storm/{name}` + * Description: Retrieves the status of a Storm topology + * Input: + * name - Topology name + * Returns: Topology status information + +### `GET /api/v1/transformation/list` + * Description: Retrieves field transformations + * Returns: List field transformations + +### `GET /api/v1/transformation/list/functions` + * Description: Lists the Stellar functions that can be found on the classpath + * Returns: List of Stellar functions + +### `GET /api/v1/transformation/list/simple/functions` + * Description: Lists the simple Stellar functions (functions with only 1 input) that can be found on the classpath + * Returns: List of simple Stellar functions + +### `POST /api/v1/transformation/validate` + * Description: Executes transformations against a sample message + * Input: + * transformationValidation - Object containing SensorParserConfig and sample message + * Returns: Transformation results + +### `POST /api/v1/transformation/validate/rules` + * Description: Tests Stellar statements to ensure they are well-formed + * Input: + * statements - List of statements to validate + * Returns: Validation results + +### `GET /api/v1/user` + * Description: Retrieves the current user + * Returns: Current user + ## License -This project depends on the Java Transaction API. See https://java.net/projects/jta-spec/ for more details. \ No newline at end of file +This project depends on the Java Transaction API. See https://java.net/projects/jta-spec/ for more details. diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index 2c7ccd0c45..fa7647cd08 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -242,6 +242,12 @@ + + org.apache.velocity + velocity + 1.7 + test + diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java index 4b72249433..a95500997f 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java @@ -17,6 +17,9 @@ */ package org.apache.metron.rest.controller; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; import org.apache.metron.rest.service.GlobalConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -35,11 +38,15 @@ public class GlobalConfigController { @Autowired private GlobalConfigService globalConfigService; + @ApiOperation(value = "Creates or updates the Global Config in Zookeeper") + @ApiResponse(message = "Saved Global Config JSON", code = 200) @RequestMapping(method = RequestMethod.POST) - ResponseEntity> save(@RequestBody Map globalConfig) throws Exception { + ResponseEntity> save(@ApiParam(name="globalConfig", value="The Global Config JSON to be saved", required=true)@RequestBody Map globalConfig) throws Exception { return new ResponseEntity<>(globalConfigService.save(globalConfig), HttpStatus.CREATED); } + @ApiOperation(value = "Retrieves the current Global Config from Zookeeper") + @ApiResponse(message = "Current Global Config JSON in Zookeeper", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> get() throws Exception { Map globalConfig = globalConfigService.get(); @@ -50,6 +57,8 @@ ResponseEntity> get() throws Exception { } } + @ApiOperation(value = "Deletes the current Global Config from Zookeeper") + @ApiResponse(message = "No return value", code = 200) @RequestMapping(method = RequestMethod.DELETE) ResponseEntity delete() throws Exception { if (globalConfigService.delete()) { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java index eb75efef68..86f7e17e7b 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java @@ -17,6 +17,9 @@ */ package org.apache.metron.rest.controller; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; import org.apache.metron.rest.model.GrokValidation; import org.apache.metron.rest.service.GrokService; import org.springframework.beans.factory.annotation.Autowired; @@ -36,11 +39,15 @@ public class GrokController { @Autowired private GrokService grokService; + @ApiOperation(value = "Applies a Grok statement to a sample message") + @ApiResponse(message = "JSON results", code = 200) @RequestMapping(value = "/validate", method = RequestMethod.POST) - ResponseEntity post(@RequestBody GrokValidation grokValidation) throws Exception { + ResponseEntity post(@ApiParam(name="grokValidation", value="Object containing Grok statment and sample message", required=true)@RequestBody GrokValidation grokValidation) throws Exception { return new ResponseEntity<>(grokService.validateGrokStatement(grokValidation), HttpStatus.OK); } + @ApiOperation(value = "Lists the common Grok statements available in Metron") + @ApiResponse(message = "JSON object containing pattern label/Grok statements key value pairs", code = 200) @RequestMapping(value = "/list", method = RequestMethod.GET) ResponseEntity> list() throws Exception { return new ResponseEntity<>(grokService.getCommonGrokPatterns(), HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java index 07caf01cb7..e9513819fa 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java @@ -17,6 +17,9 @@ */ package org.apache.metron.rest.controller; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; import org.apache.metron.rest.model.KafkaTopic; import org.apache.metron.rest.service.KafkaService; import org.springframework.beans.factory.annotation.Autowired; @@ -37,13 +40,17 @@ public class KafkaController { @Autowired private KafkaService kafkaService; + @ApiOperation(value = "Creates a new Kafka topic") + @ApiResponse(message = "Saved Kafka topic", code = 200) @RequestMapping(value = "/topic", method = RequestMethod.POST) - ResponseEntity save(@RequestBody KafkaTopic topic) throws Exception { + ResponseEntity save(@ApiParam(name="topic", value="Kafka topic", required=true)@RequestBody KafkaTopic topic) throws Exception { return new ResponseEntity<>(kafkaService.createTopic(topic), HttpStatus.CREATED); } + @ApiOperation(value = "Retrieves a Kafka topic") + @ApiResponse(message = "Kafka topic", code = 200) @RequestMapping(value = "/topic/{name}", method = RequestMethod.GET) - ResponseEntity get(@PathVariable String name) throws Exception { + ResponseEntity get(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws Exception { KafkaTopic kafkaTopic = kafkaService.getTopic(name); if (kafkaTopic != null) { return new ResponseEntity<>(kafkaTopic, HttpStatus.OK); @@ -52,13 +59,17 @@ ResponseEntity get(@PathVariable String name) throws Exception { } } + @ApiOperation(value = "Retrieves all Kafka topics") + @ApiResponse(message = "A list of all Kafka topics", code = 200) @RequestMapping(value = "/topic", method = RequestMethod.GET) ResponseEntity> list() throws Exception { return new ResponseEntity<>(kafkaService.listTopics(), HttpStatus.OK); } + @ApiOperation(value = "Delets a Kafka topic") + @ApiResponse(message = "No return value", code = 200) @RequestMapping(value = "/topic/{name}", method = RequestMethod.DELETE) - ResponseEntity delete(@PathVariable String name) throws Exception { + ResponseEntity delete(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws Exception { if (kafkaService.deleteTopic(name)) { return new ResponseEntity<>(HttpStatus.OK); } else { @@ -66,8 +77,10 @@ ResponseEntity delete(@PathVariable String name) throws Exception { } } + @ApiOperation(value = "Retrieves a sample message from a Kafka topic using the most recent offset") + @ApiResponse(message = "Sample message", code = 200) @RequestMapping(value = "/topic/{name}/sample", method = RequestMethod.GET) - ResponseEntity getSample(@PathVariable String name) throws Exception { + ResponseEntity getSample(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws Exception { String sampleMessage = kafkaService.getSampleMessage(name); if (sampleMessage != null) { return new ResponseEntity<>(sampleMessage, HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java index a8713ed4f1..57075b3838 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java @@ -17,6 +17,9 @@ */ package org.apache.metron.rest.controller; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; import org.apache.metron.rest.service.SensorEnrichmentConfigService; import org.springframework.beans.factory.annotation.Autowired; @@ -37,13 +40,18 @@ public class SensorEnrichmentConfigController { @Autowired private SensorEnrichmentConfigService sensorEnrichmentConfigService; + @ApiOperation(value = "Updates or creates a SensorEnrichmentConfig in Zookeeper") + @ApiResponse(message = "Saved SensorEnrichmentConfig", code = 200) @RequestMapping(value = "/{name}", method = RequestMethod.POST) - ResponseEntity save(@PathVariable String name, @RequestBody SensorEnrichmentConfig sensorEnrichmentConfig) throws Exception { + ResponseEntity save(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name, + @ApiParam(name="sensorEnrichmentConfig", value="SensorEnrichmentConfig", required=true)@RequestBody SensorEnrichmentConfig sensorEnrichmentConfig) throws Exception { return new ResponseEntity<>(sensorEnrichmentConfigService.save(name, sensorEnrichmentConfig), HttpStatus.CREATED); } + @ApiOperation(value = "Retrieves a SensorEnrichmentConfig from Zookeeper") + @ApiResponse(message = "SensorEnrichmentConfig", code = 200) @RequestMapping(value = "/{name}", method = RequestMethod.GET) - ResponseEntity findOne(@PathVariable String name) throws Exception { + ResponseEntity findOne(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name) throws Exception { SensorEnrichmentConfig sensorEnrichmentConfig = sensorEnrichmentConfigService.findOne(name); if (sensorEnrichmentConfig != null) { return new ResponseEntity<>(sensorEnrichmentConfig, HttpStatus.OK); @@ -52,14 +60,17 @@ ResponseEntity findOne(@PathVariable String name) throws return new ResponseEntity<>(HttpStatus.NOT_FOUND); } - + @ApiOperation(value = "Retrieves all SensorEnrichmentConfigs from Zookeeper") + @ApiResponse(message = "All SensorEnrichmentConfigs", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> getAll() throws Exception { return new ResponseEntity<>(sensorEnrichmentConfigService.getAll(), HttpStatus.OK); } + @ApiOperation(value = "Deletes a SensorEnrichmentConfig from Zookeeper") + @ApiResponse(message = "No return value", code = 200) @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) - ResponseEntity delete(@PathVariable String name) throws Exception { + ResponseEntity delete(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name) throws Exception { if (sensorEnrichmentConfigService.delete(name)) { return new ResponseEntity<>(HttpStatus.OK); } else { @@ -67,6 +78,8 @@ ResponseEntity delete(@PathVariable String name) throws Exception { } } + @ApiOperation(value = "Lists the available enrichments") + @ApiResponse(message = "List of available enrichments", code = 200) @RequestMapping(value = "/list/available", method = RequestMethod.GET) ResponseEntity> getAvailable() throws Exception { return new ResponseEntity<>(sensorEnrichmentConfigService.getAvailableEnrichments(), HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java index 4220ad7e54..9f6111b2d1 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java @@ -17,6 +17,9 @@ */ package org.apache.metron.rest.controller; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; import org.apache.metron.common.configuration.SensorParserConfig; import org.apache.metron.rest.model.ParseMessageRequest; import org.apache.metron.rest.service.SensorParserConfigService; @@ -39,13 +42,17 @@ public class SensorParserConfigController { @Autowired private SensorParserConfigService sensorParserConfigService; + @ApiOperation(value = "Updates or creates a SensorParserConfig in Zookeeper") + @ApiResponse(message = "Saved SensorParserConfig", code = 200) @RequestMapping(method = RequestMethod.POST) - ResponseEntity save(@RequestBody SensorParserConfig sensorParserConfig) throws Exception { + ResponseEntity save(@ApiParam(name="sensorParserConfig", value="SensorParserConfig", required=true)@RequestBody SensorParserConfig sensorParserConfig) throws Exception { return new ResponseEntity<>(sensorParserConfigService.save(sensorParserConfig), HttpStatus.CREATED); } + @ApiOperation(value = "Retrieves a SensorParserConfig from Zookeeper") + @ApiResponse(message = "SensorParserConfig", code = 200) @RequestMapping(value = "/{name}", method = RequestMethod.GET) - ResponseEntity findOne(@PathVariable String name) throws Exception { + ResponseEntity findOne(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { SensorParserConfig sensorParserConfig = sensorParserConfigService.findOne(name); if (sensorParserConfig != null) { return new ResponseEntity<>(sensorParserConfig, HttpStatus.OK); @@ -54,13 +61,17 @@ ResponseEntity findOne(@PathVariable String name) throws Exc return new ResponseEntity<>(HttpStatus.NOT_FOUND); } + @ApiOperation(value = "Retrieves all SensorParserConfigs from Zookeeper") + @ApiResponse(message = "All SensorParserConfigs", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> findAll() throws Exception { return new ResponseEntity<>(sensorParserConfigService.getAll(), HttpStatus.OK); } + @ApiOperation(value = "Deletes a SensorParserConfig from Zookeeper") + @ApiResponse(message = "No return value", code = 200) @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) - ResponseEntity delete(@PathVariable String name) throws Exception { + ResponseEntity delete(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { if (sensorParserConfigService.delete(name)) { return new ResponseEntity<>(HttpStatus.OK); } else { @@ -68,18 +79,24 @@ ResponseEntity delete(@PathVariable String name) throws Exception { } } + @ApiOperation(value = "Lists the available parser classes that can be found on the classpath") + @ApiResponse(message = "List of available parser classes", code = 200) @RequestMapping(value = "/list/available", method = RequestMethod.GET) ResponseEntity> getAvailable() throws Exception { return new ResponseEntity<>(sensorParserConfigService.getAvailableParsers(), HttpStatus.OK); } + @ApiOperation(value = "Scans the classpath for available parser classes and reloads the cached parser class list") + @ApiResponse(message = "List of available parser classes", code = 200) @RequestMapping(value = "/reload/available", method = RequestMethod.GET) ResponseEntity> reloadAvailable() throws Exception { return new ResponseEntity<>(sensorParserConfigService.reloadAvailableParsers(), HttpStatus.OK); } + @ApiOperation(value = "Parses a sample message given a SensorParserConfig") + @ApiResponse(message = "Parsed message", code = 200) @RequestMapping(value = "/parseMessage", method = RequestMethod.POST) - ResponseEntity parseMessage(@RequestBody ParseMessageRequest parseMessageRequest) throws Exception { + ResponseEntity parseMessage(@ApiParam(name="parseMessageRequest", value="Object containing a sample message and SensorParserConfig", required=true) @RequestBody ParseMessageRequest parseMessageRequest) throws Exception { return new ResponseEntity<>(sensorParserConfigService.parseMessage(parseMessageRequest), HttpStatus.OK); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java index ae79b86591..73ded2378c 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java @@ -17,6 +17,9 @@ */ package org.apache.metron.rest.controller; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; import org.apache.metron.rest.model.SensorParserConfigHistory; import org.apache.metron.rest.service.SensorParserConfigHistoryService; import org.springframework.beans.factory.annotation.Autowired; @@ -36,8 +39,10 @@ public class SensorParserConfigHistoryController { @Autowired private SensorParserConfigHistoryService sensorParserHistoryService; + @ApiOperation(value = "Retrieves the current version of a SensorParserConfig including audit information") + @ApiResponse(message = "SensorParserConfig with audit information", code = 200) @RequestMapping(value = "/{name}", method = RequestMethod.GET) - ResponseEntity findOne(@PathVariable String name) throws Exception { + ResponseEntity findOne(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { SensorParserConfigHistory sensorParserConfigHistory = sensorParserHistoryService.findOne(name); if (sensorParserConfigHistory != null) { return new ResponseEntity<>(sensorParserHistoryService.findOne(name), HttpStatus.OK); @@ -45,14 +50,17 @@ ResponseEntity findOne(@PathVariable String name) thr return new ResponseEntity<>(HttpStatus.NOT_FOUND); } - + @ApiOperation(value = "Retrieves all current versions of SensorParserConfigs including audit information") + @ApiResponse(message = "SensorParserConfigs with audit information", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> getall() throws Exception { return new ResponseEntity<>(sensorParserHistoryService.getAll(), HttpStatus.OK); } + @ApiOperation(value = "Retrieves the history of all changes made to a SensorParserConfig") + @ApiResponse(message = "SensorParserConfig history", code = 200) @RequestMapping(value = "/history/{name}", method = RequestMethod.GET) - ResponseEntity> history(@PathVariable String name) throws Exception { + ResponseEntity> history(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { return new ResponseEntity<>(sensorParserHistoryService.history(name), HttpStatus.OK); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java index b54f9496f4..e5c83bb5ef 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java @@ -17,6 +17,9 @@ */ package org.apache.metron.rest.controller; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; import org.apache.metron.rest.model.TopologyResponse; import org.apache.metron.rest.model.TopologyStatus; import org.apache.metron.rest.service.StormService; @@ -39,41 +42,56 @@ public class StormController { @Autowired private StormService stormService; + @ApiOperation(value = "Retrieves the status of all Storm topologies") + @ApiResponse(message = "List of topologies with status information", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> getAll() throws Exception { return new ResponseEntity<>(stormService.getAllTopologyStatus(), HttpStatus.OK); } + @ApiOperation(value = "Retrieves the status of a Storm topology") + @ApiResponse(message = "Topology status information", code = 200) @RequestMapping(value = "/{name}", method = RequestMethod.GET) - ResponseEntity get(@PathVariable String name) throws Exception { - TopologyStatus sensorParserStatus = stormService.getTopologyStatus(name); - if (sensorParserStatus != null) { - return new ResponseEntity<>(sensorParserStatus, HttpStatus.OK); + ResponseEntity get(@ApiParam(name="name", value="Topology name", required=true)@PathVariable String name) throws Exception { + TopologyStatus topologyStatus = stormService.getTopologyStatus(name); + if (topologyStatus != null) { + return new ResponseEntity<>(topologyStatus, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } } + @ApiOperation(value = "Starts a Storm parser topology") + @ApiResponse(message = "Start response message", code = 200) @RequestMapping(value = "/parser/start/{name}", method = RequestMethod.GET) - ResponseEntity start(@PathVariable String name) throws Exception { + ResponseEntity start(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws Exception { return new ResponseEntity<>(stormService.startParserTopology(name), HttpStatus.OK); } + @ApiOperation(value = "Stops a Storm parser topology") + @ApiResponse(message = "Stop response message", code = 200) @RequestMapping(value = "/parser/stop/{name}", method = RequestMethod.GET) - ResponseEntity stop(@PathVariable String name, @RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { + ResponseEntity stop(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name, + @ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { return new ResponseEntity<>(stormService.stopParserTopology(name, stopNow), HttpStatus.OK); } + @ApiOperation(value = "Activates a Storm parser topology") + @ApiResponse(message = "Activate response message", code = 200) @RequestMapping(value = "/parser/activate/{name}", method = RequestMethod.GET) - ResponseEntity activate(@PathVariable String name) throws Exception { + ResponseEntity activate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws Exception { return new ResponseEntity<>(stormService.activateTopology(name), HttpStatus.OK); } + @ApiOperation(value = "Deactivates a Storm parser topology") + @ApiResponse(message = "Deactivate response message", code = 200) @RequestMapping(value = "/parser/deactivate/{name}", method = RequestMethod.GET) - ResponseEntity deactivate(@PathVariable String name) throws Exception { + ResponseEntity deactivate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws Exception { return new ResponseEntity<>(stormService.deactivateTopology(name), HttpStatus.OK); } + @ApiOperation(value = "Retrieves the status of the Storm enrichment topology") + @ApiResponse(message = "Topology status information", code = 200) @RequestMapping(value = "/enrichment", method = RequestMethod.GET) ResponseEntity getEnrichment() throws Exception { TopologyStatus sensorParserStatus = stormService.getTopologyStatus(StormService.ENRICHMENT_TOPOLOGY_NAME); @@ -84,56 +102,76 @@ ResponseEntity getEnrichment() throws Exception { } } + @ApiOperation(value = "Starts a Storm enrichment topology") + @ApiResponse(message = "Start response message", code = 200) @RequestMapping(value = "/enrichment/start", method = RequestMethod.GET) ResponseEntity startEnrichment() throws Exception { return new ResponseEntity<>(stormService.startEnrichmentTopology(), HttpStatus.OK); } + @ApiOperation(value = "Stops a Storm enrichment topology") + @ApiResponse(message = "Stop response message", code = 200) @RequestMapping(value = "/enrichment/stop", method = RequestMethod.GET) - ResponseEntity stopEnrichment(@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { + ResponseEntity stopEnrichment(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { return new ResponseEntity<>(stormService.stopEnrichmentTopology(stopNow), HttpStatus.OK); } + @ApiOperation(value = "Activates a Storm enrichment topology") + @ApiResponse(message = "Activate response message", code = 200) @RequestMapping(value = "/enrichment/activate", method = RequestMethod.GET) ResponseEntity activateEnrichment() throws Exception { return new ResponseEntity<>(stormService.activateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); } + @ApiOperation(value = "Deactivates a Storm enrichment topology") + @ApiResponse(message = "Deactivate response message", code = 200) @RequestMapping(value = "/enrichment/deactivate", method = RequestMethod.GET) ResponseEntity deactivateEnrichment() throws Exception { return new ResponseEntity<>(stormService.deactivateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); } + @ApiOperation(value = "Retrieves the status of the Storm indexing topology") + @ApiResponse(message = "Topology status information", code = 200) @RequestMapping(value = "/indexing", method = RequestMethod.GET) ResponseEntity getIndexing() throws Exception { - TopologyStatus sensorParserStatus = stormService.getTopologyStatus(StormService.INDEXING_TOPOLOGY_NAME); - if (sensorParserStatus != null) { - return new ResponseEntity<>(sensorParserStatus, HttpStatus.OK); + TopologyStatus topologyStatus = stormService.getTopologyStatus(StormService.INDEXING_TOPOLOGY_NAME); + if (topologyStatus != null) { + return new ResponseEntity<>(topologyStatus, HttpStatus.OK); } else { return new ResponseEntity<>(HttpStatus.NOT_FOUND); } } + @ApiOperation(value = "Starts a Storm indexing topology") + @ApiResponse(message = "Start response message", code = 200) @RequestMapping(value = "/indexing/start", method = RequestMethod.GET) ResponseEntity startIndexing() throws Exception { return new ResponseEntity<>(stormService.startIndexingTopology(), HttpStatus.OK); } + @ApiOperation(value = "Stops a Storm enrichment topology") + @ApiResponse(message = "Stop response message", code = 200) @RequestMapping(value = "/indexing/stop", method = RequestMethod.GET) - ResponseEntity stopIndexing(@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { + ResponseEntity stopIndexing(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { return new ResponseEntity<>(stormService.stopIndexingTopology(stopNow), HttpStatus.OK); } + @ApiOperation(value = "Activates a Storm indexing topology") + @ApiResponse(message = "Activate response message", code = 200) @RequestMapping(value = "/indexing/activate", method = RequestMethod.GET) ResponseEntity activateIndexing() throws Exception { return new ResponseEntity<>(stormService.activateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); } + @ApiOperation(value = "Deactivates a Storm indexing topology") + @ApiResponse(message = "Deactivate response message", code = 200) @RequestMapping(value = "/indexing/deactivate", method = RequestMethod.GET) ResponseEntity deactivateIndexing() throws Exception { return new ResponseEntity<>(stormService.deactivateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); } + @ApiOperation(value = "Retrieves information about the Storm command line client") + @ApiResponse(message = "Storm command line client information", code = 200) @RequestMapping(value = "/client/status", method = RequestMethod.GET) ResponseEntity> clientStatus() throws Exception { return new ResponseEntity<>(stormService.getStormClientStatus(), HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java index 971740f358..10148c266b 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java @@ -17,6 +17,9 @@ */ package org.apache.metron.rest.controller; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; import org.apache.metron.common.field.transformation.FieldTransformations; import org.apache.metron.rest.model.StellarFunctionDescription; import org.apache.metron.rest.model.TransformationValidation; @@ -39,26 +42,36 @@ public class TransformationController { @Autowired private TransformationService transformationService; + @ApiOperation(value = "Tests Stellar statements to ensure they are well-formed") + @ApiResponse(message = "Validation results", code = 200) @RequestMapping(value = "/validate/rules", method = RequestMethod.POST) - ResponseEntity> validateRule(@RequestBody List rules) throws Exception { - return new ResponseEntity<>(transformationService.validateRules(rules), HttpStatus.OK); + ResponseEntity> validateRule(@ApiParam(name="statements", value="List of statements to validate", required=true)@RequestBody List statements) throws Exception { + return new ResponseEntity<>(transformationService.validateRules(statements), HttpStatus.OK); } + @ApiOperation(value = "Executes transformations against a sample message") + @ApiResponse(message = "Transformation results", code = 200) @RequestMapping(value = "/validate", method = RequestMethod.POST) - ResponseEntity> validateTransformation(@RequestBody TransformationValidation transformationValidation) throws Exception { + ResponseEntity> validateTransformation(@ApiParam(name="transformationValidation", value="Object containing SensorParserConfig and sample message", required=true)@RequestBody TransformationValidation transformationValidation) throws Exception { return new ResponseEntity<>(transformationService.validateTransformation(transformationValidation), HttpStatus.OK); } + @ApiOperation(value = "Retrieves field transformations") + @ApiResponse(message = "List field transformations", code = 200) @RequestMapping(value = "/list", method = RequestMethod.GET) ResponseEntity list() throws Exception { return new ResponseEntity<>(transformationService.getTransformations(), HttpStatus.OK); } + @ApiOperation(value = "Lists the Stellar functions that can be found on the classpath") + @ApiResponse(message = "List of Stellar functions", code = 200) @RequestMapping(value = "/list/functions", method = RequestMethod.GET) ResponseEntity> listFunctions() throws Exception { return new ResponseEntity<>(transformationService.getStellarFunctions(), HttpStatus.OK); } + @ApiOperation(value = "Lists the simple Stellar functions (functions with only 1 input) that can be found on the classpath") + @ApiResponse(message = "List of simple Stellar functions", code = 200) @RequestMapping(value = "/list/simple/functions", method = RequestMethod.GET) ResponseEntity> listSimpleFunctions() throws Exception { return new ResponseEntity<>(transformationService.getSimpleStellarFunctions(), HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java index a6257b4c93..594b51f427 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/UserController.java @@ -17,6 +17,8 @@ */ package org.apache.metron.rest.controller; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -25,6 +27,8 @@ @RestController public class UserController { + @ApiOperation(value = "Retrieves the current user") + @ApiResponse(message = "Current user", code = 200) @RequestMapping("/api/v1/user") public String user(Principal user) { return user.getName(); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java index ce218aca5c..7034eacf44 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java @@ -21,9 +21,12 @@ import oi.thekraken.grok.api.Match; import org.apache.hadoop.fs.Path; import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.parsers.GrokParser; import org.apache.metron.rest.model.GrokValidation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import java.io.File; @@ -38,8 +41,9 @@ @Service public class GrokService { - public static final String GROK_PATH_SPRING_PROPERTY = "grok.path"; - public static final String GROK_CLASS_NAME = "org.apache.metron.parsers.GrokParser"; + public static final String GROK_DEFAULT_PATH_SPRING_PROPERTY = "grok.path.default"; + public static final String GROK_TEMP_PATH_SPRING_PROPERTY = "grok.path.temp"; + public static final String GROK_CLASS_NAME = GrokParser.class.getName(); public static final String GROK_PATH_KEY = "grokPath"; public static final String GROK_STATEMENT_KEY = "grokStatement"; public static final String GROK_PATTERN_LABEL_KEY = "patternLabel"; @@ -101,7 +105,7 @@ public void addGrokPathToConfig(SensorParserConfig sensorParserConfig) { String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); if (grokStatement != null) { sensorParserConfig.getParserConfig().put(GROK_PATH_KEY, - new Path(environment.getProperty(GROK_PATH_SPRING_PROPERTY), sensorParserConfig.getSensorTopic()).toString()); + new Path(environment.getProperty(GROK_DEFAULT_PATH_SPRING_PROPERTY), sensorParserConfig.getSensorTopic()).toString()); } } } @@ -122,23 +126,34 @@ private void saveGrokStatement(SensorParserConfig sensorParserConfig, boolean is String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); - String fullGrokStatement = patternLabel + " " + grokStatement; if (grokStatement != null) { + String fullGrokStatement = patternLabel + " " + grokStatement; if (!isTemporary) { hdfsService.write(new Path(grokPath), fullGrokStatement.getBytes()); } else { - FileWriter fileWriter = new FileWriter(new File(grokPath)); + File grokDirectory = new File(getTemporaryGrokRootPath()); + if (!grokDirectory.exists()) { + grokDirectory.mkdirs(); + } + FileWriter fileWriter = new FileWriter(new File(grokDirectory, sensorParserConfig.getSensorTopic())); fileWriter.write(fullGrokStatement); fileWriter.close(); } + } else { + throw new IllegalArgumentException("A grokStatement must be provided"); } } public void deleteTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws IOException { - String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); - File file = new File(grokPath); + File file = new File(getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()); file.delete(); } + public String getTemporaryGrokRootPath() { + String grokTempPath = environment.getProperty(GROK_TEMP_PATH_SPRING_PROPERTY); + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + return new Path(grokTempPath, authentication.getName()).toString(); + } + } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java index ec745733c3..2f13cb446e 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java @@ -85,7 +85,6 @@ public List getAvailableEnrichments() { add("geo"); add("host"); add("whois"); - add("sample"); }}; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java index 981d4d84c9..1d43c36eef 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -33,6 +33,7 @@ import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.stereotype.Service; +import java.io.File; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -159,10 +160,15 @@ public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws E throw new Exception("Could not find parser class name"); } else { MessageParser parser = (MessageParser) Class.forName(sensorParserConfig.getParserClassName()).newInstance(); - grokService.saveTemporaryGrokStatement(sensorParserConfig); + if (grokService.isGrokConfig(sensorParserConfig)) { + grokService.saveTemporaryGrokStatement(sensorParserConfig); + sensorParserConfig.getParserConfig().put(GrokService.GROK_PATH_KEY, new File(grokService.getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()).toString()); + } parser.configure(sensorParserConfig.getParserConfig()); JSONObject results = parser.parse(parseMessageRequest.getSampleData().getBytes()).get(0); - grokService.deleteTemporaryGrokStatement(sensorParserConfig); + if (grokService.isGrokConfig(sensorParserConfig)) { + grokService.deleteTemporaryGrokStatement(sensorParserConfig); + } return results; } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java index c59620bddf..1449988be7 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java @@ -29,7 +29,6 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -78,34 +77,10 @@ public List getStellarFunctions() { return stellarFunctionDescriptions; } - private List simpleFunctionNames = Arrays.asList( - "DOMAIN_REMOVE_SUBDOMAINS", - "DOMAIN_REMOVE_TLD", - "DOMAIN_TO_TLD", - "IS_DOMAIN", - "IS_EMAIL", - "IS_EMPTY", - "LENGTH", - "PROTOCOL_TO_NAME", - "TO_INTEGER", - "TO_LOWER", - "TO_STRING", - "TO_UPPER", - "TRIM", - "URL_TO_HOST", - "URL_TO_PATH", - "URL_TO_PORT", - "URL_TO_PROTOCOL", - "WEEK_OF_MONTH", - "WEEK_OF_YEAR", - "YEAR" - ); - public List getSimpleStellarFunctions() { - List stellarFunctionDescriptions = getStellarFunctions(); - return stellarFunctionDescriptions.stream().filter(stellarFunctionDescription -> - simpleFunctionNames.contains(stellarFunctionDescription.getName())).collect(Collectors.toList()); + List stellarFunctionDescriptions = getStellarFunctions(); + return stellarFunctionDescriptions.stream().filter(stellarFunctionDescription -> + stellarFunctionDescription.getParams().length == 1).sorted((o1, o2) -> o1.getName().compareTo(o2.getName())).collect(Collectors.toList()); } - } diff --git a/metron-interface/metron-rest/src/main/resources/application-docker.yml b/metron-interface/metron-rest/src/main/resources/application-docker.yml index 7958b1bc2d..cce6f75a94 100644 --- a/metron-interface/metron-rest/src/main/resources/application-docker.yml +++ b/metron-interface/metron-rest/src/main/resources/application-docker.yml @@ -42,7 +42,9 @@ hdfs: url: file:/// grok: - path: target/patterns + path: + temp: target/patterns/temp + default: target/patterns storm: ui: diff --git a/metron-interface/metron-rest/src/main/resources/application-test.yml b/metron-interface/metron-rest/src/main/resources/application-test.yml index 2731592b35..2872e95665 100644 --- a/metron-interface/metron-rest/src/main/resources/application-test.yml +++ b/metron-interface/metron-rest/src/main/resources/application-test.yml @@ -27,7 +27,9 @@ spring: banner-mode: off grok: - path: target/patterns + path: + temp: target/patterns/temp + default: target/patterns storm: ui: diff --git a/metron-interface/metron-rest/src/main/resources/application.yml b/metron-interface/metron-rest/src/main/resources/application.yml index 6e078cd62f..d43d6b3d86 100644 --- a/metron-interface/metron-rest/src/main/resources/application.yml +++ b/metron-interface/metron-rest/src/main/resources/application.yml @@ -23,3 +23,8 @@ logging: spring: jackson: date-format: yyyy-MM-dd HH:mm:ss + +grok: + path: + temp: ./ + default: /apps/metron/patterns 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 75a328df65..c3f65ea0f1 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 @@ -218,8 +218,7 @@ public void test() throws Exception { .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")) - .andExpect(jsonPath("$[3]").value("sample")); + .andExpect(jsonPath("$[2]").value("whois")); } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java index 625b0344de..fed9c500bd 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -18,6 +18,8 @@ package org.apache.metron.rest.controller; import org.adrianwalker.multilinestring.Multiline; +import org.apache.commons.io.FileUtils; +import org.apache.metron.rest.service.GrokService; import org.apache.metron.rest.service.SensorParserConfigService; import org.junit.Before; import org.junit.Test; @@ -25,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; +import org.springframework.core.env.Environment; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -32,6 +35,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import java.io.File; +import java.io.IOException; + import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; @@ -101,14 +107,11 @@ public class SensorParserConfigControllerIntegrationTest { public static String parseRequest; @Autowired - private SensorParserConfigService sensorParserConfigService; + private Environment environment; @Autowired private WebApplicationContext wac; - @Autowired - private ApplicationContext applicationContext; - private MockMvc mockMvc; private String user = "user"; @@ -136,6 +139,7 @@ public void testSecurity() throws Exception { @Test public void test() throws Exception { + cleanFileSystem(); this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) .andExpect(status().isCreated()) @@ -255,8 +259,19 @@ public void test() throws Exception { .andExpect(jsonPath("$.ip_src_addr").value("127.0.0.1")) .andExpect(jsonPath("$.url").value("http://www.aliexpress.com/af/shoes.html?")) .andExpect(jsonPath("$.timestamp").value(1467011157401L)); + } - //runner.stop(); + private void cleanFileSystem() throws IOException { + File grokTempPath = new File(environment.getProperty(GrokService.GROK_TEMP_PATH_SPRING_PROPERTY)); + if (grokTempPath.exists()) { + FileUtils.cleanDirectory(grokTempPath); + FileUtils.deleteDirectory(grokTempPath); + } + File grokPath = new File(environment.getProperty(GrokService.GROK_DEFAULT_PATH_SPRING_PROPERTY)); + if (grokPath.exists()) { + FileUtils.cleanDirectory(grokPath); + FileUtils.deleteDirectory(grokPath); + } } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java index 68251b55ca..892083b946 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java @@ -223,10 +223,15 @@ private void validateCreateModifiedByDate(Map result, boolean sh } private void cleanFileSystem() throws IOException { - File grokPath = new File(environment.getProperty(GrokService.GROK_PATH_SPRING_PROPERTY)); + File grokTempPath = new File(environment.getProperty(GrokService.GROK_TEMP_PATH_SPRING_PROPERTY)); + if (grokTempPath.exists()) { + FileUtils.cleanDirectory(grokTempPath); + FileUtils.deleteDirectory(grokTempPath); + } + File grokPath = new File(environment.getProperty(GrokService.GROK_DEFAULT_PATH_SPRING_PROPERTY)); if (grokPath.exists()) { - FileUtils.cleanDirectory(grokPath); - FileUtils.deleteDirectory(grokPath); + FileUtils.cleanDirectory(grokPath); + FileUtils.deleteDirectory(grokPath); } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java new file mode 100644 index 0000000000..339700aa8c --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java @@ -0,0 +1,115 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.utils; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import org.apache.velocity.Template; +import org.apache.velocity.VelocityContext; +import org.apache.velocity.app.Velocity; +import org.apache.velocity.runtime.RuntimeConstants; +import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; +import org.reflections.Reflections; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.io.FileWriter; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.security.Principal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +public class ReadMeUtils { + + public static void main(String[] args) throws Exception { + if (args.length == 0) { + System.out.println("README output path must be passed in as first argument"); + } + + Reflections reflections = new Reflections("org.apache.metron.rest.controller"); + List endpoints = new ArrayList<>(); + Set> controllers = reflections.getTypesAnnotatedWith(RestController.class); + for(Class controller: controllers) { + RequestMapping controllerRequestMapping = controller.getAnnotation(RequestMapping.class); + String pathPrefix; + if (controllerRequestMapping == null) { + pathPrefix = ""; + } else { + pathPrefix = controllerRequestMapping.value()[0]; + } + for(Method method: controller.getDeclaredMethods()) { + RestControllerInfo restControllerInfo = new RestControllerInfo(); + RequestMapping requestMapping = method.getAnnotation(RequestMapping.class); + if (requestMapping == null) { + throw new Exception(String.format("@RequestMapping annotation missing from method %s.%s. Every controller method must have a @RequestMapping annotation.", controller.getSimpleName(), method.getName())); + } + ApiOperation apiOperation = method.getAnnotation(ApiOperation.class); + if (apiOperation == null) { + throw new Exception(String.format("@ApiOperation annotation missing from method %s.%s. Every controller method must have an @ApiOperation annotation.", controller.getSimpleName(), method.getName())); + } + ApiResponse apiResponse = method.getAnnotation(ApiResponse.class); + if (apiResponse == null) { + throw new Exception(String.format("@ApiResponse annotation missing from method %s.%s. Every controller method must have an @ApiResponse annotation.", controller.getSimpleName(), method.getName())); + } + String[] requestMappingValue = requestMapping.value(); + if (requestMappingValue.length == 0) { + restControllerInfo.setPath(pathPrefix); + } else { + restControllerInfo.setPath(pathPrefix + requestMappingValue[0]); + } + restControllerInfo.setDescription(apiOperation.value()); + RequestMethod requestMethod; + if (requestMapping.method().length == 0) { + requestMethod = RequestMethod.GET; + } else { + requestMethod = requestMapping.method()[0]; + } + restControllerInfo.setMethod(requestMethod); + restControllerInfo.setResponseDescription(apiResponse.message()); + for(Parameter parameter: method.getParameters()) { + if (!parameter.getType().equals(Principal.class)) { + ApiParam apiParam = parameter.getAnnotation(ApiParam.class); + if (apiParam == null) { + throw new Exception(String.format("@ApiParam annotation missing from parameter %s.%s.%s. Every controller method parameter must have an @ApiParam annotation.", controller.getSimpleName(), method.getName(), parameter.getName())); + } + restControllerInfo.addParameterDescription(apiParam.name(), apiParam.value()); + } + } + endpoints.add(restControllerInfo); + } + } + Collections.sort(endpoints, (o1, o2) -> o1.getPath().compareTo(o2.getPath())); + + Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath"); + Velocity.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName()); + Velocity.init(); + + VelocityContext context = new VelocityContext(); + context.put( "endpoints", endpoints ); + + Template template = Velocity.getTemplate("README.vm"); + FileWriter fileWriter = new FileWriter(args[0]); + template.merge( context, fileWriter ); + fileWriter.close(); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/RestControllerInfo.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/RestControllerInfo.java new file mode 100644 index 0000000000..250831f068 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/RestControllerInfo.java @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.utils; + +import org.springframework.web.bind.annotation.RequestMethod; + +import java.util.HashMap; +import java.util.Map; + +public class RestControllerInfo { + + private String path; + private String description; + private RequestMethod method; + private String responseDescription; + private Map parameterDescriptions = new HashMap<>(); + + public RestControllerInfo() {} + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public RequestMethod getMethod() { + return method; + } + + public void setMethod(RequestMethod method) { + this.method = method; + } + + public String getResponseDescription() { + return responseDescription; + } + + public void setResponseDescription(String responseDescription) { + this.responseDescription = responseDescription; + } + + public Map getParameterDescriptions() { + return parameterDescriptions; + } + + public void addParameterDescription(String name, String description) { + parameterDescriptions.put(name, description); + } +} diff --git a/metron-interface/metron-rest/src/test/resources/README.vm b/metron-interface/metron-rest/src/test/resources/README.vm new file mode 100644 index 0000000000..e4e87e72fd --- /dev/null +++ b/metron-interface/metron-rest/src/test/resources/README.vm @@ -0,0 +1,89 @@ +#[[#]]# Metron REST and Configuration UI + +This UI exposes and aids in sensor configuration. + +#[[##]]# Prerequisites + +* A running Metron cluster +* A running instance of MySQL +* Java 8 installed +* Storm CLI and Metron topology scripts (start_parser_topology.sh, start_enrichment_topology.sh, start_elasticsearch_topology.sh) installed + +#[[##]]# Installation +1. Package the Application with Maven: + ``` + mvn clean package + ``` + +1. Untar the archive in the target directory. The directory structure will look like: + ``` + bin + start.sh + lib + metron-rest-version.jar + ``` + +1. Install Hibernate by downloading version 5.0.11.Final from (http://hibernate.org/orm/downloads/). Unpack the archive and set the HIBERNATE_HOME environment variable to the absolute path of the top level directory. + ``` + export HIBERNATE_HOME=/path/to/hibernate-release-5.0.11.Final + ``` + +1. Install the MySQL client by downloading version 5.1.40 from (https://dev.mysql.com/downloads/connector/j/). Unpack the archive and set the MYSQL_CLIENT_HOME environment variable to the absolute path of the top level directory. + ``` + export MYSQL_CLIENT_HOME=/path/to/mysql-connector-java-5.1.40 + ``` + +1. Create a MySQL user for the Config UI (http://dev.mysql.com/doc/refman/5.7/en/adding-users.html). + +1. Create a Config UI database in MySQL with this command: + ``` + CREATE DATABASE IF NOT EXISTS metronrest + ``` + +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.username` and `spring.datasource.password` properties using the MySQL credentials from step 4. + +1. Start the UI with this command: + ``` + ./bin/start.sh /path/to/application.yml + ``` + +#[[##]]# Usage + +The exposed REST endpoints can be accessed with the Swagger UI at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. Users can be added with this SQL statement: +``` +use metronrest; +insert into users (username, password, enabled) values ('your_username','your_password',1); +insert into authorities (username, authority) values ('your_username', 'ROLE_USER'); +``` +Users can be added to additional groups with this SQL statement: +``` +use metronrest; +insert into authorities (username, authority) values ('your_username', 'your_group'); +``` + +#[[##]]# API + +Request and Response objects are JSON formatted. The JSON schemas are available in the Swagger UI. + +| | +| ---------- | +#foreach( $restControllerInfo in $endpoints ) +| [ `$restControllerInfo.getMethod().toString() $restControllerInfo.getPath()`](#$restControllerInfo.getMethod().toString().toLowerCase()-$restControllerInfo.getPath().toLowerCase())| +#end + +#foreach( $restControllerInfo in $endpoints ) +#[[###]]# `$restControllerInfo.getMethod().toString() $restControllerInfo.getPath()` + * Description: $restControllerInfo.getDescription() +#if($restControllerInfo.getParameterDescriptions().size() > 0) + * Input: +#end +#foreach( $parameterDescription in $restControllerInfo.getParameterDescriptions().entrySet()) + * $parameterDescription.getKey() - $parameterDescription.getValue() +#end + * Returns: $restControllerInfo.getResponseDescription() + +#end + +#[[##]]# License + +This project depends on the Java Transaction API. See https://java.net/projects/jta-spec/ for more details. From 11fa4ae1634d683f545b7d75a46a131ae8295f0f Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 16 Dec 2016 12:42:20 -0600 Subject: [PATCH 21/54] Fixed README API links --- metron-interface/metron-rest/README.md | 96 +++++++++---------- .../metron-rest/src/test/resources/README.vm | 2 +- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index d8286d14f8..5c0063b4a7 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -67,54 +67,54 @@ Request and Response objects are JSON formatted. The JSON schemas are available | | | ---------- | -| [ `GET /api/v1/globalConfig`](#get-/api/v1/globalconfig)| -| [ `DELETE /api/v1/globalConfig`](#delete-/api/v1/globalconfig)| -| [ `POST /api/v1/globalConfig`](#post-/api/v1/globalconfig)| -| [ `GET /api/v1/grok/list`](#get-/api/v1/grok/list)| -| [ `POST /api/v1/grok/validate`](#post-/api/v1/grok/validate)| -| [ `GET /api/v1/kafka/topic`](#get-/api/v1/kafka/topic)| -| [ `POST /api/v1/kafka/topic`](#post-/api/v1/kafka/topic)| -| [ `GET /api/v1/kafka/topic/{name}`](#get-/api/v1/kafka/topic/{name})| -| [ `DELETE /api/v1/kafka/topic/{name}`](#delete-/api/v1/kafka/topic/{name})| -| [ `GET /api/v1/kafka/topic/{name}/sample`](#get-/api/v1/kafka/topic/{name}/sample)| -| [ `GET /api/v1/sensorEnrichmentConfig`](#get-/api/v1/sensorenrichmentconfig)| -| [ `GET /api/v1/sensorEnrichmentConfig/list/available`](#get-/api/v1/sensorenrichmentconfig/list/available)| -| [ `DELETE /api/v1/sensorEnrichmentConfig/{name}`](#delete-/api/v1/sensorenrichmentconfig/{name})| -| [ `POST /api/v1/sensorEnrichmentConfig/{name}`](#post-/api/v1/sensorenrichmentconfig/{name})| -| [ `GET /api/v1/sensorEnrichmentConfig/{name}`](#get-/api/v1/sensorenrichmentconfig/{name})| -| [ `POST /api/v1/sensorParserConfig`](#post-/api/v1/sensorparserconfig)| -| [ `GET /api/v1/sensorParserConfig`](#get-/api/v1/sensorparserconfig)| -| [ `GET /api/v1/sensorParserConfig/list/available`](#get-/api/v1/sensorparserconfig/list/available)| -| [ `POST /api/v1/sensorParserConfig/parseMessage`](#post-/api/v1/sensorparserconfig/parsemessage)| -| [ `GET /api/v1/sensorParserConfig/reload/available`](#get-/api/v1/sensorparserconfig/reload/available)| -| [ `DELETE /api/v1/sensorParserConfig/{name}`](#delete-/api/v1/sensorparserconfig/{name})| -| [ `GET /api/v1/sensorParserConfig/{name}`](#get-/api/v1/sensorparserconfig/{name})| -| [ `GET /api/v1/sensorParserConfigHistory`](#get-/api/v1/sensorparserconfighistory)| -| [ `GET /api/v1/sensorParserConfigHistory/history/{name}`](#get-/api/v1/sensorparserconfighistory/history/{name})| -| [ `GET /api/v1/sensorParserConfigHistory/{name}`](#get-/api/v1/sensorparserconfighistory/{name})| -| [ `GET /api/v1/storm`](#get-/api/v1/storm)| -| [ `GET /api/v1/storm/client/status`](#get-/api/v1/storm/client/status)| -| [ `GET /api/v1/storm/enrichment`](#get-/api/v1/storm/enrichment)| -| [ `GET /api/v1/storm/enrichment/activate`](#get-/api/v1/storm/enrichment/activate)| -| [ `GET /api/v1/storm/enrichment/deactivate`](#get-/api/v1/storm/enrichment/deactivate)| -| [ `GET /api/v1/storm/enrichment/start`](#get-/api/v1/storm/enrichment/start)| -| [ `GET /api/v1/storm/enrichment/stop`](#get-/api/v1/storm/enrichment/stop)| -| [ `GET /api/v1/storm/indexing`](#get-/api/v1/storm/indexing)| -| [ `GET /api/v1/storm/indexing/activate`](#get-/api/v1/storm/indexing/activate)| -| [ `GET /api/v1/storm/indexing/deactivate`](#get-/api/v1/storm/indexing/deactivate)| -| [ `GET /api/v1/storm/indexing/start`](#get-/api/v1/storm/indexing/start)| -| [ `GET /api/v1/storm/indexing/stop`](#get-/api/v1/storm/indexing/stop)| -| [ `GET /api/v1/storm/parser/activate/{name}`](#get-/api/v1/storm/parser/activate/{name})| -| [ `GET /api/v1/storm/parser/deactivate/{name}`](#get-/api/v1/storm/parser/deactivate/{name})| -| [ `GET /api/v1/storm/parser/start/{name}`](#get-/api/v1/storm/parser/start/{name})| -| [ `GET /api/v1/storm/parser/stop/{name}`](#get-/api/v1/storm/parser/stop/{name})| -| [ `GET /api/v1/storm/{name}`](#get-/api/v1/storm/{name})| -| [ `GET /api/v1/transformation/list`](#get-/api/v1/transformation/list)| -| [ `GET /api/v1/transformation/list/functions`](#get-/api/v1/transformation/list/functions)| -| [ `GET /api/v1/transformation/list/simple/functions`](#get-/api/v1/transformation/list/simple/functions)| -| [ `POST /api/v1/transformation/validate`](#post-/api/v1/transformation/validate)| -| [ `POST /api/v1/transformation/validate/rules`](#post-/api/v1/transformation/validate/rules)| -| [ `GET /api/v1/user`](#get-/api/v1/user)| +| [ `GET /api/v1/globalConfig`](#get-apiv1globalconfig)| +| [ `DELETE /api/v1/globalConfig`](#delete-apiv1globalconfig)| +| [ `POST /api/v1/globalConfig`](#post-apiv1globalconfig)| +| [ `GET /api/v1/grok/list`](#get-apiv1groklist)| +| [ `POST /api/v1/grok/validate`](#post-apiv1grokvalidate)| +| [ `GET /api/v1/kafka/topic`](#get-apiv1kafkatopic)| +| [ `POST /api/v1/kafka/topic`](#post-apiv1kafkatopic)| +| [ `GET /api/v1/kafka/topic/{name}`](#get-apiv1kafkatopic{name})| +| [ `DELETE /api/v1/kafka/topic/{name}`](#delete-apiv1kafkatopic{name})| +| [ `GET /api/v1/kafka/topic/{name}/sample`](#get-apiv1kafkatopic{name}sample)| +| [ `GET /api/v1/sensorEnrichmentConfig`](#get-apiv1sensorenrichmentconfig)| +| [ `GET /api/v1/sensorEnrichmentConfig/list/available`](#get-apiv1sensorenrichmentconfiglistavailable)| +| [ `DELETE /api/v1/sensorEnrichmentConfig/{name}`](#delete-apiv1sensorenrichmentconfig{name})| +| [ `POST /api/v1/sensorEnrichmentConfig/{name}`](#post-apiv1sensorenrichmentconfig{name})| +| [ `GET /api/v1/sensorEnrichmentConfig/{name}`](#get-apiv1sensorenrichmentconfig{name})| +| [ `POST /api/v1/sensorParserConfig`](#post-apiv1sensorparserconfig)| +| [ `GET /api/v1/sensorParserConfig`](#get-apiv1sensorparserconfig)| +| [ `GET /api/v1/sensorParserConfig/list/available`](#get-apiv1sensorparserconfiglistavailable)| +| [ `POST /api/v1/sensorParserConfig/parseMessage`](#post-apiv1sensorparserconfigparsemessage)| +| [ `GET /api/v1/sensorParserConfig/reload/available`](#get-apiv1sensorparserconfigreloadavailable)| +| [ `DELETE /api/v1/sensorParserConfig/{name}`](#delete-apiv1sensorparserconfig{name})| +| [ `GET /api/v1/sensorParserConfig/{name}`](#get-apiv1sensorparserconfig{name})| +| [ `GET /api/v1/sensorParserConfigHistory`](#get-apiv1sensorparserconfighistory)| +| [ `GET /api/v1/sensorParserConfigHistory/history/{name}`](#get-apiv1sensorparserconfighistoryhistory{name})| +| [ `GET /api/v1/sensorParserConfigHistory/{name}`](#get-apiv1sensorparserconfighistory{name})| +| [ `GET /api/v1/storm`](#get-apiv1storm)| +| [ `GET /api/v1/storm/client/status`](#get-apiv1stormclientstatus)| +| [ `GET /api/v1/storm/enrichment`](#get-apiv1stormenrichment)| +| [ `GET /api/v1/storm/enrichment/activate`](#get-apiv1stormenrichmentactivate)| +| [ `GET /api/v1/storm/enrichment/deactivate`](#get-apiv1stormenrichmentdeactivate)| +| [ `GET /api/v1/storm/enrichment/start`](#get-apiv1stormenrichmentstart)| +| [ `GET /api/v1/storm/enrichment/stop`](#get-apiv1stormenrichmentstop)| +| [ `GET /api/v1/storm/indexing`](#get-apiv1stormindexing)| +| [ `GET /api/v1/storm/indexing/activate`](#get-apiv1stormindexingactivate)| +| [ `GET /api/v1/storm/indexing/deactivate`](#get-apiv1stormindexingdeactivate)| +| [ `GET /api/v1/storm/indexing/start`](#get-apiv1stormindexingstart)| +| [ `GET /api/v1/storm/indexing/stop`](#get-apiv1stormindexingstop)| +| [ `GET /api/v1/storm/parser/activate/{name}`](#get-apiv1stormparseractivate{name})| +| [ `GET /api/v1/storm/parser/deactivate/{name}`](#get-apiv1stormparserdeactivate{name})| +| [ `GET /api/v1/storm/parser/start/{name}`](#get-apiv1stormparserstart{name})| +| [ `GET /api/v1/storm/parser/stop/{name}`](#get-apiv1stormparserstop{name})| +| [ `GET /api/v1/storm/{name}`](#get-apiv1storm{name})| +| [ `GET /api/v1/transformation/list`](#get-apiv1transformationlist)| +| [ `GET /api/v1/transformation/list/functions`](#get-apiv1transformationlistfunctions)| +| [ `GET /api/v1/transformation/list/simple/functions`](#get-apiv1transformationlistsimplefunctions)| +| [ `POST /api/v1/transformation/validate`](#post-apiv1transformationvalidate)| +| [ `POST /api/v1/transformation/validate/rules`](#post-apiv1transformationvalidaterules)| +| [ `GET /api/v1/user`](#get-apiv1user)| ### `GET /api/v1/globalConfig` * Description: Retrieves the current Global Config from Zookeeper diff --git a/metron-interface/metron-rest/src/test/resources/README.vm b/metron-interface/metron-rest/src/test/resources/README.vm index e4e87e72fd..e78d1eef94 100644 --- a/metron-interface/metron-rest/src/test/resources/README.vm +++ b/metron-interface/metron-rest/src/test/resources/README.vm @@ -68,7 +68,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())| +| [ `$restControllerInfo.getMethod().toString() $restControllerInfo.getPath()`](#$restControllerInfo.getMethod().toString().toLowerCase()-$restControllerInfo.getPath().toLowerCase().replaceAll("/", ""))| #end #foreach( $restControllerInfo in $endpoints ) From 07f1a5fe209d8a29d835557a0e9a1836ed4a29ab Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 19 Dec 2016 15:05:28 -0600 Subject: [PATCH 22/54] Changes from PR feedback. Replaced install script with maven pom. Also added more documentation. --- metron-docker/.env | 2 - metron-docker/.gitignore | 24 +- metron-docker/README.md | 204 +++++++++++-- .../{ => compose}/docker-compose.yml | 1 + metron-docker/{ => compose}/hbase/Dockerfile | 1 + .../{ => compose}/hbase/bin/init-commands.txt | 0 .../{ => compose}/hbase/bin/init-hbase.sh | 0 .../{ => compose}/hbase/bin/start.sh | 0 .../hbase/conf/enrichment-extractor.json | 0 .../hbase/conf/hbase-site.docker.xml | 0 .../hbase/conf/threatintel-extractor.json | 0 .../{ => compose}/hbase/data/enrichments.csv | 0 .../{ => compose}/hbase/data/threatintel.csv | 0 .../{ => compose}/kafkazk/Dockerfile | 15 + .../{ => compose}/kafkazk/bin/create-topic.sh | 0 .../{ => compose}/kafkazk/bin/init-kafka.sh | 0 .../{ => compose}/kafkazk/bin/init-zk.sh | 0 .../{ => compose}/kafkazk/bin/output-data.sh | 0 .../{ => compose}/kafkazk/bin/produce-data.sh | 0 .../{ => compose}/kafkazk/bin/run-consumer.sh | 0 .../{ => compose}/kafkazk/bin/start.sh | 0 .../compose/kafkazk/conf/global.json | 6 + .../kafkazk/data/BroExampleOutput.txt | 0 .../kafkazk/data/SquidExampleOutput.txt | 0 metron-docker/{ => compose}/kibana/Dockerfile | 0 .../kibana/conf/kibana-index.json | 0 .../{ => compose}/kibana/images/metron.svg | 0 metron-docker/{ => compose}/mysql/Dockerfile | 1 + .../{ => compose}/mysql/bin/init-mysql.sh | 0 .../{ => compose}/mysql/bin/start.sh | 0 metron-docker/{ => compose}/storm/Dockerfile | 4 + .../storm/bin/start_docker_parser_topology.sh | 18 ++ metron-docker/conf/.env | 2 + metron-docker/kafkazk/bin/wait-for-it.sh | 161 ---------- metron-docker/mysql/bin/wait-for-it.sh | 161 ---------- metron-docker/pom.xml | 276 ++++++++++++++++++ .../{ => scripts}/create-docker-machine.sh | 0 .../{hbase/bin => scripts}/wait-for-it.sh | 0 .../src/main/scripts/zk_load_configs.sh | 3 +- pom.xml | 1 + 40 files changed, 519 insertions(+), 361 deletions(-) delete mode 100644 metron-docker/.env rename metron-docker/{ => compose}/docker-compose.yml (98%) rename metron-docker/{ => compose}/hbase/Dockerfile (97%) rename metron-docker/{ => compose}/hbase/bin/init-commands.txt (100%) rename metron-docker/{ => compose}/hbase/bin/init-hbase.sh (100%) rename metron-docker/{ => compose}/hbase/bin/start.sh (100%) rename metron-docker/{ => compose}/hbase/conf/enrichment-extractor.json (100%) rename metron-docker/{ => compose}/hbase/conf/hbase-site.docker.xml (100%) rename metron-docker/{ => compose}/hbase/conf/threatintel-extractor.json (100%) rename metron-docker/{ => compose}/hbase/data/enrichments.csv (100%) rename metron-docker/{ => compose}/hbase/data/threatintel.csv (100%) rename metron-docker/{ => compose}/kafkazk/Dockerfile (69%) rename metron-docker/{ => compose}/kafkazk/bin/create-topic.sh (100%) rename metron-docker/{ => compose}/kafkazk/bin/init-kafka.sh (100%) rename metron-docker/{ => compose}/kafkazk/bin/init-zk.sh (100%) rename metron-docker/{ => compose}/kafkazk/bin/output-data.sh (100%) rename metron-docker/{ => compose}/kafkazk/bin/produce-data.sh (100%) rename metron-docker/{ => compose}/kafkazk/bin/run-consumer.sh (100%) rename metron-docker/{ => compose}/kafkazk/bin/start.sh (100%) create mode 100644 metron-docker/compose/kafkazk/conf/global.json rename metron-docker/{ => compose}/kafkazk/data/BroExampleOutput.txt (100%) rename metron-docker/{ => compose}/kafkazk/data/SquidExampleOutput.txt (100%) rename metron-docker/{ => compose}/kibana/Dockerfile (100%) rename metron-docker/{ => compose}/kibana/conf/kibana-index.json (100%) rename metron-docker/{ => compose}/kibana/images/metron.svg (100%) rename metron-docker/{ => compose}/mysql/Dockerfile (97%) rename metron-docker/{ => compose}/mysql/bin/init-mysql.sh (100%) rename metron-docker/{ => compose}/mysql/bin/start.sh (100%) rename metron-docker/{ => compose}/storm/Dockerfile (97%) create mode 100755 metron-docker/compose/storm/bin/start_docker_parser_topology.sh create mode 100644 metron-docker/conf/.env delete mode 100755 metron-docker/kafkazk/bin/wait-for-it.sh delete mode 100755 metron-docker/mysql/bin/wait-for-it.sh create mode 100644 metron-docker/pom.xml rename metron-docker/{ => scripts}/create-docker-machine.sh (100%) rename metron-docker/{hbase/bin => scripts}/wait-for-it.sh (100%) diff --git a/metron-docker/.env b/metron-docker/.env deleted file mode 100644 index fa9dc932a6..0000000000 --- a/metron-docker/.env +++ /dev/null @@ -1,2 +0,0 @@ -METRON_VERSION=0.3.0 -COMPOSE_PROJECT_NAME=metron diff --git a/metron-docker/.gitignore b/metron-docker/.gitignore index c46d09aab2..01cfaca82f 100644 --- a/metron-docker/.gitignore +++ b/metron-docker/.gitignore @@ -1,9 +1,15 @@ -/mysql/enrichment -/hbase/data-management -/storm/elasticsearch -/storm/enrichment -/storm/parser -/storm/indexing -/kafkazk/data/* -!/kafkazk/data/BroExampleOutput.txt -!/kafkazk/data/SquidExampleOutput.txt +/compose/.env +/compose/kafkazk/common +/compose/kafkazk/parser +/compose/kafkazk/enrichment +/compose/mysql/enrichment +/compose/hbase/data-management +/compose/storm/elasticsearch +/compose/storm/enrichment +/compose/storm/parser +/compose/storm/indexing +/compose/kafkazk/data/* +!/compose/kafkazk/data/BroExampleOutput.txt +!/compose/kafkazk/data/SquidExampleOutput.txt +wait-for-it.sh +!/scripts/wait-for-it.sh \ No newline at end of file diff --git a/metron-docker/README.md b/metron-docker/README.md index c5a0d1f520..3fa57d3824 100644 --- a/metron-docker/README.md +++ b/metron-docker/README.md @@ -18,75 +18,225 @@ Metron Docker includes these images that have been customized for Metron: Setup ----- -Install Docker from https://docs.docker.com/docker-for-mac/. The following versions have been tested: +Install [Docker for Mac](https://docs.docker.com/docker-for-mac/) or [Docker for Windows](https://docs.docker.com/docker-for-windows/). The following versions have been tested: - Docker version 1.12.0 - docker-machine version 0.8.0 - docker-compose version 1.8.0 -External Metron binaries must be deployed to the various Dockerfile contexts. Run this script to do that: +Build Metron from the top level directory with: ``` -./install-metron.sh -b +$ cd $METRON_HOME +$ mvn clean install -DskipTests ``` -If your Metron project has already been compiled and packaged with Maven, you can skip that step by removing the -b option: +You are welcome to use an existing Docker host but we prefer one with more resources. You can create one of those with this script: ``` -./install-metron.sh +$ export METRON_DOCKER_HOME=$METRON_HOME/metron-docker +$ cd $METRON_DOCKER_HOME && ./scripts/create-docker-machine.sh ``` -You are welcome to use an existing docker-machine but we prefer a machine with more resources. You can create one of those by running this: +This will create a host called "metron-machine". Anytime you want to run Docker commands against this host, make sure you run this first to set the Docker environment variables: ``` -./create-docker-machine.sh +$ eval "$(docker-machine env metron-machine)" ``` -This will create a docker-machine called "metron-machine". Anytime you want to run Docker commands against this machine, make sure you run this first to set the Docker environment variables: +Usage +----- + +Navigate to the compose application root: ``` -eval "$(docker-machine env metron-machine)" +$ cd $METRON_DOCKER_HOME/compose/ ``` -Usage +The Metron Docker environment lifecycle is controlled by the [docker-compose](https://docs.docker.com/compose/reference/overview/) command. These service names can be found in the docker-compose.yml file. For example, to build the environment run this command: +``` +$ docker-compose up -d +``` + +After all services have started list the containers and ensure their status is 'Up': +``` +$ docker ps --format 'table {{.Names}}\t{{.Status}}' +NAMES STATUS +metron_storm_1 Up 5 minutes +metron_hbase_1 Up 5 minutes +metron_kibana_1 Up 5 minutes +metron_kafkazk_1 Up 5 minutes +metron_mysql_1 Up 5 minutes +metron_elasticsearch_1 Up 5 minutes +``` + +Various services are exposed through http on the Docker host. Get the host ip from the URL property: +``` +$ docker-machine ls +NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS +metron-machine * virtualbox Running tcp://192.168.99.100:2376 v1.12.5 +``` + +Then, assuming a host ip of `192.168.99.100`, the UIs and APIs are available at: + +* Storm - http://192.168.99.100:8080/ +* HBase - http://192.168.99.100:16010/ +* Elasticsearch - http://192.168.99.100:9200/ +* Kibana - http://192.168.99.100:5601/ + +Examples ----- +* [Deploy a new parser class](#deploy-a-new-parser-class) +* [Connect to a container](#connect-to-a-container) +* [Create a sensor from sample data](create-a-sensor-from-sample-data) +* [Upload configs to Zookeeper](upload-configs-to-zookeeper) +* [Manage a topology](manage-a-topology) +* [Run sensor data end to end](run-sensor-data-end-to-end) -The Metron Docker environment lifecycle is controlled by the [docker-compose](https://docs.docker.com/compose/reference/overview/) command. These service names can be found in the docker-compose.yml file. For example, to build the environment run this command: + +### Deploy a new parser class + +After adding a new parser to metron-parsers, build Metron from the top level directory: ``` -docker-compose up -d +$ cd $METRON_HOME +$ mvn clean install -DskipTests ``` -If a new parser is added to metron-parsers, run these commands to redeploy the parsers to the Storm image: +Then run these commands to redeploy the parsers to the Storm image: ``` -docker-compose down -./install-metron -b -docker-compose build storm -docker-compose up -d +$ cd $METRON_DOCKER_HOME/compose +$ docker-compose down +$ docker-compose build storm +$ docker-compose up -d ``` -If there is a problem with Kafka, run this command to connect and explore the Kafka container: +### Connect to a container + +Suppose there is a problem with Kafka and the logs are needed for further investigation. Run this command to connect and explore the running Kafka container: ``` -docker-compose exec kafkazk bash +$ cd $METRON_DOCKER_HOME/compose +$ docker-compose exec kafkazk bash ``` +### Create a sensor from sample data + A tool for producing test data in Kafka is included with the Kafka/Zookeeper image. It loops through lines in a test data file and outputs them to Kafka at the desired frequency. Create a test data file in `./kafkazk/data/` and rebuild the Kafka/Zookeeper image: ``` -printf 'first test data\nsecond test data\nthird test data\n' > ./kafkazk/data/TestData.txt -docker-compose down -docker-compose build kafkazk -docker-compose up -d +$ cd $METRON_DOCKER_HOME/compose +$ printf 'first test data\nsecond test data\nthird test data\n' > ./kafkazk/data/TestData.txt +$ docker-compose down +$ docker-compose build kafkazk +$ docker-compose up -d ``` This will deploy the test data file to the Kafka/Zookeeper container. Now that data can be streamed to a Kafka topic: ``` -docker-compose exec kafkazk ./bin/produce-data.sh +$ docker-compose exec kafkazk ./bin/produce-data.sh Usage: produce-data.sh data_path topic [message_delay_in_seconds] # Stream data in TestData.txt to the 'test' Kafka topic at a frequency of 5 seconds (default is 1 second) -docker-compose exec kafkazk ./bin/produce-data.sh /data/TestData.txt test 5 +$ docker-compose exec kafkazk ./bin/produce-data.sh /data/TestData.txt test 5 ``` The Kafka/Zookeeper image comes with sample Bro and Squid data: ``` # Stream Bro test data every 1 second -docker-compose exec kafkazk ./bin/produce-data.sh /data/BroExampleOutput.txt bro +$ docker-compose exec kafkazk ./bin/produce-data.sh /data/BroExampleOutput.txt bro # Stream Squid test data every 0.1 seconds -docker-compose exec kafkazk ./bin/produce-data.sh /data/SquidExampleOutput.txt squid 0.1 +$ docker-compose exec kafkazk ./bin/produce-data.sh /data/SquidExampleOutput.txt squid 0.1 +``` + +### Upload configs to Zookeeper + +Parser configs and a global config configured for this Docker environment are included with the Kafka/Zookeeper image. Load them with: +``` +$ docker-compose exec kafkazk bash +# $METRON_HOME/bin/zk_load_configs.sh -z localhost:2181 -m PUSH -i $METRON_HOME/config/zookeeper +# exit +``` + +Dump out the configs with: +``` +$ docker-compose exec kafkazk bash +# $METRON_HOME/bin/zk_load_configs.sh -z localhost:2181 -m DUMP +# exit +``` + +### Manage a topology + +The Storm image comes with a script to easily start parser topologies: +``` +docker-compose exec storm ./bin/start_docker_parser_topology.sh sensor_name +``` + +The enrichment topology can be started with: +``` +docker-compose exec storm ./bin/start_enrichment_topology.sh +``` + +The indexing topology can be started with: +``` +docker-compose exec storm ./bin/start_elasticsearch_topology.sh +``` + +Topologies can be stoped using the Storm CLI. For example, stop the enrichment topology with: +``` +docker-compose exec storm storm kill enrichments -w 0 +``` + +### Run sensor data end to end + +First ensure configs were uploaded as described in the previous example. Then start a sensor and leave it running: +``` +$ cd $METRON_DOCKER_HOME/compose +$ docker-compose exec kafkazk ./bin/produce-data.sh /data/BroExampleOutput.txt bro +``` + +Open a separate console session and verify the sensor is running by consuming a message from Kafka: +``` +$ export METRON_DOCKER_HOME=$METRON_HOME/metron-docker +$ cd $METRON_DOCKER_HOME/compose +$ docker-compose exec kafkazk ./bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic bro +``` + +A new message should be printed every second. Now kill the consumer and start the Bro parser topology: +``` +$ docker-compose exec storm ./bin/start_docker_parser_topology.sh bro +``` + +Bro data should be flowing through the bro parser topology and into the Kafka enrichments topic. The enrichments topic should be created automatically: +``` +$ docker-compose exec kafkazk ./bin/kafka-topics.sh --zookeeper localhost:2181 --list +bro +enrichments +indexing +``` + +Verify parsed Bro data is in the Kafka enrichments topic: +``` +docker-compose exec kafkazk ./bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic enrichments +``` + +Now start the enrichment topology: +``` +docker-compose exec storm ./bin/start_enrichment_topology.sh +``` + +Parsed Bro data should be flowing through the enrichment topology and into the Kafka indexing topic. Verify enriched Bro data is in the Kafka indexing topic: +``` +docker-compose exec kafkazk ./bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic indexing +``` + +Now start the indexing topology: +``` +docker-compose exec storm ./bin/start_elasticsearch_topology.sh +``` + +Enriched Bro data should now be present in the Elasticsearch container: +``` +$ docker-machine ls +NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS +metron-machine * virtualbox Running tcp://192.168.99.100:2376 v1.12.5 + +$ curl -XGET http://192.168.99.100:9200/_cat/indices?v +health status index pri rep docs.count docs.deleted store.size pri.store.size +yellow open .kibana 1 1 1 0 3.1kb 3.1kb +yellow open bro_index_2016.12.19.18 5 1 180 0 475kb 475kb ``` \ No newline at end of file diff --git a/metron-docker/docker-compose.yml b/metron-docker/compose/docker-compose.yml similarity index 98% rename from metron-docker/docker-compose.yml rename to metron-docker/compose/docker-compose.yml index 09779d2490..b270157ee6 100644 --- a/metron-docker/docker-compose.yml +++ b/metron-docker/compose/docker-compose.yml @@ -30,6 +30,7 @@ services: context: ./kafkazk args: DOCKER_HOST: $DOCKER_HOST + METRON_VERSION: $METRON_VERSION ports: - "9092:9092" - "2181:2181" diff --git a/metron-docker/hbase/Dockerfile b/metron-docker/compose/hbase/Dockerfile similarity index 97% rename from metron-docker/hbase/Dockerfile rename to metron-docker/compose/hbase/Dockerfile index f29bd2ed2c..dd857904f9 100644 --- a/metron-docker/hbase/Dockerfile +++ b/metron-docker/compose/hbase/Dockerfile @@ -35,6 +35,7 @@ ADD ./conf/enrichment-extractor.json /conf/enrichment-extractor.json ADD ./conf/threatintel-extractor.json /conf/threatintel-extractor.json ADD ./conf/hbase-site.docker.xml $HBASE_HOME/conf/hbase-site.xml ADD ./bin $HBASE_HOME/bin +RUN chmod 755 $HBASE_HOME/bin/wait-for-it.sh EXPOSE 8080 8085 9090 9095 16000 16010 16201 16301 diff --git a/metron-docker/hbase/bin/init-commands.txt b/metron-docker/compose/hbase/bin/init-commands.txt similarity index 100% rename from metron-docker/hbase/bin/init-commands.txt rename to metron-docker/compose/hbase/bin/init-commands.txt diff --git a/metron-docker/hbase/bin/init-hbase.sh b/metron-docker/compose/hbase/bin/init-hbase.sh similarity index 100% rename from metron-docker/hbase/bin/init-hbase.sh rename to metron-docker/compose/hbase/bin/init-hbase.sh diff --git a/metron-docker/hbase/bin/start.sh b/metron-docker/compose/hbase/bin/start.sh similarity index 100% rename from metron-docker/hbase/bin/start.sh rename to metron-docker/compose/hbase/bin/start.sh diff --git a/metron-docker/hbase/conf/enrichment-extractor.json b/metron-docker/compose/hbase/conf/enrichment-extractor.json similarity index 100% rename from metron-docker/hbase/conf/enrichment-extractor.json rename to metron-docker/compose/hbase/conf/enrichment-extractor.json diff --git a/metron-docker/hbase/conf/hbase-site.docker.xml b/metron-docker/compose/hbase/conf/hbase-site.docker.xml similarity index 100% rename from metron-docker/hbase/conf/hbase-site.docker.xml rename to metron-docker/compose/hbase/conf/hbase-site.docker.xml diff --git a/metron-docker/hbase/conf/threatintel-extractor.json b/metron-docker/compose/hbase/conf/threatintel-extractor.json similarity index 100% rename from metron-docker/hbase/conf/threatintel-extractor.json rename to metron-docker/compose/hbase/conf/threatintel-extractor.json diff --git a/metron-docker/hbase/data/enrichments.csv b/metron-docker/compose/hbase/data/enrichments.csv similarity index 100% rename from metron-docker/hbase/data/enrichments.csv rename to metron-docker/compose/hbase/data/enrichments.csv diff --git a/metron-docker/hbase/data/threatintel.csv b/metron-docker/compose/hbase/data/threatintel.csv similarity index 100% rename from metron-docker/hbase/data/threatintel.csv rename to metron-docker/compose/hbase/data/threatintel.csv diff --git a/metron-docker/kafkazk/Dockerfile b/metron-docker/compose/kafkazk/Dockerfile similarity index 69% rename from metron-docker/kafkazk/Dockerfile rename to metron-docker/compose/kafkazk/Dockerfile index 54cec4ad2f..59ddb7626b 100644 --- a/metron-docker/kafkazk/Dockerfile +++ b/metron-docker/compose/kafkazk/Dockerfile @@ -17,6 +17,11 @@ FROM centos ARG DOCKER_HOST="localhost" +ARG METRON_VERSION + +ENV METRON_VERSION $METRON_VERSION +ENV METRON_HOME /usr/metron/$METRON_VERSION/ +ENV ZK_CLIENT_JARS /opt/kafka_2.11-0.10.0.0/libs ADD https://archive.apache.org/dist/kafka/0.10.0.0/kafka_2.11-0.10.0.0.tgz /opt/kafka_2.11-0.10.0.0.tgz RUN tar -xzf /opt/kafka_2.11-0.10.0.0.tgz -C /opt @@ -24,8 +29,18 @@ RUN echo -n 'advertised.listeners=PLAINTEXT://' >> /opt/kafka_2.11-0.10.0.0/conf RUN echo $DOCKER_HOST | sed "s/tcp:\\/\\///g" | sed "s/:.*/:9092/g" >> /opt/kafka_2.11-0.10.0.0/config/server.properties RUN echo 'delete.topic.enable=true' >> /opt/kafka_2.11-0.10.0.0/config/server.properties RUN yum install -y java-1.8.0-openjdk lsof + +RUN mkdir -p $METRON_HOME ADD ./bin /opt/kafka_2.11-0.10.0.0/bin +RUN chmod 755 /opt/kafka_2.11-0.10.0.0/bin/wait-for-it.sh +ADD ./common /common +ADD ./parser /parser +ADD ./enrichment /enrichment ADD ./data /data +RUN tar -xzf /common/metron-common-$METRON_VERSION-archive.tar.gz -C /usr/metron/$METRON_VERSION/ +RUN tar -xzf /parser/metron-parsers-$METRON_VERSION-archive.tar.gz -C /usr/metron/$METRON_VERSION/ +RUN tar -xzf /enrichment/metron-enrichment-$METRON_VERSION-archive.tar.gz -C /usr/metron/$METRON_VERSION/ +ADD ./conf /$METRON_HOME/config/zookeeper EXPOSE 2181 9092 diff --git a/metron-docker/kafkazk/bin/create-topic.sh b/metron-docker/compose/kafkazk/bin/create-topic.sh similarity index 100% rename from metron-docker/kafkazk/bin/create-topic.sh rename to metron-docker/compose/kafkazk/bin/create-topic.sh diff --git a/metron-docker/kafkazk/bin/init-kafka.sh b/metron-docker/compose/kafkazk/bin/init-kafka.sh similarity index 100% rename from metron-docker/kafkazk/bin/init-kafka.sh rename to metron-docker/compose/kafkazk/bin/init-kafka.sh diff --git a/metron-docker/kafkazk/bin/init-zk.sh b/metron-docker/compose/kafkazk/bin/init-zk.sh similarity index 100% rename from metron-docker/kafkazk/bin/init-zk.sh rename to metron-docker/compose/kafkazk/bin/init-zk.sh diff --git a/metron-docker/kafkazk/bin/output-data.sh b/metron-docker/compose/kafkazk/bin/output-data.sh similarity index 100% rename from metron-docker/kafkazk/bin/output-data.sh rename to metron-docker/compose/kafkazk/bin/output-data.sh diff --git a/metron-docker/kafkazk/bin/produce-data.sh b/metron-docker/compose/kafkazk/bin/produce-data.sh similarity index 100% rename from metron-docker/kafkazk/bin/produce-data.sh rename to metron-docker/compose/kafkazk/bin/produce-data.sh diff --git a/metron-docker/kafkazk/bin/run-consumer.sh b/metron-docker/compose/kafkazk/bin/run-consumer.sh similarity index 100% rename from metron-docker/kafkazk/bin/run-consumer.sh rename to metron-docker/compose/kafkazk/bin/run-consumer.sh diff --git a/metron-docker/kafkazk/bin/start.sh b/metron-docker/compose/kafkazk/bin/start.sh similarity index 100% rename from metron-docker/kafkazk/bin/start.sh rename to metron-docker/compose/kafkazk/bin/start.sh diff --git a/metron-docker/compose/kafkazk/conf/global.json b/metron-docker/compose/kafkazk/conf/global.json new file mode 100644 index 0000000000..4a1e302111 --- /dev/null +++ b/metron-docker/compose/kafkazk/conf/global.json @@ -0,0 +1,6 @@ +{ + "es.clustername": "elasticsearch", + "es.ip": "elasticsearch", + "es.port": "9300", + "es.date.format": "yyyy.MM.dd.HH" +} \ No newline at end of file diff --git a/metron-docker/kafkazk/data/BroExampleOutput.txt b/metron-docker/compose/kafkazk/data/BroExampleOutput.txt similarity index 100% rename from metron-docker/kafkazk/data/BroExampleOutput.txt rename to metron-docker/compose/kafkazk/data/BroExampleOutput.txt diff --git a/metron-docker/kafkazk/data/SquidExampleOutput.txt b/metron-docker/compose/kafkazk/data/SquidExampleOutput.txt similarity index 100% rename from metron-docker/kafkazk/data/SquidExampleOutput.txt rename to metron-docker/compose/kafkazk/data/SquidExampleOutput.txt diff --git a/metron-docker/kibana/Dockerfile b/metron-docker/compose/kibana/Dockerfile similarity index 100% rename from metron-docker/kibana/Dockerfile rename to metron-docker/compose/kibana/Dockerfile diff --git a/metron-docker/kibana/conf/kibana-index.json b/metron-docker/compose/kibana/conf/kibana-index.json similarity index 100% rename from metron-docker/kibana/conf/kibana-index.json rename to metron-docker/compose/kibana/conf/kibana-index.json diff --git a/metron-docker/kibana/images/metron.svg b/metron-docker/compose/kibana/images/metron.svg similarity index 100% rename from metron-docker/kibana/images/metron.svg rename to metron-docker/compose/kibana/images/metron.svg diff --git a/metron-docker/mysql/Dockerfile b/metron-docker/compose/mysql/Dockerfile similarity index 97% rename from metron-docker/mysql/Dockerfile rename to metron-docker/compose/mysql/Dockerfile index bb2392c506..463499817c 100644 --- a/metron-docker/mysql/Dockerfile +++ b/metron-docker/compose/mysql/Dockerfile @@ -23,6 +23,7 @@ ENV METRON_HOME /usr/metron/$METRON_VERSION/ ADD http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLiteCity-latest.tar.xz /tmp/geoip/GeoLiteCity-latest.tar.xz ADD ./bin /usr/local/bin +RUN chmod 755 /usr/local/bin/wait-for-it.sh ADD ./enrichment /enrichment RUN apt-get update diff --git a/metron-docker/mysql/bin/init-mysql.sh b/metron-docker/compose/mysql/bin/init-mysql.sh similarity index 100% rename from metron-docker/mysql/bin/init-mysql.sh rename to metron-docker/compose/mysql/bin/init-mysql.sh diff --git a/metron-docker/mysql/bin/start.sh b/metron-docker/compose/mysql/bin/start.sh similarity index 100% rename from metron-docker/mysql/bin/start.sh rename to metron-docker/compose/mysql/bin/start.sh diff --git a/metron-docker/storm/Dockerfile b/metron-docker/compose/storm/Dockerfile similarity index 97% rename from metron-docker/storm/Dockerfile rename to metron-docker/compose/storm/Dockerfile index 1b576a2eb9..d97ce521fe 100644 --- a/metron-docker/storm/Dockerfile +++ b/metron-docker/compose/storm/Dockerfile @@ -21,6 +21,8 @@ ARG METRON_VERSION ENV METRON_VERSION $METRON_VERSION ENV METRON_HOME /usr/metron/$METRON_VERSION/ +ADD ./bin $METRON_HOME/bin +ADD ./conf $METRON_HOME/config/zookeeper ADD ./parser /parser ADD ./enrichment /enrichment ADD ./indexing /indexing @@ -52,3 +54,5 @@ RUN sed -i -e "s/bolt.hdfs.file.system.url=.*:8020/bolt.hdfs.file.system.url=fil EXPOSE 8080 8000 EXPOSE 8081 8081 + +WORKDIR $METRON_HOME diff --git a/metron-docker/compose/storm/bin/start_docker_parser_topology.sh b/metron-docker/compose/storm/bin/start_docker_parser_topology.sh new file mode 100755 index 0000000000..17712eff68 --- /dev/null +++ b/metron-docker/compose/storm/bin/start_docker_parser_topology.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +$METRON_HOME/bin/start_parser_topology.sh -k kafkazk:9092 -z kafkazk:2181 -s "$@" \ No newline at end of file diff --git a/metron-docker/conf/.env b/metron-docker/conf/.env new file mode 100644 index 0000000000..9b2675d34f --- /dev/null +++ b/metron-docker/conf/.env @@ -0,0 +1,2 @@ +METRON_VERSION=${project.version} +COMPOSE_PROJECT_NAME=metron diff --git a/metron-docker/kafkazk/bin/wait-for-it.sh b/metron-docker/kafkazk/bin/wait-for-it.sh deleted file mode 100755 index eca6c3b9c8..0000000000 --- a/metron-docker/kafkazk/bin/wait-for-it.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash -# Use this script to test if a given TCP host/port are available - -cmdname=$(basename $0) - -echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } - -usage() -{ - cat << USAGE >&2 -Usage: - $cmdname host:port [-s] [-t timeout] [-- command args] - -h HOST | --host=HOST Host or IP under test - -p PORT | --port=PORT TCP port under test - Alternatively, you specify the host and port as host:port - -s | --strict Only execute subcommand if the test succeeds - -q | --quiet Don't output any status messages - -t TIMEOUT | --timeout=TIMEOUT - Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit 1 -} - -wait_for() -{ - if [[ $TIMEOUT -gt 0 ]]; then - echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" - else - echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" - fi - start_ts=$(date +%s) - while : - do - (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 - result=$? - if [[ $result -eq 0 ]]; then - end_ts=$(date +%s) - echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" - break - fi - sleep 1 - done - return $result -} - -wait_for_wrapper() -{ - # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 - if [[ $QUIET -eq 1 ]]; then - timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - else - timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - fi - PID=$! - trap "kill -INT -$PID" INT - wait $PID - RESULT=$? - if [[ $RESULT -ne 0 ]]; then - echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" - fi - return $RESULT -} - -# process arguments -while [[ $# -gt 0 ]] -do - case "$1" in - *:* ) - hostport=(${1//:/ }) - HOST=${hostport[0]} - PORT=${hostport[1]} - shift 1 - ;; - --child) - CHILD=1 - shift 1 - ;; - -q | --quiet) - QUIET=1 - shift 1 - ;; - -s | --strict) - STRICT=1 - shift 1 - ;; - -h) - HOST="$2" - if [[ $HOST == "" ]]; then break; fi - shift 2 - ;; - --host=*) - HOST="${1#*=}" - shift 1 - ;; - -p) - PORT="$2" - if [[ $PORT == "" ]]; then break; fi - shift 2 - ;; - --port=*) - PORT="${1#*=}" - shift 1 - ;; - -t) - TIMEOUT="$2" - if [[ $TIMEOUT == "" ]]; then break; fi - shift 2 - ;; - --timeout=*) - TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - CLI="$@" - break - ;; - --help) - usage - ;; - *) - echoerr "Unknown argument: $1" - usage - ;; - esac -done - -if [[ "$HOST" == "" || "$PORT" == "" ]]; then - echoerr "Error: you need to provide a host and port to test." - usage -fi - -TIMEOUT=${TIMEOUT:-15} -STRICT=${STRICT:-0} -CHILD=${CHILD:-0} -QUIET=${QUIET:-0} - -if [[ $CHILD -gt 0 ]]; then - wait_for - RESULT=$? - exit $RESULT -else - if [[ $TIMEOUT -gt 0 ]]; then - wait_for_wrapper - RESULT=$? - else - wait_for - RESULT=$? - fi -fi - -if [[ $CLI != "" ]]; then - if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then - echoerr "$cmdname: strict mode, refusing to execute subprocess" - exit $RESULT - fi - exec $CLI -else - exit $RESULT -fi diff --git a/metron-docker/mysql/bin/wait-for-it.sh b/metron-docker/mysql/bin/wait-for-it.sh deleted file mode 100755 index eca6c3b9c8..0000000000 --- a/metron-docker/mysql/bin/wait-for-it.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env bash -# Use this script to test if a given TCP host/port are available - -cmdname=$(basename $0) - -echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } - -usage() -{ - cat << USAGE >&2 -Usage: - $cmdname host:port [-s] [-t timeout] [-- command args] - -h HOST | --host=HOST Host or IP under test - -p PORT | --port=PORT TCP port under test - Alternatively, you specify the host and port as host:port - -s | --strict Only execute subcommand if the test succeeds - -q | --quiet Don't output any status messages - -t TIMEOUT | --timeout=TIMEOUT - Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit 1 -} - -wait_for() -{ - if [[ $TIMEOUT -gt 0 ]]; then - echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT" - else - echoerr "$cmdname: waiting for $HOST:$PORT without a timeout" - fi - start_ts=$(date +%s) - while : - do - (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1 - result=$? - if [[ $result -eq 0 ]]; then - end_ts=$(date +%s) - echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds" - break - fi - sleep 1 - done - return $result -} - -wait_for_wrapper() -{ - # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 - if [[ $QUIET -eq 1 ]]; then - timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - else - timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT & - fi - PID=$! - trap "kill -INT -$PID" INT - wait $PID - RESULT=$? - if [[ $RESULT -ne 0 ]]; then - echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT" - fi - return $RESULT -} - -# process arguments -while [[ $# -gt 0 ]] -do - case "$1" in - *:* ) - hostport=(${1//:/ }) - HOST=${hostport[0]} - PORT=${hostport[1]} - shift 1 - ;; - --child) - CHILD=1 - shift 1 - ;; - -q | --quiet) - QUIET=1 - shift 1 - ;; - -s | --strict) - STRICT=1 - shift 1 - ;; - -h) - HOST="$2" - if [[ $HOST == "" ]]; then break; fi - shift 2 - ;; - --host=*) - HOST="${1#*=}" - shift 1 - ;; - -p) - PORT="$2" - if [[ $PORT == "" ]]; then break; fi - shift 2 - ;; - --port=*) - PORT="${1#*=}" - shift 1 - ;; - -t) - TIMEOUT="$2" - if [[ $TIMEOUT == "" ]]; then break; fi - shift 2 - ;; - --timeout=*) - TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - CLI="$@" - break - ;; - --help) - usage - ;; - *) - echoerr "Unknown argument: $1" - usage - ;; - esac -done - -if [[ "$HOST" == "" || "$PORT" == "" ]]; then - echoerr "Error: you need to provide a host and port to test." - usage -fi - -TIMEOUT=${TIMEOUT:-15} -STRICT=${STRICT:-0} -CHILD=${CHILD:-0} -QUIET=${QUIET:-0} - -if [[ $CHILD -gt 0 ]]; then - wait_for - RESULT=$? - exit $RESULT -else - if [[ $TIMEOUT -gt 0 ]]; then - wait_for_wrapper - RESULT=$? - else - wait_for - RESULT=$? - fi -fi - -if [[ $CLI != "" ]]; then - if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then - echoerr "$cmdname: strict mode, refusing to execute subprocess" - exit $RESULT - fi - exec $CLI -else - exit $RESULT -fi diff --git a/metron-docker/pom.xml b/metron-docker/pom.xml new file mode 100644 index 0000000000..4c30035bbf --- /dev/null +++ b/metron-docker/pom.xml @@ -0,0 +1,276 @@ + + + + + 4.0.0 + metron-docker + pom + metron-docker + + org.apache.metron + Metron + 0.3.0 + + Metron Docker + + UTF-8 + UTF-8 + + + + + maven-resources-plugin + 3.0.1 + + + copy-common-to-kafkazk + prepare-package + + copy-resources + + + ${project.basedir}/compose/kafkazk/common + + + ../metron-platform/metron-common/target/ + + *.tar.gz + + + + + + + copy-parsers-to-kafkazk + prepare-package + + copy-resources + + + ${project.basedir}/compose/kafkazk/parser + + + ../metron-platform/metron-parsers/target/ + + *.tar.gz + + + + + + + copy-enrichment-to-kafkazk + prepare-package + + copy-resources + + + ${project.basedir}/compose/kafkazk/enrichment + + + ../metron-platform/metron-enrichment/target/ + + *.tar.gz + + + + + + + copy-data-management-to-hbase + prepare-package + + copy-resources + + + ${project.basedir}/compose/hbase/data-management + + + ../metron-platform/metron-data-management/target/ + + *.tar.gz + + + + + + + copy-enrichment-to-mysql + prepare-package + + copy-resources + + + ${project.basedir}/compose/mysql/enrichment + + + ../metron-platform/metron-enrichment/target/ + + *.tar.gz + + + + + + + copy-parsers-to-storm + prepare-package + + copy-resources + + + ${project.basedir}/compose/storm/parser + + + ${project.basedir}/../metron-platform/metron-parsers/target/ + + *.tar.gz + + + + + + + copy-enrichment-to-storm + prepare-package + + copy-resources + + + ${project.basedir}/compose/storm/enrichment + + + ${project.basedir}/../metron-platform/metron-enrichment/target/ + + *.tar.gz + + + + + + + copy-indexing-to-storm + prepare-package + + copy-resources + + + ${project.basedir}/compose/storm/indexing + + + ${project.basedir}/../metron-platform/metron-indexing/target/ + + *.tar.gz + + + + + + + copy-elasticsearch-to-storm + prepare-package + + copy-resources + + + ${project.basedir}/compose/storm/elasticsearch + + + ../metron-platform/metron-elasticsearch/target/ + + *.tar.gz + + + + + + + filter-docker-env + prepare-package + + copy-resources + + + ${project.basedir}/compose + + + ./conf + true + + .env + + + + + + + copy-wait-for-it-to-hbase + prepare-package + + copy-resources + + + ${project.basedir}/compose/hbase/bin + + + ./scripts + + wait-for-it.sh + + + + + + + copy-wait-for-it-to-kafkazk + prepare-package + + copy-resources + + + ${project.basedir}/compose/kafkazk/bin + + + ./scripts + + wait-for-it.sh + + + + + + + copy-wait-for-it-to-mysql + prepare-package + + copy-resources + + + ${project.basedir}/compose/mysql/bin + + + ./scripts + + wait-for-it.sh + + + + + + + + + + \ No newline at end of file diff --git a/metron-docker/create-docker-machine.sh b/metron-docker/scripts/create-docker-machine.sh similarity index 100% rename from metron-docker/create-docker-machine.sh rename to metron-docker/scripts/create-docker-machine.sh diff --git a/metron-docker/hbase/bin/wait-for-it.sh b/metron-docker/scripts/wait-for-it.sh similarity index 100% rename from metron-docker/hbase/bin/wait-for-it.sh rename to metron-docker/scripts/wait-for-it.sh diff --git a/metron-platform/metron-common/src/main/scripts/zk_load_configs.sh b/metron-platform/metron-common/src/main/scripts/zk_load_configs.sh index ff64e3d752..e28ca235b7 100755 --- a/metron-platform/metron-common/src/main/scripts/zk_load_configs.sh +++ b/metron-platform/metron-common/src/main/scripts/zk_load_configs.sh @@ -30,4 +30,5 @@ export METRON_VERSION=${project.version} export METRON_HOME=/usr/metron/$METRON_VERSION export PARSERS_JAR=${project.artifactId}-$METRON_VERSION.jar export ZK_HOME=${ZK_HOME:-/usr/hdp/current/zookeeper-client} -java -cp $METRON_HOME/lib/$PARSERS_JAR:$ZK_HOME/lib/* org.apache.metron.common.cli.ConfigurationManager "$@" +export ZK_CLIENT_JARS=${ZK_CLIENT_JARS:-$ZK_HOME/lib} +java -cp $METRON_HOME/lib/$PARSERS_JAR:$ZK_CLIENT_JARS/* org.apache.metron.common.cli.ConfigurationManager "$@" diff --git a/pom.xml b/pom.xml index f2dce7470b..72660639ac 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,7 @@ metron-analytics metron-platform metron-deployment + metron-docker From bd4b81bfe459ac28324000b419d9328f82d57b87 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Tue, 20 Dec 2016 08:35:30 -0600 Subject: [PATCH 23/54] Added commons-lang:2.4 to dependencies_with_url.csv --- dependencies_with_url.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/dependencies_with_url.csv b/dependencies_with_url.csv index 9071940225..f60730346a 100644 --- a/dependencies_with_url.csv +++ b/dependencies_with_url.csv @@ -157,6 +157,7 @@ commons-httpclient:commons-httpclient:jar:3.1:compile,Apache License,http://jaka commons-io:commons-io:jar:2.4:compile,ASLv2,http://commons.apache.org/io/ commons-io:commons-io:jar:2.5:compile,ASLv2,http://commons.apache.org/io/ commons-io:commons-io:jar:2.4:provided,ASLv2,http://commons.apache.org/io/ +commons-lang:commons-lang:jar:2.4:compile,ASLv2,http://commons.apache.org/lang/ commons-lang:commons-lang:jar:2.5:compile,ASLv2,http://commons.apache.org/lang/ commons-lang:commons-lang:jar:2.6:compile,ASLv2,http://commons.apache.org/lang/ commons-lang:commons-lang:jar:2.6:provided,ASLv2,http://commons.apache.org/lang/ From adce9216629611208f496be291ab7f839b3a9d9c Mon Sep 17 00:00:00 2001 From: rmerriman Date: Wed, 21 Dec 2016 11:16:55 -0600 Subject: [PATCH 24/54] Removed config directory --- metron-docker/compose/storm/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/metron-docker/compose/storm/Dockerfile b/metron-docker/compose/storm/Dockerfile index d97ce521fe..75191db8ce 100644 --- a/metron-docker/compose/storm/Dockerfile +++ b/metron-docker/compose/storm/Dockerfile @@ -22,7 +22,6 @@ ENV METRON_VERSION $METRON_VERSION ENV METRON_HOME /usr/metron/$METRON_VERSION/ ADD ./bin $METRON_HOME/bin -ADD ./conf $METRON_HOME/config/zookeeper ADD ./parser /parser ADD ./enrichment /enrichment ADD ./indexing /indexing From 2861756c9c7601eca96c0e46148a24e37634a07d Mon Sep 17 00:00:00 2001 From: rmerriman Date: Wed, 21 Dec 2016 11:46:11 -0600 Subject: [PATCH 25/54] Updated docker compose path in application-docker.yml --- .../java/org/apache/metron/rest/service/StormCLIWrapper.java | 2 +- .../metron-rest/src/main/resources/application-docker.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java index 692d058ec7..0c2f890006 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java @@ -134,7 +134,7 @@ protected String stormClientVersionInstalled() throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); List lines = reader.lines().collect(toList()); lines.forEach(System.out::println); - if (lines.size() > 0) { + if (lines.size() > 1) { stormClientVersionInstalled = lines.get(1).replaceFirst("Storm ", ""); } return stormClientVersionInstalled; diff --git a/metron-interface/metron-rest/src/main/resources/application-docker.yml b/metron-interface/metron-rest/src/main/resources/application-docker.yml index cce6f75a94..859ca5ee40 100644 --- a/metron-interface/metron-rest/src/main/resources/application-docker.yml +++ b/metron-interface/metron-rest/src/main/resources/application-docker.yml @@ -17,7 +17,7 @@ docker: host: address: 192.168.99.100 compose: - path: ../../metron-docker/docker-compose.yml + path: ../../metron-docker/compose/docker-compose.yml spring: datasource: From 9bab5022aebee995173c66b0733b95ea6b7a952f Mon Sep 17 00:00:00 2001 From: rmerriman Date: Tue, 10 Jan 2017 15:24:14 -0600 Subject: [PATCH 26/54] Moved model classes to separate metron-rest-client project. Added documentation for all Http response codes. --- metron-interface/metron-rest-client/pom.xml | 54 ++ .../metron/rest/model/GrokValidation.java | 0 .../apache/metron/rest/model/KafkaTopic.java | 0 .../rest/model/ParseMessageRequest.java | 0 .../rest/model/SensorParserConfigHistory.java | 0 .../rest/model/SensorParserConfigVersion.java | 0 .../model/StellarFunctionDescription.java | 0 .../metron/rest/model/TopologyResponse.java | 0 .../metron/rest/model/TopologyStatus.java | 0 .../metron/rest/model/TopologyStatusCode.java | 0 .../metron/rest/model/TopologySummary.java | 0 .../rest/model/TransformationValidation.java | 0 metron-interface/metron-rest/README.md | 157 ++-- metron-interface/metron-rest/pom.xml | 671 +++++++++--------- .../controller/GlobalConfigController.java | 9 +- .../rest/controller/KafkaController.java | 14 +- .../SensorEnrichmentConfigController.java | 13 +- .../SensorParserConfigController.java | 17 +- .../SensorParserConfigHistoryController.java | 8 +- .../rest/controller/StormController.java | 38 +- .../controller/TransformationController.java | 10 +- .../apache/metron/rest/utils/ReadMeUtils.java | 19 +- .../metron/rest/utils/RestControllerInfo.java | 39 +- .../metron-rest/src/test/resources/README.vm | 5 +- 24 files changed, 618 insertions(+), 436 deletions(-) create mode 100644 metron-interface/metron-rest-client/pom.xml rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/GrokValidation.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/KafkaTopic.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/TopologyResponse.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/TopologyStatus.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/TopologyStatusCode.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/TopologySummary.java (100%) rename metron-interface/{metron-rest => metron-rest-client}/src/main/java/org/apache/metron/rest/model/TransformationValidation.java (100%) diff --git a/metron-interface/metron-rest-client/pom.xml b/metron-interface/metron-rest-client/pom.xml new file mode 100644 index 0000000000..29937fa484 --- /dev/null +++ b/metron-interface/metron-rest-client/pom.xml @@ -0,0 +1,54 @@ + + + + + 4.0.0 + + org.apache.metron + metron-interface + 0.3.0 + + metron-rest-client + ${project.parent.version} + + 2.9.4 + 5.0.11.Final + + + + org.apache.metron + metron-common + ${project.parent.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + joda-time + joda-time + ${joda.time.version} + + + org.hibernate + hibernate-envers + ${hibernate.version} + provided + + + + diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/GrokValidation.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/GrokValidation.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/KafkaTopic.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/KafkaTopic.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/KafkaTopic.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/KafkaTopic.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyResponse.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyResponse.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatus.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyStatus.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatus.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyStatus.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatusCode.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyStatusCode.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologyStatusCode.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyStatusCode.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologySummary.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TopologySummary.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TransformationValidation.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TransformationValidation.java similarity index 100% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/model/TransformationValidation.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TransformationValidation.java diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index 5c0063b4a7..5438324ebf 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -118,245 +118,306 @@ Request and Response objects are JSON formatted. The JSON schemas are available ### `GET /api/v1/globalConfig` * Description: Retrieves the current Global Config from Zookeeper - * Returns: Current Global Config JSON in Zookeeper + * Returns: + * 200 - Returns current Global Config JSON in Zookeeper + * 404 - Global Config JSON was not found in Zookeeper ### `DELETE /api/v1/globalConfig` * Description: Deletes the current Global Config from Zookeeper - * Returns: No return value + * Returns: + * 200 - Global Config JSON was deleted + * 404 - Global Config JSON was not found in Zookeeper ### `POST /api/v1/globalConfig` * Description: Creates or updates the Global Config in Zookeeper * Input: * globalConfig - The Global Config JSON to be saved - * Returns: Saved Global Config JSON + * Returns: + * 200 - Returns saved Global Config JSON ### `GET /api/v1/grok/list` * Description: Lists the common Grok statements available in Metron - * Returns: JSON object containing pattern label/Grok statements key value pairs + * Returns: + * 200 - JSON object containing pattern label/Grok statements key value pairs ### `POST /api/v1/grok/validate` * Description: Applies a Grok statement to a sample message * Input: * grokValidation - Object containing Grok statment and sample message - * Returns: JSON results + * Returns: + * 200 - JSON results ### `GET /api/v1/kafka/topic` * Description: Retrieves all Kafka topics - * Returns: A list of all Kafka topics + * Returns: + * 200 - Returns a list of all Kafka topics ### `POST /api/v1/kafka/topic` * Description: Creates a new Kafka topic * Input: * topic - Kafka topic - * Returns: Saved Kafka topic + * Returns: + * 200 - Returns saved Kafka topic ### `GET /api/v1/kafka/topic/{name}` * Description: Retrieves a Kafka topic * Input: * name - Kafka topic name - * Returns: Kafka topic + * Returns: + * 200 - Returns Kafka topic + * 404 - Kafka topic is missing ### `DELETE /api/v1/kafka/topic/{name}` * Description: Delets a Kafka topic * Input: * name - Kafka topic name - * Returns: No return value + * Returns: + * 200 - Kafka topic was deleted + * 404 - Kafka topic is missing ### `GET /api/v1/kafka/topic/{name}/sample` * Description: Retrieves a sample message from a Kafka topic using the most recent offset * Input: * name - Kafka topic name - * Returns: Sample message + * Returns: + * 200 - Returns sample message + * 404 - Either Kafka topic is missing or contains no messages ### `GET /api/v1/sensorEnrichmentConfig` * Description: Retrieves all SensorEnrichmentConfigs from Zookeeper - * Returns: All SensorEnrichmentConfigs + * Returns: + * 200 - Returns all SensorEnrichmentConfigs ### `GET /api/v1/sensorEnrichmentConfig/list/available` * Description: Lists the available enrichments - * Returns: List of available enrichments + * Returns: + * 200 - Returns a list of available enrichments ### `DELETE /api/v1/sensorEnrichmentConfig/{name}` * Description: Deletes a SensorEnrichmentConfig from Zookeeper * Input: * name - SensorEnrichmentConfig name - * Returns: No return value + * Returns: + * 200 - SensorEnrichmentConfig was deleted + * 404 - SensorEnrichmentConfig is missing ### `POST /api/v1/sensorEnrichmentConfig/{name}` * Description: Updates or creates a SensorEnrichmentConfig in Zookeeper * Input: * sensorEnrichmentConfig - SensorEnrichmentConfig * name - SensorEnrichmentConfig name - * Returns: Saved SensorEnrichmentConfig + * Returns: + * 200 - Returns saved SensorEnrichmentConfig ### `GET /api/v1/sensorEnrichmentConfig/{name}` * Description: Retrieves a SensorEnrichmentConfig from Zookeeper * Input: * name - SensorEnrichmentConfig name - * Returns: SensorEnrichmentConfig + * Returns: + * 200 - Returns SensorEnrichmentConfig + * 404 - SensorEnrichmentConfig is missing ### `POST /api/v1/sensorParserConfig` * Description: Updates or creates a SensorParserConfig in Zookeeper * Input: * sensorParserConfig - SensorParserConfig - * Returns: Saved SensorParserConfig + * Returns: + * 200 - Returns saved SensorParserConfig ### `GET /api/v1/sensorParserConfig` * Description: Retrieves all SensorParserConfigs from Zookeeper - * Returns: All SensorParserConfigs + * Returns: + * 200 - Returns all SensorParserConfigs ### `GET /api/v1/sensorParserConfig/list/available` * Description: Lists the available parser classes that can be found on the classpath - * Returns: List of available parser classes + * Returns: + * 200 - Returns a list of available parser classes ### `POST /api/v1/sensorParserConfig/parseMessage` * Description: Parses a sample message given a SensorParserConfig * Input: * parseMessageRequest - Object containing a sample message and SensorParserConfig - * Returns: Parsed message + * Returns: + * 200 - Returns parsed message ### `GET /api/v1/sensorParserConfig/reload/available` * Description: Scans the classpath for available parser classes and reloads the cached parser class list - * Returns: List of available parser classes + * Returns: + * 200 - Returns a list of available parser classes ### `DELETE /api/v1/sensorParserConfig/{name}` * Description: Deletes a SensorParserConfig from Zookeeper * Input: * name - SensorParserConfig name - * Returns: No return value + * Returns: + * 200 - SensorParserConfig was deleted + * 404 - SensorParserConfig is missing ### `GET /api/v1/sensorParserConfig/{name}` * Description: Retrieves a SensorParserConfig from Zookeeper * Input: * name - SensorParserConfig name - * Returns: SensorParserConfig + * Returns: + * 200 - Returns SensorParserConfig + * 404 - SensorParserConfig is missing ### `GET /api/v1/sensorParserConfigHistory` * Description: Retrieves all current versions of SensorParserConfigs including audit information - * Returns: SensorParserConfigs with audit information + * Returns: + * 200 - Returns all SensorParserConfigs with audit information ### `GET /api/v1/sensorParserConfigHistory/history/{name}` * Description: Retrieves the history of all changes made to a SensorParserConfig * Input: * name - SensorParserConfig name - * Returns: SensorParserConfig history + * Returns: + * 200 - Returns SensorParserConfig history ### `GET /api/v1/sensorParserConfigHistory/{name}` * Description: Retrieves the current version of a SensorParserConfig including audit information * Input: * name - SensorParserConfig name - * Returns: SensorParserConfig with audit information + * Returns: + * 200 - Returns SensorParserConfig with audit information + * 404 - SensorParserConfig is missing ### `GET /api/v1/storm` * Description: Retrieves the status of all Storm topologies - * Returns: List of topologies with status information + * Returns: + * 200 - Returns a list of topologies with status information ### `GET /api/v1/storm/client/status` * Description: Retrieves information about the Storm command line client - * Returns: Storm command line client information + * Returns: + * 200 - Returns storm command line client information ### `GET /api/v1/storm/enrichment` * Description: Retrieves the status of the Storm enrichment topology - * Returns: Topology status information + * Returns: + * 200 - Returns topology status information + * 404 - Topology is missing ### `GET /api/v1/storm/enrichment/activate` * Description: Activates a Storm enrichment topology - * Returns: Activate response message + * Returns: + * 200 - Returns activate response message ### `GET /api/v1/storm/enrichment/deactivate` * Description: Deactivates a Storm enrichment topology - * Returns: Deactivate response message + * Returns: + * 200 - Returns deactivate response message ### `GET /api/v1/storm/enrichment/start` * Description: Starts a Storm enrichment topology - * Returns: Start response message + * Returns: + * 200 - Returns start response message ### `GET /api/v1/storm/enrichment/stop` * Description: Stops a Storm enrichment topology * Input: * stopNow - Stop the topology immediately - * Returns: Stop response message + * Returns: + * 200 - Returns stop response message ### `GET /api/v1/storm/indexing` * Description: Retrieves the status of the Storm indexing topology - * Returns: Topology status information + * Returns: + * 200 - Returns topology status information + * 404 - Topology is missing ### `GET /api/v1/storm/indexing/activate` * Description: Activates a Storm indexing topology - * Returns: Activate response message + * Returns: + * 200 - Returns activate response message ### `GET /api/v1/storm/indexing/deactivate` * Description: Deactivates a Storm indexing topology - * Returns: Deactivate response message + * Returns: + * 200 - Returns deactivate response message ### `GET /api/v1/storm/indexing/start` * Description: Starts a Storm indexing topology - * Returns: Start response message + * Returns: + * 200 - Returns start response message ### `GET /api/v1/storm/indexing/stop` * Description: Stops a Storm enrichment topology * Input: * stopNow - Stop the topology immediately - * Returns: Stop response message + * Returns: + * 200 - Returns stop response message ### `GET /api/v1/storm/parser/activate/{name}` * Description: Activates a Storm parser topology * Input: * name - Parser name - * Returns: Activate response message + * Returns: + * 200 - Returns activate response message ### `GET /api/v1/storm/parser/deactivate/{name}` * Description: Deactivates a Storm parser topology * Input: * name - Parser name - * Returns: Deactivate response message + * Returns: + * 200 - Returns deactivate response message ### `GET /api/v1/storm/parser/start/{name}` * Description: Starts a Storm parser topology * Input: * name - Parser name - * Returns: Start response message + * Returns: + * 200 - Returns start response message ### `GET /api/v1/storm/parser/stop/{name}` * Description: Stops a Storm parser topology * Input: * name - Parser name * stopNow - Stop the topology immediately - * Returns: Stop response message + * Returns: + * 200 - Returns stop response message ### `GET /api/v1/storm/{name}` * Description: Retrieves the status of a Storm topology * Input: * name - Topology name - * Returns: Topology status information + * Returns: + * 200 - Returns topology status information + * 404 - Topology is missing ### `GET /api/v1/transformation/list` * Description: Retrieves field transformations - * Returns: List field transformations + * Returns: + * 200 - Returns a list field transformations ### `GET /api/v1/transformation/list/functions` * Description: Lists the Stellar functions that can be found on the classpath - * Returns: List of Stellar functions + * Returns: + * 200 - Returns a list of Stellar functions ### `GET /api/v1/transformation/list/simple/functions` * Description: Lists the simple Stellar functions (functions with only 1 input) that can be found on the classpath - * Returns: List of simple Stellar functions + * Returns: + * 200 - Returns a list of simple Stellar functions ### `POST /api/v1/transformation/validate` * Description: Executes transformations against a sample message * Input: * transformationValidation - Object containing SensorParserConfig and sample message - * Returns: Transformation results + * Returns: + * 200 - Returns transformation results ### `POST /api/v1/transformation/validate/rules` * Description: Tests Stellar statements to ensure they are well-formed * Input: * statements - List of statements to validate - * Returns: Validation results + * Returns: + * 200 - Returns validation results ### `GET /api/v1/user` * Description: Retrieves the current user - * Returns: Current user + * Returns: + * 200 - Current user ## License diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index fa7647cd08..1682fa47c5 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -13,340 +13,345 @@ --> - 4.0.0 - - org.apache.metron - metron-interface - 0.3.0 - - metron-rest - ${project.parent.version} - - UTF-8 - UTF-8 - 1.8 - 4.5 - 2.7.1 - 1.6.4 - 1.4.1.RELEASE - 2.5.0 - 5.1.40 - 2.9.4 - 5.0.11.Final - - - - org.springframework.boot - spring-boot-starter-web - - - ch.qos.logback - logback-classic - - - org.slf4j - log4j-over-slf4j - - - org.hibernate - hibernate-validator - - - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.hibernate - hibernate-core - - - org.hibernate - hibernate-entitymanager - - - - - org.hibernate - hibernate-core - ${hibernate.version} - provided - - - mysql - mysql-connector-java - ${mysql.client.version} - provided - - - org.apache.curator - curator-recipes - ${curator.version} - - - com.googlecode.json-simple - json-simple - ${global_json_simple_version} - - - org.antlr - antlr4-runtime - ${antlr.version} - - - com.fasterxml.jackson.core - jackson-databind - 2.8.3 - - - com.fasterxml.jackson.datatype - jackson-datatype-joda - 2.8.1 - - - org.apache.metron - metron-common - ${project.parent.version} - - - com.fasterxml.jackson.core - jackson-databind - - - - - org.apache.metron - metron-parsers - ${project.parent.version} - - - com.fasterxml.jackson.core - jackson-databind - - - org.apache.metron - metron-profiler-client - - - org.apache.metron - metron-writer - - - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - org.apache.kafka - kafka_2.10 - ${global_kafka_version} - - - joda-time - joda-time - ${joda.time.version} - - - org.hibernate - hibernate-envers - ${hibernate.version} - provided - - - io.thekraken - grok - 0.1.0 - - - org.reflections - reflections - 0.9.10 - - - com.google.code.findbugs - annotations - - - - - - org.springframework.boot - spring-boot-starter-test - test - - - com.h2database - h2 - test - - - org.springframework.security - spring-security-test - test - - - org.powermock - powermock-module-junit4 - ${powermock.version} - test - - - org.powermock - powermock-api-mockito - ${powermock.version} - test - - - org.apache.metron - metron-integration-test - ${project.parent.version} - test - - - org.apache.logging.log4j - log4j-slf4j-impl - - - org.slf4j - log4j-over-slf4j - - - javax.servlet - servlet-api - - - - - org.apache.kafka - kafka-clients - ${global_kafka_version} - test - test - - - log4j - log4j - - - - - org.apache.velocity - velocity - 1.7 - test - - - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.apache.metron + metron-interface + 0.3.0 + + metron-rest + ${project.parent.version} + + UTF-8 + UTF-8 + 1.8 + 4.5 + 2.7.1 + 1.6.4 + 1.4.1.RELEASE + 2.5.0 + 5.1.40 + 2.9.4 + 5.0.11.Final + - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - org.apache.logging.log4j - log4j-slf4j-impl - - - ch.qos.logback - logback-classic - - - + + org.springframework.boot + spring-boot-starter-web + + + ch.qos.logback + logback-classic + + + org.slf4j + log4j-over-slf4j + + + org.hibernate + hibernate-validator + + + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.hibernate + hibernate-core + + + org.hibernate + hibernate-entitymanager + + + + + org.hibernate + hibernate-core + ${hibernate.version} + provided + + + mysql + mysql-connector-java + ${mysql.client.version} + provided + + + org.apache.curator + curator-recipes + ${curator.version} + + + com.googlecode.json-simple + json-simple + ${global_json_simple_version} + + + org.antlr + antlr4-runtime + ${antlr.version} + + + com.fasterxml.jackson.core + jackson-databind + 2.8.3 + + + com.fasterxml.jackson.datatype + jackson-datatype-joda + 2.8.1 + + + org.apache.metron + metron-rest-client + ${project.parent.version} + + + org.apache.metron + metron-common + ${project.parent.version} + + + com.fasterxml.jackson.core + jackson-databind + + + + + org.apache.metron + metron-parsers + ${project.parent.version} + + + com.fasterxml.jackson.core + jackson-databind + + + org.apache.metron + metron-profiler-client + + + org.apache.metron + metron-writer + + + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + org.apache.kafka + kafka_2.10 + ${global_kafka_version} + + + joda-time + joda-time + ${joda.time.version} + + + org.hibernate + hibernate-envers + ${hibernate.version} + provided + + + io.thekraken + grok + 0.1.0 + + + org.reflections + reflections + 0.9.10 + + + com.google.code.findbugs + annotations + + + + + + org.springframework.boot + spring-boot-starter-test + test + + + com.h2database + h2 + test + + + org.springframework.security + spring-security-test + test + + + org.powermock + powermock-module-junit4 + ${powermock.version} + test + + + org.powermock + powermock-api-mockito + ${powermock.version} + test + + + org.apache.metron + metron-integration-test + ${project.parent.version} + test + + + org.apache.logging.log4j + log4j-slf4j-impl + + + org.slf4j + log4j-over-slf4j + + + javax.servlet + servlet-api + + + + + org.apache.kafka + kafka-clients + ${global_kafka_version} + test + test + + + log4j + log4j + + + + + org.apache.velocity + velocity + 1.7 + test + - - - - - org.codehaus.mojo - emma-maven-plugin - 1.0-alpha-3 - - - org.apache.maven.plugins - maven-pmd-plugin - - ${global_java_version} - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - ZIP - - - mysql - mysql-connector-java - - - org.hibernate.common - hibernate-commons-annotations - - - org.hibernate - hibernate-core - - - org.hibernate - hibernate-envers - - - org.hibernate - hibernate-entitymanager - - - org.hibernate.javax.persistence - hibernate-jpa-2.1-api - - - - - - maven-assembly-plugin - - src/main/assembly/assembly.xml - - - - make-assembly - package - - single - - - - - - + + + + + org.springframework.boot + spring-boot-dependencies + ${spring.boot.version} + pom + import + + + org.apache.logging.log4j + log4j-slf4j-impl + + + ch.qos.logback + logback-classic + + + + + + + + + + org.codehaus.mojo + emma-maven-plugin + 1.0-alpha-3 + + + org.apache.maven.plugins + maven-pmd-plugin + + ${global_java_version} + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + ZIP + + + mysql + mysql-connector-java + + + org.hibernate.common + hibernate-commons-annotations + + + org.hibernate + hibernate-core + + + org.hibernate + hibernate-envers + + + org.hibernate + hibernate-entitymanager + + + org.hibernate.javax.persistence + hibernate-jpa-2.1-api + + + + + + maven-assembly-plugin + + src/main/assembly/assembly.xml + + + + make-assembly + package + + single + + + + + + diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java index a95500997f..47f50e889f 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.apache.metron.rest.service.GlobalConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -39,14 +40,15 @@ public class GlobalConfigController { private GlobalConfigService globalConfigService; @ApiOperation(value = "Creates or updates the Global Config in Zookeeper") - @ApiResponse(message = "Saved Global Config JSON", code = 200) + @ApiResponse(message = "Returns saved Global Config JSON", code = 200) @RequestMapping(method = RequestMethod.POST) ResponseEntity> save(@ApiParam(name="globalConfig", value="The Global Config JSON to be saved", required=true)@RequestBody Map globalConfig) throws Exception { return new ResponseEntity<>(globalConfigService.save(globalConfig), HttpStatus.CREATED); } @ApiOperation(value = "Retrieves the current Global Config from Zookeeper") - @ApiResponse(message = "Current Global Config JSON in Zookeeper", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Returns current Global Config JSON in Zookeeper", code = 200), + @ApiResponse(message = "Global Config JSON was not found in Zookeeper", code = 404) }) @RequestMapping(method = RequestMethod.GET) ResponseEntity> get() throws Exception { Map globalConfig = globalConfigService.get(); @@ -58,7 +60,8 @@ ResponseEntity> get() throws Exception { } @ApiOperation(value = "Deletes the current Global Config from Zookeeper") - @ApiResponse(message = "No return value", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Global Config JSON was deleted", code = 200), + @ApiResponse(message = "Global Config JSON was not found in Zookeeper", code = 404) }) @RequestMapping(method = RequestMethod.DELETE) ResponseEntity delete() throws Exception { if (globalConfigService.delete()) { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java index e9513819fa..ada1b137d2 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.apache.metron.rest.model.KafkaTopic; import org.apache.metron.rest.service.KafkaService; import org.springframework.beans.factory.annotation.Autowired; @@ -41,14 +42,15 @@ public class KafkaController { private KafkaService kafkaService; @ApiOperation(value = "Creates a new Kafka topic") - @ApiResponse(message = "Saved Kafka topic", code = 200) + @ApiResponse(message = "Returns saved Kafka topic", code = 200) @RequestMapping(value = "/topic", method = RequestMethod.POST) ResponseEntity save(@ApiParam(name="topic", value="Kafka topic", required=true)@RequestBody KafkaTopic topic) throws Exception { return new ResponseEntity<>(kafkaService.createTopic(topic), HttpStatus.CREATED); } @ApiOperation(value = "Retrieves a Kafka topic") - @ApiResponse(message = "Kafka topic", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Returns Kafka topic", code = 200), + @ApiResponse(message = "Kafka topic is missing", code = 404) }) @RequestMapping(value = "/topic/{name}", method = RequestMethod.GET) ResponseEntity get(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws Exception { KafkaTopic kafkaTopic = kafkaService.getTopic(name); @@ -60,14 +62,15 @@ ResponseEntity get(@ApiParam(name="name", value="Kafka topic name", } @ApiOperation(value = "Retrieves all Kafka topics") - @ApiResponse(message = "A list of all Kafka topics", code = 200) + @ApiResponse(message = "Returns a list of all Kafka topics", code = 200) @RequestMapping(value = "/topic", method = RequestMethod.GET) ResponseEntity> list() throws Exception { return new ResponseEntity<>(kafkaService.listTopics(), HttpStatus.OK); } @ApiOperation(value = "Delets a Kafka topic") - @ApiResponse(message = "No return value", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Kafka topic was deleted", code = 200), + @ApiResponse(message = "Kafka topic is missing", code = 404) }) @RequestMapping(value = "/topic/{name}", method = RequestMethod.DELETE) ResponseEntity delete(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws Exception { if (kafkaService.deleteTopic(name)) { @@ -78,7 +81,8 @@ ResponseEntity delete(@ApiParam(name="name", value="Kafka topic name", req } @ApiOperation(value = "Retrieves a sample message from a Kafka topic using the most recent offset") - @ApiResponse(message = "Sample message", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Returns sample message", code = 200), + @ApiResponse(message = "Either Kafka topic is missing or contains no messages", code = 404) }) @RequestMapping(value = "/topic/{name}/sample", method = RequestMethod.GET) ResponseEntity getSample(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws Exception { String sampleMessage = kafkaService.getSampleMessage(name); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java index 57075b3838..1cda0c8e62 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; import org.apache.metron.rest.service.SensorEnrichmentConfigService; import org.springframework.beans.factory.annotation.Autowired; @@ -41,7 +42,7 @@ public class SensorEnrichmentConfigController { private SensorEnrichmentConfigService sensorEnrichmentConfigService; @ApiOperation(value = "Updates or creates a SensorEnrichmentConfig in Zookeeper") - @ApiResponse(message = "Saved SensorEnrichmentConfig", code = 200) + @ApiResponse(message = "Returns saved SensorEnrichmentConfig", code = 200) @RequestMapping(value = "/{name}", method = RequestMethod.POST) ResponseEntity save(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name, @ApiParam(name="sensorEnrichmentConfig", value="SensorEnrichmentConfig", required=true)@RequestBody SensorEnrichmentConfig sensorEnrichmentConfig) throws Exception { @@ -49,7 +50,8 @@ ResponseEntity save(@ApiParam(name="name", value="Sensor } @ApiOperation(value = "Retrieves a SensorEnrichmentConfig from Zookeeper") - @ApiResponse(message = "SensorEnrichmentConfig", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Returns SensorEnrichmentConfig", code = 200), + @ApiResponse(message = "SensorEnrichmentConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.GET) ResponseEntity findOne(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name) throws Exception { SensorEnrichmentConfig sensorEnrichmentConfig = sensorEnrichmentConfigService.findOne(name); @@ -61,14 +63,15 @@ ResponseEntity findOne(@ApiParam(name="name", value="Sen } @ApiOperation(value = "Retrieves all SensorEnrichmentConfigs from Zookeeper") - @ApiResponse(message = "All SensorEnrichmentConfigs", code = 200) + @ApiResponse(message = "Returns all SensorEnrichmentConfigs", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> getAll() throws Exception { return new ResponseEntity<>(sensorEnrichmentConfigService.getAll(), HttpStatus.OK); } @ApiOperation(value = "Deletes a SensorEnrichmentConfig from Zookeeper") - @ApiResponse(message = "No return value", code = 200) + @ApiResponses(value = { @ApiResponse(message = "SensorEnrichmentConfig was deleted", code = 200), + @ApiResponse(message = "SensorEnrichmentConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) ResponseEntity delete(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name) throws Exception { if (sensorEnrichmentConfigService.delete(name)) { @@ -79,7 +82,7 @@ ResponseEntity delete(@ApiParam(name="name", value="SensorEnrichmentConfig } @ApiOperation(value = "Lists the available enrichments") - @ApiResponse(message = "List of available enrichments", code = 200) + @ApiResponse(message = "Returns a list of available enrichments", code = 200) @RequestMapping(value = "/list/available", method = RequestMethod.GET) ResponseEntity> getAvailable() throws Exception { return new ResponseEntity<>(sensorEnrichmentConfigService.getAvailableEnrichments(), HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java index 9f6111b2d1..3fb600e091 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.apache.metron.common.configuration.SensorParserConfig; import org.apache.metron.rest.model.ParseMessageRequest; import org.apache.metron.rest.service.SensorParserConfigService; @@ -43,14 +44,15 @@ public class SensorParserConfigController { private SensorParserConfigService sensorParserConfigService; @ApiOperation(value = "Updates or creates a SensorParserConfig in Zookeeper") - @ApiResponse(message = "Saved SensorParserConfig", code = 200) + @ApiResponse(message = "Returns saved SensorParserConfig", code = 200) @RequestMapping(method = RequestMethod.POST) ResponseEntity save(@ApiParam(name="sensorParserConfig", value="SensorParserConfig", required=true)@RequestBody SensorParserConfig sensorParserConfig) throws Exception { return new ResponseEntity<>(sensorParserConfigService.save(sensorParserConfig), HttpStatus.CREATED); } @ApiOperation(value = "Retrieves a SensorParserConfig from Zookeeper") - @ApiResponse(message = "SensorParserConfig", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Returns SensorParserConfig", code = 200), + @ApiResponse(message = "SensorParserConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.GET) ResponseEntity findOne(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { SensorParserConfig sensorParserConfig = sensorParserConfigService.findOne(name); @@ -62,14 +64,15 @@ ResponseEntity findOne(@ApiParam(name="name", value="SensorP } @ApiOperation(value = "Retrieves all SensorParserConfigs from Zookeeper") - @ApiResponse(message = "All SensorParserConfigs", code = 200) + @ApiResponse(message = "Returns all SensorParserConfigs", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> findAll() throws Exception { return new ResponseEntity<>(sensorParserConfigService.getAll(), HttpStatus.OK); } @ApiOperation(value = "Deletes a SensorParserConfig from Zookeeper") - @ApiResponse(message = "No return value", code = 200) + @ApiResponses(value = { @ApiResponse(message = "SensorParserConfig was deleted", code = 200), + @ApiResponse(message = "SensorParserConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) ResponseEntity delete(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { if (sensorParserConfigService.delete(name)) { @@ -80,21 +83,21 @@ ResponseEntity delete(@ApiParam(name="name", value="SensorParserConfig nam } @ApiOperation(value = "Lists the available parser classes that can be found on the classpath") - @ApiResponse(message = "List of available parser classes", code = 200) + @ApiResponse(message = "Returns a list of available parser classes", code = 200) @RequestMapping(value = "/list/available", method = RequestMethod.GET) ResponseEntity> getAvailable() throws Exception { return new ResponseEntity<>(sensorParserConfigService.getAvailableParsers(), HttpStatus.OK); } @ApiOperation(value = "Scans the classpath for available parser classes and reloads the cached parser class list") - @ApiResponse(message = "List of available parser classes", code = 200) + @ApiResponse(message = "Returns a list of available parser classes", code = 200) @RequestMapping(value = "/reload/available", method = RequestMethod.GET) ResponseEntity> reloadAvailable() throws Exception { return new ResponseEntity<>(sensorParserConfigService.reloadAvailableParsers(), HttpStatus.OK); } @ApiOperation(value = "Parses a sample message given a SensorParserConfig") - @ApiResponse(message = "Parsed message", code = 200) + @ApiResponse(message = "Returns parsed message", code = 200) @RequestMapping(value = "/parseMessage", method = RequestMethod.POST) ResponseEntity parseMessage(@ApiParam(name="parseMessageRequest", value="Object containing a sample message and SensorParserConfig", required=true) @RequestBody ParseMessageRequest parseMessageRequest) throws Exception { return new ResponseEntity<>(sensorParserConfigService.parseMessage(parseMessageRequest), HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java index 73ded2378c..88fe6d8816 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.apache.metron.rest.model.SensorParserConfigHistory; import org.apache.metron.rest.service.SensorParserConfigHistoryService; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +41,8 @@ public class SensorParserConfigHistoryController { private SensorParserConfigHistoryService sensorParserHistoryService; @ApiOperation(value = "Retrieves the current version of a SensorParserConfig including audit information") - @ApiResponse(message = "SensorParserConfig with audit information", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Returns SensorParserConfig with audit information", code = 200), + @ApiResponse(message = "SensorParserConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.GET) ResponseEntity findOne(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { SensorParserConfigHistory sensorParserConfigHistory = sensorParserHistoryService.findOne(name); @@ -51,14 +53,14 @@ ResponseEntity findOne(@ApiParam(name="name", value=" } @ApiOperation(value = "Retrieves all current versions of SensorParserConfigs including audit information") - @ApiResponse(message = "SensorParserConfigs with audit information", code = 200) + @ApiResponse(message = "Returns all SensorParserConfigs with audit information", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> getall() throws Exception { return new ResponseEntity<>(sensorParserHistoryService.getAll(), HttpStatus.OK); } @ApiOperation(value = "Retrieves the history of all changes made to a SensorParserConfig") - @ApiResponse(message = "SensorParserConfig history", code = 200) + @ApiResponse(message = "Returns SensorParserConfig history", code = 200) @RequestMapping(value = "/history/{name}", method = RequestMethod.GET) ResponseEntity> history(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { return new ResponseEntity<>(sensorParserHistoryService.history(name), HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java index e5c83bb5ef..a06e2714ba 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.apache.metron.rest.model.TopologyResponse; import org.apache.metron.rest.model.TopologyStatus; import org.apache.metron.rest.service.StormService; @@ -43,14 +44,15 @@ public class StormController { private StormService stormService; @ApiOperation(value = "Retrieves the status of all Storm topologies") - @ApiResponse(message = "List of topologies with status information", code = 200) + @ApiResponse(message = "Returns a list of topologies with status information", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> getAll() throws Exception { return new ResponseEntity<>(stormService.getAllTopologyStatus(), HttpStatus.OK); } @ApiOperation(value = "Retrieves the status of a Storm topology") - @ApiResponse(message = "Topology status information", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Returns topology status information", code = 200), + @ApiResponse(message = "Topology is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.GET) ResponseEntity get(@ApiParam(name="name", value="Topology name", required=true)@PathVariable String name) throws Exception { TopologyStatus topologyStatus = stormService.getTopologyStatus(name); @@ -62,14 +64,14 @@ ResponseEntity get(@ApiParam(name="name", value="Topology name", } @ApiOperation(value = "Starts a Storm parser topology") - @ApiResponse(message = "Start response message", code = 200) + @ApiResponse(message = "Returns start response message", code = 200) @RequestMapping(value = "/parser/start/{name}", method = RequestMethod.GET) ResponseEntity start(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws Exception { return new ResponseEntity<>(stormService.startParserTopology(name), HttpStatus.OK); } @ApiOperation(value = "Stops a Storm parser topology") - @ApiResponse(message = "Stop response message", code = 200) + @ApiResponse(message = "Returns stop response message", code = 200) @RequestMapping(value = "/parser/stop/{name}", method = RequestMethod.GET) ResponseEntity stop(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name, @ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { @@ -77,21 +79,22 @@ ResponseEntity stop(@ApiParam(name="name", value="Parser name" } @ApiOperation(value = "Activates a Storm parser topology") - @ApiResponse(message = "Activate response message", code = 200) + @ApiResponse(message = "Returns activate response message", code = 200) @RequestMapping(value = "/parser/activate/{name}", method = RequestMethod.GET) ResponseEntity activate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws Exception { return new ResponseEntity<>(stormService.activateTopology(name), HttpStatus.OK); } @ApiOperation(value = "Deactivates a Storm parser topology") - @ApiResponse(message = "Deactivate response message", code = 200) + @ApiResponse(message = "Returns deactivate response message", code = 200) @RequestMapping(value = "/parser/deactivate/{name}", method = RequestMethod.GET) ResponseEntity deactivate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws Exception { return new ResponseEntity<>(stormService.deactivateTopology(name), HttpStatus.OK); } @ApiOperation(value = "Retrieves the status of the Storm enrichment topology") - @ApiResponse(message = "Topology status information", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Returns topology status information", code = 200), + @ApiResponse(message = "Topology is missing", code = 404) }) @RequestMapping(value = "/enrichment", method = RequestMethod.GET) ResponseEntity getEnrichment() throws Exception { TopologyStatus sensorParserStatus = stormService.getTopologyStatus(StormService.ENRICHMENT_TOPOLOGY_NAME); @@ -103,35 +106,36 @@ ResponseEntity getEnrichment() throws Exception { } @ApiOperation(value = "Starts a Storm enrichment topology") - @ApiResponse(message = "Start response message", code = 200) + @ApiResponse(message = "Returns start response message", code = 200) @RequestMapping(value = "/enrichment/start", method = RequestMethod.GET) ResponseEntity startEnrichment() throws Exception { return new ResponseEntity<>(stormService.startEnrichmentTopology(), HttpStatus.OK); } @ApiOperation(value = "Stops a Storm enrichment topology") - @ApiResponse(message = "Stop response message", code = 200) + @ApiResponse(message = "Returns stop response message", code = 200) @RequestMapping(value = "/enrichment/stop", method = RequestMethod.GET) ResponseEntity stopEnrichment(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { return new ResponseEntity<>(stormService.stopEnrichmentTopology(stopNow), HttpStatus.OK); } @ApiOperation(value = "Activates a Storm enrichment topology") - @ApiResponse(message = "Activate response message", code = 200) + @ApiResponse(message = "Returns activate response message", code = 200) @RequestMapping(value = "/enrichment/activate", method = RequestMethod.GET) ResponseEntity activateEnrichment() throws Exception { return new ResponseEntity<>(stormService.activateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Deactivates a Storm enrichment topology") - @ApiResponse(message = "Deactivate response message", code = 200) + @ApiResponse(message = "Returns deactivate response message", code = 200) @RequestMapping(value = "/enrichment/deactivate", method = RequestMethod.GET) ResponseEntity deactivateEnrichment() throws Exception { return new ResponseEntity<>(stormService.deactivateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Retrieves the status of the Storm indexing topology") - @ApiResponse(message = "Topology status information", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Returns topology status information", code = 200), + @ApiResponse(message = "Topology is missing", code = 404) }) @RequestMapping(value = "/indexing", method = RequestMethod.GET) ResponseEntity getIndexing() throws Exception { TopologyStatus topologyStatus = stormService.getTopologyStatus(StormService.INDEXING_TOPOLOGY_NAME); @@ -143,35 +147,35 @@ ResponseEntity getIndexing() throws Exception { } @ApiOperation(value = "Starts a Storm indexing topology") - @ApiResponse(message = "Start response message", code = 200) + @ApiResponse(message = "Returns start response message", code = 200) @RequestMapping(value = "/indexing/start", method = RequestMethod.GET) ResponseEntity startIndexing() throws Exception { return new ResponseEntity<>(stormService.startIndexingTopology(), HttpStatus.OK); } @ApiOperation(value = "Stops a Storm enrichment topology") - @ApiResponse(message = "Stop response message", code = 200) + @ApiResponse(message = "Returns stop response message", code = 200) @RequestMapping(value = "/indexing/stop", method = RequestMethod.GET) ResponseEntity stopIndexing(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { return new ResponseEntity<>(stormService.stopIndexingTopology(stopNow), HttpStatus.OK); } @ApiOperation(value = "Activates a Storm indexing topology") - @ApiResponse(message = "Activate response message", code = 200) + @ApiResponse(message = "Returns activate response message", code = 200) @RequestMapping(value = "/indexing/activate", method = RequestMethod.GET) ResponseEntity activateIndexing() throws Exception { return new ResponseEntity<>(stormService.activateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Deactivates a Storm indexing topology") - @ApiResponse(message = "Deactivate response message", code = 200) + @ApiResponse(message = "Returns deactivate response message", code = 200) @RequestMapping(value = "/indexing/deactivate", method = RequestMethod.GET) ResponseEntity deactivateIndexing() throws Exception { return new ResponseEntity<>(stormService.deactivateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Retrieves information about the Storm command line client") - @ApiResponse(message = "Storm command line client information", code = 200) + @ApiResponse(message = "Returns storm command line client information", code = 200) @RequestMapping(value = "/client/status", method = RequestMethod.GET) ResponseEntity> clientStatus() throws Exception { return new ResponseEntity<>(stormService.getStormClientStatus(), HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java index 10148c266b..28dec101d8 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java @@ -43,35 +43,35 @@ public class TransformationController { private TransformationService transformationService; @ApiOperation(value = "Tests Stellar statements to ensure they are well-formed") - @ApiResponse(message = "Validation results", code = 200) + @ApiResponse(message = "Returns validation results", code = 200) @RequestMapping(value = "/validate/rules", method = RequestMethod.POST) ResponseEntity> validateRule(@ApiParam(name="statements", value="List of statements to validate", required=true)@RequestBody List statements) throws Exception { return new ResponseEntity<>(transformationService.validateRules(statements), HttpStatus.OK); } @ApiOperation(value = "Executes transformations against a sample message") - @ApiResponse(message = "Transformation results", code = 200) + @ApiResponse(message = "Returns transformation results", code = 200) @RequestMapping(value = "/validate", method = RequestMethod.POST) ResponseEntity> validateTransformation(@ApiParam(name="transformationValidation", value="Object containing SensorParserConfig and sample message", required=true)@RequestBody TransformationValidation transformationValidation) throws Exception { return new ResponseEntity<>(transformationService.validateTransformation(transformationValidation), HttpStatus.OK); } @ApiOperation(value = "Retrieves field transformations") - @ApiResponse(message = "List field transformations", code = 200) + @ApiResponse(message = "Returns a list field transformations", code = 200) @RequestMapping(value = "/list", method = RequestMethod.GET) ResponseEntity list() throws Exception { return new ResponseEntity<>(transformationService.getTransformations(), HttpStatus.OK); } @ApiOperation(value = "Lists the Stellar functions that can be found on the classpath") - @ApiResponse(message = "List of Stellar functions", code = 200) + @ApiResponse(message = "Returns a list of Stellar functions", code = 200) @RequestMapping(value = "/list/functions", method = RequestMethod.GET) ResponseEntity> listFunctions() throws Exception { return new ResponseEntity<>(transformationService.getStellarFunctions(), HttpStatus.OK); } @ApiOperation(value = "Lists the simple Stellar functions (functions with only 1 input) that can be found on the classpath") - @ApiResponse(message = "List of simple Stellar functions", code = 200) + @ApiResponse(message = "Returns a list of simple Stellar functions", code = 200) @RequestMapping(value = "/list/simple/functions", method = RequestMethod.GET) ResponseEntity> listSimpleFunctions() throws Exception { return new ResponseEntity<>(transformationService.getSimpleStellarFunctions(), HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java index 339700aa8c..f427caba32 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; @@ -67,9 +68,17 @@ public static void main(String[] args) throws Exception { if (apiOperation == null) { throw new Exception(String.format("@ApiOperation annotation missing from method %s.%s. Every controller method must have an @ApiOperation annotation.", controller.getSimpleName(), method.getName())); } - ApiResponse apiResponse = method.getAnnotation(ApiResponse.class); - if (apiResponse == null) { - throw new Exception(String.format("@ApiResponse annotation missing from method %s.%s. Every controller method must have an @ApiResponse annotation.", controller.getSimpleName(), method.getName())); + ApiResponse[] apiResponseArray; + ApiResponses apiResponses = method.getAnnotation(ApiResponses.class); + if (apiResponses == null) { + ApiResponse apiResponse = method.getAnnotation(ApiResponse.class); + if (apiResponse == null) { + throw new Exception(String.format("@ApiResponses or @ApiResponse annotation missing from method %s.%s. Every controller method must have an @ApiResponses or @ApiResponse annotation.", controller.getSimpleName(), method.getName())); + } else { + apiResponseArray = new ApiResponse[]{ apiResponse }; + } + } else { + apiResponseArray = apiResponses.value(); } String[] requestMappingValue = requestMapping.value(); if (requestMappingValue.length == 0) { @@ -85,7 +94,9 @@ public static void main(String[] args) throws Exception { requestMethod = requestMapping.method()[0]; } restControllerInfo.setMethod(requestMethod); - restControllerInfo.setResponseDescription(apiResponse.message()); + for (ApiResponse apiResponse: apiResponseArray) { + restControllerInfo.addResponse(apiResponse.message(), apiResponse.code()); + } for(Parameter parameter: method.getParameters()) { if (!parameter.getType().equals(Principal.class)) { ApiParam apiParam = parameter.getAnnotation(ApiParam.class); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/RestControllerInfo.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/RestControllerInfo.java index 250831f068..5b7ac0e3ba 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/RestControllerInfo.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/RestControllerInfo.java @@ -19,15 +19,39 @@ import org.springframework.web.bind.annotation.RequestMethod; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; public class RestControllerInfo { + public class Response { + + private String message; + private int code; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } + } + private String path; private String description; private RequestMethod method; - private String responseDescription; + private List responses = new ArrayList<>(); private Map parameterDescriptions = new HashMap<>(); public RestControllerInfo() {} @@ -56,12 +80,15 @@ public void setMethod(RequestMethod method) { this.method = method; } - public String getResponseDescription() { - return responseDescription; + public List getResponses() { + return responses; } - public void setResponseDescription(String responseDescription) { - this.responseDescription = responseDescription; + public void addResponse(String message, int code) { + Response response = new Response(); + response.setMessage(message); + response.setCode(code); + this.responses.add(response); } public Map getParameterDescriptions() { @@ -72,3 +99,5 @@ public void addParameterDescription(String name, String description) { parameterDescriptions.put(name, description); } } + + diff --git a/metron-interface/metron-rest/src/test/resources/README.vm b/metron-interface/metron-rest/src/test/resources/README.vm index e78d1eef94..f259a91602 100644 --- a/metron-interface/metron-rest/src/test/resources/README.vm +++ b/metron-interface/metron-rest/src/test/resources/README.vm @@ -80,7 +80,10 @@ Request and Response objects are JSON formatted. The JSON schemas are available #foreach( $parameterDescription in $restControllerInfo.getParameterDescriptions().entrySet()) * $parameterDescription.getKey() - $parameterDescription.getValue() #end - * Returns: $restControllerInfo.getResponseDescription() + * Returns: +#foreach( $response in $restControllerInfo.getResponses()) + * $response.getCode() - $response.getMessage() +#end #end From 2fc78d677c411653cf70ce1a304ccffbd3a0c33d Mon Sep 17 00:00:00 2001 From: rmerriman Date: Tue, 10 Jan 2017 15:47:33 -0600 Subject: [PATCH 27/54] Updated url paths for GlobalConfig, SensorParserConfig, SensorEnrichmentConfig, and SensorParserConfigHistory controllers. --- .../controller/GlobalConfigController.java | 2 +- .../SensorEnrichmentConfigController.java | 2 +- .../SensorParserConfigController.java | 2 +- .../SensorParserConfigHistoryController.java | 2 +- ...GlobalConfigControllerIntegrationTest.java | 17 ++-- .../GrokControllerIntegrationTest.java | 13 +-- .../KafkaControllerIntegrationTest.java | 27 +++--- ...chmentConfigControllerIntegrationTest.java | 25 ++--- ...ParserConfigControllerIntegrationTest.java | 39 ++++---- ...onfigHistoryControllerIntegrationTest.java | 24 ++--- .../StormControllerIntegrationTest.java | 95 ++++++++++--------- ...ansformationControllerIntegrationTest.java | 19 ++-- 12 files changed, 138 insertions(+), 129 deletions(-) diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java index 47f50e889f..1b7863b2c8 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java @@ -33,7 +33,7 @@ import java.util.Map; @RestController -@RequestMapping("/api/v1/globalConfig") +@RequestMapping("/api/v1/global/config") public class GlobalConfigController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java index 1cda0c8e62..991fae4740 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java @@ -35,7 +35,7 @@ import java.util.List; @RestController -@RequestMapping("/api/v1/sensorEnrichmentConfig") +@RequestMapping("/api/v1/sensor/enrichment/config") public class SensorEnrichmentConfigController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java index 3fb600e091..c608f3a89c 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java @@ -37,7 +37,7 @@ import java.util.Map; @RestController -@RequestMapping("/api/v1/sensorParserConfig") +@RequestMapping("/api/v1/sensor/parser/config") public class SensorParserConfigController { @Autowired diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java index 88fe6d8816..b973bcdfc7 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java @@ -34,7 +34,7 @@ import java.util.List; @RestController -@RequestMapping("/api/v1/sensorParserConfigHistory") +@RequestMapping("/api/v1/sensor/parser/config/history") public class SensorParserConfigHistoryController { @Autowired diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java index b90e49afc8..4938873fa9 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java @@ -64,6 +64,7 @@ public class GlobalConfigControllerIntegrationTest { private MockMvc mockMvc; + private String globalConfigUrl = "/api/v1/global/config"; private String user = "user"; private String password = "password"; @@ -74,32 +75,32 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/api/v1/globalConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) + this.mockMvc.perform(post(globalConfigUrl).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/globalConfig")) + this.mockMvc.perform(get(globalConfigUrl)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(delete("/api/v1/globalConfig").with(csrf())) + this.mockMvc.perform(delete(globalConfigUrl).with(csrf())) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(get("/api/v1/globalConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get(globalConfigUrl).with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(post("/api/v1/globalConfig").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) + this.mockMvc.perform(post(globalConfigUrl).with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))); - this.mockMvc.perform(get("/api/v1/globalConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get(globalConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()); - this.mockMvc.perform(delete("/api/v1/globalConfig").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(globalConfigUrl).with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(delete("/api/v1/globalConfig").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(globalConfigUrl).with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java index 7b5c25d34a..9577ce5c2d 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java @@ -62,11 +62,12 @@ public class GrokControllerIntegrationTest { @Multiline public static String badGrokValidationJson; - @Autowired + @Autowired private WebApplicationContext wac; private MockMvc mockMvc; + private String grokUrl = "/api/v1/grok"; private String user = "user"; private String password = "password"; @@ -77,16 +78,16 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/api/v1/grok/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) + this.mockMvc.perform(post(grokUrl + "/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/grok/list")) + this.mockMvc.perform(get(grokUrl + "/list")) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(post("/api/v1/grok/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) + this.mockMvc.perform(post(grokUrl + "/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(grokValidationJson)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.results.action").value("TCP_MISS")) @@ -99,12 +100,12 @@ public void test() throws Exception { .andExpect(jsonPath("$.results.timestamp").value("1467011157.401")) .andExpect(jsonPath("$.results.url").value("http://www.aliexpress.com/af/shoes.html?")); - this.mockMvc.perform(post("/api/v1/grok/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(badGrokValidationJson)) + this.mockMvc.perform(post(grokUrl + "/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(badGrokValidationJson)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.results.error").exists()); - this.mockMvc.perform(get("/api/v1/grok/list").with(httpBasic(user,password))) + this.mockMvc.perform(get(grokUrl + "/list").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$").isNotEmpty()); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java index e325728973..553acf8716 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java @@ -106,6 +106,7 @@ public void stop() { private MockMvc mockMvc; + private String kafkaUrl = "/api/v1/kafka"; private String user = "user"; private String password = "password"; @@ -116,19 +117,19 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/api/v1/kafka/topic").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) + this.mockMvc.perform(post(kafkaUrl + "/topic").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/kafka/topic/bro")) + this.mockMvc.perform(get(kafkaUrl + "/topic/bro")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/kafka/topic")) + this.mockMvc.perform(get(kafkaUrl + "/topic")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/kafka/topic/bro/sample")) + this.mockMvc.perform(get(kafkaUrl + "/topic/bro/sample")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(delete("/api/v1/kafka/topic/bro").with(csrf())) + this.mockMvc.perform(delete(kafkaUrl + "/topic/bro").with(csrf())) .andExpect(status().isUnauthorized()); } @@ -138,10 +139,10 @@ public void test() throws Exception { this.kafkaService.deleteTopic("someTopic"); Thread.sleep(1000); - this.mockMvc.perform(delete("/api/v1/kafka/topic/bro").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(kafkaUrl + "/topic/bro").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(post("/api/v1/kafka/topic").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) + this.mockMvc.perform(post(kafkaUrl + "/topic").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broTopic)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("bro")) @@ -151,31 +152,31 @@ public void test() throws Exception { sampleDataThread.start(); Thread.sleep(1000); - this.mockMvc.perform(get("/api/v1/kafka/topic/bro").with(httpBasic(user,password))) + this.mockMvc.perform(get(kafkaUrl + "/topic/bro").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("bro")) .andExpect(jsonPath("$.numPartitions").value(1)) .andExpect(jsonPath("$.replicationFactor").value(1)); - this.mockMvc.perform(get("/api/v1/kafka/topic/someTopic").with(httpBasic(user,password))) + this.mockMvc.perform(get(kafkaUrl + "/topic/someTopic").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/api/v1/kafka/topic").with(httpBasic(user,password))) + this.mockMvc.perform(get(kafkaUrl + "/topic").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", Matchers.hasItem("bro"))); - this.mockMvc.perform(get("/api/v1/kafka/topic/bro/sample").with(httpBasic(user,password))) + this.mockMvc.perform(get(kafkaUrl + "/topic/bro/sample").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("text/plain;charset=UTF-8"))) .andExpect(jsonPath("$").isNotEmpty()); - this.mockMvc.perform(get("/api/v1/kafka/topic/someTopic/sample").with(httpBasic(user,password))) + this.mockMvc.perform(get(kafkaUrl + "/topic/someTopic/sample").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(delete("/api/v1/kafka/topic/bro").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(kafkaUrl + "/topic/bro").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); } 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 c3f65ea0f1..31229f0ab0 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 @@ -114,6 +114,7 @@ public class SensorEnrichmentConfigControllerIntegrationTest { private MockMvc mockMvc; + private String sensorEnrichmentConfigUrl = "/api/v1/sensor/enrichment/config"; private String user = "user"; private String password = "password"; @@ -124,16 +125,16 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/api/v1/sensorEnrichmentConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + this.mockMvc.perform(post(sensorEnrichmentConfigUrl).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig/broTest")) + this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig")) + this.mockMvc.perform(get(sensorEnrichmentConfigUrl)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(delete("/api/v1/sensorEnrichmentConfig/broTest").with(csrf())) + this.mockMvc.perform(delete(sensorEnrichmentConfigUrl + "/broTest").with(csrf())) .andExpect(status().isUnauthorized()); } @@ -141,7 +142,7 @@ public void testSecurity() throws Exception { public void test() throws Exception { sensorEnrichmentConfigService.delete("broTest"); - this.mockMvc.perform(post("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + this.mockMvc.perform(post(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.index").value("broTest")) @@ -160,7 +161,7 @@ public void test() throws Exception { .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); - this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.index").value("broTest")) @@ -179,7 +180,7 @@ public void test() throws Exception { .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); - this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorEnrichmentConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.index == 'broTest' &&" + @@ -199,21 +200,21 @@ public void test() throws Exception { "@.threatIntel.triageConfig.aggregator == 'MAX'" + ")]").exists()); - this.mockMvc.perform(delete("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(delete("/api/v1/sensorEnrichmentConfig/broTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorEnrichmentConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").doesNotExist()); - this.mockMvc.perform(get("/api/v1/sensorEnrichmentConfig/list/available").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/list/available").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[0]").value("geo")) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java index fed9c500bd..d8ba14de5e 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -114,6 +114,7 @@ public class SensorParserConfigControllerIntegrationTest { private MockMvc mockMvc; + private String sensorParserConfigUrl = "/api/v1/sensor/parser/config"; private String user = "user"; private String password = "password"; @@ -124,16 +125,16 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) + this.mockMvc.perform(post(sensorParserConfigUrl).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/sensorParserConfig/squidTest")) + this.mockMvc.perform(get(sensorParserConfigUrl + "/squidTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/sensorParserConfig")) + this.mockMvc.perform(get(sensorParserConfigUrl)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(delete("/api/v1/sensorParserConfig/squidTest").with(csrf())) + this.mockMvc.perform(delete(sensorParserConfigUrl + "/squidTest").with(csrf())) .andExpect(status().isUnauthorized()); } @@ -141,7 +142,7 @@ public void testSecurity() throws Exception { public void test() throws Exception { cleanFileSystem(); - this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) + this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(squidJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.GrokParser")) @@ -156,7 +157,7 @@ public void test() throws Exception { .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); - this.mockMvc.perform(get("/api/v1/sensorParserConfig/squidTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorParserConfigUrl + "/squidTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.GrokParser")) @@ -171,7 +172,7 @@ public void test() throws Exception { .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); - this.mockMvc.perform(get("/api/v1/sensorParserConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorParserConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.parserClassName == 'org.apache.metron.parsers.GrokParser' &&" + @@ -185,14 +186,14 @@ public void test() throws Exception { "@.fieldTransformations[0].config.full_hostname == 'URL_TO_HOST(url)' &&" + "@.fieldTransformations[0].config.domain_without_subdomains == 'DOMAIN_REMOVE_SUBDOMAINS(full_hostname)')]").exists()); - this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) .andExpect(jsonPath("$.sensorTopic").value("broTest")) .andExpect(jsonPath("$.parserConfig").isEmpty()); - this.mockMvc.perform(get("/api/v1/sensorParserConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorParserConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.parserClassName == 'org.apache.metron.parsers.GrokParser' &&" + @@ -208,46 +209,46 @@ public void test() throws Exception { .andExpect(jsonPath("$[?(@.parserClassName == 'org.apache.metron.parsers.bro.BasicBroParser' && " + "@.sensorTopic == 'broTest')]").exists()); - this.mockMvc.perform(delete("/api/v1/sensorParserConfig/squidTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(sensorParserConfigUrl + "/squidTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(get("/api/v1/sensorParserConfig/squidTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorParserConfigUrl + "/squidTest").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(delete("/api/v1/sensorParserConfig/squidTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(sensorParserConfigUrl + "/squidTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/api/v1/sensorParserConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorParserConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.sensorTopic == 'squidTest')]").doesNotExist()) .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").exists()); - this.mockMvc.perform(delete("/api/v1/sensorParserConfig/broTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(sensorParserConfigUrl + "/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isOk()); - this.mockMvc.perform(delete("/api/v1/sensorParserConfig/broTest").with(httpBasic(user,password)).with(csrf())) + this.mockMvc.perform(delete(sensorParserConfigUrl + "/broTest").with(httpBasic(user,password)).with(csrf())) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/api/v1/sensorParserConfig").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorParserConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.sensorTopic == 'squidTest')]").doesNotExist()) .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").doesNotExist()); - this.mockMvc.perform(get("/api/v1/sensorParserConfig/list/available").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorParserConfigUrl + "/list/available").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.Bro").value("org.apache.metron.parsers.bro.BasicBroParser")) .andExpect(jsonPath("$.Grok").value("org.apache.metron.parsers.GrokParser")); - this.mockMvc.perform(get("/api/v1/sensorParserConfig/reload/available").with(httpBasic(user,password))) + this.mockMvc.perform(get(sensorParserConfigUrl + "/reload/available").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.Bro").value("org.apache.metron.parsers.bro.BasicBroParser")) .andExpect(jsonPath("$.Grok").value("org.apache.metron.parsers.GrokParser")); - this.mockMvc.perform(post("/api/v1/sensorParserConfig/parseMessage").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(parseRequest)) + this.mockMvc.perform(post(sensorParserConfigUrl + "/parseMessage").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(parseRequest)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.elapsed").value(415)) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java index 892083b946..8786950a30 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java @@ -119,6 +119,8 @@ public class SensorParserConfigHistoryControllerIntegrationTest { private MockMvc mockMvc; + private String sensorParserConfigUrl = "/api/v1/sensor/parser/config"; + private String sensorParserConfigHistoryUrl = "/api/v1/sensor/parser/config/history"; private String user1 = "user1"; private String user2 = "user2"; private String password = "password"; @@ -130,13 +132,13 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(get("/api/v1/sensorParserInfo/broTest")) + this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/sensorParserInfo/getall")) + this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/getall")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/sensorParserInfo/history/bro")) + this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/history/bro")) .andExpect(status().isUnauthorized()); } @@ -147,18 +149,18 @@ public void test() throws Exception { resetAuditTables(); SensorParserConfig bro3 = fromJson(broJson3); - this.mockMvc.perform(get("/api/v1/sensorParserConfigHistory/broTest").with(httpBasic(user1,password))) + this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/broTest").with(httpBasic(user1,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson1)); + this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson1)); Thread.sleep(1000); - this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson2)); + this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson2)); Thread.sleep(1000); - this.mockMvc.perform(post("/api/v1/sensorParserConfig").with(httpBasic(user2,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson3)); + this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user2,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson3)); assertEquals(bro3.getParserConfig().get("version"), fromJson(sensorParserConfigVersionRepository.findOne("broTest").getConfig()).getParserConfig().get("version")); - String json = this.mockMvc.perform(get("/api/v1/sensorParserConfigHistory/broTest").with(httpBasic(user1,password))) + String json = this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/broTest").with(httpBasic(user1,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) @@ -171,14 +173,14 @@ public void test() throws Exception { Map result = objectMapper.readValue(json, new TypeReference>() {}); validateCreateModifiedByDate(result, false); - this.mockMvc.perform(get("/api/v1/sensorParserConfigHistory").with(httpBasic(user1,password))) + this.mockMvc.perform(get(sensorParserConfigHistoryUrl).with(httpBasic(user1,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.config.sensorTopic == 'broTest')]").exists()); - this.mockMvc.perform(delete("/api/v1/sensorParserConfig/broTest").with(httpBasic(user2,password)).with(csrf())); + this.mockMvc.perform(delete(sensorParserConfigUrl + "/broTest").with(httpBasic(user2,password)).with(csrf())); - json = this.mockMvc.perform(get("/api/v1/sensorParserConfigHistory/history/broTest").with(httpBasic(user1,password))) + json = this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/history/broTest").with(httpBasic(user1,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[0].config", isEmptyOrNullString())) 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 8a4995a247..7c976aa679 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 @@ -65,6 +65,7 @@ public class StormControllerIntegrationTest { private MockMvc mockMvc; + private String stormUrl = "/api/v1/storm"; private String user = "user"; private String password = "password"; @@ -78,62 +79,62 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(get("/api/v1/storm")) + this.mockMvc.perform(get(stormUrl)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/broTest")) + this.mockMvc.perform(get(stormUrl + "/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/parser/start/broTest")) + this.mockMvc.perform(get(stormUrl + "/parser/start/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/parser/stop/broTest")) + this.mockMvc.perform(get(stormUrl + "/parser/stop/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/parser/activate/broTest")) + this.mockMvc.perform(get(stormUrl + "/parser/activate/broTest")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/parser/deactivate/broTest")) + this.mockMvc.perform(get(stormUrl + "/parser/deactivate/broTest")) .andExpect(status().isUnauthorized()); this.mockMvc.perform(get("/enrichment")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/enrichment/start")) + this.mockMvc.perform(get(stormUrl + "/enrichment/start")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/enrichment/stop")) + this.mockMvc.perform(get(stormUrl + "/enrichment/stop")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/enrichment/activate")) + this.mockMvc.perform(get(stormUrl + "/enrichment/activate")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/enrichment/deactivate")) + this.mockMvc.perform(get(stormUrl + "/enrichment/deactivate")) .andExpect(status().isUnauthorized()); this.mockMvc.perform(get("/indexing")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/indexing/start")) + this.mockMvc.perform(get(stormUrl + "/indexing/start")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/indexing/stop")) + this.mockMvc.perform(get(stormUrl + "/indexing/stop")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/indexing/activate")) + this.mockMvc.perform(get(stormUrl + "/indexing/activate")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/storm/indexing/deactivate")) + this.mockMvc.perform(get(stormUrl + "/indexing/deactivate")) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(get("/api/v1/storm").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$", hasSize(0))); - this.mockMvc.perform(get("/api/v1/storm/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/broTest").with(httpBasic(user,password))) .andExpect(status().isNotFound()); Map globalConfig = globalConfigService.get(); @@ -143,29 +144,29 @@ public void test() throws Exception { globalConfigService.delete(); sensorParserConfigService.delete("broTest"); - this.mockMvc.perform(get("/api/v1/storm/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); - this.mockMvc.perform(get("/api/v1/storm/parser/activate/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/parser/activate/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/api/v1/storm/parser/deactivate/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/parser/deactivate/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/api/v1/storm/parser/start/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/parser/start/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.GLOBAL_CONFIG_MISSING.name())); globalConfigService.save(globalConfig); - this.mockMvc.perform(get("/api/v1/storm/parser/start/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/parser/start/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.SENSOR_PARSER_CONFIG_MISSING.name())); @@ -175,12 +176,12 @@ public void test() throws Exception { sensorParserConfig.setSensorTopic("broTest"); sensorParserConfigService.save(sensorParserConfig); - this.mockMvc.perform(get("/api/v1/storm/parser/start/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/parser/start/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.name())); - this.mockMvc.perform(get("/api/v1/storm/broTest").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("broTest")) @@ -189,55 +190,55 @@ public void test() throws Exception { .andExpect(jsonPath("$.latency").exists()) .andExpect(jsonPath("$.throughput").exists()); - this.mockMvc.perform(get("/api/v1/storm").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.name == 'broTest' && @.status == 'ACTIVE')]").exists()); - this.mockMvc.perform(get("/api/v1/storm/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); - this.mockMvc.perform(get("/api/v1/storm/enrichment").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/api/v1/storm/enrichment/activate").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/api/v1/storm/enrichment/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/api/v1/storm/enrichment/stop?stopNow=true").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment/stop?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); - this.mockMvc.perform(get("/api/v1/storm/enrichment/start").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment/start").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.toString())); - this.mockMvc.perform(get("/api/v1/storm/enrichment/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); - this.mockMvc.perform(get("/api/v1/storm/enrichment/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); - this.mockMvc.perform(get("/api/v1/storm/enrichment/activate").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.ACTIVE.name())); - this.mockMvc.perform(get("/api/v1/storm/enrichment").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("enrichment")) @@ -246,50 +247,50 @@ public void test() throws Exception { .andExpect(jsonPath("$.latency").exists()) .andExpect(jsonPath("$.throughput").exists()); - this.mockMvc.perform(get("/api/v1/storm").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.name == 'enrichment' && @.status == 'ACTIVE')]").exists()); - this.mockMvc.perform(get("/api/v1/storm/enrichment/stop").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/enrichment/stop").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); - this.mockMvc.perform(get("/api/v1/storm/indexing").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/indexing").with(httpBasic(user,password))) .andExpect(status().isNotFound()); - this.mockMvc.perform(get("/api/v1/storm/indexing/activate").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/indexing/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/api/v1/storm/indexing/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/indexing/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); - this.mockMvc.perform(get("/api/v1/storm/indexing/stop?stopNow=true").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/indexing/stop?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("error")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); - this.mockMvc.perform(get("/api/v1/storm/indexing/start").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/indexing/start").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.toString())); - this.mockMvc.perform(get("/api/v1/storm/indexing/deactivate").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/indexing/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); - this.mockMvc.perform(get("/api/v1/storm/indexing/activate").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/indexing/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.ACTIVE.name())); - this.mockMvc.perform(get("/api/v1/storm/indexing").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/indexing").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.name").value("indexing")) @@ -298,17 +299,17 @@ public void test() throws Exception { .andExpect(jsonPath("$.latency").exists()) .andExpect(jsonPath("$.throughput").exists()); - this.mockMvc.perform(get("/api/v1/storm").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$[?(@.name == 'indexing' && @.status == 'ACTIVE')]").exists()); - this.mockMvc.perform(get("/api/v1/storm/indexing/stop").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/indexing/stop").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.status").value("success")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); - this.mockMvc.perform(get("/api/v1/storm/client/status").with(httpBasic(user,password))) + this.mockMvc.perform(get(stormUrl + "/client/status").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(jsonPath("$.stormClientVersionInstalled").value("1.0.1")) .andExpect(jsonPath("$.parserScriptPath").value("/usr/metron/" + metronVersion + "/bin/start_parser_topology.sh")) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java index ef39d53d52..c8813ac229 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java @@ -65,6 +65,7 @@ public class TransformationControllerIntegrationTest { private MockMvc mockMvc; + private String transformationUrl = "/api/v1/transformation"; private String user = "user"; private String password = "password"; @@ -75,44 +76,44 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post("/api/v1/transformation/validate/rules").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) + this.mockMvc.perform(post(transformationUrl + "/validate/rules").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(post("/api/v1/transformation/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) + this.mockMvc.perform(post(transformationUrl + "/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/transformation/list")) + this.mockMvc.perform(get(transformationUrl + "/list")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get("/api/v1/transformation/list/functions")) + this.mockMvc.perform(get(transformationUrl + "/list/functions")) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(post("/api/v1/transformation/validate/rules").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) + this.mockMvc.perform(post(transformationUrl + "/validate/rules").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.['" + valid + "']").value(Boolean.TRUE)) .andExpect(jsonPath("$.['" + invalid + "']").value(Boolean.FALSE)); - this.mockMvc.perform(post("/api/v1/transformation/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) + this.mockMvc.perform(post(transformationUrl + "/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.url").value("https://caseystella.com/blog")) .andExpect(jsonPath("$.url_host").value("caseystella.com")); - this.mockMvc.perform(get("/api/v1/transformation/list").with(httpBasic(user,password))) + this.mockMvc.perform(get(transformationUrl + "/list").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", hasSize(greaterThan(0)))); - this.mockMvc.perform(get("/api/v1/transformation/list/functions").with(httpBasic(user,password))) + this.mockMvc.perform(get(transformationUrl + "/list/functions").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", hasSize(greaterThan(0)))); - this.mockMvc.perform(get("/api/v1/transformation/list/simple/functions").with(httpBasic(user,password))) + this.mockMvc.perform(get(transformationUrl + "/list/simple/functions").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", hasSize(greaterThan(0)))); From a76ba8eb284baeb30169c88e4c44c7f21f0deb84 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Wed, 11 Jan 2017 16:38:17 -0600 Subject: [PATCH 28/54] Converted all exceptions to RestException and add an exception handler --- .../apache/metron/rest/model/RestError.java | 43 ++++++ .../org/apache/metron/rest/RestException.java | 43 ++++++ .../controller/GlobalConfigController.java | 7 +- .../rest/controller/GrokController.java | 5 +- .../rest/controller/KafkaController.java | 9 +- .../rest/controller/RestExceptionHandler.java | 48 ++++++ .../SensorEnrichmentConfigController.java | 9 +- .../SensorParserConfigController.java | 15 +- .../SensorParserConfigHistoryController.java | 7 +- .../rest/controller/StormController.java | 35 +++-- .../controller/TransformationController.java | 11 +- .../rest/service/GlobalConfigService.java | 17 +- .../metron/rest/service/GrokService.java | 65 ++++---- .../SensorEnrichmentConfigService.java | 32 ++-- .../SensorParserConfigHistoryService.java | 17 +- .../service/SensorParserConfigService.java | 53 +++++-- .../metron/rest/service/StormCLIWrapper.java | 35 +++-- .../metron/rest/service/StormService.java | 16 +- .../GrokControllerIntegrationTest.java | 5 +- ...ParserConfigControllerIntegrationTest.java | 86 ++++++++++- .../rest/mock/MockStormCLIClientWrapper.java | 16 +- metron-interface/pom.xml | 145 +++++++++--------- 22 files changed, 507 insertions(+), 212 deletions(-) create mode 100644 metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/RestError.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/RestException.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/RestExceptionHandler.java diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/RestError.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/RestError.java new file mode 100644 index 0000000000..5f9de622cc --- /dev/null +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/RestError.java @@ -0,0 +1,43 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +public class RestError { + + private int responseCode; + private String message; + private String fullMessage; + + public RestError(int responseCode, String message, String fullMessage) { + this.responseCode = responseCode; + this.message = message; + this.fullMessage = fullMessage; + } + + public int getResponseCode() { + return responseCode; + } + + public String getMessage() { + return message; + } + + public String getFullMessage() { + return fullMessage; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/RestException.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/RestException.java new file mode 100644 index 0000000000..1f985f7b18 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/RestException.java @@ -0,0 +1,43 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest; + +public class RestException extends Exception { + + private String fullMessage; + + public RestException(Exception e) { super( e.getMessage(), e.getCause()); } + + public RestException(String message) { + super(message); + } + + public RestException(String message, Throwable cause) { + super(message, cause); + } + + public RestException(String message, String fullMessage, Throwable cause) { + super(message, cause); + this.fullMessage = fullMessage; + } + + public String getFullMessage() { + return this.fullMessage; + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java index 1b7863b2c8..24b9502555 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java @@ -21,6 +21,7 @@ import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.service.GlobalConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -42,7 +43,7 @@ public class GlobalConfigController { @ApiOperation(value = "Creates or updates the Global Config in Zookeeper") @ApiResponse(message = "Returns saved Global Config JSON", code = 200) @RequestMapping(method = RequestMethod.POST) - ResponseEntity> save(@ApiParam(name="globalConfig", value="The Global Config JSON to be saved", required=true)@RequestBody Map globalConfig) throws Exception { + ResponseEntity> save(@ApiParam(name="globalConfig", value="The Global Config JSON to be saved", required=true)@RequestBody Map globalConfig) throws RestException { return new ResponseEntity<>(globalConfigService.save(globalConfig), HttpStatus.CREATED); } @@ -50,7 +51,7 @@ ResponseEntity> save(@ApiParam(name="globalConfig", value="T @ApiResponses(value = { @ApiResponse(message = "Returns current Global Config JSON in Zookeeper", code = 200), @ApiResponse(message = "Global Config JSON was not found in Zookeeper", code = 404) }) @RequestMapping(method = RequestMethod.GET) - ResponseEntity> get() throws Exception { + ResponseEntity> get() throws RestException { Map globalConfig = globalConfigService.get(); if (globalConfig != null) { return new ResponseEntity<>(globalConfig, HttpStatus.OK); @@ -63,7 +64,7 @@ ResponseEntity> get() throws Exception { @ApiResponses(value = { @ApiResponse(message = "Global Config JSON was deleted", code = 200), @ApiResponse(message = "Global Config JSON was not found in Zookeeper", code = 404) }) @RequestMapping(method = RequestMethod.DELETE) - ResponseEntity delete() throws Exception { + ResponseEntity delete() throws RestException { if (globalConfigService.delete()) { return new ResponseEntity<>(HttpStatus.OK); } else { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java index 86f7e17e7b..2b155b1a40 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.GrokValidation; import org.apache.metron.rest.service.GrokService; import org.springframework.beans.factory.annotation.Autowired; @@ -42,14 +43,14 @@ public class GrokController { @ApiOperation(value = "Applies a Grok statement to a sample message") @ApiResponse(message = "JSON results", code = 200) @RequestMapping(value = "/validate", method = RequestMethod.POST) - ResponseEntity post(@ApiParam(name="grokValidation", value="Object containing Grok statment and sample message", required=true)@RequestBody GrokValidation grokValidation) throws Exception { + ResponseEntity post(@ApiParam(name="grokValidation", value="Object containing Grok statment and sample message", required=true)@RequestBody GrokValidation grokValidation) throws RestException { return new ResponseEntity<>(grokService.validateGrokStatement(grokValidation), HttpStatus.OK); } @ApiOperation(value = "Lists the common Grok statements available in Metron") @ApiResponse(message = "JSON object containing pattern label/Grok statements key value pairs", code = 200) @RequestMapping(value = "/list", method = RequestMethod.GET) - ResponseEntity> list() throws Exception { + ResponseEntity> list() throws RestException { return new ResponseEntity<>(grokService.getCommonGrokPatterns(), HttpStatus.OK); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java index ada1b137d2..876558b198 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/KafkaController.java @@ -21,6 +21,7 @@ import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.KafkaTopic; import org.apache.metron.rest.service.KafkaService; import org.springframework.beans.factory.annotation.Autowired; @@ -44,7 +45,7 @@ public class KafkaController { @ApiOperation(value = "Creates a new Kafka topic") @ApiResponse(message = "Returns saved Kafka topic", code = 200) @RequestMapping(value = "/topic", method = RequestMethod.POST) - ResponseEntity save(@ApiParam(name="topic", value="Kafka topic", required=true)@RequestBody KafkaTopic topic) throws Exception { + ResponseEntity save(@ApiParam(name="topic", value="Kafka topic", required=true)@RequestBody KafkaTopic topic) throws RestException { return new ResponseEntity<>(kafkaService.createTopic(topic), HttpStatus.CREATED); } @@ -52,7 +53,7 @@ ResponseEntity save(@ApiParam(name="topic", value="Kafka topic", req @ApiResponses(value = { @ApiResponse(message = "Returns Kafka topic", code = 200), @ApiResponse(message = "Kafka topic is missing", code = 404) }) @RequestMapping(value = "/topic/{name}", method = RequestMethod.GET) - ResponseEntity get(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws Exception { + ResponseEntity get(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws RestException { KafkaTopic kafkaTopic = kafkaService.getTopic(name); if (kafkaTopic != null) { return new ResponseEntity<>(kafkaTopic, HttpStatus.OK); @@ -72,7 +73,7 @@ ResponseEntity> list() throws Exception { @ApiResponses(value = { @ApiResponse(message = "Kafka topic was deleted", code = 200), @ApiResponse(message = "Kafka topic is missing", code = 404) }) @RequestMapping(value = "/topic/{name}", method = RequestMethod.DELETE) - ResponseEntity delete(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws Exception { + ResponseEntity delete(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws RestException { if (kafkaService.deleteTopic(name)) { return new ResponseEntity<>(HttpStatus.OK); } else { @@ -84,7 +85,7 @@ ResponseEntity delete(@ApiParam(name="name", value="Kafka topic name", req @ApiResponses(value = { @ApiResponse(message = "Returns sample message", code = 200), @ApiResponse(message = "Either Kafka topic is missing or contains no messages", code = 404) }) @RequestMapping(value = "/topic/{name}/sample", method = RequestMethod.GET) - ResponseEntity getSample(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws Exception { + ResponseEntity getSample(@ApiParam(name="name", value="Kafka topic name", required=true)@PathVariable String name) throws RestException { String sampleMessage = kafkaService.getSampleMessage(name); if (sampleMessage != null) { return new ResponseEntity<>(sampleMessage, HttpStatus.OK); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/RestExceptionHandler.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/RestExceptionHandler.java new file mode 100644 index 0000000000..fa73dab6a5 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/RestExceptionHandler.java @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.model.RestError; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +import javax.servlet.http.HttpServletRequest; + +@ControllerAdvice(basePackages = "org.apache.metron.rest.controller") +public class RestExceptionHandler extends ResponseEntityExceptionHandler { + + @ExceptionHandler(RestException.class) + @ResponseBody + ResponseEntity handleControllerException(HttpServletRequest request, Throwable ex) { + HttpStatus status = getStatus(request); + return new ResponseEntity<>(new RestError(status.value(), ex.getMessage(), ex.getMessage()), status); + } + + private HttpStatus getStatus(HttpServletRequest request) { + Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); + if (statusCode == null) { + return HttpStatus.INTERNAL_SERVER_ERROR; + } + return HttpStatus.valueOf(statusCode); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java index 991fae4740..15ed568496 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java @@ -22,6 +22,7 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.service.SensorEnrichmentConfigService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -45,7 +46,7 @@ public class SensorEnrichmentConfigController { @ApiResponse(message = "Returns saved SensorEnrichmentConfig", code = 200) @RequestMapping(value = "/{name}", method = RequestMethod.POST) ResponseEntity save(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name, - @ApiParam(name="sensorEnrichmentConfig", value="SensorEnrichmentConfig", required=true)@RequestBody SensorEnrichmentConfig sensorEnrichmentConfig) throws Exception { + @ApiParam(name="sensorEnrichmentConfig", value="SensorEnrichmentConfig", required=true)@RequestBody SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException { return new ResponseEntity<>(sensorEnrichmentConfigService.save(name, sensorEnrichmentConfig), HttpStatus.CREATED); } @@ -53,7 +54,7 @@ ResponseEntity save(@ApiParam(name="name", value="Sensor @ApiResponses(value = { @ApiResponse(message = "Returns SensorEnrichmentConfig", code = 200), @ApiResponse(message = "SensorEnrichmentConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.GET) - ResponseEntity findOne(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name) throws Exception { + ResponseEntity findOne(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name) throws RestException { SensorEnrichmentConfig sensorEnrichmentConfig = sensorEnrichmentConfigService.findOne(name); if (sensorEnrichmentConfig != null) { return new ResponseEntity<>(sensorEnrichmentConfig, HttpStatus.OK); @@ -73,7 +74,7 @@ ResponseEntity> getAll() throws Exception { @ApiResponses(value = { @ApiResponse(message = "SensorEnrichmentConfig was deleted", code = 200), @ApiResponse(message = "SensorEnrichmentConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) - ResponseEntity delete(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name) throws Exception { + ResponseEntity delete(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name) throws RestException { if (sensorEnrichmentConfigService.delete(name)) { return new ResponseEntity<>(HttpStatus.OK); } else { @@ -84,7 +85,7 @@ ResponseEntity delete(@ApiParam(name="name", value="SensorEnrichmentConfig @ApiOperation(value = "Lists the available enrichments") @ApiResponse(message = "Returns a list of available enrichments", code = 200) @RequestMapping(value = "/list/available", method = RequestMethod.GET) - ResponseEntity> getAvailable() throws Exception { + ResponseEntity> getAvailable() throws RestException { return new ResponseEntity<>(sensorEnrichmentConfigService.getAvailableEnrichments(), HttpStatus.OK); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java index c608f3a89c..f617fcbfe0 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java @@ -22,6 +22,7 @@ import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.ParseMessageRequest; import org.apache.metron.rest.service.SensorParserConfigService; import org.json.simple.JSONObject; @@ -46,7 +47,7 @@ public class SensorParserConfigController { @ApiOperation(value = "Updates or creates a SensorParserConfig in Zookeeper") @ApiResponse(message = "Returns saved SensorParserConfig", code = 200) @RequestMapping(method = RequestMethod.POST) - ResponseEntity save(@ApiParam(name="sensorParserConfig", value="SensorParserConfig", required=true)@RequestBody SensorParserConfig sensorParserConfig) throws Exception { + ResponseEntity save(@ApiParam(name="sensorParserConfig", value="SensorParserConfig", required=true)@RequestBody SensorParserConfig sensorParserConfig) throws RestException { return new ResponseEntity<>(sensorParserConfigService.save(sensorParserConfig), HttpStatus.CREATED); } @@ -54,7 +55,7 @@ ResponseEntity save(@ApiParam(name="sensorParserConfig", val @ApiResponses(value = { @ApiResponse(message = "Returns SensorParserConfig", code = 200), @ApiResponse(message = "SensorParserConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.GET) - ResponseEntity findOne(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { + ResponseEntity findOne(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws RestException { SensorParserConfig sensorParserConfig = sensorParserConfigService.findOne(name); if (sensorParserConfig != null) { return new ResponseEntity<>(sensorParserConfig, HttpStatus.OK); @@ -66,7 +67,7 @@ ResponseEntity findOne(@ApiParam(name="name", value="SensorP @ApiOperation(value = "Retrieves all SensorParserConfigs from Zookeeper") @ApiResponse(message = "Returns all SensorParserConfigs", code = 200) @RequestMapping(method = RequestMethod.GET) - ResponseEntity> findAll() throws Exception { + ResponseEntity> findAll() throws RestException { return new ResponseEntity<>(sensorParserConfigService.getAll(), HttpStatus.OK); } @@ -74,7 +75,7 @@ ResponseEntity> findAll() throws Exception { @ApiResponses(value = { @ApiResponse(message = "SensorParserConfig was deleted", code = 200), @ApiResponse(message = "SensorParserConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) - ResponseEntity delete(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { + ResponseEntity delete(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws RestException { if (sensorParserConfigService.delete(name)) { return new ResponseEntity<>(HttpStatus.OK); } else { @@ -85,21 +86,21 @@ ResponseEntity delete(@ApiParam(name="name", value="SensorParserConfig nam @ApiOperation(value = "Lists the available parser classes that can be found on the classpath") @ApiResponse(message = "Returns a list of available parser classes", code = 200) @RequestMapping(value = "/list/available", method = RequestMethod.GET) - ResponseEntity> getAvailable() throws Exception { + ResponseEntity> getAvailable() throws RestException { return new ResponseEntity<>(sensorParserConfigService.getAvailableParsers(), HttpStatus.OK); } @ApiOperation(value = "Scans the classpath for available parser classes and reloads the cached parser class list") @ApiResponse(message = "Returns a list of available parser classes", code = 200) @RequestMapping(value = "/reload/available", method = RequestMethod.GET) - ResponseEntity> reloadAvailable() throws Exception { + ResponseEntity> reloadAvailable() throws RestException { return new ResponseEntity<>(sensorParserConfigService.reloadAvailableParsers(), HttpStatus.OK); } @ApiOperation(value = "Parses a sample message given a SensorParserConfig") @ApiResponse(message = "Returns parsed message", code = 200) @RequestMapping(value = "/parseMessage", method = RequestMethod.POST) - ResponseEntity parseMessage(@ApiParam(name="parseMessageRequest", value="Object containing a sample message and SensorParserConfig", required=true) @RequestBody ParseMessageRequest parseMessageRequest) throws Exception { + ResponseEntity parseMessage(@ApiParam(name="parseMessageRequest", value="Object containing a sample message and SensorParserConfig", required=true) @RequestBody ParseMessageRequest parseMessageRequest) throws RestException { return new ResponseEntity<>(sensorParserConfigService.parseMessage(parseMessageRequest), HttpStatus.OK); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java index b973bcdfc7..11a1d8c44a 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java @@ -21,6 +21,7 @@ import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.SensorParserConfigHistory; import org.apache.metron.rest.service.SensorParserConfigHistoryService; import org.springframework.beans.factory.annotation.Autowired; @@ -44,7 +45,7 @@ public class SensorParserConfigHistoryController { @ApiResponses(value = { @ApiResponse(message = "Returns SensorParserConfig with audit information", code = 200), @ApiResponse(message = "SensorParserConfig is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.GET) - ResponseEntity findOne(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { + ResponseEntity findOne(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws RestException { SensorParserConfigHistory sensorParserConfigHistory = sensorParserHistoryService.findOne(name); if (sensorParserConfigHistory != null) { return new ResponseEntity<>(sensorParserHistoryService.findOne(name), HttpStatus.OK); @@ -55,14 +56,14 @@ ResponseEntity findOne(@ApiParam(name="name", value=" @ApiOperation(value = "Retrieves all current versions of SensorParserConfigs including audit information") @ApiResponse(message = "Returns all SensorParserConfigs with audit information", code = 200) @RequestMapping(method = RequestMethod.GET) - ResponseEntity> getall() throws Exception { + ResponseEntity> getall() throws RestException { return new ResponseEntity<>(sensorParserHistoryService.getAll(), HttpStatus.OK); } @ApiOperation(value = "Retrieves the history of all changes made to a SensorParserConfig") @ApiResponse(message = "Returns SensorParserConfig history", code = 200) @RequestMapping(value = "/history/{name}", method = RequestMethod.GET) - ResponseEntity> history(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws Exception { + ResponseEntity> history(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws RestException { return new ResponseEntity<>(sensorParserHistoryService.history(name), HttpStatus.OK); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java index a06e2714ba..f6a904c212 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java @@ -21,6 +21,7 @@ import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.TopologyResponse; import org.apache.metron.rest.model.TopologyStatus; import org.apache.metron.rest.service.StormService; @@ -46,7 +47,7 @@ public class StormController { @ApiOperation(value = "Retrieves the status of all Storm topologies") @ApiResponse(message = "Returns a list of topologies with status information", code = 200) @RequestMapping(method = RequestMethod.GET) - ResponseEntity> getAll() throws Exception { + ResponseEntity> getAll() throws RestException { return new ResponseEntity<>(stormService.getAllTopologyStatus(), HttpStatus.OK); } @@ -54,7 +55,7 @@ ResponseEntity> getAll() throws Exception { @ApiResponses(value = { @ApiResponse(message = "Returns topology status information", code = 200), @ApiResponse(message = "Topology is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.GET) - ResponseEntity get(@ApiParam(name="name", value="Topology name", required=true)@PathVariable String name) throws Exception { + ResponseEntity get(@ApiParam(name="name", value="Topology name", required=true)@PathVariable String name) throws RestException { TopologyStatus topologyStatus = stormService.getTopologyStatus(name); if (topologyStatus != null) { return new ResponseEntity<>(topologyStatus, HttpStatus.OK); @@ -66,7 +67,7 @@ ResponseEntity get(@ApiParam(name="name", value="Topology name", @ApiOperation(value = "Starts a Storm parser topology") @ApiResponse(message = "Returns start response message", code = 200) @RequestMapping(value = "/parser/start/{name}", method = RequestMethod.GET) - ResponseEntity start(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws Exception { + ResponseEntity start(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws RestException { return new ResponseEntity<>(stormService.startParserTopology(name), HttpStatus.OK); } @@ -74,21 +75,21 @@ ResponseEntity start(@ApiParam(name="name", value="Parser name @ApiResponse(message = "Returns stop response message", code = 200) @RequestMapping(value = "/parser/stop/{name}", method = RequestMethod.GET) ResponseEntity stop(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name, - @ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { + @ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws RestException { return new ResponseEntity<>(stormService.stopParserTopology(name, stopNow), HttpStatus.OK); } @ApiOperation(value = "Activates a Storm parser topology") @ApiResponse(message = "Returns activate response message", code = 200) @RequestMapping(value = "/parser/activate/{name}", method = RequestMethod.GET) - ResponseEntity activate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws Exception { + ResponseEntity activate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws RestException { return new ResponseEntity<>(stormService.activateTopology(name), HttpStatus.OK); } @ApiOperation(value = "Deactivates a Storm parser topology") @ApiResponse(message = "Returns deactivate response message", code = 200) @RequestMapping(value = "/parser/deactivate/{name}", method = RequestMethod.GET) - ResponseEntity deactivate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws Exception { + ResponseEntity deactivate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws RestException { return new ResponseEntity<>(stormService.deactivateTopology(name), HttpStatus.OK); } @@ -96,7 +97,7 @@ ResponseEntity deactivate(@ApiParam(name="name", value="Parser @ApiResponses(value = { @ApiResponse(message = "Returns topology status information", code = 200), @ApiResponse(message = "Topology is missing", code = 404) }) @RequestMapping(value = "/enrichment", method = RequestMethod.GET) - ResponseEntity getEnrichment() throws Exception { + ResponseEntity getEnrichment() throws RestException { TopologyStatus sensorParserStatus = stormService.getTopologyStatus(StormService.ENRICHMENT_TOPOLOGY_NAME); if (sensorParserStatus != null) { return new ResponseEntity<>(sensorParserStatus, HttpStatus.OK); @@ -108,28 +109,28 @@ ResponseEntity getEnrichment() throws Exception { @ApiOperation(value = "Starts a Storm enrichment topology") @ApiResponse(message = "Returns start response message", code = 200) @RequestMapping(value = "/enrichment/start", method = RequestMethod.GET) - ResponseEntity startEnrichment() throws Exception { + ResponseEntity startEnrichment() throws RestException { return new ResponseEntity<>(stormService.startEnrichmentTopology(), HttpStatus.OK); } @ApiOperation(value = "Stops a Storm enrichment topology") @ApiResponse(message = "Returns stop response message", code = 200) @RequestMapping(value = "/enrichment/stop", method = RequestMethod.GET) - ResponseEntity stopEnrichment(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { + ResponseEntity stopEnrichment(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws RestException { return new ResponseEntity<>(stormService.stopEnrichmentTopology(stopNow), HttpStatus.OK); } @ApiOperation(value = "Activates a Storm enrichment topology") @ApiResponse(message = "Returns activate response message", code = 200) @RequestMapping(value = "/enrichment/activate", method = RequestMethod.GET) - ResponseEntity activateEnrichment() throws Exception { + ResponseEntity activateEnrichment() throws RestException { return new ResponseEntity<>(stormService.activateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Deactivates a Storm enrichment topology") @ApiResponse(message = "Returns deactivate response message", code = 200) @RequestMapping(value = "/enrichment/deactivate", method = RequestMethod.GET) - ResponseEntity deactivateEnrichment() throws Exception { + ResponseEntity deactivateEnrichment() throws RestException { return new ResponseEntity<>(stormService.deactivateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); } @@ -137,7 +138,7 @@ ResponseEntity deactivateEnrichment() throws Exception { @ApiResponses(value = { @ApiResponse(message = "Returns topology status information", code = 200), @ApiResponse(message = "Topology is missing", code = 404) }) @RequestMapping(value = "/indexing", method = RequestMethod.GET) - ResponseEntity getIndexing() throws Exception { + ResponseEntity getIndexing() throws RestException { TopologyStatus topologyStatus = stormService.getTopologyStatus(StormService.INDEXING_TOPOLOGY_NAME); if (topologyStatus != null) { return new ResponseEntity<>(topologyStatus, HttpStatus.OK); @@ -149,35 +150,35 @@ ResponseEntity getIndexing() throws Exception { @ApiOperation(value = "Starts a Storm indexing topology") @ApiResponse(message = "Returns start response message", code = 200) @RequestMapping(value = "/indexing/start", method = RequestMethod.GET) - ResponseEntity startIndexing() throws Exception { + ResponseEntity startIndexing() throws RestException { return new ResponseEntity<>(stormService.startIndexingTopology(), HttpStatus.OK); } @ApiOperation(value = "Stops a Storm enrichment topology") @ApiResponse(message = "Returns stop response message", code = 200) @RequestMapping(value = "/indexing/stop", method = RequestMethod.GET) - ResponseEntity stopIndexing(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws Exception { + ResponseEntity stopIndexing(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws RestException { return new ResponseEntity<>(stormService.stopIndexingTopology(stopNow), HttpStatus.OK); } @ApiOperation(value = "Activates a Storm indexing topology") @ApiResponse(message = "Returns activate response message", code = 200) @RequestMapping(value = "/indexing/activate", method = RequestMethod.GET) - ResponseEntity activateIndexing() throws Exception { + ResponseEntity activateIndexing() throws RestException { return new ResponseEntity<>(stormService.activateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Deactivates a Storm indexing topology") @ApiResponse(message = "Returns deactivate response message", code = 200) @RequestMapping(value = "/indexing/deactivate", method = RequestMethod.GET) - ResponseEntity deactivateIndexing() throws Exception { + ResponseEntity deactivateIndexing() throws RestException { return new ResponseEntity<>(stormService.deactivateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Retrieves information about the Storm command line client") @ApiResponse(message = "Returns storm command line client information", code = 200) @RequestMapping(value = "/client/status", method = RequestMethod.GET) - ResponseEntity> clientStatus() throws Exception { + ResponseEntity> clientStatus() throws RestException { return new ResponseEntity<>(stormService.getStormClientStatus(), HttpStatus.OK); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java index 28dec101d8..bc8b201558 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java @@ -21,6 +21,7 @@ import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import org.apache.metron.common.field.transformation.FieldTransformations; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.StellarFunctionDescription; import org.apache.metron.rest.model.TransformationValidation; import org.apache.metron.rest.service.TransformationService; @@ -45,35 +46,35 @@ public class TransformationController { @ApiOperation(value = "Tests Stellar statements to ensure they are well-formed") @ApiResponse(message = "Returns validation results", code = 200) @RequestMapping(value = "/validate/rules", method = RequestMethod.POST) - ResponseEntity> validateRule(@ApiParam(name="statements", value="List of statements to validate", required=true)@RequestBody List statements) throws Exception { + ResponseEntity> validateRule(@ApiParam(name="statements", value="List of statements to validate", required=true)@RequestBody List statements) throws RestException { return new ResponseEntity<>(transformationService.validateRules(statements), HttpStatus.OK); } @ApiOperation(value = "Executes transformations against a sample message") @ApiResponse(message = "Returns transformation results", code = 200) @RequestMapping(value = "/validate", method = RequestMethod.POST) - ResponseEntity> validateTransformation(@ApiParam(name="transformationValidation", value="Object containing SensorParserConfig and sample message", required=true)@RequestBody TransformationValidation transformationValidation) throws Exception { + ResponseEntity> validateTransformation(@ApiParam(name="transformationValidation", value="Object containing SensorParserConfig and sample message", required=true)@RequestBody TransformationValidation transformationValidation) throws RestException { return new ResponseEntity<>(transformationService.validateTransformation(transformationValidation), HttpStatus.OK); } @ApiOperation(value = "Retrieves field transformations") @ApiResponse(message = "Returns a list field transformations", code = 200) @RequestMapping(value = "/list", method = RequestMethod.GET) - ResponseEntity list() throws Exception { + ResponseEntity list() throws RestException { return new ResponseEntity<>(transformationService.getTransformations(), HttpStatus.OK); } @ApiOperation(value = "Lists the Stellar functions that can be found on the classpath") @ApiResponse(message = "Returns a list of Stellar functions", code = 200) @RequestMapping(value = "/list/functions", method = RequestMethod.GET) - ResponseEntity> listFunctions() throws Exception { + ResponseEntity> listFunctions() throws RestException { return new ResponseEntity<>(transformationService.getStellarFunctions(), HttpStatus.OK); } @ApiOperation(value = "Lists the simple Stellar functions (functions with only 1 input) that can be found on the classpath") @ApiResponse(message = "Returns a list of simple Stellar functions", code = 200) @RequestMapping(value = "/list/simple/functions", method = RequestMethod.GET) - ResponseEntity> listSimpleFunctions() throws Exception { + ResponseEntity> listSimpleFunctions() throws RestException { return new ResponseEntity<>(transformationService.getSimpleStellarFunctions(), HttpStatus.OK); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java index 46124f7deb..39a48b5115 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java @@ -22,6 +22,7 @@ import org.apache.metron.common.configuration.ConfigurationType; import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.utils.JSONUtils; +import org.apache.metron.rest.RestException; import org.apache.zookeeper.KeeperException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -35,27 +36,35 @@ public class GlobalConfigService { @Autowired private CuratorFramework client; - public Map save(Map globalConfig) throws Exception { + public Map save(Map globalConfig) throws RestException { + try { ConfigurationsUtils.writeGlobalConfigToZookeeper(globalConfig, client); - return globalConfig; + } catch (Exception e) { + throw new RestException(e); + } + return globalConfig; } - public Map get() throws Exception { + public Map get() throws RestException { Map globalConfig; try { byte[] globalConfigBytes = ConfigurationsUtils.readGlobalConfigBytesFromZookeeper(client); globalConfig = JSONUtils.INSTANCE.load(new ByteArrayInputStream(globalConfigBytes), new TypeReference>(){}); } catch (KeeperException.NoNodeException e) { return null; + } catch (Exception e) { + throw new RestException(e); } return globalConfig; } - public boolean delete() throws Exception { + public boolean delete() throws RestException { try { client.delete().forPath(ConfigurationType.GLOBAL.getZookeeperRoot()); } catch (KeeperException.NoNodeException e) { return false; + } catch (Exception e) { + throw new RestException(e); } return true; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java index 7034eacf44..d622ef014f 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java @@ -22,6 +22,7 @@ import org.apache.hadoop.fs.Path; import org.apache.metron.common.configuration.SensorParserConfig; import org.apache.metron.parsers.GrokParser; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.GrokValidation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; @@ -30,12 +31,10 @@ import org.springframework.stereotype.Service; import java.io.File; -import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.StringReader; -import java.util.HashMap; import java.util.Map; @Service @@ -61,8 +60,8 @@ public Map getCommonGrokPatterns() { return commonGrok.getPatterns(); } - public GrokValidation validateGrokStatement(GrokValidation grokValidation) { - Map results = new HashMap<>(); + public GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException { + Map results; try { Grok grok = new Grok(); grok.addPatternFromReader(new InputStreamReader(getClass().getResourceAsStream("/patterns/common"))); @@ -75,9 +74,9 @@ public GrokValidation validateGrokStatement(GrokValidation grokValidation) { results = gm.toMap(); results.remove(patternLabel); } catch (StringIndexOutOfBoundsException e) { - results.put("error", "A pattern label must be included (ex. PATTERN_LABEL ${PATTERN:field} ...)"); + throw new RestException("A pattern label must be included (ex. PATTERN_LABEL ${PATTERN:field} ...)", e.getCause()); } catch (Exception e) { - results.put("error", e.getMessage()); + throw new RestException(e); } grokValidation.setResults(results); return grokValidation; @@ -87,15 +86,13 @@ public boolean isGrokConfig(SensorParserConfig sensorParserConfig) { return GROK_CLASS_NAME.equals(sensorParserConfig.getParserClassName()); } - public void addGrokStatementToConfig(SensorParserConfig sensorParserConfig) throws IOException { + public void addGrokStatementToConfig(SensorParserConfig sensorParserConfig) throws RestException { String grokStatement = ""; String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); if (grokPath != null) { - try { - String fullGrokStatement = getGrokStatement(grokPath); - String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); - grokStatement = fullGrokStatement.replaceFirst(patternLabel + " ", ""); - } catch(FileNotFoundException e) {} + String fullGrokStatement = getGrokStatement(grokPath); + String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); + grokStatement = fullGrokStatement.replaceFirst(patternLabel + " ", ""); } sensorParserConfig.getParserConfig().put(GROK_STATEMENT_KEY, grokStatement); } @@ -104,47 +101,55 @@ public void addGrokPathToConfig(SensorParserConfig sensorParserConfig) { if (sensorParserConfig.getParserConfig().get(GROK_PATH_KEY) == null) { String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); if (grokStatement != null) { - sensorParserConfig.getParserConfig().put(GROK_PATH_KEY, + sensorParserConfig.getParserConfig().put(GROK_PATH_KEY, new Path(environment.getProperty(GROK_DEFAULT_PATH_SPRING_PROPERTY), sensorParserConfig.getSensorTopic()).toString()); } } } - public String getGrokStatement(String path) throws IOException { - return new String(hdfsService.read(new Path(path))); + public String getGrokStatement(String path) throws RestException { + try { + return new String(hdfsService.read(new Path(path))); + } catch (IOException e) { + throw new RestException(e); + } } - public void saveGrokStatement(SensorParserConfig sensorParserConfig) throws IOException { + public void saveGrokStatement(SensorParserConfig sensorParserConfig) throws RestException { saveGrokStatement(sensorParserConfig, false); } - public void saveTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws IOException { + public void saveTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws RestException { saveGrokStatement(sensorParserConfig, true); } - private void saveGrokStatement(SensorParserConfig sensorParserConfig, boolean isTemporary) throws IOException { + private void saveGrokStatement(SensorParserConfig sensorParserConfig, boolean isTemporary) throws RestException { String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); if (grokStatement != null) { - String fullGrokStatement = patternLabel + " " + grokStatement; - if (!isTemporary) { - hdfsService.write(new Path(grokPath), fullGrokStatement.getBytes()); - } else { - File grokDirectory = new File(getTemporaryGrokRootPath()); - if (!grokDirectory.exists()) { - grokDirectory.mkdirs(); + String fullGrokStatement = patternLabel + " " + grokStatement; + try { + if (!isTemporary) { + hdfsService.write(new Path(grokPath), fullGrokStatement.getBytes()); + } else { + File grokDirectory = new File(getTemporaryGrokRootPath()); + if (!grokDirectory.exists()) { + grokDirectory.mkdirs(); + } + FileWriter fileWriter = new FileWriter(new File(grokDirectory, sensorParserConfig.getSensorTopic())); + fileWriter.write(fullGrokStatement); + fileWriter.close(); } - FileWriter fileWriter = new FileWriter(new File(grokDirectory, sensorParserConfig.getSensorTopic())); - fileWriter.write(fullGrokStatement); - fileWriter.close(); + } catch (IOException e) { + throw new RestException(e); } } else { - throw new IllegalArgumentException("A grokStatement must be provided"); + throw new RestException("A grokStatement must be provided"); } } - public void deleteTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws IOException { + public void deleteTemporaryGrokStatement(SensorParserConfig sensorParserConfig) { File file = new File(getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()); file.delete(); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java index 2f13cb446e..d612222632 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java @@ -22,6 +22,7 @@ import org.apache.metron.common.configuration.ConfigurationType; import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; +import org.apache.metron.rest.RestException; import org.apache.zookeeper.KeeperException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -38,21 +39,28 @@ public class SensorEnrichmentConfigService { @Autowired private CuratorFramework client; - public SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnrichmentConfig) throws Exception { + public SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException { + try { ConfigurationsUtils.writeSensorEnrichmentConfigToZookeeper(name, objectMapper.writeValueAsString(sensorEnrichmentConfig).getBytes(), client); - return sensorEnrichmentConfig; + } catch (Exception e) { + throw new RestException(e); + } + return sensorEnrichmentConfig; } - public SensorEnrichmentConfig findOne(String name) throws Exception { - SensorEnrichmentConfig sensorEnrichmentConfig = null; + public SensorEnrichmentConfig findOne(String name) throws RestException { + SensorEnrichmentConfig sensorEnrichmentConfig; try { sensorEnrichmentConfig = ConfigurationsUtils.readSensorEnrichmentConfigFromZookeeper(name, client); } catch (KeeperException.NoNodeException e) { + return null; + } catch (Exception e) { + throw new RestException(e); } - return sensorEnrichmentConfig; + return sensorEnrichmentConfig; } - public List getAll() throws Exception { + public List getAll() throws RestException { List sensorEnrichmentConfigs = new ArrayList<>(); List sensorNames = getAllTypes(); for (String name : sensorNames) { @@ -61,23 +69,27 @@ public List getAll() throws Exception { return sensorEnrichmentConfigs; } - public List getAllTypes() throws Exception { + public List getAllTypes() throws RestException { List types; try { types = client.getChildren().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot()); } catch (KeeperException.NoNodeException e) { types = new ArrayList<>(); + } catch (Exception e) { + throw new RestException(e); } - return types; + return types; } - public boolean delete(String name) throws Exception { + public boolean delete(String name) throws RestException { try { client.delete().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/" + name); } catch (KeeperException.NoNodeException e) { return false; + } catch (Exception e) { + throw new RestException(e); } - return true; + return true; } public List getAvailableEnrichments() { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java index 4ef392fd40..3fe6d8a9ba 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java @@ -20,6 +20,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.audit.UserRevEntity; import org.apache.metron.rest.model.SensorParserConfigVersion; import org.apache.metron.rest.model.SensorParserConfigHistory; @@ -52,7 +53,7 @@ public class SensorParserConfigHistoryService { @Autowired private SensorParserConfigService sensorParserConfigService; - public SensorParserConfigHistory findOne(String name) throws Exception { + public SensorParserConfigHistory findOne(String name) throws RestException { SensorParserConfigHistory sensorParserConfigHistory = null; AuditReader reader = AuditReaderFactory.get(entityManager); try{ @@ -65,7 +66,7 @@ public SensorParserConfigHistory findOne(String name) throws Exception { sensorParserConfigHistory = new SensorParserConfigHistory(); String config = sensorParserConfigVersion.getConfig(); if (config != null) { - sensorParserConfigHistory.setConfig(deserializeSensorParserConfig(config)); + sensorParserConfigHistory.setConfig(deserialize(config)); if (grokService.isGrokConfig(sensorParserConfigHistory.getConfig())) { grokService.addGrokStatementToConfig(sensorParserConfigHistory.getConfig()); } @@ -94,7 +95,7 @@ public SensorParserConfigHistory findOne(String name) throws Exception { return sensorParserConfigHistory; } - public List getAll() throws Exception { + public List getAll() throws RestException { List historyList = new ArrayList<>(); for(String sensorType: sensorParserConfigService.getAllTypes()) { historyList.add(findOne(sensorType)); @@ -102,7 +103,7 @@ public List getAll() throws Exception { return historyList; } - public List history(String name) throws Exception { + public List history(String name) throws RestException { List historyList = new ArrayList<>(); AuditReader reader = AuditReaderFactory.get(entityManager); List results = reader.createQuery().forRevisionsOfEntity(SensorParserConfigVersion.class, false, true) @@ -124,7 +125,7 @@ public List history(String name) throws Exception { SensorParserConfigHistory sensorParserInfo = new SensorParserConfigHistory(); String config = sensorParserConfigVersion.getConfig(); if (config != null) { - sensorParserInfo.setConfig(deserializeSensorParserConfig(config)); + sensorParserInfo.setConfig(deserialize(config)); } else { sensorParserInfo.setConfig(null); } @@ -137,7 +138,11 @@ public List history(String name) throws Exception { return historyList; } - private SensorParserConfig deserializeSensorParserConfig(String config) throws IOException { + private SensorParserConfig deserialize(String config) throws RestException { + try { return objectMapper.readValue(config, new TypeReference() {}); + } catch (IOException e) { + throw new RestException(e); + } } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java index 1d43c36eef..a3eb53e9ef 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -17,12 +17,14 @@ */ package org.apache.metron.rest.service; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.curator.framework.CuratorFramework; import org.apache.metron.common.configuration.ConfigurationType; import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.configuration.SensorParserConfig; import org.apache.metron.parsers.interfaces.MessageParser; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.ParseMessageRequest; import org.apache.metron.rest.model.SensorParserConfigVersion; import org.apache.metron.rest.repository.SensorParserConfigVersionRepository; @@ -61,24 +63,37 @@ public void setClient(CuratorFramework client) { private Map availableParsers; - public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws Exception { + public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws RestException { String serializedConfig; if (grokService.isGrokConfig(sensorParserConfig)) { grokService.addGrokPathToConfig(sensorParserConfig); sensorParserConfig.getParserConfig().putIfAbsent(GrokService.GROK_PATTERN_LABEL_KEY, sensorParserConfig.getSensorTopic().toUpperCase()); String statement = (String) sensorParserConfig.getParserConfig().remove(GrokService.GROK_STATEMENT_KEY); - serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); - ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), serializedConfig.getBytes(), client); + serializedConfig = serialize(sensorParserConfig); sensorParserConfig.getParserConfig().put(GrokService.GROK_STATEMENT_KEY, statement); grokService.saveGrokStatement(sensorParserConfig); } else { - serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); + serializedConfig = serialize(sensorParserConfig); + } + try { ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), serializedConfig.getBytes(), client); + } catch (Exception e) { + throw new RestException(e); } saveVersion(sensorParserConfig.getSensorTopic(), serializedConfig); return sensorParserConfig; } + private String serialize(SensorParserConfig sensorParserConfig) throws RestException { + String serializedConfig; + try { + serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); + } catch (JsonProcessingException e) { + throw new RestException("Could not serialize SensorParserConfig", "Could not serialize " + sensorParserConfig.toString(), e.getCause()); + } + return serializedConfig; + } + private void saveVersion(String name, String config) { SensorParserConfigVersion sensorParser = new SensorParserConfigVersion(); sensorParser.setName(name); @@ -86,19 +101,22 @@ private void saveVersion(String name, String config) { sensorParserRepository.save(sensorParser); } - public SensorParserConfig findOne(String name) throws Exception{ - SensorParserConfig sensorParserConfig = null; + public SensorParserConfig findOne(String name) throws RestException { + SensorParserConfig sensorParserConfig; try { sensorParserConfig = ConfigurationsUtils.readSensorParserConfigFromZookeeper(name, client); if (grokService.isGrokConfig(sensorParserConfig)) { grokService.addGrokStatementToConfig(sensorParserConfig); } } catch (KeeperException.NoNodeException e) { + return null; + } catch (Exception e) { + throw new RestException(e); } return sensorParserConfig; } - public Iterable getAll() throws Exception { + public Iterable getAll() throws RestException { List sensorParserConfigs = new ArrayList<>(); List sensorNames = getAllTypes(); for (String name : sensorNames) { @@ -107,7 +125,7 @@ public Iterable getAll() throws Exception { return sensorParserConfigs; } - public boolean delete(String name) throws Exception { + public boolean delete(String name) throws RestException { try { client.delete().forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/" + name); sensorParserRepository.delete(name); @@ -115,16 +133,20 @@ public boolean delete(String name) throws Exception { return false; } catch (EmptyResultDataAccessException e) { return true; + } catch (Exception e) { + throw new RestException(e); } return true; } - public List getAllTypes() throws Exception { + public List getAllTypes() throws RestException { List types; try { types = client.getChildren().forPath(ConfigurationType.PARSER.getZookeeperRoot()); } catch (KeeperException.NoNodeException e) { types = new ArrayList<>(); + } catch (Exception e) { + throw new RestException(e); } return types; } @@ -152,14 +174,19 @@ private Set> getParserClasses() { return reflections.getSubTypesOf(MessageParser.class); } - public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws Exception { + public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws RestException { SensorParserConfig sensorParserConfig = parseMessageRequest.getSensorParserConfig(); if (sensorParserConfig == null) { - throw new Exception("Could not find parser config"); + throw new RestException("SensorParserConfig is missing from ParseMessageRequest"); } else if (sensorParserConfig.getParserClassName() == null) { - throw new Exception("Could not find parser class name"); + throw new RestException("SensorParserConfig must have a parserClassName"); } else { - MessageParser parser = (MessageParser) Class.forName(sensorParserConfig.getParserClassName()).newInstance(); + MessageParser parser = null; + try { + parser = (MessageParser) Class.forName(sensorParserConfig.getParserClassName()).newInstance(); + } catch (Exception e) { + throw new RestException(e.toString(), e.getCause()); + } if (grokService.isGrokConfig(sensorParserConfig)) { grokService.saveTemporaryGrokStatement(sensorParserConfig); sensorParserConfig.getParserConfig().put(GrokService.GROK_PATH_KEY, new File(grokService.getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()).toString()); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java index 0c2f890006..aecb421ad7 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java @@ -17,6 +17,7 @@ */ package org.apache.metron.rest.service; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.config.KafkaConfig; import org.apache.metron.rest.config.ZookeeperConfig; import org.springframework.beans.factory.annotation.Autowired; @@ -42,35 +43,40 @@ public class StormCLIWrapper { @Autowired private Environment environment; - public int startParserTopology(String name) throws IOException, InterruptedException { + public int startParserTopology(String name) throws RestException { return runCommand(getParserStartCommand(name)); } - public int stopParserTopology(String name, boolean stopNow) throws IOException, InterruptedException { + public int stopParserTopology(String name, boolean stopNow) throws RestException { return runCommand(getStopCommand(name, stopNow)); } - public int startEnrichmentTopology() throws IOException, InterruptedException { + public int startEnrichmentTopology() throws RestException { return runCommand(getEnrichmentStartCommand()); } - public int stopEnrichmentTopology(boolean stopNow) throws IOException, InterruptedException { + public int stopEnrichmentTopology(boolean stopNow) throws RestException { return runCommand(getStopCommand(ENRICHMENT_TOPOLOGY_NAME, stopNow)); } - public int startIndexingTopology() throws IOException, InterruptedException { + public int startIndexingTopology() throws RestException { return runCommand(getIndexingStartCommand()); } - public int stopIndexingTopology(boolean stopNow) throws IOException, InterruptedException { + public int stopIndexingTopology(boolean stopNow) throws RestException { return runCommand(getStopCommand(INDEXING_TOPOLOGY_NAME, stopNow)); } - protected int runCommand(String[] command) throws IOException, InterruptedException { + protected int runCommand(String[] command) throws RestException { ProcessBuilder pb = getProcessBuilder(command); pb.inheritIO(); - Process process = pb.start(); - process.waitFor(); + Process process = null; + try { + process = pb.start(); + process.waitFor(); + } catch (Exception e) { + throw new RestException(e); + } return process.exitValue(); } @@ -117,7 +123,7 @@ protected ProcessBuilder getProcessBuilder(String... command) { return new ProcessBuilder(command); } - public Map getStormClientStatus() throws IOException { + public Map getStormClientStatus() throws RestException { Map status = new HashMap<>(); status.put("parserScriptPath", environment.getProperty(PARSER_SCRIPT_PATH_SPRING_PROPERTY)); status.put("enrichmentScriptPath", environment.getProperty(ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY)); @@ -126,11 +132,16 @@ public Map getStormClientStatus() throws IOException { return status; } - protected String stormClientVersionInstalled() throws IOException { + protected String stormClientVersionInstalled() throws RestException { String stormClientVersionInstalled = "Storm client is not installed"; ProcessBuilder pb = getProcessBuilder("storm", "version"); pb.redirectErrorStream(true); - Process p = pb.start(); + Process p; + try { + p = pb.start(); + } catch (IOException e) { + throw new RestException(e); + } BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); List lines = reader.lines().collect(toList()); lines.forEach(System.out::println); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java index 29d2d4f05f..01c18099b0 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java @@ -17,6 +17,7 @@ */ package org.apache.metron.rest.service; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.TopologyResponse; import org.apache.metron.rest.model.TopologyStatus; import org.apache.metron.rest.model.TopologyStatusCode; @@ -26,7 +27,6 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -134,7 +134,7 @@ public TopologyResponse deactivateTopology(String name) { return topologyResponse; } - public TopologyResponse startParserTopology(String name) throws Exception { + public TopologyResponse startParserTopology(String name) throws RestException { TopologyResponse topologyResponse = new TopologyResponse(); if (globalConfigService.get() == null) { topologyResponse.setErrorMessage(TopologyStatusCode.GLOBAL_CONFIG_MISSING.toString()); @@ -146,23 +146,23 @@ public TopologyResponse startParserTopology(String name) throws Exception { return topologyResponse; } - public TopologyResponse stopParserTopology(String name, boolean stopNow) throws IOException, InterruptedException { + public TopologyResponse stopParserTopology(String name, boolean stopNow) throws RestException { return createResponse(stormCLIClientWrapper.stopParserTopology(name, stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); } - public TopologyResponse startEnrichmentTopology() throws IOException, InterruptedException { + public TopologyResponse startEnrichmentTopology() throws RestException { return createResponse(stormCLIClientWrapper.startEnrichmentTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); } - public TopologyResponse stopEnrichmentTopology(boolean stopNow) throws IOException, InterruptedException { + public TopologyResponse stopEnrichmentTopology(boolean stopNow) throws RestException { return createResponse(stormCLIClientWrapper.stopEnrichmentTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); } - public TopologyResponse startIndexingTopology() throws IOException, InterruptedException { + public TopologyResponse startIndexingTopology() throws RestException { return createResponse(stormCLIClientWrapper.startIndexingTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); } - public TopologyResponse stopIndexingTopology(boolean stopNow) throws IOException, InterruptedException { + public TopologyResponse stopIndexingTopology(boolean stopNow) throws RestException { return createResponse(stormCLIClientWrapper.stopIndexingTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); } @@ -176,7 +176,7 @@ protected TopologyResponse createResponse(int responseCode, TopologyStatusCode s return topologyResponse; } - public Map getStormClientStatus() throws IOException { + public Map getStormClientStatus() throws RestException { return stormCLIClientWrapper.getStormClientStatus(); } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java index 9577ce5c2d..3e7f8c5537 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java @@ -101,9 +101,10 @@ public void test() throws Exception { .andExpect(jsonPath("$.results.url").value("http://www.aliexpress.com/af/shoes.html?")); this.mockMvc.perform(post(grokUrl + "/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(badGrokValidationJson)) - .andExpect(status().isOk()) + .andExpect(status().isInternalServerError()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$.results.error").exists()); + .andExpect(jsonPath("$.responseCode").value(500)) + .andExpect(jsonPath("$.message").value("A pattern label must be included (ex. PATTERN_LABEL ${PATTERN:field} ...)")); this.mockMvc.perform(get(grokUrl + "/list").with(httpBasic(user,password))) .andExpect(status().isOk()) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java index d8ba14de5e..1a9aff8a3a 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -20,13 +20,11 @@ import org.adrianwalker.multilinestring.Multiline; import org.apache.commons.io.FileUtils; import org.apache.metron.rest.service.GrokService; -import org.apache.metron.rest.service.SensorParserConfigService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.ApplicationContext; import org.springframework.core.env.Environment; import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; @@ -77,6 +75,19 @@ public class SensorParserConfigControllerIntegrationTest { @Multiline public static String squidJson; + /** + { + "parserClassName": "org.apache.metron.parsers.GrokParser", + "sensorTopic": "squidTest", + "parserConfig": { + "patternLabel": "SQUIDTEST", + "timestampField": "timestamp" + } + } + */ + @Multiline + public static String missingGrokJson; + /** { "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", @@ -106,6 +117,52 @@ public class SensorParserConfigControllerIntegrationTest { @Multiline public static String parseRequest; + /** + { + "sensorParserConfig": null, + "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html" + } + */ + @Multiline + public static String missingConfigParseRequest; + + /** + { + "sensorParserConfig": + { + "sensorTopic": "squidTest", + "parserConfig": { + "grokStatement": "%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", + "patternLabel": "SQUIDTEST", + "grokPath":"./squidTest", + "timestampField": "timestamp" + } + }, + "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html" + } + */ + @Multiline + public static String missingClassParseRequest; + + /** + { + "sensorParserConfig": + { + "parserClassName": "badClass", + "sensorTopic": "squidTest", + "parserConfig": { + "grokStatement": "%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", + "patternLabel": "SQUIDTEST", + "grokPath":"./squidTest", + "timestampField": "timestamp" + } + }, + "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html" + } + */ + @Multiline + public static String badClassParseRequest; + @Autowired private Environment environment; @@ -157,6 +214,12 @@ public void test() throws Exception { .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); + this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(missingGrokJson)) + .andExpect(status().isInternalServerError()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.responseCode").value(500)) + .andExpect(jsonPath("$.message").value("A grokStatement must be provided")); + this.mockMvc.perform(get(sensorParserConfigUrl + "/squidTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) @@ -260,6 +323,25 @@ public void test() throws Exception { .andExpect(jsonPath("$.ip_src_addr").value("127.0.0.1")) .andExpect(jsonPath("$.url").value("http://www.aliexpress.com/af/shoes.html?")) .andExpect(jsonPath("$.timestamp").value(1467011157401L)); + + this.mockMvc.perform(post(sensorParserConfigUrl + "/parseMessage").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(missingConfigParseRequest)) + .andExpect(status().isInternalServerError()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.responseCode").value(500)) + .andExpect(jsonPath("$.message").value("SensorParserConfig is missing from ParseMessageRequest")); + + this.mockMvc.perform(post(sensorParserConfigUrl + "/parseMessage").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(missingClassParseRequest)) + .andExpect(status().isInternalServerError()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.responseCode").value(500)) + .andExpect(jsonPath("$.message").value("SensorParserConfig must have a parserClassName")); + + this.mockMvc.perform(post(sensorParserConfigUrl + "/parseMessage").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(badClassParseRequest)) + .andExpect(status().isInternalServerError()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.responseCode").value(500)) + .andExpect(jsonPath("$.message").value("java.lang.ClassNotFoundException: badClass")); + } private void cleanFileSystem() throws IOException { diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java index 26f5af5c54..7fdcff0401 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java @@ -17,10 +17,10 @@ */ package org.apache.metron.rest.mock; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.TopologyStatusCode; import org.apache.metron.rest.service.StormCLIWrapper; -import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -45,7 +45,7 @@ public TopologyStatusCode getParserStatus(String name) { } @Override - public int startParserTopology(String name) throws IOException, InterruptedException { + public int startParserTopology(String name) throws RestException { TopologyStatusCode parserStatus = parsersStatus.get(name); if (parserStatus == null || parserStatus == TopologyStatusCode.TOPOLOGY_NOT_FOUND) { parsersStatus.put(name, TopologyStatusCode.ACTIVE); @@ -56,7 +56,7 @@ public int startParserTopology(String name) throws IOException, InterruptedExcep } @Override - public int stopParserTopology(String name, boolean stopNow) throws IOException, InterruptedException { + public int stopParserTopology(String name, boolean stopNow) throws RestException { TopologyStatusCode parserStatus = parsersStatus.get(name); if (parserStatus == TopologyStatusCode.ACTIVE) { parsersStatus.put(name, TopologyStatusCode.TOPOLOGY_NOT_FOUND); @@ -91,7 +91,7 @@ public TopologyStatusCode getEnrichmentStatus() { } @Override - public int startEnrichmentTopology() throws IOException, InterruptedException { + public int startEnrichmentTopology() throws RestException { if (enrichmentStatus == TopologyStatusCode.TOPOLOGY_NOT_FOUND) { enrichmentStatus = TopologyStatusCode.ACTIVE; return 0; @@ -101,7 +101,7 @@ public int startEnrichmentTopology() throws IOException, InterruptedException { } @Override - public int stopEnrichmentTopology(boolean stopNow) throws IOException, InterruptedException { + public int stopEnrichmentTopology(boolean stopNow) throws RestException { if (enrichmentStatus == TopologyStatusCode.ACTIVE) { enrichmentStatus = TopologyStatusCode.TOPOLOGY_NOT_FOUND; return 0; @@ -133,7 +133,7 @@ public TopologyStatusCode getIndexingStatus() { } @Override - public int startIndexingTopology() throws IOException, InterruptedException { + public int startIndexingTopology() throws RestException { if (indexingStatus == TopologyStatusCode.TOPOLOGY_NOT_FOUND) { indexingStatus = TopologyStatusCode.ACTIVE; return 0; @@ -143,7 +143,7 @@ public int startIndexingTopology() throws IOException, InterruptedException { } @Override - public int stopIndexingTopology(boolean stopNow) throws IOException, InterruptedException { + public int stopIndexingTopology(boolean stopNow) throws RestException { if (indexingStatus == TopologyStatusCode.ACTIVE) { indexingStatus = TopologyStatusCode.TOPOLOGY_NOT_FOUND; return 0; @@ -171,7 +171,7 @@ public int deactivateIndexingTopology() { } @Override - protected String stormClientVersionInstalled() throws IOException { + protected String stormClientVersionInstalled() throws RestException { return "1.0.1"; } } diff --git a/metron-interface/pom.xml b/metron-interface/pom.xml index 99e83fc0b8..078da198b6 100644 --- a/metron-interface/pom.xml +++ b/metron-interface/pom.xml @@ -14,76 +14,77 @@ - 4.0.0 - metron-interface - pom - metron-interface - - org.apache.metron - Metron - 0.3.0 - - Interfaces for Metron - https://metron.incubator.apache.org/ - - scm:git:https://git-wip-us.apache.org/repos/asf/incubator-metron.git - scm:git:https://git-wip-us.apache.org/repos/asf/incubator-metron.git - HEAD - https://git-wip-us.apache.org/repos/asf/incubator-metron - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - metron-rest - - - - junit - junit - 4.12 - test - - - org.adrianwalker - multiline-string - 0.1.2 - test - - - - - - - - - - org.apache.maven.plugins - maven-pmd-plugin - 3.3 - - ${global_java_version} - - - - org.codehaus.mojo - emma-maven-plugin - 1.0-alpha-3 - true - - - - - - multiline-release-repo - https://raw.github.com/benelog/multiline/master/maven-repository - - false - - - + 4.0.0 + metron-interface + pom + metron-interface + + org.apache.metron + Metron + 0.3.0 + + Interfaces for Metron + https://metron.incubator.apache.org/ + + scm:git:https://git-wip-us.apache.org/repos/asf/incubator-metron.git + scm:git:https://git-wip-us.apache.org/repos/asf/incubator-metron.git + HEAD + https://git-wip-us.apache.org/repos/asf/incubator-metron + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + metron-rest + metron-rest-client + + + + junit + junit + 4.12 + test + + + org.adrianwalker + multiline-string + 0.1.2 + test + + + + + + + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.3 + + ${global_java_version} + + + + org.codehaus.mojo + emma-maven-plugin + 1.0-alpha-3 + true + + + + + + multiline-release-repo + https://raw.github.com/benelog/multiline/master/maven-repository + + false + + + From 901a6b755ebb31c1abae50c2159dde3d4c73ec97 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Tue, 17 Jan 2017 15:22:11 -0600 Subject: [PATCH 29/54] Resolved merge conflicts with METRON-652 --- metron-interface/metron-rest/README.md | 139 +++++++++++------- .../SensorEnrichmentConfigController.java | 3 +- .../SensorIndexingConfigController.java | 83 +++++++++++ .../SensorEnrichmentConfigService.java | 8 +- .../service/SensorIndexingConfigService.java | 100 +++++++++++++ ...chmentConfigControllerIntegrationTest.java | 34 ++--- ...dexingConfigControllerIntegrationTest.java | 128 ++++++++++++++++ .../apache/metron/rest/utils/ReadMeUtils.java | 8 +- 8 files changed, 423 insertions(+), 80 deletions(-) create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index 5438324ebf..cbed246a2f 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -67,9 +67,9 @@ Request and Response objects are JSON formatted. The JSON schemas are available | | | ---------- | -| [ `GET /api/v1/globalConfig`](#get-apiv1globalconfig)| -| [ `DELETE /api/v1/globalConfig`](#delete-apiv1globalconfig)| -| [ `POST /api/v1/globalConfig`](#post-apiv1globalconfig)| +| [ `GET /api/v1/global/config`](#get-apiv1globalconfig)| +| [ `DELETE /api/v1/global/config`](#delete-apiv1globalconfig)| +| [ `POST /api/v1/global/config`](#post-apiv1globalconfig)| | [ `GET /api/v1/grok/list`](#get-apiv1groklist)| | [ `POST /api/v1/grok/validate`](#post-apiv1grokvalidate)| | [ `GET /api/v1/kafka/topic`](#get-apiv1kafkatopic)| @@ -77,21 +77,25 @@ Request and Response objects are JSON formatted. The JSON schemas are available | [ `GET /api/v1/kafka/topic/{name}`](#get-apiv1kafkatopic{name})| | [ `DELETE /api/v1/kafka/topic/{name}`](#delete-apiv1kafkatopic{name})| | [ `GET /api/v1/kafka/topic/{name}/sample`](#get-apiv1kafkatopic{name}sample)| -| [ `GET /api/v1/sensorEnrichmentConfig`](#get-apiv1sensorenrichmentconfig)| -| [ `GET /api/v1/sensorEnrichmentConfig/list/available`](#get-apiv1sensorenrichmentconfiglistavailable)| -| [ `DELETE /api/v1/sensorEnrichmentConfig/{name}`](#delete-apiv1sensorenrichmentconfig{name})| -| [ `POST /api/v1/sensorEnrichmentConfig/{name}`](#post-apiv1sensorenrichmentconfig{name})| -| [ `GET /api/v1/sensorEnrichmentConfig/{name}`](#get-apiv1sensorenrichmentconfig{name})| -| [ `POST /api/v1/sensorParserConfig`](#post-apiv1sensorparserconfig)| -| [ `GET /api/v1/sensorParserConfig`](#get-apiv1sensorparserconfig)| -| [ `GET /api/v1/sensorParserConfig/list/available`](#get-apiv1sensorparserconfiglistavailable)| -| [ `POST /api/v1/sensorParserConfig/parseMessage`](#post-apiv1sensorparserconfigparsemessage)| -| [ `GET /api/v1/sensorParserConfig/reload/available`](#get-apiv1sensorparserconfigreloadavailable)| -| [ `DELETE /api/v1/sensorParserConfig/{name}`](#delete-apiv1sensorparserconfig{name})| -| [ `GET /api/v1/sensorParserConfig/{name}`](#get-apiv1sensorparserconfig{name})| -| [ `GET /api/v1/sensorParserConfigHistory`](#get-apiv1sensorparserconfighistory)| -| [ `GET /api/v1/sensorParserConfigHistory/history/{name}`](#get-apiv1sensorparserconfighistoryhistory{name})| -| [ `GET /api/v1/sensorParserConfigHistory/{name}`](#get-apiv1sensorparserconfighistory{name})| +| [ `GET /api/v1/sensor/enrichment/config`](#get-apiv1sensorenrichmentconfig)| +| [ `GET /api/v1/sensor/enrichment/config/list/available`](#get-apiv1sensorenrichmentconfiglistavailable)| +| [ `DELETE /api/v1/sensor/enrichment/config/{name}`](#delete-apiv1sensorenrichmentconfig{name})| +| [ `POST /api/v1/sensor/enrichment/config/{name}`](#post-apiv1sensorenrichmentconfig{name})| +| [ `GET /api/v1/sensor/enrichment/config/{name}`](#get-apiv1sensorenrichmentconfig{name})| +| [ `GET /api/v1/sensor/indexing/config`](#get-apiv1sensorindexingconfig)| +| [ `DELETE /api/v1/sensor/indexing/config/{name}`](#delete-apiv1sensorindexingconfig{name})| +| [ `POST /api/v1/sensor/indexing/config/{name}`](#post-apiv1sensorindexingconfig{name})| +| [ `GET /api/v1/sensor/indexing/config/{name}`](#get-apiv1sensorindexingconfig{name})| +| [ `POST /api/v1/sensor/parser/config`](#post-apiv1sensorparserconfig)| +| [ `GET /api/v1/sensor/parser/config`](#get-apiv1sensorparserconfig)| +| [ `GET /api/v1/sensor/parser/config/history`](#get-apiv1sensorparserconfighistory)| +| [ `GET /api/v1/sensor/parser/config/history/history/{name}`](#get-apiv1sensorparserconfighistoryhistory{name})| +| [ `GET /api/v1/sensor/parser/config/history/{name}`](#get-apiv1sensorparserconfighistory{name})| +| [ `GET /api/v1/sensor/parser/config/list/available`](#get-apiv1sensorparserconfiglistavailable)| +| [ `POST /api/v1/sensor/parser/config/parseMessage`](#post-apiv1sensorparserconfigparsemessage)| +| [ `GET /api/v1/sensor/parser/config/reload/available`](#get-apiv1sensorparserconfigreloadavailable)| +| [ `DELETE /api/v1/sensor/parser/config/{name}`](#delete-apiv1sensorparserconfig{name})| +| [ `GET /api/v1/sensor/parser/config/{name}`](#get-apiv1sensorparserconfig{name})| | [ `GET /api/v1/storm`](#get-apiv1storm)| | [ `GET /api/v1/storm/client/status`](#get-apiv1stormclientstatus)| | [ `GET /api/v1/storm/enrichment`](#get-apiv1stormenrichment)| @@ -116,19 +120,19 @@ Request and Response objects are JSON formatted. The JSON schemas are available | [ `POST /api/v1/transformation/validate/rules`](#post-apiv1transformationvalidaterules)| | [ `GET /api/v1/user`](#get-apiv1user)| -### `GET /api/v1/globalConfig` +### `GET /api/v1/global/config` * Description: Retrieves the current Global Config from Zookeeper * Returns: * 200 - Returns current Global Config JSON in Zookeeper * 404 - Global Config JSON was not found in Zookeeper -### `DELETE /api/v1/globalConfig` +### `DELETE /api/v1/global/config` * Description: Deletes the current Global Config from Zookeeper * Returns: * 200 - Global Config JSON was deleted * 404 - Global Config JSON was not found in Zookeeper -### `POST /api/v1/globalConfig` +### `POST /api/v1/global/config` * Description: Creates or updates the Global Config in Zookeeper * Input: * globalConfig - The Global Config JSON to be saved @@ -183,17 +187,17 @@ Request and Response objects are JSON formatted. The JSON schemas are available * 200 - Returns sample message * 404 - Either Kafka topic is missing or contains no messages -### `GET /api/v1/sensorEnrichmentConfig` +### `GET /api/v1/sensor/enrichment/config` * Description: Retrieves all SensorEnrichmentConfigs from Zookeeper * Returns: * 200 - Returns all SensorEnrichmentConfigs -### `GET /api/v1/sensorEnrichmentConfig/list/available` +### `GET /api/v1/sensor/enrichment/config/list/available` * Description: Lists the available enrichments * Returns: * 200 - Returns a list of available enrichments -### `DELETE /api/v1/sensorEnrichmentConfig/{name}` +### `DELETE /api/v1/sensor/enrichment/config/{name}` * Description: Deletes a SensorEnrichmentConfig from Zookeeper * Input: * name - SensorEnrichmentConfig name @@ -201,7 +205,7 @@ Request and Response objects are JSON formatted. The JSON schemas are available * 200 - SensorEnrichmentConfig was deleted * 404 - SensorEnrichmentConfig is missing -### `POST /api/v1/sensorEnrichmentConfig/{name}` +### `POST /api/v1/sensor/enrichment/config/{name}` * Description: Updates or creates a SensorEnrichmentConfig in Zookeeper * Input: * sensorEnrichmentConfig - SensorEnrichmentConfig @@ -209,7 +213,7 @@ Request and Response objects are JSON formatted. The JSON schemas are available * Returns: * 200 - Returns saved SensorEnrichmentConfig -### `GET /api/v1/sensorEnrichmentConfig/{name}` +### `GET /api/v1/sensor/enrichment/config/{name}` * Description: Retrieves a SensorEnrichmentConfig from Zookeeper * Input: * name - SensorEnrichmentConfig name @@ -217,36 +221,85 @@ Request and Response objects are JSON formatted. The JSON schemas are available * 200 - Returns SensorEnrichmentConfig * 404 - SensorEnrichmentConfig is missing -### `POST /api/v1/sensorParserConfig` +### `GET /api/v1/sensor/indexing/config` + * Description: Retrieves all SensorIndexingConfigs from Zookeeper + * Returns: + * 200 - Returns all SensorIndexingConfigs + +### `DELETE /api/v1/sensor/indexing/config/{name}` + * Description: Deletes a SensorIndexingConfig from Zookeeper + * Input: + * name - SensorIndexingConfig name + * Returns: + * 200 - SensorIndexingConfig was deleted + * 404 - SensorIndexingConfig is missing + +### `POST /api/v1/sensor/indexing/config/{name}` + * Description: Updates or creates a SensorIndexingConfig in Zookeeper + * Input: + * sensorIndexingConfig - SensorIndexingConfig + * name - SensorIndexingConfig name + * Returns: + * 200 - Returns saved SensorIndexingConfig + +### `GET /api/v1/sensor/indexing/config/{name}` + * Description: Retrieves a SensorIndexingConfig from Zookeeper + * Input: + * name - SensorIndexingConfig name + * Returns: + * 200 - Returns SensorIndexingConfig + * 404 - SensorIndexingConfig is missing + +### `POST /api/v1/sensor/parser/config` * Description: Updates or creates a SensorParserConfig in Zookeeper * Input: * sensorParserConfig - SensorParserConfig * Returns: * 200 - Returns saved SensorParserConfig -### `GET /api/v1/sensorParserConfig` +### `GET /api/v1/sensor/parser/config` * Description: Retrieves all SensorParserConfigs from Zookeeper * Returns: * 200 - Returns all SensorParserConfigs -### `GET /api/v1/sensorParserConfig/list/available` +### `GET /api/v1/sensor/parser/config/history` + * Description: Retrieves all current versions of SensorParserConfigs including audit information + * Returns: + * 200 - Returns all SensorParserConfigs with audit information + +### `GET /api/v1/sensor/parser/config/history/history/{name}` + * Description: Retrieves the history of all changes made to a SensorParserConfig + * Input: + * name - SensorParserConfig name + * Returns: + * 200 - Returns SensorParserConfig history + +### `GET /api/v1/sensor/parser/config/history/{name}` + * Description: Retrieves the current version of a SensorParserConfig including audit information + * Input: + * name - SensorParserConfig name + * Returns: + * 200 - Returns SensorParserConfig with audit information + * 404 - SensorParserConfig is missing + +### `GET /api/v1/sensor/parser/config/list/available` * Description: Lists the available parser classes that can be found on the classpath * Returns: * 200 - Returns a list of available parser classes -### `POST /api/v1/sensorParserConfig/parseMessage` +### `POST /api/v1/sensor/parser/config/parseMessage` * Description: Parses a sample message given a SensorParserConfig * Input: * parseMessageRequest - Object containing a sample message and SensorParserConfig * Returns: * 200 - Returns parsed message -### `GET /api/v1/sensorParserConfig/reload/available` +### `GET /api/v1/sensor/parser/config/reload/available` * Description: Scans the classpath for available parser classes and reloads the cached parser class list * Returns: * 200 - Returns a list of available parser classes -### `DELETE /api/v1/sensorParserConfig/{name}` +### `DELETE /api/v1/sensor/parser/config/{name}` * Description: Deletes a SensorParserConfig from Zookeeper * Input: * name - SensorParserConfig name @@ -254,7 +307,7 @@ Request and Response objects are JSON formatted. The JSON schemas are available * 200 - SensorParserConfig was deleted * 404 - SensorParserConfig is missing -### `GET /api/v1/sensorParserConfig/{name}` +### `GET /api/v1/sensor/parser/config/{name}` * Description: Retrieves a SensorParserConfig from Zookeeper * Input: * name - SensorParserConfig name @@ -262,26 +315,6 @@ Request and Response objects are JSON formatted. The JSON schemas are available * 200 - Returns SensorParserConfig * 404 - SensorParserConfig is missing -### `GET /api/v1/sensorParserConfigHistory` - * Description: Retrieves all current versions of SensorParserConfigs including audit information - * Returns: - * 200 - Returns all SensorParserConfigs with audit information - -### `GET /api/v1/sensorParserConfigHistory/history/{name}` - * Description: Retrieves the history of all changes made to a SensorParserConfig - * Input: - * name - SensorParserConfig name - * Returns: - * 200 - Returns SensorParserConfig history - -### `GET /api/v1/sensorParserConfigHistory/{name}` - * Description: Retrieves the current version of a SensorParserConfig including audit information - * Input: - * name - SensorParserConfig name - * Returns: - * 200 - Returns SensorParserConfig with audit information - * 404 - SensorParserConfig is missing - ### `GET /api/v1/storm` * Description: Retrieves the status of all Storm topologies * Returns: diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java index 15ed568496..e00207f5cb 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java @@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Map; @RestController @RequestMapping("/api/v1/sensor/enrichment/config") @@ -66,7 +67,7 @@ ResponseEntity findOne(@ApiParam(name="name", value="Sen @ApiOperation(value = "Retrieves all SensorEnrichmentConfigs from Zookeeper") @ApiResponse(message = "Returns all SensorEnrichmentConfigs", code = 200) @RequestMapping(method = RequestMethod.GET) - ResponseEntity> getAll() throws Exception { + ResponseEntity> getAll() throws Exception { return new ResponseEntity<>(sensorEnrichmentConfigService.getAll(), HttpStatus.OK); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java new file mode 100644 index 0000000000..3d6ff8884e --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java @@ -0,0 +1,83 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.SensorIndexingConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Map; + +@RestController +@RequestMapping("/api/v1/sensor/indexing/config") +public class SensorIndexingConfigController { + + @Autowired + private SensorIndexingConfigService sensorIndexingConfigService; + + @ApiOperation(value = "Updates or creates a SensorIndexingConfig in Zookeeper") + @ApiResponse(message = "Returns saved SensorIndexingConfig", code = 200) + @RequestMapping(value = "/{name}", method = RequestMethod.POST) + ResponseEntity> save(@ApiParam(name="name", value="SensorIndexingConfig name", required=true)@PathVariable String name, + @ApiParam(name="sensorIndexingConfig", value="SensorIndexingConfig", required=true)@RequestBody Map sensorIndexingConfig) throws RestException { + return new ResponseEntity<>(sensorIndexingConfigService.save(name, sensorIndexingConfig), HttpStatus.CREATED); + } + + @ApiOperation(value = "Retrieves a SensorIndexingConfig from Zookeeper") + @ApiResponses(value = { @ApiResponse(message = "Returns SensorIndexingConfig", code = 200), + @ApiResponse(message = "SensorIndexingConfig is missing", code = 404) }) + @RequestMapping(value = "/{name}", method = RequestMethod.GET) + ResponseEntity> findOne(@ApiParam(name="name", value="SensorIndexingConfig name", required=true)@PathVariable String name) throws RestException { + Map sensorIndexingConfig = sensorIndexingConfigService.findOne(name); + if (sensorIndexingConfig != null) { + return new ResponseEntity<>(sensorIndexingConfig, HttpStatus.OK); + } + + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + @ApiOperation(value = "Retrieves all SensorIndexingConfigs from Zookeeper") + @ApiResponse(message = "Returns all SensorIndexingConfigs", code = 200) + @RequestMapping(method = RequestMethod.GET) + ResponseEntity>> getAll() throws Exception { + return new ResponseEntity<>(sensorIndexingConfigService.getAll(), HttpStatus.OK); + } + + @ApiOperation(value = "Deletes a SensorIndexingConfig from Zookeeper") + @ApiResponses(value = { @ApiResponse(message = "SensorIndexingConfig was deleted", code = 200), + @ApiResponse(message = "SensorIndexingConfig is missing", code = 404) }) + @RequestMapping(value = "/{name}", method = RequestMethod.DELETE) + ResponseEntity delete(@ApiParam(name="name", value="SensorIndexingConfig name", required=true)@PathVariable String name) throws RestException { + if (sensorIndexingConfigService.delete(name)) { + return new ResponseEntity<>(HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java index d612222632..b2e1dc7681 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java @@ -28,7 +28,9 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class SensorEnrichmentConfigService { @@ -60,11 +62,11 @@ public SensorEnrichmentConfig findOne(String name) throws RestException { return sensorEnrichmentConfig; } - public List getAll() throws RestException { - List sensorEnrichmentConfigs = new ArrayList<>(); + public Map getAll() throws RestException { + Map sensorEnrichmentConfigs = new HashMap<>(); List sensorNames = getAllTypes(); for (String name : sensorNames) { - sensorEnrichmentConfigs.add(findOne(name)); + sensorEnrichmentConfigs.put(name, findOne(name)); } return sensorEnrichmentConfigs; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java new file mode 100644 index 0000000000..76df174084 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java @@ -0,0 +1,100 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.curator.framework.CuratorFramework; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.ConfigurationsUtils; +import org.apache.metron.common.utils.JSONUtils; +import org.apache.metron.rest.RestException; +import org.apache.zookeeper.KeeperException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class SensorIndexingConfigService { + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private CuratorFramework client; + + public Map save(String name, Map sensorIndexingConfig) throws RestException { + try { + ConfigurationsUtils.writeSensorIndexingConfigToZookeeper(name, objectMapper.writeValueAsString(sensorIndexingConfig).getBytes(), client); + } catch (Exception e) { + throw new RestException(e); + } + return sensorIndexingConfig; + } + + public Map findOne(String name) throws RestException { + Map sensorIndexingConfig; + try { + byte[] sensorIndexingConfigBytes = ConfigurationsUtils.readSensorIndexingConfigBytesFromZookeeper(name, client); + sensorIndexingConfig = JSONUtils.INSTANCE.load(new ByteArrayInputStream(sensorIndexingConfigBytes), new TypeReference>(){}); + } catch (KeeperException.NoNodeException e) { + return null; + } catch (Exception e) { + throw new RestException(e); + } + return sensorIndexingConfig; + } + + public Map> getAll() throws RestException { + Map> sensorIndexingConfigs = new HashMap<>(); + List sensorNames = getAllTypes(); + for (String name : sensorNames) { + sensorIndexingConfigs.put(name, findOne(name)); + } + return sensorIndexingConfigs; + } + + public List getAllTypes() throws RestException { + List types; + try { + types = client.getChildren().forPath(ConfigurationType.INDEXING.getZookeeperRoot()); + } catch (KeeperException.NoNodeException e) { + types = new ArrayList<>(); + } catch (Exception e) { + throw new RestException(e); + } + return types; + } + + public boolean delete(String name) throws RestException { + try { + client.delete().forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/" + name); + } catch (KeeperException.NoNodeException e) { + return false; + } catch (Exception e) { + throw new RestException(e); + } + return true; + } + +} 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 31229f0ab0..4dd9fa537c 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 @@ -48,8 +48,6 @@ public class SensorEnrichmentConfigControllerIntegrationTest { /** { - "index": "broTest", - "batchSize": 1, "enrichment": { "fieldMap": { "geo": [ @@ -145,8 +143,6 @@ public void test() throws Exception { this.mockMvc.perform(post(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$.index").value("broTest")) - .andExpect(jsonPath("$.batchSize").value(1)) .andExpect(jsonPath("$.enrichment.fieldMap.geo[0]").value("ip_dst_addr")) .andExpect(jsonPath("$.enrichment.fieldMap.host[0]").value("ip_dst_addr")) .andExpect(jsonPath("$.enrichment.fieldMap.hbaseEnrichment[0]").value("ip_src_addr")) @@ -164,8 +160,6 @@ public void test() throws Exception { this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$.index").value("broTest")) - .andExpect(jsonPath("$.batchSize").value(1)) .andExpect(jsonPath("$.enrichment.fieldMap.geo[0]").value("ip_dst_addr")) .andExpect(jsonPath("$.enrichment.fieldMap.host[0]").value("ip_dst_addr")) .andExpect(jsonPath("$.enrichment.fieldMap.hbaseEnrichment[0]").value("ip_src_addr")) @@ -183,21 +177,19 @@ public void test() throws Exception { this.mockMvc.perform(get(sensorEnrichmentConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$[?(@.index == 'broTest' &&" + - "@.batchSize == 1 &&" + - "@.enrichment.fieldMap.geo[0] == 'ip_dst_addr' &&" + - "@.enrichment.fieldMap.host[0] == 'ip_dst_addr' &&" + - "@.enrichment.fieldMap.hbaseEnrichment[0] == 'ip_src_addr' &&" + - "@.enrichment.fieldToTypeMap.ip_src_addr[0] == 'sample' &&" + - "@.enrichment.fieldMap.stellar.config.group1.foo == '1 + 1' &&" + - "@.enrichment.fieldMap.stellar.config.group1.bar == 'foo' &&" + - "@.enrichment.fieldMap.stellar.config.group2.ALL_CAPS == 'TO_UPPER(source.type)' &&" + - "@.threatIntel.fieldMap.hbaseThreatIntel[0] == 'ip_src_addr' &&" + - "@.threatIntel.fieldMap.hbaseThreatIntel[1] == 'ip_dst_addr' &&" + - "@.threatIntel.fieldToTypeMap.ip_src_addr[0] == 'malicious_ip' &&" + - "@.threatIntel.fieldToTypeMap.ip_dst_addr[0] == 'malicious_ip' &&" + - "@.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"] == 10 &&" + - "@.threatIntel.triageConfig.aggregator == 'MAX'" + + .andExpect(jsonPath("$[?(@.broTest.enrichment.fieldMap.geo[0] == 'ip_dst_addr' &&" + + "@.broTest.enrichment.fieldMap.host[0] == 'ip_dst_addr' &&" + + "@.broTest.enrichment.fieldMap.hbaseEnrichment[0] == 'ip_src_addr' &&" + + "@.broTest.enrichment.fieldToTypeMap.ip_src_addr[0] == 'sample' &&" + + "@.broTest.enrichment.fieldMap.stellar.config.group1.foo == '1 + 1' &&" + + "@.broTest.enrichment.fieldMap.stellar.config.group1.bar == 'foo' &&" + + "@.broTest.enrichment.fieldMap.stellar.config.group2.ALL_CAPS == 'TO_UPPER(source.type)' &&" + + "@.broTest.threatIntel.fieldMap.hbaseThreatIntel[0] == 'ip_src_addr' &&" + + "@.broTest.threatIntel.fieldMap.hbaseThreatIntel[1] == 'ip_dst_addr' &&" + + "@.broTest.threatIntel.fieldToTypeMap.ip_src_addr[0] == 'malicious_ip' &&" + + "@.broTest.threatIntel.fieldToTypeMap.ip_dst_addr[0] == 'malicious_ip' &&" + + "@.broTest.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"] == 10 &&" + + "@.broTest.threatIntel.triageConfig.aggregator == 'MAX'" + ")]").exists()); this.mockMvc.perform(delete(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user,password)).with(csrf())) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java new file mode 100644 index 0000000000..6affa0a69f --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java @@ -0,0 +1,128 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.adrianwalker.multilinestring.Multiline; +import org.apache.metron.rest.service.SensorIndexingConfigService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class SensorIndexingConfigControllerIntegrationTest { + + /** + { + "index": "broTest", + "batchSize": 1 + } + */ + @Multiline + public static String broJson; + + @Autowired + private SensorIndexingConfigService sensorIndexingConfigService; + + @Autowired + private WebApplicationContext wac; + + private MockMvc mockMvc; + + private String sensorIndexingConfigUrl = "/api/v1/sensor/indexing/config"; + private String user = "user"; + private String password = "password"; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(post(sensorIndexingConfigUrl).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get(sensorIndexingConfigUrl + "/broTest")) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get(sensorIndexingConfigUrl)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(delete(sensorIndexingConfigUrl + "/broTest").with(csrf())) + .andExpect(status().isUnauthorized()); + } + + @Test + public void test() throws Exception { + sensorIndexingConfigService.delete("broTest"); + + this.mockMvc.perform(post(sensorIndexingConfigUrl + "/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + .andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.index").value("broTest")) + .andExpect(jsonPath("$.batchSize").value(1)); + + this.mockMvc.perform(get(sensorIndexingConfigUrl + "/broTest").with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.index").value("broTest")) + .andExpect(jsonPath("$.batchSize").value(1)); + + this.mockMvc.perform(get(sensorIndexingConfigUrl).with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[?(@.broTest.index == 'broTest' &&" + + "@.broTest.batchSize == 1" + + ")]").exists()); + + this.mockMvc.perform(delete(sensorIndexingConfigUrl + "/broTest").with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isOk()); + + this.mockMvc.perform(get(sensorIndexingConfigUrl + "/broTest").with(httpBasic(user,password))) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(delete(sensorIndexingConfigUrl + "/broTest").with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(get(sensorIndexingConfigUrl).with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$[?(@.sensorTopic == 'broTest')]").doesNotExist()); + } +} + diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java index f427caba32..d9522f2fa9 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/utils/ReadMeUtils.java @@ -43,8 +43,12 @@ public class ReadMeUtils { public static void main(String[] args) throws Exception { + String path; if (args.length == 0) { - System.out.println("README output path must be passed in as first argument"); + System.out.println("README output path was not set. Defaulting to 'metron-interface/metron-rest/README.md'"); + path = "metron-interface/metron-rest/README.md"; + } else { + path = args[0]; } Reflections reflections = new Reflections("org.apache.metron.rest.controller"); @@ -119,7 +123,7 @@ public static void main(String[] args) throws Exception { context.put( "endpoints", endpoints ); Template template = Velocity.getTemplate("README.vm"); - FileWriter fileWriter = new FileWriter(args[0]); + FileWriter fileWriter = new FileWriter(path); template.merge( context, fileWriter ); fileWriter.close(); } From 0a784d5a941abcfc15b7cfc036d2b594ccf2c446 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 20 Jan 2017 16:19:34 -0600 Subject: [PATCH 30/54] Changes to address PR feedback. Includes: - addressing NPEs in model classes - removing SensorParserConfigHistory endpoint - updating config controllers to return 201 on create and 200 on update - added exception handling to Kafka create topic function - moved zookeeper/curator properties to application.yml - small pom adjustments - limited automatic user create to test and dev profiles - created a top level constant class --- metron-interface/metron-rest-client/pom.xml | 14 - .../metron/rest/model/GrokValidation.java | 4 + .../rest/model/SensorParserConfigHistory.java | 77 ------ .../rest/model/SensorParserConfigVersion.java | 51 ---- .../model/StellarFunctionDescription.java | 3 + .../metron/rest/model/TopologySummary.java | 3 + .../rest/model/TransformationValidation.java | 7 + metron-interface/metron-rest/README.md | 35 +-- metron-interface/metron-rest/pom.xml | 37 +-- ...pository.java => MetronRestConstants.java} | 10 +- .../metron/rest/audit/UserRevEntity.java | 31 --- .../rest/audit/UserRevisionListener.java | 37 --- .../metron/rest/config/WebSecurityConfig.java | 24 +- .../metron/rest/config/ZookeeperConfig.java | 12 +- .../controller/GlobalConfigController.java | 9 +- .../SensorEnrichmentConfigController.java | 9 +- .../SensorIndexingConfigController.java | 9 +- .../SensorParserConfigController.java | 10 +- .../SensorParserConfigHistoryController.java | 69 ----- .../metron/rest/service/KafkaService.java | 10 +- .../SensorParserConfigHistoryService.java | 148 ---------- .../service/SensorParserConfigService.java | 17 -- .../src/main/resources/application.yml | 12 + ...GlobalConfigControllerIntegrationTest.java | 11 +- .../GrokControllerIntegrationTest.java | 3 +- .../KafkaControllerIntegrationTest.java | 3 +- ...chmentConfigControllerIntegrationTest.java | 20 +- ...dexingConfigControllerIntegrationTest.java | 9 +- ...ParserConfigControllerIntegrationTest.java | 10 +- ...onfigHistoryControllerIntegrationTest.java | 258 ------------------ .../StormControllerIntegrationTest.java | 3 +- ...ansformationControllerIntegrationTest.java | 3 +- .../UserControllerIntegrationTest.java | 3 +- .../rest/service/SensorParserConfigTest.java | 4 - 34 files changed, 160 insertions(+), 805 deletions(-) delete mode 100644 metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java delete mode 100644 metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java rename metron-interface/metron-rest/src/main/java/org/apache/metron/rest/{repository/SensorParserConfigVersionRepository.java => MetronRestConstants.java} (74%) delete mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevEntity.java delete mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevisionListener.java delete mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java delete mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java delete mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java diff --git a/metron-interface/metron-rest-client/pom.xml b/metron-interface/metron-rest-client/pom.xml index 29937fa484..66ccf52ce4 100644 --- a/metron-interface/metron-rest-client/pom.xml +++ b/metron-interface/metron-rest-client/pom.xml @@ -21,10 +21,7 @@ 0.3.0 metron-rest-client - ${project.parent.version} - 2.9.4 - 5.0.11.Final @@ -38,17 +35,6 @@ - - joda-time - joda-time - ${joda.time.version} - - - org.hibernate - hibernate-envers - ${hibernate.version} - provided - diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java index ef62cc7c41..7fbcd342ea 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java @@ -17,6 +17,7 @@ */ package org.apache.metron.rest.model; +import java.util.HashMap; import java.util.Map; public class GrokValidation { @@ -42,6 +43,9 @@ public void setSampleData(String sampleData) { } public Map getResults() { + if (results == null) { + return new HashMap<>(); + } return results; } diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java deleted file mode 100644 index 4f35b7dbba..0000000000 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigHistory.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.rest.model; - -import com.fasterxml.jackson.annotation.JsonFormat; -import org.apache.metron.common.configuration.SensorParserConfig; -import org.joda.time.DateTime; - -public class SensorParserConfigHistory { - - public SensorParserConfig config; - private String createdBy; - private String modifiedBy; - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private DateTime createdDate; - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private DateTime modifiedByDate; - - public SensorParserConfig getConfig() { - return config; - } - - public void setConfig(SensorParserConfig config) { - this.config = config; - } - - public String getCreatedBy() { - return createdBy; - } - - public void setCreatedBy(String createdBy) { - this.createdBy = createdBy; - } - - public String getModifiedBy() { - return modifiedBy; - } - - public void setModifiedBy(String modifiedBy) { - this.modifiedBy = modifiedBy; - } - - public DateTime getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(DateTime createdDate) { - this.createdDate = createdDate; - } - - public DateTime getModifiedByDate() { - return modifiedByDate; - } - - public void setModifiedByDate(DateTime modifiedByDate) { - this.modifiedByDate = modifiedByDate; - } -} - - diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java deleted file mode 100644 index f43bf5ca5b..0000000000 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserConfigVersion.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.rest.model; - -import org.hibernate.envers.Audited; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; - -@Entity -@Audited -public class SensorParserConfigVersion { - - @Id - private String name; - - @Column(length = 10000) - private String config; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getConfig() { - return config; - } - - public void setConfig(String config) { - this.config = config; - } -} diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java index 43e158c00c..a1b9f03a21 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/StellarFunctionDescription.java @@ -40,6 +40,9 @@ public String getDescription() { } public String[] getParams() { + if (params == null) { + return new String[0]; + } return params; } diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java index 5af9b57b5e..b9d39a491e 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java @@ -22,6 +22,9 @@ public class TopologySummary { private TopologyStatus[] topologies; public TopologyStatus[] getTopologies() { + if (topologies == null) { + return new TopologyStatus[0]; + } return topologies; } diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TransformationValidation.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TransformationValidation.java index d40697ce32..c2e39e4d26 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TransformationValidation.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TransformationValidation.java @@ -19,6 +19,7 @@ import org.apache.metron.common.configuration.SensorParserConfig; +import java.util.HashMap; import java.util.Map; public class TransformationValidation { @@ -27,6 +28,9 @@ public class TransformationValidation { private SensorParserConfig sensorParserConfig; public Map getSampleData() { + if (sampleData == null) { + return new HashMap<>(); + } return sampleData; } @@ -35,6 +39,9 @@ public void setSampleData(Map sampleData) { } public SensorParserConfig getSensorParserConfig() { + if (sensorParserConfig == null) { + return new SensorParserConfig(); + } return sensorParserConfig; } diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index cbed246a2f..63a2d34cb7 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -88,9 +88,6 @@ Request and Response objects are JSON formatted. The JSON schemas are available | [ `GET /api/v1/sensor/indexing/config/{name}`](#get-apiv1sensorindexingconfig{name})| | [ `POST /api/v1/sensor/parser/config`](#post-apiv1sensorparserconfig)| | [ `GET /api/v1/sensor/parser/config`](#get-apiv1sensorparserconfig)| -| [ `GET /api/v1/sensor/parser/config/history`](#get-apiv1sensorparserconfighistory)| -| [ `GET /api/v1/sensor/parser/config/history/history/{name}`](#get-apiv1sensorparserconfighistoryhistory{name})| -| [ `GET /api/v1/sensor/parser/config/history/{name}`](#get-apiv1sensorparserconfighistory{name})| | [ `GET /api/v1/sensor/parser/config/list/available`](#get-apiv1sensorparserconfiglistavailable)| | [ `POST /api/v1/sensor/parser/config/parseMessage`](#post-apiv1sensorparserconfigparsemessage)| | [ `GET /api/v1/sensor/parser/config/reload/available`](#get-apiv1sensorparserconfigreloadavailable)| @@ -137,7 +134,8 @@ Request and Response objects are JSON formatted. The JSON schemas are available * Input: * globalConfig - The Global Config JSON to be saved * Returns: - * 200 - Returns saved Global Config JSON + * 200 - Global Config updated. Returns saved Global Config JSON + * 201 - Global Config created. Returns saved Global Config JSON ### `GET /api/v1/grok/list` * Description: Lists the common Grok statements available in Metron @@ -211,7 +209,8 @@ Request and Response objects are JSON formatted. The JSON schemas are available * sensorEnrichmentConfig - SensorEnrichmentConfig * name - SensorEnrichmentConfig name * Returns: - * 200 - Returns saved SensorEnrichmentConfig + * 200 - SensorEnrichmentConfig updated. Returns saved SensorEnrichmentConfig + * 201 - SensorEnrichmentConfig created. Returns saved SensorEnrichmentConfig ### `GET /api/v1/sensor/enrichment/config/{name}` * Description: Retrieves a SensorEnrichmentConfig from Zookeeper @@ -240,7 +239,8 @@ Request and Response objects are JSON formatted. The JSON schemas are available * sensorIndexingConfig - SensorIndexingConfig * name - SensorIndexingConfig name * Returns: - * 200 - Returns saved SensorIndexingConfig + * 200 - SensorIndexingConfig updated. Returns saved SensorIndexingConfig + * 201 - SensorIndexingConfig created. Returns saved SensorIndexingConfig ### `GET /api/v1/sensor/indexing/config/{name}` * Description: Retrieves a SensorIndexingConfig from Zookeeper @@ -255,33 +255,14 @@ Request and Response objects are JSON formatted. The JSON schemas are available * Input: * sensorParserConfig - SensorParserConfig * Returns: - * 200 - Returns saved SensorParserConfig + * 200 - SensorParserConfig updated. Returns saved SensorParserConfig + * 201 - SensorParserConfig created. Returns saved SensorParserConfig ### `GET /api/v1/sensor/parser/config` * Description: Retrieves all SensorParserConfigs from Zookeeper * Returns: * 200 - Returns all SensorParserConfigs -### `GET /api/v1/sensor/parser/config/history` - * Description: Retrieves all current versions of SensorParserConfigs including audit information - * Returns: - * 200 - Returns all SensorParserConfigs with audit information - -### `GET /api/v1/sensor/parser/config/history/history/{name}` - * Description: Retrieves the history of all changes made to a SensorParserConfig - * Input: - * name - SensorParserConfig name - * Returns: - * 200 - Returns SensorParserConfig history - -### `GET /api/v1/sensor/parser/config/history/{name}` - * Description: Retrieves the current version of a SensorParserConfig including audit information - * Input: - * name - SensorParserConfig name - * Returns: - * 200 - Returns SensorParserConfig with audit information - * 404 - SensorParserConfig is missing - ### `GET /api/v1/sensor/parser/config/list/available` * Description: Lists the available parser classes that can be found on the classpath * Returns: diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index 1682fa47c5..13e95230c2 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -21,7 +21,6 @@ 0.3.0 metron-rest - ${project.parent.version} UTF-8 UTF-8 @@ -32,8 +31,7 @@ 1.4.1.RELEASE 2.5.0 5.1.40 - 2.9.4 - 5.0.11.Final + 1.0-alpha-3 @@ -59,24 +57,8 @@ spring-boot-starter-security - org.springframework.boot - spring-boot-starter-data-jpa - - - org.hibernate - hibernate-core - - - org.hibernate - hibernate-entitymanager - - - - - org.hibernate - hibernate-core - ${hibernate.version} - provided + org.springframework + spring-jdbc mysql @@ -159,17 +141,6 @@ kafka_2.10 ${global_kafka_version} - - joda-time - joda-time - ${joda.time.version} - - - org.hibernate - hibernate-envers - ${hibernate.version} - provided - io.thekraken grok @@ -283,7 +254,7 @@ org.codehaus.mojo emma-maven-plugin - 1.0-alpha-3 + ${emma.version} org.apache.maven.plugins diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/repository/SensorParserConfigVersionRepository.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestConstants.java similarity index 74% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/repository/SensorParserConfigVersionRepository.java rename to metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestConstants.java index 686cff97a7..bff32dbf26 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/repository/SensorParserConfigVersionRepository.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestConstants.java @@ -15,10 +15,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.metron.rest.repository; +package org.apache.metron.rest; -import org.apache.metron.rest.model.SensorParserConfigVersion; -import org.springframework.data.repository.CrudRepository; +public class MetronRestConstants { + + public static final String DEV_PROFILE = "dev"; + public static final String TEST_PROFILE = "test"; + public static final String CSRF_ENABLE_PROFILE = "csrf-enable"; -public interface SensorParserConfigVersionRepository extends CrudRepository { } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevEntity.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevEntity.java deleted file mode 100644 index 972b567eb4..0000000000 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevEntity.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.rest.audit; - -import org.hibernate.envers.DefaultRevisionEntity; -import org.hibernate.envers.RevisionEntity; - -import javax.persistence.Entity; - -@Entity -@RevisionEntity(UserRevisionListener.class) -public class UserRevEntity extends DefaultRevisionEntity { - private String username; - public String getUsername() { return username; } - public void setUsername(String username) { this.username = username; } -} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevisionListener.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevisionListener.java deleted file mode 100644 index 89a8a34c92..0000000000 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/audit/UserRevisionListener.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.rest.audit; - -import org.hibernate.envers.RevisionListener; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.User; - -public class UserRevisionListener implements RevisionListener { - - @Override - public void newRevision(Object revisionEntity) { - String username = null; - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if (authentication != null && authentication.isAuthenticated()) { - username = ((User) authentication.getPrincipal()).getUsername(); - } - UserRevEntity userRevEntity = (UserRevEntity) revisionEntity; - userRevEntity.setUsername(username); - } -} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/WebSecurityConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/WebSecurityConfig.java index 79dc4504dc..789098a0aa 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/WebSecurityConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/WebSecurityConfig.java @@ -17,6 +17,7 @@ */ package org.apache.metron.rest.config; +import org.apache.metron.rest.MetronRestConstants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; @@ -31,14 +32,13 @@ import javax.sql.DataSource; import java.util.Arrays; +import java.util.List; @Configuration @EnableWebSecurity @Controller public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - private static final String CSRF_ENABLE_PROFILE = "csrf-enable"; - @Autowired private Environment environment; @@ -66,7 +66,7 @@ protected void configure(HttpSecurity http) throws Exception { .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler()) .invalidateHttpSession(true) .deleteCookies("JSESSIONID"); - if (Arrays.asList(environment.getActiveProfiles()).contains(CSRF_ENABLE_PROFILE)) { + if (Arrays.asList(environment.getActiveProfiles()).contains(MetronRestConstants.CSRF_ENABLE_PROFILE)) { http.csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()); } else { http.csrf().disable(); @@ -78,12 +78,16 @@ protected void configure(HttpSecurity http) throws Exception { @Autowired public void configureJdbc(AuthenticationManagerBuilder auth) throws Exception { - auth - .jdbcAuthentication() - .dataSource(dataSource) - .withUser("user").password("password").roles("USER").and() - .withUser("user1").password("password").roles("USER").and() - .withUser("user2").password("password").roles("USER").and() - .withUser("admin").password("password").roles("USER", "ADMIN"); + List activeProfiles = Arrays.asList(environment.getActiveProfiles()); + if (activeProfiles.contains(MetronRestConstants.DEV_PROFILE) || + activeProfiles.contains(MetronRestConstants.TEST_PROFILE)) { + auth.jdbcAuthentication().dataSource(dataSource) + .withUser("user").password("password").roles("USER").and() + .withUser("user1").password("password").roles("USER").and() + .withUser("user2").password("password").roles("USER").and() + .withUser("admin").password("password").roles("USER", "ADMIN"); + } else { + auth.jdbcAuthentication().dataSource(dataSource); + } } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java index 81d5833b31..6be85889d3 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java @@ -33,15 +33,23 @@ public class ZookeeperConfig { public static final String ZK_URL_SPRING_PROPERTY = "zookeeper.url"; + public static final String ZK_CLIENT_SESSION_TIMEOUT = "zookeeper.client.timeout.session"; + public static final String ZK_CLIENT_CONNECTION_TIMEOUT = "zookeeper.client.timeout.connection"; + public static final String CURATOR_SLEEP_TIME = "curator.sleep.time"; + public static final String CURATOR_MAX_RETRIES = "curator.max.retries"; @Bean(initMethod = "start", destroyMethod="close") public CuratorFramework client(Environment environment) { - RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3); + int sleepTime = Integer.parseInt(environment.getProperty(CURATOR_SLEEP_TIME)); + int maxRetries = Integer.parseInt(environment.getProperty(CURATOR_MAX_RETRIES)); + RetryPolicy retryPolicy = new ExponentialBackoffRetry(sleepTime, maxRetries); return CuratorFrameworkFactory.newClient(environment.getProperty(ZK_URL_SPRING_PROPERTY), retryPolicy); } @Bean(destroyMethod="close") public ZkClient zkClient(Environment environment) { - return new ZkClient(environment.getProperty(ZK_URL_SPRING_PROPERTY), 10000, 10000, ZKStringSerializer$.MODULE$); + int sessionTimeout = Integer.parseInt(environment.getProperty(ZK_CLIENT_SESSION_TIMEOUT)); + int connectionTimeout = Integer.parseInt(environment.getProperty(ZK_CLIENT_CONNECTION_TIMEOUT)); + return new ZkClient(environment.getProperty(ZK_URL_SPRING_PROPERTY), sessionTimeout, connectionTimeout, ZKStringSerializer$.MODULE$); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java index 24b9502555..739d68bc2b 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GlobalConfigController.java @@ -41,10 +41,15 @@ public class GlobalConfigController { private GlobalConfigService globalConfigService; @ApiOperation(value = "Creates or updates the Global Config in Zookeeper") - @ApiResponse(message = "Returns saved Global Config JSON", code = 200) + @ApiResponses(value = { @ApiResponse(message = "Global Config updated. Returns saved Global Config JSON", code = 200), + @ApiResponse(message = "Global Config created. Returns saved Global Config JSON", code = 201) }) @RequestMapping(method = RequestMethod.POST) ResponseEntity> save(@ApiParam(name="globalConfig", value="The Global Config JSON to be saved", required=true)@RequestBody Map globalConfig) throws RestException { - return new ResponseEntity<>(globalConfigService.save(globalConfig), HttpStatus.CREATED); + if (globalConfigService.get() == null) { + return new ResponseEntity<>(globalConfigService.save(globalConfig), HttpStatus.CREATED); + } else { + return new ResponseEntity<>(globalConfigService.save(globalConfig), HttpStatus.OK); + } } @ApiOperation(value = "Retrieves the current Global Config from Zookeeper") diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java index e00207f5cb..546384ac13 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorEnrichmentConfigController.java @@ -44,11 +44,16 @@ public class SensorEnrichmentConfigController { private SensorEnrichmentConfigService sensorEnrichmentConfigService; @ApiOperation(value = "Updates or creates a SensorEnrichmentConfig in Zookeeper") - @ApiResponse(message = "Returns saved SensorEnrichmentConfig", code = 200) + @ApiResponses(value = { @ApiResponse(message = "SensorEnrichmentConfig updated. Returns saved SensorEnrichmentConfig", code = 200), + @ApiResponse(message = "SensorEnrichmentConfig created. Returns saved SensorEnrichmentConfig", code = 201) }) @RequestMapping(value = "/{name}", method = RequestMethod.POST) ResponseEntity save(@ApiParam(name="name", value="SensorEnrichmentConfig name", required=true)@PathVariable String name, @ApiParam(name="sensorEnrichmentConfig", value="SensorEnrichmentConfig", required=true)@RequestBody SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException { - return new ResponseEntity<>(sensorEnrichmentConfigService.save(name, sensorEnrichmentConfig), HttpStatus.CREATED); + if (sensorEnrichmentConfigService.findOne(name) == null) { + return new ResponseEntity<>(sensorEnrichmentConfigService.save(name, sensorEnrichmentConfig), HttpStatus.CREATED); + } else { + return new ResponseEntity<>(sensorEnrichmentConfigService.save(name, sensorEnrichmentConfig), HttpStatus.OK); + } } @ApiOperation(value = "Retrieves a SensorEnrichmentConfig from Zookeeper") diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java index 3d6ff8884e..ffd80fb35f 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorIndexingConfigController.java @@ -42,11 +42,16 @@ public class SensorIndexingConfigController { private SensorIndexingConfigService sensorIndexingConfigService; @ApiOperation(value = "Updates or creates a SensorIndexingConfig in Zookeeper") - @ApiResponse(message = "Returns saved SensorIndexingConfig", code = 200) + @ApiResponses(value = { @ApiResponse(message = "SensorIndexingConfig updated. Returns saved SensorIndexingConfig", code = 200), + @ApiResponse(message = "SensorIndexingConfig created. Returns saved SensorIndexingConfig", code = 201) }) @RequestMapping(value = "/{name}", method = RequestMethod.POST) ResponseEntity> save(@ApiParam(name="name", value="SensorIndexingConfig name", required=true)@PathVariable String name, @ApiParam(name="sensorIndexingConfig", value="SensorIndexingConfig", required=true)@RequestBody Map sensorIndexingConfig) throws RestException { - return new ResponseEntity<>(sensorIndexingConfigService.save(name, sensorIndexingConfig), HttpStatus.CREATED); + if (sensorIndexingConfigService.findOne(name) == null) { + return new ResponseEntity<>(sensorIndexingConfigService.save(name, sensorIndexingConfig), HttpStatus.CREATED); + } else { + return new ResponseEntity<>(sensorIndexingConfigService.save(name, sensorIndexingConfig), HttpStatus.OK); + } } @ApiOperation(value = "Retrieves a SensorIndexingConfig from Zookeeper") diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java index f617fcbfe0..189e2afed6 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigController.java @@ -45,10 +45,16 @@ public class SensorParserConfigController { private SensorParserConfigService sensorParserConfigService; @ApiOperation(value = "Updates or creates a SensorParserConfig in Zookeeper") - @ApiResponse(message = "Returns saved SensorParserConfig", code = 200) + @ApiResponses(value = { @ApiResponse(message = "SensorParserConfig updated. Returns saved SensorParserConfig", code = 200), + @ApiResponse(message = "SensorParserConfig created. Returns saved SensorParserConfig", code = 201) }) @RequestMapping(method = RequestMethod.POST) ResponseEntity save(@ApiParam(name="sensorParserConfig", value="SensorParserConfig", required=true)@RequestBody SensorParserConfig sensorParserConfig) throws RestException { - return new ResponseEntity<>(sensorParserConfigService.save(sensorParserConfig), HttpStatus.CREATED); + String name = sensorParserConfig.getSensorTopic(); + if (sensorParserConfigService.findOne(name) == null) { + return new ResponseEntity<>(sensorParserConfigService.save(sensorParserConfig), HttpStatus.CREATED); + } else { + return new ResponseEntity<>(sensorParserConfigService.save(sensorParserConfig), HttpStatus.OK); + } } @ApiOperation(value = "Retrieves a SensorParserConfig from Zookeeper") diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java deleted file mode 100644 index 11a1d8c44a..0000000000 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/SensorParserConfigHistoryController.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.rest.controller; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import org.apache.metron.rest.RestException; -import org.apache.metron.rest.model.SensorParserConfigHistory; -import org.apache.metron.rest.service.SensorParserConfigHistoryService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -@RestController -@RequestMapping("/api/v1/sensor/parser/config/history") -public class SensorParserConfigHistoryController { - - @Autowired - private SensorParserConfigHistoryService sensorParserHistoryService; - - @ApiOperation(value = "Retrieves the current version of a SensorParserConfig including audit information") - @ApiResponses(value = { @ApiResponse(message = "Returns SensorParserConfig with audit information", code = 200), - @ApiResponse(message = "SensorParserConfig is missing", code = 404) }) - @RequestMapping(value = "/{name}", method = RequestMethod.GET) - ResponseEntity findOne(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws RestException { - SensorParserConfigHistory sensorParserConfigHistory = sensorParserHistoryService.findOne(name); - if (sensorParserConfigHistory != null) { - return new ResponseEntity<>(sensorParserHistoryService.findOne(name), HttpStatus.OK); - } - return new ResponseEntity<>(HttpStatus.NOT_FOUND); - } - - @ApiOperation(value = "Retrieves all current versions of SensorParserConfigs including audit information") - @ApiResponse(message = "Returns all SensorParserConfigs with audit information", code = 200) - @RequestMapping(method = RequestMethod.GET) - ResponseEntity> getall() throws RestException { - return new ResponseEntity<>(sensorParserHistoryService.getAll(), HttpStatus.OK); - } - - @ApiOperation(value = "Retrieves the history of all changes made to a SensorParserConfig") - @ApiResponse(message = "Returns SensorParserConfig history", code = 200) - @RequestMapping(value = "/history/{name}", method = RequestMethod.GET) - ResponseEntity> history(@ApiParam(name="name", value="SensorParserConfig name", required=true)@PathVariable String name) throws RestException { - return new ResponseEntity<>(sensorParserHistoryService.history(name), HttpStatus.OK); - } -} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java index 0fc57685f7..f283fe2e02 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java @@ -17,6 +17,7 @@ */ package org.apache.metron.rest.service; +import kafka.admin.AdminOperationException; import kafka.admin.AdminUtils; import kafka.admin.RackAwareMode; import kafka.utils.ZkUtils; @@ -25,6 +26,7 @@ import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.common.PartitionInfo; import org.apache.kafka.common.TopicPartition; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.KafkaTopic; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -45,9 +47,13 @@ public class KafkaService { private String offsetTopic = "__consumer_offsets"; - public KafkaTopic createTopic(KafkaTopic topic) { + public KafkaTopic createTopic(KafkaTopic topic) throws RestException { if (!listTopics().contains(topic.getName())) { - AdminUtils.createTopic(zkUtils, topic.getName(), topic.getNumPartitions(), topic.getReplicationFactor(), topic.getProperties(), RackAwareMode.Disabled$.MODULE$); + try { + AdminUtils.createTopic(zkUtils, topic.getName(), topic.getNumPartitions(), topic.getReplicationFactor(), topic.getProperties(), RackAwareMode.Disabled$.MODULE$); + } catch (AdminOperationException e) { + throw new RestException(e); + } } return topic; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java deleted file mode 100644 index 3fe6d8a9ba..0000000000 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigHistoryService.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.rest.service; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.metron.common.configuration.SensorParserConfig; -import org.apache.metron.rest.RestException; -import org.apache.metron.rest.audit.UserRevEntity; -import org.apache.metron.rest.model.SensorParserConfigVersion; -import org.apache.metron.rest.model.SensorParserConfigHistory; -import org.hibernate.envers.AuditReader; -import org.hibernate.envers.AuditReaderFactory; -import org.hibernate.envers.query.AuditEntity; -import org.joda.time.DateTime; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.persistence.EntityManager; -import javax.persistence.NoResultException; -import javax.persistence.PersistenceContext; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -@Service -public class SensorParserConfigHistoryService { - - @Autowired - private ObjectMapper objectMapper; - - @PersistenceContext - private EntityManager entityManager; - - @Autowired - private GrokService grokService; - - @Autowired - private SensorParserConfigService sensorParserConfigService; - - public SensorParserConfigHistory findOne(String name) throws RestException { - SensorParserConfigHistory sensorParserConfigHistory = null; - AuditReader reader = AuditReaderFactory.get(entityManager); - try{ - Object[] latestResults = (Object[]) reader.createQuery().forRevisionsOfEntity(SensorParserConfigVersion.class, false, true) - .add(AuditEntity.property("name").eq(name)) - .addOrder(AuditEntity.revisionNumber().desc()) - .setMaxResults(1) - .getSingleResult(); - SensorParserConfigVersion sensorParserConfigVersion = (SensorParserConfigVersion) latestResults[0]; - sensorParserConfigHistory = new SensorParserConfigHistory(); - String config = sensorParserConfigVersion.getConfig(); - if (config != null) { - sensorParserConfigHistory.setConfig(deserialize(config)); - if (grokService.isGrokConfig(sensorParserConfigHistory.getConfig())) { - grokService.addGrokStatementToConfig(sensorParserConfigHistory.getConfig()); - } - } else { - sensorParserConfigHistory.setConfig(null); - } - UserRevEntity latestUserRevEntity = (UserRevEntity) latestResults[1]; - sensorParserConfigHistory.setModifiedBy(latestUserRevEntity.getUsername()); - sensorParserConfigHistory.setModifiedByDate(new DateTime(latestUserRevEntity.getTimestamp())); - Object[] firstResults = (Object[]) reader.createQuery().forRevisionsOfEntity(SensorParserConfigVersion.class, false, true) - .add(AuditEntity.property("name").eq(name)) - .addOrder(AuditEntity.revisionNumber().asc()) - .setMaxResults(1) - .getSingleResult(); - UserRevEntity firstUserRevEntity = (UserRevEntity) firstResults[1]; - sensorParserConfigHistory.setCreatedBy(firstUserRevEntity.getUsername()); - sensorParserConfigHistory.setCreatedDate(new DateTime(firstUserRevEntity.getTimestamp())); - - } catch (NoResultException e){ - SensorParserConfig sensorParserConfig = sensorParserConfigService.findOne(name); - if (sensorParserConfig != null) { - sensorParserConfigHistory = new SensorParserConfigHistory(); - sensorParserConfigHistory.setConfig(sensorParserConfig); - } - } - return sensorParserConfigHistory; - } - - public List getAll() throws RestException { - List historyList = new ArrayList<>(); - for(String sensorType: sensorParserConfigService.getAllTypes()) { - historyList.add(findOne(sensorType)); - } - return historyList; - } - - public List history(String name) throws RestException { - List historyList = new ArrayList<>(); - AuditReader reader = AuditReaderFactory.get(entityManager); - List results = reader.createQuery().forRevisionsOfEntity(SensorParserConfigVersion.class, false, true) - .add(AuditEntity.property("name").eq(name)) - .addOrder(AuditEntity.revisionNumber().asc()) - .getResultList(); - String createdBy = ""; - DateTime createdDate = null; - for(int i = 0; i < results.size(); i++) { - Object[] revision = (Object[]) results.get(i); - SensorParserConfigVersion sensorParserConfigVersion = (SensorParserConfigVersion) revision[0]; - UserRevEntity userRevEntity = (UserRevEntity) revision[1]; - String username = userRevEntity.getUsername(); - DateTime dateTime = new DateTime(userRevEntity.getTimestamp()); - if (i == 0) { - createdBy = username; - createdDate = dateTime; - } - SensorParserConfigHistory sensorParserInfo = new SensorParserConfigHistory(); - String config = sensorParserConfigVersion.getConfig(); - if (config != null) { - sensorParserInfo.setConfig(deserialize(config)); - } else { - sensorParserInfo.setConfig(null); - } - sensorParserInfo.setCreatedBy(createdBy); - sensorParserInfo.setCreatedDate(createdDate); - sensorParserInfo.setModifiedBy(username); - sensorParserInfo.setModifiedByDate(dateTime); - historyList.add(0, sensorParserInfo); - } - return historyList; - } - - private SensorParserConfig deserialize(String config) throws RestException { - try { - return objectMapper.readValue(config, new TypeReference() {}); - } catch (IOException e) { - throw new RestException(e); - } - } -} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java index a3eb53e9ef..62fd1202a1 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -26,13 +26,10 @@ import org.apache.metron.parsers.interfaces.MessageParser; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.ParseMessageRequest; -import org.apache.metron.rest.model.SensorParserConfigVersion; -import org.apache.metron.rest.repository.SensorParserConfigVersionRepository; import org.apache.zookeeper.KeeperException; import org.json.simple.JSONObject; import org.reflections.Reflections; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.stereotype.Service; import java.io.File; @@ -58,9 +55,6 @@ public void setClient(CuratorFramework client) { @Autowired private GrokService grokService; - @Autowired - private SensorParserConfigVersionRepository sensorParserRepository; - private Map availableParsers; public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws RestException { @@ -80,7 +74,6 @@ public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws Res } catch (Exception e) { throw new RestException(e); } - saveVersion(sensorParserConfig.getSensorTopic(), serializedConfig); return sensorParserConfig; } @@ -94,13 +87,6 @@ private String serialize(SensorParserConfig sensorParserConfig) throws RestExcep return serializedConfig; } - private void saveVersion(String name, String config) { - SensorParserConfigVersion sensorParser = new SensorParserConfigVersion(); - sensorParser.setName(name); - sensorParser.setConfig(config); - sensorParserRepository.save(sensorParser); - } - public SensorParserConfig findOne(String name) throws RestException { SensorParserConfig sensorParserConfig; try { @@ -128,11 +114,8 @@ public Iterable getAll() throws RestException { public boolean delete(String name) throws RestException { try { client.delete().forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/" + name); - sensorParserRepository.delete(name); } catch (KeeperException.NoNodeException e) { return false; - } catch (EmptyResultDataAccessException e) { - return true; } catch (Exception e) { throw new RestException(e); } diff --git a/metron-interface/metron-rest/src/main/resources/application.yml b/metron-interface/metron-rest/src/main/resources/application.yml index d43d6b3d86..7e45ed984b 100644 --- a/metron-interface/metron-rest/src/main/resources/application.yml +++ b/metron-interface/metron-rest/src/main/resources/application.yml @@ -28,3 +28,15 @@ grok: path: temp: ./ default: /apps/metron/patterns + +zookeeper: + client: + timeout: + session: 10000 + connection: 10000 + +curator: + sleep: + time: 1000 + max: + retries: 3 diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java index 4938873fa9..7796c8b2bf 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GlobalConfigControllerIntegrationTest.java @@ -18,7 +18,6 @@ package org.apache.metron.rest.controller; import org.adrianwalker.multilinestring.Multiline; -import org.apache.metron.rest.service.GlobalConfigService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,6 +30,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; @@ -42,7 +42,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class GlobalConfigControllerIntegrationTest { /** @@ -59,9 +59,6 @@ public class GlobalConfigControllerIntegrationTest { @Autowired private WebApplicationContext wac; - @Autowired - private GlobalConfigService globalConfigService; - private MockMvc mockMvc; private String globalConfigUrl = "/api/v1/global/config"; @@ -94,6 +91,10 @@ public void test() throws Exception { .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))); + this.mockMvc.perform(post(globalConfigUrl).with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(globalJson)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))); + this.mockMvc.perform(get(globalConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java index 3e7f8c5537..e618d48618 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java @@ -30,6 +30,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; @@ -41,7 +42,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class GrokControllerIntegrationTest { /** diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java index 553acf8716..02997082d0 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/KafkaControllerIntegrationTest.java @@ -38,6 +38,7 @@ import java.io.IOException; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; @@ -50,7 +51,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class KafkaControllerIntegrationTest { @Autowired 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 4dd9fa537c..a840da487f 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 @@ -31,6 +31,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; @@ -43,7 +44,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class SensorEnrichmentConfigControllerIntegrationTest { /** @@ -157,6 +158,23 @@ public void test() throws Exception { .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); + this.mockMvc.perform(post(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.enrichment.fieldMap.geo[0]").value("ip_dst_addr")) + .andExpect(jsonPath("$.enrichment.fieldMap.host[0]").value("ip_dst_addr")) + .andExpect(jsonPath("$.enrichment.fieldMap.hbaseEnrichment[0]").value("ip_src_addr")) + .andExpect(jsonPath("$.enrichment.fieldToTypeMap.ip_src_addr[0]").value("sample")) + .andExpect(jsonPath("$.enrichment.fieldMap.stellar.config.group1.foo").value("1 + 1")) + .andExpect(jsonPath("$.enrichment.fieldMap.stellar.config.group1.bar").value("foo")) + .andExpect(jsonPath("$.enrichment.fieldMap.stellar.config.group2.ALL_CAPS").value("TO_UPPER(source.type)")) + .andExpect(jsonPath("$.threatIntel.fieldMap.hbaseThreatIntel[0]").value("ip_src_addr")) + .andExpect(jsonPath("$.threatIntel.fieldMap.hbaseThreatIntel[1]").value("ip_dst_addr")) + .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_src_addr[0]").value("malicious_ip")) + .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_dst_addr[0]").value("malicious_ip")) + .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) + .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); + this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java index 6affa0a69f..4daec9d84f 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java @@ -31,6 +31,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; @@ -43,7 +44,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class SensorIndexingConfigControllerIntegrationTest { /** @@ -97,6 +98,12 @@ public void test() throws Exception { .andExpect(jsonPath("$.index").value("broTest")) .andExpect(jsonPath("$.batchSize").value(1)); + this.mockMvc.perform(post(sensorIndexingConfigUrl + "/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.index").value("broTest")) + .andExpect(jsonPath("$.batchSize").value(1)); + this.mockMvc.perform(get(sensorIndexingConfigUrl + "/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java index 1a9aff8a3a..1957dc1ce5 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -36,6 +36,7 @@ import java.io.File; import java.io.IOException; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; @@ -48,7 +49,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class SensorParserConfigControllerIntegrationTest { /** @@ -256,6 +257,13 @@ public void test() throws Exception { .andExpect(jsonPath("$.sensorTopic").value("broTest")) .andExpect(jsonPath("$.parserConfig").isEmpty()); + this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) + .andExpect(jsonPath("$.sensorTopic").value("broTest")) + .andExpect(jsonPath("$.parserConfig").isEmpty()); + this.mockMvc.perform(get(sensorParserConfigUrl).with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java deleted file mode 100644 index 8786950a30..0000000000 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigHistoryControllerIntegrationTest.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.rest.controller; - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.adrianwalker.multilinestring.Multiline; -import org.apache.commons.io.FileUtils; -import org.apache.metron.common.configuration.SensorParserConfig; -import org.apache.metron.rest.repository.SensorParserConfigVersionRepository; -import org.apache.metron.rest.service.GrokService; -import org.apache.metron.rest.service.SensorParserConfigService; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.core.env.Environment; -import org.springframework.http.MediaType; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.context.WebApplicationContext; - -import javax.sql.DataSource; -import java.io.File; -import java.io.IOException; -import java.util.Map; - -import static org.hamcrest.Matchers.isEmptyOrNullString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; -import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; -import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class SensorParserConfigHistoryControllerIntegrationTest { - - /** - { - "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", - "sensorTopic":"broTest", - "parserConfig": { - "version":1 - } - } - */ - @Multiline - public static String broJson1; - - /** - { - "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", - "sensorTopic":"broTest", - "parserConfig": { - "version":2 - } - } - */ - @Multiline - public static String broJson2; - - /** - { - "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", - "sensorTopic":"broTest", - "parserConfig": { - "version":3 - } - } - */ - @Multiline - public static String broJson3; - - @Autowired - private Environment environment; - - @Autowired - private WebApplicationContext wac; - - @Autowired - private DataSource dataSource; - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private SensorParserConfigService sensorParserConfigService; - - @Autowired - private SensorParserConfigVersionRepository sensorParserConfigVersionRepository; - - private MockMvc mockMvc; - - private String sensorParserConfigUrl = "/api/v1/sensor/parser/config"; - private String sensorParserConfigHistoryUrl = "/api/v1/sensor/parser/config/history"; - private String user1 = "user1"; - private String user2 = "user2"; - private String password = "password"; - - @Before - public void setup() throws Exception { - this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); - } - - @Test - public void testSecurity() throws Exception { - this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/broTest")) - .andExpect(status().isUnauthorized()); - - this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/getall")) - .andExpect(status().isUnauthorized()); - - this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/history/bro")) - .andExpect(status().isUnauthorized()); - } - - @Test - public void test() throws Exception { - cleanFileSystem(); - resetConfigs(); - resetAuditTables(); - SensorParserConfig bro3 = fromJson(broJson3); - - this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/broTest").with(httpBasic(user1,password))) - .andExpect(status().isNotFound()); - - this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson1)); - Thread.sleep(1000); - this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user1,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson2)); - Thread.sleep(1000); - this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user2,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson3)); - - assertEquals(bro3.getParserConfig().get("version"), fromJson(sensorParserConfigVersionRepository.findOne("broTest").getConfig()).getParserConfig().get("version")); - - String json = this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/broTest").with(httpBasic(user1,password))) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$.config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) - .andExpect(jsonPath("$.config.sensorTopic").value("broTest")) - .andExpect(jsonPath("$.config.parserConfig.version").value(3)) - .andExpect(jsonPath("$.createdBy").value(user1)) - .andExpect(jsonPath("$.modifiedBy").value(user2)) - .andReturn().getResponse().getContentAsString(); - - Map result = objectMapper.readValue(json, new TypeReference>() {}); - validateCreateModifiedByDate(result, false); - - this.mockMvc.perform(get(sensorParserConfigHistoryUrl).with(httpBasic(user1,password))) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$[?(@.config.sensorTopic == 'broTest')]").exists()); - - this.mockMvc.perform(delete(sensorParserConfigUrl + "/broTest").with(httpBasic(user2,password)).with(csrf())); - - json = this.mockMvc.perform(get(sensorParserConfigHistoryUrl + "/history/broTest").with(httpBasic(user1,password))) - .andExpect(status().isOk()) - .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$[0].config", isEmptyOrNullString())) - .andExpect(jsonPath("$[0].createdBy").value(user1)) - .andExpect(jsonPath("$[0].modifiedBy").value(user2)) - .andExpect(jsonPath("$[1].config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) - .andExpect(jsonPath("$[1].config.sensorTopic").value("broTest")) - .andExpect(jsonPath("$[1].config.parserConfig.version").value(3)) - .andExpect(jsonPath("$[1].createdBy").value(user1)) - .andExpect(jsonPath("$[1].modifiedBy").value(user2)) - .andExpect(jsonPath("$[2].config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) - .andExpect(jsonPath("$[2].config.sensorTopic").value("broTest")) - .andExpect(jsonPath("$[2].config.parserConfig.version").value(2)) - .andExpect(jsonPath("$[2].createdBy").value(user1)) - .andExpect(jsonPath("$[2].modifiedBy").value(user1)) - .andExpect(jsonPath("$[3].config.parserClassName").value("org.apache.metron.parsers.bro.BasicBroParser")) - .andExpect(jsonPath("$[3].config.sensorTopic").value("broTest")) - .andExpect(jsonPath("$[3].config.parserConfig.version").value(1)) - .andExpect(jsonPath("$[3].createdBy").value(user1)) - .andExpect(jsonPath("$[3].modifiedBy").value(user1)) - .andReturn().getResponse().getContentAsString(); - - Map[] historyResults = objectMapper.readValue(json, new TypeReference[]>() {}); - validateCreateModifiedByDate(historyResults[0], false); - validateCreateModifiedByDate(historyResults[1], false); - validateCreateModifiedByDate(historyResults[2], false); - validateCreateModifiedByDate(historyResults[3], true); - - assertNull(sensorParserConfigVersionRepository.findOne("broTest")); - } - - private void validateCreateModifiedByDate(Map result, boolean shouldBeEqual) { - String createdDate = (String) result.get("createdDate"); - assertTrue("createdDate is not empty", createdDate != null && !"".equals(createdDate)); - String modifiedByDate = (String) result.get("modifiedByDate"); - assertTrue("modifiedByDate is not empty", modifiedByDate != null && !"".equals(modifiedByDate)); - if (shouldBeEqual) { - assertTrue("createdDate and modifiedByDate should be equal", createdDate.equals(modifiedByDate)); - } else { - assertTrue("createdDate and modifiedByDate should be different", !createdDate.equals(modifiedByDate)); - } - } - - private void cleanFileSystem() throws IOException { - File grokTempPath = new File(environment.getProperty(GrokService.GROK_TEMP_PATH_SPRING_PROPERTY)); - if (grokTempPath.exists()) { - FileUtils.cleanDirectory(grokTempPath); - FileUtils.deleteDirectory(grokTempPath); - } - File grokPath = new File(environment.getProperty(GrokService.GROK_DEFAULT_PATH_SPRING_PROPERTY)); - if (grokPath.exists()) { - FileUtils.cleanDirectory(grokPath); - FileUtils.deleteDirectory(grokPath); - } - } - - private void resetConfigs() throws Exception { - for(SensorParserConfig sensorParserConfig: sensorParserConfigService.getAll()) { - sensorParserConfigService.delete(sensorParserConfig.getSensorTopic()); - } - } - - private void resetAuditTables() { - JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); - jdbcTemplate.execute("SET FOREIGN_KEY_CHECKS = 0"); - jdbcTemplate.execute("truncate table sensor_parser_config_version_aud"); - jdbcTemplate.execute("truncate table user_rev_entity"); - jdbcTemplate.execute("truncate table sensor_parser_config_version"); - jdbcTemplate.execute("SET FOREIGN_KEY_CHECKS = 1"); - } - - private SensorParserConfig fromJson(String json) throws IOException { - return objectMapper.readValue(json, new TypeReference() {}); - } -} 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 7c976aa679..2a2cb11cce 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 @@ -37,6 +37,7 @@ import java.util.HashMap; import java.util.Map; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.hasSize; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; @@ -48,7 +49,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class StormControllerIntegrationTest { @Autowired diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java index c8813ac229..ec987e05fb 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java @@ -30,6 +30,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.hasSize; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; @@ -43,7 +44,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class TransformationControllerIntegrationTest { private String valid = "TO_LOWER(test)"; diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java index d2052d3c2b..9bdd439759 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/UserControllerIntegrationTest.java @@ -28,6 +28,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -36,7 +37,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class UserControllerIntegrationTest { private MockMvc mockMvc; diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java index ec6c2a0565..1d2e252a15 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java @@ -25,7 +25,6 @@ import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.configuration.SensorParserConfig; import org.apache.metron.common.utils.JSONUtils; -import org.apache.metron.rest.repository.SensorParserConfigVersionRepository; import org.apache.zookeeper.KeeperException; import org.junit.Before; import org.junit.Test; @@ -68,9 +67,6 @@ public class SensorParserConfigTest { @Mock private GrokService grokService; - @Mock - private SensorParserConfigVersionRepository sensorParserRepository; - @InjectMocks private SensorParserConfigService sensorParserConfigService; From 88c1f7df3bb671f96e33142aa6d7f360db7662a9 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 20 Jan 2017 16:35:58 -0600 Subject: [PATCH 31/54] Converted TopologyResponse status to enum --- .../metron/rest/model/TopologyResponse.java | 8 ++-- .../rest/model/TopologyResponseCode.java | 23 ++++++++++ .../StormControllerIntegrationTest.java | 44 +++++++++---------- 3 files changed, 49 insertions(+), 26 deletions(-) create mode 100644 metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponseCode.java diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java index ab43fb4a1f..6894e89821 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java @@ -19,10 +19,10 @@ public class TopologyResponse { - private String status; + private TopologyResponseCode status; private String message; - public String getStatus() { + public TopologyResponseCode getStatus() { return status; } @@ -31,12 +31,12 @@ public String getMessage() { } public void setSuccessMessage(String message) { - this.status = "success"; + this.status = TopologyResponseCode.SUCCESS; this.message = message; } public void setErrorMessage(String message) { - this.status = "error"; + this.status = TopologyResponseCode.ERROR; this.message = message; } } diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponseCode.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponseCode.java new file mode 100644 index 0000000000..a85bd89ccb --- /dev/null +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponseCode.java @@ -0,0 +1,23 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.model; + +public enum TopologyResponseCode { + + SUCCESS,ERROR +} 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 2a2cb11cce..c592159330 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 @@ -147,29 +147,29 @@ public void test() throws Exception { this.mockMvc.perform(get(stormUrl + "/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); this.mockMvc.perform(get(stormUrl + "/parser/activate/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); this.mockMvc.perform(get(stormUrl + "/parser/deactivate/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); this.mockMvc.perform(get(stormUrl + "/parser/start/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.GLOBAL_CONFIG_MISSING.name())); globalConfigService.save(globalConfig); this.mockMvc.perform(get(stormUrl + "/parser/start/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.SENSOR_PARSER_CONFIG_MISSING.name())); SensorParserConfig sensorParserConfig = new SensorParserConfig(); @@ -179,7 +179,7 @@ public void test() throws Exception { this.mockMvc.perform(get(stormUrl + "/parser/start/broTest").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.name())); this.mockMvc.perform(get(stormUrl + "/broTest").with(httpBasic(user,password))) @@ -198,7 +198,7 @@ public void test() throws Exception { this.mockMvc.perform(get(stormUrl + "/parser/stop/broTest?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); this.mockMvc.perform(get(stormUrl + "/enrichment").with(httpBasic(user,password))) @@ -206,37 +206,37 @@ public void test() throws Exception { this.mockMvc.perform(get(stormUrl + "/enrichment/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); this.mockMvc.perform(get(stormUrl + "/enrichment/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); this.mockMvc.perform(get(stormUrl + "/enrichment/stop?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); this.mockMvc.perform(get(stormUrl + "/enrichment/start").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.toString())); this.mockMvc.perform(get(stormUrl + "/enrichment/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); this.mockMvc.perform(get(stormUrl + "/enrichment/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); this.mockMvc.perform(get(stormUrl + "/enrichment/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.ACTIVE.name())); this.mockMvc.perform(get(stormUrl + "/enrichment").with(httpBasic(user,password))) @@ -255,7 +255,7 @@ public void test() throws Exception { this.mockMvc.perform(get(stormUrl + "/enrichment/stop").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); this.mockMvc.perform(get(stormUrl + "/indexing").with(httpBasic(user,password))) @@ -263,32 +263,32 @@ public void test() throws Exception { this.mockMvc.perform(get(stormUrl + "/indexing/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); this.mockMvc.perform(get(stormUrl + "/indexing/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.TOPOLOGY_NOT_FOUND.name())); this.mockMvc.perform(get(stormUrl + "/indexing/stop?stopNow=true").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("error")) + .andExpect(jsonPath("$.status").value("ERROR")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOP_ERROR.toString())); this.mockMvc.perform(get(stormUrl + "/indexing/start").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STARTED.toString())); this.mockMvc.perform(get(stormUrl + "/indexing/deactivate").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.INACTIVE.name())); this.mockMvc.perform(get(stormUrl + "/indexing/activate").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.ACTIVE.name())); this.mockMvc.perform(get(stormUrl + "/indexing").with(httpBasic(user,password))) @@ -307,7 +307,7 @@ public void test() throws Exception { this.mockMvc.perform(get(stormUrl + "/indexing/stop").with(httpBasic(user,password))) .andExpect(status().isOk()) - .andExpect(jsonPath("$.status").value("success")) + .andExpect(jsonPath("$.status").value("SUCCESS")) .andExpect(jsonPath("$.message").value(TopologyStatusCode.STOPPED.name())); this.mockMvc.perform(get(stormUrl + "/client/status").with(httpBasic(user,password))) From 98f6cafb310e03ea078a50a102072d5d5c3a7bc8 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 23 Jan 2017 13:06:46 -0600 Subject: [PATCH 32/54] Separated Services into interfaces and implementations --- .../metron/rest/MetronRestConstants.java | 29 ++ .../metron/rest/config/HadoopConfig.java | 6 +- .../metron/rest/config/KafkaConfig.java | 9 +- .../rest/config/RestTemplateConfig.java | 4 +- .../metron/rest/config/StormConfig.java | 11 +- .../metron/rest/config/ZookeeperConfig.java | 23 +- .../rest/controller/StormController.java | 43 +-- .../rest/service/GlobalConfigService.java | 46 +-- .../metron/rest/service/GrokService.java | 137 +-------- .../metron/rest/service/HdfsService.java | 31 +- .../metron/rest/service/KafkaService.java | 91 +----- .../SensorEnrichmentConfigService.java | 77 +---- .../service/SensorIndexingConfigService.java | 73 +---- .../service/SensorParserConfigService.java | 157 +--------- .../rest/service/StormAdminService.java | 42 +++ .../metron/rest/service/StormService.java | 183 ------------ .../rest/service/StormStatusService.java | 39 +++ .../rest/service/TransformationService.java | 57 +--- .../{ => impl}/DockerStormCLIWrapper.java | 2 +- .../service/impl/GlobalConfigServiceImpl.java | 72 +++++ .../rest/service/impl/GrokServiceImpl.java | 64 ++++ .../rest/service/impl/HdfsServiceImpl.java | 58 ++++ .../rest/service/impl/KafkaServiceImpl.java | 119 ++++++++ .../SensorEnrichmentConfigServiceImpl.java | 106 +++++++ .../impl/SensorIndexingConfigServiceImpl.java | 101 +++++++ .../impl/SensorParserConfigServiceImpl.java | 282 ++++++++++++++++++ .../service/impl/StormAdminServiceImpl.java | 93 ++++++ .../service/{ => impl}/StormCLIWrapper.java | 29 +- .../service/impl/StormStatusServiceImpl.java | 122 ++++++++ .../impl/TransformationServiceImpl.java | 87 ++++++ .../apache/metron/rest/config/TestConfig.java | 6 +- ...chmentConfigControllerIntegrationTest.java | 5 + ...dexingConfigControllerIntegrationTest.java | 5 + ...ParserConfigControllerIntegrationTest.java | 6 +- .../rest/mock/MockStormCLIClientWrapper.java | 2 +- .../rest/mock/MockStormRestTemplate.java | 6 +- .../metron/rest/service/HdfsServiceTest.java | 6 +- .../rest/service/SensorParserConfigTest.java | 4 +- 38 files changed, 1350 insertions(+), 883 deletions(-) create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormAdminService.java delete mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormStatusService.java rename metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/{ => impl}/DockerStormCLIWrapper.java (98%) create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java rename metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/{ => impl}/StormCLIWrapper.java (76%) create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestConstants.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestConstants.java index bff32dbf26..87862222e5 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestConstants.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/MetronRestConstants.java @@ -17,10 +17,39 @@ */ package org.apache.metron.rest; +import org.apache.metron.parsers.GrokParser; + public class MetronRestConstants { public static final String DEV_PROFILE = "dev"; public static final String TEST_PROFILE = "test"; + public static final String DOCKER_PROFILE = "docker"; public static final String CSRF_ENABLE_PROFILE = "csrf-enable"; + public static final String GROK_DEFAULT_PATH_SPRING_PROPERTY = "grok.path.default"; + public static final String GROK_TEMP_PATH_SPRING_PROPERTY = "grok.path.temp"; + public static final String GROK_CLASS_NAME = GrokParser.class.getName(); + public static final String GROK_PATH_KEY = "grokPath"; + public static final String GROK_STATEMENT_KEY = "grokStatement"; + public static final String GROK_PATTERN_LABEL_KEY = "patternLabel"; + + public static final String STORM_UI_SPRING_PROPERTY = "storm.ui.url"; + public static final String TOPOLOGY_SUMMARY_URL = "/api/v1/topology/summary"; + public static final String TOPOLOGY_URL = "/api/v1/topology"; + public static final String ENRICHMENT_TOPOLOGY_NAME = "enrichment"; + public static final String INDEXING_TOPOLOGY_NAME = "indexing"; + public static final String PARSER_SCRIPT_PATH_SPRING_PROPERTY = "storm.parser.script.path"; + public static final String ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY = "storm.enrichment.script.path"; + public static final String INDEXING_SCRIPT_PATH_SPRING_PROPERTY = "storm.indexing.script.path"; + + public static final String ZK_URL_SPRING_PROPERTY = "zookeeper.url"; + public static final String ZK_CLIENT_SESSION_TIMEOUT = "zookeeper.client.timeout.session"; + public static final String ZK_CLIENT_CONNECTION_TIMEOUT = "zookeeper.client.timeout.connection"; + public static final String CURATOR_SLEEP_TIME = "curator.sleep.time"; + public static final String CURATOR_MAX_RETRIES = "curator.max.retries"; + + public static final String KAFKA_BROKER_URL_SPRING_PROPERTY = "kafka.broker.url"; + + public static final String HDFS_URL_SPRING_PROPERTY = "hdfs.namenode.url"; + public static final String DEFAULT_HDFS_URL = "file:///"; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HadoopConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HadoopConfig.java index 59d4f21c0b..f4b8bdd783 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HadoopConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/HadoopConfig.java @@ -17,6 +17,7 @@ */ package org.apache.metron.rest.config; +import org.apache.metron.rest.MetronRestConstants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -25,16 +26,13 @@ @Configuration public class HadoopConfig { - public static final String HDFS_URL_SPRING_PROPERTY = "hdfs.namenode.url"; - public static final String DEFAULT_HDFS_URL = "file:///"; - @Autowired private Environment environment; @Bean public org.apache.hadoop.conf.Configuration configuration() { org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration(); - configuration.set("fs.defaultFS", environment.getProperty(HDFS_URL_SPRING_PROPERTY, DEFAULT_HDFS_URL)); + configuration.set("fs.defaultFS", environment.getProperty(MetronRestConstants.HDFS_URL_SPRING_PROPERTY, MetronRestConstants.DEFAULT_HDFS_URL)); return configuration; } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java index 48696a18d4..8044405a97 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java @@ -20,6 +20,7 @@ import kafka.utils.ZkUtils; import org.I0Itec.zkclient.ZkClient; import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.metron.rest.MetronRestConstants; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -28,12 +29,12 @@ import java.util.Properties; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; + @Configuration -@Profile("!test") +@Profile("!" + TEST_PROFILE) public class KafkaConfig { - public static final String KAFKA_BROKER_URL_SPRING_PROPERTY = "kafka.broker.url"; - @Autowired private Environment environment; @@ -48,7 +49,7 @@ public ZkUtils zkUtils() { @Bean(destroyMethod="close") public KafkaConsumer kafkaConsumer() { Properties props = new Properties(); - props.put("bootstrap.servers", environment.getProperty(KAFKA_BROKER_URL_SPRING_PROPERTY)); + props.put("bootstrap.servers", environment.getProperty(MetronRestConstants.KAFKA_BROKER_URL_SPRING_PROPERTY)); props.put("group.id", "metron-config"); props.put("enable.auto.commit", "false"); props.put("auto.commit.interval.ms", "1000"); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/RestTemplateConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/RestTemplateConfig.java index 923c83bd1c..8fea90cf28 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/RestTemplateConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/RestTemplateConfig.java @@ -22,8 +22,10 @@ import org.springframework.context.annotation.Profile; import org.springframework.web.client.RestTemplate; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; + @Configuration -@Profile("!test") +@Profile("!" + TEST_PROFILE) public class RestTemplateConfig { @Bean diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java index 066b70c342..d6d0cff35d 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java @@ -17,8 +17,8 @@ */ package org.apache.metron.rest.config; -import org.apache.metron.rest.service.DockerStormCLIWrapper; -import org.apache.metron.rest.service.StormCLIWrapper; +import org.apache.metron.rest.service.impl.DockerStormCLIWrapper; +import org.apache.metron.rest.service.impl.StormCLIWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -27,8 +27,11 @@ import java.util.Arrays; +import static org.apache.metron.rest.MetronRestConstants.DOCKER_PROFILE; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; + @Configuration -@Profile("!test") +@Profile("!" + TEST_PROFILE) public class StormConfig { @Autowired @@ -36,7 +39,7 @@ public class StormConfig { @Bean public StormCLIWrapper stormCLIClientWrapper() { - if (Arrays.asList(environment.getActiveProfiles()).contains("docker")) { + if (Arrays.asList(environment.getActiveProfiles()).contains(DOCKER_PROFILE)) { return new DockerStormCLIWrapper(); } else { return new StormCLIWrapper(); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java index 6be85889d3..5f58193210 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/ZookeeperConfig.java @@ -23,33 +23,30 @@ import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.ExponentialBackoffRetry; +import org.apache.metron.rest.MetronRestConstants; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.core.env.Environment; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; + @Configuration -@Profile("!test") +@Profile("!" + TEST_PROFILE) public class ZookeeperConfig { - public static final String ZK_URL_SPRING_PROPERTY = "zookeeper.url"; - public static final String ZK_CLIENT_SESSION_TIMEOUT = "zookeeper.client.timeout.session"; - public static final String ZK_CLIENT_CONNECTION_TIMEOUT = "zookeeper.client.timeout.connection"; - public static final String CURATOR_SLEEP_TIME = "curator.sleep.time"; - public static final String CURATOR_MAX_RETRIES = "curator.max.retries"; - @Bean(initMethod = "start", destroyMethod="close") public CuratorFramework client(Environment environment) { - int sleepTime = Integer.parseInt(environment.getProperty(CURATOR_SLEEP_TIME)); - int maxRetries = Integer.parseInt(environment.getProperty(CURATOR_MAX_RETRIES)); + int sleepTime = Integer.parseInt(environment.getProperty(MetronRestConstants.CURATOR_SLEEP_TIME)); + int maxRetries = Integer.parseInt(environment.getProperty(MetronRestConstants.CURATOR_MAX_RETRIES)); RetryPolicy retryPolicy = new ExponentialBackoffRetry(sleepTime, maxRetries); - return CuratorFrameworkFactory.newClient(environment.getProperty(ZK_URL_SPRING_PROPERTY), retryPolicy); + return CuratorFrameworkFactory.newClient(environment.getProperty(MetronRestConstants.ZK_URL_SPRING_PROPERTY), retryPolicy); } @Bean(destroyMethod="close") public ZkClient zkClient(Environment environment) { - int sessionTimeout = Integer.parseInt(environment.getProperty(ZK_CLIENT_SESSION_TIMEOUT)); - int connectionTimeout = Integer.parseInt(environment.getProperty(ZK_CLIENT_CONNECTION_TIMEOUT)); - return new ZkClient(environment.getProperty(ZK_URL_SPRING_PROPERTY), sessionTimeout, connectionTimeout, ZKStringSerializer$.MODULE$); + int sessionTimeout = Integer.parseInt(environment.getProperty(MetronRestConstants.ZK_CLIENT_SESSION_TIMEOUT)); + int connectionTimeout = Integer.parseInt(environment.getProperty(MetronRestConstants.ZK_CLIENT_CONNECTION_TIMEOUT)); + return new ZkClient(environment.getProperty(MetronRestConstants.ZK_URL_SPRING_PROPERTY), sessionTimeout, connectionTimeout, ZKStringSerializer$.MODULE$); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java index f6a904c212..915e304b53 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StormController.java @@ -21,10 +21,12 @@ import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponses; +import org.apache.metron.rest.MetronRestConstants; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.TopologyResponse; import org.apache.metron.rest.model.TopologyStatus; -import org.apache.metron.rest.service.StormService; +import org.apache.metron.rest.service.StormAdminService; +import org.apache.metron.rest.service.StormStatusService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -42,13 +44,16 @@ public class StormController { @Autowired - private StormService stormService; + private StormStatusService stormStatusService; + + @Autowired + private StormAdminService stormAdminService; @ApiOperation(value = "Retrieves the status of all Storm topologies") @ApiResponse(message = "Returns a list of topologies with status information", code = 200) @RequestMapping(method = RequestMethod.GET) ResponseEntity> getAll() throws RestException { - return new ResponseEntity<>(stormService.getAllTopologyStatus(), HttpStatus.OK); + return new ResponseEntity<>(stormStatusService.getAllTopologyStatus(), HttpStatus.OK); } @ApiOperation(value = "Retrieves the status of a Storm topology") @@ -56,7 +61,7 @@ ResponseEntity> getAll() throws RestException { @ApiResponse(message = "Topology is missing", code = 404) }) @RequestMapping(value = "/{name}", method = RequestMethod.GET) ResponseEntity get(@ApiParam(name="name", value="Topology name", required=true)@PathVariable String name) throws RestException { - TopologyStatus topologyStatus = stormService.getTopologyStatus(name); + TopologyStatus topologyStatus = stormStatusService.getTopologyStatus(name); if (topologyStatus != null) { return new ResponseEntity<>(topologyStatus, HttpStatus.OK); } else { @@ -68,7 +73,7 @@ ResponseEntity get(@ApiParam(name="name", value="Topology name", @ApiResponse(message = "Returns start response message", code = 200) @RequestMapping(value = "/parser/start/{name}", method = RequestMethod.GET) ResponseEntity start(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws RestException { - return new ResponseEntity<>(stormService.startParserTopology(name), HttpStatus.OK); + return new ResponseEntity<>(stormAdminService.startParserTopology(name), HttpStatus.OK); } @ApiOperation(value = "Stops a Storm parser topology") @@ -76,21 +81,21 @@ ResponseEntity start(@ApiParam(name="name", value="Parser name @RequestMapping(value = "/parser/stop/{name}", method = RequestMethod.GET) ResponseEntity stop(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name, @ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws RestException { - return new ResponseEntity<>(stormService.stopParserTopology(name, stopNow), HttpStatus.OK); + return new ResponseEntity<>(stormAdminService.stopParserTopology(name, stopNow), HttpStatus.OK); } @ApiOperation(value = "Activates a Storm parser topology") @ApiResponse(message = "Returns activate response message", code = 200) @RequestMapping(value = "/parser/activate/{name}", method = RequestMethod.GET) ResponseEntity activate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws RestException { - return new ResponseEntity<>(stormService.activateTopology(name), HttpStatus.OK); + return new ResponseEntity<>(stormStatusService.activateTopology(name), HttpStatus.OK); } @ApiOperation(value = "Deactivates a Storm parser topology") @ApiResponse(message = "Returns deactivate response message", code = 200) @RequestMapping(value = "/parser/deactivate/{name}", method = RequestMethod.GET) ResponseEntity deactivate(@ApiParam(name="name", value="Parser name", required=true)@PathVariable String name) throws RestException { - return new ResponseEntity<>(stormService.deactivateTopology(name), HttpStatus.OK); + return new ResponseEntity<>(stormStatusService.deactivateTopology(name), HttpStatus.OK); } @ApiOperation(value = "Retrieves the status of the Storm enrichment topology") @@ -98,7 +103,7 @@ ResponseEntity deactivate(@ApiParam(name="name", value="Parser @ApiResponse(message = "Topology is missing", code = 404) }) @RequestMapping(value = "/enrichment", method = RequestMethod.GET) ResponseEntity getEnrichment() throws RestException { - TopologyStatus sensorParserStatus = stormService.getTopologyStatus(StormService.ENRICHMENT_TOPOLOGY_NAME); + TopologyStatus sensorParserStatus = stormStatusService.getTopologyStatus(MetronRestConstants.ENRICHMENT_TOPOLOGY_NAME); if (sensorParserStatus != null) { return new ResponseEntity<>(sensorParserStatus, HttpStatus.OK); } else { @@ -110,28 +115,28 @@ ResponseEntity getEnrichment() throws RestException { @ApiResponse(message = "Returns start response message", code = 200) @RequestMapping(value = "/enrichment/start", method = RequestMethod.GET) ResponseEntity startEnrichment() throws RestException { - return new ResponseEntity<>(stormService.startEnrichmentTopology(), HttpStatus.OK); + return new ResponseEntity<>(stormAdminService.startEnrichmentTopology(), HttpStatus.OK); } @ApiOperation(value = "Stops a Storm enrichment topology") @ApiResponse(message = "Returns stop response message", code = 200) @RequestMapping(value = "/enrichment/stop", method = RequestMethod.GET) ResponseEntity stopEnrichment(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws RestException { - return new ResponseEntity<>(stormService.stopEnrichmentTopology(stopNow), HttpStatus.OK); + return new ResponseEntity<>(stormAdminService.stopEnrichmentTopology(stopNow), HttpStatus.OK); } @ApiOperation(value = "Activates a Storm enrichment topology") @ApiResponse(message = "Returns activate response message", code = 200) @RequestMapping(value = "/enrichment/activate", method = RequestMethod.GET) ResponseEntity activateEnrichment() throws RestException { - return new ResponseEntity<>(stormService.activateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); + return new ResponseEntity<>(stormStatusService.activateTopology(MetronRestConstants.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Deactivates a Storm enrichment topology") @ApiResponse(message = "Returns deactivate response message", code = 200) @RequestMapping(value = "/enrichment/deactivate", method = RequestMethod.GET) ResponseEntity deactivateEnrichment() throws RestException { - return new ResponseEntity<>(stormService.deactivateTopology(StormService.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); + return new ResponseEntity<>(stormStatusService.deactivateTopology(MetronRestConstants.ENRICHMENT_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Retrieves the status of the Storm indexing topology") @@ -139,7 +144,7 @@ ResponseEntity deactivateEnrichment() throws RestException { @ApiResponse(message = "Topology is missing", code = 404) }) @RequestMapping(value = "/indexing", method = RequestMethod.GET) ResponseEntity getIndexing() throws RestException { - TopologyStatus topologyStatus = stormService.getTopologyStatus(StormService.INDEXING_TOPOLOGY_NAME); + TopologyStatus topologyStatus = stormStatusService.getTopologyStatus(MetronRestConstants.INDEXING_TOPOLOGY_NAME); if (topologyStatus != null) { return new ResponseEntity<>(topologyStatus, HttpStatus.OK); } else { @@ -151,35 +156,35 @@ ResponseEntity getIndexing() throws RestException { @ApiResponse(message = "Returns start response message", code = 200) @RequestMapping(value = "/indexing/start", method = RequestMethod.GET) ResponseEntity startIndexing() throws RestException { - return new ResponseEntity<>(stormService.startIndexingTopology(), HttpStatus.OK); + return new ResponseEntity<>(stormAdminService.startIndexingTopology(), HttpStatus.OK); } @ApiOperation(value = "Stops a Storm enrichment topology") @ApiResponse(message = "Returns stop response message", code = 200) @RequestMapping(value = "/indexing/stop", method = RequestMethod.GET) ResponseEntity stopIndexing(@ApiParam(name="stopNow", value="Stop the topology immediately")@RequestParam(required = false, defaultValue = "false") boolean stopNow) throws RestException { - return new ResponseEntity<>(stormService.stopIndexingTopology(stopNow), HttpStatus.OK); + return new ResponseEntity<>(stormAdminService.stopIndexingTopology(stopNow), HttpStatus.OK); } @ApiOperation(value = "Activates a Storm indexing topology") @ApiResponse(message = "Returns activate response message", code = 200) @RequestMapping(value = "/indexing/activate", method = RequestMethod.GET) ResponseEntity activateIndexing() throws RestException { - return new ResponseEntity<>(stormService.activateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); + return new ResponseEntity<>(stormStatusService.activateTopology(MetronRestConstants.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Deactivates a Storm indexing topology") @ApiResponse(message = "Returns deactivate response message", code = 200) @RequestMapping(value = "/indexing/deactivate", method = RequestMethod.GET) ResponseEntity deactivateIndexing() throws RestException { - return new ResponseEntity<>(stormService.deactivateTopology(StormService.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); + return new ResponseEntity<>(stormStatusService.deactivateTopology(MetronRestConstants.INDEXING_TOPOLOGY_NAME), HttpStatus.OK); } @ApiOperation(value = "Retrieves information about the Storm command line client") @ApiResponse(message = "Returns storm command line client information", code = 200) @RequestMapping(value = "/client/status", method = RequestMethod.GET) ResponseEntity> clientStatus() throws RestException { - return new ResponseEntity<>(stormService.getStormClientStatus(), HttpStatus.OK); + return new ResponseEntity<>(stormAdminService.getStormClientStatus(), HttpStatus.OK); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java index 39a48b5115..9d1237b1db 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java @@ -17,55 +17,17 @@ */ package org.apache.metron.rest.service; -import com.fasterxml.jackson.core.type.TypeReference; -import org.apache.curator.framework.CuratorFramework; -import org.apache.metron.common.configuration.ConfigurationType; -import org.apache.metron.common.configuration.ConfigurationsUtils; -import org.apache.metron.common.utils.JSONUtils; import org.apache.metron.rest.RestException; -import org.apache.zookeeper.KeeperException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.io.ByteArrayInputStream; import java.util.Map; @Service -public class GlobalConfigService { +public interface GlobalConfigService { - @Autowired - private CuratorFramework client; + Map save(Map globalConfig) throws RestException; - public Map save(Map globalConfig) throws RestException { - try { - ConfigurationsUtils.writeGlobalConfigToZookeeper(globalConfig, client); - } catch (Exception e) { - throw new RestException(e); - } - return globalConfig; - } + Map get() throws RestException; - public Map get() throws RestException { - Map globalConfig; - try { - byte[] globalConfigBytes = ConfigurationsUtils.readGlobalConfigBytesFromZookeeper(client); - globalConfig = JSONUtils.INSTANCE.load(new ByteArrayInputStream(globalConfigBytes), new TypeReference>(){}); - } catch (KeeperException.NoNodeException e) { - return null; - } catch (Exception e) { - throw new RestException(e); - } - return globalConfig; - } - - public boolean delete() throws RestException { - try { - client.delete().forPath(ConfigurationType.GLOBAL.getZookeeperRoot()); - } catch (KeeperException.NoNodeException e) { - return false; - } catch (Exception e) { - throw new RestException(e); - } - return true; - } + boolean delete() throws RestException; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java index d622ef014f..b277844050 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java @@ -17,148 +17,17 @@ */ package org.apache.metron.rest.service; -import oi.thekraken.grok.api.Grok; -import oi.thekraken.grok.api.Match; -import org.apache.hadoop.fs.Path; -import org.apache.metron.common.configuration.SensorParserConfig; -import org.apache.metron.parsers.GrokParser; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.GrokValidation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.StringReader; import java.util.Map; @Service -public class GrokService { +public interface GrokService { - public static final String GROK_DEFAULT_PATH_SPRING_PROPERTY = "grok.path.default"; - public static final String GROK_TEMP_PATH_SPRING_PROPERTY = "grok.path.temp"; - public static final String GROK_CLASS_NAME = GrokParser.class.getName(); - public static final String GROK_PATH_KEY = "grokPath"; - public static final String GROK_STATEMENT_KEY = "grokStatement"; - public static final String GROK_PATTERN_LABEL_KEY = "patternLabel"; - - @Autowired - private Environment environment; - - @Autowired - private Grok commonGrok; - - @Autowired - private HdfsService hdfsService; - - public Map getCommonGrokPatterns() { - return commonGrok.getPatterns(); - } - - public GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException { - Map results; - try { - Grok grok = new Grok(); - grok.addPatternFromReader(new InputStreamReader(getClass().getResourceAsStream("/patterns/common"))); - grok.addPatternFromReader(new StringReader(grokValidation.getStatement())); - String patternLabel = grokValidation.getStatement().substring(0, grokValidation.getStatement().indexOf(" ")); - String grokPattern = "%{" + patternLabel + "}"; - grok.compile(grokPattern); - Match gm = grok.match(grokValidation.getSampleData()); - gm.captures(); - results = gm.toMap(); - results.remove(patternLabel); - } catch (StringIndexOutOfBoundsException e) { - throw new RestException("A pattern label must be included (ex. PATTERN_LABEL ${PATTERN:field} ...)", e.getCause()); - } catch (Exception e) { - throw new RestException(e); - } - grokValidation.setResults(results); - return grokValidation; - } - - public boolean isGrokConfig(SensorParserConfig sensorParserConfig) { - return GROK_CLASS_NAME.equals(sensorParserConfig.getParserClassName()); - } - - public void addGrokStatementToConfig(SensorParserConfig sensorParserConfig) throws RestException { - String grokStatement = ""; - String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); - if (grokPath != null) { - String fullGrokStatement = getGrokStatement(grokPath); - String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); - grokStatement = fullGrokStatement.replaceFirst(patternLabel + " ", ""); - } - sensorParserConfig.getParserConfig().put(GROK_STATEMENT_KEY, grokStatement); - } - - public void addGrokPathToConfig(SensorParserConfig sensorParserConfig) { - if (sensorParserConfig.getParserConfig().get(GROK_PATH_KEY) == null) { - String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); - if (grokStatement != null) { - sensorParserConfig.getParserConfig().put(GROK_PATH_KEY, - new Path(environment.getProperty(GROK_DEFAULT_PATH_SPRING_PROPERTY), sensorParserConfig.getSensorTopic()).toString()); - } - } - } - - public String getGrokStatement(String path) throws RestException { - try { - return new String(hdfsService.read(new Path(path))); - } catch (IOException e) { - throw new RestException(e); - } - } - - public void saveGrokStatement(SensorParserConfig sensorParserConfig) throws RestException { - saveGrokStatement(sensorParserConfig, false); - } - - public void saveTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws RestException { - saveGrokStatement(sensorParserConfig, true); - } - - private void saveGrokStatement(SensorParserConfig sensorParserConfig, boolean isTemporary) throws RestException { - String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); - String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); - String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); - if (grokStatement != null) { - String fullGrokStatement = patternLabel + " " + grokStatement; - try { - if (!isTemporary) { - hdfsService.write(new Path(grokPath), fullGrokStatement.getBytes()); - } else { - File grokDirectory = new File(getTemporaryGrokRootPath()); - if (!grokDirectory.exists()) { - grokDirectory.mkdirs(); - } - FileWriter fileWriter = new FileWriter(new File(grokDirectory, sensorParserConfig.getSensorTopic())); - fileWriter.write(fullGrokStatement); - fileWriter.close(); - } - } catch (IOException e) { - throw new RestException(e); - } - } else { - throw new RestException("A grokStatement must be provided"); - } - } - - public void deleteTemporaryGrokStatement(SensorParserConfig sensorParserConfig) { - File file = new File(getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()); - file.delete(); - } - - public String getTemporaryGrokRootPath() { - String grokTempPath = environment.getProperty(GROK_TEMP_PATH_SPRING_PROPERTY); - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - return new Path(grokTempPath, authentication.getName()).toString(); - } + Map getCommonGrokPatterns(); + GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java index 298bb2b2bf..3c7648a5e5 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java @@ -17,41 +17,20 @@ */ package org.apache.metron.rest.service; -import org.apache.hadoop.conf.Configuration; -import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileStatus; -import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; -import org.apache.hadoop.io.IOUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.io.ByteArrayOutputStream; import java.io.IOException; @Service -public class HdfsService { +public interface HdfsService { - @Autowired - private Configuration configuration; + byte[] read(Path path) throws IOException; - public byte[] read(Path path) throws IOException { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - IOUtils.copyBytes(FileSystem.get(configuration).open(path), byteArrayOutputStream, configuration); - return byteArrayOutputStream.toByteArray(); - } + void write(Path path, byte[] contents) throws IOException; - public void write(Path path, byte[] contents) throws IOException { - FSDataOutputStream fsDataOutputStream = FileSystem.get(configuration).create(path, true); - fsDataOutputStream.write(contents); - fsDataOutputStream.close(); - } + FileStatus[] list(Path path) throws IOException; - public FileStatus[] list(Path path) throws IOException { - return FileSystem.get(configuration).listStatus(path); - } - - public boolean delete(Path path, boolean recursive) throws IOException { - return FileSystem.get(configuration).delete(path, recursive); - } + boolean delete(Path path, boolean recursive) throws IOException; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java index f283fe2e02..e1d55745ef 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java @@ -17,102 +17,23 @@ */ package org.apache.metron.rest.service; -import kafka.admin.AdminOperationException; -import kafka.admin.AdminUtils; -import kafka.admin.RackAwareMode; -import kafka.utils.ZkUtils; -import org.apache.kafka.clients.consumer.ConsumerRecord; -import org.apache.kafka.clients.consumer.ConsumerRecords; -import org.apache.kafka.clients.consumer.KafkaConsumer; -import org.apache.kafka.common.PartitionInfo; -import org.apache.kafka.common.TopicPartition; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.KafkaTopic; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Iterator; -import java.util.List; import java.util.Set; -import java.util.stream.Collectors; @Service -public class KafkaService { +public interface KafkaService { - @Autowired - private ZkUtils zkUtils; + KafkaTopic createTopic(KafkaTopic topic) throws RestException; - @Autowired - private KafkaConsumer kafkaConsumer; + boolean deleteTopic(String name); - private String offsetTopic = "__consumer_offsets"; + KafkaTopic getTopic(String name); - public KafkaTopic createTopic(KafkaTopic topic) throws RestException { - if (!listTopics().contains(topic.getName())) { - try { - AdminUtils.createTopic(zkUtils, topic.getName(), topic.getNumPartitions(), topic.getReplicationFactor(), topic.getProperties(), RackAwareMode.Disabled$.MODULE$); - } catch (AdminOperationException e) { - throw new RestException(e); - } - } - return topic; - } + Set listTopics(); - public boolean deleteTopic(String name) { - if (listTopics().contains(name)) { - AdminUtils.deleteTopic(zkUtils, name); - return true; - } else { - return false; - } - } - - public KafkaTopic getTopic(String name) { - KafkaTopic kafkaTopic = null; - if (listTopics().contains(name)) { - List partitionInfos = kafkaConsumer.partitionsFor(name); - if (partitionInfos.size() > 0) { - PartitionInfo partitionInfo = partitionInfos.get(0); - kafkaTopic = new KafkaTopic(); - kafkaTopic.setName(name); - kafkaTopic.setNumPartitions(partitionInfos.size()); - kafkaTopic.setReplicationFactor(partitionInfo.replicas().length); - } - } - return kafkaTopic; - } - - public Set listTopics() { - Set topics; - synchronized (this) { - topics = kafkaConsumer.listTopics().keySet(); - topics.remove(offsetTopic); - } - return topics; - } - - public String getSampleMessage(String topic) { - String message = null; - if (listTopics().contains(topic)) { - synchronized (this) { - kafkaConsumer.assign(kafkaConsumer.partitionsFor(topic).stream().map(partitionInfo -> - new TopicPartition(topic, partitionInfo.partition())).collect(Collectors.toList())); - for (TopicPartition topicPartition : kafkaConsumer.assignment()) { - long offset = kafkaConsumer.position(topicPartition) - 1; - if (offset >= 0) { - kafkaConsumer.seek(topicPartition, offset); - } - } - ConsumerRecords records = kafkaConsumer.poll(100); - Iterator> iterator = records.iterator(); - if (iterator.hasNext()) { - ConsumerRecord record = iterator.next(); - message = record.value(); - } - kafkaConsumer.unsubscribe(); - } - } - return message; - } + String getSampleMessage(String topic); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java index b2e1dc7681..184d5e460f 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java @@ -17,89 +17,26 @@ */ package org.apache.metron.rest.service; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.curator.framework.CuratorFramework; -import org.apache.metron.common.configuration.ConfigurationType; -import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; import org.apache.metron.rest.RestException; -import org.apache.zookeeper.KeeperException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @Service -public class SensorEnrichmentConfigService { +public interface SensorEnrichmentConfigService { - @Autowired - private ObjectMapper objectMapper; + SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException; - @Autowired - private CuratorFramework client; + SensorEnrichmentConfig findOne(String name) throws RestException; - public SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException { - try { - ConfigurationsUtils.writeSensorEnrichmentConfigToZookeeper(name, objectMapper.writeValueAsString(sensorEnrichmentConfig).getBytes(), client); - } catch (Exception e) { - throw new RestException(e); - } - return sensorEnrichmentConfig; - } + Map getAll() throws RestException; - public SensorEnrichmentConfig findOne(String name) throws RestException { - SensorEnrichmentConfig sensorEnrichmentConfig; - try { - sensorEnrichmentConfig = ConfigurationsUtils.readSensorEnrichmentConfigFromZookeeper(name, client); - } catch (KeeperException.NoNodeException e) { - return null; - } catch (Exception e) { - throw new RestException(e); - } - return sensorEnrichmentConfig; - } + List getAllTypes() throws RestException; - public Map getAll() throws RestException { - Map sensorEnrichmentConfigs = new HashMap<>(); - List sensorNames = getAllTypes(); - for (String name : sensorNames) { - sensorEnrichmentConfigs.put(name, findOne(name)); - } - return sensorEnrichmentConfigs; - } + boolean delete(String name) throws RestException; - public List getAllTypes() throws RestException { - List types; - try { - types = client.getChildren().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot()); - } catch (KeeperException.NoNodeException e) { - types = new ArrayList<>(); - } catch (Exception e) { - throw new RestException(e); - } - return types; - } - - public boolean delete(String name) throws RestException { - try { - client.delete().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/" + name); - } catch (KeeperException.NoNodeException e) { - return false; - } catch (Exception e) { - throw new RestException(e); - } - return true; - } - - public List getAvailableEnrichments() { - return new ArrayList() {{ - add("geo"); - add("host"); - add("whois"); - }}; - } + List getAvailableEnrichments(); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java index 76df174084..084c1dd3ff 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java @@ -17,84 +17,23 @@ */ package org.apache.metron.rest.service; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.curator.framework.CuratorFramework; -import org.apache.metron.common.configuration.ConfigurationType; -import org.apache.metron.common.configuration.ConfigurationsUtils; -import org.apache.metron.common.utils.JSONUtils; import org.apache.metron.rest.RestException; -import org.apache.zookeeper.KeeperException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.io.ByteArrayInputStream; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; @Service -public class SensorIndexingConfigService { +public interface SensorIndexingConfigService { - @Autowired - private ObjectMapper objectMapper; + Map save(String name, Map sensorIndexingConfig) throws RestException; - @Autowired - private CuratorFramework client; + Map findOne(String name) throws RestException; - public Map save(String name, Map sensorIndexingConfig) throws RestException { - try { - ConfigurationsUtils.writeSensorIndexingConfigToZookeeper(name, objectMapper.writeValueAsString(sensorIndexingConfig).getBytes(), client); - } catch (Exception e) { - throw new RestException(e); - } - return sensorIndexingConfig; - } + Map> getAll() throws RestException; - public Map findOne(String name) throws RestException { - Map sensorIndexingConfig; - try { - byte[] sensorIndexingConfigBytes = ConfigurationsUtils.readSensorIndexingConfigBytesFromZookeeper(name, client); - sensorIndexingConfig = JSONUtils.INSTANCE.load(new ByteArrayInputStream(sensorIndexingConfigBytes), new TypeReference>(){}); - } catch (KeeperException.NoNodeException e) { - return null; - } catch (Exception e) { - throw new RestException(e); - } - return sensorIndexingConfig; - } + List getAllTypes() throws RestException; - public Map> getAll() throws RestException { - Map> sensorIndexingConfigs = new HashMap<>(); - List sensorNames = getAllTypes(); - for (String name : sensorNames) { - sensorIndexingConfigs.put(name, findOne(name)); - } - return sensorIndexingConfigs; - } - - public List getAllTypes() throws RestException { - List types; - try { - types = client.getChildren().forPath(ConfigurationType.INDEXING.getZookeeperRoot()); - } catch (KeeperException.NoNodeException e) { - types = new ArrayList<>(); - } catch (Exception e) { - throw new RestException(e); - } - return types; - } - - public boolean delete(String name) throws RestException { - try { - client.delete().forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/" + name); - } catch (KeeperException.NoNodeException e) { - return false; - } catch (Exception e) { - throw new RestException(e); - } - return true; - } + boolean delete(String name) throws RestException; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java index 62fd1202a1..27653fb645 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -17,169 +17,28 @@ */ package org.apache.metron.rest.service; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.curator.framework.CuratorFramework; -import org.apache.metron.common.configuration.ConfigurationType; -import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.configuration.SensorParserConfig; -import org.apache.metron.parsers.interfaces.MessageParser; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.ParseMessageRequest; -import org.apache.zookeeper.KeeperException; import org.json.simple.JSONObject; -import org.reflections.Reflections; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; import java.util.Map; -import java.util.Set; @Service -public class SensorParserConfigService { +public interface SensorParserConfigService { - @Autowired - private ObjectMapper objectMapper; + SensorParserConfig save(SensorParserConfig sensorParserConfig) throws RestException; - private CuratorFramework client; + SensorParserConfig findOne(String name) throws RestException; - @Autowired - public void setClient(CuratorFramework client) { - this.client = client; - } + Iterable getAll() throws RestException; - @Autowired - private GrokService grokService; + boolean delete(String name) throws RestException; - private Map availableParsers; + Map getAvailableParsers(); - public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws RestException { - String serializedConfig; - if (grokService.isGrokConfig(sensorParserConfig)) { - grokService.addGrokPathToConfig(sensorParserConfig); - sensorParserConfig.getParserConfig().putIfAbsent(GrokService.GROK_PATTERN_LABEL_KEY, sensorParserConfig.getSensorTopic().toUpperCase()); - String statement = (String) sensorParserConfig.getParserConfig().remove(GrokService.GROK_STATEMENT_KEY); - serializedConfig = serialize(sensorParserConfig); - sensorParserConfig.getParserConfig().put(GrokService.GROK_STATEMENT_KEY, statement); - grokService.saveGrokStatement(sensorParserConfig); - } else { - serializedConfig = serialize(sensorParserConfig); - } - try { - ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), serializedConfig.getBytes(), client); - } catch (Exception e) { - throw new RestException(e); - } - return sensorParserConfig; - } + Map reloadAvailableParsers(); - private String serialize(SensorParserConfig sensorParserConfig) throws RestException { - String serializedConfig; - try { - serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); - } catch (JsonProcessingException e) { - throw new RestException("Could not serialize SensorParserConfig", "Could not serialize " + sensorParserConfig.toString(), e.getCause()); - } - return serializedConfig; - } - - public SensorParserConfig findOne(String name) throws RestException { - SensorParserConfig sensorParserConfig; - try { - sensorParserConfig = ConfigurationsUtils.readSensorParserConfigFromZookeeper(name, client); - if (grokService.isGrokConfig(sensorParserConfig)) { - grokService.addGrokStatementToConfig(sensorParserConfig); - } - } catch (KeeperException.NoNodeException e) { - return null; - } catch (Exception e) { - throw new RestException(e); - } - return sensorParserConfig; - } - - public Iterable getAll() throws RestException { - List sensorParserConfigs = new ArrayList<>(); - List sensorNames = getAllTypes(); - for (String name : sensorNames) { - sensorParserConfigs.add(findOne(name)); - } - return sensorParserConfigs; - } - - public boolean delete(String name) throws RestException { - try { - client.delete().forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/" + name); - } catch (KeeperException.NoNodeException e) { - return false; - } catch (Exception e) { - throw new RestException(e); - } - return true; - } - - public List getAllTypes() throws RestException { - List types; - try { - types = client.getChildren().forPath(ConfigurationType.PARSER.getZookeeperRoot()); - } catch (KeeperException.NoNodeException e) { - types = new ArrayList<>(); - } catch (Exception e) { - throw new RestException(e); - } - return types; - } - - public Map getAvailableParsers() { - if (availableParsers == null) { - availableParsers = new HashMap<>(); - Set> parserClasses = getParserClasses(); - parserClasses.forEach(parserClass -> { - if (!"BasicParser".equals(parserClass.getSimpleName())) { - availableParsers.put(parserClass.getSimpleName().replaceAll("Basic|Parser", ""), parserClass.getName()); - } - }); - } - return availableParsers; - } - - public Map reloadAvailableParsers() { - availableParsers = null; - return getAvailableParsers(); - } - - private Set> getParserClasses() { - Reflections reflections = new Reflections("org.apache.metron.parsers"); - return reflections.getSubTypesOf(MessageParser.class); - } - - public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws RestException { - SensorParserConfig sensorParserConfig = parseMessageRequest.getSensorParserConfig(); - if (sensorParserConfig == null) { - throw new RestException("SensorParserConfig is missing from ParseMessageRequest"); - } else if (sensorParserConfig.getParserClassName() == null) { - throw new RestException("SensorParserConfig must have a parserClassName"); - } else { - MessageParser parser = null; - try { - parser = (MessageParser) Class.forName(sensorParserConfig.getParserClassName()).newInstance(); - } catch (Exception e) { - throw new RestException(e.toString(), e.getCause()); - } - if (grokService.isGrokConfig(sensorParserConfig)) { - grokService.saveTemporaryGrokStatement(sensorParserConfig); - sensorParserConfig.getParserConfig().put(GrokService.GROK_PATH_KEY, new File(grokService.getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()).toString()); - } - parser.configure(sensorParserConfig.getParserConfig()); - JSONObject results = parser.parse(parseMessageRequest.getSampleData().getBytes()).get(0); - if (grokService.isGrokConfig(sensorParserConfig)) { - grokService.deleteTemporaryGrokStatement(sensorParserConfig); - } - return results; - } - } + JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws RestException; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormAdminService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormAdminService.java new file mode 100644 index 0000000000..c84a5747ee --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormAdminService.java @@ -0,0 +1,42 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.model.TopologyResponse; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public interface StormAdminService { + + TopologyResponse startParserTopology(String name) throws RestException; + + TopologyResponse stopParserTopology(String name, boolean stopNow) throws RestException; + + TopologyResponse startEnrichmentTopology() throws RestException; + + TopologyResponse stopEnrichmentTopology(boolean stopNow) throws RestException; + + TopologyResponse startIndexingTopology() throws RestException; + + TopologyResponse stopIndexingTopology(boolean stopNow) throws RestException; + + Map getStormClientStatus() throws RestException; +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java deleted file mode 100644 index 01c18099b0..0000000000 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormService.java +++ /dev/null @@ -1,183 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.rest.service; - -import org.apache.metron.rest.RestException; -import org.apache.metron.rest.model.TopologyResponse; -import org.apache.metron.rest.model.TopologyStatus; -import org.apache.metron.rest.model.TopologyStatusCode; -import org.apache.metron.rest.model.TopologySummary; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Service; -import org.springframework.web.client.RestTemplate; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -@Service -public class StormService { - - public static final String STORM_UI_SPRING_PROPERTY = "storm.ui.url"; - public static final String TOPOLOGY_SUMMARY_URL = "/api/v1/topology/summary"; - public static final String TOPOLOGY_URL = "/api/v1/topology"; - public static final String ENRICHMENT_TOPOLOGY_NAME = "enrichment"; - public static final String INDEXING_TOPOLOGY_NAME = "indexing"; - - @Autowired - private Environment environment; - - private RestTemplate restTemplate; - - @Autowired - public void setRestTemplate(RestTemplate restTemplate) { - this.restTemplate = restTemplate; - } - - private StormCLIWrapper stormCLIClientWrapper; - - @Autowired - public void setStormCLIClientWrapper(StormCLIWrapper stormCLIClientWrapper) { - this.stormCLIClientWrapper = stormCLIClientWrapper; - } - - @Autowired - private GlobalConfigService globalConfigService; - - @Autowired - private SensorParserConfigService sensorParserConfigService; - - public TopologySummary getTopologySummary() { - return restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_SUMMARY_URL, TopologySummary.class); - } - - public TopologyStatus getTopologyStatus(String name) { - TopologyStatus topologyResponse = null; - String id = null; - for (TopologyStatus topology : getTopologySummary().getTopologies()) { - if (name.equals(topology.getName())) { - id = topology.getId(); - break; - } - } - if (id != null) { - topologyResponse = restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + id, TopologyStatus.class); - } - return topologyResponse; - } - - public List getAllTopologyStatus() { - List topologyStatus = new ArrayList<>(); - for (TopologyStatus topology : getTopologySummary().getTopologies()) { - topologyStatus.add(restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + topology.getId(), TopologyStatus.class)); - } - return topologyStatus; - } - - public TopologyResponse activateTopology(String name) { - TopologyResponse topologyResponse = new TopologyResponse(); - String id = null; - for (TopologyStatus topology : getTopologySummary().getTopologies()) { - if (name.equals(topology.getName())) { - id = topology.getId(); - break; - } - } - if (id != null) { - Map result = restTemplate.postForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + id + "/activate", null, Map.class); - if("success".equals(result.get("status"))) { - topologyResponse.setSuccessMessage(TopologyStatusCode.ACTIVE.toString()); - } else { - topologyResponse.setErrorMessage((String) result.get("status")); - } - } else { - topologyResponse.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString()); - } - return topologyResponse; - } - - public TopologyResponse deactivateTopology(String name) { - TopologyResponse topologyResponse = new TopologyResponse(); - String id = null; - for (TopologyStatus topology : getTopologySummary().getTopologies()) { - if (name.equals(topology.getName())) { - id = topology.getId(); - break; - } - } - if (id != null) { - Map result = restTemplate.postForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + id + "/deactivate", null, Map.class); - if("success".equals(result.get("status"))) { - topologyResponse.setSuccessMessage(TopologyStatusCode.INACTIVE.toString()); - } else { - topologyResponse.setErrorMessage((String) result.get("status")); - } - } else { - topologyResponse.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString()); - } - return topologyResponse; - } - - public TopologyResponse startParserTopology(String name) throws RestException { - TopologyResponse topologyResponse = new TopologyResponse(); - if (globalConfigService.get() == null) { - topologyResponse.setErrorMessage(TopologyStatusCode.GLOBAL_CONFIG_MISSING.toString()); - } else if (sensorParserConfigService.findOne(name) == null) { - topologyResponse.setErrorMessage(TopologyStatusCode.SENSOR_PARSER_CONFIG_MISSING.toString()); - } else { - topologyResponse = createResponse(stormCLIClientWrapper.startParserTopology(name), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); - } - return topologyResponse; - } - - public TopologyResponse stopParserTopology(String name, boolean stopNow) throws RestException { - return createResponse(stormCLIClientWrapper.stopParserTopology(name, stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); - } - - public TopologyResponse startEnrichmentTopology() throws RestException { - return createResponse(stormCLIClientWrapper.startEnrichmentTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); - } - - public TopologyResponse stopEnrichmentTopology(boolean stopNow) throws RestException { - return createResponse(stormCLIClientWrapper.stopEnrichmentTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); - } - - public TopologyResponse startIndexingTopology() throws RestException { - return createResponse(stormCLIClientWrapper.startIndexingTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); - } - - public TopologyResponse stopIndexingTopology(boolean stopNow) throws RestException { - return createResponse(stormCLIClientWrapper.stopIndexingTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); - } - - protected TopologyResponse createResponse(int responseCode, TopologyStatusCode successMessage, TopologyStatusCode errorMessage) { - TopologyResponse topologyResponse = new TopologyResponse(); - if (responseCode == 0) { - topologyResponse.setSuccessMessage(successMessage.toString()); - } else { - topologyResponse.setErrorMessage(errorMessage.toString()); - } - return topologyResponse; - } - - public Map getStormClientStatus() throws RestException { - return stormCLIClientWrapper.getStormClientStatus(); - } - -} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormStatusService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormStatusService.java new file mode 100644 index 0000000000..6563a31ccd --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormStatusService.java @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service; + +import org.apache.metron.rest.model.TopologyResponse; +import org.apache.metron.rest.model.TopologyStatus; +import org.apache.metron.rest.model.TopologySummary; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public interface StormStatusService { + + TopologySummary getTopologySummary(); + + TopologyStatus getTopologyStatus(String name); + + List getAllTopologyStatus(); + + TopologyResponse activateTopology(String name); + + TopologyResponse deactivateTopology(String name); +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java index 1449988be7..499710d4e3 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java @@ -17,70 +17,25 @@ */ package org.apache.metron.rest.service; -import org.apache.metron.common.dsl.Context; -import org.apache.metron.common.dsl.ParseException; -import org.apache.metron.common.dsl.StellarFunctionInfo; -import org.apache.metron.common.dsl.functions.resolver.SingletonFunctionResolver; import org.apache.metron.common.field.transformation.FieldTransformations; -import org.apache.metron.common.stellar.StellarProcessor; import org.apache.metron.rest.model.StellarFunctionDescription; import org.apache.metron.rest.model.TransformationValidation; -import org.json.simple.JSONObject; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; @Service -public class TransformationService { +public interface TransformationService { - public Map validateRules(List rules) { - Map results = new HashMap<>(); - StellarProcessor stellarProcessor = new StellarProcessor(); - for(String rule: rules) { - try { - boolean result = stellarProcessor.validate(rule, Context.EMPTY_CONTEXT()); - results.put(rule, result); - } catch (ParseException e) { - results.put(rule, false); - } - } - return results; - } + Map validateRules(List rules); - public Map validateTransformation(TransformationValidation transformationValidation) { - JSONObject sampleJson = new JSONObject(transformationValidation.getSampleData()); - transformationValidation.getSensorParserConfig().getFieldTransformations().forEach(fieldTransformer -> { - fieldTransformer.transformAndUpdate(sampleJson, transformationValidation.getSensorParserConfig().getParserConfig(), Context.EMPTY_CONTEXT()); - } - ); - return sampleJson; - } + Map validateTransformation(TransformationValidation transformationValidation); - public FieldTransformations[] getTransformations() { - return FieldTransformations.values(); - } + FieldTransformations[] getTransformations(); - public List getStellarFunctions() { - List stellarFunctionDescriptions = new ArrayList<>(); - Iterable stellarFunctionsInfo = SingletonFunctionResolver.getInstance().getFunctionInfo(); - stellarFunctionsInfo.forEach(stellarFunctionInfo -> { - stellarFunctionDescriptions.add(new StellarFunctionDescription( - stellarFunctionInfo.getName(), - stellarFunctionInfo.getDescription(), - stellarFunctionInfo.getParams(), - stellarFunctionInfo.getReturns())); - }); - return stellarFunctionDescriptions; - } + List getStellarFunctions(); - public List getSimpleStellarFunctions() { - List stellarFunctionDescriptions = getStellarFunctions(); - return stellarFunctionDescriptions.stream().filter(stellarFunctionDescription -> - stellarFunctionDescription.getParams().length == 1).sorted((o1, o2) -> o1.getName().compareTo(o2.getName())).collect(Collectors.toList()); - } + List getSimpleStellarFunctions(); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/DockerStormCLIWrapper.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java similarity index 98% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/DockerStormCLIWrapper.java rename to metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java index 25be4bac2c..d7bbb230f9 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/DockerStormCLIWrapper.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.metron.rest.service; +package org.apache.metron.rest.service.impl; import org.apache.commons.lang3.ArrayUtils; import org.slf4j.Logger; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java new file mode 100644 index 0000000000..86f230615d --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java @@ -0,0 +1,72 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import com.fasterxml.jackson.core.type.TypeReference; +import org.apache.curator.framework.CuratorFramework; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.ConfigurationsUtils; +import org.apache.metron.common.utils.JSONUtils; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.GlobalConfigService; +import org.apache.zookeeper.KeeperException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.ByteArrayInputStream; +import java.util.Map; + +@Service +public class GlobalConfigServiceImpl implements GlobalConfigService { + + @Autowired + private CuratorFramework client; + + public Map save(Map globalConfig) throws RestException { + try { + ConfigurationsUtils.writeGlobalConfigToZookeeper(globalConfig, client); + } catch (Exception e) { + throw new RestException(e); + } + return globalConfig; + } + + public Map get() throws RestException { + Map globalConfig; + try { + byte[] globalConfigBytes = ConfigurationsUtils.readGlobalConfigBytesFromZookeeper(client); + globalConfig = JSONUtils.INSTANCE.load(new ByteArrayInputStream(globalConfigBytes), new TypeReference>(){}); + } catch (KeeperException.NoNodeException e) { + return null; + } catch (Exception e) { + throw new RestException(e); + } + return globalConfig; + } + + public boolean delete() throws RestException { + try { + client.delete().forPath(ConfigurationType.GLOBAL.getZookeeperRoot()); + } catch (KeeperException.NoNodeException e) { + return false; + } catch (Exception e) { + throw new RestException(e); + } + return true; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java new file mode 100644 index 0000000000..cb49dc18da --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java @@ -0,0 +1,64 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import oi.thekraken.grok.api.Grok; +import oi.thekraken.grok.api.Match; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.model.GrokValidation; +import org.apache.metron.rest.service.GrokService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.InputStreamReader; +import java.io.StringReader; +import java.util.Map; + +@Service +public class GrokServiceImpl implements GrokService { + + @Autowired + private Grok commonGrok; + + public Map getCommonGrokPatterns() { + return commonGrok.getPatterns(); + } + + public GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException { + Map results; + try { + Grok grok = new Grok(); + grok.addPatternFromReader(new InputStreamReader(getClass().getResourceAsStream("/patterns/common"))); + grok.addPatternFromReader(new StringReader(grokValidation.getStatement())); + String patternLabel = grokValidation.getStatement().substring(0, grokValidation.getStatement().indexOf(" ")); + String grokPattern = "%{" + patternLabel + "}"; + grok.compile(grokPattern); + Match gm = grok.match(grokValidation.getSampleData()); + gm.captures(); + results = gm.toMap(); + results.remove(patternLabel); + } catch (StringIndexOutOfBoundsException e) { + throw new RestException("A pattern label must be included (ex. PATTERN_LABEL ${PATTERN:field} ...)", e.getCause()); + } catch (Exception e) { + throw new RestException(e); + } + grokValidation.setResults(results); + return grokValidation; + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java new file mode 100644 index 0000000000..6ebf1a84d4 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.hadoop.io.IOUtils; +import org.apache.metron.rest.service.HdfsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +@Service +public class HdfsServiceImpl implements HdfsService { + + @Autowired + private Configuration configuration; + + public byte[] read(Path path) throws IOException { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + IOUtils.copyBytes(FileSystem.get(configuration).open(path), byteArrayOutputStream, configuration); + return byteArrayOutputStream.toByteArray(); + } + + public void write(Path path, byte[] contents) throws IOException { + FSDataOutputStream fsDataOutputStream = FileSystem.get(configuration).create(path, true); + fsDataOutputStream.write(contents); + fsDataOutputStream.close(); + } + + public FileStatus[] list(Path path) throws IOException { + return FileSystem.get(configuration).listStatus(path); + } + + public boolean delete(Path path, boolean recursive) throws IOException { + return FileSystem.get(configuration).delete(path, recursive); + } + } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java new file mode 100644 index 0000000000..7a2d28a7a0 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java @@ -0,0 +1,119 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import kafka.admin.AdminOperationException; +import kafka.admin.AdminUtils; +import kafka.admin.RackAwareMode; +import kafka.utils.ZkUtils; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.common.PartitionInfo; +import org.apache.kafka.common.TopicPartition; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.model.KafkaTopic; +import org.apache.metron.rest.service.KafkaService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@Service +public class KafkaServiceImpl implements KafkaService { + + @Autowired + private ZkUtils zkUtils; + + @Autowired + private KafkaConsumer kafkaConsumer; + + private String offsetTopic = "__consumer_offsets"; + + public KafkaTopic createTopic(KafkaTopic topic) throws RestException { + if (!listTopics().contains(topic.getName())) { + try { + AdminUtils.createTopic(zkUtils, topic.getName(), topic.getNumPartitions(), topic.getReplicationFactor(), topic.getProperties(), RackAwareMode.Disabled$.MODULE$); + } catch (AdminOperationException e) { + throw new RestException(e); + } + } + return topic; + } + + public boolean deleteTopic(String name) { + if (listTopics().contains(name)) { + AdminUtils.deleteTopic(zkUtils, name); + return true; + } else { + return false; + } + } + + public KafkaTopic getTopic(String name) { + KafkaTopic kafkaTopic = null; + if (listTopics().contains(name)) { + List partitionInfos = kafkaConsumer.partitionsFor(name); + if (partitionInfos.size() > 0) { + PartitionInfo partitionInfo = partitionInfos.get(0); + kafkaTopic = new KafkaTopic(); + kafkaTopic.setName(name); + kafkaTopic.setNumPartitions(partitionInfos.size()); + kafkaTopic.setReplicationFactor(partitionInfo.replicas().length); + } + } + return kafkaTopic; + } + + public Set listTopics() { + Set topics; + synchronized (this) { + topics = kafkaConsumer.listTopics().keySet(); + topics.remove(offsetTopic); + } + return topics; + } + + public String getSampleMessage(String topic) { + String message = null; + if (listTopics().contains(topic)) { + synchronized (this) { + kafkaConsumer.assign(kafkaConsumer.partitionsFor(topic).stream().map(partitionInfo -> + new TopicPartition(topic, partitionInfo.partition())).collect(Collectors.toList())); + for (TopicPartition topicPartition : kafkaConsumer.assignment()) { + long offset = kafkaConsumer.position(topicPartition) - 1; + if (offset >= 0) { + kafkaConsumer.seek(topicPartition, offset); + } + } + ConsumerRecords records = kafkaConsumer.poll(100); + Iterator> iterator = records.iterator(); + if (iterator.hasNext()) { + ConsumerRecord record = iterator.next(); + message = record.value(); + } + kafkaConsumer.unsubscribe(); + } + } + return message; + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java new file mode 100644 index 0000000000..20c82414d5 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java @@ -0,0 +1,106 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.curator.framework.CuratorFramework; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.ConfigurationsUtils; +import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.SensorEnrichmentConfigService; +import org.apache.zookeeper.KeeperException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class SensorEnrichmentConfigServiceImpl implements SensorEnrichmentConfigService { + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private CuratorFramework client; + + public SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException { + try { + ConfigurationsUtils.writeSensorEnrichmentConfigToZookeeper(name, objectMapper.writeValueAsString(sensorEnrichmentConfig).getBytes(), client); + } catch (Exception e) { + throw new RestException(e); + } + return sensorEnrichmentConfig; + } + + public SensorEnrichmentConfig findOne(String name) throws RestException { + SensorEnrichmentConfig sensorEnrichmentConfig; + try { + sensorEnrichmentConfig = ConfigurationsUtils.readSensorEnrichmentConfigFromZookeeper(name, client); + } catch (KeeperException.NoNodeException e) { + return null; + } catch (Exception e) { + throw new RestException(e); + } + return sensorEnrichmentConfig; + } + + public Map getAll() throws RestException { + Map sensorEnrichmentConfigs = new HashMap<>(); + List sensorNames = getAllTypes(); + for (String name : sensorNames) { + sensorEnrichmentConfigs.put(name, findOne(name)); + } + return sensorEnrichmentConfigs; + } + + public List getAllTypes() throws RestException { + List types; + try { + types = client.getChildren().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot()); + } catch (KeeperException.NoNodeException e) { + types = new ArrayList<>(); + } catch (Exception e) { + throw new RestException(e); + } + return types; + } + + public boolean delete(String name) throws RestException { + try { + client.delete().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/" + name); + } catch (KeeperException.NoNodeException e) { + return false; + } catch (Exception e) { + throw new RestException(e); + } + return true; + } + + public List getAvailableEnrichments() { + return new ArrayList() {{ + add("geo"); + add("host"); + add("whois"); + }}; + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java new file mode 100644 index 0000000000..e246682d73 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java @@ -0,0 +1,101 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.curator.framework.CuratorFramework; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.ConfigurationsUtils; +import org.apache.metron.common.utils.JSONUtils; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.SensorIndexingConfigService; +import org.apache.zookeeper.KeeperException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.ByteArrayInputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class SensorIndexingConfigServiceImpl implements SensorIndexingConfigService { + + @Autowired + private ObjectMapper objectMapper; + + @Autowired + private CuratorFramework client; + + public Map save(String name, Map sensorIndexingConfig) throws RestException { + try { + ConfigurationsUtils.writeSensorIndexingConfigToZookeeper(name, objectMapper.writeValueAsString(sensorIndexingConfig).getBytes(), client); + } catch (Exception e) { + throw new RestException(e); + } + return sensorIndexingConfig; + } + + public Map findOne(String name) throws RestException { + Map sensorIndexingConfig; + try { + byte[] sensorIndexingConfigBytes = ConfigurationsUtils.readSensorIndexingConfigBytesFromZookeeper(name, client); + sensorIndexingConfig = JSONUtils.INSTANCE.load(new ByteArrayInputStream(sensorIndexingConfigBytes), new TypeReference>(){}); + } catch (KeeperException.NoNodeException e) { + return null; + } catch (Exception e) { + throw new RestException(e); + } + return sensorIndexingConfig; + } + + public Map> getAll() throws RestException { + Map> sensorIndexingConfigs = new HashMap<>(); + List sensorNames = getAllTypes(); + for (String name : sensorNames) { + sensorIndexingConfigs.put(name, findOne(name)); + } + return sensorIndexingConfigs; + } + + public List getAllTypes() throws RestException { + List types; + try { + types = client.getChildren().forPath(ConfigurationType.INDEXING.getZookeeperRoot()); + } catch (KeeperException.NoNodeException e) { + types = new ArrayList<>(); + } catch (Exception e) { + throw new RestException(e); + } + return types; + } + + public boolean delete(String name) throws RestException { + try { + client.delete().forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/" + name); + } catch (KeeperException.NoNodeException e) { + return false; + } catch (Exception e) { + throw new RestException(e); + } + return true; + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java new file mode 100644 index 0000000000..800aa46f8e --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java @@ -0,0 +1,282 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.curator.framework.CuratorFramework; +import org.apache.hadoop.fs.Path; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.ConfigurationsUtils; +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.parsers.interfaces.MessageParser; +import org.apache.metron.rest.MetronRestConstants; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.model.ParseMessageRequest; +import org.apache.metron.rest.service.HdfsService; +import org.apache.metron.rest.service.SensorParserConfigService; +import org.apache.zookeeper.KeeperException; +import org.json.simple.JSONObject; +import org.reflections.Reflections; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.apache.metron.rest.MetronRestConstants.GROK_CLASS_NAME; +import static org.apache.metron.rest.MetronRestConstants.GROK_DEFAULT_PATH_SPRING_PROPERTY; +import static org.apache.metron.rest.MetronRestConstants.GROK_PATH_KEY; +import static org.apache.metron.rest.MetronRestConstants.GROK_PATTERN_LABEL_KEY; +import static org.apache.metron.rest.MetronRestConstants.GROK_STATEMENT_KEY; +import static org.apache.metron.rest.MetronRestConstants.GROK_TEMP_PATH_SPRING_PROPERTY; + +@Service +public class SensorParserConfigServiceImpl implements SensorParserConfigService { + + @Autowired + private Environment environment; + + @Autowired + private ObjectMapper objectMapper; + + private CuratorFramework client; + + @Autowired + public void setClient(CuratorFramework client) { + this.client = client; + } + + @Autowired + private HdfsService hdfsService; + + private Map availableParsers; + + public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws RestException { + String serializedConfig; + if (isGrokConfig(sensorParserConfig)) { + addGrokPathToConfig(sensorParserConfig); + sensorParserConfig.getParserConfig().putIfAbsent(MetronRestConstants.GROK_PATTERN_LABEL_KEY, sensorParserConfig.getSensorTopic().toUpperCase()); + String statement = (String) sensorParserConfig.getParserConfig().remove(MetronRestConstants.GROK_STATEMENT_KEY); + serializedConfig = serialize(sensorParserConfig); + sensorParserConfig.getParserConfig().put(MetronRestConstants.GROK_STATEMENT_KEY, statement); + saveGrokStatement(sensorParserConfig); + } else { + serializedConfig = serialize(sensorParserConfig); + } + try { + ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), serializedConfig.getBytes(), client); + } catch (Exception e) { + throw new RestException(e); + } + return sensorParserConfig; + } + + private String serialize(SensorParserConfig sensorParserConfig) throws RestException { + String serializedConfig; + try { + serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); + } catch (JsonProcessingException e) { + throw new RestException("Could not serialize SensorParserConfig", "Could not serialize " + sensorParserConfig.toString(), e.getCause()); + } + return serializedConfig; + } + + public SensorParserConfig findOne(String name) throws RestException { + SensorParserConfig sensorParserConfig; + try { + sensorParserConfig = ConfigurationsUtils.readSensorParserConfigFromZookeeper(name, client); + if (isGrokConfig(sensorParserConfig)) { + addGrokStatementToConfig(sensorParserConfig); + } + } catch (KeeperException.NoNodeException e) { + return null; + } catch (Exception e) { + throw new RestException(e); + } + return sensorParserConfig; + } + + public Iterable getAll() throws RestException { + List sensorParserConfigs = new ArrayList<>(); + List sensorNames = getAllTypes(); + for (String name : sensorNames) { + sensorParserConfigs.add(findOne(name)); + } + return sensorParserConfigs; + } + + public boolean delete(String name) throws RestException { + try { + client.delete().forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/" + name); + } catch (KeeperException.NoNodeException e) { + return false; + } catch (Exception e) { + throw new RestException(e); + } + return true; + } + + public List getAllTypes() throws RestException { + List types; + try { + types = client.getChildren().forPath(ConfigurationType.PARSER.getZookeeperRoot()); + } catch (KeeperException.NoNodeException e) { + types = new ArrayList<>(); + } catch (Exception e) { + throw new RestException(e); + } + return types; + } + + public Map getAvailableParsers() { + if (availableParsers == null) { + availableParsers = new HashMap<>(); + Set> parserClasses = getParserClasses(); + parserClasses.forEach(parserClass -> { + if (!"BasicParser".equals(parserClass.getSimpleName())) { + availableParsers.put(parserClass.getSimpleName().replaceAll("Basic|Parser", ""), parserClass.getName()); + } + }); + } + return availableParsers; + } + + public Map reloadAvailableParsers() { + availableParsers = null; + return getAvailableParsers(); + } + + private Set> getParserClasses() { + Reflections reflections = new Reflections("org.apache.metron.parsers"); + return reflections.getSubTypesOf(MessageParser.class); + } + + public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws RestException { + SensorParserConfig sensorParserConfig = parseMessageRequest.getSensorParserConfig(); + if (sensorParserConfig == null) { + throw new RestException("SensorParserConfig is missing from ParseMessageRequest"); + } else if (sensorParserConfig.getParserClassName() == null) { + throw new RestException("SensorParserConfig must have a parserClassName"); + } else { + MessageParser parser = null; + try { + parser = (MessageParser) Class.forName(sensorParserConfig.getParserClassName()).newInstance(); + } catch (Exception e) { + throw new RestException(e.toString(), e.getCause()); + } + if (isGrokConfig(sensorParserConfig)) { + saveTemporaryGrokStatement(sensorParserConfig); + sensorParserConfig.getParserConfig().put(MetronRestConstants.GROK_PATH_KEY, new File(getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()).toString()); + } + parser.configure(sensorParserConfig.getParserConfig()); + JSONObject results = parser.parse(parseMessageRequest.getSampleData().getBytes()).get(0); + if (isGrokConfig(sensorParserConfig)) { + deleteTemporaryGrokStatement(sensorParserConfig); + } + return results; + } + } + + private boolean isGrokConfig(SensorParserConfig sensorParserConfig) { + return GROK_CLASS_NAME.equals(sensorParserConfig.getParserClassName()); + } + + private void addGrokStatementToConfig(SensorParserConfig sensorParserConfig) throws RestException { + String grokStatement = ""; + String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); + if (grokPath != null) { + String fullGrokStatement = getGrokStatement(grokPath); + String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); + grokStatement = fullGrokStatement.replaceFirst(patternLabel + " ", ""); + } + sensorParserConfig.getParserConfig().put(GROK_STATEMENT_KEY, grokStatement); + } + + private void addGrokPathToConfig(SensorParserConfig sensorParserConfig) { + if (sensorParserConfig.getParserConfig().get(GROK_PATH_KEY) == null) { + String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); + if (grokStatement != null) { + sensorParserConfig.getParserConfig().put(GROK_PATH_KEY, + new Path(environment.getProperty(GROK_DEFAULT_PATH_SPRING_PROPERTY), sensorParserConfig.getSensorTopic()).toString()); + } + } + } + + private String getGrokStatement(String path) throws RestException { + try { + return new String(hdfsService.read(new Path(path))); + } catch (IOException e) { + throw new RestException(e); + } + } + + private void saveGrokStatement(SensorParserConfig sensorParserConfig) throws RestException { + saveGrokStatement(sensorParserConfig, false); + } + + private void saveTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws RestException { + saveGrokStatement(sensorParserConfig, true); + } + + private void saveGrokStatement(SensorParserConfig sensorParserConfig, boolean isTemporary) throws RestException { + String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); + String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); + String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); + if (grokStatement != null) { + String fullGrokStatement = patternLabel + " " + grokStatement; + try { + if (!isTemporary) { + hdfsService.write(new Path(grokPath), fullGrokStatement.getBytes()); + } else { + File grokDirectory = new File(getTemporaryGrokRootPath()); + if (!grokDirectory.exists()) { + grokDirectory.mkdirs(); + } + FileWriter fileWriter = new FileWriter(new File(grokDirectory, sensorParserConfig.getSensorTopic())); + fileWriter.write(fullGrokStatement); + fileWriter.close(); + } + } catch (IOException e) { + throw new RestException(e); + } + } else { + throw new RestException("A grokStatement must be provided"); + } + } + + private void deleteTemporaryGrokStatement(SensorParserConfig sensorParserConfig) { + File file = new File(getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()); + file.delete(); + } + + private String getTemporaryGrokRootPath() { + String grokTempPath = environment.getProperty(GROK_TEMP_PATH_SPRING_PROPERTY); + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + return new Path(grokTempPath, authentication.getName()).toString(); + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java new file mode 100644 index 0000000000..8ac6667203 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java @@ -0,0 +1,93 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.model.TopologyResponse; +import org.apache.metron.rest.model.TopologyStatusCode; +import org.apache.metron.rest.service.GlobalConfigService; +import org.apache.metron.rest.service.SensorParserConfigService; +import org.apache.metron.rest.service.StormAdminService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +public class StormAdminServiceImpl implements StormAdminService { + + private StormCLIWrapper stormCLIClientWrapper; + + @Autowired + public void setStormCLIClientWrapper(StormCLIWrapper stormCLIClientWrapper) { + this.stormCLIClientWrapper = stormCLIClientWrapper; + } + + @Autowired + private GlobalConfigService globalConfigService; + + @Autowired + private SensorParserConfigService sensorParserConfigService; + + public TopologyResponse startParserTopology(String name) throws RestException { + TopologyResponse topologyResponse = new TopologyResponse(); + if (globalConfigService.get() == null) { + topologyResponse.setErrorMessage(TopologyStatusCode.GLOBAL_CONFIG_MISSING.toString()); + } else if (sensorParserConfigService.findOne(name) == null) { + topologyResponse.setErrorMessage(TopologyStatusCode.SENSOR_PARSER_CONFIG_MISSING.toString()); + } else { + topologyResponse = createResponse(stormCLIClientWrapper.startParserTopology(name), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); + } + return topologyResponse; + } + + public TopologyResponse stopParserTopology(String name, boolean stopNow) throws RestException { + return createResponse(stormCLIClientWrapper.stopParserTopology(name, stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); + } + + public TopologyResponse startEnrichmentTopology() throws RestException { + return createResponse(stormCLIClientWrapper.startEnrichmentTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); + } + + public TopologyResponse stopEnrichmentTopology(boolean stopNow) throws RestException { + return createResponse(stormCLIClientWrapper.stopEnrichmentTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); + } + + public TopologyResponse startIndexingTopology() throws RestException { + return createResponse(stormCLIClientWrapper.startIndexingTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); + } + + public TopologyResponse stopIndexingTopology(boolean stopNow) throws RestException { + return createResponse(stormCLIClientWrapper.stopIndexingTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); + } + + private TopologyResponse createResponse(int responseCode, TopologyStatusCode successMessage, TopologyStatusCode errorMessage) { + TopologyResponse topologyResponse = new TopologyResponse(); + if (responseCode == 0) { + topologyResponse.setSuccessMessage(successMessage.toString()); + } else { + topologyResponse.setErrorMessage(errorMessage.toString()); + } + return topologyResponse; + } + + public Map getStormClientStatus() throws RestException { + return stormCLIClientWrapper.getStormClientStatus(); + } + +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormCLIWrapper.java similarity index 76% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java rename to metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormCLIWrapper.java index aecb421ad7..a47251509e 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormCLIWrapper.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormCLIWrapper.java @@ -15,11 +15,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.metron.rest.service; +package org.apache.metron.rest.service.impl; +import org.apache.metron.rest.MetronRestConstants; import org.apache.metron.rest.RestException; -import org.apache.metron.rest.config.KafkaConfig; -import org.apache.metron.rest.config.ZookeeperConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; @@ -31,15 +30,11 @@ import java.util.Map; import static java.util.stream.Collectors.toList; -import static org.apache.metron.rest.service.StormService.ENRICHMENT_TOPOLOGY_NAME; -import static org.apache.metron.rest.service.StormService.INDEXING_TOPOLOGY_NAME; +import static org.apache.metron.rest.MetronRestConstants.ENRICHMENT_TOPOLOGY_NAME; +import static org.apache.metron.rest.MetronRestConstants.INDEXING_TOPOLOGY_NAME; public class StormCLIWrapper { - public static final String PARSER_SCRIPT_PATH_SPRING_PROPERTY = "storm.parser.script.path"; - public static final String ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY = "storm.enrichment.script.path"; - public static final String INDEXING_SCRIPT_PATH_SPRING_PROPERTY = "storm.indexing.script.path"; - @Autowired private Environment environment; @@ -82,11 +77,11 @@ protected int runCommand(String[] command) throws RestException { protected String[] getParserStartCommand(String name) { String[] command = new String[7]; - command[0] = environment.getProperty(PARSER_SCRIPT_PATH_SPRING_PROPERTY); + command[0] = environment.getProperty(MetronRestConstants.PARSER_SCRIPT_PATH_SPRING_PROPERTY); command[1] = "-k"; - command[2] = environment.getProperty(KafkaConfig.KAFKA_BROKER_URL_SPRING_PROPERTY); + command[2] = environment.getProperty(MetronRestConstants.KAFKA_BROKER_URL_SPRING_PROPERTY); command[3] = "-z"; - command[4] = environment.getProperty(ZookeeperConfig.ZK_URL_SPRING_PROPERTY); + command[4] = environment.getProperty(MetronRestConstants.ZK_URL_SPRING_PROPERTY); command[5] = "-s"; command[6] = name; return command; @@ -94,13 +89,13 @@ protected String[] getParserStartCommand(String name) { protected String[] getEnrichmentStartCommand() { String[] command = new String[1]; - command[0] = environment.getProperty(ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY); + command[0] = environment.getProperty(MetronRestConstants.ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY); return command; } protected String[] getIndexingStartCommand() { String[] command = new String[1]; - command[0] = environment.getProperty(INDEXING_SCRIPT_PATH_SPRING_PROPERTY); + command[0] = environment.getProperty(MetronRestConstants.INDEXING_SCRIPT_PATH_SPRING_PROPERTY); return command; } @@ -125,9 +120,9 @@ protected ProcessBuilder getProcessBuilder(String... command) { public Map getStormClientStatus() throws RestException { Map status = new HashMap<>(); - status.put("parserScriptPath", environment.getProperty(PARSER_SCRIPT_PATH_SPRING_PROPERTY)); - status.put("enrichmentScriptPath", environment.getProperty(ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY)); - status.put("indexingScriptPath", environment.getProperty(INDEXING_SCRIPT_PATH_SPRING_PROPERTY)); + status.put("parserScriptPath", environment.getProperty(MetronRestConstants.PARSER_SCRIPT_PATH_SPRING_PROPERTY)); + status.put("enrichmentScriptPath", environment.getProperty(MetronRestConstants.ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY)); + status.put("indexingScriptPath", environment.getProperty(MetronRestConstants.INDEXING_SCRIPT_PATH_SPRING_PROPERTY)); status.put("stormClientVersionInstalled", stormClientVersionInstalled()); return status; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java new file mode 100644 index 0000000000..280d72aa5d --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java @@ -0,0 +1,122 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import org.apache.metron.rest.model.TopologyResponse; +import org.apache.metron.rest.model.TopologyStatus; +import org.apache.metron.rest.model.TopologyStatusCode; +import org.apache.metron.rest.model.TopologySummary; +import org.apache.metron.rest.service.StormStatusService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import static org.apache.metron.rest.MetronRestConstants.STORM_UI_SPRING_PROPERTY; +import static org.apache.metron.rest.MetronRestConstants.TOPOLOGY_SUMMARY_URL; +import static org.apache.metron.rest.MetronRestConstants.TOPOLOGY_URL; + +@Service +public class StormStatusServiceImpl implements StormStatusService { + + @Autowired + private Environment environment; + + @Autowired + private RestTemplate restTemplate; + + @Override + public TopologySummary getTopologySummary() { + return restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_SUMMARY_URL, TopologySummary.class); + } + + @Override + public TopologyStatus getTopologyStatus(String name) { + TopologyStatus topologyResponse = null; + String id = null; + for (TopologyStatus topology : getTopologySummary().getTopologies()) { + if (name.equals(topology.getName())) { + id = topology.getId(); + break; + } + } + if (id != null) { + topologyResponse = restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + id, TopologyStatus.class); + } + return topologyResponse; + } + + @Override + public List getAllTopologyStatus() { + List topologyStatus = new ArrayList<>(); + for (TopologyStatus topology : getTopologySummary().getTopologies()) { + topologyStatus.add(restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + topology.getId(), TopologyStatus.class)); + } + return topologyStatus; + } + + @Override + public TopologyResponse activateTopology(String name) { + TopologyResponse topologyResponse = new TopologyResponse(); + String id = null; + for (TopologyStatus topology : getTopologySummary().getTopologies()) { + if (name.equals(topology.getName())) { + id = topology.getId(); + break; + } + } + if (id != null) { + Map result = restTemplate.postForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + id + "/activate", null, Map.class); + if("success".equals(result.get("status"))) { + topologyResponse.setSuccessMessage(TopologyStatusCode.ACTIVE.toString()); + } else { + topologyResponse.setErrorMessage((String) result.get("status")); + } + } else { + topologyResponse.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString()); + } + return topologyResponse; + } + + @Override + public TopologyResponse deactivateTopology(String name) { + TopologyResponse topologyResponse = new TopologyResponse(); + String id = null; + for (TopologyStatus topology : getTopologySummary().getTopologies()) { + if (name.equals(topology.getName())) { + id = topology.getId(); + break; + } + } + if (id != null) { + Map result = restTemplate.postForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_URL + "/" + id + "/deactivate", null, Map.class); + if("success".equals(result.get("status"))) { + topologyResponse.setSuccessMessage(TopologyStatusCode.INACTIVE.toString()); + } else { + topologyResponse.setErrorMessage((String) result.get("status")); + } + } else { + topologyResponse.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString()); + } + return topologyResponse; + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java new file mode 100644 index 0000000000..07d1964e03 --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java @@ -0,0 +1,87 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import org.apache.metron.common.dsl.Context; +import org.apache.metron.common.dsl.ParseException; +import org.apache.metron.common.dsl.StellarFunctionInfo; +import org.apache.metron.common.dsl.functions.resolver.SingletonFunctionResolver; +import org.apache.metron.common.field.transformation.FieldTransformations; +import org.apache.metron.common.stellar.StellarProcessor; +import org.apache.metron.rest.model.StellarFunctionDescription; +import org.apache.metron.rest.model.TransformationValidation; +import org.apache.metron.rest.service.TransformationService; +import org.json.simple.JSONObject; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@Service +public class TransformationServiceImpl implements TransformationService { + + public Map validateRules(List rules) { + Map results = new HashMap<>(); + StellarProcessor stellarProcessor = new StellarProcessor(); + for(String rule: rules) { + try { + boolean result = stellarProcessor.validate(rule, Context.EMPTY_CONTEXT()); + results.put(rule, result); + } catch (ParseException e) { + results.put(rule, false); + } + } + return results; + } + + public Map validateTransformation(TransformationValidation transformationValidation) { + JSONObject sampleJson = new JSONObject(transformationValidation.getSampleData()); + transformationValidation.getSensorParserConfig().getFieldTransformations().forEach(fieldTransformer -> { + fieldTransformer.transformAndUpdate(sampleJson, transformationValidation.getSensorParserConfig().getParserConfig(), Context.EMPTY_CONTEXT()); + } + ); + return sampleJson; + } + + public FieldTransformations[] getTransformations() { + return FieldTransformations.values(); + } + + public List getStellarFunctions() { + List stellarFunctionDescriptions = new ArrayList<>(); + Iterable stellarFunctionsInfo = SingletonFunctionResolver.getInstance().getFunctionInfo(); + stellarFunctionsInfo.forEach(stellarFunctionInfo -> { + stellarFunctionDescriptions.add(new StellarFunctionDescription( + stellarFunctionInfo.getName(), + stellarFunctionInfo.getDescription(), + stellarFunctionInfo.getParams(), + stellarFunctionInfo.getReturns())); + }); + return stellarFunctionDescriptions; + } + + public List getSimpleStellarFunctions() { + List stellarFunctionDescriptions = getStellarFunctions(); + return stellarFunctionDescriptions.stream().filter(stellarFunctionDescription -> + stellarFunctionDescription.getParams().length == 1).sorted((o1, o2) -> o1.getName().compareTo(o2.getName())).collect(Collectors.toList()); + } + +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java index 2e1127f91f..0949eca116 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java @@ -32,7 +32,7 @@ import org.apache.metron.integration.components.ZKServerComponent; import org.apache.metron.rest.mock.MockStormCLIClientWrapper; import org.apache.metron.rest.mock.MockStormRestTemplate; -import org.apache.metron.rest.service.StormCLIWrapper; +import org.apache.metron.rest.service.impl.StormCLIWrapper; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; @@ -41,8 +41,10 @@ import javax.annotation.Nullable; import java.util.Properties; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; + @Configuration -@Profile("test") +@Profile(TEST_PROFILE) public class TestConfig { @Bean 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 a840da487f..a6597721ee 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 @@ -141,6 +141,11 @@ public void testSecurity() throws Exception { public void test() throws Exception { sensorEnrichmentConfigService.delete("broTest"); + this.mockMvc.perform(get(sensorEnrichmentConfigUrl).with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(content().bytes("{}".getBytes())); + this.mockMvc.perform(post(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java index 4daec9d84f..10edadcb76 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorIndexingConfigControllerIntegrationTest.java @@ -92,6 +92,11 @@ public void testSecurity() throws Exception { public void test() throws Exception { sensorIndexingConfigService.delete("broTest"); + this.mockMvc.perform(get(sensorIndexingConfigUrl).with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(content().bytes("{}".getBytes())); + this.mockMvc.perform(post(sensorIndexingConfigUrl + "/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) .andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java index 1957dc1ce5..09b1b0afca 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -19,7 +19,7 @@ import org.adrianwalker.multilinestring.Multiline; import org.apache.commons.io.FileUtils; -import org.apache.metron.rest.service.GrokService; +import org.apache.metron.rest.MetronRestConstants; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -353,12 +353,12 @@ public void test() throws Exception { } private void cleanFileSystem() throws IOException { - File grokTempPath = new File(environment.getProperty(GrokService.GROK_TEMP_PATH_SPRING_PROPERTY)); + File grokTempPath = new File(environment.getProperty(MetronRestConstants.GROK_TEMP_PATH_SPRING_PROPERTY)); if (grokTempPath.exists()) { FileUtils.cleanDirectory(grokTempPath); FileUtils.deleteDirectory(grokTempPath); } - File grokPath = new File(environment.getProperty(GrokService.GROK_DEFAULT_PATH_SPRING_PROPERTY)); + File grokPath = new File(environment.getProperty(MetronRestConstants.GROK_DEFAULT_PATH_SPRING_PROPERTY)); if (grokPath.exists()) { FileUtils.cleanDirectory(grokPath); FileUtils.deleteDirectory(grokPath); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java index 7fdcff0401..dd210958de 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormCLIClientWrapper.java @@ -19,7 +19,7 @@ import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.TopologyStatusCode; -import org.apache.metron.rest.service.StormCLIWrapper; +import org.apache.metron.rest.service.impl.StormCLIWrapper; import java.util.HashMap; import java.util.Map; diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java index 88486af60e..ca5c1c9ad2 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/mock/MockStormRestTemplate.java @@ -17,10 +17,10 @@ */ package org.apache.metron.rest.mock; +import org.apache.metron.rest.MetronRestConstants; import org.apache.metron.rest.model.TopologyStatus; import org.apache.metron.rest.model.TopologyStatusCode; import org.apache.metron.rest.model.TopologySummary; -import org.apache.metron.rest.service.StormService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.web.client.RestClientException; @@ -45,7 +45,7 @@ public void setMockStormCLIClientWrapper(MockStormCLIClientWrapper mockStormCLIC @Override public Object getForObject(String url, Class responseType, Object... urlVariables) throws RestClientException { Object response = null; - if (url.equals("http://" + environment.getProperty(StormService.STORM_UI_SPRING_PROPERTY) + StormService.TOPOLOGY_SUMMARY_URL)) { + if (url.equals("http://" + environment.getProperty(MetronRestConstants.STORM_UI_SPRING_PROPERTY) + MetronRestConstants.TOPOLOGY_SUMMARY_URL)) { TopologySummary topologySummary = new TopologySummary(); List topologyStatusList = new ArrayList<>(); for(String name: mockStormCLIClientWrapper.getParserTopologyNames()) { @@ -61,7 +61,7 @@ public Object getForObject(String url, Class responseType, Object... urlVariable } topologySummary.setTopologies(topologyStatusList.toArray(new TopologyStatus[topologyStatusList.size()])); response = topologySummary; - } else if (url.startsWith("http://" + environment.getProperty(StormService.STORM_UI_SPRING_PROPERTY) + StormService.TOPOLOGY_URL + "/")){ + } else if (url.startsWith("http://" + environment.getProperty(MetronRestConstants.STORM_UI_SPRING_PROPERTY) + MetronRestConstants.TOPOLOGY_URL + "/")){ String name = url.substring(url.lastIndexOf('/') + 1, url.length()).replaceFirst("-id", ""); response = getTopologyStatus(name); } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java index ce50827664..f7e43ab0cc 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java @@ -21,6 +21,7 @@ import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.apache.metron.rest.config.HadoopConfig; +import org.apache.metron.rest.service.impl.HdfsServiceImpl; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -34,12 +35,13 @@ import java.io.File; import java.io.IOException; +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes={HadoopConfig.class, HdfsServiceTest.HdfsServiceTestContextConfiguration.class}) -@ActiveProfiles("test") +@ActiveProfiles(TEST_PROFILE) public class HdfsServiceTest { @Configuration @@ -48,7 +50,7 @@ static class HdfsServiceTestContextConfiguration { @Bean public HdfsService hdfsService() { - return new HdfsService(); + return new HdfsServiceImpl(); } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java index 1d2e252a15..561548e999 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java @@ -25,6 +25,7 @@ import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.configuration.SensorParserConfig; import org.apache.metron.common.utils.JSONUtils; +import org.apache.metron.rest.service.impl.SensorParserConfigServiceImpl; import org.apache.zookeeper.KeeperException; import org.junit.Before; import org.junit.Test; @@ -68,7 +69,7 @@ public class SensorParserConfigTest { private GrokService grokService; @InjectMocks - private SensorParserConfigService sensorParserConfigService; + private SensorParserConfigServiceImpl sensorParserConfigService; @Before public void setUp() throws Exception { @@ -85,7 +86,6 @@ public void test() throws Exception { broParserConfig.setParserClassName("org.apache.metron.parsers.bro.BasicBroParser"); broParserConfig.setSensorTopic("broTest"); Mockito.when(objectMapper.writeValueAsString(broParserConfig)).thenReturn(new String(JSONUtils.INSTANCE.toJSON(broParserConfig))); - Mockito.when(grokService.isGrokConfig(broParserConfig)).thenReturn(false); sensorParserConfigService.save(broParserConfig); verifyStatic(times(1)); ConfigurationsUtils.writeSensorParserConfigToZookeeper("broTest", JSONUtils.INSTANCE.toJSON(broParserConfig), client); From 12532423ac520cc08937fa6a5a6fbaff5255879d Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 23 Jan 2017 17:13:43 -0600 Subject: [PATCH 33/54] Fixed jdbc dependency --- metron-interface/metron-rest/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index 13e95230c2..c2beb2d5f4 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -57,8 +57,8 @@ spring-boot-starter-security - org.springframework - spring-jdbc + org.springframework.boot + spring-boot-starter-jdbc mysql From 6f753487b40409ed1b2207a9343c77dc72fe219b Mon Sep 17 00:00:00 2001 From: rmerriman Date: Wed, 25 Jan 2017 09:24:22 -0600 Subject: [PATCH 34/54] Removed @Service annotation from interfaces and added @Override annotation to implementations --- .../apache/metron/rest/service/GlobalConfigService.java | 2 -- .../java/org/apache/metron/rest/service/GrokService.java | 2 -- .../java/org/apache/metron/rest/service/HdfsService.java | 1 - .../org/apache/metron/rest/service/KafkaService.java | 2 -- .../rest/service/SensorEnrichmentConfigService.java | 2 -- .../metron/rest/service/SensorIndexingConfigService.java | 2 -- .../metron/rest/service/SensorParserConfigService.java | 2 -- .../apache/metron/rest/service/StormAdminService.java | 2 -- .../apache/metron/rest/service/StormStatusService.java | 2 -- .../metron/rest/service/TransformationService.java | 2 -- .../rest/service/impl/GlobalConfigServiceImpl.java | 3 +++ .../apache/metron/rest/service/impl/GrokServiceImpl.java | 2 ++ .../apache/metron/rest/service/impl/HdfsServiceImpl.java | 4 ++++ .../metron/rest/service/impl/KafkaServiceImpl.java | 5 +++++ .../service/impl/SensorEnrichmentConfigServiceImpl.java | 6 ++++++ .../service/impl/SensorIndexingConfigServiceImpl.java | 5 +++++ .../rest/service/impl/SensorParserConfigServiceImpl.java | 9 ++++++++- .../metron/rest/service/impl/StormAdminServiceImpl.java | 7 +++++++ .../rest/service/impl/TransformationServiceImpl.java | 5 +++++ 19 files changed, 45 insertions(+), 20 deletions(-) diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java index 9d1237b1db..7b8cf450fd 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GlobalConfigService.java @@ -18,11 +18,9 @@ package org.apache.metron.rest.service; import org.apache.metron.rest.RestException; -import org.springframework.stereotype.Service; import java.util.Map; -@Service public interface GlobalConfigService { Map save(Map globalConfig) throws RestException; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java index b277844050..95ce1ba4ad 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java @@ -19,11 +19,9 @@ import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.GrokValidation; -import org.springframework.stereotype.Service; import java.util.Map; -@Service public interface GrokService { Map getCommonGrokPatterns(); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java index 3c7648a5e5..97888ff5ac 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java @@ -23,7 +23,6 @@ import java.io.IOException; -@Service public interface HdfsService { byte[] read(Path path) throws IOException; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java index e1d55745ef..e89b16565c 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java @@ -19,11 +19,9 @@ import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.KafkaTopic; -import org.springframework.stereotype.Service; import java.util.Set; -@Service public interface KafkaService { KafkaTopic createTopic(KafkaTopic topic) throws RestException; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java index 184d5e460f..fe84802ba0 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorEnrichmentConfigService.java @@ -19,12 +19,10 @@ import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; import org.apache.metron.rest.RestException; -import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; -@Service public interface SensorEnrichmentConfigService { SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java index 084c1dd3ff..06994317b4 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorIndexingConfigService.java @@ -18,12 +18,10 @@ package org.apache.metron.rest.service; import org.apache.metron.rest.RestException; -import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; -@Service public interface SensorIndexingConfigService { Map save(String name, Map sensorIndexingConfig) throws RestException; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java index 27653fb645..efda639b97 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -21,11 +21,9 @@ import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.ParseMessageRequest; import org.json.simple.JSONObject; -import org.springframework.stereotype.Service; import java.util.Map; -@Service public interface SensorParserConfigService { SensorParserConfig save(SensorParserConfig sensorParserConfig) throws RestException; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormAdminService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormAdminService.java index c84a5747ee..8c1e228864 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormAdminService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormAdminService.java @@ -19,11 +19,9 @@ import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.TopologyResponse; -import org.springframework.stereotype.Service; import java.util.Map; -@Service public interface StormAdminService { TopologyResponse startParserTopology(String name) throws RestException; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormStatusService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormStatusService.java index 6563a31ccd..76216d0207 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormStatusService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StormStatusService.java @@ -20,11 +20,9 @@ import org.apache.metron.rest.model.TopologyResponse; import org.apache.metron.rest.model.TopologyStatus; import org.apache.metron.rest.model.TopologySummary; -import org.springframework.stereotype.Service; import java.util.List; -@Service public interface StormStatusService { TopologySummary getTopologySummary(); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java index 499710d4e3..d1400c6dc8 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java @@ -20,12 +20,10 @@ import org.apache.metron.common.field.transformation.FieldTransformations; import org.apache.metron.rest.model.StellarFunctionDescription; import org.apache.metron.rest.model.TransformationValidation; -import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; -@Service public interface TransformationService { Map validateRules(List rules); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java index 86f230615d..54c331a8b9 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java @@ -37,6 +37,7 @@ public class GlobalConfigServiceImpl implements GlobalConfigService { @Autowired private CuratorFramework client; + @Override public Map save(Map globalConfig) throws RestException { try { ConfigurationsUtils.writeGlobalConfigToZookeeper(globalConfig, client); @@ -46,6 +47,7 @@ public Map save(Map globalConfig) throws RestExc return globalConfig; } + @Override public Map get() throws RestException { Map globalConfig; try { @@ -59,6 +61,7 @@ public Map get() throws RestException { return globalConfig; } + @Override public boolean delete() throws RestException { try { client.delete().forPath(ConfigurationType.GLOBAL.getZookeeperRoot()); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java index cb49dc18da..8fbea1301d 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java @@ -35,10 +35,12 @@ public class GrokServiceImpl implements GrokService { @Autowired private Grok commonGrok; + @Override public Map getCommonGrokPatterns() { return commonGrok.getPatterns(); } + @Override public GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException { Map results; try { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java index 6ebf1a84d4..c14ec0c364 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java @@ -36,22 +36,26 @@ public class HdfsServiceImpl implements HdfsService { @Autowired private Configuration configuration; + @Override public byte[] read(Path path) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); IOUtils.copyBytes(FileSystem.get(configuration).open(path), byteArrayOutputStream, configuration); return byteArrayOutputStream.toByteArray(); } + @Override public void write(Path path, byte[] contents) throws IOException { FSDataOutputStream fsDataOutputStream = FileSystem.get(configuration).create(path, true); fsDataOutputStream.write(contents); fsDataOutputStream.close(); } + @Override public FileStatus[] list(Path path) throws IOException { return FileSystem.get(configuration).listStatus(path); } + @Override public boolean delete(Path path, boolean recursive) throws IOException { return FileSystem.get(configuration).delete(path, recursive); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java index 7a2d28a7a0..7246c2faaf 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java @@ -48,6 +48,7 @@ public class KafkaServiceImpl implements KafkaService { private String offsetTopic = "__consumer_offsets"; + @Override public KafkaTopic createTopic(KafkaTopic topic) throws RestException { if (!listTopics().contains(topic.getName())) { try { @@ -59,6 +60,7 @@ public KafkaTopic createTopic(KafkaTopic topic) throws RestException { return topic; } + @Override public boolean deleteTopic(String name) { if (listTopics().contains(name)) { AdminUtils.deleteTopic(zkUtils, name); @@ -68,6 +70,7 @@ public boolean deleteTopic(String name) { } } + @Override public KafkaTopic getTopic(String name) { KafkaTopic kafkaTopic = null; if (listTopics().contains(name)) { @@ -83,6 +86,7 @@ public KafkaTopic getTopic(String name) { return kafkaTopic; } + @Override public Set listTopics() { Set topics; synchronized (this) { @@ -92,6 +96,7 @@ public Set listTopics() { return topics; } + @Override public String getSampleMessage(String topic) { String message = null; if (listTopics().contains(topic)) { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java index 20c82414d5..8b3dbb7e88 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java @@ -42,6 +42,7 @@ public class SensorEnrichmentConfigServiceImpl implements SensorEnrichmentConfig @Autowired private CuratorFramework client; + @Override public SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException { try { ConfigurationsUtils.writeSensorEnrichmentConfigToZookeeper(name, objectMapper.writeValueAsString(sensorEnrichmentConfig).getBytes(), client); @@ -51,6 +52,7 @@ public SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnr return sensorEnrichmentConfig; } + @Override public SensorEnrichmentConfig findOne(String name) throws RestException { SensorEnrichmentConfig sensorEnrichmentConfig; try { @@ -63,6 +65,7 @@ public SensorEnrichmentConfig findOne(String name) throws RestException { return sensorEnrichmentConfig; } + @Override public Map getAll() throws RestException { Map sensorEnrichmentConfigs = new HashMap<>(); List sensorNames = getAllTypes(); @@ -72,6 +75,7 @@ public Map getAll() throws RestException { return sensorEnrichmentConfigs; } + @Override public List getAllTypes() throws RestException { List types; try { @@ -84,6 +88,7 @@ public List getAllTypes() throws RestException { return types; } + @Override public boolean delete(String name) throws RestException { try { client.delete().forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/" + name); @@ -95,6 +100,7 @@ public boolean delete(String name) throws RestException { return true; } + @Override public List getAvailableEnrichments() { return new ArrayList() {{ add("geo"); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java index e246682d73..ab46418161 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java @@ -44,6 +44,7 @@ public class SensorIndexingConfigServiceImpl implements SensorIndexingConfigServ @Autowired private CuratorFramework client; + @Override public Map save(String name, Map sensorIndexingConfig) throws RestException { try { ConfigurationsUtils.writeSensorIndexingConfigToZookeeper(name, objectMapper.writeValueAsString(sensorIndexingConfig).getBytes(), client); @@ -53,6 +54,7 @@ public Map save(String name, Map sensorIndexingC return sensorIndexingConfig; } + @Override public Map findOne(String name) throws RestException { Map sensorIndexingConfig; try { @@ -66,6 +68,7 @@ public Map findOne(String name) throws RestException { return sensorIndexingConfig; } + @Override public Map> getAll() throws RestException { Map> sensorIndexingConfigs = new HashMap<>(); List sensorNames = getAllTypes(); @@ -75,6 +78,7 @@ public Map> getAll() throws RestException { return sensorIndexingConfigs; } + @Override public List getAllTypes() throws RestException { List types; try { @@ -87,6 +91,7 @@ public List getAllTypes() throws RestException { return types; } + @Override public boolean delete(String name) throws RestException { try { client.delete().forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/" + name); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java index 800aa46f8e..cb88708adc 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java @@ -76,6 +76,7 @@ public void setClient(CuratorFramework client) { private Map availableParsers; + @Override public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws RestException { String serializedConfig; if (isGrokConfig(sensorParserConfig)) { @@ -106,6 +107,7 @@ private String serialize(SensorParserConfig sensorParserConfig) throws RestExcep return serializedConfig; } + @Override public SensorParserConfig findOne(String name) throws RestException { SensorParserConfig sensorParserConfig; try { @@ -121,6 +123,7 @@ public SensorParserConfig findOne(String name) throws RestException { return sensorParserConfig; } + @Override public Iterable getAll() throws RestException { List sensorParserConfigs = new ArrayList<>(); List sensorNames = getAllTypes(); @@ -130,6 +133,7 @@ public Iterable getAll() throws RestException { return sensorParserConfigs; } + @Override public boolean delete(String name) throws RestException { try { client.delete().forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/" + name); @@ -141,7 +145,7 @@ public boolean delete(String name) throws RestException { return true; } - public List getAllTypes() throws RestException { + private List getAllTypes() throws RestException { List types; try { types = client.getChildren().forPath(ConfigurationType.PARSER.getZookeeperRoot()); @@ -153,6 +157,7 @@ public List getAllTypes() throws RestException { return types; } + @Override public Map getAvailableParsers() { if (availableParsers == null) { availableParsers = new HashMap<>(); @@ -166,6 +171,7 @@ public Map getAvailableParsers() { return availableParsers; } + @Override public Map reloadAvailableParsers() { availableParsers = null; return getAvailableParsers(); @@ -176,6 +182,7 @@ private Set> getParserClasses() { return reflections.getSubTypesOf(MessageParser.class); } + @Override public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws RestException { SensorParserConfig sensorParserConfig = parseMessageRequest.getSensorParserConfig(); if (sensorParserConfig == null) { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java index 8ac6667203..cb7c449ab1 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java @@ -44,6 +44,7 @@ public void setStormCLIClientWrapper(StormCLIWrapper stormCLIClientWrapper) { @Autowired private SensorParserConfigService sensorParserConfigService; + @Override public TopologyResponse startParserTopology(String name) throws RestException { TopologyResponse topologyResponse = new TopologyResponse(); if (globalConfigService.get() == null) { @@ -56,22 +57,27 @@ public TopologyResponse startParserTopology(String name) throws RestException { return topologyResponse; } + @Override public TopologyResponse stopParserTopology(String name, boolean stopNow) throws RestException { return createResponse(stormCLIClientWrapper.stopParserTopology(name, stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); } + @Override public TopologyResponse startEnrichmentTopology() throws RestException { return createResponse(stormCLIClientWrapper.startEnrichmentTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); } + @Override public TopologyResponse stopEnrichmentTopology(boolean stopNow) throws RestException { return createResponse(stormCLIClientWrapper.stopEnrichmentTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); } + @Override public TopologyResponse startIndexingTopology() throws RestException { return createResponse(stormCLIClientWrapper.startIndexingTopology(), TopologyStatusCode.STARTED, TopologyStatusCode.START_ERROR); } + @Override public TopologyResponse stopIndexingTopology(boolean stopNow) throws RestException { return createResponse(stormCLIClientWrapper.stopIndexingTopology(stopNow), TopologyStatusCode.STOPPED, TopologyStatusCode.STOP_ERROR); } @@ -86,6 +92,7 @@ private TopologyResponse createResponse(int responseCode, TopologyStatusCode suc return topologyResponse; } + @Override public Map getStormClientStatus() throws RestException { return stormCLIClientWrapper.getStormClientStatus(); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java index 07d1964e03..b26dc82355 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java @@ -38,6 +38,7 @@ @Service public class TransformationServiceImpl implements TransformationService { + @Override public Map validateRules(List rules) { Map results = new HashMap<>(); StellarProcessor stellarProcessor = new StellarProcessor(); @@ -52,6 +53,7 @@ public Map validateRules(List rules) { return results; } + @Override public Map validateTransformation(TransformationValidation transformationValidation) { JSONObject sampleJson = new JSONObject(transformationValidation.getSampleData()); transformationValidation.getSensorParserConfig().getFieldTransformations().forEach(fieldTransformer -> { @@ -61,10 +63,12 @@ public Map validateTransformation(TransformationValidation trans return sampleJson; } + @Override public FieldTransformations[] getTransformations() { return FieldTransformations.values(); } + @Override public List getStellarFunctions() { List stellarFunctionDescriptions = new ArrayList<>(); Iterable stellarFunctionsInfo = SingletonFunctionResolver.getInstance().getFunctionInfo(); @@ -78,6 +82,7 @@ public List getStellarFunctions() { return stellarFunctionDescriptions; } + @Override public List getSimpleStellarFunctions() { List stellarFunctionDescriptions = getStellarFunctions(); return stellarFunctionDescriptions.stream().filter(stellarFunctionDescription -> From 13e3520cd00a1c9c046ae8a352085698e6e6be3e Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 27 Jan 2017 16:07:02 -0600 Subject: [PATCH 35/54] Resolved merge conflict --- .../java/org/apache/metron/rest/config/TestConfig.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java index 0949eca116..7931fe6509 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java @@ -55,14 +55,7 @@ public Properties zkProperties() { @Bean public ZKServerComponent zkServerComponent(Properties zkProperties) { return new ZKServerComponent() - .withPostStartCallback(new Function() { - @Nullable - @Override - public Void apply(@Nullable ZKServerComponent zkComponent) { - zkProperties.setProperty(ZKServerComponent.ZOOKEEPER_PROPERTY, zkComponent.getConnectionString()); - return null; - } - }); + .withPostStartCallback((zkComponent) -> zkProperties.setProperty(ZKServerComponent.ZOOKEEPER_PROPERTY, zkComponent.getConnectionString())); } @Bean From 9b75f7ebdb135537e9996ae78123d05ede359e07 Mon Sep 17 00:00:00 2001 From: JJ Date: Sun, 29 Jan 2017 19:31:37 -0600 Subject: [PATCH 36/54] METRON-503: added unit tests for some of the services. To make unit testing simpler, minor refactoring was done. For example, a constructor with all dependencies was created. --- .../metron/rest/model/GrokValidation.java | 20 ++ .../apache/metron/rest/model/KafkaTopic.java | 22 ++ .../metron/rest/config/KafkaConfig.java | 8 +- .../metron/rest/config/StormConfig.java | 2 +- .../rest/controller/GrokController.java | 2 +- .../metron/rest/service/KafkaService.java | 2 +- .../service/impl/DockerStormCLIWrapper.java | 12 +- .../service/impl/GlobalConfigServiceImpl.java | 5 +- .../rest/service/impl/GrokServiceImpl.java | 14 +- .../rest/service/impl/KafkaServiceImpl.java | 52 ++-- .../impl/DockerStormCLIWrapperTest.java | 37 +++ .../impl/GlobalConfigServiceImplTest.java | 137 +++++++++ .../service/impl/GrokServiceImplTest.java | 134 +++++++++ .../HdfsServiceImplTest.java} | 8 +- .../service/impl/KafkaServiceImplTest.java | 275 ++++++++++++++++++ 15 files changed, 687 insertions(+), 43 deletions(-) create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImplTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GrokServiceImplTest.java rename metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/{HdfsServiceTest.java => impl/HdfsServiceImplTest.java} (94%) create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java index 7fbcd342ea..ccd2c5c5c5 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java @@ -52,4 +52,24 @@ public Map getResults() { public void setResults(Map results) { this.results = results; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + GrokValidation that = (GrokValidation) o; + + if (statement != null ? !statement.equals(that.statement) : that.statement != null) return false; + if (sampleData != null ? !sampleData.equals(that.sampleData) : that.sampleData != null) return false; + return results != null ? results.equals(that.results) : that.results == null; + } + + @Override + public int hashCode() { + int result = statement != null ? statement.hashCode() : 0; + result = 31 * result + (sampleData != null ? sampleData.hashCode() : 0); + result = 31 * result + (results != null ? results.hashCode() : 0); + return result; + } } diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/KafkaTopic.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/KafkaTopic.java index c8db9f64fb..55dd2b2d42 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/KafkaTopic.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/KafkaTopic.java @@ -57,4 +57,26 @@ public Properties getProperties() { public void setProperties(Properties properties) { this.properties = properties; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + KafkaTopic that = (KafkaTopic) o; + + if (numPartitions != that.numPartitions) return false; + if (replicationFactor != that.replicationFactor) return false; + if (name != null ? !name.equals(that.name) : that.name != null) return false; + return properties != null ? properties.equals(that.properties) : that.properties == null; + } + + @Override + public int hashCode() { + int result = name != null ? name.hashCode() : 0; + result = 31 * result + numPartitions; + result = 31 * result + replicationFactor; + result = 31 * result + (properties != null ? properties.hashCode() : 0); + return result; + } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java index 8044405a97..f6ff73c7db 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/KafkaConfig.java @@ -17,6 +17,7 @@ */ package org.apache.metron.rest.config; +import kafka.admin.AdminUtils$; import kafka.utils.ZkUtils; import org.I0Itec.zkclient.ZkClient; import org.apache.kafka.clients.consumer.KafkaConsumer; @@ -46,7 +47,7 @@ public ZkUtils zkUtils() { return ZkUtils.apply(zkClient, false); } - @Bean(destroyMethod="close") + @Bean(destroyMethod = "close") public KafkaConsumer kafkaConsumer() { Properties props = new Properties(); props.put("bootstrap.servers", environment.getProperty(MetronRestConstants.KAFKA_BROKER_URL_SPRING_PROPERTY)); @@ -58,4 +59,9 @@ public KafkaConsumer kafkaConsumer() { props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer"); return new KafkaConsumer<>(props); } + + @Bean + public AdminUtils$ adminUtils() { + return AdminUtils$.MODULE$; + } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java index d6d0cff35d..7a61cbce08 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/config/StormConfig.java @@ -40,7 +40,7 @@ public class StormConfig { @Bean public StormCLIWrapper stormCLIClientWrapper() { if (Arrays.asList(environment.getActiveProfiles()).contains(DOCKER_PROFILE)) { - return new DockerStormCLIWrapper(); + return new DockerStormCLIWrapper(environment); } else { return new StormCLIWrapper(); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java index 2b155b1a40..d561897813 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/GrokController.java @@ -43,7 +43,7 @@ public class GrokController { @ApiOperation(value = "Applies a Grok statement to a sample message") @ApiResponse(message = "JSON results", code = 200) @RequestMapping(value = "/validate", method = RequestMethod.POST) - ResponseEntity post(@ApiParam(name="grokValidation", value="Object containing Grok statment and sample message", required=true)@RequestBody GrokValidation grokValidation) throws RestException { + ResponseEntity post(@ApiParam(name = "grokValidation", value = "Object containing Grok statement and sample message", required = true) @RequestBody GrokValidation grokValidation) throws RestException { return new ResponseEntity<>(grokService.validateGrokStatement(grokValidation), HttpStatus.OK); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java index e89b16565c..f3cd9019ea 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/KafkaService.java @@ -23,6 +23,7 @@ import java.util.Set; public interface KafkaService { + String CONSUMER_OFFSETS_TOPIC = "__consumer_offsets"; KafkaTopic createTopic(KafkaTopic topic) throws RestException; @@ -33,5 +34,4 @@ public interface KafkaService { Set listTopics(); String getSampleMessage(String topic); - } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java index d7bbb230f9..23791ac6f3 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java @@ -30,11 +30,15 @@ public class DockerStormCLIWrapper extends StormCLIWrapper { - private Logger LOG = LoggerFactory.getLogger(DockerStormCLIWrapper.class); + private static final Logger LOG = LoggerFactory.getLogger(DockerStormCLIWrapper.class); - @Autowired private Environment environment; + @Autowired + public DockerStormCLIWrapper(Environment environment) { + this.environment = environment; + } + @Override protected ProcessBuilder getProcessBuilder(String... command) { String[] dockerCommand = {"docker-compose", "-f", environment.getProperty("docker.compose.path"), "-p", "metron", "exec", "storm"}; @@ -45,7 +49,7 @@ protected ProcessBuilder getProcessBuilder(String... command) { return pb; } - protected void setDockerEnvironment(Map environmentVariables) { + private void setDockerEnvironment(Map environmentVariables) { ProcessBuilder pb = getDockerEnvironmentProcessBuilder(); try { Process process = pb.start(); @@ -63,7 +67,7 @@ protected void setDockerEnvironment(Map environmentVariables) { } } - protected ProcessBuilder getDockerEnvironmentProcessBuilder() { + private ProcessBuilder getDockerEnvironmentProcessBuilder() { String[] command = {"docker-machine", "env", "metron-machine"}; return new ProcessBuilder(command); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java index 54c331a8b9..e80380bd14 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImpl.java @@ -33,9 +33,12 @@ @Service public class GlobalConfigServiceImpl implements GlobalConfigService { + private CuratorFramework client; @Autowired - private CuratorFramework client; + public GlobalConfigServiceImpl(CuratorFramework client) { + this.client = client; + } @Override public Map save(Map globalConfig) throws RestException { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java index 8fbea1301d..323ca78002 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java @@ -19,6 +19,7 @@ import oi.thekraken.grok.api.Grok; import oi.thekraken.grok.api.Match; +import org.apache.directory.api.util.Strings; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.GrokValidation; import org.apache.metron.rest.service.GrokService; @@ -31,9 +32,12 @@ @Service public class GrokServiceImpl implements GrokService { + private Grok commonGrok; @Autowired - private Grok commonGrok; + public GrokServiceImpl(Grok commonGrok) { + this.commonGrok = commonGrok; + } @Override public Map getCommonGrokPatterns() { @@ -44,10 +48,12 @@ public Map getCommonGrokPatterns() { public GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException { Map results; try { + String statement = Strings.isEmpty(grokValidation.getStatement()) ? "" : grokValidation.getStatement(); + Grok grok = new Grok(); grok.addPatternFromReader(new InputStreamReader(getClass().getResourceAsStream("/patterns/common"))); - grok.addPatternFromReader(new StringReader(grokValidation.getStatement())); - String patternLabel = grokValidation.getStatement().substring(0, grokValidation.getStatement().indexOf(" ")); + grok.addPatternFromReader(new StringReader(statement)); + String patternLabel = statement.substring(0, statement.indexOf(" ")); String grokPattern = "%{" + patternLabel + "}"; grok.compile(grokPattern); Match gm = grok.match(grokValidation.getSampleData()); @@ -55,7 +61,7 @@ public GrokValidation validateGrokStatement(GrokValidation grokValidation) throw results = gm.toMap(); results.remove(patternLabel); } catch (StringIndexOutOfBoundsException e) { - throw new RestException("A pattern label must be included (ex. PATTERN_LABEL ${PATTERN:field} ...)", e.getCause()); + throw new RestException("A pattern label must be included (eg. PATTERN_LABEL %{PATTERN:field} ...)", e.getCause()); } catch (Exception e) { throw new RestException(e); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java index 7246c2faaf..7b10dc4ed4 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/KafkaServiceImpl.java @@ -18,10 +18,9 @@ package org.apache.metron.rest.service.impl; import kafka.admin.AdminOperationException; -import kafka.admin.AdminUtils; +import kafka.admin.AdminUtils$; import kafka.admin.RackAwareMode; import kafka.utils.ZkUtils; -import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; import org.apache.kafka.common.PartitionInfo; @@ -32,27 +31,30 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Iterator; +import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @Service public class KafkaServiceImpl implements KafkaService { - - @Autowired private ZkUtils zkUtils; - - @Autowired private KafkaConsumer kafkaConsumer; + private AdminUtils$ adminUtils; - private String offsetTopic = "__consumer_offsets"; + @Autowired + public KafkaServiceImpl(ZkUtils zkUtils, KafkaConsumer kafkaConsumer, AdminUtils$ adminUtils) { + this.zkUtils = zkUtils; + this.kafkaConsumer = kafkaConsumer; + this.adminUtils = adminUtils; + } @Override public KafkaTopic createTopic(KafkaTopic topic) throws RestException { if (!listTopics().contains(topic.getName())) { try { - AdminUtils.createTopic(zkUtils, topic.getName(), topic.getNumPartitions(), topic.getReplicationFactor(), topic.getProperties(), RackAwareMode.Disabled$.MODULE$); + adminUtils.createTopic(zkUtils, topic.getName(), topic.getNumPartitions(), topic.getReplicationFactor(), topic.getProperties(), RackAwareMode.Disabled$.MODULE$); } catch (AdminOperationException e) { throw new RestException(e); } @@ -62,8 +64,9 @@ public KafkaTopic createTopic(KafkaTopic topic) throws RestException { @Override public boolean deleteTopic(String name) { - if (listTopics().contains(name)) { - AdminUtils.deleteTopic(zkUtils, name); + Set topics = listTopics(); + if (topics != null && topics.contains(name)) { + adminUtils.deleteTopic(zkUtils, name); return true; } else { return false; @@ -90,8 +93,9 @@ public KafkaTopic getTopic(String name) { public Set listTopics() { Set topics; synchronized (this) { - topics = kafkaConsumer.listTopics().keySet(); - topics.remove(offsetTopic); + Map> topicsInfo = kafkaConsumer.listTopics(); + topics = topicsInfo == null ? new HashSet<>() : topicsInfo.keySet(); + topics.remove(CONSUMER_OFFSETS_TOPIC); } return topics; } @@ -101,20 +105,16 @@ public String getSampleMessage(String topic) { String message = null; if (listTopics().contains(topic)) { synchronized (this) { - kafkaConsumer.assign(kafkaConsumer.partitionsFor(topic).stream().map(partitionInfo -> - new TopicPartition(topic, partitionInfo.partition())).collect(Collectors.toList())); - for (TopicPartition topicPartition : kafkaConsumer.assignment()) { - long offset = kafkaConsumer.position(topicPartition) - 1; - if (offset >= 0) { - kafkaConsumer.seek(topicPartition, offset); - } - } + kafkaConsumer.assign(kafkaConsumer.partitionsFor(topic).stream() + .map(partitionInfo -> new TopicPartition(topic, partitionInfo.partition())) + .collect(Collectors.toList())); + + kafkaConsumer.assignment().stream() + .filter(p -> (kafkaConsumer.position(p) -1) >= 0) + .forEach(p -> kafkaConsumer.seek(p, kafkaConsumer.position(p) - 1)); + ConsumerRecords records = kafkaConsumer.poll(100); - Iterator> iterator = records.iterator(); - if (iterator.hasNext()) { - ConsumerRecord record = iterator.next(); - message = record.value(); - } + message = records.isEmpty() ? null : records.iterator().next().value(); kafkaConsumer.unsubscribe(); } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java new file mode 100644 index 0000000000..964a5884e0 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java @@ -0,0 +1,37 @@ +package org.apache.metron.rest.service.impl; + +import org.junit.Before; +import org.junit.Test; +import org.springframework.core.env.Environment; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class DockerStormCLIWrapperTest { + private Environment environment; + private DockerStormCLIWrapper dockerStormCLIWrapper; + + @Before + public void setUp() throws Exception { + environment = mock(Environment.class); + + dockerStormCLIWrapper = new DockerStormCLIWrapper(environment); + } + + @Test + public void getProcessBuilderShouldProperlyGenerateProcessorBuilder() throws Exception { + ProcessBuilder expectedProcessBuilder = new ProcessBuilder("docker-compose", "-f", "/test", "-p", "metron", "exec", "storm", "oo", "ooo"); + expectedProcessBuilder.environment().put("METRON_VERSION", "1"); + + + when(environment.getProperty("docker.compose.path")).thenReturn("/test"); + when(environment.getProperty("metron.version")).thenReturn("1"); + + + ProcessBuilder actualBuilder = dockerStormCLIWrapper.getProcessBuilder("oo", "ooo"); + + assertEquals(expectedProcessBuilder.environment(), actualBuilder.environment()); + assertEquals(expectedProcessBuilder.command(), actualBuilder.command()); + } +} \ No newline at end of file diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImplTest.java new file mode 100644 index 0000000000..0d96de907a --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImplTest.java @@ -0,0 +1,137 @@ +package org.apache.metron.rest.service.impl; + +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.api.DeleteBuilder; +import org.apache.curator.framework.api.GetDataBuilder; +import org.apache.curator.framework.api.SetDataBuilder; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.GlobalConfigService; +import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.data.Stat; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@SuppressWarnings("ALL") +public class GlobalConfigServiceImplTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); + + CuratorFramework curatorFramework; + GlobalConfigService globalConfigService; + + @Before + public void setUp() throws Exception { + curatorFramework = mock(CuratorFramework.class); + globalConfigService = new GlobalConfigServiceImpl(curatorFramework); + } + + + @Test + public void deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse() throws Exception { + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenThrow(KeeperException.NoNodeException.class); + + assertFalse(globalConfigService.delete()); + } + + @Test + public void deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException() throws Exception { + exception.expect(RestException.class); + + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenThrow(Exception.class); + + assertFalse(globalConfigService.delete()); + } + + @Test + public void deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete() throws Exception { + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenReturn(null); + + assertTrue(globalConfigService.delete()); + + verify(curatorFramework).delete(); + } + + @Test + public void getShouldProperlyReturnGlobalConfig() throws Exception { + final String config = "{\"k\":\"v\"}"; + final Map configMap = new HashMap() {{ + put("k", "v"); + }}; + + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenReturn(config.getBytes()); + + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertEquals(configMap, globalConfigService.get()); + } + + @Test + public void getShouldReturnNullWhenNoNodeExceptionIsThrown() throws Exception { + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenThrow(KeeperException.NoNodeException.class); + + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertNull(globalConfigService.get()); + } + + @Test + public void getShouldWrapNonNoNodeExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot())).thenThrow(Exception.class); + + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + globalConfigService.get(); + } + + @Test + public void saveShouldWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + SetDataBuilder setDataBuilder = mock(SetDataBuilder.class); + when(setDataBuilder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot(), "{}".getBytes())).thenThrow(Exception.class); + + when(curatorFramework.setData()).thenReturn(setDataBuilder); + + globalConfigService.save(new HashMap<>()); + } + + @Test + public void saveShouldReturnSameConfigThatIsPassedOnSuccessfulSave() throws Exception { + SetDataBuilder setDataBuilder = mock(SetDataBuilder.class); + when(setDataBuilder.forPath(ConfigurationType.GLOBAL.getZookeeperRoot(), "{}".getBytes())).thenReturn(new Stat()); + + when(curatorFramework.setData()).thenReturn(setDataBuilder); + + assertEquals(new HashMap<>(), globalConfigService.save(new HashMap<>())); + verify(setDataBuilder).forPath(eq(ConfigurationType.GLOBAL.getZookeeperRoot()), eq("{}".getBytes())); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000..f4def72044 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GrokServiceImplTest.java @@ -0,0 +1,134 @@ +package org.apache.metron.rest.service.impl; + +import oi.thekraken.grok.api.Grok; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.model.GrokValidation; +import org.apache.metron.rest.service.GrokService; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class GrokServiceImplTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); + + private Grok grok; + private GrokService grokService; + + @Before + public void setUp() throws Exception { + grok = mock(Grok.class); + grokService = new GrokServiceImpl(grok); + } + + @Test + public void getCommonGrokPattersShouldCallGrokToGetPatterns() throws Exception { + grokService.getCommonGrokPatterns(); + + verify(grok).getPatterns(); + } + + @Test + public void getCommonGrokPattersShouldCallGrokToGetPatternsAndNotAlterValue() throws Exception { + Map patterns = new HashMap() {{ + put("k", "v"); + put("k1", "v1"); + }}; + + when(grok.getPatterns()).thenReturn(patterns); + + assertEquals(patterns, grokService.getCommonGrokPatterns()); + } + + @Test + public void validateGrokStatementShouldThrowExceptionWithEmptyStringAsStatement() throws Exception { + exception.expect(RestException.class); + exception.expectMessage("A pattern label must be included (eg. PATTERN_LABEL %{PATTERN:field} ...)"); + + GrokValidation grokValidation = new GrokValidation(); + grokValidation.setResults(new HashMap<>()); + grokValidation.setSampleData("asdf asdf"); + grokValidation.setStatement(""); + + grokService.validateGrokStatement(grokValidation); + } + + @Test + public void validateGrokStatementShouldThrowExceptionWithNullStringAsStatement() throws Exception { + exception.expect(RestException.class); + exception.expectMessage("A pattern label must be included (eg. PATTERN_LABEL %{PATTERN:field} ...)"); + + GrokValidation grokValidation = new GrokValidation(); + grokValidation.setResults(new HashMap<>()); + grokValidation.setSampleData("asdf asdf"); + grokValidation.setStatement(null); + + grokService.validateGrokStatement(grokValidation); + } + + @Test + public void validateGrokStatementShouldProperlyMatchSampleDataAgainstGivenStatement() throws Exception { + GrokValidation grokValidation = new GrokValidation(); + grokValidation.setResults(new HashMap<>()); + grokValidation.setSampleData("asdf asdf"); + grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + + GrokValidation expectedGrokValidation = new GrokValidation(); + expectedGrokValidation.setResults(new HashMap() {{ put("word1", "asdf"); put("word2", "asdf"); }}); + expectedGrokValidation.setSampleData("asdf asdf"); + expectedGrokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + + assertEquals(expectedGrokValidation, grokService.validateGrokStatement(grokValidation)); + } + + @Test + public void validateGrokStatementShouldProperlyMatchNothingAgainstEmptyString() throws Exception { + GrokValidation grokValidation = new GrokValidation(); + grokValidation.setResults(new HashMap<>()); + grokValidation.setSampleData(""); + grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + + GrokValidation expectedGrokValidation = new GrokValidation(); + expectedGrokValidation.setResults(new HashMap<>()); + expectedGrokValidation.setSampleData(""); + expectedGrokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + + assertEquals(expectedGrokValidation, grokService.validateGrokStatement(grokValidation)); + } + + @Test + public void validateGrokStatementShouldProperlyMatchNothingAgainstNullString() throws Exception { + GrokValidation grokValidation = new GrokValidation(); + grokValidation.setResults(new HashMap<>()); + grokValidation.setSampleData(null); + grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + + GrokValidation expectedGrokValidation = new GrokValidation(); + expectedGrokValidation.setResults(new HashMap<>()); + expectedGrokValidation.setSampleData(null); + expectedGrokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + + assertEquals(expectedGrokValidation, grokService.validateGrokStatement(grokValidation)); + } + + @Test + public void invalidGrokStatementShouldThrowRestException() throws Exception { + exception.expect(RestException.class); + + GrokValidation grokValidation = new GrokValidation(); + grokValidation.setResults(new HashMap<>()); + grokValidation.setSampleData(null); + grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2"); + + grokService.validateGrokStatement(grokValidation); + } +} \ No newline at end of file diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplTest.java similarity index 94% rename from metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java rename to metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplTest.java index f7e43ab0cc..d67892eae8 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/HdfsServiceTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplTest.java @@ -15,13 +15,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.metron.rest.service; +package org.apache.metron.rest.service.impl; import org.apache.commons.io.FileUtils; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; import org.apache.metron.rest.config.HadoopConfig; -import org.apache.metron.rest.service.impl.HdfsServiceImpl; +import org.apache.metron.rest.service.HdfsService; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -40,9 +40,9 @@ import static org.junit.Assert.fail; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes={HadoopConfig.class, HdfsServiceTest.HdfsServiceTestContextConfiguration.class}) +@ContextConfiguration(classes={HadoopConfig.class, HdfsServiceImplTest.HdfsServiceTestContextConfiguration.class}) @ActiveProfiles(TEST_PROFILE) -public class HdfsServiceTest { +public class HdfsServiceImplTest { @Configuration @Profile("test") diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java new file mode 100644 index 0000000000..0aa8dbbe12 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java @@ -0,0 +1,275 @@ +package org.apache.metron.rest.service.impl; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import kafka.admin.AdminOperationException; +import kafka.admin.AdminUtils$; +import kafka.admin.RackAwareMode; +import kafka.utils.ZkUtils; +import org.apache.kafka.clients.consumer.ConsumerRecord; +import org.apache.kafka.clients.consumer.ConsumerRecords; +import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.common.Node; +import org.apache.kafka.common.PartitionInfo; +import org.apache.kafka.common.TopicPartition; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.model.KafkaTopic; +import org.apache.metron.rest.service.KafkaService; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PowerMockIgnore; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; +import static org.powermock.api.mockito.PowerMockito.mock; + +@SuppressWarnings("unchecked") +@RunWith(PowerMockRunner.class) +@PowerMockIgnore("javax.management.*") // resolve classloader conflict +@PrepareForTest({AdminUtils$.class}) +public class KafkaServiceImplTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); + + private ZkUtils zkUtils; + private KafkaConsumer kafkaConsumer; + private AdminUtils$ adminUtils; + + private KafkaService kafkaService; + + private static final KafkaTopic VALID_KAFKA_TOPIC = new KafkaTopic() {{ + setReplicationFactor(2); + setNumPartitions(1); + setName("t"); + setProperties(new Properties()); + }}; + + @SuppressWarnings("unchecked") + @Before + public void setUp() throws Exception { + zkUtils = mock(ZkUtils.class); + kafkaConsumer = mock(KafkaConsumer.class); + adminUtils = mock(AdminUtils$.class); + + kafkaService = new KafkaServiceImpl(zkUtils, kafkaConsumer, adminUtils); + } + + @Test + public void listTopicsHappyPathWithListTopicsReturningNull() throws Exception { + final Map> topics = null; + + when(kafkaConsumer.listTopics()).thenReturn(topics); + + final Set listedTopics = kafkaService.listTopics(); + + assertEquals(Sets.newHashSet(), listedTopics); + + verifyZeroInteractions(zkUtils); + verify(kafkaConsumer).listTopics(); + verifyNoMoreInteractions(kafkaConsumer, zkUtils, adminUtils); + } + + @Test + public void listTopicsHappyPathWithListTopicsReturningEmptyMap() throws Exception { + final Map> topics = new HashMap<>(); + + when(kafkaConsumer.listTopics()).thenReturn(topics); + + final Set listedTopics = kafkaService.listTopics(); + + assertEquals(Sets.newHashSet(), listedTopics); + + verifyZeroInteractions(zkUtils); + verify(kafkaConsumer).listTopics(); + verifyNoMoreInteractions(kafkaConsumer, zkUtils); + } + + @Test + public void listTopicsHappyPath() throws Exception { + final Map> topics = new HashMap<>(); + topics.put("topic1", Lists.newArrayList()); + topics.put("topic2", Lists.newArrayList()); + topics.put("topic3", Lists.newArrayList()); + + when(kafkaConsumer.listTopics()).thenReturn(topics); + + final Set listedTopics = kafkaService.listTopics(); + + assertEquals(Sets.newHashSet("topic1", "topic2", "topic3"), listedTopics); + + verifyZeroInteractions(zkUtils); + verify(kafkaConsumer).listTopics(); + verifyNoMoreInteractions(kafkaConsumer, zkUtils); + } + + @Test + public void listTopicsShouldProperlyRemoveOffsetTopic() throws Exception { + final Map> topics = new HashMap<>(); + topics.put("topic1", Lists.newArrayList()); + topics.put("topic2", Lists.newArrayList()); + topics.put("topic3", Lists.newArrayList()); + topics.put("__consumer_offsets", Lists.newArrayList()); + + when(kafkaConsumer.listTopics()).thenReturn(topics); + + final Set listedTopics = kafkaService.listTopics(); + + assertEquals(Sets.newHashSet("topic1", "topic2", "topic3"), listedTopics); + + verifyZeroInteractions(zkUtils); + verify(kafkaConsumer).listTopics(); + verifyNoMoreInteractions(kafkaConsumer, zkUtils); + } + + @Test + public void deletingTopicThatDoesNotExistShouldReturnFalse() throws Exception { + when(kafkaConsumer.listTopics()).thenReturn(Maps.newHashMap()); + + assertFalse(kafkaService.deleteTopic("non_existent_topic")); + + verifyZeroInteractions(zkUtils); + verify(kafkaConsumer).listTopics(); + verifyNoMoreInteractions(kafkaConsumer, zkUtils); + } + + @Test + public void deletingTopicThatExistShouldReturnTrue() throws Exception { + final Map> topics = new HashMap<>(); + topics.put("non_existent_topic", Lists.newArrayList()); + + when(kafkaConsumer.listTopics()).thenReturn(topics); + + assertTrue(kafkaService.deleteTopic("non_existent_topic")); + + verify(kafkaConsumer).listTopics(); + verify(adminUtils).deleteTopic(zkUtils, "non_existent_topic"); + verifyNoMoreInteractions(kafkaConsumer); + } + + @Test + public void makeSureDeletingTopicReturnsFalseWhenNoTopicsExist() throws Exception { + final Map> topics = null; + + when(kafkaConsumer.listTopics()).thenReturn(topics); + + assertFalse(kafkaService.deleteTopic("non_existent_topic")); + + verify(kafkaConsumer).listTopics(); + verifyNoMoreInteractions(kafkaConsumer); + } + + @Test + public void getTopicShouldProperlyMapTopicToKafkaTopic() throws Exception { + final PartitionInfo partitionInfo = mock(PartitionInfo.class); + when(partitionInfo.replicas()).thenReturn(new Node[] {new Node(1, "host", 8080)}); + + final Map> topics = new HashMap<>(); + topics.put("t", Lists.newArrayList(partitionInfo)); + topics.put("t1", Lists.newArrayList()); + + final KafkaTopic expected = new KafkaTopic(); + expected.setName("t"); + expected.setNumPartitions(1); + expected.setReplicationFactor(1); + + when(kafkaConsumer.listTopics()).thenReturn(topics); + when(kafkaConsumer.partitionsFor("t")).thenReturn(Lists.newArrayList(partitionInfo)); + + assertEquals(expected, kafkaService.getTopic("t")); + } + + @Test + public void getTopicShouldProperlyHandleTopicsThatDontExist() throws Exception { + final Map> topics = new HashMap<>(); + topics.put("t1", Lists.newArrayList()); + + when(kafkaConsumer.listTopics()).thenReturn(topics); + when(kafkaConsumer.partitionsFor("t")).thenReturn(Lists.newArrayList()); + + assertEquals(null, kafkaService.getTopic("t")); + + verify(kafkaConsumer).listTopics(); + verify(kafkaConsumer, times(0)).partitionsFor("t"); + verifyZeroInteractions(zkUtils); + verifyNoMoreInteractions(kafkaConsumer); + } + + @Test + public void createTopicShouldFailIfReplicationFactorIsGreaterThanAvailableBrokers() throws Exception { + final Map> topics = new HashMap<>(); + + when(kafkaConsumer.listTopics()).thenReturn(topics); + + kafkaService.createTopic(VALID_KAFKA_TOPIC); + + verify(adminUtils).createTopic(eq(zkUtils), eq("t"), eq(1), eq(2), eq(new Properties()), eq(RackAwareMode.Disabled$.MODULE$)); + verify(kafkaConsumer).listTopics(); + verifyZeroInteractions(zkUtils); + } + + @Test + public void whenAdminUtilsThrowsAdminOperationExceptionCreateTopicShouldProperlyWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + final Map> topics = new HashMap<>(); + topics.put("1", new ArrayList<>()); + + when(kafkaConsumer.listTopics()).thenReturn(topics); + + doThrow(AdminOperationException.class).when(adminUtils).createTopic(eq(zkUtils), eq("t"), eq(1), eq(2), eq(new Properties()), eq(RackAwareMode.Disabled$.MODULE$)); + + kafkaService.createTopic(VALID_KAFKA_TOPIC); + } + + @Test + public void getSampleMessageProperlyReturnsAMessageFromAGivenKafkaTopic() throws Exception { + final String topicName = "t"; + final Node host = new Node(1, "host", 8080); + final Node[] replicas = {host}; + final List partitionInfo = Lists.newArrayList(new PartitionInfo(topicName, 1, host, replicas, replicas)); + final TopicPartition topicPartition = new TopicPartition(topicName, 1); + final List topicPartitions = Lists.newArrayList(topicPartition); + final Set topicPartitionsSet = Sets.newHashSet(topicPartitions); + final ConsumerRecords records = new ConsumerRecords<>(new HashMap>>() {{ + put(topicPartition, Lists.newArrayList(new ConsumerRecord<>(topicName, 1, 1, "k", "message"))); + }}); + + when(kafkaConsumer.listTopics()).thenReturn(new HashMap>() {{ put(topicName, Lists.newArrayList()); }}); + when(kafkaConsumer.partitionsFor(eq(topicName))).thenReturn(partitionInfo); + when(kafkaConsumer.assignment()).thenReturn(topicPartitionsSet); + when(kafkaConsumer.position(topicPartition)).thenReturn(1L); + when(kafkaConsumer.poll(100)).thenReturn(records); + + assertEquals("message", kafkaService.getSampleMessage(topicName)); + + verify(kafkaConsumer).assign(eq(topicPartitions)); + verify(kafkaConsumer).assignment(); + verify(kafkaConsumer).poll(100); + verify(kafkaConsumer).unsubscribe(); + verify(kafkaConsumer, times(2)).position(topicPartition); + verify(kafkaConsumer).seek(topicPartition, 0); + + verifyZeroInteractions(zkUtils, adminUtils); + } +} From 8ea6ae57739226d80a97bf849f80cc3c2a7ebac4 Mon Sep 17 00:00:00 2001 From: JJ Date: Mon, 30 Jan 2017 06:27:43 -0600 Subject: [PATCH 37/54] METRON-503: Updated DockerStormCLIWrapper to mock all process builders. --- .../service/impl/DockerStormCLIWrapper.java | 22 +++++----- .../impl/DockerStormCLIWrapperTest.java | 41 ++++++++++++++++--- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java index 23791ac6f3..059afd781c 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapper.java @@ -35,29 +35,29 @@ public class DockerStormCLIWrapper extends StormCLIWrapper { private Environment environment; @Autowired - public DockerStormCLIWrapper(Environment environment) { + public DockerStormCLIWrapper(final Environment environment) { this.environment = environment; } @Override - protected ProcessBuilder getProcessBuilder(String... command) { - String[] dockerCommand = {"docker-compose", "-f", environment.getProperty("docker.compose.path"), "-p", "metron", "exec", "storm"}; - ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(dockerCommand, command)); - Map pbEnvironment = pb.environment(); + protected ProcessBuilder getProcessBuilder(final String... command) { + final String[] dockerCommand = {"docker-compose", "-f", environment.getProperty("docker.compose.path"), "-p", "metron", "exec", "storm"}; + final ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(dockerCommand, command)); + final Map pbEnvironment = pb.environment(); pbEnvironment.put("METRON_VERSION", environment.getProperty("metron.version")); setDockerEnvironment(pbEnvironment); return pb; } - private void setDockerEnvironment(Map environmentVariables) { - ProcessBuilder pb = getDockerEnvironmentProcessBuilder(); + private void setDockerEnvironment(final Map environmentVariables) { + final ProcessBuilder pb = getDockerEnvironmentProcessBuilder(); try { - Process process = pb.start(); - BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream())); + final Process process = pb.start(); + final BufferedReader inputStream = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; - while((line = inputStream.readLine()) != null) { + while ((line = inputStream.readLine()) != null) { if (line.startsWith("export")) { - String[] parts = line.replaceFirst("export ", "").split("="); + final String[] parts = line.replaceFirst("export ", "").split("="); environmentVariables.put(parts[0], parts[1].replaceAll("\"", "")); } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java index 964a5884e0..50940af2d6 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java @@ -2,18 +2,34 @@ import org.junit.Before; import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.core.env.Environment; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; + import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.mockito.Matchers.anyVararg; +import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.when; +import static org.powermock.api.mockito.PowerMockito.whenNew; +@SuppressWarnings("unchecked") +@RunWith(PowerMockRunner.class) +@PrepareForTest({DockerStormCLIWrapper.class, ProcessBuilder.class}) public class DockerStormCLIWrapperTest { + private ProcessBuilder processBuilder; private Environment environment; private DockerStormCLIWrapper dockerStormCLIWrapper; @Before public void setUp() throws Exception { + processBuilder = mock(ProcessBuilder.class); environment = mock(Environment.class); dockerStormCLIWrapper = new DockerStormCLIWrapper(environment); @@ -21,17 +37,30 @@ public void setUp() throws Exception { @Test public void getProcessBuilderShouldProperlyGenerateProcessorBuilder() throws Exception { - ProcessBuilder expectedProcessBuilder = new ProcessBuilder("docker-compose", "-f", "/test", "-p", "metron", "exec", "storm", "oo", "ooo"); - expectedProcessBuilder.environment().put("METRON_VERSION", "1"); + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + when(processBuilder.environment()).thenReturn(new HashMap<>()); + when(processBuilder.command()).thenReturn(new ArrayList<>()); + Process process = mock(Process.class); + InputStream inputStream = new InputStream() { + @Override + public int read() throws IOException { + return -1; + } + }; + when(processBuilder.start()).thenReturn(process); + when(process.getInputStream()).thenReturn(inputStream); when(environment.getProperty("docker.compose.path")).thenReturn("/test"); when(environment.getProperty("metron.version")).thenReturn("1"); ProcessBuilder actualBuilder = dockerStormCLIWrapper.getProcessBuilder("oo", "ooo"); - assertEquals(expectedProcessBuilder.environment(), actualBuilder.environment()); - assertEquals(expectedProcessBuilder.command(), actualBuilder.command()); + assertEquals(new HashMap() {{ put("METRON_VERSION", "1"); }}, actualBuilder.environment()); + assertEquals(new ArrayList<>(), actualBuilder.command()); + + verify(process).waitFor(); } } \ No newline at end of file From e46a0f19b375a785aae70e45d263d62d1fd5d31b Mon Sep 17 00:00:00 2001 From: JJ Date: Mon, 30 Jan 2017 06:52:25 -0600 Subject: [PATCH 38/54] Added license to newly created tests. --- .../service/impl/DockerStormCLIWrapperTest.java | 17 +++++++++++++++++ .../impl/GlobalConfigServiceImplTest.java | 17 +++++++++++++++++ .../rest/service/impl/GrokServiceImplTest.java | 17 +++++++++++++++++ .../rest/service/impl/KafkaServiceImplTest.java | 17 +++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java index 50940af2d6..1217bcb2fb 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.metron.rest.service.impl; import org.junit.Before; diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImplTest.java index 0d96de907a..59d595739d 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImplTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/GlobalConfigServiceImplTest.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.metron.rest.service.impl; import org.apache.curator.framework.CuratorFramework; 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 f4def72044..7fc8748afd 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 @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.metron.rest.service.impl; import oi.thekraken.grok.api.Grok; diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java index 0aa8dbbe12..b211ee6f6b 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.metron.rest.service.impl; import com.google.common.collect.Lists; From 45f94a812ed166858999a2a5354e2e3962c60b7b Mon Sep 17 00:00:00 2001 From: JJ Date: Mon, 30 Jan 2017 11:56:57 -0600 Subject: [PATCH 39/54] Updated test config to create necessary admin utils class for kafka. Fixed typo/grammar in grok test. --- .../java/org/apache/metron/rest/config/TestConfig.java | 8 ++++++-- .../rest/controller/GrokControllerIntegrationTest.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java index 7931fe6509..edfd5427e4 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/config/TestConfig.java @@ -17,7 +17,7 @@ */ package org.apache.metron.rest.config; -import com.google.common.base.Function; +import kafka.admin.AdminUtils$; import kafka.utils.ZKStringSerializer$; import kafka.utils.ZkUtils; import org.I0Itec.zkclient.ZkClient; @@ -38,7 +38,6 @@ import org.springframework.context.annotation.Profile; import org.springframework.web.client.RestTemplate; -import javax.annotation.Nullable; import java.util.Properties; import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; @@ -121,4 +120,9 @@ public RestTemplate restTemplate(StormCLIWrapper stormCLIClientWrapper) { restTemplate.setMockStormCLIClientWrapper((MockStormCLIClientWrapper) stormCLIClientWrapper); return restTemplate; } + + @Bean + public AdminUtils$ adminUtils() { + return AdminUtils$.MODULE$; + } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java index e618d48618..45326164cb 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java @@ -105,7 +105,7 @@ public void test() throws Exception { .andExpect(status().isInternalServerError()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.responseCode").value(500)) - .andExpect(jsonPath("$.message").value("A pattern label must be included (ex. PATTERN_LABEL ${PATTERN:field} ...)")); + .andExpect(jsonPath("$.message").value("A pattern label must be included (eg. PATTERN_LABEL %{PATTERN:field} ...)")); this.mockMvc.perform(get(grokUrl + "/list").with(httpBasic(user,password))) .andExpect(status().isOk()) From a03f78c9ab8e574834593fc0e0516f2cd425abe0 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Tue, 31 Jan 2017 17:06:32 -0600 Subject: [PATCH 40/54] Added several new tests and refactored SensorParserConfigService to remove handling of Grok special cases --- .../rest/model/ParseMessageRequest.java | 9 + .../metron/rest/model/TopologyResponse.java | 18 + .../metron/rest/model/TopologyStatus.java | 28 +- .../metron/rest/model/TopologySummary.java | 17 + .../metron/rest/service/GrokService.java | 3 + .../service/SensorParserConfigService.java | 3 + .../rest/service/impl/GrokServiceImpl.java | 42 ++- .../SensorEnrichmentConfigServiceImpl.java | 8 +- .../impl/SensorIndexingConfigServiceImpl.java | 8 +- .../impl/SensorParserConfigServiceImpl.java | 141 +------ .../service/impl/StormAdminServiceImpl.java | 13 +- .../rest/service/impl/StormCLIWrapper.java | 6 +- .../service/impl/StormStatusServiceImpl.java | 8 +- ...ParserConfigControllerIntegrationTest.java | 31 +- .../rest/service/SensorParserConfigTest.java | 116 ------ .../impl/DockerStormCLIWrapperTest.java | 14 +- .../service/impl/GrokServiceImplTest.java | 111 ++++-- .../service/impl/KafkaServiceImplTest.java | 4 +- ...SensorEnrichmentConfigServiceImplTest.java | 256 +++++++++++++ .../SensorIndexingConfigServiceImplTest.java | 234 ++++++++++++ .../SensorParserConfigServiceImplTest.java | 344 ++++++++++++++++++ .../impl/StormAdminServiceImplTest.java | 156 ++++++++ .../service/impl/StormCliWrapperTest.java | 216 +++++++++++ .../impl/StormStatusServiceImplTest.java | 221 +++++++++++ 24 files changed, 1692 insertions(+), 315 deletions(-) delete mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImplTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImplTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImplTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormAdminServiceImplTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormStatusServiceImplTest.java diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java index 8dfe17b695..50eb88de99 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/ParseMessageRequest.java @@ -22,6 +22,7 @@ public class ParseMessageRequest { private SensorParserConfig sensorParserConfig; + private String grokStatement; private String sampleData; public SensorParserConfig getSensorParserConfig() { @@ -32,6 +33,14 @@ public void setSensorParserConfig(SensorParserConfig sensorParserConfig) { this.sensorParserConfig = sensorParserConfig; } + public String getGrokStatement() { + return grokStatement; + } + + public void setGrokStatement(String grokStatement) { + this.grokStatement = grokStatement; + } + public String getSampleData() { return sampleData; } diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java index 6894e89821..0ad2e9f487 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyResponse.java @@ -39,4 +39,22 @@ public void setErrorMessage(String message) { this.status = TopologyResponseCode.ERROR; this.message = message; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + TopologyResponse that = (TopologyResponse) o; + + if (status != null ? !status.equals(that.status) : that.status != null) return false; + return message != null ? message.equals(that.message) : that.message == null; + } + + @Override + public int hashCode() { + int result = status != null ? status.hashCode() : 0; + result = 31 * result + (message != null ? message.hashCode() : 0); + return result; + } } diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyStatus.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyStatus.java index 0e2d28a40d..6fc1c019fe 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyStatus.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologyStatus.java @@ -26,8 +26,8 @@ public class TopologyStatus { private String name; private TopologyStatusCode status; private Map[] topologyStats; - private double latency = 0; - private double throughput = 0; + private Double latency = 0.0; + private Double throughput = 0.0; public String getId() { return id; @@ -73,4 +73,28 @@ public void setTopologyStats(List> topologyStats) { } } } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + TopologyStatus that = (TopologyStatus) o; + + if (id != null ? !id.equals(that.id) : that.id != null) return false; + if (name != null ? !name.equals(that.name) : that.name != null) return false; + if (status != null ? !status.equals(that.status) : that.status != null) return false; + if (!latency.equals(that.latency)) return false; + return throughput.equals(that.throughput); + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (status != null ? status.hashCode() : 0); + result = 31 * result + (latency != null ? latency.hashCode() : 0); + result = 31 * result + (throughput != null ? throughput.hashCode() : 0); + return result; + } } diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java index b9d39a491e..8621daf19c 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TopologySummary.java @@ -17,6 +17,8 @@ */ package org.apache.metron.rest.model; +import java.util.Arrays; + public class TopologySummary { private TopologyStatus[] topologies; @@ -31,4 +33,19 @@ public TopologyStatus[] getTopologies() { public void setTopologies(TopologyStatus[] topologies) { this.topologies = topologies; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + TopologySummary that = (TopologySummary) o; + + return topologies != null ? Arrays.equals(topologies, that.topologies) : that.topologies != null; + } + + @Override + public int hashCode() { + return topologies != null ? Arrays.hashCode(topologies) : 0; + } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java index 95ce1ba4ad..268d396077 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/GrokService.java @@ -20,6 +20,7 @@ import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.GrokValidation; +import java.io.File; import java.util.Map; public interface GrokService { @@ -28,4 +29,6 @@ public interface GrokService { GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException; + File saveTemporary(String statement, String name) throws RestException; + } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java index efda639b97..9b863b8f6a 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/SensorParserConfigService.java @@ -22,6 +22,7 @@ import org.apache.metron.rest.model.ParseMessageRequest; import org.json.simple.JSONObject; +import java.util.List; import java.util.Map; public interface SensorParserConfigService { @@ -32,6 +33,8 @@ public interface SensorParserConfigService { Iterable getAll() throws RestException; + List getAllTypes() throws RestException; + boolean delete(String name) throws RestException; Map getAvailableParsers(); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java index 323ca78002..e69d1b4665 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java @@ -20,22 +20,35 @@ import oi.thekraken.grok.api.Grok; import oi.thekraken.grok.api.Match; import org.apache.directory.api.util.Strings; +import org.apache.hadoop.fs.Path; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.GrokValidation; import org.apache.metron.rest.service.GrokService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.io.InputStreamReader; import java.io.StringReader; import java.util.Map; +import static org.apache.metron.rest.MetronRestConstants.GROK_TEMP_PATH_SPRING_PROPERTY; + @Service public class GrokServiceImpl implements GrokService { + + private Environment environment; + private Grok commonGrok; @Autowired - public GrokServiceImpl(Grok commonGrok) { + public GrokServiceImpl(Environment environment, Grok commonGrok) { + this.environment = environment; this.commonGrok = commonGrok; } @@ -69,4 +82,31 @@ public GrokValidation validateGrokStatement(GrokValidation grokValidation) throw return grokValidation; } + @Override + public File saveTemporary(String statement, String name) throws RestException { + if (statement != null) { + try { + File grokDirectory = new File(getTemporaryGrokRootPath()); + if (!grokDirectory.exists()) { + grokDirectory.mkdirs(); + } + File path = new File(grokDirectory, name); + FileWriter fileWriter = new FileWriter(new File(grokDirectory, name)); + fileWriter.write(statement); + fileWriter.close(); + return path; + } catch (IOException e) { + throw new RestException(e); + } + } else { + throw new RestException("A grokStatement must be provided"); + } + } + + private String getTemporaryGrokRootPath() { + String grokTempPath = environment.getProperty(GROK_TEMP_PATH_SPRING_PROPERTY); + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + return new Path(grokTempPath, authentication.getName()).toString(); + } + } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java index 8b3dbb7e88..2bfef89ce4 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImpl.java @@ -36,12 +36,16 @@ @Service public class SensorEnrichmentConfigServiceImpl implements SensorEnrichmentConfigService { - @Autowired private ObjectMapper objectMapper; - @Autowired private CuratorFramework client; + @Autowired + public SensorEnrichmentConfigServiceImpl(ObjectMapper objectMapper, CuratorFramework client) { + this.objectMapper = objectMapper; + this.client = client; + } + @Override public SensorEnrichmentConfig save(String name, SensorEnrichmentConfig sensorEnrichmentConfig) throws RestException { try { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java index ab46418161..9f984e0021 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImpl.java @@ -38,12 +38,16 @@ @Service public class SensorIndexingConfigServiceImpl implements SensorIndexingConfigService { - @Autowired private ObjectMapper objectMapper; - @Autowired private CuratorFramework client; + @Autowired + public SensorIndexingConfigServiceImpl(ObjectMapper objectMapper, CuratorFramework client) { + this.objectMapper = objectMapper; + this.client = client; + } + @Override public Map save(String name, Map sensorIndexingConfig) throws RestException { try { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java index cb88708adc..eddfc8d74d 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImpl.java @@ -17,10 +17,8 @@ */ package org.apache.metron.rest.service.impl; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.curator.framework.CuratorFramework; -import org.apache.hadoop.fs.Path; import org.apache.metron.common.configuration.ConfigurationType; import org.apache.metron.common.configuration.ConfigurationsUtils; import org.apache.metron.common.configuration.SensorParserConfig; @@ -28,20 +26,15 @@ import org.apache.metron.rest.MetronRestConstants; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.ParseMessageRequest; -import org.apache.metron.rest.service.HdfsService; +import org.apache.metron.rest.service.GrokService; import org.apache.metron.rest.service.SensorParserConfigService; import org.apache.zookeeper.KeeperException; import org.json.simple.JSONObject; import org.reflections.Reflections; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import java.io.File; -import java.io.FileWriter; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -49,72 +42,40 @@ import java.util.Set; import static org.apache.metron.rest.MetronRestConstants.GROK_CLASS_NAME; -import static org.apache.metron.rest.MetronRestConstants.GROK_DEFAULT_PATH_SPRING_PROPERTY; -import static org.apache.metron.rest.MetronRestConstants.GROK_PATH_KEY; -import static org.apache.metron.rest.MetronRestConstants.GROK_PATTERN_LABEL_KEY; -import static org.apache.metron.rest.MetronRestConstants.GROK_STATEMENT_KEY; -import static org.apache.metron.rest.MetronRestConstants.GROK_TEMP_PATH_SPRING_PROPERTY; @Service public class SensorParserConfigServiceImpl implements SensorParserConfigService { - @Autowired - private Environment environment; - - @Autowired private ObjectMapper objectMapper; private CuratorFramework client; + private GrokService grokService; + @Autowired - public void setClient(CuratorFramework client) { + public SensorParserConfigServiceImpl(ObjectMapper objectMapper, CuratorFramework client, GrokService grokService) { + this.objectMapper = objectMapper; this.client = client; + this.grokService = grokService; } - @Autowired - private HdfsService hdfsService; - private Map availableParsers; @Override public SensorParserConfig save(SensorParserConfig sensorParserConfig) throws RestException { - String serializedConfig; - if (isGrokConfig(sensorParserConfig)) { - addGrokPathToConfig(sensorParserConfig); - sensorParserConfig.getParserConfig().putIfAbsent(MetronRestConstants.GROK_PATTERN_LABEL_KEY, sensorParserConfig.getSensorTopic().toUpperCase()); - String statement = (String) sensorParserConfig.getParserConfig().remove(MetronRestConstants.GROK_STATEMENT_KEY); - serializedConfig = serialize(sensorParserConfig); - sensorParserConfig.getParserConfig().put(MetronRestConstants.GROK_STATEMENT_KEY, statement); - saveGrokStatement(sensorParserConfig); - } else { - serializedConfig = serialize(sensorParserConfig); - } try { - ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), serializedConfig.getBytes(), client); + ConfigurationsUtils.writeSensorParserConfigToZookeeper(sensorParserConfig.getSensorTopic(), objectMapper.writeValueAsString(sensorParserConfig).getBytes(), client); } catch (Exception e) { throw new RestException(e); } return sensorParserConfig; } - private String serialize(SensorParserConfig sensorParserConfig) throws RestException { - String serializedConfig; - try { - serializedConfig = objectMapper.writeValueAsString(sensorParserConfig); - } catch (JsonProcessingException e) { - throw new RestException("Could not serialize SensorParserConfig", "Could not serialize " + sensorParserConfig.toString(), e.getCause()); - } - return serializedConfig; - } - @Override public SensorParserConfig findOne(String name) throws RestException { SensorParserConfig sensorParserConfig; try { sensorParserConfig = ConfigurationsUtils.readSensorParserConfigFromZookeeper(name, client); - if (isGrokConfig(sensorParserConfig)) { - addGrokStatementToConfig(sensorParserConfig); - } } catch (KeeperException.NoNodeException e) { return null; } catch (Exception e) { @@ -145,7 +106,8 @@ public boolean delete(String name) throws RestException { return true; } - private List getAllTypes() throws RestException { + @Override + public List getAllTypes() throws RestException { List types; try { types = client.getChildren().forPath(ConfigurationType.PARSER.getZookeeperRoot()); @@ -190,20 +152,21 @@ public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws R } else if (sensorParserConfig.getParserClassName() == null) { throw new RestException("SensorParserConfig must have a parserClassName"); } else { - MessageParser parser = null; + MessageParser parser; try { parser = (MessageParser) Class.forName(sensorParserConfig.getParserClassName()).newInstance(); } catch (Exception e) { throw new RestException(e.toString(), e.getCause()); } + File temporaryGrokFile = null; if (isGrokConfig(sensorParserConfig)) { - saveTemporaryGrokStatement(sensorParserConfig); - sensorParserConfig.getParserConfig().put(MetronRestConstants.GROK_PATH_KEY, new File(getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()).toString()); + temporaryGrokFile = grokService.saveTemporary(parseMessageRequest.getGrokStatement(), parseMessageRequest.getSensorParserConfig().getSensorTopic()); + sensorParserConfig.getParserConfig().put(MetronRestConstants.GROK_PATH_KEY, temporaryGrokFile.toString()); } parser.configure(sensorParserConfig.getParserConfig()); JSONObject results = parser.parse(parseMessageRequest.getSampleData().getBytes()).get(0); - if (isGrokConfig(sensorParserConfig)) { - deleteTemporaryGrokStatement(sensorParserConfig); + if (isGrokConfig(sensorParserConfig) && temporaryGrokFile != null) { + temporaryGrokFile.delete(); } return results; } @@ -212,78 +175,4 @@ public JSONObject parseMessage(ParseMessageRequest parseMessageRequest) throws R private boolean isGrokConfig(SensorParserConfig sensorParserConfig) { return GROK_CLASS_NAME.equals(sensorParserConfig.getParserClassName()); } - - private void addGrokStatementToConfig(SensorParserConfig sensorParserConfig) throws RestException { - String grokStatement = ""; - String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); - if (grokPath != null) { - String fullGrokStatement = getGrokStatement(grokPath); - String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); - grokStatement = fullGrokStatement.replaceFirst(patternLabel + " ", ""); - } - sensorParserConfig.getParserConfig().put(GROK_STATEMENT_KEY, grokStatement); - } - - private void addGrokPathToConfig(SensorParserConfig sensorParserConfig) { - if (sensorParserConfig.getParserConfig().get(GROK_PATH_KEY) == null) { - String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); - if (grokStatement != null) { - sensorParserConfig.getParserConfig().put(GROK_PATH_KEY, - new Path(environment.getProperty(GROK_DEFAULT_PATH_SPRING_PROPERTY), sensorParserConfig.getSensorTopic()).toString()); - } - } - } - - private String getGrokStatement(String path) throws RestException { - try { - return new String(hdfsService.read(new Path(path))); - } catch (IOException e) { - throw new RestException(e); - } - } - - private void saveGrokStatement(SensorParserConfig sensorParserConfig) throws RestException { - saveGrokStatement(sensorParserConfig, false); - } - - private void saveTemporaryGrokStatement(SensorParserConfig sensorParserConfig) throws RestException { - saveGrokStatement(sensorParserConfig, true); - } - - private void saveGrokStatement(SensorParserConfig sensorParserConfig, boolean isTemporary) throws RestException { - String patternLabel = (String) sensorParserConfig.getParserConfig().get(GROK_PATTERN_LABEL_KEY); - String grokPath = (String) sensorParserConfig.getParserConfig().get(GROK_PATH_KEY); - String grokStatement = (String) sensorParserConfig.getParserConfig().get(GROK_STATEMENT_KEY); - if (grokStatement != null) { - String fullGrokStatement = patternLabel + " " + grokStatement; - try { - if (!isTemporary) { - hdfsService.write(new Path(grokPath), fullGrokStatement.getBytes()); - } else { - File grokDirectory = new File(getTemporaryGrokRootPath()); - if (!grokDirectory.exists()) { - grokDirectory.mkdirs(); - } - FileWriter fileWriter = new FileWriter(new File(grokDirectory, sensorParserConfig.getSensorTopic())); - fileWriter.write(fullGrokStatement); - fileWriter.close(); - } - } catch (IOException e) { - throw new RestException(e); - } - } else { - throw new RestException("A grokStatement must be provided"); - } - } - - private void deleteTemporaryGrokStatement(SensorParserConfig sensorParserConfig) { - File file = new File(getTemporaryGrokRootPath(), sensorParserConfig.getSensorTopic()); - file.delete(); - } - - private String getTemporaryGrokRootPath() { - String grokTempPath = environment.getProperty(GROK_TEMP_PATH_SPRING_PROPERTY); - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - return new Path(grokTempPath, authentication.getName()).toString(); - } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java index cb7c449ab1..9bd368ff4c 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormAdminServiceImpl.java @@ -33,16 +33,17 @@ public class StormAdminServiceImpl implements StormAdminService { private StormCLIWrapper stormCLIClientWrapper; + private GlobalConfigService globalConfigService; + + private SensorParserConfigService sensorParserConfigService; + @Autowired - public void setStormCLIClientWrapper(StormCLIWrapper stormCLIClientWrapper) { + public StormAdminServiceImpl(StormCLIWrapper stormCLIClientWrapper, GlobalConfigService globalConfigService, SensorParserConfigService sensorParserConfigService) { this.stormCLIClientWrapper = stormCLIClientWrapper; + this.globalConfigService = globalConfigService; + this.sensorParserConfigService = sensorParserConfigService; } - @Autowired - private GlobalConfigService globalConfigService; - - @Autowired - private SensorParserConfigService sensorParserConfigService; @Override public TopologyResponse startParserTopology(String name) throws RestException { diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormCLIWrapper.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormCLIWrapper.java index a47251509e..c5569c59c1 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormCLIWrapper.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormCLIWrapper.java @@ -35,9 +35,13 @@ public class StormCLIWrapper { - @Autowired private Environment environment; + @Autowired + public void setEnvironment(final Environment environment) { + this.environment = environment; + } + public int startParserTopology(String name) throws RestException { return runCommand(getParserStartCommand(name)); } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java index 280d72aa5d..a02ee755ca 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StormStatusServiceImpl.java @@ -38,12 +38,16 @@ @Service public class StormStatusServiceImpl implements StormStatusService { - @Autowired private Environment environment; - @Autowired private RestTemplate restTemplate; + @Autowired + public StormStatusServiceImpl(Environment environment, RestTemplate restTemplate) { + this.environment = environment; + this.restTemplate = restTemplate; + } + @Override public TopologySummary getTopologySummary() { return restTemplate.getForObject("http://" + environment.getProperty(STORM_UI_SPRING_PROPERTY) + TOPOLOGY_SUMMARY_URL, TopologySummary.class); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java index 09b1b0afca..fad751117c 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/SensorParserConfigControllerIntegrationTest.java @@ -20,6 +20,7 @@ import org.adrianwalker.multilinestring.Multiline; import org.apache.commons.io.FileUtils; import org.apache.metron.rest.MetronRestConstants; +import org.apache.metron.rest.service.GrokService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -58,7 +59,7 @@ public class SensorParserConfigControllerIntegrationTest { "sensorTopic": "squidTest", "parserConfig": { "patternLabel": "SQUIDTEST", - "grokStatement": "%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", + "grokPath": "target/patterns/squidTest", "timestampField": "timestamp" }, "fieldTransformations" : [ @@ -76,19 +77,6 @@ public class SensorParserConfigControllerIntegrationTest { @Multiline public static String squidJson; - /** - { - "parserClassName": "org.apache.metron.parsers.GrokParser", - "sensorTopic": "squidTest", - "parserConfig": { - "patternLabel": "SQUIDTEST", - "timestampField": "timestamp" - } - } - */ - @Multiline - public static String missingGrokJson; - /** { "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", @@ -106,12 +94,12 @@ public class SensorParserConfigControllerIntegrationTest { "parserClassName": "org.apache.metron.parsers.GrokParser", "sensorTopic": "squidTest", "parserConfig": { - "grokStatement": "%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}", - "patternLabel": "SQUIDTEST", + "patternLabel": "SQUID_DELIMITED", "grokPath":"./squidTest", "timestampField": "timestamp" } }, + "grokStatement":"SQUID_DELIMITED %{NUMBER:timestamp}[^0-9]*%{INT:elapsed} %{IP:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url}[^0-9]*(%{IP:ip_dst_addr})?", "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html" } */ @@ -167,6 +155,9 @@ public class SensorParserConfigControllerIntegrationTest { @Autowired private Environment environment; + @Autowired + private GrokService grokService; + @Autowired private WebApplicationContext wac; @@ -207,7 +198,6 @@ public void test() throws Exception { .andExpect(jsonPath("$.sensorTopic").value("squidTest")) .andExpect(jsonPath("$.parserConfig.grokPath").value("target/patterns/squidTest")) .andExpect(jsonPath("$.parserConfig.patternLabel").value("SQUIDTEST")) - .andExpect(jsonPath("$.parserConfig.grokStatement").value("%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}/%{WORD:UNWANTED}")) .andExpect(jsonPath("$.parserConfig.timestampField").value("timestamp")) .andExpect(jsonPath("$.fieldTransformations[0].transformation").value("STELLAR")) .andExpect(jsonPath("$.fieldTransformations[0].output[0]").value("full_hostname")) @@ -215,12 +205,6 @@ public void test() throws Exception { .andExpect(jsonPath("$.fieldTransformations[0].config.full_hostname").value("URL_TO_HOST(url)")) .andExpect(jsonPath("$.fieldTransformations[0].config.domain_without_subdomains").value("DOMAIN_REMOVE_SUBDOMAINS(full_hostname)")); - this.mockMvc.perform(post(sensorParserConfigUrl).with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(missingGrokJson)) - .andExpect(status().isInternalServerError()) - .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) - .andExpect(jsonPath("$.responseCode").value(500)) - .andExpect(jsonPath("$.message").value("A grokStatement must be provided")); - this.mockMvc.perform(get(sensorParserConfigUrl + "/squidTest").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) @@ -228,7 +212,6 @@ public void test() throws Exception { .andExpect(jsonPath("$.sensorTopic").value("squidTest")) .andExpect(jsonPath("$.parserConfig.grokPath").value("target/patterns/squidTest")) .andExpect(jsonPath("$.parserConfig.patternLabel").value("SQUIDTEST")) - .andExpect(jsonPath("$.parserConfig.grokStatement").value("%{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}/%{WORD:UNWANTED}")) .andExpect(jsonPath("$.parserConfig.timestampField").value("timestamp")) .andExpect(jsonPath("$.fieldTransformations[0].transformation").value("STELLAR")) .andExpect(jsonPath("$.fieldTransformations[0].output[0]").value("full_hostname")) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java deleted file mode 100644 index 561548e999..0000000000 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/SensorParserConfigTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.metron.rest.service; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.curator.framework.CuratorFramework; -import org.apache.curator.framework.api.DeleteBuilder; -import org.apache.curator.framework.api.GetChildrenBuilder; -import org.apache.metron.common.configuration.ConfigurationType; -import org.apache.metron.common.configuration.ConfigurationsUtils; -import org.apache.metron.common.configuration.SensorParserConfig; -import org.apache.metron.common.utils.JSONUtils; -import org.apache.metron.rest.service.impl.SensorParserConfigServiceImpl; -import org.apache.zookeeper.KeeperException; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({ConfigurationsUtils.class}) -public class SensorParserConfigTest { - - @Mock - private GetChildrenBuilder getChildrenBuilder; - - @Mock - private DeleteBuilder deleteBuilder; - - @Mock - private ObjectMapper objectMapper; - - @Mock - private CuratorFramework client; - - @Mock - private GrokService grokService; - - @InjectMocks - private SensorParserConfigServiceImpl sensorParserConfigService; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - Mockito.when(client.getChildren()).thenReturn(getChildrenBuilder); - Mockito.when(client.delete()).thenReturn(deleteBuilder); - - } - - @Test - public void test() throws Exception { - mockStatic(ConfigurationsUtils.class); - SensorParserConfig broParserConfig = new SensorParserConfig(); - broParserConfig.setParserClassName("org.apache.metron.parsers.bro.BasicBroParser"); - broParserConfig.setSensorTopic("broTest"); - Mockito.when(objectMapper.writeValueAsString(broParserConfig)).thenReturn(new String(JSONUtils.INSTANCE.toJSON(broParserConfig))); - sensorParserConfigService.save(broParserConfig); - verifyStatic(times(1)); - ConfigurationsUtils.writeSensorParserConfigToZookeeper("broTest", JSONUtils.INSTANCE.toJSON(broParserConfig), client); - - PowerMockito.when(ConfigurationsUtils.readSensorParserConfigFromZookeeper("broTest", client)).thenReturn(broParserConfig); - assertEquals(broParserConfig, sensorParserConfigService.findOne("broTest")); - - SensorParserConfig squidParserConfig = new SensorParserConfig(); - squidParserConfig.setParserClassName("org.apache.metron.parsers.GrokParser"); - squidParserConfig.setSensorTopic("squid"); - PowerMockito.when(ConfigurationsUtils.readSensorParserConfigFromZookeeper("squidTest", client)).thenReturn(squidParserConfig); - - List allTypes = new ArrayList() {{ - add("broTest"); - add("squidTest"); - }}; - Mockito.when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())).thenReturn(allTypes); - assertEquals(new ArrayList() {{ add(broParserConfig); add(squidParserConfig); }}, sensorParserConfigService.getAll()); - - Mockito.when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())).thenThrow(new KeeperException.NoNodeException()); - assertEquals(new ArrayList<>(), sensorParserConfigService.getAll()); - - assertTrue(sensorParserConfigService.delete("broTest")); - verify(deleteBuilder, times(1)).forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/broTest"); - Mockito.when(deleteBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/broTest")).thenThrow(new KeeperException.NoNodeException()); - assertFalse(sensorParserConfigService.delete("broTest")); - } -} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java index 1217bcb2fb..bc91b91a89 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/DockerStormCLIWrapperTest.java @@ -24,7 +24,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.core.env.Environment; -import java.io.IOException; +import java.io.ByteArrayInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; @@ -60,12 +60,7 @@ public void getProcessBuilderShouldProperlyGenerateProcessorBuilder() throws Exc when(processBuilder.command()).thenReturn(new ArrayList<>()); Process process = mock(Process.class); - InputStream inputStream = new InputStream() { - @Override - public int read() throws IOException { - return -1; - } - }; + InputStream inputStream = new ByteArrayInputStream("export DOCKER_HOST=\"tcp://192.168.99.100:2376\"".getBytes()); when(processBuilder.start()).thenReturn(process); when(process.getInputStream()).thenReturn(inputStream); @@ -75,7 +70,10 @@ public int read() throws IOException { ProcessBuilder actualBuilder = dockerStormCLIWrapper.getProcessBuilder("oo", "ooo"); - assertEquals(new HashMap() {{ put("METRON_VERSION", "1"); }}, actualBuilder.environment()); + assertEquals(new HashMap() {{ + put("METRON_VERSION", "1"); + put("DOCKER_HOST", "tcp://192.168.99.100:2376"); + }}, actualBuilder.environment()); assertEquals(new ArrayList<>(), actualBuilder.command()); verify(process).waitFor(); 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 7fc8748afd..ffef9b9551 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 @@ -18,6 +18,7 @@ package org.apache.metron.rest.service.impl; import oi.thekraken.grok.api.Grok; +import org.apache.commons.io.FileUtils; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.GrokValidation; import org.apache.metron.rest.service.GrokService; @@ -25,26 +26,42 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; - +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.core.env.Environment; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.util.HashMap; import java.util.Map; +import static org.apache.metron.rest.MetronRestConstants.GROK_TEMP_PATH_SPRING_PROPERTY; import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.powermock.api.mockito.PowerMockito.when; +import static org.powermock.api.mockito.PowerMockito.whenNew; +@RunWith(PowerMockRunner.class) +@PrepareForTest({GrokServiceImpl.class, FileWriter.class}) public class GrokServiceImplTest { @Rule public final ExpectedException exception = ExpectedException.none(); + private Environment environment; private Grok grok; private GrokService grokService; @Before public void setUp() throws Exception { + environment = mock(Environment.class); grok = mock(Grok.class); - grokService = new GrokServiceImpl(grok); + grokService = new GrokServiceImpl(environment, grok); } @Test @@ -56,14 +73,18 @@ public void getCommonGrokPattersShouldCallGrokToGetPatterns() throws Exception { @Test public void getCommonGrokPattersShouldCallGrokToGetPatternsAndNotAlterValue() throws Exception { - Map patterns = new HashMap() {{ + final Map actual = new HashMap() {{ put("k", "v"); put("k1", "v1"); }}; - when(grok.getPatterns()).thenReturn(patterns); + when(grok.getPatterns()).thenReturn(actual); - assertEquals(patterns, grokService.getCommonGrokPatterns()); + Map expected = new HashMap() {{ + put("k", "v"); + put("k1", "v1"); + }}; + assertEquals(expected, grokService.getCommonGrokPatterns()); } @Test @@ -94,47 +115,49 @@ public void validateGrokStatementShouldThrowExceptionWithNullStringAsStatement() @Test public void validateGrokStatementShouldProperlyMatchSampleDataAgainstGivenStatement() throws Exception { - GrokValidation grokValidation = new GrokValidation(); + final GrokValidation grokValidation = new GrokValidation(); grokValidation.setResults(new HashMap<>()); grokValidation.setSampleData("asdf asdf"); grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); - GrokValidation expectedGrokValidation = new GrokValidation(); - expectedGrokValidation.setResults(new HashMap() {{ put("word1", "asdf"); put("word2", "asdf"); }}); - expectedGrokValidation.setSampleData("asdf asdf"); - expectedGrokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + GrokValidation expected = new GrokValidation(); + expected.setResults(new HashMap() {{ put("word1", "asdf"); put("word2", "asdf"); }}); + expected.setSampleData("asdf asdf"); + expected.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); - assertEquals(expectedGrokValidation, grokService.validateGrokStatement(grokValidation)); + GrokValidation actual = grokService.validateGrokStatement(grokValidation); + assertEquals(expected, actual); + assertEquals(expected.hashCode(), actual.hashCode()); } @Test public void validateGrokStatementShouldProperlyMatchNothingAgainstEmptyString() throws Exception { - GrokValidation grokValidation = new GrokValidation(); + final GrokValidation grokValidation = new GrokValidation(); grokValidation.setResults(new HashMap<>()); grokValidation.setSampleData(""); grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); - GrokValidation expectedGrokValidation = new GrokValidation(); - expectedGrokValidation.setResults(new HashMap<>()); - expectedGrokValidation.setSampleData(""); - expectedGrokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + GrokValidation expected = new GrokValidation(); + expected.setResults(new HashMap<>()); + expected.setSampleData(""); + expected.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); - assertEquals(expectedGrokValidation, grokService.validateGrokStatement(grokValidation)); + assertEquals(expected, grokService.validateGrokStatement(grokValidation)); } @Test public void validateGrokStatementShouldProperlyMatchNothingAgainstNullString() throws Exception { - GrokValidation grokValidation = new GrokValidation(); + final GrokValidation grokValidation = new GrokValidation(); grokValidation.setResults(new HashMap<>()); grokValidation.setSampleData(null); grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); - GrokValidation expectedGrokValidation = new GrokValidation(); - expectedGrokValidation.setResults(new HashMap<>()); - expectedGrokValidation.setSampleData(null); - expectedGrokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + GrokValidation expected = new GrokValidation(); + expected.setResults(new HashMap<>()); + expected.setSampleData(null); + expected.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); - assertEquals(expectedGrokValidation, grokService.validateGrokStatement(grokValidation)); + assertEquals(expected, grokService.validateGrokStatement(grokValidation)); } @Test @@ -148,4 +171,44 @@ public void invalidGrokStatementShouldThrowRestException() throws Exception { grokService.validateGrokStatement(grokValidation); } + + @Test + public void saveTemporaryShouldProperlySaveFile() throws Exception { + new File("./target/user1").delete(); + String statement = "grok statement"; + + Authentication authentication = mock(Authentication.class); + when(authentication.getName()).thenReturn("user1"); + SecurityContextHolder.getContext().setAuthentication(authentication); + when(environment.getProperty(GROK_TEMP_PATH_SPRING_PROPERTY)).thenReturn("./target"); + + grokService.saveTemporary(statement, "squid"); + + File testFile = new File("./target/user1/squid"); + assertEquals(statement, FileUtils.readFileToString(testFile)); + testFile.delete(); + } + + @Test + public void saveTemporaryShouldWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + String statement = "grok statement"; + + Authentication authentication = mock(Authentication.class); + when(authentication.getName()).thenReturn("user1"); + SecurityContextHolder.getContext().setAuthentication(authentication); + when(environment.getProperty(GROK_TEMP_PATH_SPRING_PROPERTY)).thenReturn("./target"); + whenNew(FileWriter.class).withParameterTypes(File.class).withArguments(any()).thenThrow(new IOException()); + + grokService.saveTemporary(statement, "squid"); + } + + @Test + public void missingGrokStatementShouldThrowRestException() throws Exception { + exception.expect(RestException.class); + exception.expectMessage("A grokStatement must be provided"); + + grokService.saveTemporary(null, "squid"); + } } \ No newline at end of file diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java index b211ee6f6b..c7d42b3164 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/KafkaServiceImplTest.java @@ -213,7 +213,9 @@ public void getTopicShouldProperlyMapTopicToKafkaTopic() throws Exception { when(kafkaConsumer.listTopics()).thenReturn(topics); when(kafkaConsumer.partitionsFor("t")).thenReturn(Lists.newArrayList(partitionInfo)); - assertEquals(expected, kafkaService.getTopic("t")); + KafkaTopic actual = kafkaService.getTopic("t"); + assertEquals(expected, actual); + assertEquals(expected.hashCode(), actual.hashCode()); } @Test 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 new file mode 100644 index 0000000000..d2929487cc --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorEnrichmentConfigServiceImplTest.java @@ -0,0 +1,256 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.adrianwalker.multilinestring.Multiline; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.api.DeleteBuilder; +import org.apache.curator.framework.api.GetChildrenBuilder; +import org.apache.curator.framework.api.GetDataBuilder; +import org.apache.curator.framework.api.SetDataBuilder; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.enrichment.EnrichmentConfig; +import org.apache.metron.common.configuration.enrichment.SensorEnrichmentConfig; +import org.apache.metron.common.configuration.enrichment.threatintel.ThreatIntelConfig; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.SensorEnrichmentConfigService; +import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.data.Stat; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@SuppressWarnings("ALL") +public class SensorEnrichmentConfigServiceImplTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); + + ObjectMapper objectMapper; + CuratorFramework curatorFramework; + SensorEnrichmentConfigService sensorEnrichmentConfigService; + + /** + { + "enrichment" : { + "fieldMap": { + "geo": ["ip_dst_addr"] + } + }, + "threatIntel": { + "fieldMap": { + "hbaseThreatIntel": ["ip_src_addr"] + }, + "fieldToTypeMap": { + "ip_src_addr" : ["malicious_ip"] + } + } + } + */ + @Multiline + public static String broJson; + + @Before + public void setUp() throws Exception { + objectMapper = mock(ObjectMapper.class); + curatorFramework = mock(CuratorFramework.class); + sensorEnrichmentConfigService = new SensorEnrichmentConfigServiceImpl(objectMapper, curatorFramework); + } + + + @Test + public void deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse() throws Exception { + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenThrow(KeeperException.NoNodeException.class); + + assertFalse(sensorEnrichmentConfigService.delete("bro")); + } + + @Test + public void deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException() throws Exception { + exception.expect(RestException.class); + + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenThrow(Exception.class); + + assertFalse(sensorEnrichmentConfigService.delete("bro")); + } + + @Test + public void deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete() throws Exception { + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenReturn(null); + + assertTrue(sensorEnrichmentConfigService.delete("bro")); + + verify(curatorFramework).delete(); + } + + @Test + public void findOneShouldProperlyReturnSensorEnrichmentConfig() throws Exception { + final SensorEnrichmentConfig sensorEnrichmentConfig = getTestSensorEnrichmentConfig(); + + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenReturn(broJson.getBytes()); + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertEquals(getTestSensorEnrichmentConfig(), sensorEnrichmentConfigService.findOne("bro")); + } + + @Test + public void findOneShouldReturnNullWhenNoNodeExceptionIsThrown() throws Exception { + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenThrow(KeeperException.NoNodeException.class); + + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertNull(sensorEnrichmentConfigService.findOne("bro")); + } + + @Test + public void findOneShouldWrapNonNoNodeExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenThrow(Exception.class); + + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + sensorEnrichmentConfigService.findOne("bro"); + } + + @Test + public void getAllTypesShouldProperlyReturnTypes() throws Exception { + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot())) + .thenReturn(new ArrayList() {{ + add("bro"); + add("squid"); + }}); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + assertEquals(new ArrayList() {{ + add("bro"); + add("squid"); + }}, sensorEnrichmentConfigService.getAllTypes()); + } + + @Test + public void getAllTypesShouldReturnNullWhenNoNodeExceptionIsThrown() throws Exception { + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot())).thenThrow(KeeperException.NoNodeException.class); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + assertEquals(new ArrayList<>(), sensorEnrichmentConfigService.getAllTypes()); + } + + @Test + public void getAllTypesShouldWrapNonNoNodeExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot())).thenThrow(Exception.class); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + sensorEnrichmentConfigService.getAllTypes(); + } + + @Test + public void getAllShouldProperlyReturnSensorEnrichmentConfigs() throws Exception { + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot())) + .thenReturn(new ArrayList() {{ + add("bro"); + }}); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + final SensorEnrichmentConfig sensorEnrichmentConfig = getTestSensorEnrichmentConfig(); + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro")).thenReturn(broJson.getBytes()); + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertEquals(new HashMap() {{ put("bro", sensorEnrichmentConfig);}}, sensorEnrichmentConfigService.getAll()); + } + + @Test + public void saveShouldWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + SetDataBuilder setDataBuilder = mock(SetDataBuilder.class); + when(setDataBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro", broJson.getBytes())).thenThrow(Exception.class); + + when(curatorFramework.setData()).thenReturn(setDataBuilder); + + sensorEnrichmentConfigService.save("bro", new SensorEnrichmentConfig()); + } + + @Test + public void saveShouldReturnSameConfigThatIsPassedOnSuccessfulSave() throws Exception { + final SensorEnrichmentConfig sensorEnrichmentConfig = getTestSensorEnrichmentConfig(); + + when(objectMapper.writeValueAsString(sensorEnrichmentConfig)).thenReturn(broJson); + + SetDataBuilder setDataBuilder = mock(SetDataBuilder.class); + when(setDataBuilder.forPath(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro", broJson.getBytes())).thenReturn(new Stat()); + when(curatorFramework.setData()).thenReturn(setDataBuilder); + + assertEquals(sensorEnrichmentConfig, sensorEnrichmentConfigService.save("bro", sensorEnrichmentConfig)); + verify(setDataBuilder).forPath(eq(ConfigurationType.ENRICHMENT.getZookeeperRoot() + "/bro"), eq(broJson.getBytes())); + } + + @Test + public void getAvailableEnrichmentsShouldReturnEnrichments() throws Exception { + assertEquals(new ArrayList() {{ + add("geo"); + add("host"); + add("whois"); + }}, sensorEnrichmentConfigService.getAvailableEnrichments()); + } + + private SensorEnrichmentConfig getTestSensorEnrichmentConfig() { + SensorEnrichmentConfig sensorEnrichmentConfig = new SensorEnrichmentConfig(); + EnrichmentConfig enrichmentConfig = new EnrichmentConfig(); + enrichmentConfig.setFieldMap(new HashMap() {{ put("geo", Arrays.asList("ip_dst_addr")); }}); + sensorEnrichmentConfig.setEnrichment(enrichmentConfig); + ThreatIntelConfig threatIntelConfig = new ThreatIntelConfig(); + threatIntelConfig.setFieldMap(new HashMap() {{ put("hbaseThreatIntel", Arrays.asList("ip_src_addr")); }}); + threatIntelConfig.setFieldToTypeMap(new HashMap() {{ put("ip_src_addr", Arrays.asList("malicious_ip")); }}); + sensorEnrichmentConfig.setThreatIntel(threatIntelConfig); + return sensorEnrichmentConfig; + } + } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImplTest.java new file mode 100644 index 0000000000..43ca0f75ee --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorIndexingConfigServiceImplTest.java @@ -0,0 +1,234 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.adrianwalker.multilinestring.Multiline; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.api.DeleteBuilder; +import org.apache.curator.framework.api.GetChildrenBuilder; +import org.apache.curator.framework.api.GetDataBuilder; +import org.apache.curator.framework.api.SetDataBuilder; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.SensorIndexingConfigService; +import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.data.Stat; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@SuppressWarnings("ALL") +public class SensorIndexingConfigServiceImplTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); + + ObjectMapper objectMapper; + CuratorFramework curatorFramework; + SensorIndexingConfigService sensorIndexingConfigService; + + /** + { + "hdfs" : { + "index": "bro", + "batchSize": 5, + "enabled" : true + } + } + */ + @Multiline + public static String broJson; + + @Before + public void setUp() throws Exception { + objectMapper = mock(ObjectMapper.class); + curatorFramework = mock(CuratorFramework.class); + sensorIndexingConfigService = new SensorIndexingConfigServiceImpl(objectMapper, curatorFramework); + } + + + @Test + public void deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse() throws Exception { + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenThrow(KeeperException.NoNodeException.class); + + assertFalse(sensorIndexingConfigService.delete("bro")); + } + + @Test + public void deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException() throws Exception { + exception.expect(RestException.class); + + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenThrow(Exception.class); + + assertFalse(sensorIndexingConfigService.delete("bro")); + } + + @Test + public void deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete() throws Exception { + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenReturn(null); + + assertTrue(sensorIndexingConfigService.delete("bro")); + + verify(curatorFramework).delete(); + } + + @Test + public void findOneShouldProperlyReturnSensorEnrichmentConfig() throws Exception { + final Map sensorIndexingConfig = getTestSensorIndexingConfig(); + + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenReturn(broJson.getBytes()); + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertEquals(getTestSensorIndexingConfig(), sensorIndexingConfigService.findOne("bro")); + } + + @Test + public void findOneShouldReturnNullWhenNoNodeExceptionIsThrown() throws Exception { + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenThrow(KeeperException.NoNodeException.class); + + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertNull(sensorIndexingConfigService.findOne("bro")); + } + + @Test + public void findOneShouldWrapNonNoNodeExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenThrow(Exception.class); + + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + sensorIndexingConfigService.findOne("bro"); + } + + @Test + public void getAllTypesShouldProperlyReturnTypes() throws Exception { + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot())) + .thenReturn(new ArrayList() {{ + add("bro"); + add("squid"); + }}); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + assertEquals(new ArrayList() {{ + add("bro"); + add("squid"); + }}, sensorIndexingConfigService.getAllTypes()); + } + + @Test + public void getAllTypesShouldReturnNullWhenNoNodeExceptionIsThrown() throws Exception { + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot())).thenThrow(KeeperException.NoNodeException.class); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + assertEquals(new ArrayList<>(), sensorIndexingConfigService.getAllTypes()); + } + + @Test + public void getAllTypesShouldWrapNonNoNodeExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot())).thenThrow(Exception.class); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + sensorIndexingConfigService.getAllTypes(); + } + + @Test + public void getAllShouldProperlyReturnSensorEnrichmentConfigs() throws Exception { + final Map sensorIndexingConfig = getTestSensorIndexingConfig(); + + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot())) + .thenReturn(new ArrayList() {{ + add("bro"); + }}); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro")).thenReturn(broJson.getBytes()); + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertEquals(new HashMap() {{ put("bro", sensorIndexingConfig);}}, sensorIndexingConfigService.getAll()); + } + + @Test + public void saveShouldWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + SetDataBuilder setDataBuilder = mock(SetDataBuilder.class); + when(setDataBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro", broJson.getBytes())).thenThrow(Exception.class); + + when(curatorFramework.setData()).thenReturn(setDataBuilder); + + sensorIndexingConfigService.save("bro", new HashMap<>()); + } + + @Test + public void saveShouldReturnSameConfigThatIsPassedOnSuccessfulSave() throws Exception { + final Map sensorIndexingConfig = getTestSensorIndexingConfig(); + + when(objectMapper.writeValueAsString(sensorIndexingConfig)).thenReturn(broJson); + + SetDataBuilder setDataBuilder = mock(SetDataBuilder.class); + when(setDataBuilder.forPath(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro", broJson.getBytes())).thenReturn(new Stat()); + when(curatorFramework.setData()).thenReturn(setDataBuilder); + + assertEquals(sensorIndexingConfig, sensorIndexingConfigService.save("bro", sensorIndexingConfig)); + verify(setDataBuilder).forPath(eq(ConfigurationType.INDEXING.getZookeeperRoot() + "/bro"), eq(broJson.getBytes())); + } + + private Map getTestSensorIndexingConfig() { + Map sensorIndexingConfig = new HashMap<>(); + sensorIndexingConfig.put("hdfs", new HashMap(){{ + put("index", "bro"); + put("batchSize", 5); + put("enabled", true); + }}); + return sensorIndexingConfig; + } + } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImplTest.java new file mode 100644 index 0000000000..d35a48c37c --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/SensorParserConfigServiceImplTest.java @@ -0,0 +1,344 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.adrianwalker.multilinestring.Multiline; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.api.DeleteBuilder; +import org.apache.curator.framework.api.GetChildrenBuilder; +import org.apache.curator.framework.api.GetDataBuilder; +import org.apache.curator.framework.api.SetDataBuilder; +import org.apache.metron.common.configuration.ConfigurationType; +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.model.ParseMessageRequest; +import org.apache.metron.rest.service.GrokService; +import org.apache.metron.rest.service.SensorParserConfigService; +import org.apache.zookeeper.KeeperException; +import org.apache.zookeeper.data.Stat; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.springframework.core.env.Environment; + +import java.io.File; +import java.io.FileWriter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@SuppressWarnings("ALL") +public class SensorParserConfigServiceImplTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); + + Environment environment; + ObjectMapper objectMapper; + CuratorFramework curatorFramework; + GrokService grokService; + SensorParserConfigService sensorParserConfigService; + + /** + { + "parserClassName": "org.apache.metron.parsers.GrokParser", + "sensorTopic": "squid", + "parserConfig": { + "grokPath": "/patterns/squid", + "patternLabel": "SQUID_DELIMITED", + "timestampField": "timestamp" + } + } + */ + @Multiline + public static String squidJson; + + /** + { + "parserClassName":"org.apache.metron.parsers.bro.BasicBroParser", + "sensorTopic":"bro", + "parserConfig": {} + } + */ + @Multiline + public static String broJson; + + @Before + public void setUp() throws Exception { + objectMapper = mock(ObjectMapper.class); + curatorFramework = mock(CuratorFramework.class); + grokService = mock(GrokService.class); + sensorParserConfigService = new SensorParserConfigServiceImpl(objectMapper, curatorFramework, grokService); + } + + + @Test + public void deleteShouldProperlyCatchNoNodeExceptionAndReturnFalse() throws Exception { + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenThrow(KeeperException.NoNodeException.class); + + assertFalse(sensorParserConfigService.delete("bro")); + } + + @Test + public void deleteShouldProperlyCatchNonNoNodeExceptionAndThrowRestException() throws Exception { + exception.expect(RestException.class); + + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenThrow(Exception.class); + + assertFalse(sensorParserConfigService.delete("bro")); + } + + @Test + public void deleteShouldReturnTrueWhenClientSuccessfullyCallsDelete() throws Exception { + DeleteBuilder builder = mock(DeleteBuilder.class); + + when(curatorFramework.delete()).thenReturn(builder); + when(builder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenReturn(null); + + assertTrue(sensorParserConfigService.delete("bro")); + + verify(curatorFramework).delete(); + } + + @Test + public void findOneShouldProperlyReturnSensorEnrichmentConfig() throws Exception { + final SensorParserConfig sensorParserConfig = getTestBroSensorParserConfig(); + + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenReturn(broJson.getBytes()); + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertEquals(getTestBroSensorParserConfig(), sensorParserConfigService.findOne("bro")); + } + + @Test + public void findOneShouldReturnNullWhenNoNodeExceptionIsThrown() throws Exception { + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenThrow(KeeperException.NoNodeException.class); + + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertNull(sensorParserConfigService.findOne("bro")); + } + + @Test + public void findOneShouldWrapNonNoNodeExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenThrow(Exception.class); + + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + sensorParserConfigService.findOne("bro"); + } + + @Test + public void getAllTypesShouldProperlyReturnTypes() throws Exception { + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())) + .thenReturn(new ArrayList() {{ + add("bro"); + add("squid"); + }}); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + assertEquals(new ArrayList() {{ + add("bro"); + add("squid"); + }}, sensorParserConfigService.getAllTypes()); + } + + @Test + public void getAllTypesShouldReturnEmptyListWhenNoNodeExceptionIsThrown() throws Exception { + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())).thenThrow(KeeperException.NoNodeException.class); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + assertEquals(new ArrayList<>(), sensorParserConfigService.getAllTypes()); + } + + @Test + public void getAllTypesShouldWrapNonNoNodeExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())).thenThrow(Exception.class); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + sensorParserConfigService.getAllTypes(); + } + + @Test + public void getAllShouldProperlyReturnSensorParserConfigs() throws Exception { + GetChildrenBuilder getChildrenBuilder = mock(GetChildrenBuilder.class); + when(getChildrenBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot())) + .thenReturn(new ArrayList() {{ + add("bro"); + add("squid"); + }}); + when(curatorFramework.getChildren()).thenReturn(getChildrenBuilder); + + final SensorParserConfig broSensorParserConfig = getTestBroSensorParserConfig(); + final SensorParserConfig squidSensorParserConfig = getTestSquidSensorParserConfig(); + GetDataBuilder getDataBuilder = mock(GetDataBuilder.class); + when(getDataBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro")).thenReturn(broJson.getBytes()); + when(getDataBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/squid")).thenReturn(squidJson.getBytes()); + when(curatorFramework.getData()).thenReturn(getDataBuilder); + + assertEquals(new ArrayList() {{ + add(getTestBroSensorParserConfig()); + add(getTestSquidSensorParserConfig()); + }}, sensorParserConfigService.getAll()); + } + + @Test + public void saveShouldWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + SetDataBuilder setDataBuilder = mock(SetDataBuilder.class); + when(setDataBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro", broJson.getBytes())).thenThrow(Exception.class); + + when(curatorFramework.setData()).thenReturn(setDataBuilder); + + final SensorParserConfig sensorParserConfig = new SensorParserConfig(); + sensorParserConfig.setSensorTopic("bro"); + sensorParserConfigService.save(sensorParserConfig); + } + + @Test + public void saveShouldReturnSameConfigThatIsPassedOnSuccessfulSave() throws Exception { + final SensorParserConfig sensorParserConfig = getTestBroSensorParserConfig(); + + when(objectMapper.writeValueAsString(sensorParserConfig)).thenReturn(broJson); + + SetDataBuilder setDataBuilder = mock(SetDataBuilder.class); + when(setDataBuilder.forPath(ConfigurationType.PARSER.getZookeeperRoot() + "/bro", broJson.getBytes())).thenReturn(new Stat()); + when(curatorFramework.setData()).thenReturn(setDataBuilder); + + assertEquals(getTestBroSensorParserConfig(), sensorParserConfigService.save(sensorParserConfig)); + verify(setDataBuilder).forPath(eq(ConfigurationType.PARSER.getZookeeperRoot() + "/bro"), eq(broJson.getBytes())); + } + + @Test + public void reloadAvailableParsersShouldReturnParserClasses() throws Exception { + Map availableParsers = sensorParserConfigService.reloadAvailableParsers(); + assertTrue(availableParsers.size() > 0); + assertEquals("org.apache.metron.parsers.GrokParser", availableParsers.get("Grok")); + assertEquals("org.apache.metron.parsers.bro.BasicBroParser", availableParsers.get("Bro")); + } + + @Test + public void parseMessageShouldProperlyReturnParsedResults() throws Exception { + final SensorParserConfig sensorParserConfig = getTestSquidSensorParserConfig(); + String grokStatement = "SQUID_DELIMITED %{NUMBER:timestamp}[^0-9]*%{INT:elapsed} %{IP:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url}[^0-9]*(%{IP:ip_dst_addr})?"; + String sampleData = "1461576382.642 161 127.0.0.1 TCP_MISS/200 103701 GET http://www.cnn.com/ - DIRECT/199.27.79.73 text/html"; + ParseMessageRequest parseMessageRequest = new ParseMessageRequest(); + parseMessageRequest.setSensorParserConfig(sensorParserConfig); + parseMessageRequest.setGrokStatement(grokStatement); + parseMessageRequest.setSampleData(sampleData); + + File patternFile = new File("./target/squidTest"); + FileWriter writer = new FileWriter(patternFile); + writer.write(grokStatement); + writer.close(); + + when(grokService.saveTemporary(grokStatement, "squid")).thenReturn(patternFile); + + assertEquals(new HashMap() {{ + put("elapsed", 161); + put("code", 200); + put("ip_dst_addr", "199.27.79.73"); + put("ip_src_addr", "127.0.0.1"); + put("action", "TCP_MISS"); + put("bytes", 103701); + put("method", "GET"); + put("url", "http://www.cnn.com/"); + put("timestamp", 1461576382642L); + put("original_string", "1461576382.642 161 127.0.0.1 TCP_MISS/200 103701 GET http://www.cnn.com/ - DIRECT/199.27.79.73 text/html"); + }}, sensorParserConfigService.parseMessage(parseMessageRequest)); + + } + + @Test + public void missingSensorParserConfigShouldThrowRestException() throws Exception { + exception.expect(RestException.class); + + ParseMessageRequest parseMessageRequest = new ParseMessageRequest(); + sensorParserConfigService.parseMessage(parseMessageRequest); + } + + @Test + public void missingParserClassShouldThrowRestException() throws Exception { + exception.expect(RestException.class); + + final SensorParserConfig sensorParserConfig = new SensorParserConfig(); + sensorParserConfig.setSensorTopic("squid"); + ParseMessageRequest parseMessageRequest = new ParseMessageRequest(); + parseMessageRequest.setSensorParserConfig(sensorParserConfig); + sensorParserConfigService.parseMessage(parseMessageRequest); + } + + @Test + public void invalidParserClassShouldThrowRestException() throws Exception { + exception.expect(RestException.class); + + final SensorParserConfig sensorParserConfig = new SensorParserConfig(); + sensorParserConfig.setSensorTopic("squid"); + sensorParserConfig.setParserClassName("bad.class.package.BadClassName"); + ParseMessageRequest parseMessageRequest = new ParseMessageRequest(); + parseMessageRequest.setSensorParserConfig(sensorParserConfig); + sensorParserConfigService.parseMessage(parseMessageRequest); + } + + private SensorParserConfig getTestBroSensorParserConfig() { + SensorParserConfig sensorParserConfig = new SensorParserConfig(); + sensorParserConfig.setSensorTopic("bro"); + sensorParserConfig.setParserClassName("org.apache.metron.parsers.bro.BasicBroParser"); + return sensorParserConfig; + } + + private SensorParserConfig getTestSquidSensorParserConfig() { + SensorParserConfig sensorParserConfig = new SensorParserConfig(); + sensorParserConfig.setSensorTopic("squid"); + sensorParserConfig.setParserClassName("org.apache.metron.parsers.GrokParser"); + sensorParserConfig.setParserConfig(new HashMap() {{ + put("grokPath", "/patterns/squid"); + put("patternLabel", "SQUID_DELIMITED"); + put("timestampField", "timestamp"); + }}); + return sensorParserConfig; + } + + } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormAdminServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormAdminServiceImplTest.java new file mode 100644 index 0000000000..d83a74cac3 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormAdminServiceImplTest.java @@ -0,0 +1,156 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.model.TopologyResponse; +import org.apache.metron.rest.model.TopologyStatusCode; +import org.apache.metron.rest.service.GlobalConfigService; +import org.apache.metron.rest.service.SensorParserConfigService; +import org.apache.metron.rest.service.StormAdminService; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@SuppressWarnings("ALL") +public class StormAdminServiceImplTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); + + StormCLIWrapper stormCLIClientWrapper; + StormAdminService stormAdminService; + GlobalConfigService globalConfigService; + SensorParserConfigService sensorParserConfigService; + + @Before + public void setUp() throws Exception { + stormCLIClientWrapper = mock(StormCLIWrapper.class); + globalConfigService = mock(GlobalConfigService.class); + sensorParserConfigService = mock(SensorParserConfigService.class); + stormAdminService = new StormAdminServiceImpl(stormCLIClientWrapper, globalConfigService, sensorParserConfigService); + } + + @Test + public void startParserTopologyShouldProperlyReturnSuccessTopologyResponse() throws Exception { + when(stormCLIClientWrapper.startParserTopology("bro")).thenReturn(0); + when(globalConfigService.get()).thenReturn(new HashMap()); + when(sensorParserConfigService.findOne("bro")).thenReturn(new SensorParserConfig()); + + TopologyResponse expected = new TopologyResponse(); + expected.setSuccessMessage(TopologyStatusCode.STARTED.toString()); + TopologyResponse actual = stormAdminService.startParserTopology("bro"); + + assertEquals(expected, actual); + assertEquals(expected.hashCode(), actual.hashCode()); + } + + @Test + public void startParserTopologyShouldReturnGlobalConfigMissingError() throws Exception { + when(globalConfigService.get()).thenReturn(null); + + TopologyResponse expected = new TopologyResponse(); + expected.setErrorMessage(TopologyStatusCode.GLOBAL_CONFIG_MISSING.toString()); + + assertEquals(expected, stormAdminService.startParserTopology("bro")); + } + + @Test + public void startParserTopologyShouldReturnSensorParserConfigMissingError() throws Exception { + when(globalConfigService.get()).thenReturn(new HashMap()); + when(sensorParserConfigService.findOne("bro")).thenReturn(null); + + TopologyResponse expected = new TopologyResponse(); + expected.setErrorMessage(TopologyStatusCode.SENSOR_PARSER_CONFIG_MISSING.toString()); + + assertEquals(expected, stormAdminService.startParserTopology("bro")); + } + + @Test + public void stopParserTopologyShouldProperlyReturnErrorTopologyResponse() throws Exception { + when(stormCLIClientWrapper.stopParserTopology("bro", false)).thenReturn(1); + when(globalConfigService.get()).thenReturn(new HashMap()); + when(sensorParserConfigService.findOne("bro")).thenReturn(new SensorParserConfig()); + + TopologyResponse expected = new TopologyResponse(); + expected.setErrorMessage(TopologyStatusCode.STOP_ERROR.toString()); + + assertEquals(expected, stormAdminService.stopParserTopology("bro", false)); + } + + @Test + public void startEnrichmentTopologyShouldProperlyReturnSuccessTopologyResponse() throws Exception { + when(stormCLIClientWrapper.startEnrichmentTopology()).thenReturn(0); + + TopologyResponse expected = new TopologyResponse(); + expected.setSuccessMessage(TopologyStatusCode.STARTED.toString()); + + assertEquals(expected, stormAdminService.startEnrichmentTopology()); + } + + @Test + public void stopEnrichmentTopologyShouldProperlyReturnSuccessTopologyResponse() throws Exception { + when(stormCLIClientWrapper.stopEnrichmentTopology(false)).thenReturn(0); + + TopologyResponse expected = new TopologyResponse(); + expected.setSuccessMessage(TopologyStatusCode.STOPPED.toString()); + + assertEquals(expected, stormAdminService.stopEnrichmentTopology(false)); + } + + @Test + public void startIndexingTopologyShouldProperlyReturnSuccessTopologyResponse() throws Exception { + when(stormCLIClientWrapper.startIndexingTopology()).thenReturn(0); + + TopologyResponse expected = new TopologyResponse(); + expected.setSuccessMessage(TopologyStatusCode.STARTED.toString()); + + assertEquals(expected, stormAdminService.startIndexingTopology()); + } + + @Test + public void stopIndexingTopologyShouldProperlyReturnSuccessTopologyResponse() throws Exception { + when(stormCLIClientWrapper.stopIndexingTopology(false)).thenReturn(0); + + TopologyResponse expected = new TopologyResponse(); + expected.setSuccessMessage(TopologyStatusCode.STOPPED.toString()); + + assertEquals(expected, stormAdminService.stopIndexingTopology(false)); + } + + @Test + public void getStormClientStatusShouldProperlyReturnStatus() throws Exception { + final Map status = new HashMap() {{ + put("status", "statusValue"); + }}; + when(stormCLIClientWrapper.getStormClientStatus()).thenReturn(status); + + assertEquals(new HashMap() {{ + put("status", "statusValue"); + }}, stormAdminService.getStormClientStatus()); + } + + +} \ No newline at end of file diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java new file mode 100644 index 0000000000..ff05371084 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java @@ -0,0 +1,216 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import org.apache.metron.rest.MetronRestConstants; +import org.apache.metron.rest.RestException; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; +import org.springframework.core.env.Environment; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.anyVararg; +import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.verifyNew; +import static org.powermock.api.mockito.PowerMockito.when; +import static org.powermock.api.mockito.PowerMockito.whenNew; + +@SuppressWarnings("unchecked") +@RunWith(PowerMockRunner.class) +@PrepareForTest({DockerStormCLIWrapper.class, ProcessBuilder.class}) +public class StormCliWrapperTest { + + @Rule + public final ExpectedException exception = ExpectedException.none(); + + private ProcessBuilder processBuilder; + private Environment environment; + private Process process; + private StormCLIWrapper stormCLIWrapper; + + @Before + public void setUp() throws Exception { + processBuilder = mock(ProcessBuilder.class); + environment = mock(Environment.class); + process = mock(Process.class); + stormCLIWrapper = new StormCLIWrapper(); + stormCLIWrapper.setEnvironment(environment); + } + + @Test + public void startParserTopologyShouldRunCommandProperly() throws Exception { + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + when(processBuilder.start()).thenReturn(process); + when(environment.getProperty(MetronRestConstants.PARSER_SCRIPT_PATH_SPRING_PROPERTY)).thenReturn("/start_parser"); + when(environment.getProperty(MetronRestConstants.KAFKA_BROKER_URL_SPRING_PROPERTY)).thenReturn("kafka_broker_url"); + when(environment.getProperty(MetronRestConstants.ZK_URL_SPRING_PROPERTY)).thenReturn("zookeeper_url"); + when(process.exitValue()).thenReturn(0); + + assertEquals(0, stormCLIWrapper.startParserTopology("bro")); + verify(process).waitFor(); + verifyNew(ProcessBuilder.class).withArguments("/start_parser", "-k", "kafka_broker_url", "-z", "zookeeper_url", "-s", "bro"); + } + + @Test + public void stopParserTopologyShouldRunCommandProperly() throws Exception { + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + when(processBuilder.start()).thenReturn(process); + when(process.exitValue()).thenReturn(0); + + assertEquals(0, stormCLIWrapper.stopParserTopology("bro", false)); + verify(process).waitFor(); + verifyNew(ProcessBuilder.class).withArguments("storm", "kill", "bro"); + } + + @Test + public void stopParserTopologyNowShouldRunCommandProperly() throws Exception { + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + when(processBuilder.start()).thenReturn(process); + when(process.exitValue()).thenReturn(0); + + assertEquals(0, stormCLIWrapper.stopParserTopology("bro", true)); + verify(process).waitFor(); + verifyNew(ProcessBuilder.class).withArguments("storm", "kill", "bro", "-w", "0"); + } + + @Test + public void startEnrichmentTopologyShouldRunCommandProperly() throws Exception { + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + when(processBuilder.start()).thenReturn(process); + when(environment.getProperty(MetronRestConstants.ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY)).thenReturn("/start_enrichment"); + when(process.exitValue()).thenReturn(0); + + assertEquals(0, stormCLIWrapper.startEnrichmentTopology()); + verify(process).waitFor(); + verifyNew(ProcessBuilder.class).withArguments("/start_enrichment"); + + } + + @Test + public void stopEnrichmentTopologyShouldRunCommandProperly() throws Exception { + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + when(processBuilder.start()).thenReturn(process); + when(process.exitValue()).thenReturn(0); + + assertEquals(0, stormCLIWrapper.stopEnrichmentTopology(false)); + verify(process).waitFor(); + verifyNew(ProcessBuilder.class).withArguments("storm", "kill", MetronRestConstants.ENRICHMENT_TOPOLOGY_NAME); + } + + @Test + public void startIndexingTopologyShouldRunCommandProperly() throws Exception { + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + when(processBuilder.start()).thenReturn(process); + when(environment.getProperty(MetronRestConstants.INDEXING_SCRIPT_PATH_SPRING_PROPERTY)).thenReturn("/start_indexing"); + when(process.exitValue()).thenReturn(0); + + assertEquals(0, stormCLIWrapper.startIndexingTopology()); + verify(process).waitFor(); + verifyNew(ProcessBuilder.class).withArguments("/start_indexing"); + + } + + @Test + public void stopIndexingTopologyShouldRunCommandProperly() throws Exception { + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + when(processBuilder.start()).thenReturn(process); + when(process.exitValue()).thenReturn(0); + + assertEquals(0, stormCLIWrapper.stopIndexingTopology(false)); + verify(process).waitFor(); + verifyNew(ProcessBuilder.class).withArguments("storm", "kill", MetronRestConstants.INDEXING_TOPOLOGY_NAME); + } + + @Test + public void getStormClientStatusShouldReturnCorrectStatus() throws Exception { + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + Process process = mock(Process.class); + InputStream inputStream = new ByteArrayInputStream("\nStorm 1.1".getBytes(UTF_8)); + + when(processBuilder.start()).thenReturn(process); + + when(process.getInputStream()).thenReturn(inputStream); + when(environment.getProperty(MetronRestConstants.PARSER_SCRIPT_PATH_SPRING_PROPERTY)).thenReturn("/start_parser"); + when(environment.getProperty(MetronRestConstants.ENRICHMENT_SCRIPT_PATH_SPRING_PROPERTY)).thenReturn("/start_enrichment"); + when(environment.getProperty(MetronRestConstants.INDEXING_SCRIPT_PATH_SPRING_PROPERTY)).thenReturn("/start_indexing"); + + + Map actual = stormCLIWrapper.getStormClientStatus(); + assertEquals(new HashMap() {{ + put("parserScriptPath", "/start_parser"); + put("enrichmentScriptPath", "/start_enrichment"); + put("indexingScriptPath", "/start_indexing"); + put("stormClientVersionInstalled", "1.1"); + + }}, actual); + verifyNew(ProcessBuilder.class).withArguments("storm", "version"); + } + + @Test + public void stormClientVersionInstalledShouldReturnDefault() throws Exception { + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + + Process process = mock(Process.class); + InputStream inputStream = new ByteArrayInputStream("".getBytes(UTF_8)); + + when(processBuilder.start()).thenReturn(process); + when(process.getInputStream()).thenReturn(inputStream); + assertEquals("Storm client is not installed", stormCLIWrapper.stormClientVersionInstalled()); + } + + @Test + public void runCommandShouldReturnRestExceptionOnError() throws Exception { + exception.expect(RestException.class); + + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + when(processBuilder.start()).thenThrow(new IOException()); + + stormCLIWrapper.runCommand(new String[]{"storm", "kill"}); + } + + @Test + public void stormClientVersionInstalledShouldReturnRestExceptionOnError() throws Exception { + exception.expect(RestException.class); + + whenNew(ProcessBuilder.class).withParameterTypes(String[].class).withArguments(anyVararg()).thenReturn(processBuilder); + when(processBuilder.start()).thenThrow(new IOException()); + + stormCLIWrapper.stormClientVersionInstalled(); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormStatusServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormStatusServiceImplTest.java new file mode 100644 index 0000000000..db2cb7f911 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormStatusServiceImplTest.java @@ -0,0 +1,221 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import org.apache.metron.rest.model.TopologyResponse; +import org.apache.metron.rest.model.TopologyStatus; +import org.apache.metron.rest.model.TopologyStatusCode; +import org.apache.metron.rest.model.TopologySummary; +import org.apache.metron.rest.service.StormStatusService; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.springframework.core.env.Environment; +import org.springframework.web.client.RestTemplate; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import static org.apache.metron.rest.MetronRestConstants.STORM_UI_SPRING_PROPERTY; +import static org.apache.metron.rest.MetronRestConstants.TOPOLOGY_SUMMARY_URL; +import static org.apache.metron.rest.MetronRestConstants.TOPOLOGY_URL; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +@SuppressWarnings("ALL") +public class StormStatusServiceImplTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); + + Environment environment; + RestTemplate restTemplate; + StormStatusService stormStatusService; + + @Before + public void setUp() throws Exception { + environment = mock(Environment.class); + restTemplate = mock(RestTemplate.class); + stormStatusService = new StormStatusServiceImpl(environment, restTemplate); + } + + @Test + public void getTopologySummaryShouldReturnTopologySummary() throws Exception { + final TopologyStatus topologyStatus = new TopologyStatus(); + topologyStatus.setStatus(TopologyStatusCode.STARTED); + topologyStatus.setName("bro"); + topologyStatus.setId("bro_id"); + final TopologySummary topologySummary = new TopologySummary(); + topologySummary.setTopologies(new TopologyStatus[]{topologyStatus}); + + when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui"); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary); + + TopologyStatus expectedStatus = new TopologyStatus(); + expectedStatus.setStatus(TopologyStatusCode.STARTED); + expectedStatus.setName("bro"); + expectedStatus.setId("bro_id"); + TopologySummary expected = new TopologySummary(); + expected.setTopologies(new TopologyStatus[]{expectedStatus}); + + TopologySummary actual = stormStatusService.getTopologySummary(); + assertEquals(expected, actual); + assertEquals(expected.hashCode(), actual.hashCode()); + } + + @Test + public void getTopologyStatusShouldReturnTopologyStatus() throws Exception { + final TopologyStatus topologyStatus = new TopologyStatus(); + topologyStatus.setStatus(TopologyStatusCode.STARTED); + topologyStatus.setName("bro"); + topologyStatus.setId("bro_id"); + final TopologySummary topologySummary = new TopologySummary(); + topologySummary.setTopologies(new TopologyStatus[]{topologyStatus}); + + when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui"); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id", TopologyStatus.class)).thenReturn(topologyStatus); + + TopologyStatus expected = new TopologyStatus(); + expected.setStatus(TopologyStatusCode.STARTED); + expected.setName("bro"); + expected.setId("bro_id"); + + TopologyStatus actual = stormStatusService.getTopologyStatus("bro"); + assertEquals(expected, actual); + assertEquals(expected.hashCode(), actual.hashCode()); + } + + @Test + public void getAllTopologyStatusShouldReturnAllTopologyStatus() { + final TopologyStatus topologyStatus = new TopologyStatus(); + topologyStatus.setStatus(TopologyStatusCode.STARTED); + topologyStatus.setName("bro"); + topologyStatus.setId("bro_id"); + final TopologySummary topologySummary = new TopologySummary(); + topologySummary.setTopologies(new TopologyStatus[]{topologyStatus}); + + when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui"); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id", TopologyStatus.class)).thenReturn(topologyStatus); + + TopologyStatus expected = new TopologyStatus(); + expected.setStatus(TopologyStatusCode.STARTED); + expected.setName("bro"); + expected.setId("bro_id"); + + assertEquals(new ArrayList() {{ add(expected); }}, stormStatusService.getAllTopologyStatus()); + } + + + @Test + public void activateTopologyShouldReturnActiveTopologyResponse() { + final TopologyStatus topologyStatus = new TopologyStatus(); + topologyStatus.setName("bro"); + topologyStatus.setId("bro_id"); + final TopologySummary topologySummary = new TopologySummary(); + topologySummary.setTopologies(new TopologyStatus[]{topologyStatus}); + + when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui"); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary); + when(restTemplate.postForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id/activate", null, Map.class)) + .thenReturn(new HashMap() {{ put("status", "success"); }}); + + TopologyResponse expected = new TopologyResponse(); + expected.setSuccessMessage(TopologyStatusCode.ACTIVE.toString()); + assertEquals(expected, stormStatusService.activateTopology("bro")); + } + + @Test + public void activateTopologyShouldReturnErrorTopologyResponse() { + final TopologyStatus topologyStatus = new TopologyStatus(); + topologyStatus.setName("bro"); + topologyStatus.setId("bro_id"); + final TopologySummary topologySummary = new TopologySummary(); + topologySummary.setTopologies(new TopologyStatus[]{topologyStatus}); + + when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui"); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary); + when(restTemplate.postForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id/activate", null, Map.class)) + .thenReturn(new HashMap() {{ put("status", "error message"); }}); + + TopologyResponse expected = new TopologyResponse(); + expected.setErrorMessage("error message"); + assertEquals(expected, stormStatusService.activateTopology("bro")); + } + + @Test + public void activateTopologyShouldReturnTopologyNotFoundTopologyResponse() { + when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui"); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(new TopologySummary()); + + TopologyResponse expected = new TopologyResponse(); + expected.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString()); + assertEquals(expected, stormStatusService.activateTopology("bro")); + } + + @Test + public void deactivateTopologyShouldReturnActiveTopologyResponse() { + final TopologyStatus topologyStatus = new TopologyStatus(); + topologyStatus.setName("bro"); + topologyStatus.setId("bro_id"); + final TopologySummary topologySummary = new TopologySummary(); + topologySummary.setTopologies(new TopologyStatus[]{topologyStatus}); + + when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui"); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary); + when(restTemplate.postForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id/deactivate", null, Map.class)) + .thenReturn(new HashMap() {{ put("status", "success"); }}); + + TopologyResponse expected = new TopologyResponse(); + expected.setSuccessMessage(TopologyStatusCode.INACTIVE.toString()); + assertEquals(expected, stormStatusService.deactivateTopology("bro")); + } + + @Test + public void deactivateTopologyShouldReturnErrorTopologyResponse() { + final TopologyStatus topologyStatus = new TopologyStatus(); + topologyStatus.setName("bro"); + topologyStatus.setId("bro_id"); + final TopologySummary topologySummary = new TopologySummary(); + topologySummary.setTopologies(new TopologyStatus[]{topologyStatus}); + + when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui"); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(topologySummary); + when(restTemplate.postForObject("http://storm_ui" + TOPOLOGY_URL + "/bro_id/deactivate", null, Map.class)) + .thenReturn(new HashMap() {{ put("status", "error message"); }}); + + TopologyResponse expected = new TopologyResponse(); + expected.setErrorMessage("error message"); + assertEquals(expected, stormStatusService.deactivateTopology("bro")); + } + + @Test + public void deactivateTopologyShouldReturnTopologyNotFoundTopologyResponse() { + when(environment.getProperty(STORM_UI_SPRING_PROPERTY)).thenReturn("storm_ui"); + when(restTemplate.getForObject("http://storm_ui" + TOPOLOGY_SUMMARY_URL, TopologySummary.class)).thenReturn(new TopologySummary()); + + TopologyResponse expected = new TopologyResponse(); + expected.setErrorMessage(TopologyStatusCode.TOPOLOGY_NOT_FOUND.toString()); + assertEquals(expected, stormStatusService.deactivateTopology("bro")); + } + + +} \ No newline at end of file From 5443cd800e91899e8c56ad90384e04ee3b4cfae7 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 6 Feb 2017 17:40:23 -0600 Subject: [PATCH 41/54] Added HDFS controller and renamed StellarService --- ...lidation.java => SensorParserContext.java} | 2 +- .../rest/controller/HdfsController.java | 87 +++++++++++ ...Controller.java => StellarController.java} | 26 ++-- .../metron/rest/service/HdfsService.java | 13 +- ...mationService.java => StellarService.java} | 6 +- .../rest/service/impl/HdfsServiceImpl.java | 55 +++++-- ...rviceImpl.java => StellarServiceImpl.java} | 14 +- .../HdfsControllerIntegrationTest.java | 101 +++++++++++++ ... => StellarControllerIntegrationTest.java} | 24 +-- .../impl/HdfsServiceImplExceptionTest.java | 101 +++++++++++++ .../service/impl/HdfsServiceImplTest.java | 143 ++++++++---------- .../service/impl/StormCliWrapperTest.java | 2 +- 12 files changed, 439 insertions(+), 135 deletions(-) rename metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/{TransformationValidation.java => SensorParserContext.java} (97%) create mode 100644 metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java rename metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/{TransformationController.java => StellarController.java} (69%) rename metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/{TransformationService.java => StellarService.java} (86%) rename metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/{TransformationServiceImpl.java => StellarServiceImpl.java} (85%) create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/HdfsControllerIntegrationTest.java rename metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/{TransformationControllerIntegrationTest.java => StellarControllerIntegrationTest.java} (79%) create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplExceptionTest.java diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TransformationValidation.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserContext.java similarity index 97% rename from metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TransformationValidation.java rename to metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserContext.java index c2e39e4d26..cb10cfe3b8 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/TransformationValidation.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/SensorParserContext.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; -public class TransformationValidation { +public class SensorParserContext { private Map sampleData; private SensorParserConfig sensorParserConfig; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java new file mode 100644 index 0000000000..83b3ddc02e --- /dev/null +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java @@ -0,0 +1,87 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import org.apache.hadoop.fs.Path; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.HdfsService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import static java.nio.charset.StandardCharsets.UTF_8; + +@RestController +@RequestMapping("/api/v1/hdfs") +public class HdfsController { + + @Autowired + private HdfsService hdfsService; + + @ApiOperation(value = "Reads a file from HDFS and returns the contents") + @ApiResponse(message = "Returns file contents", code = 200) + @RequestMapping(value = "/list", method = RequestMethod.GET) + ResponseEntity> list(@ApiParam(name = "path", value = "Path to HDFS directory", required = true) @RequestParam String path) throws RestException { + return new ResponseEntity<>(hdfsService.list(new Path(path)), HttpStatus.OK); + } + + @ApiOperation(value = "Reads a file from HDFS and returns the contents") + @ApiResponse(message = "Returns file contents", code = 200) + @RequestMapping(method = RequestMethod.GET) + ResponseEntity read(@ApiParam(name = "path", value = "Path to HDFS file", required = true) @RequestParam String path) throws RestException { + String contents = hdfsService.read(new Path(path)); + if (contents != null) { + return new ResponseEntity<>(hdfsService.read(new Path(path)), HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + + } + + @ApiOperation(value = "Writes contents to an HDFS file") + @ApiResponse(message = "Contents were written", code = 200) + @RequestMapping(method = RequestMethod.POST) + ResponseEntity write(@ApiParam(name="path", value="Path to HDFS file", required=true) @RequestParam String path, + @ApiParam(name="contents", value="File contents", required=true) @RequestBody String contents) throws RestException { + hdfsService.write(new Path(path), contents.getBytes(UTF_8)); + return new ResponseEntity<>(HttpStatus.OK); + + } + + @ApiOperation(value = "Retrieves field transformations") + @ApiResponse(message = "Returns a list field transformations", code = 200) + @RequestMapping(method = RequestMethod.DELETE) + ResponseEntity delete(@ApiParam(name = "path", value = "Path to HDFS file", required = true) @RequestParam String path, + @ApiParam(name = "recursive", value = "Delete files recursively") @RequestParam(required = false, defaultValue = "false") boolean recursive) throws RestException { + if (hdfsService.delete(new Path(path), recursive)) { + return new ResponseEntity<>(HttpStatus.OK); + } else { + return new ResponseEntity<>(HttpStatus.NOT_FOUND); + } + } +} diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StellarController.java similarity index 69% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java rename to metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StellarController.java index bc8b201558..13327f9279 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/TransformationController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/StellarController.java @@ -23,8 +23,8 @@ import org.apache.metron.common.field.transformation.FieldTransformations; import org.apache.metron.rest.RestException; import org.apache.metron.rest.model.StellarFunctionDescription; -import org.apache.metron.rest.model.TransformationValidation; -import org.apache.metron.rest.service.TransformationService; +import org.apache.metron.rest.model.SensorParserContext; +import org.apache.metron.rest.service.StellarService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -37,44 +37,44 @@ import java.util.Map; @RestController -@RequestMapping("/api/v1/transformation") -public class TransformationController { +@RequestMapping("/api/v1/stellar") +public class StellarController { @Autowired - private TransformationService transformationService; + private StellarService stellarService; @ApiOperation(value = "Tests Stellar statements to ensure they are well-formed") @ApiResponse(message = "Returns validation results", code = 200) @RequestMapping(value = "/validate/rules", method = RequestMethod.POST) - ResponseEntity> validateRule(@ApiParam(name="statements", value="List of statements to validate", required=true)@RequestBody List statements) throws RestException { - return new ResponseEntity<>(transformationService.validateRules(statements), HttpStatus.OK); + ResponseEntity> validateRules(@ApiParam(name="statements", value="List of statements to validate", required=true)@RequestBody List statements) throws RestException { + return new ResponseEntity<>(stellarService.validateRules(statements), HttpStatus.OK); } @ApiOperation(value = "Executes transformations against a sample message") @ApiResponse(message = "Returns transformation results", code = 200) - @RequestMapping(value = "/validate", method = RequestMethod.POST) - ResponseEntity> validateTransformation(@ApiParam(name="transformationValidation", value="Object containing SensorParserConfig and sample message", required=true)@RequestBody TransformationValidation transformationValidation) throws RestException { - return new ResponseEntity<>(transformationService.validateTransformation(transformationValidation), HttpStatus.OK); + @RequestMapping(value = "/apply/transformations", method = RequestMethod.POST) + ResponseEntity> applyTransformations(@ApiParam(name="transformationValidation", value="Object containing SensorParserConfig and sample message", required=true)@RequestBody SensorParserContext sensorParserContext) throws RestException { + return new ResponseEntity<>(stellarService.applyTransformations(sensorParserContext), HttpStatus.OK); } @ApiOperation(value = "Retrieves field transformations") @ApiResponse(message = "Returns a list field transformations", code = 200) @RequestMapping(value = "/list", method = RequestMethod.GET) ResponseEntity list() throws RestException { - return new ResponseEntity<>(transformationService.getTransformations(), HttpStatus.OK); + return new ResponseEntity<>(stellarService.getTransformations(), HttpStatus.OK); } @ApiOperation(value = "Lists the Stellar functions that can be found on the classpath") @ApiResponse(message = "Returns a list of Stellar functions", code = 200) @RequestMapping(value = "/list/functions", method = RequestMethod.GET) ResponseEntity> listFunctions() throws RestException { - return new ResponseEntity<>(transformationService.getStellarFunctions(), HttpStatus.OK); + return new ResponseEntity<>(stellarService.getStellarFunctions(), HttpStatus.OK); } @ApiOperation(value = "Lists the simple Stellar functions (functions with only 1 input) that can be found on the classpath") @ApiResponse(message = "Returns a list of simple Stellar functions", code = 200) @RequestMapping(value = "/list/simple/functions", method = RequestMethod.GET) ResponseEntity> listSimpleFunctions() throws RestException { - return new ResponseEntity<>(transformationService.getSimpleStellarFunctions(), HttpStatus.OK); + return new ResponseEntity<>(stellarService.getSimpleStellarFunctions(), HttpStatus.OK); } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java index 97888ff5ac..d5932c7bab 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/HdfsService.java @@ -17,19 +17,18 @@ */ package org.apache.metron.rest.service; -import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.Path; -import org.springframework.stereotype.Service; +import org.apache.metron.rest.RestException; -import java.io.IOException; +import java.util.List; public interface HdfsService { - byte[] read(Path path) throws IOException; + String read(Path path) throws RestException; - void write(Path path, byte[] contents) throws IOException; + void write(Path path, byte[] contents) throws RestException; - FileStatus[] list(Path path) throws IOException; + List list(Path path) throws RestException; - boolean delete(Path path, boolean recursive) throws IOException; + boolean delete(Path path, boolean recursive) throws RestException; } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StellarService.java similarity index 86% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java rename to metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StellarService.java index d1400c6dc8..18ae56252b 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/TransformationService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StellarService.java @@ -19,16 +19,16 @@ import org.apache.metron.common.field.transformation.FieldTransformations; import org.apache.metron.rest.model.StellarFunctionDescription; -import org.apache.metron.rest.model.TransformationValidation; +import org.apache.metron.rest.model.SensorParserContext; import java.util.List; import java.util.Map; -public interface TransformationService { +public interface StellarService { Map validateRules(List rules); - Map validateTransformation(TransformationValidation transformationValidation); + Map applyTransformations(SensorParserContext transformationValidation); FieldTransformations[] getTransformations(); diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java index c14ec0c364..789c4216b5 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/HdfsServiceImpl.java @@ -19,44 +19,73 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataOutputStream; -import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IOUtils; +import org.apache.metron.rest.RestException; import org.apache.metron.rest.service.HdfsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.ByteArrayOutputStream; +import java.io.FileNotFoundException; import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static java.nio.charset.StandardCharsets.UTF_8; @Service public class HdfsServiceImpl implements HdfsService { - @Autowired private Configuration configuration; + @Autowired + public HdfsServiceImpl(Configuration configuration) { + this.configuration = configuration; + } + @Override - public byte[] read(Path path) throws IOException { - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - IOUtils.copyBytes(FileSystem.get(configuration).open(path), byteArrayOutputStream, configuration); - return byteArrayOutputStream.toByteArray(); + public List list(Path path) throws RestException { + try { + return Arrays.asList(FileSystem.get(configuration).listStatus(path)).stream().map(fileStatus -> fileStatus.getPath().getName()).collect(Collectors.toList()); + } catch (IOException e) { + throw new RestException(e); + } } @Override - public void write(Path path, byte[] contents) throws IOException { - FSDataOutputStream fsDataOutputStream = FileSystem.get(configuration).create(path, true); - fsDataOutputStream.write(contents); - fsDataOutputStream.close(); + public String read(Path path) throws RestException { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + try { + IOUtils.copyBytes(FileSystem.get(configuration).open(path), byteArrayOutputStream, configuration); + } catch (FileNotFoundException e) { + return null; + } catch (IOException e) { + throw new RestException(e); + } + return new String(byteArrayOutputStream.toByteArray(), UTF_8); } @Override - public FileStatus[] list(Path path) throws IOException { - return FileSystem.get(configuration).listStatus(path); + public void write(Path path, byte[] contents) throws RestException { + FSDataOutputStream fsDataOutputStream; + try { + fsDataOutputStream = FileSystem.get(configuration).create(path, true); + fsDataOutputStream.write(contents); + fsDataOutputStream.close(); + } catch (IOException e) { + throw new RestException(e); + } } @Override - public boolean delete(Path path, boolean recursive) throws IOException { + public boolean delete(Path path, boolean recursive) throws RestException { + try { return FileSystem.get(configuration).delete(path, recursive); + } catch (IOException e) { + throw new RestException(e); + } } } diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StellarServiceImpl.java similarity index 85% rename from metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java rename to metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StellarServiceImpl.java index b26dc82355..f5392bee2b 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/TransformationServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/StellarServiceImpl.java @@ -24,8 +24,8 @@ import org.apache.metron.common.field.transformation.FieldTransformations; import org.apache.metron.common.stellar.StellarProcessor; import org.apache.metron.rest.model.StellarFunctionDescription; -import org.apache.metron.rest.model.TransformationValidation; -import org.apache.metron.rest.service.TransformationService; +import org.apache.metron.rest.model.SensorParserContext; +import org.apache.metron.rest.service.StellarService; import org.json.simple.JSONObject; import org.springframework.stereotype.Service; @@ -36,7 +36,7 @@ import java.util.stream.Collectors; @Service -public class TransformationServiceImpl implements TransformationService { +public class StellarServiceImpl implements StellarService { @Override public Map validateRules(List rules) { @@ -54,10 +54,10 @@ public Map validateRules(List rules) { } @Override - public Map validateTransformation(TransformationValidation transformationValidation) { - JSONObject sampleJson = new JSONObject(transformationValidation.getSampleData()); - transformationValidation.getSensorParserConfig().getFieldTransformations().forEach(fieldTransformer -> { - fieldTransformer.transformAndUpdate(sampleJson, transformationValidation.getSensorParserConfig().getParserConfig(), Context.EMPTY_CONTEXT()); + public Map applyTransformations(SensorParserContext sensorParserContext) { + JSONObject sampleJson = new JSONObject(sensorParserContext.getSampleData()); + sensorParserContext.getSensorParserConfig().getFieldTransformations().forEach(fieldTransformer -> { + fieldTransformer.transformAndUpdate(sampleJson, sensorParserContext.getSensorParserConfig().getParserConfig(), Context.EMPTY_CONTEXT()); } ); return sampleJson; diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/HdfsControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/HdfsControllerIntegrationTest.java new file mode 100644 index 0000000000..a6c3469bdc --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/HdfsControllerIntegrationTest.java @@ -0,0 +1,101 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.controller; + +import org.apache.hadoop.fs.Path; +import org.apache.metron.rest.service.HdfsService; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.setup.MockMvcBuilders; +import org.springframework.web.context.WebApplicationContext; + +import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles(TEST_PROFILE) +public class HdfsControllerIntegrationTest { + + @Autowired + private HdfsService hdfsService; + + @Autowired + private WebApplicationContext wac; + + private MockMvc mockMvc; + + private String hdfsUrl = "/api/v1/hdfs"; + private String user = "user"; + private String password = "password"; + private String path = "./target/hdfsTest.txt"; + private String fileContents = "file contents"; + + @Before + public void setup() throws Exception { + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).apply(springSecurity()).build(); + } + + @Test + public void testSecurity() throws Exception { + this.mockMvc.perform(post(hdfsUrl).with(csrf()).contentType(MediaType.parseMediaType("text/plain;charset=UTF-8")).content(fileContents)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(get(hdfsUrl)) + .andExpect(status().isUnauthorized()); + + this.mockMvc.perform(delete(hdfsUrl).with(csrf())) + .andExpect(status().isUnauthorized()); + } + + @Test + public void test() throws Exception { + this.hdfsService.delete(new Path(path), false); + + this.mockMvc.perform(get(hdfsUrl + "?path=" + path).with(httpBasic(user,password))) + .andExpect(status().isNotFound()); + + this.mockMvc.perform(post(hdfsUrl + "?path=" + path).with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("text/plain;charset=UTF-8")).content(fileContents)) + .andExpect(status().isOk()); + + this.mockMvc.perform(get(hdfsUrl + "?path=" + path).with(httpBasic(user,password))) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.parseMediaType("text/plain;charset=UTF-8"))) + .andExpect(content().bytes(fileContents.getBytes())); + + this.mockMvc.perform(delete(hdfsUrl + "?path=" + path).with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isOk()); + + this.mockMvc.perform(delete(hdfsUrl + "?path=" + path).with(httpBasic(user,password)).with(csrf())) + .andExpect(status().isNotFound()); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StellarControllerIntegrationTest.java similarity index 79% rename from metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java rename to metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StellarControllerIntegrationTest.java index ec987e05fb..7a57173426 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/TransformationControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/StellarControllerIntegrationTest.java @@ -45,7 +45,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles(TEST_PROFILE) -public class TransformationControllerIntegrationTest { +public class StellarControllerIntegrationTest { private String valid = "TO_LOWER(test)"; private String invalid = "BAD_FUNCTION(test)"; @@ -58,7 +58,7 @@ public class TransformationControllerIntegrationTest { } */ @Multiline - public static String sensorParseConfigJson; + public static String sensorParseContext; @Autowired @@ -66,7 +66,7 @@ public class TransformationControllerIntegrationTest { private MockMvc mockMvc; - private String transformationUrl = "/api/v1/transformation"; + private String stellarUrl = "/api/v1/stellar"; private String user = "user"; private String password = "password"; @@ -77,44 +77,44 @@ public void setup() throws Exception { @Test public void testSecurity() throws Exception { - this.mockMvc.perform(post(transformationUrl + "/validate/rules").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) + this.mockMvc.perform(post(stellarUrl + "/validate/rules").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(post(transformationUrl + "/validate").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) + this.mockMvc.perform(post(stellarUrl + "/apply/transformations").with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseContext)) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get(transformationUrl + "/list")) + this.mockMvc.perform(get(stellarUrl + "/list")) .andExpect(status().isUnauthorized()); - this.mockMvc.perform(get(transformationUrl + "/list/functions")) + this.mockMvc.perform(get(stellarUrl + "/list/functions")) .andExpect(status().isUnauthorized()); } @Test public void test() throws Exception { - this.mockMvc.perform(post(transformationUrl + "/validate/rules").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) + this.mockMvc.perform(post(stellarUrl + "/validate/rules").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(rulesJson)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.['" + valid + "']").value(Boolean.TRUE)) .andExpect(jsonPath("$.['" + invalid + "']").value(Boolean.FALSE)); - this.mockMvc.perform(post(transformationUrl + "/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseConfigJson)) + this.mockMvc.perform(post(stellarUrl + "/apply/transformations").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(sensorParseContext)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.url").value("https://caseystella.com/blog")) .andExpect(jsonPath("$.url_host").value("caseystella.com")); - this.mockMvc.perform(get(transformationUrl + "/list").with(httpBasic(user,password))) + this.mockMvc.perform(get(stellarUrl + "/list").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", hasSize(greaterThan(0)))); - this.mockMvc.perform(get(transformationUrl + "/list/functions").with(httpBasic(user,password))) + this.mockMvc.perform(get(stellarUrl + "/list/functions").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", hasSize(greaterThan(0)))); - this.mockMvc.perform(get(transformationUrl + "/list/simple/functions").with(httpBasic(user,password))) + this.mockMvc.perform(get(stellarUrl + "/list/simple/functions").with(httpBasic(user,password))) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$", hasSize(greaterThan(0)))); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplExceptionTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplExceptionTest.java new file mode 100644 index 0000000000..d11f5a4b19 --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplExceptionTest.java @@ -0,0 +1,101 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.apache.metron.rest.RestException; +import org.apache.metron.rest.service.HdfsService; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.io.IOException; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.powermock.api.mockito.PowerMockito.mock; +import static org.powermock.api.mockito.PowerMockito.mockStatic; +import static org.powermock.api.mockito.PowerMockito.when; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({HdfsServiceImpl.class, FileSystem.class}) +public class HdfsServiceImplExceptionTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); + + private Configuration configuration; + private HdfsService hdfsService; + private String testDir = "./target/hdfsUnitTest"; + + @Before + public void setup() throws IOException { + configuration = new Configuration(); + hdfsService = new HdfsServiceImpl(configuration); + + mockStatic(FileSystem.class); + } + + @Test + public void listShouldWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + FileSystem fileSystem = mock(FileSystem.class); + when(FileSystem.get(configuration)).thenReturn(fileSystem); + when(fileSystem.listStatus(new Path(testDir))).thenThrow(new IOException()); + + hdfsService.list(new Path(testDir)); + } + + @Test + public void readShouldWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + FileSystem fileSystem = mock(FileSystem.class); + when(FileSystem.get(configuration)).thenReturn(fileSystem); + when(fileSystem.open(new Path(testDir))).thenThrow(new IOException()); + + hdfsService.read(new Path(testDir)); + } + + @Test + public void writeShouldWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + FileSystem fileSystem = mock(FileSystem.class); + when(FileSystem.get(configuration)).thenReturn(fileSystem); + when(fileSystem.create(new Path(testDir), true)).thenThrow(new IOException()); + + hdfsService.write(new Path(testDir), "contents".getBytes(UTF_8)); + } + + @Test + public void deleteShouldWrapExceptionInRestException() throws Exception { + exception.expect(RestException.class); + + FileSystem fileSystem = mock(FileSystem.class); + when(FileSystem.get(configuration)).thenReturn(fileSystem); + when(fileSystem.delete(new Path(testDir), false)).thenThrow(new IOException()); + + hdfsService.delete(new Path(testDir), false); + } +} diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplTest.java index d67892eae8..9c18dc6b8e 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/HdfsServiceImplTest.java @@ -18,100 +18,87 @@ package org.apache.metron.rest.service.impl; import org.apache.commons.io.FileUtils; -import org.apache.hadoop.fs.FileStatus; +import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; -import org.apache.metron.rest.config.HadoopConfig; import org.apache.metron.rest.service.HdfsService; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.junit.rules.ExpectedException; import java.io.File; import java.io.IOException; +import java.util.List; -import static org.apache.metron.rest.MetronRestConstants.TEST_PROFILE; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes={HadoopConfig.class, HdfsServiceImplTest.HdfsServiceTestContextConfiguration.class}) -@ActiveProfiles(TEST_PROFILE) public class HdfsServiceImplTest { + @Rule + public final ExpectedException exception = ExpectedException.none(); - @Configuration - @Profile("test") - static class HdfsServiceTestContextConfiguration { - - @Bean - public HdfsService hdfsService() { - return new HdfsServiceImpl(); + private Configuration configuration; + private HdfsService hdfsService; + private String testDir = "./target/hdfsUnitTest"; + + @Before + public void setup() throws IOException { + configuration = new Configuration(); + hdfsService = new HdfsServiceImpl(configuration); + File file = new File(testDir); + if (!file.exists()) { + file.mkdirs(); } + FileUtils.cleanDirectory(file); } - @Autowired - private HdfsService hdfsService; + @After + public void teardown() throws IOException { + File file = new File(testDir); + FileUtils.cleanDirectory(file); + } @Test - public void test() throws IOException { - String rootDir = "./src/test/tmp"; - File rootFile = new File(rootDir); - Path rootPath = new Path(rootDir); - if (rootFile.exists()) { - FileUtils.cleanDirectory(rootFile); - FileUtils.deleteDirectory(rootFile); - } - assertEquals(true, rootFile.mkdir()); - String fileName1 = "fileName1"; - String fileName2 = "fileName2"; - Path path1 = new Path(rootDir, fileName1); - String value1 = "value1"; - String value2 = "value2"; - Path path2 = new Path(rootDir, fileName2); - String invalidFile = "invalidFile"; - Path pathInvalidFile = new Path(rootDir, invalidFile); - - FileStatus[] fileStatuses = hdfsService.list(new Path(rootDir)); - assertEquals(0, fileStatuses.length); - - - hdfsService.write(path1, value1.getBytes()); - assertEquals(value1, FileUtils.readFileToString(new File(rootDir, fileName1))); - assertEquals(value1, new String(hdfsService.read(path1))); - - fileStatuses = hdfsService.list(rootPath); - assertEquals(1, fileStatuses.length); - assertEquals(fileName1, fileStatuses[0].getPath().getName()); - - hdfsService.write(path2, value2.getBytes()); - assertEquals(value2, FileUtils.readFileToString(new File(rootDir, fileName2))); - assertEquals(value2, new String(hdfsService.read(path2))); - - fileStatuses = hdfsService.list(rootPath); - assertEquals(2, fileStatuses.length); - assertEquals(fileName1, fileStatuses[0].getPath().getName()); - assertEquals(fileName1, fileStatuses[0].getPath().getName()); - - assertEquals(true, hdfsService.delete(path1, false)); - fileStatuses = hdfsService.list(rootPath); - assertEquals(1, fileStatuses.length); - assertEquals(fileName2, fileStatuses[0].getPath().getName()); - assertEquals(true, hdfsService.delete(path2, false)); - fileStatuses = hdfsService.list(rootPath); - assertEquals(0, fileStatuses.length); - - try { - hdfsService.read(pathInvalidFile); - fail("Exception should be thrown when reading invalid file name"); - } catch(IOException e) { - } - assertEquals(false, hdfsService.delete(pathInvalidFile, false)); + public void listShouldListFiles() throws Exception { + FileUtils.writeStringToFile(new File(testDir, "file1.txt"), "value1"); + FileUtils.writeStringToFile(new File(testDir, "file2.txt"), "value2"); + + List paths = hdfsService.list(new Path(testDir)); + assertEquals(2, paths.size()); + assertEquals("file1.txt", paths.get(0)); + assertEquals("file2.txt", paths.get(1)); + } + + + @Test + public void readShouldProperlyReadContents() throws Exception { + String contents = "contents"; + FileUtils.writeStringToFile(new File(testDir, "readTest.txt"), contents); + + assertEquals("contents", hdfsService.read(new Path(testDir, "readTest.txt"))); + } + + @Test + public void writeShouldProperlyWriteContents() throws Exception { + String contents = "contents"; + hdfsService.write(new Path(testDir, "writeTest.txt"), contents.getBytes(UTF_8)); + + assertEquals("contents", FileUtils.readFileToString(new File(testDir, "writeTest.txt"))); + } + + @Test + public void deleteShouldProperlyDeleteFile() throws Exception { + String contents = "contents"; + FileUtils.writeStringToFile(new File(testDir, "deleteTest.txt"), contents); + + List paths = hdfsService.list(new Path(testDir)); + assertEquals(1, paths.size()); + assertEquals("deleteTest.txt", paths.get(0)); + + hdfsService.delete(new Path(testDir, "deleteTest.txt"), false); - FileUtils.deleteDirectory(new File(rootDir)); + paths = hdfsService.list(new Path(testDir)); + assertEquals(0, paths.size()); } } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java index ff05371084..cb26783f16 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java @@ -46,7 +46,7 @@ @SuppressWarnings("unchecked") @RunWith(PowerMockRunner.class) @PrepareForTest({DockerStormCLIWrapper.class, ProcessBuilder.class}) -public class StormCliWrapperTest { +public class StormCLIWrapperTest { @Rule public final ExpectedException exception = ExpectedException.none(); From f26c166dce3039476dda34c282221ea6b42ff0a5 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 13 Feb 2017 14:29:00 -0600 Subject: [PATCH 42/54] Renamed StormCLIWrapperTest.java --- .../impl/{StormCliWrapperTest.java => StormCLIWrapperTest.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/{StormCliWrapperTest.java => StormCLIWrapperTest.java} (100%) diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCLIWrapperTest.java similarity index 100% rename from metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCliWrapperTest.java rename to metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StormCLIWrapperTest.java From 0ca2dc75b6d370ab4c664c675b5f319e64d718b7 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Tue, 14 Feb 2017 17:45:04 -0600 Subject: [PATCH 43/54] Added StellarService unit test --- .../metron/rest/service/StellarService.java | 2 +- .../service/impl/StellarServiceImplTest.java | 91 +++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StellarServiceImplTest.java diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StellarService.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StellarService.java index 18ae56252b..14cd31fc9a 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StellarService.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/StellarService.java @@ -28,7 +28,7 @@ public interface StellarService { Map validateRules(List rules); - Map applyTransformations(SensorParserContext transformationValidation); + Map applyTransformations(SensorParserContext sensorParserContext); FieldTransformations[] getTransformations(); diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StellarServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StellarServiceImplTest.java new file mode 100644 index 0000000000..04a7fa293b --- /dev/null +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StellarServiceImplTest.java @@ -0,0 +1,91 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.metron.rest.service.impl; + +import org.apache.metron.common.configuration.FieldTransformer; +import org.apache.metron.common.configuration.SensorParserConfig; +import org.apache.metron.rest.model.SensorParserContext; +import org.apache.metron.rest.service.StellarService; +import org.apache.storm.shade.com.google.common.collect.ImmutableList; +import org.junit.Before; +import org.junit.Test; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class StellarServiceImplTest { + + private StellarService stellarService; + + @Before + public void setUp() throws Exception { + stellarService = new StellarServiceImpl(); + } + + @Test + public void validateRulesShouldProperlyValidateRules() { + List rules = Arrays.asList("TO_LOWER(test)", "BAD_FUNCTION(test)"); + Map results = stellarService.validateRules(rules); + assertEquals(2, results.size()); + assertEquals(true, results.get("TO_LOWER(test)")); + assertEquals(false, results.get("BAD_FUNCTION(test)")); + } + + @Test + public void applyTransformationsShouldProperlyTransformData() { + SensorParserConfig sensorParserConfig = new SensorParserConfig(); + FieldTransformer fieldTransformater = new FieldTransformer(); + fieldTransformater.setOutput("url_host"); + fieldTransformater.setTransformation("STELLAR"); + fieldTransformater.setConfig(new HashMap() {{ + put("url_host", "TO_LOWER(URL_TO_HOST(url))"); + }}); + sensorParserConfig.setFieldTransformations(ImmutableList.of(fieldTransformater)); + SensorParserContext sensorParserContext = new SensorParserContext(); + sensorParserContext.setSensorParserConfig(sensorParserConfig); + sensorParserContext.setSampleData(new HashMap() {{ + put("url", "https://caseystella.com/blog"); + }}); + Map results = stellarService.applyTransformations(sensorParserContext); + assertEquals(2, results.size()); + assertEquals("https://caseystella.com/blog", results.get("url")); + assertEquals("caseystella.com", results.get("url_host")); + } + + @Test + public void getTransformationsShouldReturnTransformation() { + assertTrue(stellarService.getTransformations().length > 0); + } + + @Test + public void getStellarFunctionsShouldReturnFunctions() { + assertTrue(stellarService.getStellarFunctions().size() > 0); + } + + @Test + public void getSimpleStellarFunctionsShouldReturnFunctions() { + assertEquals(1, stellarService.getSimpleStellarFunctions().stream() + .filter(stellarFunctionDescription -> stellarFunctionDescription.getName().equals("TO_LOWER")).count()); + } + +} From a3545914c7c52c300185dc377b749a23a7e1ce70 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 17 Feb 2017 11:05:23 -0600 Subject: [PATCH 44/54] Removed MySQL dependency and substituted H2. Updated documentation to reflect changes. Also added profile for Quick Dev. --- metron-interface/metron-rest/.gitignore | 1 + metron-interface/metron-rest/README.md | 194 +++++++++++------- metron-interface/metron-rest/pom.xml | 21 +- .../rest/controller/HdfsController.java | 6 +- .../src/main/resources/application-docker.yml | 6 +- .../main/resources/application-vagrant.yml | 51 +++++ .../{start.sh => start_metron_rest.sh} | 16 +- .../metron-rest/src/test/resources/README.vm | 89 ++++---- 8 files changed, 253 insertions(+), 131 deletions(-) create mode 100644 metron-interface/metron-rest/.gitignore create mode 100644 metron-interface/metron-rest/src/main/resources/application-vagrant.yml rename metron-interface/metron-rest/src/main/scripts/{start.sh => start_metron_rest.sh} (65%) diff --git a/metron-interface/metron-rest/.gitignore b/metron-interface/metron-rest/.gitignore new file mode 100644 index 0000000000..608e1deedd --- /dev/null +++ b/metron-interface/metron-rest/.gitignore @@ -0,0 +1 @@ +metrondb.mv.db \ No newline at end of file diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index 63a2d34cb7..0bde6c2ebd 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -1,65 +1,82 @@ -# Metron REST and Configuration UI +# Metron REST -This UI exposes and aids in sensor configuration. +This module provides a RESTful API for interacting with Metron. ## Prerequisites * A running Metron cluster -* A running instance of MySQL * Java 8 installed * Storm CLI and Metron topology scripts (start_parser_topology.sh, start_enrichment_topology.sh, start_elasticsearch_topology.sh) installed ## Installation -1. Package the Application with Maven: - ``` - mvn clean package - ``` +1. Package the application with Maven: +``` +mvn clean package +``` 1. Untar the archive in the target directory. The directory structure will look like: - ``` - bin - start.sh - lib - metron-rest-version.jar - ``` +``` +bin + start_metron_rest.sh +lib + metron-rest-$METRON_VERSION.jar +``` -1. Install Hibernate by downloading version 5.0.11.Final from (http://hibernate.org/orm/downloads/). Unpack the archive and set the HIBERNATE_HOME environment variable to the absolute path of the top level directory. - ``` - export HIBERNATE_HOME=/path/to/hibernate-release-5.0.11.Final - ``` +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. Install the MySQL client by downloading version 5.1.40 from (https://dev.mysql.com/downloads/connector/j/). Unpack the archive and set the MYSQL_CLIENT_HOME environment variable to the absolute path of the top level directory. - ``` - export MYSQL_CLIENT_HOME=/path/to/mysql-connector-java-5.1.40 - ``` +1. Start the application with this command: +``` +./bin/start_metron_rest.sh /path/to/application.yml +``` -1. Create a MySQL user for the Config UI (http://dev.mysql.com/doc/refman/5.7/en/adding-users.html). +## Usage -1. Create a Config UI database in MySQL with this command: - ``` - CREATE DATABASE IF NOT EXISTS metronrest - ``` +The exposed REST endpoints can be accessed with the Swagger UI at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. -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.username` and `spring.datasource.password` properties using the MySQL credentials from step 4. +## Security -1. Start the UI with this command: - ``` - ./bin/start.sh /path/to/application.yml - ``` +The metron-rest module uses [Spring Security](http://projects.spring.io/spring-security/) for authentication and stores user credentials in a relational database. The H2 database is configured by default and is intended only for development purposes. The "dev" profile can be used to automatically load test users: +``` +./bin/start_metron_rest.sh /path/to/application.yml --spring.profiles.active=dev +``` -## Usage +For [production use](http://docs.spring.io/spring-boot/docs/1.4.1.RELEASE/reference/htmlsingle/#boot-features-connect-to-production-database), a relational database should be configured. For example, configuring MySQL would be done as follows: -The exposed REST endpoints can be accessed with the Swagger UI at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. Users can be added with this SQL statement: +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 +``` + +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'); ``` -Users can be added to additional groups with this SQL statement: + +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 ``` -use metronrest; -insert into authorities (username, authority) values ('your_username', 'your_group'); + +1. Add a dependency for the MySQL JDBC connector in the metron-rest pom.xml: ``` + + mysql + mysql-connector-java + ${mysql.client.version} + +``` + +1. Follow the steps in the [Installation](#installation) section ## API @@ -72,6 +89,10 @@ Request and Response objects are JSON formatted. The JSON schemas are available | [ `POST /api/v1/global/config`](#post-apiv1globalconfig)| | [ `GET /api/v1/grok/list`](#get-apiv1groklist)| | [ `POST /api/v1/grok/validate`](#post-apiv1grokvalidate)| +| [ `POST /api/v1/hdfs`](#post-apiv1hdfs)| +| [ `GET /api/v1/hdfs`](#get-apiv1hdfs)| +| [ `DELETE /api/v1/hdfs`](#delete-apiv1hdfs)| +| [ `GET /api/v1/hdfs/list`](#get-apiv1hdfslist)| | [ `GET /api/v1/kafka/topic`](#get-apiv1kafkatopic)| | [ `POST /api/v1/kafka/topic`](#post-apiv1kafkatopic)| | [ `GET /api/v1/kafka/topic/{name}`](#get-apiv1kafkatopic{name})| @@ -93,6 +114,11 @@ Request and Response objects are JSON formatted. The JSON schemas are available | [ `GET /api/v1/sensor/parser/config/reload/available`](#get-apiv1sensorparserconfigreloadavailable)| | [ `DELETE /api/v1/sensor/parser/config/{name}`](#delete-apiv1sensorparserconfig{name})| | [ `GET /api/v1/sensor/parser/config/{name}`](#get-apiv1sensorparserconfig{name})| +| [ `POST /api/v1/stellar/apply/transformations`](#post-apiv1stellarapplytransformations)| +| [ `GET /api/v1/stellar/list`](#get-apiv1stellarlist)| +| [ `GET /api/v1/stellar/list/functions`](#get-apiv1stellarlistfunctions)| +| [ `GET /api/v1/stellar/list/simple/functions`](#get-apiv1stellarlistsimplefunctions)| +| [ `POST /api/v1/stellar/validate/rules`](#post-apiv1stellarvalidaterules)| | [ `GET /api/v1/storm`](#get-apiv1storm)| | [ `GET /api/v1/storm/client/status`](#get-apiv1stormclientstatus)| | [ `GET /api/v1/storm/enrichment`](#get-apiv1stormenrichment)| @@ -110,11 +136,6 @@ Request and Response objects are JSON formatted. The JSON schemas are available | [ `GET /api/v1/storm/parser/start/{name}`](#get-apiv1stormparserstart{name})| | [ `GET /api/v1/storm/parser/stop/{name}`](#get-apiv1stormparserstop{name})| | [ `GET /api/v1/storm/{name}`](#get-apiv1storm{name})| -| [ `GET /api/v1/transformation/list`](#get-apiv1transformationlist)| -| [ `GET /api/v1/transformation/list/functions`](#get-apiv1transformationlistfunctions)| -| [ `GET /api/v1/transformation/list/simple/functions`](#get-apiv1transformationlistsimplefunctions)| -| [ `POST /api/v1/transformation/validate`](#post-apiv1transformationvalidate)| -| [ `POST /api/v1/transformation/validate/rules`](#post-apiv1transformationvalidaterules)| | [ `GET /api/v1/user`](#get-apiv1user)| ### `GET /api/v1/global/config` @@ -145,10 +166,41 @@ Request and Response objects are JSON formatted. The JSON schemas are available ### `POST /api/v1/grok/validate` * Description: Applies a Grok statement to a sample message * Input: - * grokValidation - Object containing Grok statment and sample message + * grokValidation - Object containing Grok statement and sample message * Returns: * 200 - JSON results +### `POST /api/v1/hdfs` + * Description: Writes contents to an HDFS file + * Input: + * path - Path to HDFS file + * contents - File contents + * Returns: + * 200 - Contents were written + +### `GET /api/v1/hdfs` + * Description: Reads a file from HDFS and returns the contents + * Input: + * path - Path to HDFS file + * Returns: + * 200 - Returns file contents + +### `DELETE /api/v1/hdfs` + * Description: Deletes a file from HDFS + * Input: + * path - Path to HDFS file + * recursive - Delete files recursively + * Returns: + * 200 - File was deleted + * 404 - File was not found in HDFS + +### `GET /api/v1/hdfs/list` + * Description: Reads a file from HDFS and returns the contents + * Input: + * path - Path to HDFS directory + * Returns: + * 200 - Returns file contents + ### `GET /api/v1/kafka/topic` * Description: Retrieves all Kafka topics * Returns: @@ -296,6 +348,35 @@ Request and Response objects are JSON formatted. The JSON schemas are available * 200 - Returns SensorParserConfig * 404 - SensorParserConfig is missing +### `POST /api/v1/stellar/apply/transformations` + * Description: Executes transformations against a sample message + * Input: + * transformationValidation - Object containing SensorParserConfig and sample message + * Returns: + * 200 - Returns transformation results + +### `GET /api/v1/stellar/list` + * Description: Retrieves field transformations + * Returns: + * 200 - Returns a list field transformations + +### `GET /api/v1/stellar/list/functions` + * Description: Lists the Stellar functions that can be found on the classpath + * Returns: + * 200 - Returns a list of Stellar functions + +### `GET /api/v1/stellar/list/simple/functions` + * Description: Lists the simple Stellar functions (functions with only 1 input) that can be found on the classpath + * Returns: + * 200 - Returns a list of simple Stellar functions + +### `POST /api/v1/stellar/validate/rules` + * Description: Tests Stellar statements to ensure they are well-formed + * Input: + * statements - List of statements to validate + * Returns: + * 200 - Returns validation results + ### `GET /api/v1/storm` * Description: Retrieves the status of all Storm topologies * Returns: @@ -399,35 +480,6 @@ Request and Response objects are JSON formatted. The JSON schemas are available * 200 - Returns topology status information * 404 - Topology is missing -### `GET /api/v1/transformation/list` - * Description: Retrieves field transformations - * Returns: - * 200 - Returns a list field transformations - -### `GET /api/v1/transformation/list/functions` - * Description: Lists the Stellar functions that can be found on the classpath - * Returns: - * 200 - Returns a list of Stellar functions - -### `GET /api/v1/transformation/list/simple/functions` - * Description: Lists the simple Stellar functions (functions with only 1 input) that can be found on the classpath - * Returns: - * 200 - Returns a list of simple Stellar functions - -### `POST /api/v1/transformation/validate` - * Description: Executes transformations against a sample message - * Input: - * transformationValidation - Object containing SensorParserConfig and sample message - * Returns: - * 200 - Returns transformation results - -### `POST /api/v1/transformation/validate/rules` - * Description: Tests Stellar statements to ensure they are well-formed - * Input: - * statements - List of statements to validate - * Returns: - * 200 - Returns validation results - ### `GET /api/v1/user` * Description: Retrieves the current user * Returns: diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index c2beb2d5f4..61085a3e63 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -60,16 +60,16 @@ org.springframework.boot spring-boot-starter-jdbc - - mysql - mysql-connector-java - ${mysql.client.version} - provided - org.apache.curator curator-recipes ${curator.version} + + + com.google.guava + guava + + com.googlecode.json-simple @@ -120,10 +120,18 @@ org.apache.metron metron-profiler-client + + org.apache.metron + metron-statistics + org.apache.metron metron-writer + + com.google.guava + guava + @@ -166,7 +174,6 @@ com.h2database h2 - test org.springframework.security diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java index 83b3ddc02e..3d56d7b4e5 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.apache.hadoop.fs.Path; import org.apache.metron.rest.RestException; import org.apache.metron.rest.service.HdfsService; @@ -73,8 +74,9 @@ ResponseEntity write(@ApiParam(name="path", value="Path to HDFS file", req } - @ApiOperation(value = "Retrieves field transformations") - @ApiResponse(message = "Returns a list field transformations", code = 200) + @ApiOperation(value = "Deletes a file from HDFS") + @ApiResponses(value = { @ApiResponse(message = "File was deleted", code = 200), + @ApiResponse(message = "File was not found in HDFS", code = 404) }) @RequestMapping(method = RequestMethod.DELETE) ResponseEntity delete(@ApiParam(name = "path", value = "Path to HDFS file", required = true) @RequestParam String path, @ApiParam(name = "recursive", value = "Delete files recursively") @RequestParam(required = false, defaultValue = "false") boolean recursive) throws RestException { diff --git a/metron-interface/metron-rest/src/main/resources/application-docker.yml b/metron-interface/metron-rest/src/main/resources/application-docker.yml index 859ca5ee40..5891417364 100644 --- a/metron-interface/metron-rest/src/main/resources/application-docker.yml +++ b/metron-interface/metron-rest/src/main/resources/application-docker.yml @@ -21,11 +21,11 @@ docker: spring: datasource: - driverClassName: com.mysql.jdbc.Driver - url: jdbc:mysql://${docker.host.address}:3306/metronrest + driverClassName: org.h2.Driver + url: jdbc:h2:file:./metrondb username: root password: root - platform: mysql + platform: h2 jpa: hibernate: ddl-auto: update diff --git a/metron-interface/metron-rest/src/main/resources/application-vagrant.yml b/metron-interface/metron-rest/src/main/resources/application-vagrant.yml new file mode 100644 index 0000000000..76bef56748 --- /dev/null +++ b/metron-interface/metron-rest/src/main/resources/application-vagrant.yml @@ -0,0 +1,51 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +spring: + datasource: + driverClassName: org.h2.Driver + url: jdbc:h2:file:./metrondb + username: root + password: root + platform: h2 + jpa: + hibernate: + ddl-auto: update + +zookeeper: + url: node1:2181 + +kafka: + broker: + url: node1:6667 + +hdfs: + namenode: + url: hdfs://node1:8020 + +grok: + path: + temp: ./patterns/temp + default: /apps/metron/patterns + +storm: + ui: + url: node1:8744 + parser: + script.path: /usr/metron/${metron.version}/bin/start_parser_topology.sh + enrichment: + script.path: /usr/metron/${metron.version}/bin/start_enrichment_topology.sh + indexing: + script.path: /usr/metron/${metron.version}/bin/start_elasticsearch_topology.sh diff --git a/metron-interface/metron-rest/src/main/scripts/start.sh b/metron-interface/metron-rest/src/main/scripts/start_metron_rest.sh similarity index 65% rename from metron-interface/metron-rest/src/main/scripts/start.sh rename to metron-interface/metron-rest/src/main/scripts/start_metron_rest.sh index d83a2fd846..ea5d6c903d 100755 --- a/metron-interface/metron-rest/src/main/scripts/start.sh +++ b/metron-interface/metron-rest/src/main/scripts/start_metron_rest.sh @@ -15,19 +15,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # -METRON_VERSION=0.3.0 +METRON_VERSION=${project.version} SCRIPTS_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -if [ "$#" -ne 1 ]; then - echo "Usage: start.sh " +if [ "$#" -lt 1 ]; then + echo "Usage: start.sh " echo "Path can be absolute or relative to $SCRIPTS_ROOT" else - if [ -z "$MYSQL_CLIENT_HOME" ]; then - echo MYSQL_CLIENT_HOME is not set - else - if [ -z "$HIBERNATE_HOME" ]; then - echo HIBERNATE_HOME is not set - else - java -Dloader.path=$MYSQL_CLIENT_HOME/*,$HIBERNATE_HOME/lib/envers/*,$HIBERNATE_HOME/lib/jpa/*,$HIBERNATE_HOME/lib/required/* -jar $SCRIPTS_ROOT/../lib/metron-rest-$METRON_VERSION.jar --spring.config.location=$1 - fi - fi + java -jar $SCRIPTS_ROOT/../lib/metron-rest-$METRON_VERSION.jar --spring.config.location=$@ fi \ No newline at end of file diff --git a/metron-interface/metron-rest/src/test/resources/README.vm b/metron-interface/metron-rest/src/test/resources/README.vm index f259a91602..4ef561bbab 100644 --- a/metron-interface/metron-rest/src/test/resources/README.vm +++ b/metron-interface/metron-rest/src/test/resources/README.vm @@ -1,65 +1,82 @@ -#[[#]]# Metron REST and Configuration UI +#[[#]]# Metron REST -This UI exposes and aids in sensor configuration. +This module provides a RESTful API for interacting with Metron. #[[##]]# Prerequisites * A running Metron cluster -* A running instance of MySQL * Java 8 installed * Storm CLI and Metron topology scripts (start_parser_topology.sh, start_enrichment_topology.sh, start_elasticsearch_topology.sh) installed #[[##]]# Installation -1. Package the Application with Maven: - ``` - mvn clean package - ``` +1. Package the application with Maven: +``` +mvn clean package +``` 1. Untar the archive in the target directory. The directory structure will look like: - ``` - bin - start.sh - lib - metron-rest-version.jar - ``` +``` +bin + start_metron_rest.sh +lib + metron-rest-$METRON_VERSION.jar +``` -1. Install Hibernate by downloading version 5.0.11.Final from (http://hibernate.org/orm/downloads/). Unpack the archive and set the HIBERNATE_HOME environment variable to the absolute path of the top level directory. - ``` - export HIBERNATE_HOME=/path/to/hibernate-release-5.0.11.Final - ``` +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. Install the MySQL client by downloading version 5.1.40 from (https://dev.mysql.com/downloads/connector/j/). Unpack the archive and set the MYSQL_CLIENT_HOME environment variable to the absolute path of the top level directory. - ``` - export MYSQL_CLIENT_HOME=/path/to/mysql-connector-java-5.1.40 - ``` +1. Start the application with this command: +``` +./bin/start_metron_rest.sh /path/to/application.yml +``` -1. Create a MySQL user for the Config UI (http://dev.mysql.com/doc/refman/5.7/en/adding-users.html). +#[[##]]# Usage -1. Create a Config UI database in MySQL with this command: - ``` - CREATE DATABASE IF NOT EXISTS metronrest - ``` +The exposed REST endpoints can be accessed with the Swagger UI at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. -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.username` and `spring.datasource.password` properties using the MySQL credentials from step 4. +#[[##]]# Security -1. Start the UI with this command: - ``` - ./bin/start.sh /path/to/application.yml - ``` +The metron-rest module uses [Spring Security](http://projects.spring.io/spring-security/) for authentication and stores user credentials in a relational database. The H2 database is configured by default and is intended only for development purposes. The "dev" profile can be used to automatically load test users: +``` +./bin/start_metron_rest.sh /path/to/application.yml --spring.profiles.active=dev +``` -#[[##]]# Usage +For [production use](http://docs.spring.io/spring-boot/docs/1.4.1.RELEASE/reference/htmlsingle/#boot-features-connect-to-production-database), a relational database should be configured. For example, configuring MySQL would be done as follows: -The exposed REST endpoints can be accessed with the Swagger UI at http://host:port/swagger-ui.html#/. The default port is 8080 but can be changed in application.yml by setting "server.port" to the desired port. Users can be added with this SQL statement: +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 +``` + +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'); ``` -Users can be added to additional groups with this SQL statement: + +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 ``` -use metronrest; -insert into authorities (username, authority) values ('your_username', 'your_group'); + +1. Add a dependency for the MySQL JDBC connector in the metron-rest pom.xml: ``` + + mysql + mysql-connector-java + ${mysql.client.version} + +``` + +1. Follow the steps in the [Installation](#installation) section #[[##]]# API From 940f7ba0b87289d524ff5c69a0d3a4d00b4812b2 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Fri, 17 Feb 2017 15:48:04 -0600 Subject: [PATCH 45/54] Documented testing on metron-docker and quick dev --- metron-interface/metron-rest/README.md | 32 ++++++++++++++++++ .../metron-rest/src/test/resources/README.vm | 33 +++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index 0bde6c2ebd..a4518fa7cc 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -485,6 +485,38 @@ Request and Response objects are JSON formatted. The JSON schemas are available * Returns: * 200 - Current user +## Testing + +Profiles are includes for both the metron-docker and Quick Dev environments. + +### metron-docker + +Start the [metron-docker](../../metron-docker) environment. Build the metron-rest module and start it with the Spring Boot Maven plugin: +``` +mvn clean package +mvn spring-boot:run -Drun.profiles=docker,dev +``` +The metron-rest application will be available at http://localhost:8080/swagger-ui.html#/. + +### Quick Dev + +Start the [Quick Dev](../../metron-deployment/vagrant/quick-dev-platform) environment. Build the metron-rest module and start it with the Spring Boot Maven plugin: +``` +mvn clean package +mvn spring-boot:run -Drun.profiles=vagrant,dev +``` +The metron-rest application will be available at http://localhost:8080/swagger-ui.html#/. + +To run the application locally on the Quick Dev host, package the application and scp the archive to node1: +``` +mvn clean package +scp ./target/metron-rest-$METRON_VERSION-archive.tar.gz root@node1:~/ +``` +Login to node1 and unarchive the metron-rest application. Start the application on a different port to avoid conflicting with Ambari: +``` +java -jar ./lib/metron-rest-0.3.0.jar --spring.profiles.active=vagrant,dev --server.port=8082 +``` +The metron-rest application will be available at http://node1:8082/swagger-ui.html#/. ## License diff --git a/metron-interface/metron-rest/src/test/resources/README.vm b/metron-interface/metron-rest/src/test/resources/README.vm index 4ef561bbab..ab35b1fa1b 100644 --- a/metron-interface/metron-rest/src/test/resources/README.vm +++ b/metron-interface/metron-rest/src/test/resources/README.vm @@ -104,6 +104,39 @@ Request and Response objects are JSON formatted. The JSON schemas are available #end +#[[##]]# Testing + +Profiles are includes for both the metron-docker and Quick Dev environments. + +#[[###]]# metron-docker + +Start the [metron-docker](../../metron-docker) environment. Build the metron-rest module and start it with the Spring Boot Maven plugin: +``` +mvn clean package +mvn spring-boot:run -Drun.profiles=docker,dev +``` +The metron-rest application will be available at http://localhost:8080/swagger-ui.html#/. + +#[[###]]# Quick Dev + +Start the [Quick Dev](../../metron-deployment/vagrant/quick-dev-platform) environment. Build the metron-rest module and start it with the Spring Boot Maven plugin: +``` +mvn clean package +mvn spring-boot:run -Drun.profiles=vagrant,dev +``` +The metron-rest application will be available at http://localhost:8080/swagger-ui.html#/. + +To run the application locally on the Quick Dev host, package the application and scp the archive to node1: +``` +mvn clean package +scp ./target/metron-rest-$METRON_VERSION-archive.tar.gz root@node1:~/ +``` +Login to node1 and unarchive the metron-rest application. Start the application on a different port to avoid conflicting with Ambari: +``` +java -jar ./lib/metron-rest-0.3.0.jar --spring.profiles.active=vagrant,dev --server.port=8082 +``` +The metron-rest application will be available at http://node1:8082/swagger-ui.html#/. + #[[##]]# License This project depends on the Java Transaction API. See https://java.net/projects/jta-spec/ for more details. From 65f5173bdca1cec08f801887420f605c726cc7fd Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 20 Feb 2017 12:47:50 -0600 Subject: [PATCH 46/54] Updated test to match new SensorEnrichmentConfig structure --- ...chmentConfigControllerIntegrationTest.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) 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 a6597721ee..0c9e18c430 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 @@ -94,9 +94,12 @@ public class SensorEnrichmentConfigControllerIntegrationTest { ] }, "triageConfig": { - "riskLevelRules": { - "ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'": 10 - }, + "riskLevelRules": [ + { + "rule": "ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'", + "score": 10 + } + ], "aggregator": "MAX" } } @@ -160,7 +163,8 @@ public void test() throws Exception { .andExpect(jsonPath("$.threatIntel.fieldMap.hbaseThreatIntel[1]").value("ip_dst_addr")) .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_src_addr[0]").value("malicious_ip")) .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_dst_addr[0]").value("malicious_ip")) - .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) + .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[0].rule").value("ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'")) + .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[0].score").value(10)) .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); this.mockMvc.perform(post(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user, password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(broJson)) @@ -177,7 +181,8 @@ public void test() throws Exception { .andExpect(jsonPath("$.threatIntel.fieldMap.hbaseThreatIntel[1]").value("ip_dst_addr")) .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_src_addr[0]").value("malicious_ip")) .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_dst_addr[0]").value("malicious_ip")) - .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) + .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[0].rule").value("ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'")) + .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[0].score").value(10)) .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); this.mockMvc.perform(get(sensorEnrichmentConfigUrl + "/broTest").with(httpBasic(user,password))) @@ -194,7 +199,8 @@ public void test() throws Exception { .andExpect(jsonPath("$.threatIntel.fieldMap.hbaseThreatIntel[1]").value("ip_dst_addr")) .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_src_addr[0]").value("malicious_ip")) .andExpect(jsonPath("$.threatIntel.fieldToTypeMap.ip_dst_addr[0]").value("malicious_ip")) - .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"]").value(10)) + .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[0].rule").value("ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'")) + .andExpect(jsonPath("$.threatIntel.triageConfig.riskLevelRules[0].score").value(10)) .andExpect(jsonPath("$.threatIntel.triageConfig.aggregator").value("MAX")); this.mockMvc.perform(get(sensorEnrichmentConfigUrl).with(httpBasic(user,password))) @@ -211,7 +217,8 @@ public void test() throws Exception { "@.broTest.threatIntel.fieldMap.hbaseThreatIntel[1] == 'ip_dst_addr' &&" + "@.broTest.threatIntel.fieldToTypeMap.ip_src_addr[0] == 'malicious_ip' &&" + "@.broTest.threatIntel.fieldToTypeMap.ip_dst_addr[0] == 'malicious_ip' &&" + - "@.broTest.threatIntel.triageConfig.riskLevelRules[\"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\"] == 10 &&" + + "@.broTest.threatIntel.triageConfig.riskLevelRules[0].rule == \"ip_src_addr == '10.122.196.204' or ip_dst_addr == '10.122.196.204'\" &&" + + "@.broTest.threatIntel.triageConfig.riskLevelRules[0].score == 10 &&" + "@.broTest.threatIntel.triageConfig.aggregator == 'MAX'" + ")]").exists()); From a3d36d2e02b49b0108619eb7dd116b8e2f9b6c80 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 20 Feb 2017 12:48:53 -0600 Subject: [PATCH 47/54] Updated version number --- metron-interface/metron-rest-client/pom.xml | 2 +- metron-interface/metron-rest/pom.xml | 2 +- metron-interface/metron-rest/src/main/resources/application.yml | 2 +- metron-interface/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/metron-interface/metron-rest-client/pom.xml b/metron-interface/metron-rest-client/pom.xml index 66ccf52ce4..0a49986784 100644 --- a/metron-interface/metron-rest-client/pom.xml +++ b/metron-interface/metron-rest-client/pom.xml @@ -18,7 +18,7 @@ org.apache.metron metron-interface - 0.3.0 + 0.3.1 metron-rest-client diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index 61085a3e63..0e765821b7 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -18,7 +18,7 @@ org.apache.metron metron-interface - 0.3.0 + 0.3.1 metron-rest diff --git a/metron-interface/metron-rest/src/main/resources/application.yml b/metron-interface/metron-rest/src/main/resources/application.yml index 7e45ed984b..2bb1462030 100644 --- a/metron-interface/metron-rest/src/main/resources/application.yml +++ b/metron-interface/metron-rest/src/main/resources/application.yml @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. metron: - version: 0.3.0 + version: 0.3.1 logging: level: diff --git a/metron-interface/pom.xml b/metron-interface/pom.xml index 078da198b6..805c024649 100644 --- a/metron-interface/pom.xml +++ b/metron-interface/pom.xml @@ -21,7 +21,7 @@ org.apache.metron Metron - 0.3.0 + 0.3.1 Interfaces for Metron https://metron.incubator.apache.org/ From 39ffba88dabbaf2e94864573e79dcdbf1e3ae0d0 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 20 Feb 2017 12:50:53 -0600 Subject: [PATCH 48/54] Updated validateGrokStatement function to accept a patternLabel input --- .../metron/rest/model/GrokValidation.java | 13 +++++++++- .../rest/service/impl/GrokServiceImpl.java | 17 +++++++------ .../GrokControllerIntegrationTest.java | 24 +++++++++++++++--- .../service/impl/GrokServiceImplTest.java | 25 +++++++++++++++++-- 4 files changed, 64 insertions(+), 15 deletions(-) diff --git a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java index ccd2c5c5c5..279532066a 100644 --- a/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java +++ b/metron-interface/metron-rest-client/src/main/java/org/apache/metron/rest/model/GrokValidation.java @@ -22,10 +22,19 @@ public class GrokValidation { + private String patternLabel; private String statement; private String sampleData; private Map results; + public String getPatternLabel() { + return patternLabel; + } + + public void setPatternLabel(String patternLabel) { + this.patternLabel = patternLabel; + } + public String getStatement() { return statement; } @@ -60,6 +69,7 @@ public boolean equals(Object o) { GrokValidation that = (GrokValidation) o; + if (patternLabel != null ? !patternLabel.equals(that.patternLabel) : that.patternLabel != null) return false; if (statement != null ? !statement.equals(that.statement) : that.statement != null) return false; if (sampleData != null ? !sampleData.equals(that.sampleData) : that.sampleData != null) return false; return results != null ? results.equals(that.results) : that.results == null; @@ -67,7 +77,8 @@ public boolean equals(Object o) { @Override public int hashCode() { - int result = statement != null ? statement.hashCode() : 0; + int result = patternLabel != null ? patternLabel.hashCode() : 0; + result = 31 * result + (statement != null ? statement.hashCode() : 0); result = 31 * result + (sampleData != null ? sampleData.hashCode() : 0); result = 31 * result + (results != null ? results.hashCode() : 0); return result; diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java index e69d1b4665..3f2de2f62a 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/service/impl/GrokServiceImpl.java @@ -61,20 +61,21 @@ public Map getCommonGrokPatterns() { public GrokValidation validateGrokStatement(GrokValidation grokValidation) throws RestException { Map results; try { - String statement = Strings.isEmpty(grokValidation.getStatement()) ? "" : grokValidation.getStatement(); - + if (grokValidation.getPatternLabel() == null) { + throw new RestException("Pattern label is required"); + } + if (Strings.isEmpty(grokValidation.getStatement())) { + throw new RestException("Grok statement is required"); + } Grok grok = new Grok(); grok.addPatternFromReader(new InputStreamReader(getClass().getResourceAsStream("/patterns/common"))); - grok.addPatternFromReader(new StringReader(statement)); - String patternLabel = statement.substring(0, statement.indexOf(" ")); - String grokPattern = "%{" + patternLabel + "}"; + grok.addPatternFromReader(new StringReader(grokValidation.getStatement())); + String grokPattern = "%{" + grokValidation.getPatternLabel() + "}"; grok.compile(grokPattern); Match gm = grok.match(grokValidation.getSampleData()); gm.captures(); results = gm.toMap(); - results.remove(patternLabel); - } catch (StringIndexOutOfBoundsException e) { - throw new RestException("A pattern label must be included (eg. PATTERN_LABEL %{PATTERN:field} ...)", e.getCause()); + results.remove(grokValidation.getPatternLabel()); } catch (Exception e) { throw new RestException(e); } diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java index 45326164cb..e0a9c5baf6 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/controller/GrokControllerIntegrationTest.java @@ -48,6 +48,7 @@ public class GrokControllerIntegrationTest { /** { "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html", + "patternLabel":"SQUID", "statement":"SQUID %{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}" } */ @@ -57,11 +58,20 @@ public class GrokControllerIntegrationTest { /** { "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html", - "statement":"" + "statement":"SQUID %{NUMBER:timestamp} %{INT:elapsed} %{IPV4:ip_src_addr} %{WORD:action}/%{NUMBER:code} %{NUMBER:bytes} %{WORD:method} %{NOTSPACE:url} - %{WORD:UNWANTED}\/%{IPV4:ip_dst_addr} %{WORD:UNWANTED}\/%{WORD:UNWANTED}" + } + */ + @Multiline + public static String missingPatternLabelGrokValidationJson; + + /** + { + "sampleData":"1467011157.401 415 127.0.0.1 TCP_MISS/200 337891 GET http://www.aliexpress.com/af/shoes.html? - DIRECT/207.109.73.154 text/html", + "patternLabel":"SQUID" } */ @Multiline - public static String badGrokValidationJson; + public static String missingStatementGrokValidationJson; @Autowired private WebApplicationContext wac; @@ -101,11 +111,17 @@ public void test() throws Exception { .andExpect(jsonPath("$.results.timestamp").value("1467011157.401")) .andExpect(jsonPath("$.results.url").value("http://www.aliexpress.com/af/shoes.html?")); - this.mockMvc.perform(post(grokUrl + "/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(badGrokValidationJson)) + this.mockMvc.perform(post(grokUrl + "/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(missingPatternLabelGrokValidationJson)) + .andExpect(status().isInternalServerError()) + .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) + .andExpect(jsonPath("$.responseCode").value(500)) + .andExpect(jsonPath("$.message").value("Pattern label is required")); + + this.mockMvc.perform(post(grokUrl + "/validate").with(httpBasic(user,password)).with(csrf()).contentType(MediaType.parseMediaType("application/json;charset=UTF-8")).content(missingStatementGrokValidationJson)) .andExpect(status().isInternalServerError()) .andExpect(content().contentType(MediaType.parseMediaType("application/json;charset=UTF-8"))) .andExpect(jsonPath("$.responseCode").value(500)) - .andExpect(jsonPath("$.message").value("A pattern label must be included (eg. PATTERN_LABEL %{PATTERN:field} ...)")); + .andExpect(jsonPath("$.message").value("Grok statement is required")); this.mockMvc.perform(get(grokUrl + "/list").with(httpBasic(user,password))) .andExpect(status().isOk()) 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 ffef9b9551..6dd95c5808 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 @@ -87,14 +87,28 @@ public void getCommonGrokPattersShouldCallGrokToGetPatternsAndNotAlterValue() th assertEquals(expected, grokService.getCommonGrokPatterns()); } + @Test + public void validateGrokStatementShouldThrowExceptionWithNullStringAsPatternLabel() throws Exception { + exception.expect(RestException.class); + exception.expectMessage("Pattern label is required"); + + GrokValidation grokValidation = new GrokValidation(); + grokValidation.setResults(new HashMap<>()); + grokValidation.setSampleData("asdf asdf"); + grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + + grokService.validateGrokStatement(grokValidation); + } + @Test public void validateGrokStatementShouldThrowExceptionWithEmptyStringAsStatement() throws Exception { exception.expect(RestException.class); - exception.expectMessage("A pattern label must be included (eg. PATTERN_LABEL %{PATTERN:field} ...)"); + exception.expectMessage("Grok statement is required"); GrokValidation grokValidation = new GrokValidation(); grokValidation.setResults(new HashMap<>()); grokValidation.setSampleData("asdf asdf"); + grokValidation.setPatternLabel("LABEL"); grokValidation.setStatement(""); grokService.validateGrokStatement(grokValidation); @@ -103,11 +117,12 @@ public void validateGrokStatementShouldThrowExceptionWithEmptyStringAsStatement( @Test public void validateGrokStatementShouldThrowExceptionWithNullStringAsStatement() throws Exception { exception.expect(RestException.class); - exception.expectMessage("A pattern label must be included (eg. PATTERN_LABEL %{PATTERN:field} ...)"); + exception.expectMessage("Grok statement is required"); GrokValidation grokValidation = new GrokValidation(); grokValidation.setResults(new HashMap<>()); grokValidation.setSampleData("asdf asdf"); + grokValidation.setPatternLabel("LABEL"); grokValidation.setStatement(null); grokService.validateGrokStatement(grokValidation); @@ -119,11 +134,13 @@ public void validateGrokStatementShouldProperlyMatchSampleDataAgainstGivenStatem grokValidation.setResults(new HashMap<>()); grokValidation.setSampleData("asdf asdf"); grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + grokValidation.setPatternLabel("LABEL"); GrokValidation expected = new GrokValidation(); expected.setResults(new HashMap() {{ put("word1", "asdf"); put("word2", "asdf"); }}); expected.setSampleData("asdf asdf"); expected.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + expected.setPatternLabel("LABEL"); GrokValidation actual = grokService.validateGrokStatement(grokValidation); assertEquals(expected, actual); @@ -135,11 +152,13 @@ public void validateGrokStatementShouldProperlyMatchNothingAgainstEmptyString() final GrokValidation grokValidation = new GrokValidation(); grokValidation.setResults(new HashMap<>()); grokValidation.setSampleData(""); + grokValidation.setPatternLabel("LABEL"); grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); GrokValidation expected = new GrokValidation(); expected.setResults(new HashMap<>()); expected.setSampleData(""); + expected.setPatternLabel("LABEL"); expected.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); assertEquals(expected, grokService.validateGrokStatement(grokValidation)); @@ -151,11 +170,13 @@ public void validateGrokStatementShouldProperlyMatchNothingAgainstNullString() t grokValidation.setResults(new HashMap<>()); grokValidation.setSampleData(null); grokValidation.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + grokValidation.setPatternLabel("LABEL"); GrokValidation expected = new GrokValidation(); expected.setResults(new HashMap<>()); expected.setSampleData(null); expected.setStatement("LABEL %{WORD:word1} %{WORD:word2}"); + expected.setPatternLabel("LABEL"); assertEquals(expected, grokService.validateGrokStatement(grokValidation)); } From 23cd26edc714071fff8878f9626e6a13f60529de Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 20 Feb 2017 12:53:17 -0600 Subject: [PATCH 49/54] Added $METRON_VERSION instead of hardcoded version --- metron-interface/metron-rest/README.md | 2 +- metron-interface/metron-rest/src/test/resources/README.vm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index a4518fa7cc..9f2a0c25b8 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -514,7 +514,7 @@ scp ./target/metron-rest-$METRON_VERSION-archive.tar.gz root@node1:~/ ``` Login to node1 and unarchive the metron-rest application. Start the application on a different port to avoid conflicting with Ambari: ``` -java -jar ./lib/metron-rest-0.3.0.jar --spring.profiles.active=vagrant,dev --server.port=8082 +java -jar ./lib/metron-rest-$METRON_VERSION.jar --spring.profiles.active=vagrant,dev --server.port=8082 ``` The metron-rest application will be available at http://node1:8082/swagger-ui.html#/. diff --git a/metron-interface/metron-rest/src/test/resources/README.vm b/metron-interface/metron-rest/src/test/resources/README.vm index ab35b1fa1b..bae40b6e09 100644 --- a/metron-interface/metron-rest/src/test/resources/README.vm +++ b/metron-interface/metron-rest/src/test/resources/README.vm @@ -133,7 +133,7 @@ scp ./target/metron-rest-$METRON_VERSION-archive.tar.gz root@node1:~/ ``` Login to node1 and unarchive the metron-rest application. Start the application on a different port to avoid conflicting with Ambari: ``` -java -jar ./lib/metron-rest-0.3.0.jar --spring.profiles.active=vagrant,dev --server.port=8082 +java -jar ./lib/metron-rest-$METRON_VERSION.jar --spring.profiles.active=vagrant,dev --server.port=8082 ``` The metron-rest application will be available at http://node1:8082/swagger-ui.html#/. From cc84429501c37656506b97fd7aa52df587fb2ee0 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 20 Feb 2017 12:57:21 -0600 Subject: [PATCH 50/54] Added overwrite warning to HdfsController --- metron-interface/metron-rest/README.md | 2 +- .../java/org/apache/metron/rest/controller/HdfsController.java | 2 +- metron-interface/metron-rest/src/test/resources/README.vm | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/metron-interface/metron-rest/README.md b/metron-interface/metron-rest/README.md index 9f2a0c25b8..cf41bf33e4 100644 --- a/metron-interface/metron-rest/README.md +++ b/metron-interface/metron-rest/README.md @@ -171,7 +171,7 @@ Request and Response objects are JSON formatted. The JSON schemas are available * 200 - JSON results ### `POST /api/v1/hdfs` - * Description: Writes contents to an HDFS file + * Description: Writes contents to an HDFS file. Warning: this will overwite the contents of a file if it already exists. * Input: * path - Path to HDFS file * contents - File contents diff --git a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java index 3d56d7b4e5..bf7ae84b93 100644 --- a/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java +++ b/metron-interface/metron-rest/src/main/java/org/apache/metron/rest/controller/HdfsController.java @@ -64,7 +64,7 @@ ResponseEntity read(@ApiParam(name = "path", value = "Path to HDFS file" } - @ApiOperation(value = "Writes contents to an HDFS file") + @ApiOperation(value = "Writes contents to an HDFS file. Warning: this will overwite the contents of a file if it already exists.") @ApiResponse(message = "Contents were written", code = 200) @RequestMapping(method = RequestMethod.POST) ResponseEntity write(@ApiParam(name="path", value="Path to HDFS file", required=true) @RequestParam String path, diff --git a/metron-interface/metron-rest/src/test/resources/README.vm b/metron-interface/metron-rest/src/test/resources/README.vm index bae40b6e09..99f4286ff0 100644 --- a/metron-interface/metron-rest/src/test/resources/README.vm +++ b/metron-interface/metron-rest/src/test/resources/README.vm @@ -103,7 +103,6 @@ Request and Response objects are JSON formatted. The JSON schemas are available #end #end - #[[##]]# Testing Profiles are includes for both the metron-docker and Quick Dev environments. From 11fb7352c5531356aa6732f2f2a7c45a7970718e Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 20 Feb 2017 14:34:54 -0600 Subject: [PATCH 51/54] updated dependencies_with_url.csv --- dependencies_with_url.csv | 1 + 1 file changed, 1 insertion(+) diff --git a/dependencies_with_url.csv b/dependencies_with_url.csv index d6e9fc4fc3..3ccc2cd268 100644 --- a/dependencies_with_url.csv +++ b/dependencies_with_url.csv @@ -281,3 +281,4 @@ org.springframework.security:spring-security-config:jar:4.1.3.RELEASE:compile,AS org.springframework.security:spring-security-core:jar:4.1.3.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-security org.springframework.security:spring-security-web:jar:4.1.3.RELEASE:compile,ASLv2,https://github.com/spring-projects/spring-security antlr:antlr:jar:2.7.7:compile,BSD 3-Clause License,http://www.antlr2.org +com.h2database:h2:jar:1.4.192:compile,EPL 1.0,http://www.h2database.com/html/license.html From 6f3fc0bb07a54f1debb165ec2642f2cb19a9598b Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 20 Feb 2017 15:07:40 -0600 Subject: [PATCH 52/54] removed org.reflections dependency --- metron-interface/metron-rest/pom.xml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index 0e765821b7..26602142a9 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -154,18 +154,6 @@ grok 0.1.0 - - org.reflections - reflections - 0.9.10 - - - com.google.code.findbugs - annotations - - - - org.springframework.boot spring-boot-starter-test From de9954325aca74ad15b73f3db95e02f9a464f791 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Thu, 23 Feb 2017 08:55:19 -0600 Subject: [PATCH 53/54] Updated to match all h2 databases --- metron-interface/metron-rest/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metron-interface/metron-rest/.gitignore b/metron-interface/metron-rest/.gitignore index 608e1deedd..26b3af1e1a 100644 --- a/metron-interface/metron-rest/.gitignore +++ b/metron-interface/metron-rest/.gitignore @@ -1 +1 @@ -metrondb.mv.db \ No newline at end of file +metrondb.*.db From 52f87fdb80248d5a5eda3d7296956dfd74725ee7 Mon Sep 17 00:00:00 2001 From: rmerriman Date: Mon, 27 Feb 2017 11:22:09 -0600 Subject: [PATCH 54/54] Merged latest changes and excluded org.reflections from metron-common dependency --- metron-interface/metron-rest/pom.xml | 4 ++++ .../metron/rest/service/impl/StellarServiceImplTest.java | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/metron-interface/metron-rest/pom.xml b/metron-interface/metron-rest/pom.xml index 26602142a9..849455e67d 100644 --- a/metron-interface/metron-rest/pom.xml +++ b/metron-interface/metron-rest/pom.xml @@ -105,6 +105,10 @@ com.fasterxml.jackson.core jackson-databind + + org.reflections + reflections + diff --git a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StellarServiceImplTest.java b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StellarServiceImplTest.java index 04a7fa293b..3ddbf5644f 100644 --- a/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StellarServiceImplTest.java +++ b/metron-interface/metron-rest/src/test/java/org/apache/metron/rest/service/impl/StellarServiceImplTest.java @@ -27,6 +27,7 @@ import java.util.Arrays; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -57,7 +58,7 @@ public void applyTransformationsShouldProperlyTransformData() { FieldTransformer fieldTransformater = new FieldTransformer(); fieldTransformater.setOutput("url_host"); fieldTransformater.setTransformation("STELLAR"); - fieldTransformater.setConfig(new HashMap() {{ + fieldTransformater.setConfig(new LinkedHashMap() {{ put("url_host", "TO_LOWER(URL_TO_HOST(url))"); }}); sensorParserConfig.setFieldTransformations(ImmutableList.of(fieldTransformater));