diff --git a/Watcher/Watcher/frontend/src/components/SiteMonitoring/SuspiciousSites.js b/Watcher/Watcher/frontend/src/components/SiteMonitoring/SuspiciousSites.js index b1d3d33..1e44824 100755 --- a/Watcher/Watcher/frontend/src/components/SiteMonitoring/SuspiciousSites.js +++ b/Watcher/Watcher/frontend/src/components/SiteMonitoring/SuspiciousSites.js @@ -10,9 +10,9 @@ import Col from "react-bootstrap/Col"; import Form from "react-bootstrap/Form"; import DayPickerInput from "react-day-picker/DayPickerInput"; import {formatDate, parseDate} from 'react-day-picker/moment'; - + export class SuspiciousSites extends Component { - + constructor(props) { super(props); this.state = { @@ -41,7 +41,7 @@ export class SuspiciousSites extends Component { this.webContentMonitoringRef = React.createRef(); this.emailMonitoringRef = React.createRef(); } - + static propTypes = { sites: PropTypes.array.isRequired, getSites: PropTypes.func.isRequired, @@ -53,11 +53,11 @@ export class SuspiciousSites extends Component { auth: PropTypes.object.isRequired, error: PropTypes.object.isRequired, }; - + componentDidMount() { this.props.getSites(); } - + componentDidUpdate(prevProps) { if (this.props.sites !== prevProps.sites) { this.setState({ @@ -74,7 +74,7 @@ export class SuspiciousSites extends Component { } } } - + displayDeleteModal = (id, domainName) => { this.setState({ showDeleteModal: true, @@ -82,7 +82,7 @@ export class SuspiciousSites extends Component { domainName: domainName, }); }; - + deleteModal = () => { let handleClose; handleClose = () => { @@ -90,7 +90,7 @@ export class SuspiciousSites extends Component { showDeleteModal: false }); }; - + let onSubmit; onSubmit = e => { e.preventDefault(); @@ -101,7 +101,7 @@ export class SuspiciousSites extends Component { }); handleClose(); }; - + return ( @@ -123,7 +123,7 @@ export class SuspiciousSites extends Component { ); }; - + displayEditModal = (site) => { site.expiry = site.expiry ? new Date(site.expiry) : null; this.setState({ @@ -138,7 +138,7 @@ export class SuspiciousSites extends Component { emailMonitoring: site.mail_monitoring }); }; - + editModal = () => { let handleClose; handleClose = () => { @@ -146,7 +146,7 @@ export class SuspiciousSites extends Component { showEditModal: false }); }; - + let onSubmit; onSubmit = e => { e.preventDefault(); @@ -157,9 +157,9 @@ export class SuspiciousSites extends Component { const ip_monitoring = this.ipMonitoringRef.current.checked; const content_monitoring = this.webContentMonitoringRef.current.checked; const mail_monitoring = this.emailMonitoringRef.current.checked; - + const site = {domain_name, ticket_id, rtir, expiry, ip_monitoring, content_monitoring, mail_monitoring}; - + this.props.patchSite(this.state.id, site); this.setState({ day: "", @@ -167,12 +167,12 @@ export class SuspiciousSites extends Component { }); handleClose(); }; - + let handleOnChange; handleOnChange = e => { e.preventDefault(); }; - + return ( @@ -276,38 +276,19 @@ export class SuspiciousSites extends Component { ); }; - + displayAddModal = () => { this.setState({ showAddModal: true }); }; - + addModal = () => { - let handleClose; - handleClose = () => { - this.setState({ - showAddModal: false - }); + let handleClose = () => { + this.setState({ showAddModal: false }); }; - - let getMax; - getMax = (arr, prop) => { - var max; - if (arr.length !== 0) { - for (var i=0 ; i parseInt(max[prop])) - max = arr[i]; - } - max=max.rtir - } else { - max=0; - } - return max; - }; - - let onSubmit; - onSubmit = e => { + + let onSubmit = e => { e.preventDefault(); const domain_name = this.inputDomainRef.current.value; const ticket_id = this.inputTicketRef.current.value; @@ -315,18 +296,14 @@ export class SuspiciousSites extends Component { const ip_monitoring = this.ipMonitoringRef.current.checked; const content_monitoring = this.webContentMonitoringRef.current.checked; const mail_monitoring = this.emailMonitoringRef.current.checked; - const site = expiry ? {domain_name, ticket_id, expiry, ip_monitoring, content_monitoring, mail_monitoring} : {domain_name, ticket_id, ip_monitoring, content_monitoring, mail_monitoring}; - + + const site = { domain_name, ticket_id, expiry, ip_monitoring, content_monitoring, mail_monitoring }; + this.props.addSite(site); - this.setState({ - domainName: "", - day: "", - id: 0, - ticketId: "", - addLoading: true - }); + this.setState({ domainName: "", day: "", ticketId: "", addLoading: true }); handleClose(); }; + return ( @@ -335,7 +312,7 @@ export class SuspiciousSites extends Component { - +
Domain name @@ -347,65 +324,42 @@ export class SuspiciousSites extends Component { Ticket ID - + Expiry Date - this.setState({day})}/> + this.setState({ day })}/> Ip Monitoring - + Web Content Monitoring - + Email Monitoring - + - + @@ -421,8 +375,9 @@ export class SuspiciousSites extends Component { ); }; - - + + + displayExportModal = (id, domainName, ticketId, theHiveCaseId, mispEventId) => { this.setState({ showExportModal: true, @@ -433,7 +388,7 @@ export class SuspiciousSites extends Component { mispEventId: mispEventId }); }; - + exportModal = () => { let handleClose; handleClose = () => { @@ -441,13 +396,13 @@ export class SuspiciousSites extends Component { showExportModal: false }); }; - + let onSubmitTheHive; onSubmitTheHive = e => { e.preventDefault(); const id = this.state.id; const site = {id}; - + this.props.exportToTheHive(site); this.setState({ domainName: "", @@ -457,13 +412,13 @@ export class SuspiciousSites extends Component { }); handleClose(); }; - + let onSubmitMisp; onSubmitMisp = e => { e.preventDefault(); const id = this.state.id; const site = {id}; - + this.props.exportToMISP(site); this.setState({ domainName: "", @@ -473,7 +428,7 @@ export class SuspiciousSites extends Component { }); handleClose(); }; - + const theHiveExportButton = ( ); - + return ( @@ -525,8 +480,8 @@ export class SuspiciousSites extends Component { ); }; - - + + render() { const yes_monitoring = ( { this.displayExportModal(site.id, site.domain_name, site.ticket_id, site.the_hive_case_id, site.misp_event_id) }} disabled={this.state.exportLoading === site.id}> - + {this.state.exportLoading === site.id && (
Loading...
)} @@ -564,7 +519,7 @@ export class SuspiciousSites extends Component { )} ); - + return (
@@ -654,13 +609,13 @@ export class SuspiciousSites extends Component { ) } } - + const mapStateToProps = state => ({ sites: state.SiteMonitoring.sites, auth: state.auth, error: state.errors }); - + export default connect(mapStateToProps, { getSites, deleteSite,