[
https://issues.apache.org/jira/browse/METRON-623?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15941282#comment-15941282
]
ASF GitHub Bot commented on METRON-623:
---------------------------------------
Github user simonellistonball commented on a diff in the pull request:
https://github.com/apache/incubator-metron/pull/489#discussion_r108007221
--- Diff:
metron-interface/metron-config/src/app/sensors/sensor-field-schema/sensor-field-schema.component.spec.ts
---
@@ -0,0 +1,506 @@
+/**
+ * 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.
+ */
+/* tslint:disable:no-unused-variable */
+/* tslint:disable:max-line-length */
+
+import { TestBed, async, ComponentFixture } from '@angular/core/testing';
+import {Http} from '@angular/http';
+import {SimpleChanges, SimpleChange} from '@angular/core';
+import {SensorParserConfigService} from
'../../service/sensor-parser-config.service';
+import {StellarService} from '../../service/stellar.service';
+import {MetronAlerts} from '../../shared/metron-alerts';
+import {SensorFieldSchemaModule} from './sensor-field-schema.module';
+import {SensorFieldSchemaComponent, FieldSchemaRow} from
'./sensor-field-schema.component';
+import {KafkaService} from '../../service/kafka.service';
+import {Observable} from 'rxjs/Observable';
+import {StellarFunctionDescription} from
'../../model/stellar-function-description';
+import {SensorParserConfig} from '../../model/sensor-parser-config';
+import {SensorEnrichmentConfig, EnrichmentConfig, ThreatIntelConfig} from
'../../model/sensor-enrichment-config';
+import {ParseMessageRequest} from '../../model/parse-message-request';
+import {AutocompleteOption} from '../../model/autocomplete-option';
+import {FieldTransformer} from '../../model/field-transformer';
+import {SensorEnrichmentConfigService} from
'../../service/sensor-enrichment-config.service';
+
+
+class MockSensorParserConfigService {
+
+ parseMessage(parseMessageRequest: ParseMessageRequest): Observable<{}>
{
+ let parsedJson = {
+ 'elapsed': 415,
+ 'code': 200,
+ 'ip_dst_addr': '207.109.73.154',
+ 'original_string': '1467011157.401 415 127.0.0.1 TCP_MISS/200
337891 GET http://www.aliexpress.com/',
+ 'method': 'GET',
+ 'bytes': 337891,
+ 'action': 'TCP_MISS',
+ 'ip_src_addr': '127.0.0.1',
+ 'url': 'http://www.aliexpress.com/af/shoes.html?',
+ 'timestamp': '1467011157.401'
+ };
+ return Observable.create((observable) => {
+ observable.next(parsedJson);
+ observable.complete();
+ });
+ }
+}
+
+class MockTransformationValidationService {
+ public listSimpleFunctions(): Observable<StellarFunctionDescription[]>
{
+ let stellarFunctionDescription: StellarFunctionDescription[] = [];
+ stellarFunctionDescription.push(new
StellarFunctionDescription('TO_LOWER', 'TO_LOWER description', ['input - input
field']));
+ stellarFunctionDescription.push(new
StellarFunctionDescription('TO_UPPER', 'TO_UPPER description', ['input - input
field']));
+ stellarFunctionDescription.push(new
StellarFunctionDescription('TRIM', 'Lazy to copy desc', ['input - input
field']));
+ return Observable.create((observer) => {
+ observer.next(stellarFunctionDescription);
+ observer.complete();
+ });
+ }
+}
+
+class MockSensorEnrichmentConfigService {
+ public getAvailable(): Observable<string[]> {
+ return Observable.create((observer) => {
+ observer.next(['geo', 'host', 'whois']);
+ observer.complete();
+ });
+ }
+}
+
+class MockKafkaService {
+
+}
+
+describe('Component: SensorFieldSchema', () => {
+ let component: SensorFieldSchemaComponent;
+ let sensorEnrichmentConfigService: SensorEnrichmentConfigService;
+ let sensorParserConfigService: SensorParserConfigService;
+ let fixture: ComponentFixture<SensorFieldSchemaComponent>;
+ let transformationValidationService: StellarService;
+
+ let squidSensorConfigJson = {
+ 'parserClassName': 'org.apache.metron.parsers.GrokParser',
+ 'sensorTopic': 'squid',
+ 'parserConfig': {
+ 'grokPath': 'target/patterns/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}'
+ },
+ 'fieldTransformations': [
+ {
+ 'input': [],
+ 'output': ['method'],
+ 'transformation': 'STELLAR',
+ 'config': {
+ 'method': 'TRIM(TO_LOWER(method))'
+ }
+ },
+ {
+ 'input': ['method'],
+ 'output': null,
+ 'transformation': 'REMOVE',
+ 'config': {
+ 'method': 'TRIM(TO_LOWER(method))'
+ }
+ },
--- End diff --
This seems like an impossible situation, does it make for a good test case?
(stellar statement on a remove transformation)
> Management UI
> -------------
>
> Key: METRON-623
> URL: https://issues.apache.org/jira/browse/METRON-623
> Project: Metron
> Issue Type: New Feature
> Reporter: Ryan Merriman
> Assignee: Ryan Merriman
>
> It would be useful to have a User Interface for modifying parser/enrichment
> configurations and managing topologies.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)