sensor setup

This commit is contained in:
snoop 2017-08-16 17:04:55 +09:00
parent 8692555516
commit 7c70dc0d71
3 changed files with 313 additions and 2 deletions

View File

@ -0,0 +1,301 @@
import * as React from 'react';
// import update from 'immutability-helper';
import {
Checkbox,
Container,
Label,
Accordion,
Icon,
List,
ListItemProps,
} from 'semantic-ui-react';
import Host from '@overflow/discovery/api/model/Host';
import Port from '@overflow/discovery/api/model/Port';
import Service from '@overflow/discovery/api/model/Service';
import * as Utils from '@overflow/commons/util/Utils';
export interface DiscoveryResultProps {
}
export interface DiscoveryResultState {
portState: { [key: number]: boolean; };
}
export class DiscoveryTree extends React.Component<DiscoveryResultProps, DiscoveryResultState> {
constructor(props: any, context: any) {
super(props, context);
this.state = {
portState: {},
};
// fs.readFile('../../../../../dh.json', this.handlJSONFile);
}
public render(): JSX.Element {
return (
<Container>
<List selection>
{
jsonData.map((data: any, index: number) => {
let hh: Host = data;
this.state.portState[hh.ip] = false;
return (
<List.Item key={index} >
<List.Icon name='folder' onClick={() => {
{/*const newPortState = update.newContext()(this.state.portState, {
[hh.ip]: !this.state.portState[hh.ip]
});*/}
{/*this.setState({ portState: newPortState });*/ }
}} />
<List.Content>
<List.Header> <Checkbox label={Utils.int2ip(hh.ip) + ' ' + hh.os} /> </List.Header>
<List.Description>Host</List.Description>
{this.state.portState[hh.ip] ?
hh.ports ? hh.ports.map((port: Port, idx: number) => {
return (
<List.List key={idx * 1000}>
<List.Item>
<List.Icon name='folder' />
<List.Content>
<List.Header> <Checkbox label={port.portNumber + ' ' + port.portType} /></List.Header>
<List.Description>Port</List.Description>
{port.services ? port.services.map((service: Service, sIdx: number) => {
return (
<List.List key={sIdx * 10000}>
<List.Item>
<List.Icon name='folder' />
<List.Content>
<List.Header><Checkbox label={service.serviceName + ' ' + service.portType} /></List.Header>
<List.Description>Service</List.Description>
</List.Content>
</List.Item>
</List.List>
);
}) : ''}
</List.Content>
</List.Item>
</List.List>
);
}) : '' : ''}
</List.Content>
</List.Item>
);
})}
</List>
{/*<List>
<List.Item >
<Label basic onClick={() => {
this.setState({ tt: !this.state.tt });
}}>Host</Label>
<Checkbox />
</List.Item>
{this.state.tt ? <List.Item selection >
<List.List>
<List.Item>Port 22 NOR</List.Item>
<List.Item>Port 443 TLS</List.Item>
<List.Item>Port 80 NOR </List.Item>
</List.List>
</List.Item> : ''}
</List>*/}
</Container>
);
}
}
const jsonData = [{
'firstScanRange': 1,
'lastScanRange': 10000,
'name': '',
'ip': 3232235818,
'mac': 91754662925,
'os': 'Windows',
'ports': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'SSH',
'target': true,
}],
'portType': 'TCP',
'portNumber': 22,
},
{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'HTTP',
}],
'portType': 'TCP',
'portNumber': 443,
},
{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'HTTP',
}],
'portType': 'TCP',
'portNumber': 80,
}],
'createDate': 1498470178000,
'updateDate': 1498470178000,
},
{
'firstScanRange': 1,
'lastScanRange': 10000,
'name': '',
'ip': 3232235781,
'mac': 91754660625,
'os': 'Windows',
'ports': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'SSH',
}],
'portType': 'TCP',
'portNumber': 22,
},
{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'HTTP',
}],
'portType': 'TCP',
'portNumber': 80,
},
{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'HTTP',
}],
'portType': 'TCP',
'portNumber': 1936,
},
{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': null,
'portType': 'TCP',
'portNumber': 443,
}],
'createDate': 1498470178000,
'updateDate': 1498470178000,
},
{
'firstScanRange': 1,
'lastScanRange': 10000,
'name': '',
'ip': 3232235797,
'mac': 91754662913,
'os': 'Windows',
'target': true,
'ports': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'HTTP',
}],
'portType': 'TCP',
'portNumber': 80,
},
{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'SSH',
}],
'portType': 'TCP',
'portNumber': 22,
},
{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'HTTP',
}],
'portType': 'TCP',
'portNumber': 3343,
},
{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'services': [{
'createDate': -62135596800000,
'updateDate': -62135596800000,
'portType': 'TCP',
'serviceName': 'HTTP',
}],
'portType': 'TCP',
'portNumber': 443,
}],
'createDate': 1498470178000,
'updateDate': 1498470178000,
},
{
'firstScanRange': 1,
'lastScanRange': 10000,
'name': '',
'ip': 3232235877,
'mac': 75361038758387,
'os': 'Windows',
'ports': null,
'createDate': 1498470179000,
'updateDate': 1498470179000,
},
];

View File

@ -102,6 +102,8 @@ export class CrawlerSelector extends React.Component<CrawlerSelectorProps, Crawl
id: Number(data.value), id: Number(data.value),
}; };
this.props.onCrawlerReadAllByMetaCrawler(crawler); this.props.onCrawlerReadAllByMetaCrawler(crawler);
this.props.onSelectCrawlerId(Number(data.value));
} }
public checkInstall(): void { public checkInstall(): void {

View File

@ -16,7 +16,7 @@ export interface SensorConfigurationDispatchProps {
} }
export interface SensorConfigurationState { export interface SensorConfigurationState {
selectedCrawlerId: number;
} }
export type SensorConfigurationProps = SensorConfigurationStateProps & SensorConfigurationDispatchProps; export type SensorConfigurationProps = SensorConfigurationStateProps & SensorConfigurationDispatchProps;
@ -26,12 +26,20 @@ export class SensorConfiguration extends React.Component<SensorConfigurationProp
constructor(props: SensorConfigurationProps, context: SensorConfigurationState) { constructor(props: SensorConfigurationProps, context: SensorConfigurationState) {
super(props, context); super(props, context);
this.state = { this.state = {
selectedCrawlerId: 0,
}; };
} }
public onSelectCrawlerId = (id: number) => {
this.setState({
selectedCrawlerId: id,
});
}
public render(): JSX.Element { public render(): JSX.Element {
let steps = [<CrawlerSelectorContainer />, <Segment vertical><SensorItemTree /></Segment>, <ETCSelector />]; let steps = [<CrawlerSelectorContainer onSelectCrawlerId={this.onSelectCrawlerId.bind(this)}/>,
<Segment vertical><SensorItemTree crawlerId={this.state.selectedCrawlerId}/></Segment>, <ETCSelector />];
return ( return (
<ConfigStepper steps={steps} /> <ConfigStepper steps={steps} />