Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #5

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"env": {
"browser": true,
"es6": true
},
"rules": {
"indent": ["error", 4, {
"SwitchCase": 0
}],
"no-trailing-spaces": "error",
"no-unused-vars": ["warn", {"args": "none"}],
"space-infix-ops": "error",
"space-in-parens": ["error", "never"],
"react/prop-types": "warn"
}
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
"private": true,
"devDependencies": {
"babel-core": "6.26.0",
"babel-eslint": "^8.2.3",
"babel-loader": "7.1.2",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"babel-preset-env": "1.6.1",
"babel-preset-react": "6.24.1",
"babel-preset-stage-3": "^6.24.1",
"copy-webpack-plugin": "4.2.1",
"css-hot-loader": "1.3.3",
"css-loader": "0.28.7",
"dotenv": "^4.0.0",
"eslint": "^4.19.1",
"eslint-plugin-react": "^7.9.1",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"git-describe": "^4.0.2",
Expand Down
98 changes: 49 additions & 49 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,95 +18,95 @@ export const FETCH_SESSION_CONTENT = 'FETCH_SESSION_CONTENT';
const ROOT_URL = 'http://127.0.0.1:8089';

export function clearHotCountries(event) {
return {
type: HOT_COUNTRIES,
return {
type: HOT_COUNTRIES,
payload: {},
};
};
}

export function receivedHotCountries(event) {
return {
type: RECEIVED_HOT_COUNTRIES,
return {
type: RECEIVED_HOT_COUNTRIES,
payload: event
};
};
}

export function receivedMetadata(event) {
return {
type: RECEIVED_METADATA,
return {
type: RECEIVED_METADATA,
payload: event
};
};
}

export function receivedEvents(data) {
return {
type: RECEIVED_EVENTS,
return {
type: RECEIVED_EVENTS,
payload: data
};
};
}

export function receivedEvent(event) {
return {
type: RECEIVED_EVENT,
return {
type: RECEIVED_EVENT,
payload: event
};
};
}

export function connectionStatus(connected) {
return {
type: CONNECTION_STATUS,
payload: {
connected: connected,
return {
type: CONNECTION_STATUS,
payload: {
connected: connected,
}
};
};
}

export function addSession(id) {
return {
type: ADD_SESSION,
payload: {
id: id,
date: '10/02/2017',
location: 'unknown',
started: '10/02/2017 10:10',
ended: '10/02/2017 10:11',
username: 'root',
password: 'root'
}
};
return {
type: ADD_SESSION,
payload: {
id: id,
date: '10/02/2017',
location: 'unknown',
started: '10/02/2017 10:10',
ended: '10/02/2017 10:11',
username: 'root',
password: 'root'
}
};
}

export function fetchCountries() {
const request = axios.all([axios.get(`https://unpkg.com/world-atlas@1/world/110m.json`), axios.get(`https://unpkg.com/world-atlas@1/world/110m.tsv`)]);

return {
type: FETCH_COUNTRIES,
payload: request
return {
type: FETCH_COUNTRIES,
payload: request
};
}

export function fetchSessions() {
const request = axios.get(`${ROOT_URL}/api/v1/sessions`);
const request = axios.get(`${ROOT_URL}/api/v1/sessions`);

return {
type: FETCH_SESSIONS,
payload: request
}
return {
type: FETCH_SESSIONS,
payload: request
}
}

export function fetchSession(id) {
const request = axios.get(`${ROOT_URL}/api/v1/sessions/${id}`);
const request = axios.get(`${ROOT_URL}/api/v1/sessions/${id}`);

return {
type: FETCH_SESSION,
payload: request
}
return {
type: FETCH_SESSION,
payload: request
}
}

export function fetchSessionContent(content) {

return {
type: FETCH_SESSION_CONTENT,
payload: content
}
return {
type: FETCH_SESSION_CONTENT,
payload: content
}
}
6 changes: 0 additions & 6 deletions src/bootstrap.min.css

This file was deleted.

27 changes: 3 additions & 24 deletions src/components/agents.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
import React, { Component } from 'react';

import { connect } from 'react-redux';

import Header from './header';
import SessionList from './session-list';
import React, {PureComponent} from 'react';

import View from './view';
import Flag from "react-flags";

class Agents extends Component {
constructor(props) {
super(props);
}

componentWillMount() {
const { dispatch } = this.props;
}

export default class Agents extends PureComponent {
render() {
return (
<View title="Overview" subtitle="Agents">
Agents
</View>
);
}
}

function mapStateToProps(state) {
return {
};
}

export default connect(mapStateToProps)(Agents);
}
42 changes: 26 additions & 16 deletions src/components/app.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';

import Header from './header';

import Dashboard from './dashboard';
import Attacks from './attacks';
import Events from './events';
import Agents from './agents';
/*
import SessionShow from './components/session-show';
import Socket from './components/socket';
import Server from './components/server';
import Random from './components/random';
*/

import Navigation from './navigation';
import Search from './search';

import SessionList from './session-list';
import ConfigurationOverview from './configuration-overview';
import NotFoundPage from './not-found';

import { HashRouter, BrowserRouter, Redirect, Switch, Route } from 'react-router-dom';
import { Redirect, Switch, Route } from 'react-router-dom';

class App extends Component {
render() {
Expand All @@ -32,12 +33,14 @@ class App extends Component {
}

let versionAvailable = null;
if (false) {
/*
if (...) {
versionAvailable =
<div className="alert alert-warning" role="alert">
New version available. <a>Upgrade</a>.
</div>;
}
*/

return (
<div className="container">
Expand All @@ -57,18 +60,25 @@ class App extends Component {
</div>
</nav>
</div>
<Switch>
<Route exact path="/" component={Dashboard} / >
<Route exact path="/agents" component={Agents} />
<Route exact path="/events" component={Events} />
<Route exact path="/configuration" component={ConfigurationOverview} />
<Route path="/404" component={NotFoundPage} />
<Redirect from='*' to='/404' />
</Switch>
<Switch>
<Route exact path="/" component={Dashboard} / >
<Route exact path="/agents" component={Agents} />
<Route exact path="/events" component={Events} />
<Route exact path="/configuration" component={ConfigurationOverview} />
<Route path="/404" component={NotFoundPage} />
{/*
<Route path="/session/:id" component={SessionShow} />
<Route path="/session/:id" component={SessionShow} />
<Route path="/socket" component={Socket} />
<Route path="/server" component={Server} />
<Route path="/random" component={Random} />
*/}
<Redirect from='*' to='/404' />
</Switch>
</div>
</div>
);
}
}
}

function mapStateToProps(state) {
Expand Down
35 changes: 12 additions & 23 deletions src/components/attacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@ import React, { Component } from 'react';

import { connect } from 'react-redux';

import Header from './header';
import SessionList from './session-list';

import View from './view';

class Attacks extends Component {
constructor(props) {
super(props);
}

componentWillMount() {
const { dispatch } = this.props;
}

renderTable() {
if(!this.props.events) {
return (
Expand All @@ -27,18 +16,18 @@ class Attacks extends Component {


return events.map((event, i) => {
const message = (event.message || event.payload );
return (
<tr key={i}>
<td>{event.date.format('lll')}</td>
<td>{event.sensor}</td>
<td>{event.category}</td>
<td>{event["source-ip"] } ({event["source-port"] })</td>
<td>{event["destination-ip"] } ({event["destination-port"] })</td>
<td>{message}</td>
</tr>
const message = (event.message || event.payload);

return (
<tr key={i}>
<td>{event.date.format('lll')}</td>
<td>{event.sensor}</td>
<td>{event.category}</td>
<td>{event["source-ip"] } ({event["source-port"] })</td>
<td>{event["destination-ip"] } ({event["destination-port"] })</td>
<td>{message}</td>
</tr>

);
});
}
Expand Down
Loading