diff --git a/@overflow/discovery/component/discovery/discovery.component.ts b/@overflow/discovery/component/discovery/discovery.component.ts
index dcd9246..3d783d0 100644
--- a/@overflow/discovery/component/discovery/discovery.component.ts
+++ b/@overflow/discovery/component/discovery/discovery.component.ts
@@ -1,7 +1,8 @@
import {
- Component, Input,
+ Component, Input, Output, EventEmitter,
} from '@angular/core';
import { Probe, ProbeHost } from '@overflow/commons-typescript/model/probe';
+import { DiscoverZone } from '@overflow/commons-typescript/model/discovery';
@Component({
selector: 'of-discovery',
@@ -11,10 +12,10 @@ export class DiscoveryComponent {
private tabIdx: number;
@Input() selectedProbe: ProbeHost;
+ @Output() requestDiscovery = new EventEmitter
();
constructor(
) {
}
-
}
diff --git a/@overflow/discovery/component/discovery/search-config/ip-input.component.ts b/@overflow/discovery/component/discovery/search-config/ip-input.component.ts
index d05b3fe..6e5b84d 100644
--- a/@overflow/discovery/component/discovery/search-config/ip-input.component.ts
+++ b/@overflow/discovery/component/discovery/search-config/ip-input.component.ts
@@ -46,7 +46,7 @@ export class IpInputComponent implements OnInit, AfterContentInit {
(this.second !== '' && this.second !== undefined) &&
(this.third !== '' && this.third !== undefined) &&
(this.fourth !== '' && this.fourth !== undefined) ) {
- event.target.data = this.first + '.' + this.second + '.' + this.third + '.' + this.fourth;
+ event.value = this.first + '.' + this.second + '.' + this.third + '.' + this.fourth;
this.inputIp.emit(event);
} else {
return;
diff --git a/@overflow/discovery/component/discovery/search-config/search-config.component.html b/@overflow/discovery/component/discovery/search-config/search-config.component.html
index f95b7aa..b538a6b 100644
--- a/@overflow/discovery/component/discovery/search-config/search-config.component.html
+++ b/@overflow/discovery/component/discovery/search-config/search-config.component.html
@@ -1,120 +1,71 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ {{ipErrMsg}}
+
+
+
+
+
+
+
+
+
+ {{portErrMsg}}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/@overflow/discovery/component/discovery/search-config/search-config.component.ts b/@overflow/discovery/component/discovery/search-config/search-config.component.ts
index 63460e1..90bdc54 100644
--- a/@overflow/discovery/component/discovery/search-config/search-config.component.ts
+++ b/@overflow/discovery/component/discovery/search-config/search-config.component.ts
@@ -1,75 +1,188 @@
import {
- AfterContentInit, Component, EventEmitter, Input,
- OnInit, Output
+ Component, EventEmitter, Input,
+ Output, OnChanges, SimpleChanges
} from '@angular/core';
-import {
- FormBuilder,
- FormGroup, Validators
-} from '@angular/forms';
+import { ProbeHost } from '@overflow/commons-typescript/model/probe';
+import * as CIDR from 'ip-cidr';
+import * as ipRangeCheck from 'ip-range-check';
+import { DiscoverPort, DiscoverService, DiscoverZone } from '@overflow/commons-typescript/model/discovery';
+import { Checkbox } from 'primeng/primeng';
@Component({
selector: 'of-discovery-search-config',
templateUrl: './search-config.component.html',
})
-export class SearchConfigComponent implements OnInit, AfterContentInit {
+export class SearchConfigComponent implements OnChanges {
- @Output() discoverySearchStartClick = new EventEmitter();
- @Output() selectedProbe = new EventEmitter();
-
- includeServices = [];
-
- discoveryFormGroup: FormGroup;
-
- ipVesion: number;
+ @Input() probeHost: ProbeHost;
+ @Output() requestDiscovery = new EventEmitter();
+ ipVer: string;
startIP: string;
endIP: string;
- excludeIP: string;
startPort: string;
endPort: string;
- excludePort: string;
+ includeServices = [];
- startHostIp: string;
- endHostIp: string;
- excludeHostIp: string;
+ hostChecked = true;
+ portChecked = true;
+ serviceChecked = true;
+ tcpChecked = true;
+ udpChecked = true;
- selectPortTypes: string[] = ['0'];
+ validation = false;
+ ipErrMsg: string;
+ portErrMsg: string;
constructor(
- private formBuilder: FormBuilder,
) {
}
- ngOnInit() {
- this.ipVesion = 0;
- this.initForm();
- // this.hostIp = '192.168.1.10';
+ ngOnChanges(changes: SimpleChanges): void {
+ this.initByProbe();
+ this.validation = true;
}
- ngAfterContentInit() {
+ initByProbe() {
+ const cidr = new CIDR(this.probeHost.probe.cidr);
+ if (!cidr.isValid()) {
+ return;
+ }
+ this.ipVer = 'ipv4';
+ this.startIP = cidr.addressStart.address;
+ this.endIP = cidr.addressEnd.address;
+ this.startPort = '1';
+ this.endPort = '1024';
+
+ // TODO: Initialize services
}
- initForm() {
- // this.discoveryFormGroup = this.formBuilder.group({
- // probeSelect: [null],
- // IPType: [null],
- // startIP:[null],
- // endIP: [null],
- // exIP: [null],
- // portType: [null],
- // startPort: [null],
- // endPort: [null],
- // exPort: [null],
- // services: [null]
- // });
+ onRequestDiscovery() {
+ let discoverPort: DiscoverPort = null;
+ let discoverService: DiscoverService = null;
+
+ if (this.serviceChecked) {
+ const services = new Array();
+ for (const service of this.includeServices) {
+ services.push(service.description);
+ }
+ discoverService = {
+ includeServices: services,
+ };
+ }
+ if (this.portChecked) {
+ discoverPort = {
+ firstScanRange: Number(this.startPort),
+ lastScanRange: Number(this.endPort),
+ includeTCP: this.tcpChecked,
+ includeUDP: this.udpChecked,
+ excludePorts: null,
+ discoverService: discoverService
+ };
+ }
+ const discoverZone: DiscoverZone = {
+ discoverHost: {
+ firstScanRangev4: this.startIP,
+ lastScanRangev4: this.endIP,
+ discoverPort: discoverPort
+ },
+ };
+
+ this.requestDiscovery.emit(discoverZone);
}
- discoveryStartClick() {
- this.discoverySearchStartClick.emit();
+ onPortCheckChange(serviceCheckbox: Checkbox, checked: boolean) {
+ if (!checked) {
+ serviceCheckbox.checked = false;
+ this.serviceChecked = false;
+ }
}
- onInputIP(event, idx) {
- console.log(idx);
- console.log(event.target.data);
+ onServiceCheckChange(portCheckbox: Checkbox, checked: boolean) {
+ if (checked) {
+ portCheckbox.checked = true;
+ this.portChecked = true;
+ }
}
+
+ onInputIP(e, idx: number) {
+ const value = e.value;
+ if (idx === 0) {
+ this.startIP = value;
+ } else {
+ this.endIP = value;
+ }
+ this.ipErrMsg = this.validateIP(value, idx);
+
+ if (this.ipErrMsg) {
+ this.validation = false;
+ } else {
+ this.validation = true;
+ }
+ }
+
+ validateIP(value: string, idx): string {
+ if (!this.isValidIPregex(value)) {
+ return 'Not valid IP format.';
+ }
+ if (!ipRangeCheck(value, this.probeHost.probe.cidr)) {
+ return 'Not valid IP range.';
+ }
+ const ipArray = [this.startIP, this.endIP];
+ const sortedIpArray = this.sortIP([this.startIP, this.endIP]);
+ if (ipArray[0] !== sortedIpArray[0]) {
+ return 'Not valiad range';
+ }
+
+ return null;
+ }
+
+ isValidIPregex(ip: string): boolean {
+ if (this.ipVer === 'ipv4') {
+ return /^(?=\d+\.\d+\.\d+\.\d+$)(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])\.?){4}$/.test(ip);
+ }
+ return false;
+ }
+
+ sortIP(ipAddressArray) {
+ return ipAddressArray.sort(function (a, b) {
+ a = a.split('.');
+ b = b.split('.');
+ for (let i = 0; i < a.length; i++) {
+ // tslint:disable-next-line:radix
+ if ((a[i] = parseInt(a[i])) < (b[i] = parseInt(b[i]))) {
+ return -1;
+ } else if (a[i] > b[i]) {
+ return 1;
+ }
+ }
+ return 0;
+ });
+ }
+
+ onInputPort(portNum: string, idx: number) {
+ if (idx === 0) {
+ this.startPort = portNum;
+ } else {
+ this.endPort = portNum;
+ }
+ this.portErrMsg = this.validatePort(portNum);
+
+ if (this.portErrMsg) {
+ this.validation = false;
+ } else {
+ this.validation = true;
+ }
+ }
+
+ validatePort(portNum): string {
+ if (Number(this.startPort) > Number(this.endPort)) {
+ return 'Not valid port range.';
+ }
+ if (Number(portNum) <= 0 || Number(portNum) > 65535) {
+ return 'Not valid port range.';
+ }
+ return null;
+ }
+
}
diff --git a/@overflow/discovery/component/discovery/service-selector/service-selector.component.ts b/@overflow/discovery/component/discovery/service-selector/service-selector.component.ts
index 484570c..634d76e 100644
--- a/@overflow/discovery/component/discovery/service-selector/service-selector.component.ts
+++ b/@overflow/discovery/component/discovery/service-selector/service-selector.component.ts
@@ -23,6 +23,7 @@ export class ServiceSelectorComponent implements OnInit, AfterContentInit, OnDes
crawlers: MetaCrawler[];
@Output() crawlerSelected = new EventEmitter();
@Input() includeServices;
+ @Input() disabled: boolean;
constructor(
private listStore: Store,
diff --git a/@overflow/discovery/container/discovery/discovery-container.component.html b/@overflow/discovery/container/discovery/discovery-container.component.html
index b92e73f..3e21ad5 100644
--- a/@overflow/discovery/container/discovery/discovery-container.component.html
+++ b/@overflow/discovery/container/discovery/discovery-container.component.html
@@ -1,2 +1,2 @@
-
+
diff --git a/@overflow/discovery/container/discovery/discovery-container.component.ts b/@overflow/discovery/container/discovery/discovery-container.component.ts
index 6cfd9b0..91a6374 100644
--- a/@overflow/discovery/container/discovery/discovery-container.component.ts
+++ b/@overflow/discovery/container/discovery/discovery-container.component.ts
@@ -3,6 +3,7 @@ import {
Input,
} from '@angular/core';
import { ProbeHost } from '@overflow/commons-typescript/model/probe';
+import { DiscoverZone } from '@overflow/commons-typescript/model/discovery';
@Component({
selector: 'of-discovery-container',
@@ -21,4 +22,9 @@ export class DiscoveryContainerComponent {
this.selectedProbe = probe;
}
+ onRequestDiscovery(dz: DiscoverZone) {
+ console.log(dz);
+ // this.discoverStore.dispatch(new DiscoverStore.DiscoverZone(
+ // { probeID: this.selectedProbe.probeKey, discoverZone: discoverZone }));
+ }
}
diff --git a/@overflow/probe/component/list/list.component.html b/@overflow/probe/component/list/list.component.html
index 1271546..c46b612 100644
--- a/@overflow/probe/component/list/list.component.html
+++ b/@overflow/probe/component/list/list.component.html
@@ -1,7 +1,7 @@
Probes
-
-
-
+
+
+
diff --git a/@overflow/probe/component/list/list.component.ts b/@overflow/probe/component/list/list.component.ts
index 6c55619..e96d262 100644
--- a/@overflow/probe/component/list/list.component.ts
+++ b/@overflow/probe/component/list/list.component.ts
@@ -7,8 +7,9 @@ import { ProbeHost, Probe } from '@overflow/commons-typescript/model/probe';
})
export class ProbeListComponent {
@Output() select = new EventEmitter();
- @Input() pending;
+ @Input() pending: boolean;
@Input() probeHosts: ProbeHost[];
+ @Input() error: any;
constructor() {
}
diff --git a/@overflow/probe/component/selector/selector.component.html b/@overflow/probe/component/selector/selector.component.html
index 2619076..a6072a3 100644
--- a/@overflow/probe/component/selector/selector.component.html
+++ b/@overflow/probe/component/selector/selector.component.html
@@ -1,4 +1,4 @@
0" [options]="options" [(ngModel)]="selected" optionLabel="displayName" placeholder="Select a Probe"
- (onChange)="onSelect($event.value)">
+ (onChange)="onSelect()">
\ No newline at end of file
diff --git a/@overflow/probe/component/selector/selector.component.ts b/@overflow/probe/component/selector/selector.component.ts
index a018727..ae91577 100644
--- a/@overflow/probe/component/selector/selector.component.ts
+++ b/@overflow/probe/component/selector/selector.component.ts
@@ -12,6 +12,7 @@ export class ProbeSelectorComponent implements OnChanges {
@Input() probeHostID: number;
options: Probe[];
+ selected: Probe;
constructor() {
}
@@ -34,8 +35,8 @@ export class ProbeSelectorComponent implements OnChanges {
});
}
- onSelect(probe: Probe) {
- const optionselected = this.probeHosts.find(probeHost => probeHost.id === probe.id);
+ onSelect() {
+ const optionselected = this.probeHosts.find(probeHost => probeHost.probe.id === this.selected.id);
this.select.emit(optionselected);
}
diff --git a/@overflow/probe/container/probe-list-container.component.html b/@overflow/probe/container/probe-list-container.component.html
index 6362c8f..802589c 100644
--- a/@overflow/probe/container/probe-list-container.component.html
+++ b/@overflow/probe/container/probe-list-container.component.html
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/@overflow/probe/container/probe-list-container.component.ts b/@overflow/probe/container/probe-list-container.component.ts
index f06c72c..eb53923 100644
--- a/@overflow/probe/container/probe-list-container.component.ts
+++ b/@overflow/probe/container/probe-list-container.component.ts
@@ -26,6 +26,8 @@ export class ProbeListContainerComponent implements OnInit {
ngOnInit() {
this.probeHosts$ = this.store.pipe(select(ProbeListContainerSelector.selectAll));
this.pending$ = this.store.pipe(select(ProbeListContainerSelector.selectPending));
+ this.error$ = this.store.pipe(select(ProbeListContainerSelector.selectError));
+
this.store.select(AuthContainerSelector.selectDomainMember).subscribe(
(domainMember: DomainMember) => {
this.store.dispatch(new ProbeEntityStore.ReadAllByDomainID(domainMember.domain.id));
diff --git a/@overflow/probe/probe.module.ts b/@overflow/probe/probe.module.ts
index 6822bc9..5a17a43 100644
--- a/@overflow/probe/probe.module.ts
+++ b/@overflow/probe/probe.module.ts
@@ -9,6 +9,8 @@ import { PrimeNGModules } from '../commons/prime-ng/prime-ng.module';
import { FormsModule } from '@angular/forms';
import { MetaModule } from '@overflow/meta/meta.module';
import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.module';
+import { BlockProgressbarModule } from '../commons/component/block-progressbar/block-progressbar.module';
+import { MessageModule } from 'primeng/primeng';
@NgModule({
imports: [
@@ -17,7 +19,9 @@ import { KeyValueModule } from '@overflow/commons/component/key-value/key-value.
ProbeStoreModule,
FormsModule,
KeyValueModule,
- MetaModule
+ MetaModule,
+ BlockProgressbarModule,
+ MessageModule
],
declarations: [
CONTAINER_COMPONENTS,
diff --git a/package-lock.json b/package-lock.json
index 3ee970b..42b2f07 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5045,19 +5045,26 @@
}
},
"ip-cidr": {
- "version": "1.1.2",
- "resolved": "https://nexus.loafle.net/repository/npm-all/ip-cidr/-/ip-cidr-1.1.2.tgz",
- "integrity": "sha512-JYrr9jiToVM4R3krXZdC47QTpIYuTKutlZWLhub1sny++WUeIS/XLnQZlWQhfy8DHnKPbxJsmFPlmBPJgbP/ww==",
+ "version": "2.0.0",
+ "resolved": "https://nexus.loafle.net/repository/npm-all/ip-cidr/-/ip-cidr-2.0.0.tgz",
+ "integrity": "sha512-RG2+JvxGxdrZ4vJkn0pk2wpOhywTNxxvcLW2/1wqFTMpuk2fzTagZbU33ztlgF0pwRkSmSMo0kaNCCSazJr7Rw==",
"requires": {
"ip-address": "5.8.9",
"jsbn": "0.1.1"
}
},
+ "ip-range-check": {
+ "version": "0.0.2",
+ "resolved": "https://nexus.loafle.net/repository/npm-all/ip-range-check/-/ip-range-check-0.0.2.tgz",
+ "integrity": "sha1-YFyFloeqTxhGORjUYZDYs2maKTw=",
+ "requires": {
+ "ipaddr.js": "1.6.0"
+ }
+ },
"ipaddr.js": {
"version": "1.6.0",
"resolved": "https://nexus.loafle.net/repository/npm-all/ipaddr.js/-/ipaddr.js-1.6.0.tgz",
- "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs=",
- "dev": true
+ "integrity": "sha1-4/o1e3c9phnybpXwSdBVxyeW+Gs="
},
"is-accessor-descriptor": {
"version": "0.1.6",
diff --git a/package.json b/package.json
index c42fc29..1b25500 100644
--- a/package.json
+++ b/package.json
@@ -42,8 +42,9 @@
"angular-l10n": "^5.0.0",
"angularx-qrcode": "^1.1.7",
"chart.js": "^2.7.2",
+ "ip-cidr": "^2.0.0",
"core-js": "^2.5.4",
- "ip-cidr": "^1.1.2",
+ "ip-range-check": "0.0.2",
"jquery": "^3.3.1",
"ngx-cookie-service": "^1.0.10",
"openssl": "^1.1.0",
diff --git a/src/styles.scss b/src/styles.scss
index 149bcb8..b57f2e2 100644
--- a/src/styles.scss
+++ b/src/styles.scss
@@ -414,4 +414,8 @@ body .ui-progressbar .ui-progressbar-value {
}
.ui-panel {
border: none !important;
+}
+
+.ui-blockui.ui-widget-overlay {
+ opacity: 0;
}
\ No newline at end of file