Merge pull request #132 from BloodHoundAD/UI-Update

Object Properties Update
master
Rohan Vazarkar 2017-10-10 03:54:19 -04:00 committed by GitHub
commit 60a68c4a54
20 changed files with 2862 additions and 2605 deletions

View File

@ -16,7 +16,6 @@
<script src="node_modules/linkurious/dist/plugins.js" type="text/javascript"></script>
<script src="node_modules/dagre/dist/dagre.min.js" type="text/javascript"></script>
<script src="node_modules/bootstrap-3-typeahead/bootstrap3-typeahead.min.js" type="text/javascript"></script>
<script src="src/js/papaparse.min.js" type="text/javascript"></script>
<script src="src/js/simple-slider.min.js" type="text/javascript"></script>
<link type="text/css" rel="stylesheet" href="src/css/simple-slider.css">
<link type="text/css" rel="stylesheet" href="src/css/simple-slider-volume.css">

View File

@ -28,7 +28,7 @@
},
"babel": {
"presets": [
"es2015",
"env",
"stage-0",
"react"
]
@ -38,7 +38,7 @@
"babel-core": "^6.22.1",
"babel-loader": "^7.0.0",
"babel-polyfill": "^6.22.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.22.0",
"babel-preset-stage-0": "^6.22.0",
"concurrently": "^3.1.0",
@ -56,15 +56,16 @@
"configstore": "^3.1.0",
"dagre": "^0.7.4",
"eventemitter2": "^4.1.0",
"fast-csv": "^2.4.1",
"jquery": "^3.2.1",
"linkurious": "^1.5.1",
"mustache": "^2.2.1",
"neo4j-driver": "^1.3.0",
"prop-types": "^15.5.10",
"neo4j-driver": "^1.4.1",
"react": "^15.4.2",
"react-bootstrap": "^0.31.0",
"react-dom": "^15.4.2",
"react-if": "^2.1.0",
"react-transition-group": "^1.1.3"
"react-transition-group": "^1.1.3",
"unzipper": "^0.8.9"
}
}

View File

@ -2,46 +2,46 @@ import React, { Component } from 'react';
import { Alert } from 'react-bootstrap';
export default class GenericAlert extends Component {
constructor(){
super()
this.state = {
visible: false,
text: "No data returned from query",
timeout: null
}
constructor(){
super();
this.state = {
visible: false,
text: "No data returned from query",
timeout: null
};
emitter.on('showAlert', this._show.bind(this))
emitter.on('hideAlert', this._dismiss.bind(this))
}
emitter.on('showAlert', this._show.bind(this));
emitter.on('hideAlert', this._dismiss.bind(this));
}
_dismiss(){
this.setState({visible: false});
}
_dismiss(){
this.setState({visible: false});
}
_show(val){
clearTimeout(this.state.timeout)
var t = setTimeout(function(){
this._dismiss()
}.bind(this), 2500)
_show(val){
clearTimeout(this.state.timeout);
var t = setTimeout(function(){
this._dismiss();
}.bind(this), 2500);
this.setState({
visible: true,
text: val,
timeout: t
})
this.setState({
visible: true,
text: val,
timeout: t
});
}
}
render() {
if (this.state.visible){
return (
<Alert className="alertdiv" bsStyle="danger" onDismiss={this._dismiss.bind(this)}>
{this.state.text}
</Alert>
)
}else{
return null
}
render() {
if (this.state.visible){
return (
<Alert className="alertdiv" bsStyle="danger" onDismiss={this._dismiss.bind(this)}>
{this.state.text}
</Alert>
);
}else{
return null;
}
}
}
}

View File

@ -1,280 +1,285 @@
import React, { Component } from 'react';
export default class Login extends Component {
constructor(){
super();
this.state = {
url: "",
icon: null,
loginEnabled: false,
user: "",
password: "",
loginInProgress: false,
save: false
}
}
constructor(){
super();
this.state = {
url: "",
icon: null,
loginEnabled: false,
user: "",
password: "",
loginInProgress: false,
save: false
};
}
checkDBPresence(){
var url = this.state.url;
var icon = this.state.icon;
var jicon = jQuery(icon)
var btn = jQuery(this.refs.loginButton)
componentWillMount() {
var c = conf.get('databaseInfo');
if (typeof c !== 'undefined'){
this.setState({
url: c.url,
user: c.user,
password: c.password,
save: true
});
}
}
if (url === ""){
return;
}
componentDidMount() {
jQuery(this.refs.password).tooltip({
placement : 'right',
title: '',
container: 'body',
trigger: 'manual',
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner tooltip-inner-custom"></div></div>'
});
this.setIcon();
jQuery(this.refs.urlspinner).toggle(true)
if (this.state.password !== ""){
this.checkDBCreds();
}
}
url = url.replace(/\/$/, "");
setIcon(){
var icon = jQuery(this.refs.urlspinner);
icon.tooltip({
placement : 'right',
title: '',
container: 'body',
delay: {show: 200, hide: 0},
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner tooltip-inner-custom"></div></div>'
});
icon.toggle(false);
this.setState({icon: jQuery(this.refs.urlspinner)});
}
if (!url.includes(':')){
url = url + ':7687'
}
checkDBPresence(){
var url = this.state.url;
var icon = this.state.icon;
var jicon = jQuery(icon);
var btn = jQuery(this.refs.loginButton);
if (!url.startsWith('bolt://')){
url = 'bolt://' + url
}
if (url === ""){
return;
}
icon.removeClass();
icon.addClass("fa fa-spinner fa-spin form-control-feedback");
icon.toggle(true);
var driver = neo4j.driver(url, neo4j.auth.basic("",""), {encrypted:'ENCRYPTION_ON'})
var session = driver.session();
jQuery(this.refs.urlspinner).toggle(true);
driver.onCompleted = function(){
session.close()
driver.close()
}
driver.onError = function(error){
if (error.message.includes("authentication failure")){
icon.removeClass();
icon.addClass("fa fa-check-circle green-icon-color form-control-feedback");
this.setState({loginEnabled: true, url: url})
}else{
icon.removeClass();
icon.addClass("fa fa-times-circle red-icon-color form-control-feedback");
icon.attr('data-original-title', 'No database found')
.tooltip('fixTitle')
.tooltip('show')
this.setState({
loginInProgress: false,
loginEnabled: false
})
}
session.close()
driver.close()
}.bind(this)
session.run("return 1")
}
url = url.replace(/\/$/, "");
checkDBCreds(){
if (this.state.loginInProgress){
return;
}
this.setState({
loginInProgress: true,
loginEnabled: false
})
if (!url.includes(':')){
url = url + ':7687';
}
var btn = jQuery(this.refs.loginButton)
var pwf = jQuery(this.refs.password)
if (!url.startsWith('bolt://')){
url = 'bolt://' + url;
}
var driver = neo4j.driver(this.state.url, neo4j.auth.basic(this.state.user, this.state.password))
driver.onError = function(error){
console.log(error)
if (error.message.includes("authentication failure")){
btn.removeClass('activate');
this.setState({
loginInProgress: false,
loginEnabled: true
})
pwf.attr('data-original-title', 'Invalid username or password')
.tooltip('fixTitle')
.tooltip('show')
}else if (error.message.includes("too many times in a row")){
btn.removeClass('activate');
this.setState({
loginInProgress: false,
loginEnabled: true
})
pwf.attr('data-original-title', 'Too many authentication attempts, please wait')
.tooltip('fixTitle')
.tooltip('show')
}else if (error.toString().includes('ECONNREFUSED')){
var icon = this.state.icon
icon.toggle('true')
icon.removeClass();
icon.addClass("fa fa-times-circle red-icon-color form-control-feedback");
icon.attr('data-original-title', 'No database found')
.tooltip('fixTitle')
.tooltip('show')
this.setState({
loginInProgress: false,
loginEnabled: false
})
}
driver.close()
}.bind(this)
var session = driver.session();
session.run('MATCH (n) RETURN (n) LIMIT 1')
.subscribe({
onError: function(error){
btn.removeClass('activate');
var url = this.state.url.replace('bolt://','http://').replace('7687','7474')
if (error.fields && error.fields[0].code === "Neo.ClientError.Security.CredentialsExpired"){
pwf.attr('data-original-title', 'Credentials need to be changed from the neo4j browser first. Go to {} and change them.'.format(url))
.tooltip('fixTitle')
.tooltip('show')
this.setState({
loginInProgress: false,
loginEnabled: true
})
}
}.bind(this),
onNext: function(){
icon.removeClass();
icon.addClass("fa fa-spinner fa-spin form-control-feedback");
icon.toggle(true);
var driver = neo4j.driver(url, neo4j.auth.basic("",""), {encrypted:'ENCRYPTION_ON'});
var session = driver.session();
},
onCompleted: function(){
btn.toggleClass('activate');
btn.removeClass('btn-default')
btn.addClass('btn-success')
btn.html('Success!')
this.setState({
loginInProgress: false
})
driver.onCompleted = function(){
session.close();
driver.close();
};
driver.onError = function(error){
if (error.message.includes("authentication failure")){
icon.removeClass();
icon.addClass("fa fa-check-circle green-icon-color form-control-feedback");
this.setState({loginEnabled: true, url: url});
}else{
icon.removeClass();
icon.addClass("fa fa-times-circle red-icon-color form-control-feedback");
icon.attr('data-original-title', 'No database found')
.tooltip('fixTitle')
.tooltip('show');
this.setState({
loginInProgress: false,
loginEnabled: false
});
}
session.close();
driver.close();
}.bind(this);
session.run("return 1");
}
var dbinfo = {
url: this.state.url,
user: this.state.user,
password: this.state.password
}
checkDBCreds(){
if (this.state.loginInProgress){
return;
}
this.setState({
loginInProgress: true,
loginEnabled: false
});
if (this.state.save){
conf.set('databaseInfo',dbinfo)
}
var btn = jQuery(this.refs.loginButton);
var pwf = jQuery(this.refs.password);
appStore.databaseInfo = dbinfo;
var driver = neo4j.driver(this.state.url, neo4j.auth.basic(this.state.user, this.state.password));
driver.onError = function(error){
console.log(error);
if (error.message.includes("authentication failure")){
btn.removeClass('activate');
this.setState({
loginInProgress: false,
loginEnabled: true
});
pwf.attr('data-original-title', 'Invalid username or password')
.tooltip('fixTitle')
.tooltip('show');
}else if (error.message.includes("too many times in a row")){
btn.removeClass('activate');
this.setState({
loginInProgress: false,
loginEnabled: true
});
pwf.attr('data-original-title', 'Too many authentication attempts, please wait')
.tooltip('fixTitle')
.tooltip('show');
}else if (error.toString().includes('ECONNREFUSED')){
var icon = this.state.icon;
icon.toggle('true');
icon.removeClass();
icon.addClass("fa fa-times-circle red-icon-color form-control-feedback");
icon.attr('data-original-title', 'No database found')
.tooltip('fixTitle')
.tooltip('show');
this.setState({
loginInProgress: false,
loginEnabled: false
});
}
driver.close();
}.bind(this);
var session = driver.session();
session.run('MATCH (n) RETURN (n) LIMIT 1')
.subscribe({
onError: function(error){
btn.removeClass('activate');
var url = this.state.url.replace('bolt://','http://').replace('7687','7474');
if (error.fields && error.fields[0].code === "Neo.ClientError.Security.CredentialsExpired"){
pwf.attr('data-original-title', 'Credentials need to be changed from the neo4j browser first. Go to {} and change them.'.format(url))
.tooltip('fixTitle')
.tooltip('show');
this.setState({
loginInProgress: false,
loginEnabled: true
});
}
}.bind(this),
onNext: function(){
jQuery(this.refs.password).tooltip('hide')
jQuery(this.refs.urlspinner).tooltip('hide')
setTimeout(function(){
jQuery(this.refs.outer).fadeOut(400, function(){
renderEmit.emit('login');
});
}.bind(this), 1500)
driver.close()
global.driver = neo4j.driver(this.state.url, neo4j.auth.basic(this.state.user, this.state.password))
}.bind(this)
})
},
onCompleted: function(){
btn.toggleClass('activate');
btn.removeClass('btn-default');
btn.addClass('btn-success');
btn.html('Success!');
this.setState({
loginInProgress: false
});
btn.toggleClass('activate');
var dbinfo = {
url: this.state.url,
user: this.state.user,
password: this.state.password
};
}
if (this.state.save){
conf.set('databaseInfo',dbinfo);
}
componentWillMount() {
var c = conf.get('databaseInfo')
if (typeof c !== 'undefined'){
this.setState({
url: c.url,
user: c.user,
password: c.password,
save: true
})
}
}
appStore.databaseInfo = dbinfo;
componentDidMount() {
jQuery(this.refs.password).tooltip({
placement : 'right',
title: '',
container: 'body',
trigger: 'manual',
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner tooltip-inner-custom"></div></div>'
})
this.setState({icon: jQuery(this.refs.urlspinner)})
var icon = jQuery(this.refs.urlspinner)
icon.tooltip({
placement : 'right',
title: '',
container: 'body',
delay: {show: 200, hide: 0},
template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner tooltip-inner-custom"></div></div>'
})
icon.toggle(false)
if (this.state.password !== ""){
this.checkDBCreds();
}
}
jQuery(this.refs.password).tooltip('hide');
jQuery(this.refs.urlspinner).tooltip('hide');
setTimeout(function(){
jQuery(this.refs.outer).fadeOut(400, function(){
renderEmit.emit('login');
});
}.bind(this), 1500);
driver.close();
global.driver = neo4j.driver(this.state.url, neo4j.auth.basic(this.state.user, this.state.password));
}.bind(this)
});
_saveChange(event) {
this.setState({save: event.target.checked});
}
btn.toggleClass('activate');
_urlChanged(event){
this.setState({url: event.target.value})
}
}
_userChanged(event){
this.setState({user: event.target.value})
jQuery(this.refs.password).tooltip('hide')
}
_saveChange(event) {
this.setState({save: event.target.checked});
}
_passChanged(event){
this.setState({password: event.target.value})
jQuery(this.refs.password).tooltip('hide')
}
_urlChanged(event){
this.setState({url: event.target.value});
}
_triggerLogin(e){
var key = e.keyCode ? e.keyCode : e.which
_userChanged(event){
this.setState({user: event.target.value});
jQuery(this.refs.password).tooltip('hide');
}
if (key === 13){
this.checkDBCreds()
}
}
_passChanged(event){
this.setState({password: event.target.value});
jQuery(this.refs.password).tooltip('hide');
}
render() {
return (
<div className="loginwindow">
<div id="loginpanel" ref="outer">
<img src="src/img/logo-white-transparent-full.png" />
<div className="text-center">
<span>Log in to Neo4j Database</span>
</div>
<form>
<div className="form-group has-feedback">
<div className="input-group">
<span className="input-group-addon" id="dburladdon">
Database URL
</span>
<input ref="url" onFocus={function(){jQuery(this.state.icon).tooltip('hide');}.bind(this)} onBlur={this.checkDBPresence.bind(this)} onChange={this._urlChanged.bind(this)} type="text" className="form-control" value={this.state.url} placeholder="bolt://localhost:7687" aria-describedby="dburladdon" />
<i ref="urlspinner" className="fa fa-spinner fa-spin form-control-feedback" />
</div>
<div className="input-group spacing">
<span className="input-group-addon" id="dbuseraddon">DB Username</span>
<input ref="user" type="text" value={this.state.user} onKeyUp={this._triggerLogin.bind(this)} onChange={this._userChanged.bind(this)} className="form-control" placeholder="neo4j" aria-describedby="dbuseraddon" />
</div>
<div className="input-group spacing">
<span className="input-group-addon" id="dbpwaddon">DB Password</span>
<input ref="password" value={this.state.password} onKeyDown={this._triggerLogin.bind(this)} onChange={this._passChanged.bind(this)} type="password" className="form-control" placeholder="neo4j" aria-describedby="dbpwaddon" />
</div>
<div className="savecontainer">
<div className="checkbox logincheck">
<label><input value={this.state.save} onChange={this._saveChange.bind(this)} ref="save" type="checkbox" />Save Password</label>
</div>
<div className="buttoncontainer">
<button ref="loginButton" disabled={!this.state.loginEnabled} type="button" onClick={this.checkDBCreds.bind(this)} className="btn btn-primary loginbutton has-spinner">
Login
<span className="button-spinner">
<i className="fa fa-spinner fa-spin" />
</span>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
);
}
_triggerLogin(e){
var key = e.keyCode ? e.keyCode : e.which;
if (key === 13){
this.checkDBCreds();
}
}
render() {
return (
<div className="loginwindow">
<div id="loginpanel" ref="outer">
<img src="src/img/logo-white-transparent-full.png" />
<div className="text-center">
<span>Log in to Neo4j Database</span>
</div>
<form>
<div className="form-group has-feedback">
<div className="input-group">
<span className="input-group-addon" id="dburladdon">
Database URL
</span>
<input ref="url" onFocus={function(){jQuery(this.state.icon).tooltip('hide');}.bind(this)} onBlur={this.checkDBPresence.bind(this)} onChange={this._urlChanged.bind(this)} type="text" className="form-control" value={this.state.url} placeholder="bolt://localhost:7687" aria-describedby="dburladdon" />
<i ref="urlspinner" className="fa fa-spinner fa-spin form-control-feedback" />
</div>
<div className="input-group spacing">
<span className="input-group-addon" id="dbuseraddon">DB Username</span>
<input ref="user" type="text" value={this.state.user} onKeyUp={this._triggerLogin.bind(this)} onChange={this._userChanged.bind(this)} className="form-control" placeholder="neo4j" aria-describedby="dbuseraddon" />
</div>
<div className="input-group spacing">
<span className="input-group-addon" id="dbpwaddon">DB Password</span>
<input ref="password" value={this.state.password} onKeyDown={this._triggerLogin.bind(this)} onChange={this._passChanged.bind(this)} type="password" className="form-control" placeholder="neo4j" aria-describedby="dbpwaddon" />
</div>
<div className="savecontainer">
<div className="checkbox logincheck">
<label><input checked={this.state.save} onChange={this._saveChange.bind(this)} ref="save" type="checkbox" />Save Password</label>
</div>
<div className="buttoncontainer">
<button ref="loginButton" disabled={!this.state.loginEnabled} type="button" onClick={this.checkDBCreds.bind(this)} className="btn btn-primary loginbutton has-spinner">
Login
<span className="button-spinner">
<i className="fa fa-spinner fa-spin" />
</span>
</button>
</div>
</div>
</div>
</form>
</div>
</div>
);
}
}

View File

@ -1,138 +1,139 @@
import React, { Component } from 'react';
export default class Settings extends Component {
constructor(){
super();
}
constructor(){
super();
}
componentDidMount() {
emitter.on('openSettings', function(){
this.openSettings()
}.bind(this))
componentDidMount() {
emitter.on('openSettings', function(){
this.openSettings()
}.bind(this))
$(this.refs.edge).simpleSlider({
range: [0,20],
step: 1,
theme: 'volume slideinline'
})
$(this.refs.edge).simpleSlider({
range: [0,20],
step: 1,
theme: 'volume slideinline'
})
$(this.refs.sibling).simpleSlider({
range: [0,20],
step: 1,
theme: 'volume slideinline'
})
$(this.refs.sibling).simpleSlider({
range: [0,20],
step: 1,
theme: 'volume slideinline'
})
$(this.refs.edge).bind('slider:changed', this.edgeChange.bind(this))
$(this.refs.sibling).bind('slider:changed', this.siblingChange.bind(this))
$(this.refs.edge).bind('slider:changed', this.edgeChange.bind(this))
$(this.refs.sibling).bind('slider:changed', this.siblingChange.bind(this))
$(this.refs.edge).simpleSlider('setValue', appStore.performance.edge)
$(this.refs.sibling).simpleSlider('setValue', appStore.performance.sibling)
$(this.refs.edge).simpleSlider('setValue', appStore.performance.edge)
$(this.refs.sibling).simpleSlider('setValue', appStore.performance.sibling)
$(this.refs.check).prop('checked', appStore.performance.lowGraphics)
$(this.refs.debug).prop('checked', appStore.performance.debug)
$(this.refs.check).prop('checked', appStore.performance.lowGraphics)
$(this.refs.debug).prop('checked', appStore.performance.debug)
$(this.refs.outer).fadeToggle(0)
$(this.refs.outer).draggable()
}
$(this.refs.outer).fadeToggle(0)
$(this.refs.outer).draggable()
}
edgeChange(event, data){
appStore.performance.edge = data.value;
$(this.refs.edgeinput).val(data.value)
conf.set('performance', appStore.performance)
}
edgeChange(event, data){
appStore.performance.edge = data.value;
$(this.refs.edgeinput).val(data.value)
conf.set('performance', appStore.performance)
}
siblingChange(event, data){
appStore.performance.sibling = data.value;
$(this.refs.siblinginput).val(data.value)
conf.set('performance', appStore.performance)
}
siblingChange(event, data){
appStore.performance.sibling = data.value;
$(this.refs.siblinginput).val(data.value)
conf.set('performance', appStore.performance)
}
onGfxChange(event){
$(this.refs.check).prop('checked', event.target.checked)
appStore.performance.lowGraphics = event.target.checked
conf.set('performance', appStore.performance)
emitter.emit('changeGraphicsMode')
}
onGfxChange(event){
$(this.refs.check).prop('checked', event.target.checked)
appStore.performance.lowGraphics = event.target.checked
conf.set('performance', appStore.performance)
emitter.emit('changeGraphicsMode')
}
onDebugChange(event){
$(this.refs.debug).prop('checked', event.target.checked)
appStore.performance.debug = event.target.checked
conf.set('performance', appStore.performance)
}
onDebugChange(event){
$(this.refs.debug).prop('checked', event.target.checked)
appStore.performance.debug = event.target.checked
conf.set('performance', appStore.performance)
}
closeSettings(){
$(this.refs.outer).fadeToggle(false)
}
closeSettings(){
$(this.refs.outer).fadeToggle(false)
}
openSettings(){
$(this.refs.outer).fadeToggle(false)
}
openSettings(){
$(this.refs.outer).fadeToggle(false)
}
updateSibling(event){
$(this.refs.sibling).simpleSlider('setValue', event.target.value)
}
updateSibling(event){
$(this.refs.sibling).simpleSlider('setValue', event.target.value)
}
updateEdge(event){
$(this.refs.edge).simpleSlider('setValue', event.target.value)
}
updateEdge(event){
$(this.refs.edge).simpleSlider('setValue', event.target.value)
}
render() {
return (
<div ref="outer" className="settingsDiv panel panel-default">
<div className="panel-heading">
Settings
<button type="button" className="close" onClick={this.closeSettings.bind(this)} aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
render() {
return (
<div ref="outer" className="settingsDiv panel panel-default">
<div className="panel-heading">
Settings
<button type="button" className="close" onClick={this.closeSettings.bind(this)} aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div className="panel-body sliderfix">
<div>
<strong>Sibling Collapse Threshold</strong>
<i data-toggle="tooltip"
data-placement="right"
title="Merge nodes that have the same parent. 0 to Disable, Default 10"
className="glyphicon glyphicon-question-sign"></i>
<br/>
<input type="text" ref="sibling" />
<span>
<input onChange={this.updateSibling.bind(this)} type="number" min="0" max="20" className="sliderinput" ref="siblinginput" />
</span>
</div>
<div className="panel-body sliderfix">
<div>
<strong>Sibling Collapse Threshold</strong>
<i data-toggle="tooltip"
data-placement="right"
title="Merge nodes that have the same parent. 0 to Disable, Default 10"
className="glyphicon glyphicon-question-sign"></i>
<br/>
<input type="text" ref="sibling" />
<span>
<input onChange={this.updateSibling.bind(this)} type="number" min="0" max="20" className="sliderinput" ref="siblinginput" />
</span>
</div>
<div>
<strong>Node Collapse Threshold</strong>
<i data-toggle="tooltip"
data-placement="right"
title="Collapse nodes at the end of paths that only have one relationship. 0 to Disable, Default 5"
className="glyphicon glyphicon-question-sign"></i>
<br />
<input type="text" ref="edge" />
<span>
<input type="number" min="0" max="20" className="sliderinput" ref="edgeinput" />
</span>
</div>
<div className="checkbox-inline">
<label>
<input ref="debug" type="checkbox" onChange={this.onDebugChange.bind(this)}/> Query Debug Mode
</label>
</div>
<i data-toggle="tooltip"
data-placement="right"
title="Dump queries run into the Raw Query Box"
className="glyphicon glyphicon-question-sign"></i>
<br />
<div className="checkbox-inline">
<label>
<input ref="check" type="checkbox" onChange={this.onGfxChange.bind(this)}/> Low Detail Mode
</label>
</div>
<i data-toggle="tooltip"
data-placement="right"
title="Lower detail of graph to improve performance"
className="glyphicon glyphicon-question-sign"></i>
</div>
</div>
);
}
<div>
<strong>Node Collapse Threshold</strong>
<i data-toggle="tooltip"
data-placement="right"
title="Collapse nodes at the end of paths that only have one relationship. 0 to Disable, Default 5"
className="glyphicon glyphicon-question-sign"></i>
<br />
<input type="text" ref="edge" />
<span>
<input type="number" min="0" max="20" className="sliderinput" ref="edgeinput" />
</span>
</div>
<br />
<div className="checkbox-inline">
<label>
<input ref="debug" type="checkbox" onChange={this.onDebugChange.bind(this)}/> Query Debug Mode
</label>
</div>
<i data-toggle="tooltip"
data-placement="right"
title="Dump queries run into the Raw Query Box"
className="glyphicon glyphicon-question-sign"></i>
<br />
<div className="checkbox-inline">
<label>
<input ref="check" type="checkbox" onChange={this.onGfxChange.bind(this)}/> Low Detail Mode
</label>
</div>
<i data-toggle="tooltip"
data-placement="right"
title="Lower detail of graph to improve performance"
className="glyphicon glyphicon-question-sign"></i>
</div>
</div>
);
}
}

View File

@ -1,15 +1,15 @@
import React, { Component } from 'react';
import ReactDOM from 'react-dom'
import ReactDOM from 'react-dom';
import { findGraphPath } from 'utils';
var fs = require('fs');
var child_process = require('child_process')
var child_process = require('child_process');
var child;
var path = require('path')
const { dialog } = require('electron').remote
var path = require('path');
const { dialog } = require('electron').remote;
export default class GraphContainer extends Component {
constructor(props){
super(props)
super(props);
child = child_process.fork(path.join(__dirname,'src','js','worker.js'), {silent:true});
@ -20,14 +20,15 @@ export default class GraphContainer extends Component {
firstDraw: true,
template: null,
session: driver.session()
}
};
$.ajax({
url: 'src/components/tooltip.html',
type: 'GET',
success: function(response){
this.setState({template: response})
this.setState({template: response});
}.bind(this)
})
});
child.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
@ -38,64 +39,93 @@ export default class GraphContainer extends Component {
});
child.on('message', function(m) {
this.loadFromChildProcess(m)
this.loadFromChildProcess(m);
}.bind(this));
var s1 = driver.session()
var s2 = driver.session()
var s3 = driver.session()
var s4 = driver.session()
var s1 = driver.session();
var s2 = driver.session();
var s3 = driver.session();
var s4 = driver.session();
s1.run("CREATE CONSTRAINT ON (c:User) ASSERT c.name IS UNIQUE")
.then(function(){
s1.close()
s1.close();
s2.run("CREATE CONSTRAINT ON (c:Computer) ASSERT c.name IS UNIQUE")
.then(function(){
s2.close()
s2.close();
s3.run("CREATE CONSTRAINT ON (c:Group) ASSERT c.name IS UNIQUE")
.then(function(){
s3.close()
s3.close();
s4.run("CREATE CONSTRAINT ON (c:Domain) ASSERT c.name IS UNIQUE")
.then(function(){
s4.close()
s4.close();
})
.catch(function(){
s4.close()
})
s4.close();
});
})
.catch(function(){
s3.close()
})
s3.close();
});
})
.catch(function(){
s2.close()
})
s2.close();
});
})
.catch(function(){
s1.close()
})
s1.close();
});
emitter.on('doLogout', function(){
this.state.sigmaInstance.graph.clear();
this.state.sigmaInstance.refresh();
sigma.layouts.killForceLink();
this.setState({sigmaInstance: null})
this.setState({sigmaInstance: null});
child.kill();
}.bind(this))
}.bind(this));
}
componentWillMount() {
emitter.on('searchQuery', this.doSearchQuery.bind(this));
emitter.on('pathQuery', this.doPathQuery.bind(this));
emitter.on('graphBack', this.goBack.bind(this));
emitter.on('query', this.doGenericQuery.bind(this));
emitter.on('spotlightClick', this.spotlightClickHandler.bind(this));
emitter.on('graphRefresh', this.relayout.bind(this));
emitter.on('export', this.export.bind(this));
emitter.on('import', this.import.bind(this));
emitter.on('clearDB', this.clearGraph.bind(this));
emitter.on('changeGraphicsMode', this.setGraphicsMode.bind(this));
emitter.on('ungroupNode', this.ungroupNode.bind(this));
emitter.on('unfoldNode', this.unfoldEdgeNode.bind(this));
emitter.on('collapseNode', this.foldEdgeNode.bind(this));
emitter.on('resetZoom', this.resetZoom.bind(this));
emitter.on('zoomIn', this.zoomIn.bind(this));
emitter.on('zoomOut', this.zoomOut.bind(this));
}
componentDidMount() {
this.initializeSigma();
this.doQueryNative({
statement: 'MATCH (n:Group) WHERE n.name =~ "(?i).*DOMAIN ADMINS.*" WITH n MATCH (n)<-[r:MemberOf*1..]-(m) RETURN n,r,m',
allowCollapse: false,
props: {}
});
}
relayout(){
sigma.layouts.stopForceLink()
sigma.layouts.stopForceLink();
if (appStore.dagre){
sigma.layouts.dagre.start(this.state.sigmaInstance);
}else{
sigma.layouts.startForceLink()
sigma.layouts.startForceLink();
}
}
export(payload){
if (payload === 'image'){
var size = $('#graph').outerWidth()
var size = $('#graph').outerWidth();
sigma.plugins.image(this.state.sigmaInstance,
this.state.sigmaInstance.renderers[0],
{
@ -106,27 +136,27 @@ export default class GraphContainer extends Component {
});
}else{
var json = this.state.sigmaInstance.toJSON({
pretty: true,
})
pretty: true
});
json = JSON.parse(json)
json.spotlight = appStore.spotlightData
json = JSON.parse(json);
json.spotlight = appStore.spotlightData;
dialog.showSaveDialog({
defaultPath: 'graph.json'
}, function(loc){
fs.writeFile(loc, JSON.stringify(json, null, 2))
})
fs.writeFile(loc, JSON.stringify(json, null, 2));
});
}
}
loadFromChildProcess(graph){
if (graph.nodes.length === 0){
emitter.emit('showAlert', "No data returned from query")
emitter.emit('updateLoadingText', "Done!")
emitter.emit('showAlert', "No data returned from query");
emitter.emit('updateLoadingText', "Done!");
setTimeout(function(){
emitter.emit('showLoadingIndicator', false);
}, 1500)
}, 1500);
}else{
if (!this.state.firstDraw){
appStore.queryStack.push({
@ -135,23 +165,23 @@ export default class GraphContainer extends Component {
spotlight: appStore.spotlightData,
startNode: appStore.startNode,
endNode: appStore.endNode
})
});
}
$.each(graph.nodes, function(i, node){
if (node.start){
appStore.startNode = node
appStore.startNode = node;
}
if (node.end){
appStore.endNode = node
appStore.endNode = node;
}
node.glyphs = $.map(node.glyphs, function(value, index) {
return [value];
});
})
});
this.setState({firstDraw: false})
this.setState({firstDraw: false});
sigma.misc.animation.camera(this.state.sigmaInstance.camera, { x: 0, y: 0, ratio: 1.075 });
appStore.spotlightData = graph.spotlight;
@ -164,7 +194,7 @@ export default class GraphContainer extends Component {
if (appStore.dagre){
sigma.layouts.dagre.start(this.state.sigmaInstance);
}else{
sigma.layouts.startForceLink()
sigma.layouts.startForceLink();
}
emitter.emit('spotlightUpdate');
}
@ -177,44 +207,44 @@ export default class GraphContainer extends Component {
graph = JSON.parse(data);
}catch (err){
emitter.emit('showAlert', 'Bad JSON File');
return
return;
}
if (graph.nodes.length === 0){
emitter.emit('showAlert', "No data returned from query")
emitter.emit('showAlert', "No data returned from query");
}else{
$.each(graph.nodes, function(i, node){
node.glyphs = $.map(node.glyphs, function(value, index) {
return [value];
});
})
});
appStore.queryStack.push({
nodes: this.state.sigmaInstance.graph.nodes(),
edges: this.state.sigmaInstance.graph.edges(),
spotlight: appStore.spotlightData,
startNode: appStore.startNode,
endNode: appStore.endNode
})
});
appStore.spotlightData = graph.spotlight;
this.state.sigmaInstance.graph.clear();
this.state.sigmaInstance.graph.read(graph);
this.state.sigmaInstance.refresh()
this.state.sigmaInstance.refresh();
emitter.emit('spotlightUpdate');
}
}.bind(this))
}.bind(this));
}
clearGraph(){
this.state.sigmaInstance.graph.clear()
this.state.sigmaInstance.refresh()
this.state.sigmaInstance.graph.clear();
this.state.sigmaInstance.refresh();
}
setGraphicsMode(){
var lowgfx = appStore.performance.lowGraphics
var sigmaInstance = this.state.sigmaInstance
this.state.design.clear()
var lowgfx = appStore.performance.lowGraphics;
var sigmaInstance = this.state.sigmaInstance;
this.state.design.clear();
if (lowgfx){
sigmaInstance.settings('defaultEdgeType', 'line');
sigmaInstance.settings('defaultEdgeColor', 'black');
@ -226,28 +256,9 @@ export default class GraphContainer extends Component {
this.state.design.setPalette(appStore.highResPalette);
this.state.design.setStyles(appStore.highResStyle);
}
this.state.design.deprecate()
sigmaInstance.refresh()
this.state.design.apply()
}
componentWillMount() {
emitter.on('searchQuery', this.doSearchQuery.bind(this));
emitter.on('pathQuery', this.doPathQuery.bind(this));
emitter.on('graphBack', this.goBack.bind(this));
emitter.on('query', this.doGenericQuery.bind(this));
emitter.on('spotlightClick', this.spotlightClickHandler.bind(this))
emitter.on('graphRefresh', this.relayout.bind(this))
emitter.on('export', this.export.bind(this))
emitter.on('import', this.import.bind(this))
emitter.on('clearDB', this.clearGraph.bind(this))
emitter.on('changeGraphicsMode', this.setGraphicsMode.bind(this))
emitter.on('ungroupNode', this.ungroupNode.bind(this))
emitter.on('unfoldNode', this.unfoldEdgeNode.bind(this))
emitter.on('collapseNode', this.foldEdgeNode.bind(this))
emitter.on('resetZoom', this.resetZoom.bind(this))
emitter.on('zoomIn', this.zoomIn.bind(this))
emitter.on('zoomOut', this.zoomOut.bind(this))
this.state.design.deprecate();
sigmaInstance.refresh();
this.state.design.apply();
}
resetZoom(){
@ -258,7 +269,7 @@ export default class GraphContainer extends Component {
}
zoomOut(){
var sigmaInstance = this.state.sigmaInstance
var sigmaInstance = this.state.sigmaInstance;
var cam = sigmaInstance.camera;
sigma.misc.animation.camera(cam, {
@ -269,7 +280,7 @@ export default class GraphContainer extends Component {
}
zoomIn(){
var sigmaInstance = this.state.sigmaInstance
var sigmaInstance = this.state.sigmaInstance;
var cam = sigmaInstance.camera;
sigma.misc.animation.camera(cam,
@ -281,16 +292,6 @@ export default class GraphContainer extends Component {
});
}
componentDidMount() {
this.initializeSigma();
this.doQueryNative({
statement: 'MATCH (n:Group) WHERE n.name =~ "(?i).*DOMAIN ADMINS.*" WITH n MATCH (n)<-[r:MemberOf*1..]-(m) RETURN n,r,m',
allowCollapse: false,
props: {}
})
}
render() {
return (
<div className="graph">
@ -321,25 +322,25 @@ export default class GraphContainer extends Component {
spotlightClickHandler(nodeId, parentId){
var sigmaInstance = this.state.sigmaInstance;
var parent = sigmaInstance.graph.nodes(nodeId)
var parent = sigmaInstance.graph.nodes(nodeId);
var label, child;
if (typeof parent === 'undefined'){
child = sigmaInstance.graph.nodes(parentId).folded.nodes.filter(function(val){
return val.id == nodeId;
})[0]
return val.id === nodeId;
})[0];
parent = sigmaInstance.graph.nodes(parentId);
}else{
child = parent;
}
label = child.label;
if (child.type_user){
emitter.emit('userNodeClicked', label)
emitter.emit('userNodeClicked', label);
}else if (child.type_group){
emitter.emit('groupNodeClicked', label)
emitter.emit('groupNodeClicked', label);
}else if (child.type_computer){
emitter.emit('computerNodeClicked', label)
emitter.emit('computerNodeClicked', label);
}
parent.color = "#2DC486"
parent.color = "#2DC486";
sigma.misc.animation.camera(
sigmaInstance.camera, {
x: parent[sigmaInstance.camera.readPrefix + 'x'],
@ -351,119 +352,120 @@ export default class GraphContainer extends Component {
setTimeout(function(){
parent.color = "black";
sigmaInstance.refresh({skipIndexation: true});
}, 2000)
}, 2000);
}
doQueryNative(params){
if (appStore.performance.debug){
emitter.emit('setRawQuery',params.statement);
}
var sigmaInstance = this.state.sigmaInstance
var nodes = {}
var edges = {}
var session = driver.session()
var sigmaInstance = this.state.sigmaInstance;
var nodes = {};
var edges = {};
var session = driver.session();
if (typeof params.props === 'undefined'){
params.props = {}
params.props = {};
}
emitter.emit('showLoadingIndicator', true);
emitter.emit('updateLoadingText', "Querying Database")
emitter.emit('resetSpotlight')
emitter.emit('updateLoadingText', "Querying Database");
emitter.emit('resetSpotlight');
session.run(params.statement, params.props)
.subscribe({
onNext: function(result){
$.each(result._fields, function(index, field){
if (field != null){
if (field !== null){
if (field.hasOwnProperty('segments')){
$.each(field.segments,function(index, segment){
var end = this.createNodeFromRow(segment.end, params)
var start = this.createNodeFromRow(segment.start, params)
var edge = this.createEdgeFromRow(segment.relationship)
var end = this.createNodeFromRow(segment.end, params);
var start = this.createNodeFromRow(segment.start, params);
var edge = this.createEdgeFromRow(segment.relationship);
if (!edges[edge.id]){
edges[edge.id] = edge
edges[edge.id] = edge;
}
if (!nodes[end.id]){
nodes[end.id] = end
nodes[end.id] = end;
}
if (!nodes[start.id]){
nodes[start.id] = start
nodes[start.id] = start;
}
}.bind(this))
}.bind(this));
}else{
if ($.isArray(field)){
$.each(field, function(index, value){
if (value != null){
var id = value.identity.low
if (value !== null){
var id = value.identity.low;
if (value.end && !edges.id){
edges[id] = this.createEdgeFromRow(value)
edges[id] = this.createEdgeFromRow(value);
}else if (!nodes.id){
nodes[id] = this.createNodeFromRow(value, params)
nodes[id] = this.createNodeFromRow(value, params);
}
}
}.bind(this))
}.bind(this));
}else{
var id = field.identity.low
var id = field.identity.low;
if (field.end && !edges.id){
edges[id] = this.createEdgeFromRow(field)
edges[id] = this.createEdgeFromRow(field);
}else if (!nodes.id){
nodes[id] = this.createNodeFromRow(field, params)
nodes[id] = this.createNodeFromRow(field, params);
}
}
}
}
}.bind(this))
}.bind(this));
}.bind(this),
onError: function(error){
console.log(error)
console.log(error);
},
onCompleted: function(){
var graph = {nodes:[],edges:[]}
var graph = {nodes:[],edges:[]};
$.each(nodes, function(node){
graph.nodes.push(nodes[node])
})
graph.nodes.push(nodes[node]);
});
$.each(edges, function(edge){
graph.edges.push(edges[edge])
})
emitter.emit('updateLoadingText', "Processing Data")
graph.edges.push(edges[edge]);
});
emitter.emit('updateLoadingText', "Processing Data");
child.send(JSON.stringify({graph: graph,
edge: params.allowCollapse ? appStore.performance.edge : 0 ,
sibling: params.allowCollapse ? appStore.performance.sibling : 0,
start: params.start,
end: params.end
}))
session.close()
}));
session.close();
}.bind(this)
})
});
}
createEdgeFromRow(data){
var id = data.identity.low
var type = data.type
var source = data.start.low
var target = data.end.low
var id = data.identity.low;
var type = data.type;
var source = data.start.low;
var target = data.end.low;
var edge = {
id: id,
type: type,
source: source,
target:target,
label: type
}
};
return edge
return edge;
}
createNodeFromRow(data, params){
var id = data.identity.low
var type = data.labels[0]
var label = data.properties.name
var id = data.identity.low;
var type = data.labels[0];
var label = data.properties.name;
var node = {
id: id,
type: type,
label: label,
Enabled: data.properties.Enabled,
glyphs: [],
folded: {
nodes: [],
@ -471,28 +473,28 @@ export default class GraphContainer extends Component {
},
x: Math.random(),
y: Math.random()
}
};
if (label === params.start){
node.start = true
node.start = true;
node.glyphs.push({
'position': 'bottom-right',
'font': 'FontAwesome',
'content': '\uF21D',
'fillColor': '#3399FF',
'fontScale': 1.5
})
});
}
if (label === params.end){
node.end = true
node.end = true;
node.glyphs.push({
'position': 'bottom-right',
'font': 'FontAwesome',
'fillColor': '#990000',
'content': '\uF05B',
'fontScale': 1.5
})
});
}
switch (type) {
@ -510,60 +512,60 @@ export default class GraphContainer extends Component {
break;
}
return node
return node;
}
unfoldEdgeNode(id){
var sigmaInstance = this.state.sigmaInstance
sigmaInstance.graph.read(sigmaInstance.graph.nodes(id).folded)
this.state.design.deprecate()
var sigmaInstance = this.state.sigmaInstance;
sigmaInstance.graph.read(sigmaInstance.graph.nodes(id).folded);
this.state.design.deprecate();
this.state.design.apply();
this.relayout()
this.relayout();
}
foldEdgeNode(id){
var sigmaInstance = this.state.sigmaInstance
var sigmaInstance = this.state.sigmaInstance;
$.each(sigmaInstance.graph.nodes(id).folded.nodes, function(index, node){
sigmaInstance.graph.dropNode(node.id)
})
sigmaInstance.refresh()
sigmaInstance.graph.dropNode(node.id);
});
sigmaInstance.refresh();
this.state.design.deprecate();
this.state.design.apply();
this.relayout();
}
ungroupNode(id){
var sigmaInstance = this.state.sigmaInstance
var node = sigmaInstance.graph.nodes(id)
var sigmaInstance = this.state.sigmaInstance;
var node = sigmaInstance.graph.nodes(id);
sigmaInstance.graph.dropNode(id);
sigmaInstance.graph.read(node.folded)
this.state.design.deprecate()
sigmaInstance.refresh()
this.state.design.apply()
sigmaInstance.graph.read(node.folded);
this.state.design.deprecate();
sigmaInstance.refresh();
this.state.design.apply();
this.relayout();
}
doSearchQuery(payload, props){
if (typeof props === 'undefined'){
props = {}
props = {};
}
this.doQueryNative({
statement: payload,
allowCollapse: true,
props: props
})
});
}
doPathQuery(start, end){
var statement = "MATCH (n {name:{start}}), (m {name:{end}}), p=allShortestPaths((n)-[*]->(m)) RETURN p"
var props = {start: start, end: end}
var statement = "MATCH (n {name:{start}}), (m {name:{end}}), p=allShortestPaths((n)-[*]->(m)) RETURN p";
var props = {start: start, end: end};
this.doQueryNative({
statement: statement,
allowCollapse: true,
props: props,
start: start,
end: end
})
});
}
doGenericQuery(statement, props, start, end, allowCollapse=true){
@ -572,7 +574,7 @@ export default class GraphContainer extends Component {
}
if (typeof props === 'undefined'){
props = {}
props = {};
}
this.doQueryNative({
statement: statement,
@ -580,26 +582,26 @@ export default class GraphContainer extends Component {
start: start,
end: end,
props: props
})
});
}
_nodeDragged(){
this.setState({dragged:true})
this.setState({dragged:true});
}
_nodeClicked(n){
if (!this.state.dragged){
if (n.data.node.type_user){
emitter.emit('userNodeClicked', n.data.node.label)
emitter.emit('userNodeClicked', n.data.node.label);
}else if (n.data.node.type_group){
emitter.emit('groupNodeClicked', n.data.node.label)
emitter.emit('groupNodeClicked', n.data.node.label);
}else if (n.data.node.type_computer && (n.data.node.label !== 'Grouped Computers')){
emitter.emit('computerNodeClicked', n.data.node.label)
emitter.emit('computerNodeClicked', n.data.node.label);
}else if (n.data.node.type_domain){
emitter.emit('domainNodeClicked', n.data.node.label)
emitter.emit('domainNodeClicked', n.data.node.label);
}
}else{
this.setState({dragged: false})
this.setState({dragged: false});
}
}
@ -610,7 +612,7 @@ export default class GraphContainer extends Component {
{
container: 'graph'
}
)
);
sigmaInstance.settings(
{
@ -629,7 +631,7 @@ export default class GraphContainer extends Component {
zoomingRatio: 1.4,
scalingMode: 'inside'
}
)
);
//Bind sigma events
sigmaInstance.renderers[0].bind('render', function(e) {
@ -642,21 +644,21 @@ export default class GraphContainer extends Component {
}else{
sigmaInstance.settings('drawEdgeLabels', true);
}
})
});
sigmaInstance.bind('clickNode', this._nodeClicked.bind(this))
sigmaInstance.bind('clickNode', this._nodeClicked.bind(this));
sigmaInstance.bind('hovers', function(e){
if (e.data.enter.nodes.length > 0) {
if (appStore.endNode !== null) {
findGraphPath(this.state.sigmaInstance, false, e.data.enter.nodes[0].id)
findGraphPath(this.state.sigmaInstance, false, e.data.enter.nodes[0].id);
}
if (appStore.startNode !== null) {
findGraphPath(this.state.sigmaInstance, true, e.data.enter.nodes[0].id)
findGraphPath(this.state.sigmaInstance, true, e.data.enter.nodes[0].id);
}
sigmaInstance.refresh({'skipIndexation': true})
sigmaInstance.refresh({'skipIndexation': true});
}
if (e.data.leave.nodes.length > 0) {
@ -668,13 +670,13 @@ export default class GraphContainer extends Component {
sigmaInstance.refresh({ 'skipIndexation': true });
}
}
}.bind(this))
}.bind(this));
//Some key binds
$(window).on('keyup', function(e){
var key = e.keyCode ? e.keyCode : e.which
var mode = appStore.performance.nodeLabels
var sigmaInstance = this.state.sigmaInstance
var key = e.keyCode ? e.keyCode : e.which;
var mode = appStore.performance.nodeLabels;
var sigmaInstance = this.state.sigmaInstance;
if (document.activeElement === document.body && key === 17){
mode = mode + 1;
@ -682,28 +684,28 @@ export default class GraphContainer extends Component {
mode = 0;
}
appStore.performance.nodeLabels = mode;
conf.set('performance', appStore.performance)
conf.set('performance', appStore.performance);
if (mode === 0){
sigmaInstance.settings('labelThreshold', 500);
emitter.emit('showAlert', 'Hiding Node Labels')
emitter.emit('showAlert', 'Hiding Node Labels');
}else if (mode === 1){
sigmaInstance.settings('labelThreshold', 15);
emitter.emit('showAlert', 'Default Node Label Threshold')
emitter.emit('showAlert', 'Default Node Label Threshold');
}else{
sigmaInstance.settings('labelThreshold', 1);
emitter.emit('showAlert', 'Always Showing Node Labels')
emitter.emit('showAlert', 'Always Showing Node Labels');
}
sigmaInstance.refresh({'skipIndexation' : true})
sigmaInstance.refresh({'skipIndexation' : true});
}
}.bind(this))
}.bind(this));
//Plugin Configuration
var dragListener = sigma.plugins.dragNodes(sigmaInstance,
sigmaInstance.renderers[0])
sigmaInstance.renderers[0]);
dragListener.bind('drag', this._nodeDragged.bind(this))
dragListener.bind('drag', this._nodeDragged.bind(this));
var tooltips = sigma.plugins.tooltips(
sigmaInstance,
@ -718,7 +720,7 @@ export default class GraphContainer extends Component {
node.expand = false;
node.collapse = false;
if (node.folded.nodes.length > 0 && !node.groupedNode) {
if (typeof this.state.sigmaInstance.graph.nodes(node.folded.nodes[0].id) == 'undefined') {
if (typeof this.state.sigmaInstance.graph.nodes(node.folded.nodes[0].id) === 'undefined') {
node.expand = true;
} else {
node.collapse = true;
@ -753,12 +755,12 @@ export default class GraphContainer extends Component {
forcelinkListener.bind('stop', function(event) {
emitter.emit('updateLoadingText', "Fixing Overlap");
sigmaInstance.startNoverlap();
})
});
forcelinkListener.bind('start', function(event){
emitter.emit('updateLoadingText', 'Initial Layout')
emitter.emit('showLoadingIndicator', true)
})
emitter.emit('updateLoadingText', 'Initial Layout');
emitter.emit('showLoadingIndicator', true);
});
var dagreListener = sigma.layouts.dagre.configure(sigmaInstance, {
easing: 'cubicInOut',
@ -774,22 +776,22 @@ export default class GraphContainer extends Component {
emitter.emit('updateLoadingText', "Fixing Overlap");
sigmaInstance.startNoverlap();
needsfix = true;
return
return;
}
}, this);
if (!needsfix){
emitter.emit('updateLoadingText', 'Done!');
sigma.canvas.edges.autoCurve(sigmaInstance)
sigma.canvas.edges.autoCurve(sigmaInstance);
setTimeout(function(){
emitter.emit('showLoadingIndicator', false);
}, 1500)
}, 1500);
}
})
});
dagreListener.bind('start', function(event){
emitter.emit('updateLoadingText', 'Initial Layout')
emitter.emit('showLoadingIndicator', true)
})
emitter.emit('updateLoadingText', 'Initial Layout');
emitter.emit('showLoadingIndicator', true);
});
// var noverlapListener = sigmaInstance.configNoverlap({
// nodeMargin: 5.0,
@ -799,19 +801,19 @@ export default class GraphContainer extends Component {
// });
//
var noverlapListener = sigmaInstance.configNoverlap({})
var noverlapListener = sigmaInstance.configNoverlap({});
noverlapListener.bind('stop', function(event) {
emitter.emit('updateLoadingText', 'Done!');
sigma.canvas.edges.autoCurve(sigmaInstance)
sigma.canvas.edges.autoCurve(sigmaInstance);
setTimeout(function(){
emitter.emit('showLoadingIndicator', false);
}, 1500)
}, 1500);
});
var lowgfx = appStore.performance.lowGraphics
var lowgfx = appStore.performance.lowGraphics;
design = sigma.plugins.design(sigmaInstance);
if (lowgfx){
@ -826,7 +828,7 @@ export default class GraphContainer extends Component {
design.setStyles(appStore.highResStyle);
}
var mode = appStore.performance.nodeLabels
var mode = appStore.performance.nodeLabels;
if (mode === 0){
sigmaInstance.settings('labelThreshold', 500);

View File

@ -1,284 +1,310 @@
import React, { Component } from 'react';
import MenuButton from './MenuButton';
import ProgressBarMenuButton from './ProgressBarMenuButton';
import { buildDomainProps, buildSessionProps, buildLocalAdminProps, buildGroupMembershipProps, buildACLProps } from 'utils';
import { buildDomainProps, buildSessionProps, buildLocalAdminProps, buildGroupMembershipProps, buildACLProps, findObjectType} from 'utils';
import { If, Then, Else } from 'react-if';
const { dialog, clipboard } = require('electron').remote
var fs = require('fs')
var async = require('async')
const { dialog, clipboard, app } = require('electron').remote;
var fs = require('fs');
var async = require('async');
var unzip = require('unzipper');
var fpath = require('path');
var csv = require('fast-csv');
export default class MenuContainer extends Component {
constructor(){
super()
constructor(){
super();
this.state = {
refreshHover: false,
uploading: false,
progress: 0,
parser: null
}
this.state = {
refreshHover: false,
uploading: false,
progress: 0,
cancelled: false
};
emitter.on('cancelUpload', this.cancelUpload.bind(this))
}
emitter.on('cancelUpload', this.cancelUpload.bind(this))
}
cancelUpload(){
this.state.parser.abort()
setTimeout(function(){
this.setState({uploading: false})
}.bind(this), 1000)
}
cancelUpload(){
this.setState({cancelled: true});
setTimeout(function(){
this.setState({uploading: false})
}.bind(this), 1000);
}
_refreshClick(){
emitter.emit('graphRefresh')
}
_refreshClick(){
emitter.emit('graphRefresh')
}
_changeLayoutClick(){
appStore.dagre = !appStore.dagre
emitter.emit('graphRefresh')
var type = appStore.dagre ? 'Hierarchical' : 'Directed'
emitter.emit('showAlert', 'Changed Layout to ' + type)
}
_changeLayoutClick(){
appStore.dagre = !appStore.dagre
emitter.emit('graphRefresh')
var type = appStore.dagre ? 'Hierarchical' : 'Directed'
emitter.emit('showAlert', 'Changed Layout to ' + type)
}
_exportClick(){
emitter.emit('showExport');
}
_exportClick(){
emitter.emit('showExport');
}
_importClick(){
var fname = dialog.showOpenDialog({
properties: ['openFile']
})
if (typeof fname !== 'undefined'){
emitter.emit('import',fname[0])
}
}
_importClick(){
var fname = dialog.showOpenDialog({
properties: ['openFile']
});
if (typeof fname !== 'undefined'){
emitter.emit('import',fname[0]);
}
}
_settingsClick(){
emitter.emit('openSettings')
}
_settingsClick(){
emitter.emit('openSettings')
}
_cancelUploadClick(){
emitter.emit('showCancelUpload')
}
_cancelUploadClick(){
emitter.emit('showCancelUpload')
}
_uploadClick(){
var input = jQuery(this.refs.fileInput)
var files = $.makeArray(input[0].files)
_uploadClick(){
var input = jQuery(this.refs.fileInput);
var fileNames = [];
async.eachSeries(files, function(file, callback){
emitter.emit('showAlert', 'Processing file {}'.format(file.name));
this.processFile(file.path, file, callback)
}.bind(this),
function done(){
setTimeout(function(){
this.setState({uploading: false})
}.bind(this), 3000)
}.bind(this))
$.each(input[0].files, function(index, file){
fileNames.push({path:file.path, name:file.name});
});
input.val('')
}
this.unzipNecessary(fileNames).then(function(results){
async.eachSeries(results, function(file, callback){
emitter.emit('showAlert', 'Processing file {}'.format(file.name));
this.processFile(file.path, callback);
}.bind(this),
function done(){
setTimeout(function(){
this.setState({uploading: false});
}.bind(this), 3000);
$.each(results, function(index, file){
if (file.delete){
fs.unlinkSync(file.path);
}
});
}.bind(this));
_aboutClick(){
emitter.emit('showAbout')
}
input.val('');
}.bind(this));
processFile(filename, fileobject, callback){
var sent = 0
}
var i;
var count = 0;
var header = ""
var procHeader = true;
fs.createReadStream(filename)
.on('data', function(chunk) {
for (i=0; i < chunk.length; ++i){
if (procHeader){
header = header + String.fromCharCode(chunk[i])
}
if (chunk[i] == 10){
if (procHeader){
procHeader = false;
}
count++
};
}
async unzipNecessary(files){
var index = 0;
var processed = [];
var tempPath = app.getPath('temp');
while (index < files.length){
var path = files[index].path;
var name = files[index].name;
})
.on('end', function() {
count = count - 1
var filetype;
if (header.includes('UserName') && header.includes('ComputerName') && header.includes('Weight')){
filetype = 'sessions'
}else if (header.includes('AccountName') && header.includes('AccountType') && header.includes('GroupName')){
filetype = 'groupmembership'
}else if (header.includes('AccountName') && header.includes('AccountType') && header.includes('ComputerName')){
filetype = 'localadmin'
}else if (header.includes('SourceDomain') && header.includes('TargetDomain') && header.includes('TrustDirection') && header.includes('TrustType') && header.includes('Transitive')){
filetype = 'domain'
}else if (header.includes('ActiveDirectoryRights') && header.includes('ObjectType') && header.includes('PrincipalType')){
filetype = 'acl'
}
if (path.endsWith(".zip")){
await fs.createReadStream(path)
.pipe(unzip.Parse())
.on('entry', function(entry){
var output = fpath.join(tempPath, entry.path);
entry.pipe(fs.createWriteStream(output));
processed.push({path:output, name:entry.path, delete: true});
}).promise();
}else{
processed.push({path:path,name:name, delete: false});
}
index++;
}
if (typeof filetype === 'undefined'){
emitter.emit('showAlert', 'Unrecognized CSV Type');
return;
}
return processed;
}
this.setState({
uploading: true,
progress: 0
})
//I have no idea why this workaround is needed. Apparently all my sessions freeze unless I make a random query
setTimeout(function(){
var sess = driver.session()
sess.run('MATCH (n) RETURN (n) LIMIT 1')
.then(function(){
sess.close()
})
}, 1000)
_aboutClick(){
emitter.emit('showAbout');
}
console.time('IngestTime')
Papa.parse(fileobject,{
header: true,
dynamicTyping: true,
skipEmptyLines: true,
chunkSize: 5242880,
//chunkSize: 500000,
chunk: function(rows, parser){
this.setState({parser: parser})
if (rows.data.length === 0){
console.timeEnd('IngestTime')
parser.abort()
this.setState({progress:100})
emitter.emit('refreshDBData')
callback()
return
}
parser.pause()
sent += rows.data.length
if (filetype === 'sessions'){
var query = 'UNWIND {props} AS prop MERGE (user:User {name:prop.account}) WITH user,prop MERGE (computer:Computer {name: prop.computer}) WITH user,computer,prop MERGE (computer)-[:HasSession {Weight : prop.weight}]-(user)'
var props = buildSessionProps(rows.data)
var session = driver.session()
session.run(query, {props: props})
.then(function(){
this.setState({progress: Math.floor((sent / count) * 100)})
session.close()
parser.resume()
}.bind(this))
}else if (filetype === 'groupmembership'){
var props = buildGroupMembershipProps(rows.data)
var userQuery = 'UNWIND {props} AS prop MERGE (user:User {name:prop.account}) WITH user,prop MERGE (group:Group {name:prop.group}) WITH user,group MERGE (user)-[:MemberOf]->(group)'
var computerQuery = 'UNWIND {props} AS prop MERGE (computer:Computer {name:prop.account}) WITH computer,prop MERGE (group:Group {name:prop.group}) WITH computer,group MERGE (computer)-[:MemberOf]->(group)'
var groupQuery = 'UNWIND {props} AS prop MERGE (group1:Group {name:prop.account}) WITH group1,prop MERGE (group2:Group {name:prop.group}) WITH group1,group2 MERGE (group1)-[:MemberOf]->(group2)'
processFile(file, callback){
console.log(file);
var count = 0;
var header = "";
var processHeader = true;
var fileType;
var session = driver.session()
var tx = session.beginTransaction()
var promises = []
//Lets calculate the number of lines in the file and get the header
var input = fs.createReadStream(file);
input.on('data', function (chunk){
for (var i=0; i < chunk.length; ++i){
if (processHeader){
header = header + String.fromCharCode(chunk[i]);
}
if (chunk[i] === 10){
//At the first newline, we look at the header to figure out
if (processHeader){
processHeader = false;
fileType = findObjectType(header);
if (fileType === 'unknown'){
emitter.emit('showAlert', 'Unrecognized CSV Type');
input.close();
}
}
count++;
}
}
})
.on('end', function(){
//We've got our line count for progress
var chunk = [];
var localCount = 0;
var sent = 0;
promises.push(tx.run(userQuery, {props: props.users}))
promises.push(tx.run(computerQuery, {props: props.computers}))
promises.push(tx.run(groupQuery, {props: props.groups}))
//Subtract one line to account for the header
count--;
Promise.all(promises)
.then(function(){
tx.commit()
.then(function(){
session.close()
this.setState({progress: Math.floor((sent / count) * 100)})
parser.resume()
}.bind(this))
}.bind(this))
}else if (filetype === 'localadmin'){
var props = buildLocalAdminProps(rows.data)
var userQuery = 'UNWIND {props} AS prop MERGE (user:User {name: prop.account}) WITH user,prop MERGE (computer:Computer {name: prop.computer}) WITH user,computer MERGE (user)-[:AdminTo]->(computer)'
var groupQuery = 'UNWIND {props} AS prop MERGE (group:Group {name: prop.account}) WITH group,prop MERGE (computer:Computer {name: prop.computer}) WITH group,computer MERGE (group)-[:AdminTo]->(computer)'
var computerQuery = 'UNWIND {props} AS prop MERGE (computer1:Computer {name: prop.account}) WITH computer1,prop MERGE (computer2:Computer {name: prop.computer}) WITH computer1,computer2 MERGE (computer1)-[:AdminTo]->(computer2)'
//Change the UI to display our uploading state
this.setState({
uploading: true,
progress: 0
});
var session = driver.session()
var tx = session.beginTransaction()
var promises = []
//Start a timer
console.time('IngestTime');
promises.push(tx.run(userQuery, {props: props.users}))
promises.push(tx.run(computerQuery, {props: props.computers}))
promises.push(tx.run(groupQuery, {props: props.groups}))
//Start parsing the file
var parser = csv.fromStream(fs.createReadStream(file),
{
headers: true,
ignoreEmpty: true
})
.on('data', function(data){
//On each row, push it into an array and increment a counter
chunk.push(data);
localCount++;
Promise.all(promises)
.then(function(){
tx.commit()
.then(function(){
session.close()
this.setState({progress: Math.floor((sent / count) * 100)})
parser.resume()
}.bind(this))
}.bind(this))
}else if (filetype === 'domain'){
var props = buildDomainProps(rows.data)
var query = "UNWIND {props} AS prop MERGE (domain1:Domain {name: prop.domain1}) WITH domain1,prop MERGE (domain2:Domain {name: prop.domain2}) WITH domain1,domain2,prop MERGE (domain1)-[:TrustedBy {TrustType : prop.trusttype, Transitive: prop.transitive}]->(domain2)"
var session = driver.session()
session.run(query, {props: props})
.then(function(){
this.setState({progress: Math.floor((sent / count) * 100)})
session.close()
parser.resume()
}.bind(this))
}else if (filetype === 'acl'){
var data = buildACLProps(rows.data)
var promises = []
var session = driver.session()
var tx = session.beginTransaction()
for (var key in data){
var promise = tx.run(data[key].statement, {props: data[key].props})
promises.push(promise)
}
//If we've collected 10k rows, push it all to the DB.
if (localCount % 10000 === 0){
//Pause the parser until upload is complete
parser.pause();
this.uploadData(chunk, fileType, count)
.then(function(){
//Update the sent number, and resume the parser
sent += chunk.length;
this.setState({progress: Math.floor(sent / count * 100)});
Promise.all(promises)
.then(function(){
tx.commit()
.then(function(){
this.setState({progress: Math.floor((sent / count) * 100)})
session.close()
parser.resume()
}.bind(this))
}.bind(this))
}
}.bind(this)
})
}.bind(this));
}
chunk = [];
parser.resume();
}.bind(this));
}
}.bind(this))
.on('end', function(){
//Upload any remaining data
this.uploadData(chunk, fileType, count)
.then(function(){
//Set the uploading state to 100%, refresh the db display, and move on to the next file if there is one
this.setState({progress:100});
emitter.emit('refreshDBData');
console.timeEnd('IngestTime');
callback();
}.bind(this));
}.bind(this));
}.bind(this));
}
render() {
return (
<div className="menudiv">
<div>
<MenuButton click={this._refreshClick.bind(this)} hoverVal="Refresh" glyphicon="glyphicon glyphicon-refresh" />
</div>
<div>
<MenuButton click={this._exportClick.bind(this)} hoverVal="Export Graph" glyphicon="glyphicon glyphicon-export" />
</div>
<div>
<MenuButton click={this._importClick.bind(this)} hoverVal="Import Graph" glyphicon="glyphicon glyphicon-import" />
</div>
<div>
<If condition={this.state.uploading}>
<Then>
<ProgressBarMenuButton click={this._cancelUploadClick.bind(this)} progress={this.state.progress} committed={this.state.committed}/>
</Then>
<Else>{ () =>
<MenuButton click={function(){jQuery(this.refs.fileInput).click()}.bind(this)} hoverVal="Upload Data" glyphicon="glyphicon glyphicon-upload" />
}</Else>
</If>
</div>
<div>
<MenuButton click={this._changeLayoutClick.bind(this)} hoverVal="Change Layout Type" glyphicon="fa fa-line-chart" />
</div>
<div>
<MenuButton click={this._settingsClick.bind(this)} hoverVal="Settings" glyphicon="fa fa-cogs" />
</div>
<div>
<MenuButton click={this._aboutClick.bind(this)} hoverVal="About" glyphicon="fa fa-info" />
</div>
<input ref="fileInput" multiple className="hide" type="file" onChange={this._uploadClick.bind(this)}/>
</div>
);
}
async uploadData(currentChunk, filetype, total){
var index = 0;
var processed;
var sent = 0;
var session = driver.session();
if (filetype === 'groupmembership'){
var userQuery = 'UNWIND {props} AS prop MERGE (user:User {name:prop.account}) WITH user,prop MERGE (group:Group {name:prop.group}) WITH user,group MERGE (user)-[:MemberOf {isACL:false}]->(group)';
var computerQuery = 'UNWIND {props} AS prop MERGE (computer:Computer {name:prop.account}) WITH computer,prop MERGE (group:Group {name:prop.group}) WITH computer,group MERGE (computer)-[:MemberOf {isACL:false}]->(group)';
var groupQuery = 'UNWIND {props} AS prop MERGE (group1:Group {name:prop.account}) WITH group1,prop MERGE (group2:Group {name:prop.group}) WITH group1,group2 MERGE (group1)-[:MemberOf {isACL:false}]->(group2)';
processed = buildGroupMembershipProps(currentChunk);
await session.run(userQuery, {props: processed.users});
await session.run(computerQuery, {props: processed.computers});
await session.run(groupQuery, {props: processed.groups});
}else if (filetype === 'localadmin'){
userQuery = 'UNWIND {props} AS prop MERGE (user:User {name: prop.account}) WITH user,prop MERGE (computer:Computer {name: prop.computer}) WITH user,computer MERGE (user)-[:AdminTo {isACL:false}]->(computer)';
groupQuery = 'UNWIND {props} AS prop MERGE (group:Group {name: prop.account}) WITH group,prop MERGE (computer:Computer {name: prop.computer}) WITH group,computer MERGE (group)-[:AdminTo {isACL:false}]->(computer)';
computerQuery = 'UNWIND {props} AS prop MERGE (computer1:Computer {name: prop.account}) WITH computer1,prop MERGE (computer2:Computer {name: prop.computer}) WITH computer1,computer2 MERGE (computer1)-[:AdminTo {isACL:false}]->(computer2)';
processed = buildLocalAdminProps(currentChunk);
await session.run(userQuery, {props: processed.users});
await session.run(computerQuery, {props: processed.computers});
await session.run(groupQuery, {props: processed.groups});
}else if (filetype === 'sessions'){
var query = 'UNWIND {props} AS prop MERGE (user:User {name:prop.account}) WITH user,prop MERGE (computer:Computer {name: prop.computer}) WITH user,computer,prop MERGE (computer)-[:HasSession {Weight : prop.weight, isACL: false}]-(user)';
processed = buildSessionProps(currentChunk);
await session.run(query, {props: processed});
}else if (filetype === 'domain'){
query = "UNWIND {props} AS prop MERGE (domain1:Domain {name: prop.domain1}) WITH domain1,prop MERGE (domain2:Domain {name: prop.domain2}) WITH domain1,domain2,prop MERGE (domain1)-[:TrustedBy {TrustType : prop.trusttype, Transitive: toBoolean(prop.transitive), isACL:false}]->(domain2)";
processed = buildDomainProps(currentChunk);
await session.run(query, {props: processed});
}else if (filetype === 'acl'){
processed = buildACLProps(currentChunk);
for (var key in processed){
await session.run(processed[key].statement, {props: processed[key].props});
}
}else if (filetype === 'userprops'){
$.each(currentChunk, function(index, obj){
var spn = obj.ServicePrincipalNames;
var sh = obj.SidHistory;
if (spn === ""){
obj.ServicePrincipalNames = [];
}else{
obj.ServicePrincipalNames = spn.split('|');
}
});
query = 'UNWIND {props} AS prop MERGE (user:User {name: upper(prop.AccountName)}) SET user.Enabled = toBoolean(prop.Enabled),user.PwdLastSet = toInt(prop.PwdLastSet),user.LastLogon = toInt(prop.LastLogon),user.Sid = prop.Sid,user.SidHistory = prop.SidHistory,user.HasSPN = toBoolean(prop.HasSPN),user.DisplayName=prop.DisplayName,user.ServicePrincipalNames = prop.ServicePrincipalNames,user.Email=prop.Email';
await session.run(query, {props:currentChunk});
}else if (filetype === 'compprops'){
query = 'UNWIND {props} AS prop MERGE (comp:Computer {name: upper(prop.AccountName)}) SET comp.Enabled=toBoolean(prop.Enabled),comp.PwdLastSet=toInt(prop.PwdLastSet),comp.LastLogon=toInt(prop.LastLogon),comp.OperatingSystem=prop.OperatingSystem,comp.Sid=prop.Sid,comp.UnconstrainedDelegation=toBoolean(prop.UnconstrainedDelegation)';
await session.run(query, {props:currentChunk});
}
}
render() {
return (
<div className="menudiv">
<div>
<MenuButton click={this._refreshClick.bind(this)} hoverVal="Refresh" glyphicon="glyphicon glyphicon-refresh" />
</div>
<div>
<MenuButton click={this._exportClick.bind(this)} hoverVal="Export Graph" glyphicon="glyphicon glyphicon-export" />
</div>
<div>
<MenuButton click={this._importClick.bind(this)} hoverVal="Import Graph" glyphicon="glyphicon glyphicon-import" />
</div>
<div>
<If condition={this.state.uploading}>
<Then>
<ProgressBarMenuButton click={this._cancelUploadClick.bind(this)} progress={this.state.progress} committed={this.state.committed}/>
</Then>
<Else>{ () =>
<MenuButton click={function(){jQuery(this.refs.fileInput).click()}.bind(this)} hoverVal="Upload Data" glyphicon="glyphicon glyphicon-upload" />
}</Else>
</If>
</div>
<div>
<MenuButton click={this._changeLayoutClick.bind(this)} hoverVal="Change Layout Type" glyphicon="fa fa-line-chart" />
</div>
<div>
<MenuButton click={this._settingsClick.bind(this)} hoverVal="Settings" glyphicon="fa fa-cogs" />
</div>
<div>
<MenuButton click={this._aboutClick.bind(this)} hoverVal="About" glyphicon="fa fa-info" />
</div>
<input ref="fileInput" multiple className="hide" type="file" onChange={this._uploadClick.bind(this)}/>
</div>
);
}
}

View File

@ -1,80 +1,80 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types'
import PropTypes from 'prop-types';
export default class ProgressBarMenuButton extends Component {
constructor(){
super()
constructor(){
super();
this.state = {
expanded: false
}
}
this.state = {
expanded: false
};
}
_leave(e){
this.setState({expanded: false})
var target = $(e.target)
var oldWidth = target.width()
target.html('{}%'.format(this.props.progress))
target.animate({
width: '41px'
}, 100)
}
componentDidMount(){
$(this.refs.btn).html('{}%'.format(this.props.progress));
$(this.refs.btn).css('padding','6px 0px 6px 0px');
$(this.refs.btn).css('width','41px');
}
_enter(e){
this.setState({expanded: true})
var target = $(e.target)
var oldWidth = target.width()
var template = `
<div class="progress" style="margin-bottom:0px">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-value-now={} aria-value-max="100" style="width:{}%">
</div>
<span>
{}%
</span>
</div>
`.formatAll(this.props.progress)
componentWillReceiveProps(nextProps){
if (this.state.expanded){
var template = `<div class="progress" style="margin-bottom:0px">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-value-now={} aria-value-max="100" style="width:{}%">
</div>
<span>
{}%
</span>
</div>`.formatAll(nextProps.progress);
$(this.refs.btn).html(template);
}else{
$(this.refs.btn).html('{}%'.format(nextProps.progress));
}
target.html(template)
target.animate({
width: '150px'
}, 100)
}
this.forceUpdate();
}
componentWillReceiveProps(nextProps){
if (this.state.expanded){
var template = `<div class="progress" style="margin-bottom:0px">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-value-now={} aria-value-max="100" style="width:{}%">
</div>
<span>
{}%
</span>
</div>`.formatAll(nextProps.progress)
$(this.refs.btn).html(template)
}else{
$(this.refs.btn).html('{}%'.format(nextProps.progress))
}
shouldComponentUpdate(nextProps, nextState){
return true;
}
this.forceUpdate()
}
_leave(e){
this.setState({expanded: false});
var target = $(e.target);
var oldWidth = target.width();
target.html('{}%'.format(this.props.progress));
target.animate({
width: '41px'
}, 100);
}
shouldComponentUpdate(nextProps, nextState){
return true
}
_enter(e){
this.setState({expanded: true});
var target = $(e.target);
var oldWidth = target.width();
var template = `
<div class="progress" style="margin-bottom:0px">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-value-now={} aria-value-max="100" style="width:{}%">
</div>
<span>
{}%
</span>
</div>
`.formatAll(this.props.progress);
componentDidMount(){
$(this.refs.btn).html('{}%'.format(this.props.progress))
$(this.refs.btn).css('padding','6px 0px 6px 0px')
$(this.refs.btn).css('width','41px')
}
target.html(template);
target.animate({
width: '150px'
}, 100);
}
render() {
return (
<button ref="btn" onClick={this.props.click} onMouseLeave={this._leave.bind(this)} onMouseEnter={this._enter.bind(this)} className="btn" />
);
}
render() {
return (
<button ref="btn" onClick={this.props.click} onMouseLeave={this._leave.bind(this)} onMouseEnter={this._enter.bind(this)} className="btn" />
);
}
}
ProgressBarMenuButton.propTypes = {
progress : React.PropTypes.number.isRequired,
click : React.PropTypes.func.isRequired
}
progress : React.PropTypes.number.isRequired,
click : React.PropTypes.func.isRequired
};

View File

@ -1,86 +1,86 @@
import React, { Component } from 'react';
import GlyphiconSpan from '../GlyphiconSpan'
import Icon from '../Icon'
import TabContainer from './TabContainer'
import GlyphiconSpan from '../GlyphiconSpan';
import Icon from '../Icon';
import TabContainer from './TabContainer';
export default class SearchContainer extends Component {
constructor(props){
super(props)
super(props);
this.state = {
mainPlaceholder:"Start typing to search for a node...",
pathfindingIsOpen: false,
mainValue: "",
pathfindValue: ""
}
};
}
_onPathfindClick(){
jQuery(this.refs.pathfinding).slideToggle()
var p = !this.state.pathfindingIsOpen
var t = this.state.pathfindingIsOpen ? "Start typing to search for a node..." : "Start Node"
jQuery(this.refs.pathfinding).slideToggle();
var p = !this.state.pathfindingIsOpen;
var t = this.state.pathfindingIsOpen ? "Start typing to search for a node..." : "Start Node";
this.setState({
pathfindingIsOpen: p,
mainPlaceholder: t
})
});
}
_onPlayClick(){
var start = jQuery(this.refs.searchbar).val()
var end = jQuery(this.refs.pathbar).val()
var start = jQuery(this.refs.searchbar).val();
var end = jQuery(this.refs.pathbar).val();
if (start !== "" && end !== ""){
emitter.emit('pathQuery', start, end)
emitter.emit('pathQuery', start, end);
}
}
_onExpandClick(){
jQuery(this.refs.tabs).slideToggle()
jQuery(this.refs.tabs).slideToggle();
}
openNodeTab(){
var e = jQuery(this.refs.tabs)
var e = jQuery(this.refs.tabs);
if (!(e.is(":visible"))){
e.slideToggle()
e.slideToggle();
}
}
componentDidMount() {
jQuery(this.refs.pathfinding).slideToggle(0);
jQuery(this.refs.tabs).slideToggle(0);
emitter.on('userNodeClicked', this.openNodeTab.bind(this))
emitter.on('groupNodeClicked', this.openNodeTab.bind(this))
emitter.on('computerNodeClicked', this.openNodeTab.bind(this))
emitter.on('domainNodeClicked', this.openNodeTab.bind(this))
emitter.on('userNodeClicked', this.openNodeTab.bind(this));
emitter.on('groupNodeClicked', this.openNodeTab.bind(this));
emitter.on('computerNodeClicked', this.openNodeTab.bind(this));
emitter.on('domainNodeClicked', this.openNodeTab.bind(this));
emitter.on('setStart', function(payload){
jQuery(this.refs.searchbar).val(payload);
}.bind(this))
}.bind(this));
emitter.on('setEnd', function(payload){
jQuery(this.refs.pathbar).val(payload);
var e = jQuery(this.refs.pathfinding)
var e = jQuery(this.refs.pathfinding);
if (!(e.is(":visible"))){
e.slideToggle()
e.slideToggle();
}
}.bind(this))
}.bind(this));
jQuery(this.refs.searchbar).typeahead({
source: function(query, process) {
var session = driver.session()
var t = '(?i).*' + query + '.*'
var data = []
var session = driver.session();
var t = '(?i).*' + query + '.*';
var data = [];
session.run("MATCH (n) WHERE n.name =~ {name} RETURN n LIMIT 10", {name:t})
.then(function(results){
$.each(results.records, function(index, record){
data.push(record._fields[0].properties.name + "#" + record._fields[0].labels[0])
})
session.close()
return process(data)
})
data.push(record._fields[0].properties.name + "#" + record._fields[0].labels[0]);
});
session.close();
return process(data);
});
},
afterSelect: function(selected) {
if (!this.state.pathfindingIsOpen) {
var statement = "MATCH (n) WHERE n.name = {name} RETURN n"
emitter.emit('searchQuery', statement, {name: selected.split("#")[0]})
var statement = "MATCH (n) WHERE n.name = {name} RETURN n";
emitter.emit('searchQuery', statement, {name: selected.split("#")[0]});
} else {
var start = jQuery(this.refs.searchbar).val();
var end = jQuery(this.refs.pathbar).val();
@ -91,57 +91,57 @@ export default class SearchContainer extends Component {
}.bind(this),
autoSelect: false,
updater: function(item){
return item.split("#")[0]
return item.split("#")[0];
},
highlighter: function(item) {
var parts = item.split("#")
var parts = item.split("#");
var query = this.query;
var icon = "";
var html = ""
var html = "";
switch (parts[1]){
case "Group":
icon = "<i style=\"float:right\" class=\"fa fa-users\"></i>"
icon = "<i style=\"float:right\" class=\"fa fa-users\"></i>";
break;
case "User":
icon = "<i style=\"float:right\" class=\"fa fa-user\"></i>"
icon = "<i style=\"float:right\" class=\"fa fa-user\"></i>";
break;
case "Computer":
icon = "<i style=\"float:right\" class=\"fa fa-desktop\"></i>"
icon = "<i style=\"float:right\" class=\"fa fa-desktop\"></i>";
break;
case "Domain":
icon = "<i style=\"float:right\" class=\"fa fa-globe\"></i>"
break
icon = "<i style=\"float:right\" class=\"fa fa-globe\"></i>";
break;
}
html = '<div>' + parts[0] + ' ' + icon + '</div>'
html = '<div>' + parts[0] + ' ' + icon + '</div>';
var reEscQuery = query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
var reQuery = new RegExp('(' + reEscQuery + ')', "gi");
var jElem = $(html)
var jElem = $(html);
var textNodes = $(jElem.find('*')).add(jElem).contents().filter(function () { return this.nodeType === 3; });
textNodes.replaceWith(function() {
return $(this).text().replace(reQuery, '<strong>$1</strong>')
return $(this).text().replace(reQuery, '<strong>$1</strong>');
});
return jElem.html();
}
}
)
);
jQuery(this.refs.pathbar).typeahead({
source: function(query, process) {
var session = driver.session()
var t = '(?i).*' + query + '.*'
var data = []
var session = driver.session();
var t = '(?i).*' + query + '.*';
var data = [];
session.run("MATCH (n) WHERE n.name =~ {name} RETURN n LIMIT 10", {name:t})
.then(function(results){
$.each(results.records, function(index, record){
data.push(record._fields[0].properties.name + "#" + record._fields[0].labels[0])
})
session.close()
return process(data)
})
data.push(record._fields[0].properties.name + "#" + record._fields[0].labels[0]);
});
session.close();
return process(data);
});
},
afterSelect: function(selected) {
var start = jQuery(this.refs.searchbar).val();
@ -152,47 +152,47 @@ export default class SearchContainer extends Component {
}.bind(this),
autoSelect: false,
updater: function(item){
return item.split("#")[0]
return item.split("#")[0];
},
highlighter: function(item) {
var parts = item.split("#")
var parts = item.split("#");
var query = this.query;
var icon = "";
var html = ""
var html = "";
switch (parts[1]){
case "Group":
icon = "<i style=\"float:right\" class=\"fa fa-users\"></i>"
icon = "<i class=\"fa fa-users\"></i>";
break;
case "User":
icon = "<i style=\"float:right\" class=\"fa fa-user\"></i>"
icon = "<i class=\"fa fa-user\"></i>";
break;
case "Computer":
icon = "<i style=\"float:right\" class=\"fa fa-desktop\"></i>"
icon = "<i class=\"fa fa-desktop\"></i>";
break;
case "Domain":
icon = "<i style=\"float:right\" class=\"fa fa-globe\"></i>"
break
icon = "<i class=\"fa fa-globe\"></i>";
break;
}
html = '<div>' + parts[0] + ' ' + icon + '</div>'
html = '<div>' + parts[0] + ' ' + icon + '</div>';
var reEscQuery = query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
var reQuery = new RegExp('(' + reEscQuery + ')', "gi");
var jElem = $(html)
var jElem = $(html);
var textNodes = $(jElem.find('*')).add(jElem).contents().filter(function () { return this.nodeType === 3; });
textNodes.replaceWith(function() {
return $(this).text().replace(reQuery, '<strong>$1</strong>')
return $(this).text().replace(reQuery, '<strong>$1</strong>');
});
return jElem.html();
}
}
)
);
}
_inputKeyPress(e){
var key = e.keyCode ? e.keyCode : e.which
var key = e.keyCode ? e.keyCode : e.which;
var start = jQuery(this.refs.searchbar).val();
var end = jQuery(this.refs.pathbar).val();
var stop = false;
@ -201,17 +201,17 @@ export default class SearchContainer extends Component {
if (!$('.searchSelectorS > ul').is(':hidden')){
$('.searchSelectorS > ul li').each(function(i){
if($(this).hasClass('active')){
stop = true
stop = true;
}
})
});
}
if (!$('.searchSelectorP > ul').is(':hidden')){
$('.searchSelectorP > ul li').each(function(i){
if($(this).hasClass('active')){
stop = true
stop = true;
}
})
});
}
if (stop){
return;
@ -219,8 +219,8 @@ export default class SearchContainer extends Component {
if (!this.state.pathfindingIsOpen) {
if (start !== ""){
var statement = "MATCH (n) WHERE n.name =~ {regex} RETURN n";
var regex = '(?i).*' + start + '.*'
emitter.emit('searchQuery', statement, {regex:regex})
var regex = '(?i).*' + start + '.*';
emitter.emit('searchQuery', statement, {regex:regex});
}
} else {
var start = jQuery(this.refs.searchbar).val();
@ -257,7 +257,7 @@ export default class SearchContainer extends Component {
tooltipTitle="Back"
classes="input-group-addon spanfix"
click={function(){
emitter.emit('graphBack')
emitter.emit('graphBack');
}}>
<Icon glyph="step-backward" extraClass="menuglyph" />
</GlyphiconSpan>
@ -289,6 +289,6 @@ export default class SearchContainer extends Component {
<TabContainer />
</div>
</div>
)
);
}
}

View File

@ -1,344 +1,386 @@
import React, { Component } from 'react';
import NodeALink from './NodeALink'
import PropTypes from 'prop-types'
import NodeALink from './NodeALink';
import PropTypes from 'prop-types';
export default class ComputerNodeData extends Component {
constructor(){
super();
constructor(){
super();
this.state = {
label: "",
os: "None",
unconstrained: "None",
explicitAdmins: -1,
unrolledAdmins: -1,
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
firstDegreeLocalAdmin: -1,
groupDelegatedLocalAdmin: -1,
derivativeLocalAdmin: -1,
sessions: -1,
firstdegreeControl: -1,
groupDelegatedControl: -1,
transitiveControl: -1,
derivativeLocalAdmins: -1,
driversessions: []
}
this.state = {
label: "",
explicitAdmins: -1,
unrolledAdmins: -1,
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
firstDegreeLocalAdmin: -1,
groupDelegatedLocalAdmin: -1,
derivativeLocalAdmin: -1,
sessions: -1,
firstdegreeControl: -1,
groupDelegatedControl: -1,
transitiveControl: -1,
derivativeLocalAdmins: -1,
driversessions: [],
propertyMap: {}
};
emitter.on('computerNodeClicked', this.getNodeData.bind(this));
}
emitter.on('computerNodeClicked', this.getNodeData.bind(this));
}
getNodeData(payload){
$.each(this.state.driversessions, function(index, record){
record.close();
})
this.setState({
label: payload,
os: "None",
unconstrained: "None",
explicitAdmins: -1,
unrolledAdmins: -1,
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
sessions: -1,
firstDegreeLocalAdmin: -1,
groupDelegatedLocalAdmin: -1,
derivativeLocalAdmin: -1,
firstdegreeControl: -1,
groupDelegatedControl: -1,
transitiveControl: -1,
derivativeLocalAdmins: -1
})
getNodeData(payload){
$.each(this.state.driversessions, function(index, record){
record.close();
});
this.setState({
label: payload,
explicitAdmins: -1,
unrolledAdmins: -1,
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
sessions: -1,
firstDegreeLocalAdmin: -1,
groupDelegatedLocalAdmin: -1,
derivativeLocalAdmin: -1,
firstdegreeControl: -1,
groupDelegatedControl: -1,
transitiveControl: -1,
derivativeLocalAdmins: -1,
propertyMap: {}
});
var s1 = driver.session()
var s2 = driver.session()
var s3 = driver.session()
var s4 = driver.session()
var s5 = driver.session()
var s6 = driver.session()
var s7 = driver.session()
var s8 = driver.session()
var s9 = driver.session()
var s10 = driver.session()
var s11 = driver.session()
var s12 = driver.session()
var s13 = driver.session()
var s1 = driver.session();
var s2 = driver.session();
var s3 = driver.session();
var s4 = driver.session();
var s5 = driver.session();
var s6 = driver.session();
var s7 = driver.session();
var s8 = driver.session();
var s9 = driver.session();
var s10 = driver.session();
var s11 = driver.session();
var s12 = driver.session();
var s13 = driver.session();
s1.run("MATCH (a)-[b:AdminTo]->(c:Computer {name:{name}}) RETURN count(a)", {name:payload})
.then(function(result){
this.setState({'explicitAdmins':result.records[0]._fields[0].low})
s1.close()
}.bind(this))
var propCollection = driver.session();
propCollection.run("MATCH (c:Computer {name:{name}}) RETURN c", {name:payload})
.then(function(result){
var properties = result.records[0]._fields[0].properties;
this.setState({propertyMap: properties});
propCollection.close();
}.bind(this));
s2.run("MATCH p=(n:User)-[r:MemberOf|AdminTo*1..]->(m:Computer {name:{name}}) RETURN count(distinct(n))", {name:payload})
.then(function(result){
this.setState({'unrolledAdmins':result.records[0]._fields[0].low})
s2.close()
}.bind(this))
s1.run("MATCH (a)-[b:AdminTo]->(c:Computer {name:{name}}) RETURN count(a)", {name:payload})
.then(function(result){
this.setState({'explicitAdmins':result.records[0]._fields[0].low});
s1.close();
}.bind(this));
s3.run("MATCH (m:Computer {name:{name}}), (n:Computer), (m)-[r:AdminTo]->(n) RETURN count(distinct(m))", {name:payload})
.then(function(result){
this.setState({'firstDegreeLocalAdmin':result.records[0]._fields[0].low})
s3.close()
}.bind(this))
s2.run("MATCH p=(n:User)-[r:MemberOf|AdminTo*1..]->(m:Computer {name:{name}}) RETURN count(distinct(n))", {name:payload})
.then(function(result){
this.setState({'unrolledAdmins':result.records[0]._fields[0].low});
s2.close();
}.bind(this));
s4.run("MATCH p=(n:Computer {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(c2:Computer) RETURN count(c2)", {name:payload})
.then(function(result){
this.setState({'groupDelegatedLocalAdmin':result.records[0]._fields[0].low})
s4.close()
}.bind(this))
s3.run("MATCH (m:Computer {name:{name}}), (n:Computer), (m)-[r:AdminTo]->(n) RETURN count(distinct(m))", {name:payload})
.then(function(result){
this.setState({'firstDegreeLocalAdmin':result.records[0]._fields[0].low});
s3.close();
}.bind(this));
s5.run("MATCH (n:Computer {name:{name}}), (m:Computer), p=shortestPath((n)-[r:AdminTo|MemberOf*1..]->(m)) RETURN count(distinct(m))", {name:payload})
.then(function(result){
this.setState({'derivativeLocalAdmin':result.records[0]._fields[0].low})
s5.close()
}.bind(this))
s4.run("MATCH p=(n:Computer {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(c2:Computer) RETURN count(c2)", {name:payload})
.then(function(result){
this.setState({'groupDelegatedLocalAdmin':result.records[0]._fields[0].low});
s4.close();
}.bind(this));
s6.run("MATCH (n:Computer {name:{name}}),(target:Group), (n)-[r:MemberOf]->(target) RETURN count(target)", {name:payload})
.then(function(result){
this.setState({'firstDegreeGroupMembership':result.records[0]._fields[0].low})
s6.close()
}.bind(this))
s5.run("MATCH (n:Computer {name:{name}}), (m:Computer) WHERE NOT m.name={name} MATCH p=shortestPath((n)-[r:AdminTo|MemberOf*1..]->(m)) RETURN count(distinct(m))", {name:payload})
.then(function(result){
this.setState({'derivativeLocalAdmin':result.records[0]._fields[0].low});
s5.close();
}.bind(this));
s7.run("MATCH p = (c:Computer {name:{name}})-[r:MemberOf*1..]->(g:Group) RETURN COUNT(DISTINCT(g))", {name:payload})
.then(function(result){
this.setState({'unrolledGroupMembership':result.records[0]._fields[0].low})
s7.close()
}.bind(this))
s6.run("MATCH (n:Computer {name:{name}}),(target:Group), (n)-[r:MemberOf]->(target) RETURN count(target)", {name:payload})
.then(function(result){
this.setState({'firstDegreeGroupMembership':result.records[0]._fields[0].low});
s6.close();
}.bind(this));
s8.run("MATCH (m:Computer {name:{name}})-[r:HasSession]->(n:User) WITH n,r,m WHERE NOT n.name ENDS WITH '$' RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'sessions':result.records[0]._fields[0].low})
s8.close()
}.bind(this))
s7.run("MATCH p = (c:Computer {name:{name}})-[r:MemberOf*1..]->(g:Group) RETURN COUNT(DISTINCT(g))", {name:payload})
.then(function(result){
this.setState({'unrolledGroupMembership':result.records[0]._fields[0].low});
s7.close();
}.bind(this));
s9.run("MATCH p = shortestPath((n)-[r:AdminTo|MemberOf|HasSession*1..]->(m:Computer {name:{name}})) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'derivativeLocalAdmins':result.records[0]._fields[0].low})
s9.close()
}.bind(this))
s8.run("MATCH (m:Computer {name:{name}})-[r:HasSession]->(n:User) WITH n,r,m WHERE NOT n.name ENDS WITH '$' RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'sessions':result.records[0]._fields[0].low});
s8.close();
}.bind(this));
s10.run("MATCH p = (c:Computer {name:{name}})-[r:MemberOf*1..]->(g:Group) WHERE NOT g.domain = c.domain RETURN COUNT(DISTINCT(g))", {name:payload})
.then(function(result){
this.setState({'foreignGroupMembership':result.records[0]._fields[0].low})
s10.close()
}.bind(this))
s9.run("MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((n)-[r:AdminTo|MemberOf|HasSession*1..]->(m:Computer {name:{name}})) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'derivativeLocalAdmins':result.records[0]._fields[0].low});
s9.close();
}.bind(this));
s11.run("MATCH p = (c:Computer {name:{name}})-[r:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstdegreeControl':result.records[0]._fields[0].low})
s11.close()
}.bind(this))
s10.run("MATCH p = (c:Computer {name:{name}})-[r:MemberOf*1..]->(g:Group) WHERE NOT g.domain = c.domain RETURN COUNT(DISTINCT(g))", {name:payload})
.then(function(result){
this.setState({'foreignGroupMembership':result.records[0]._fields[0].low});
s10.close();
}.bind(this));
s12.run("MATCH p = (c:Computer {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'groupDelegatedControl':result.records[0]._fields[0].low})
s12.close()
}.bind(this))
s11.run("MATCH p = (c:Computer {name:{name}})-[r:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstdegreeControl':result.records[0]._fields[0].low});
s11.close();
}.bind(this));
s13.run("MATCH p = shortestPath((c:Computer {name:{name}})-[r:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'transitiveControl':result.records[0]._fields[0].low})
s13.close()
}.bind(this))
s12.run("MATCH p = (c:Computer {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'groupDelegatedControl':result.records[0]._fields[0].low});
s12.close();
}.bind(this));
this.setState({'driversessions': [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13]})
}
s13.run("MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((c:Computer {name:{name}})-[r:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'transitiveControl':result.records[0]._fields[0].low});
s13.close();
}.bind(this));
render() {
return (
<div className={this.props.visible ? "" : "displaynone"}>
<dl className='dl-horizontal'>
<h4>Node Info</h4>
<dt>
Name
</dt>
<dd>
{this.state.label}
</dd>
<dt>
OS
</dt>
<dd>
{this.state.os}
</dd>
<dt>
Allows Unconstrained Delegation
</dt>
<dd>
{this.state.unconstrained}
</dd>
<dt>
Sessions
</dt>
<dd>
<NodeALink
ready={this.state.sessions !== -1}
value={this.state.sessions}
click={function(){
emitter.emit('query',
"MATCH (m:Computer {name:{name}})-[r:HasSession]->(n:User) WITH n,r,m WHERE NOT n.name ENDS WITH '$' RETURN n,r,m", {name: this.state.label})
}.bind(this)} />
</dd>
<br />
<h4>Local Admins</h4>
<dt>
Explicit Admins
</dt>
<dd>
<NodeALink
ready={this.state.explicitAdmins !== -1}
value={this.state.explicitAdmins}
click={function(){
emitter.emit('query',
"MATCH (n)-[r:AdminTo]->(m:Computer {name:{name}}) RETURN n,r,m",{name: this.state.label})
}.bind(this)} />
</dd>
<dt>
Unrolled Admins
</dt>
<dd>
<NodeALink
ready={this.state.unrolledAdmins !== -1}
value={this.state.unrolledAdmins}
click={function(){
emitter.emit('query',
"MATCH p = (n:User)-[r:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(c:Computer {name:{name}}) RETURN p",
{name: this.state.label},
this.state.label)
}.bind(this)} />
</dd>
<dt>
Derivative Local Admins
</dt>
<dd>
<NodeALink
ready={this.state.derivativeLocalAdmins !== -1}
value={this.state.derivativeLocalAdmins}
click={function(){
emitter.emit('query',
"MATCH p = shortestPath((n)-[r:AdminTo|MemberOf|HasSession*1..]->(m:Computer {name:{name}})) RETURN p",{name: this.state.label}, this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>Group Memberships</h4>
<dt>
First Degree Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeGroupMembership !== -1}
value={this.state.firstDegreeGroupMembership}
click={function(){
emitter.emit('query',
"MATCH (n:Computer {name:{name}}),(m:Group), (n)-[r:MemberOf]->(m) RETURN n,r,m",{name: this.state.label}, this.state.label)
}.bind(this)} />
</dd>
<dt>
Unrolled Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.unrolledGroupMembership !== -1}
value={this.state.unrolledGroupMembership}
click={function(){
emitter.emit('query',
"MATCH p = (n:Computer {name:{name}})-[r:MemberOf*1..]->(m:Group) RETURN p",{name: this.state.label}, this.state.label)
}.bind(this)} />
</dd>
<dt>
Foreign Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroupMembership !== -1}
value={this.state.foreignGroupMembership}
click={function(){
emitter.emit('query',
"MATCH p = (c:Computer {name:{name}})-[r:MemberOf*1..]->(g:Group) WHERE NOT g.domain = c.domain RETURN p",{name: this.state.label}, this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>Local Admin Rights</h4>
<dt>
First Degree Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeLocalAdmin !== -1}
value={this.state.firstDegreeLocalAdmin}
click={function(){
emitter.emit('query',
"MATCH (n:Computer {name:{name}}), (m:Computer), p=(n)-[r:AdminTo]->(m) RETURN p",{name: this.state.label}, this.state.label)
}.bind(this)} />
</dd>
<dt>
Group Delegated Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedLocalAdmin !== -1}
value={this.state.groupDelegatedLocalAdmin}
click={function(){
emitter.emit('query',
"MATCH p=(n:Computer {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(m:Computer) RETURN p",{name: this.state.label}, this.state.label)
}.bind(this)} />
</dd>
<dt>
Derivative Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.derivativeLocalAdmin !== -1}
value={this.state.derivativeLocalAdmin}
click={function(){
emitter.emit('query',
"MATCH p = shortestPath((c1:Computer {name:{name}})-[r:AdminTo|MemberOf|HasSession*1..]->(c:Computer)) RETURN p",{name: this.state.label}, this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>Outbound Object Control</h4>
<dt>
First Degree Object Control
</dt>
<dd>
<NodeALink
ready={this.state.firstdegreeControl !== -1}
value={this.state.firstdegreeControl}
click={function(){
emitter.emit('query', "MATCH p = (c:Computer {name:{name}})-[r1:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label})
}.bind(this)} />
</dd>
<dt>
Group Delegated Object Control
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedControl !== -1}
value={this.state.groupDelegatedControl}
click={function(){
emitter.emit('query', "MATCH p = (c:Computer {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<dt>
Transitive Object Control
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControl !== -1}
value={this.state.transitiveControl}
click={function(){
emitter.emit('query', "MATCH p = shortestPath((c:Computer {name:{name}})-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
</dl>
</div>
);
}
this.setState({'driversessions': [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,propCollection]});
}
convertToDisplayProp(propName){
var obj = this.state.propertyMap[propName];
var type = typeof obj;
if (type === 'undefined'){
return "No Data";
}else if (obj.hasOwnProperty('low')){
var t = obj.low;
if (t === 0){
return "Never";
}else{
return new Date(obj.low * 1000).toUTCString();
}
}else if (type === 'boolean'){
return obj.toString().toTitleCase();
}else if (obj === ""){
return "None";
}else{
return obj;
}
}
render() {
return (
<div className={this.props.visible ? "" : "displaynone"}>
<dl className='dl-horizontal'>
<h4>Node Info</h4>
<dt>
Name
</dt>
<dd>
{this.state.label}
</dd>
<dt>
OS
</dt>
<dd>
{this.convertToDisplayProp("OperatingSystem")}
</dd>
<dt>
Enabled
</dt>
<dd>
{this.convertToDisplayProp("Enabled")}
</dd>
<dt>
Allows Unconstrained Delegation
</dt>
<dd>
{this.convertToDisplayProp("UnconstrainedDelegation")}
</dd>
<dt>
Sessions
</dt>
<dd>
<NodeALink
ready={this.state.sessions !== -1}
value={this.state.sessions}
click={function(){
emitter.emit('query',
"MATCH (m:Computer {name:{name}})-[r:HasSession]->(n:User) WITH n,r,m WHERE NOT n.name ENDS WITH '$' RETURN n,r,m", {name: this.state.label});
}.bind(this)}
/>
</dd>
<h4>Local Admins</h4>
<dt>
Explicit Admins
</dt>
<dd>
<NodeALink
ready={this.state.explicitAdmins !== -1}
value={this.state.explicitAdmins}
click={function(){
emitter.emit('query',
"MATCH (n)-[r:AdminTo]->(m:Computer {name:{name}}) RETURN n,r,m",{name: this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Unrolled Admins
</dt>
<dd>
<NodeALink
ready={this.state.unrolledAdmins !== -1}
value={this.state.unrolledAdmins}
click={function(){
emitter.emit('query',
"MATCH p = (n:User)-[r:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(c:Computer {name:{name}}) RETURN p",
{name: this.state.label},
this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Derivative Local Admins
</dt>
<dd>
<NodeALink
ready={this.state.derivativeLocalAdmins !== -1}
value={this.state.derivativeLocalAdmins}
click={function(){
emitter.emit('query',
"MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((n)-[r:AdminTo|MemberOf|HasSession*1..]->(m:Computer {name:{name}})) RETURN p",{name: this.state.label}, this.state.label);
}.bind(this)}
/>
</dd>
<h4>Group Memberships</h4>
<dt>
First Degree Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeGroupMembership !== -1}
value={this.state.firstDegreeGroupMembership}
click={function(){
emitter.emit('query',
"MATCH (n:Computer {name:{name}}),(m:Group), (n)-[r:MemberOf]->(m) RETURN n,r,m",{name: this.state.label}, this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Unrolled Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.unrolledGroupMembership !== -1}
value={this.state.unrolledGroupMembership}
click={function(){
emitter.emit('query',
"MATCH p = (n:Computer {name:{name}})-[r:MemberOf*1..]->(m:Group) RETURN p",{name: this.state.label}, this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Foreign Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroupMembership !== -1}
value={this.state.foreignGroupMembership}
click={function(){
emitter.emit('query',
"MATCH p = (c:Computer {name:{name}})-[r:MemberOf*1..]->(g:Group) WHERE NOT g.domain = c.domain RETURN p",{name: this.state.label}, this.state.label);
}.bind(this)}
/>
</dd>
<h4>Local Admin Rights</h4>
<dt>
First Degree Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeLocalAdmin !== -1}
value={this.state.firstDegreeLocalAdmin}
click={function(){
emitter.emit('query',
"MATCH (n:Computer {name:{name}}), (m:Computer), p=(n)-[r:AdminTo]->(m) RETURN p",{name: this.state.label}, this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Group Delegated Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedLocalAdmin !== -1}
value={this.state.groupDelegatedLocalAdmin}
click={function(){
emitter.emit('query',
"MATCH p=(n:Computer {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(m:Computer) RETURN p",{name: this.state.label}, this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Derivative Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.derivativeLocalAdmin !== -1}
value={this.state.derivativeLocalAdmin}
click={function(){
emitter.emit('query',
"MATCH (c:Computer) WHERE NOT c.name={name} WITH c MATCH p = shortestPath((c1:Computer {name:{name}})-[r:AdminTo|MemberOf|HasSession*1..]->(c)) RETURN p",{name: this.state.label}, this.state.label);
}.bind(this)}
/>
</dd>
<h4>Outbound Object Control</h4>
<dt>
First Degree Object Control
</dt>
<dd>
<NodeALink
ready={this.state.firstdegreeControl !== -1}
value={this.state.firstdegreeControl}
click={function(){
emitter.emit('query', "MATCH p = (c:Computer {name:{name}})-[r1:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Group Delegated Object Control
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedControl !== -1}
value={this.state.groupDelegatedControl}
click={function(){
emitter.emit('query', "MATCH p = (c:Computer {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Transitive Object Control
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControl !== -1}
value={this.state.transitiveControl}
click={function(){
emitter.emit('query', "MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((c:Computer {name:{name}})-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
</dl>
</div>
);
}
}
ComputerNodeData.propTypes= {
visible : React.PropTypes.bool.isRequired
}
visible : React.PropTypes.bool.isRequired
};

View File

@ -2,121 +2,134 @@ import React, { Component } from 'react';
import LogoutModal from 'modals/LogoutModal';
export default class DatabaseDataDisplay extends Component {
constructor(){
super()
this.state = {
url: appStore.databaseInfo.url,
user: appStore.databaseInfo.user,
num_users: 'Refreshing',
num_computers: 'Refreshing',
num_groups: 'Refreshing',
num_relationships: 'Refreshing',
num_sessions: 'Refreshing',
interval: null
}
}
constructor(){
super();
this.state = {
url: appStore.databaseInfo.url,
user: appStore.databaseInfo.user,
num_users: 'Refreshing',
num_computers: 'Refreshing',
num_groups: 'Refreshing',
num_relationships: 'Refreshing',
num_sessions: 'Refreshing',
num_acls: 'Refreshing',
interval: null
};
}
componentDidMount() {
this.refreshDBData()
var x = setInterval(function(){
this.refreshDBData()
}.bind(this), 60000);
this.setState({
interval: x
})
emitter.on('hideDBClearModal', this.refreshDBData.bind(this))
emitter.on('refreshDBData', this.refreshDBData.bind(this))
}
componentDidMount() {
this.refreshDBData();
emitter.on('hideDBClearModal', this.refreshDBData.bind(this));
emitter.on('refreshDBData', this.refreshDBData.bind(this));
this.createInterval();
}
componentWillUnmount() {
clearInterval(this.state.interval)
this.setState({
interval: null,
session: null
})
}
componentWillUnmount() {
clearInterval(this.state.interval);
this.setState({
interval: null,
session: null
});
}
toggleLogoutModal(){
emitter.emit('showLogout');
}
createInterval(){
var x = setInterval(function(){
this.refreshDBData();
}.bind(this), 60000);
this.setState({
interval: x
});
};
toggleDBWarnModal(){
emitter.emit('openDBWarnModal')
}
toggleLogoutModal(){
emitter.emit('showLogout');
}
toggleSessionClearModal(){
emitter.emit('openSessionClearModal')
}
toggleDBWarnModal(){
emitter.emit('openDBWarnModal');
}
toggleSessionClearModal(){
emitter.emit('openSessionClearModal');
}
render() {
return (
<div>
<h3>Database Info</h3>
<dl className="dl-horizontal dl-horizontal-fix">
<dt>DB Address</dt>
<dd>{this.state.url}</dd>
<dt>DB User</dt>
<dd>{this.state.user}</dd>
<dt>Users</dt>
<dd>{this.state.num_users}</dd>
<dt>Computers</dt>
<dd>{this.state.num_computers}</dd>
<dt>Groups</dt>
<dd>{this.state.num_groups}</dd>
<dt>Sessions</dt>
<dd>{this.state.num_sessions}</dd>
<dt>Relationships</dt>
<dd>{this.state.num_relationships}</dd>
</dl>
refreshDBData(){
var s1 = driver.session();
var s2 = driver.session();
var s3 = driver.session();
var s4 = driver.session();
var s5 = driver.session();
var s6 = driver.session();
<div className="text-center">
<div className="btn-group btn-group-sm dbbuttons">
<button type="button" className="btn btn-success" onClick={function(){this.refreshDBData()}.bind(this)}>Refresh DB Stats</button>
<button type="button" className="btn btn-info" onClick={this.toggleSessionClearModal}>Clear Sessions</button>
<button type="button" className="btn btn-warning" onClick={this.toggleLogoutModal}>Log Out/Switch DB</button>
<button type="button" className="btn btn-danger" onClick={this.toggleDBWarnModal}>Clear Database</button>
</div>
</div>
</div>
);
}
s1.run("MATCH (n:User) WHERE NOT n.name ENDS WITH '$' RETURN count(n)")
.then(function(result){
this.setState({'num_users':result.records[0]._fields[0].low});
s1.close();
}.bind(this));
refreshDBData(){
var s1 = driver.session()
var s2 = driver.session()
var s3 = driver.session()
var s4 = driver.session()
var s5 = driver.session()
s2.run("MATCH (n:Group) RETURN count(n)")
.then(function(result){
this.setState({'num_groups':result.records[0]._fields[0].low});
s2.close();
}.bind(this));
s1.run("MATCH (n:User) WHERE NOT n.name ENDS WITH '$' RETURN count(n)")
.then(function(result){
this.setState({'num_users':result.records[0]._fields[0].low})
s1.close()
}.bind(this))
s3.run("MATCH (n:Computer) RETURN count(n)")
.then(function(result){
this.setState({'num_computers':result.records[0]._fields[0].low});
s3.close();
}.bind(this));
s2.run("MATCH (n:Group) RETURN count(n)")
.then(function(result){
this.setState({'num_groups':result.records[0]._fields[0].low})
s2.close()
}.bind(this))
s4.run("MATCH ()-[r:HasSession]->() RETURN count(r)")
.then(function(result){
this.setState({'num_sessions':result.records[0]._fields[0].low});
s4.close();
}.bind(this));
s3.run("MATCH (n:Computer) RETURN count(n)")
.then(function(result){
this.setState({'num_computers':result.records[0]._fields[0].low})
s3.close()
}.bind(this))
s6.run("MATCH ()-[r {isACL: true}]->() RETURN count(r)")
.then(function(result){
this.setState({'num_acls':result.records[0]._fields[0].low});
s6.close();
}.bind(this));
s4.run("MATCH ()-[r:HasSession]->() RETURN count(r)")
.then(function(result){
this.setState({'num_sessions':result.records[0]._fields[0].low})
s4.close()
}.bind(this))
s5.run("MATCH ()-[r]->() RETURN count(r)")
.then(function(result){
this.setState({'num_relationships':result.records[0]._fields[0].low});
s5.close();
}.bind(this));
}
s5.run("MATCH ()-[r]->() RETURN count(r)")
.then(function(result){
this.setState({'num_relationships':result.records[0]._fields[0].low})
s5.close()
}.bind(this))
}
render() {
return (
<div>
<h3>Database Info</h3>
<dl className="dl-horizontal dl-horizontal-fix">
<dt>DB Address</dt>
<dd>{this.state.url}</dd>
<dt>DB User</dt>
<dd>{this.state.user}</dd>
<dt>Users</dt>
<dd>{this.state.num_users}</dd>
<dt>Computers</dt>
<dd>{this.state.num_computers}</dd>
<dt>Groups</dt>
<dd>{this.state.num_groups}</dd>
<dt>Sessions</dt>
<dd>{this.state.num_sessions}</dd>
<dt>ACLs</dt>
<dd>{this.state.num_acls}</dd>
<dt>Relationships</dt>
<dd>{this.state.num_relationships}</dd>
</dl>
<div className="text-center">
<div className="btn-group btn-group-sm dbbuttons">
<button type="button" className="btn btn-success" onClick={function(){this.refreshDBData();}.bind(this)}>Refresh DB Stats</button>
<button type="button" className="btn btn-info" onClick={this.toggleSessionClearModal}>Clear Sessions</button>
<button type="button" className="btn btn-warning" onClick={this.toggleLogoutModal}>Log Out/Switch DB</button>
<button type="button" className="btn btn-danger" onClick={this.toggleDBWarnModal}>Clear Database</button>
</div>
</div>
</div>
);
}
}

View File

@ -1,233 +1,243 @@
import React, { Component } from 'react';
import NodeALink from './NodeALink.jsx'
import LoadLabel from './LoadLabel.jsx'
import PropTypes from 'prop-types'
import NodeALink from './NodeALink.jsx';
import LoadLabel from './LoadLabel.jsx';
import PropTypes from 'prop-types';
export default class DomainNodeData extends Component {
constructor(){
super();
constructor(){
super();
this.state = {
label: "",
users: -1,
groups: -1,
computers: -1,
foreignGroups: -1,
foreignUsers: -1,
firstDegreeOutboundTrusts: -1,
effectiveOutboundTrusts: -1,
firstDegreeInboundTrusts: -1,
effectiveInboundTrusts: -1,
driversessions: []
}
this.state = {
label: "",
users: -1,
groups: -1,
computers: -1,
foreignGroups: -1,
foreignUsers: -1,
firstDegreeOutboundTrusts: -1,
effectiveOutboundTrusts: -1,
firstDegreeInboundTrusts: -1,
effectiveInboundTrusts: -1,
driversessions: []
};
emitter.on('domainNodeClicked', this.getNodeData.bind(this));
}
emitter.on('domainNodeClicked', this.getNodeData.bind(this));
}
getNodeData(payload){
$.each(this.state.driversessions, function(index, record){
record.close();
})
this.setState({
label: payload,
users: -1,
groups: -1,
computers: -1,
foreignGroups: -1,
foreignUsers: -1,
firstDegreeOutboundTrusts: -1,
effectiveOutboundTrusts: -1,
firstDegreeInboundTrusts: -1,
effectiveInboundTrusts: -1
})
getNodeData(payload){
$.each(this.state.driversessions, function(index, record){
record.close();
});
this.setState({
label: payload,
users: -1,
groups: -1,
computers: -1,
foreignGroups: -1,
foreignUsers: -1,
firstDegreeOutboundTrusts: -1,
effectiveOutboundTrusts: -1,
firstDegreeInboundTrusts: -1,
effectiveInboundTrusts: -1
});
var s1 = driver.session()
var s2 = driver.session()
var s3 = driver.session()
var s4 = driver.session()
var s5 = driver.session()
var s6 = driver.session()
var s7 = driver.session()
var s8 = driver.session()
var s9 = driver.session()
var s1 = driver.session();
var s2 = driver.session();
var s3 = driver.session();
var s4 = driver.session();
var s5 = driver.session();
var s6 = driver.session();
var s7 = driver.session();
var s8 = driver.session();
var s9 = driver.session();
s1.run("MATCH (a:User) WHERE a.name ENDS WITH ('@' + {name}) RETURN COUNT(a)", {name:payload})
.then(function(result){
this.setState({'users':result.records[0]._fields[0].low})
s1.close()
}.bind(this))
s1.run("MATCH (a:User) WHERE a.name ENDS WITH ('@' + {name}) RETURN COUNT(a)", {name:payload})
.then(function(result){
this.setState({'users':result.records[0]._fields[0].low});
s1.close();
}.bind(this));
s2.run("MATCH (a:Group) WHERE a.name ENDS WITH ('@' + {name}) RETURN COUNT(a)", {name:payload})
.then(function(result){
this.setState({'groups':result.records[0]._fields[0].low})
s2.close()
}.bind(this))
s2.run("MATCH (a:Group) WHERE a.name ENDS WITH ('@' + {name}) RETURN COUNT(a)", {name:payload})
.then(function(result){
this.setState({'groups':result.records[0]._fields[0].low});
s2.close();
}.bind(this));
s3.run("MATCH (n:Computer) WHERE n.name ENDS WITH {name} WITH n WHERE size(split(n.name,'.')) - size(split({name},'.')) = 1 RETURN count(n)", {name:payload})
.then(function(result){
this.setState({'computers':result.records[0]._fields[0].low})
s3.close()
}.bind(this))
s3.run("MATCH (n:Computer) WHERE n.name ENDS WITH {name} WITH n WHERE size(split(n.name,'.')) - size(split({name},'.')) = 1 RETURN count(n)", {name:payload})
.then(function(result){
this.setState({'computers':result.records[0]._fields[0].low});
s3.close();
}.bind(this));
s4.run("MATCH (a:Group) WHERE NOT a.name ENDS WITH ('@' + {name}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {name}) WITH a,b MATCH (a)-[r:MemberOf]->(b) RETURN count(a)", {name:payload})
.then(function(result){
this.setState({'foreignGroups':result.records[0]._fields[0].low})
s4.close()
}.bind(this))
s4.run("MATCH (a:Group) WHERE NOT a.name ENDS WITH ('@' + {name}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {name}) WITH a,b MATCH (a)-[r:MemberOf]->(b) RETURN count(a)", {name:payload})
.then(function(result){
this.setState({'foreignGroups':result.records[0]._fields[0].low});
s4.close();
}.bind(this));
s5.run("MATCH (a:User) WHERE NOT a.name ENDS WITH ('@' + {name}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {name}) WITH a,b MATCH (a)-[r:MemberOf]->(b) RETURN count(a)", {name:payload})
.then(function(result){
this.setState({'foreignUsers':result.records[0]._fields[0].low})
s5.close()
}.bind(this))
s5.run("MATCH (a:User) WHERE NOT a.name ENDS WITH ('@' + {name}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {name}) WITH a,b MATCH (a)-[r:MemberOf]->(b) RETURN count(a)", {name:payload})
.then(function(result){
this.setState({'foreignUsers':result.records[0]._fields[0].low});
s5.close();
}.bind(this));
s6.run("MATCH (a:Domain {name:{name}})<-[r:TrustedBy]-(b:Domain) RETURN count(b)", {name:payload})
.then(function(result){
this.setState({'firstDegreeInboundTrusts':result.records[0]._fields[0].low})
s6.close()
}.bind(this))
s6.run("MATCH (a:Domain {name:{name}})<-[r:TrustedBy]-(b:Domain) RETURN count(b)", {name:payload})
.then(function(result){
this.setState({'firstDegreeInboundTrusts':result.records[0]._fields[0].low});
s6.close();
}.bind(this));
s7.run("MATCH (a:Domain {name:{name}})-[r:TrustedBy]->(b:Domain) RETURN count(b)", {name:payload})
.then(function(result){
this.setState({'firstDegreeOutboundTrusts':result.records[0]._fields[0].low})
s7.close()
}.bind(this))
s7.run("MATCH (a:Domain {name:{name}})-[r:TrustedBy]->(b:Domain) RETURN count(b)", {name:payload})
.then(function(result){
this.setState({'firstDegreeOutboundTrusts':result.records[0]._fields[0].low});
s7.close();
}.bind(this));
s8.run("MATCH p=shortestPath((a:Domain {name:{name}})<-[r:TrustedBy*1..]-(b:Domain)) RETURN count(b)", {name:payload})
.then(function(result){
this.setState({'effectiveInboundTrusts':result.records[0]._fields[0].low})
s8.close()
}.bind(this))
s8.run("MATCH (b:Domain) WHERE NOT b.name={name} WITH b MATCH p=shortestPath((a:Domain {name:{name}})<-[r:TrustedBy*1..]-(b)) RETURN count(b)", {name:payload})
.then(function(result){
this.setState({'effectiveInboundTrusts':result.records[0]._fields[0].low});
s8.close();
}.bind(this));
s9.run("MATCH p=shortestPath((a:Domain {name:{name}})-[r:TrustedBy*1..]->(b:Domain)) RETURN count(b)", {name:payload})
.then(function(result){
this.setState({'effectiveOutboundTrusts':result.records[0]._fields[0].low})
s9.close()
}.bind(this))
s9.run("MATCH (b:Domain) WHERE NOT b.name={name} MATCH p=shortestPath((a:Domain {name:{name}})-[r:TrustedBy*1..]->(b)) RETURN count(b)", {name:payload})
.then(function(result){
this.setState({'effectiveOutboundTrusts':result.records[0]._fields[0].low});
s9.close();
}.bind(this));
this.setState({'driversessions': [s1,s2,s3,s4,s5,s6,s7,s8,s9]})
}
this.setState({'driversessions': [s1,s2,s3,s4,s5,s6,s7,s8,s9]});
}
render() {
return (
<div className={this.props.visible ? "" : "displaynone"}>
<dl className='dl-horizontal'>
<dt>
Node
</dt>
<dd>
{this.state.label}
</dd>
<br />
<dt>
Users
</dt>
<dd>
<LoadLabel
ready={this.state.users !== -1}
value={this.state.users} />
</dd>
<dt>
Groups
</dt>
<dd>
<LoadLabel
ready={this.state.groups !== -1}
value={this.state.groups} />
</dd>
<dt>
Computers
</dt>
<dd>
<LoadLabel
ready={this.state.computers !== -1}
value={this.state.computers} />
</dd>
<br />
<dt>
Foreign Users
</dt>
<dd>
<NodeALink
ready={this.state.foreignUsers !== -1}
value={this.state.foreignUsers}
click={function(){
emitter.emit('query', "MATCH (a:User) WHERE NOT a.name ENDS WITH ('@' + {domain}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {domain}) WITH a,b MATCH (a)-[r:MemberOf]-(b) RETURN a,r,b", {domain: this.state.label})
}.bind(this)} />
</dd>
<dt>
Foreign Groups
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroups !== -1}
value={this.state.foreignGroups}
click={function(){
emitter.emit('query', "MATCH (a:Group) WHERE NOT a.name ENDS WITH ('@' + {domain}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {domain}) WITH a,b MATCH (a)-[r:MemberOf]-(b) RETURN a,r,b", {domain: this.state.label})
}.bind(this)} />
</dd>
<dt>
Foreign Admins
</dt>
<dd>
<NodeALink
ready={this.state.foreignAdmins !== -1}
value={this.state.foreignAdmins}
click={function(){
emitter.emit('query', "MATCH (a:Group) WHERE NOT a.name ENDS WITH ('@' + {domain}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {domain}) WITH a,b MATCH (a)-[r:MemberOf]-(b) RETURN a,r,b", {domain: this.state.label})
}.bind(this)} />
</dd>
<br />
<dt>
Inbound Trusts
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeInboundTrusts !== -1}
value={this.state.firstDegreeInboundTrusts}
click={function(){
emitter.emit('query', "MATCH (a:Domain {name:{domain}})<-[r:TrustedBy]-(b:Domain) RETURN a,r,b", {domain: this.state.label})
}.bind(this)} />
</dd>
<dt>
Effective Inbound Trusts
</dt>
<dd>
<NodeALink
ready={this.state.effectiveInboundTrusts !== -1}
value={this.state.effectiveInboundTrusts}
click={function(){
emitter.emit('query', "MATCH p=shortestPath((a:Domain {name:{domain}})<-[r:TrustedBy*1..]-(b:Domain)) RETURN p", {domain: this.state.label})
}.bind(this)} />
</dd>
<dt>
Outbound Trusts
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeOutboundTrusts !== -1}
value={this.state.firstDegreeOutboundTrusts}
click={function(){
emitter.emit('query', "MATCH (a:Domain {name:{domain}})-[r:TrustedBy]->(b:Domain) RETURN a,r,b", {domain: this.state.label})
}.bind(this)} />
</dd>
<dt>
Effective Outbound Trusts
</dt>
<dd>
<NodeALink
ready={this.state.effectiveOutboundTrusts !== -1}
value={this.state.effectiveOutboundTrusts}
click={function(){
emitter.emit('query', "MATCH p=shortestPath((a:Domain {name:{domain}})-[r:TrustedBy*1..]->(b:Domain)) RETURN p", {domain: this.state.label})
}.bind(this)} />
</dd>
</dl>
</div>
);
}
render() {
return (
<div className={this.props.visible ? "" : "displaynone"}>
<dl className='dl-horizontal'>
<dt>
Node
</dt>
<dd>
{this.state.label}
</dd>
<br />
<dt>
Users
</dt>
<dd>
<LoadLabel
ready={this.state.users !== -1}
value={this.state.users}
/>
</dd>
<dt>
Groups
</dt>
<dd>
<LoadLabel
ready={this.state.groups !== -1}
value={this.state.groups}
/>
</dd>
<dt>
Computers
</dt>
<dd>
<LoadLabel
ready={this.state.computers !== -1}
value={this.state.computers}
/>
</dd>
<br />
<dt>
Foreign Users
</dt>
<dd>
<NodeALink
ready={this.state.foreignUsers !== -1}
value={this.state.foreignUsers}
click={function(){
emitter.emit('query', "MATCH (a:User) WHERE NOT a.name ENDS WITH ('@' + {domain}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {domain}) WITH a,b MATCH (a)-[r:MemberOf]-(b) RETURN a,r,b", {domain: this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Foreign Groups
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroups !== -1}
value={this.state.foreignGroups}
click={function(){
emitter.emit('query', "MATCH (a:Group) WHERE NOT a.name ENDS WITH ('@' + {domain}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {domain}) WITH a,b MATCH (a)-[r:MemberOf]-(b) RETURN a,r,b", {domain: this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Foreign Admins
</dt>
<dd>
<NodeALink
ready={this.state.foreignAdmins !== -1}
value={this.state.foreignAdmins}
click={function(){
emitter.emit('query', "MATCH (a:Group) WHERE NOT a.name ENDS WITH ('@' + {domain}) WITH a MATCH (b:Group) WHERE b.name ENDS WITH ('@' + {domain}) WITH a,b MATCH (a)-[r:MemberOf]-(b) RETURN a,r,b", {domain: this.state.label});
}.bind(this)}
/>
</dd>
<br />
<dt>
Inbound Trusts
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeInboundTrusts !== -1}
value={this.state.firstDegreeInboundTrusts}
click={function(){
emitter.emit('query', "MATCH (a:Domain {name:{domain}})<-[r:TrustedBy]-(b:Domain) RETURN a,r,b", {domain: this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Effective Inbound Trusts
</dt>
<dd>
<NodeALink
ready={this.state.effectiveInboundTrusts !== -1}
value={this.state.effectiveInboundTrusts}
click={function(){
emitter.emit('query', "MATCH (b:Domain) WHERE NOT b.name={domain} WITH b MATCH p=shortestPath((a:Domain {name:{domain}})<-[r:TrustedBy*1..]-(b)) RETURN p", {domain: this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Outbound Trusts
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeOutboundTrusts !== -1}
value={this.state.firstDegreeOutboundTrusts}
click={function(){
emitter.emit('query', "MATCH (a:Domain {name:{domain}})-[r:TrustedBy]->(b:Domain) RETURN a,r,b", {domain: this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Effective Outbound Trusts
</dt>
<dd>
<NodeALink
ready={this.state.effectiveOutboundTrusts !== -1}
value={this.state.effectiveOutboundTrusts}
click={function(){
emitter.emit('query', "MATCH (b:Domain) WHERE NOT b.name={domain} WITH b MATCH p=shortestPath((a:Domain {name:{domain}})-[r:TrustedBy*1..]->(b:Domain)) RETURN p", {domain: this.state.label});
}.bind(this)}
/>
</dd>
</dl>
</div>
);
}
}
DomainNodeData.propTypes = {
visible : React.PropTypes.bool.isRequired
}
visible : React.PropTypes.bool.isRequired
};

View File

@ -1,394 +1,405 @@
import React, { Component } from 'react';
import NodeALink from './NodeALink'
import PropTypes from 'prop-types'
import NodeALink from './NodeALink';
import PropTypes from 'prop-types';
export default class GroupNodeData extends Component {
constructor(){
super();
constructor(){
super();
this.state = {
label: "",
directMembers: -1,
unrolledMembers: -1,
directAdminTo: -1,
derivativeAdminTo: -1,
unrolledMemberOf: -1,
sessions: -1,
foreignGroupMembership: -1,
foreignGroupMembers: -1,
firstDegreeGroupMembership: -1,
groupDelegatedAdmin: -1,
firstdegreeControl: -1,
groupDelegatedControl: -1,
transitiveControl: -1,
firstDegreeControllers: -1,
unrolledControllers: -1,
transitiveControllers: -1,
driversessions: []
}
this.state = {
label: "",
directMembers: -1,
unrolledMembers: -1,
directAdminTo: -1,
derivativeAdminTo: -1,
unrolledMemberOf: -1,
sessions: -1,
foreignGroupMembership: -1,
foreignGroupMembers: -1,
firstDegreeGroupMembership: -1,
groupDelegatedAdmin: -1,
firstdegreeControl: -1,
groupDelegatedControl: -1,
transitiveControl: -1,
firstDegreeControllers: -1,
unrolledControllers: -1,
transitiveControllers: -1,
driversessions: []
};
emitter.on('groupNodeClicked', this.getNodeData.bind(this));
}
emitter.on('groupNodeClicked', this.getNodeData.bind(this));
}
getNodeData(payload){
$.each(this.state.driversessions, function(index, record){
record.close();
})
getNodeData(payload){
$.each(this.state.driversessions, function(index, record){
record.close();
});
this.setState({
label: payload,
directMembers: -1,
unrolledMembers: -1,
directAdminTo: -1,
derivativeAdminTo: -1,
unrolledMemberOf: -1,
sessions: -1,
foreignGroupMembership: -1,
foreignGroupMembers: -1,
firstDegreeGroupMembership: -1,
groupDelegatedAdmin: -1,
firstdegreeControl: -1,
groupDelegatedControl: -1,
transitiveControl: -1,
firstDegreeControllers: -1,
unrolledControllers: -1,
transitiveControllers: -1
})
this.setState({
label: payload,
directMembers: -1,
unrolledMembers: -1,
directAdminTo: -1,
derivativeAdminTo: -1,
unrolledMemberOf: -1,
sessions: -1,
foreignGroupMembership: -1,
foreignGroupMembers: -1,
firstDegreeGroupMembership: -1,
groupDelegatedAdmin: -1,
firstdegreeControl: -1,
groupDelegatedControl: -1,
transitiveControl: -1,
firstDegreeControllers: -1,
unrolledControllers: -1,
transitiveControllers: -1
});
var domain = '@' + payload.split('@').last()
var s1 = driver.session()
var s2 = driver.session()
var s3 = driver.session()
var s4 = driver.session()
var s5 = driver.session()
var s6 = driver.session()
var s7 = driver.session()
var s8 = driver.session()
var s9 = driver.session()
var s10 = driver.session()
var s11 = driver.session()
var s12 = driver.session()
var s13 = driver.session()
var s14 = driver.session()
var s15 = driver.session()
var s16 = driver.session()
var domain = '@' + payload.split('@').last();
var s1 = driver.session();
var s2 = driver.session();
var s3 = driver.session();
var s4 = driver.session();
var s5 = driver.session();
var s6 = driver.session();
var s7 = driver.session();
var s8 = driver.session();
var s9 = driver.session();
var s10 = driver.session();
var s11 = driver.session();
var s12 = driver.session();
var s13 = driver.session();
var s14 = driver.session();
var s15 = driver.session();
var s16 = driver.session();
s1.run("MATCH (a)-[b:MemberOf]->(c:Group {name:{name}}) RETURN count(a)", {name:payload})
.then(function(result){
this.setState({'directMembers':result.records[0]._fields[0].low})
s1.close()
}.bind(this))
s1.run("MATCH (a)-[b:MemberOf]->(c:Group {name:{name}}) RETURN count(a)", {name:payload})
.then(function(result){
this.setState({'directMembers':result.records[0]._fields[0].low});
s1.close();
}.bind(this));
s2.run("MATCH p = (n)-[r:MemberOf*1..]->(g:Group {name:{name}}) RETURN COUNT(n)", {name:payload})
.then(function(result){
this.setState({'unrolledMembers':result.records[0]._fields[0].low})
s2.close()
}.bind(this))
s2.run("MATCH p = (n)-[r:MemberOf*1..]->(g:Group {name:{name}}) RETURN COUNT(n)", {name:payload})
.then(function(result){
this.setState({'unrolledMembers':result.records[0]._fields[0].low});
s2.close();
}.bind(this));
s3.run("MATCH (n:Group {name:{name}})-[r:AdminTo]->(m:Computer) RETURN count(distinct(m))", {name:payload})
.then(function(result){
this.setState({'directAdminTo':result.records[0]._fields[0].low})
s3.close()
}.bind(this))
s3.run("MATCH (n:Group {name:{name}})-[r:AdminTo]->(m:Computer) RETURN count(distinct(m))", {name:payload})
.then(function(result){
this.setState({'directAdminTo':result.records[0]._fields[0].low});
s3.close();
}.bind(this));
s4.run("MATCH p = shortestPath((g:Group {name:{name}})-[r:MemberOf|AdminTo|HasSession*1..]->(c:Computer)) RETURN COUNT(DISTINCT(c))", {name:payload})
.then(function(result){
this.setState({'derivativeAdminTo':result.records[0]._fields[0].low})
s4.close()
}.bind(this))
s4.run("MATCH (c:Computer) WHERE NOT c.name={name} WITH c MATCH p = shortestPath((g:Group {name:{name}})-[r:MemberOf|AdminTo|HasSession*1..]->(c)) RETURN COUNT(DISTINCT(c))", {name:payload})
.then(function(result){
this.setState({'derivativeAdminTo':result.records[0]._fields[0].low});
s4.close();
}.bind(this));
s5.run("MATCH p = (g1:Group {name:{name}})-[r:MemberOf*1..]->(g2:Group) RETURN COUNT(DISTINCT(g2))", {name:payload})
.then(function(result){
this.setState({'unrolledMemberOf':result.records[0]._fields[0].low})
s5.close()
}.bind(this))
s5.run("MATCH p = (g1:Group {name:{name}})-[r:MemberOf*1..]->(g2:Group) RETURN COUNT(DISTINCT(g2))", {name:payload})
.then(function(result){
this.setState({'unrolledMemberOf':result.records[0]._fields[0].low});
s5.close();
}.bind(this));
s6.run("MATCH p = (c:Computer)-[r1:HasSession]->(u:User)-[r2:MemberOf*1..]->(g:Group {name: {name}}) RETURN COUNT(r1)", {name:payload})
.then(function(result){
this.setState({'sessions':result.records[0]._fields[0].low})
s6.close()
}.bind(this))
s6.run("MATCH p = (c:Computer)-[r1:HasSession]->(u:User)-[r2:MemberOf*1..]->(g:Group {name: {name}}) RETURN COUNT(r1)", {name:payload})
.then(function(result){
this.setState({'sessions':result.records[0]._fields[0].low});
s6.close();
}.bind(this));
s7.run("MATCH (n:Group) WHERE NOT n.name ENDS WITH {domain} WITH n MATCH (m:Group {name:{name}}) MATCH (m)-[r:MemberOf]->(n) RETURN count(n)", {name:payload, domain:domain})
.then(function(result){
this.setState({'foreignGroupMembership':result.records[0]._fields[0].low})
s7.close()
}.bind(this))
s7.run("MATCH (n:Group) WHERE NOT n.name ENDS WITH {domain} WITH n MATCH (m:Group {name:{name}}) MATCH (m)-[r:MemberOf]->(n) RETURN count(n)", {name:payload, domain:domain})
.then(function(result){
this.setState({'foreignGroupMembership':result.records[0]._fields[0].low});
s7.close();
}.bind(this));
s8.run("MATCH p = (n)-[r:MemberOf*1..]->(g:Group {name:{name}}) WHERE NOT g.domain = n.domain RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'foreignGroupMembers':result.records[0]._fields[0].low})
s8.close()
}.bind(this))
s8.run("MATCH p = (n)-[r:MemberOf*1..]->(g:Group {name:{name}}) WHERE NOT g.domain = n.domain RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'foreignGroupMembers':result.records[0]._fields[0].low});
s8.close();
}.bind(this));
s9.run("MATCH p = (g1:Group {name:{name}})-[r:MemberOf]->(g2:Group) RETURN COUNT(DISTINCT(g2))", {name:payload})
.then(function(result){
this.setState({'firstDegreeGroupMembership':result.records[0]._fields[0].low})
s9.close()
}.bind(this))
s9.run("MATCH p = (g1:Group {name:{name}})-[r:MemberOf]->(g2:Group) RETURN COUNT(DISTINCT(g2))", {name:payload})
.then(function(result){
this.setState({'firstDegreeGroupMembership':result.records[0]._fields[0].low});
s9.close();
}.bind(this));
s10.run("MATCH p = (g1:Group {name:{name}})-[r1:MemberOf*1..]->(g2:Group)-[r2:AdminTo]->(c:Computer) RETURN COUNT(DISTINCT(c))", {name:payload})
.then(function(result){
this.setState({'groupDelegatedAdmin':result.records[0]._fields[0].low})
s10.close()
}.bind(this))
s10.run("MATCH p = (g1:Group {name:{name}})-[r1:MemberOf*1..]->(g2:Group)-[r2:AdminTo]->(c:Computer) RETURN COUNT(DISTINCT(c))", {name:payload})
.then(function(result){
this.setState({'groupDelegatedAdmin':result.records[0]._fields[0].low});
s10.close();
}.bind(this));
s11.run("MATCH p = (g:Group {name:{name}})-[r:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstdegreeControl':result.records[0]._fields[0].low})
s11.close()
}.bind(this))
s11.run("MATCH p = (g:Group {name:{name}})-[r:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstdegreeControl':result.records[0]._fields[0].low});
s11.close();
}.bind(this));
s12.run("MATCH p = (g1:Group {name:{name}})-[r1:MemberOf*1..]->(g2:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'groupDelegatedControl':result.records[0]._fields[0].low})
s12.close()
}.bind(this))
s12.run("MATCH p = (g1:Group {name:{name}})-[r1:MemberOf*1..]->(g2:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'groupDelegatedControl':result.records[0]._fields[0].low});
s12.close();
}.bind(this));
s13.run("MATCH p = shortestPath((g:Group {name:{name}})-[r:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'transitiveControl':result.records[0]._fields[0].low})
s13.close()
}.bind(this))
s13.run("MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((g:Group {name:{name}})-[r:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'transitiveControl':result.records[0]._fields[0].low});
s13.close();
}.bind(this));
s14.run("MATCH p = (n)-[r:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(g:Group {name:{name}}) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstDegreeControllers':result.records[0]._fields[0].low})
s14.close()
}.bind(this))
s14.run("MATCH p = (n)-[r:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(g:Group {name:{name}}) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstDegreeControllers':result.records[0]._fields[0].low});
s14.close();
}.bind(this));
s15.run("MATCH p = (n1)-[r:MemberOf*1..]->(g1:Group)-[r1:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(g2:Group {name: {name}}) WITH LENGTH(p) as pathLength, p, n1 WHERE NONE (x in NODES(p)[1..(pathLength-1)] WHERE x.name = g2.name) AND NOT n1.name = g2.name RETURN COUNT(DISTINCT(n1))", {name:payload})
.then(function(result){
this.setState({'unrolledControllers':result.records[0]._fields[0].low})
s15.close()
}.bind(this))
s15.run("MATCH p = (n1)-[r:MemberOf*1..]->(g1:Group)-[r1:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(g2:Group {name: {name}}) WITH LENGTH(p) as pathLength, p, n1 WHERE NONE (x in NODES(p)[1..(pathLength-1)] WHERE x.name = g2.name) AND NOT n1.name = g2.name RETURN COUNT(DISTINCT(n1))", {name:payload})
.then(function(result){
this.setState({'unrolledControllers':result.records[0]._fields[0].low});
s15.close();
}.bind(this));
s16.run("MATCH p = shortestPath((n)-[r:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(g:Group {name:{name}})) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'transitiveControllers':result.records[0]._fields[0].low})
s16.close()
}.bind(this))
s16.run("MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((n)-[r:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(g:Group {name:{name}})) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'transitiveControllers':result.records[0]._fields[0].low});
s16.close();
}.bind(this));
this.setState({'driversessions': [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16]})
}
this.setState({'driversessions': [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16]});
}
render() {
var domain = '@' + this.state.label.split('@')
return (
<div className={this.props.visible ? "" : "displaynone"}>
<dl className='dl-horizontal'>
<h4>Node Info</h4>
<dt>
Name
</dt>
<dd>
{this.state.label}
</dd>
<dt>
Sessions
</dt>
<dd>
<NodeALink
ready={this.state.sessions !== -1}
value={this.state.sessions}
click={function(){
emitter.emit('query', "MATCH p = (c:Computer)-[r1:HasSession]->(u:User)-[r2:MemberOf*1..]->(g:Group {name: {name}}) RETURN p", {name: this.state.label},
"",this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>Group Members</h4>
<dt>
Direct Members
</dt>
<dd>
<NodeALink
ready={this.state.directMembers !== -1}
value={this.state.directMembers}
click={function(){
emitter.emit('query', "MATCH (n)-[r:MemberOf]->(m:Group {name:{name}}) RETURN n,r,m", {name: this.state.label})
}.bind(this)} />
</dd>
<dt>
Unrolled Members
</dt>
<dd>
<NodeALink
ready={this.state.unrolledMembers !== -1}
value={this.state.unrolledMembers}
click={function(){
emitter.emit('query', "MATCH p = (n)-[r:MemberOf*1..]->(g:Group {name:{name}}) RETURN p", {name: this.state.label},
this.state.label)
}.bind(this)} />
</dd>
<dt>
Foreign Members
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroupMembers !== -1}
value={this.state.foreignGroupMembers}
click={function(){
emitter.emit('query', "MATCH p = (n)-[r:MemberOf*1..]->(g:Group {name:{name}}) WHERE NOT g.domain = n.domain RETURN p", {name: this.state.label},
this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>Group Membership</h4>
<dt>
First Degree Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeGroupMembership !== -1}
value={this.state.firstDegreeGroupMembership}
click={function(){
emitter.emit('query', "MATCH p = (g1:Group {name:{name}})-[r:MemberOf]->(g2:Group) RETURN p", {name: this.state.label},
this.state.label)
}.bind(this)} />
</dd>
<dt>
Unrolled Member Of
</dt>
<dd>
<NodeALink
ready={this.state.unrolledMemberOf !== -1}
value={this.state.unrolledMemberOf}
click={function(){
emitter.emit('query', "MATCH p = (g1:Group {name:{name}})-[r:MemberOf*1..]->(g2:Group) RETURN p", {name: this.state.label},
this.state.label)
}.bind(this)} />
</dd>
<dt>
Foreign Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroupMembership !== -1}
value={this.state.foreignGroupMembership}
click={function(){
emitter.emit('query', "MATCH (n:Group) WHERE NOT n.name ENDS WITH {domain} WITH n MATCH (m:Group {name:{name}}) MATCH (m)-[r:MemberOf]->(n) RETURN m,r,n", {name: this.state.label, domain: domain})
}.bind(this)} />
</dd>
<br />
<h4>Local Admin Rights</h4>
<dt>
First Degree Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.directAdminTo !== -1}
value={this.state.directAdminTo}
click={function(){
emitter.emit('query', "MATCH p=(g:Group {name:{name}})-[r:AdminTo]->(c:Computer) RETURN p", {name: this.state.label},
this.state.label)
}.bind(this)} />
</dd>
<dt>
Group Delegated Local Admin Rights
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedAdmin !== -1}
value={this.state.groupDelegatedAdmin}
click={function(){
emitter.emit('query', "MATCH p = (g1:Group {name:{name}})-[r1:MemberOf*1..]->(g2:Group)-[r2:AdminTo]->(c:Computer) RETURN p", {name: this.state.label},
this.state.label)
}.bind(this)} />
</dd>
<dt>
Derivative Local Admin Rights
</dt>
<dd>
<NodeALink
ready={this.state.derivativeAdminTo !== -1}
value={this.state.derivativeAdminTo}
click={function(){
emitter.emit('query', "MATCH p = shortestPath((g:Group {name:{name}})-[r:MemberOf|AdminTo|HasSession*1..]->(c:Computer)) RETURN p", {name: this.state.label},
this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>Outbound Object Control</h4>
<dt>
First Degree Object Control
</dt>
<dd>
<NodeALink
ready={this.state.firstdegreeControl !== -1}
value={this.state.firstdegreeControl}
click={function(){
emitter.emit('query', "MATCH p = (g:Group {name:{name}})-[r1:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label})
}.bind(this)} />
</dd>
<dt>
Group Delegated Object Control
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedControl !== -1}
value={this.state.groupDelegatedControl}
click={function(){
emitter.emit('query', "MATCH p = (g1:Group {name:{name}})-[r1:MemberOf*1..]->(g2:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<dt>
Transitive Object Control
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControl !== -1}
value={this.state.transitiveControl}
click={function(){
emitter.emit('query', "MATCH p = shortestPath((g:Group {name:{name}})-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>Inbound Object Control</h4>
<dt>
Explicit Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeControllers !== -1}
value={this.state.firstDegreeControllers}
click={function(){
emitter.emit('query', "MATCH p = (n)-[r:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(g:Group {name: {name}}) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<dt>
Unrolled Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.unrolledControllers !== -1}
value={this.state.unrolledControllers}
click={function(){
emitter.emit('query', "MATCH p = (n1)-[r:MemberOf*1..]->(g1:Group)-[r1:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(g2:Group {name: {name}}) WITH LENGTH(p) as pathLength, p, n1 WHERE NONE (x in NODES(p)[1..(pathLength-1)] WHERE x.name = g2.name) AND NOT n1.name = g2.name RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<dt>
Transitive Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControllers !== -1}
value={this.state.transitiveControllers}
click={function(){
emitter.emit('query', "MATCH p = shortestPath((n)-[r:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(g:Group {name: {name}})) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
</dl>
</div>
);
}
render() {
var domain = '@' + this.state.label.split('@');
return (
<div className={this.props.visible ? "" : "displaynone"}>
<dl className='dl-horizontal'>
<h4>Node Info</h4>
<dt>
Name
</dt>
<dd>
{this.state.label}
</dd>
<dt>
Sessions
</dt>
<dd>
<NodeALink
ready={this.state.sessions !== -1}
value={this.state.sessions}
click={function(){
emitter.emit('query', "MATCH p = (c:Computer)-[r1:HasSession]->(u:User)-[r2:MemberOf*1..]->(g:Group {name: {name}}) RETURN p", {name: this.state.label},
"",this.state.label);
}.bind(this)}
/>
</dd>
<h4>Group Members</h4>
<dt>
Direct Members
</dt>
<dd>
<NodeALink
ready={this.state.directMembers !== -1}
value={this.state.directMembers}
click={function(){
emitter.emit('query', "MATCH (n)-[r:MemberOf]->(m:Group {name:{name}}) RETURN n,r,m", {name: this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Unrolled Members
</dt>
<dd>
<NodeALink
ready={this.state.unrolledMembers !== -1}
value={this.state.unrolledMembers}
click={function(){
emitter.emit('query', "MATCH p = (n)-[r:MemberOf*1..]->(g:Group {name:{name}}) RETURN p", {name: this.state.label},
this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Foreign Members
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroupMembers !== -1}
value={this.state.foreignGroupMembers}
click={function(){
emitter.emit('query', "MATCH p = (n)-[r:MemberOf*1..]->(g:Group {name:{name}}) WHERE NOT g.domain = n.domain RETURN p", {name: this.state.label},
this.state.label);
}.bind(this)}
/>
</dd>
<h4>Group Membership</h4>
<dt>
First Degree Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeGroupMembership !== -1}
value={this.state.firstDegreeGroupMembership}
click={function(){
emitter.emit('query', "MATCH p = (g1:Group {name:{name}})-[r:MemberOf]->(g2:Group) RETURN p", {name: this.state.label},
this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Unrolled Member Of
</dt>
<dd>
<NodeALink
ready={this.state.unrolledMemberOf !== -1}
value={this.state.unrolledMemberOf}
click={function(){
emitter.emit('query', "MATCH p = (g1:Group {name:{name}})-[r:MemberOf*1..]->(g2:Group) RETURN p", {name: this.state.label},
this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Foreign Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroupMembership !== -1}
value={this.state.foreignGroupMembership}
click={function(){
emitter.emit('query', "MATCH (n:Group) WHERE NOT n.name ENDS WITH {domain} WITH n MATCH (m:Group {name:{name}}) MATCH (m)-[r:MemberOf]->(n) RETURN m,r,n", {name: this.state.label, domain: domain});
}.bind(this)}
/>
</dd>
<h4>Local Admin Rights</h4>
<dt>
First Degree Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.directAdminTo !== -1}
value={this.state.directAdminTo}
click={function(){
emitter.emit('query', "MATCH p=(g:Group {name:{name}})-[r:AdminTo]->(c:Computer) RETURN p", {name: this.state.label},
this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Group Delegated Local Admin Rights
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedAdmin !== -1}
value={this.state.groupDelegatedAdmin}
click={function(){
emitter.emit('query', "MATCH p = (g1:Group {name:{name}})-[r1:MemberOf*1..]->(g2:Group)-[r2:AdminTo]->(c:Computer) RETURN p", {name: this.state.label},
this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Derivative Local Admin Rights
</dt>
<dd>
<NodeALink
ready={this.state.derivativeAdminTo !== -1}
value={this.state.derivativeAdminTo}
click={function(){
emitter.emit('query', "MATCH (c:Computer) WHERE NOT c.name={name} WITH c MATCH p = shortestPath((g:Group {name:{name}})-[r:MemberOf|AdminTo|HasSession*1..]->(c)) RETURN p", {name: this.state.label},
this.state.label);
}.bind(this)}
/>
</dd>
<h4>Outbound Object Control</h4>
<dt>
First Degree Object Control
</dt>
<dd>
<NodeALink
ready={this.state.firstdegreeControl !== -1}
value={this.state.firstdegreeControl}
click={function(){
emitter.emit('query', "MATCH p = (g:Group {name:{name}})-[r1:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Group Delegated Object Control
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedControl !== -1}
value={this.state.groupDelegatedControl}
click={function(){
emitter.emit('query', "MATCH p = (g1:Group {name:{name}})-[r1:MemberOf*1..]->(g2:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Transitive Object Control
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControl !== -1}
value={this.state.transitiveControl}
click={function(){
emitter.emit('query', "MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((g:Group {name:{name}})-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<h4>Inbound Object Control</h4>
<dt>
Explicit Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeControllers !== -1}
value={this.state.firstDegreeControllers}
click={function(){
emitter.emit('query', "MATCH p = (n)-[r:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(g:Group {name: {name}}) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Unrolled Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.unrolledControllers !== -1}
value={this.state.unrolledControllers}
click={function(){
emitter.emit('query', "MATCH p = (n1)-[r:MemberOf*1..]->(g1:Group)-[r1:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(g2:Group {name: {name}}) WITH LENGTH(p) as pathLength, p, n1 WHERE NONE (x in NODES(p)[1..(pathLength-1)] WHERE x.name = g2.name) AND NOT n1.name = g2.name RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Transitive Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControllers !== -1}
value={this.state.transitiveControllers}
click={function(){
emitter.emit('query', "MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((n)-[r:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(g:Group {name: {name}})) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
</dl>
</div>
);
}
}
GroupNodeData.propTypes = {
visible : React.PropTypes.bool.isRequired
}
visible : React.PropTypes.bool.isRequired
};

View File

@ -0,0 +1,51 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
export default class NodePropItem extends Component{
constructor(props){
super(props);
}
isArray(object){
return object && typeof object === 'object' && object.constructor === Array;
}
render() {
var val;
var obj = this.props.keyValue;
if (obj.hasOwnProperty('low')){
return [
<dt>{this.props.keyName}</dt>,
<dd>{obj.low}</dd>
];
}else if (this.isArray(obj)){
console.log(obj);
if (obj.length === 0){
return [
<dt>{this.props.keyName}</dt>,
<dd>None</dd>
];
}else{
var elements = [];
$.each(obj, function(index, prop){
elements.push(<dt></dt>);
elements.push(<dd>{prop}</dd>);
});
elements[0] = <dt>Service Principal Names</dt>;
}
return elements;
}else if (typeof obj === 'boolean'){
return [
<dt>{this.props.keyName}</dt>,
<dd>{this.props.keyValue.toString().toTitleCase()}</dd>
];
}else{
return [
<dt>{this.props.keyName}</dt>,
<dd>{this.props.keyValue.toString()}</dd>
];
}
}
}

View File

@ -1,363 +1,432 @@
import React, { Component } from 'react';
import NodeALink from './NodeALink'
import PropTypes from 'prop-types'
import NodeALink from './NodeALink';
import NodePropItem from './NodePropItem';
import PropTypes from 'prop-types';
import { If, Then, Else } from 'react-if';
export default class UserNodeData extends Component {
constructor(){
super();
constructor(){
super();
this.state = {
label: "",
samAccountName: "None",
displayName: "None",
pwdLastChanged: "None",
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
foreignGroupMembership: -1,
firstDegreeLocalAdmin: -1,
groupDelegatedLocalAdmin: -1,
derivativeLocalAdmin: -1,
sessions: -1,
firstdegreeControllers: -1,
unrolledControllers: -1,
transitiveControllers: -1,
firstdegreeControl: -1,
unrolledControl: -1,
transitiveControl: -1,
driversessions : []
}
this.state = {
label: "",
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
foreignGroupMembership: -1,
firstDegreeLocalAdmin: -1,
groupDelegatedLocalAdmin: -1,
derivativeLocalAdmin: -1,
sessions: -1,
firstdegreeControllers: -1,
unrolledControllers: -1,
transitiveControllers: -1,
firstdegreeControl: -1,
unrolledControl: -1,
transitiveControl: -1,
driversessions : [],
propertyMap: {ServicePrincipalNames: []}
};
emitter.on('userNodeClicked', this.getNodeData.bind(this));
}
emitter.on('userNodeClicked', this.getNodeData.bind(this));
}
getNodeData(payload){
$.each(this.state.driversessions,function(index, record){
record.close();
})
getNodeData(payload){
$.each(this.state.driversessions,function(index, record){
record.close();
});
this.setState({
label: payload,
samAccountName: "None",
displayName: "None",
pwdLastChanged: "None",
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
foreignGroupMembership: -1,
firstDegreeLocalAdmin: -1,
groupDelegatedLocalAdmin: -1,
derivativeLocalAdmin: -1,
sessions: -1,
firstdegreeControllers: -1,
unrolledControllers: -1,
transitiveControllers: -1,
firstdegreeControl: -1,
unrolledControl: -1,
transitiveControl: -1
})
this.setState({
label: payload,
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
foreignGroupMembership: -1,
firstDegreeLocalAdmin: -1,
groupDelegatedLocalAdmin: -1,
derivativeLocalAdmin: -1,
sessions: -1,
firstdegreeControllers: -1,
unrolledControllers: -1,
transitiveControllers: -1,
firstdegreeControl: -1,
unrolledControl: -1,
transitiveControl: -1,
propertyMap: {ServicePrincipalNames: []}
});
var domain = '@' + payload.split('@').last()
var domain = '@' + payload.split('@').last();
var s1 = driver.session()
var s2 = driver.session()
var s3 = driver.session()
var s4 = driver.session()
var s5 = driver.session()
var s6 = driver.session()
var s7 = driver.session()
var s8 = driver.session()
var s9 = driver.session()
var s10 = driver.session()
var s11 = driver.session()
var s12 = driver.session()
var s13 = driver.session()
var s1 = driver.session();
var s2 = driver.session();
var s3 = driver.session();
var s4 = driver.session();
var s5 = driver.session();
var s6 = driver.session();
var s7 = driver.session();
var s8 = driver.session();
var s9 = driver.session();
var s10 = driver.session();
var s11 = driver.session();
var s12 = driver.session();
var s13 = driver.session();
s1.run("MATCH (n:Group) WHERE NOT n.name ENDS WITH {domain} WITH n MATCH (m:User {name:{name}}) MATCH (m)-[r:MemberOf*1..]->(n) RETURN count(n)", {name:payload, domain: domain})
.then(function(result){
this.setState({'foreignGroupMembership':result.records[0]._fields[0].low})
s1.close()
}.bind(this))
var props = driver.session();
props.run("MATCH (n:User {name:{name}}) RETURN n", {name: payload})
.then(function(result){
var properties = result.records[0]._fields[0].properties;
this.setState({propertyMap: properties});
props.close();
}.bind(this));
s2.run("MATCH (n:User {name:{name}}), (m:Group), p=(n)-[:MemberOf]->(m) RETURN count(m)", {name:payload})
.then(function(result){
this.setState({'firstDegreeGroupMembership':result.records[0]._fields[0].low})
s2.close()
}.bind(this))
s1.run("MATCH (n:Group) WHERE NOT n.name ENDS WITH {domain} WITH n MATCH (m:User {name:{name}}) MATCH (m)-[r:MemberOf*1..]->(n) RETURN count(n)", {name:payload, domain: domain})
.then(function(result){
this.setState({'foreignGroupMembership':result.records[0]._fields[0].low});
s1.close();
}.bind(this));
s3.run("MATCH p = (n:User {name:{name}})-[r:MemberOf*1..]->(g:Group) RETURN COUNT(DISTINCT(g))", {name:payload})
.then(function(result){
this.setState({'unrolledGroupMembership':result.records[0]._fields[0].low})
s3.close()
}.bind(this))
s2.run("MATCH (n:User {name:{name}}), (m:Group), p=(n)-[:MemberOf]->(m) RETURN count(m)", {name:payload})
.then(function(result){
this.setState({'firstDegreeGroupMembership':result.records[0]._fields[0].low});
s2.close();
}.bind(this));
s4.run("MATCH p = (n:User {name:{name}})-[r:AdminTo]->(c:Computer) RETURN COUNT(DISTINCT(c))", {name:payload})
.then(function(result){
this.setState({'firstDegreeLocalAdmin':result.records[0]._fields[0].low})
s4.close()
}.bind(this))
s3.run("MATCH p = (n:User {name:{name}})-[r:MemberOf*1..]->(g:Group) RETURN COUNT(DISTINCT(g))", {name:payload})
.then(function(result){
this.setState({'unrolledGroupMembership':result.records[0]._fields[0].low});
s3.close();
}.bind(this));
s5.run("MATCH p=(n:User {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(c:Computer) RETURN count(distinct(c))", {name:payload})
.then(function(result){
this.setState({'groupDelegatedLocalAdmin':result.records[0]._fields[0].low})
s5.close()
}.bind(this))
s4.run("MATCH p = (n:User {name:{name}})-[r:AdminTo]->(c:Computer) RETURN COUNT(DISTINCT(c))", {name:payload})
.then(function(result){
this.setState({'firstDegreeLocalAdmin':result.records[0]._fields[0].low});
s4.close();
}.bind(this));
s6.run("MATCH p = shortestPath((n:User {name:{name}})-[r:HasSession|AdminTo|MemberOf*1..]->(c:Computer)) RETURN COUNT(c)", {name:payload})
.then(function(result){
this.setState({'derivativeLocalAdmin':result.records[0]._fields[0].low})
s6.close()
}.bind(this))
s5.run("MATCH p=(n:User {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(c:Computer) RETURN count(distinct(c))", {name:payload})
.then(function(result){
this.setState({'groupDelegatedLocalAdmin':result.records[0]._fields[0].low});
s5.close();
}.bind(this));
s7.run("MATCH p = (n:Computer)-[r:HasSession]->(m:User {name:{name}}) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'sessions':result.records[0]._fields[0].low})
s7.close()
}.bind(this))
s6.run("MATCH (c:Computer) WHERE NOT c.name={name} WITH c MATCH p = shortestPath((n:User {name:{name}})-[r:HasSession|AdminTo|MemberOf*1..]->(c)) RETURN COUNT(c)", {name:payload})
.then(function(result){
this.setState({'derivativeLocalAdmin':result.records[0]._fields[0].low});
s6.close();
}.bind(this));
s8.run("MATCH p = (n)-[r:AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(u1:User {name: {name}}) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstdegreeControllers':result.records[0]._fields[0].low})
s8.close()
}.bind(this))
s7.run("MATCH p = (n:Computer)-[r:HasSession]->(m:User {name:{name}}) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'sessions':result.records[0]._fields[0].low});
s7.close();
}.bind(this));
s9.run("MATCH p = (n1)-[r:MemberOf*1..]->(g:Group)-[r1:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(u:User {name: {name}}) WITH LENGTH(p) as pathLength, p, n1 WHERE NONE (x in NODES(p)[1..(pathLength-1)] WHERE x.name = u.name) AND NOT n1.name = u.name RETURN COUNT(DISTINCT(n1))", {name:payload})
.then(function(result){
this.setState({'unrolledControllers':result.records[0]._fields[0].low})
s9.close()
}.bind(this))
s8.run("MATCH p = (n)-[r:AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(u1:User {name: {name}}) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstdegreeControllers':result.records[0]._fields[0].low});
s8.close();
}.bind(this));
s10.run("MATCH p = shortestPath((n1)-[r1:MemberOf|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(u1:User {name: {name}})) RETURN COUNT(DISTINCT(n1))", {name:payload})
.then(function(result){
this.setState({'transitiveControllers':result.records[0]._fields[0].low})
s10.close()
}.bind(this))
s9.run("MATCH p = (n1)-[r:MemberOf*1..]->(g:Group)-[r1:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(u:User {name: {name}}) WITH LENGTH(p) as pathLength, p, n1 WHERE NONE (x in NODES(p)[1..(pathLength-1)] WHERE x.name = u.name) AND NOT n1.name = u.name RETURN COUNT(DISTINCT(n1))", {name:payload})
.then(function(result){
this.setState({'unrolledControllers':result.records[0]._fields[0].low});
s9.close();
}.bind(this));
s11.run("MATCH p = (u:User {name:{name}})-[r1:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstdegreeControl':result.records[0]._fields[0].low})
s11.close()
}.bind(this))
s10.run("MATCH (n1) WHERE NOT n1.name={name} WITH n1 MATCH p = shortestPath((n1)-[r1:MemberOf|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(u1:User {name: {name}})) RETURN COUNT(DISTINCT(n1))", {name:payload})
.then(function(result){
this.setState({'transitiveControllers':result.records[0]._fields[0].low});
s10.close();
}.bind(this));
s12.run("MATCH p = (u:User {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'unrolledControl':result.records[0]._fields[0].low})
s12.close()
}.bind(this))
s11.run("MATCH p = (u:User {name:{name}})-[r1:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'firstdegreeControl':result.records[0]._fields[0].low});
s11.close();
}.bind(this));
s13.run("MATCH p = shortestPath((u:User {name:{name}})-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'transitiveControl':result.records[0]._fields[0].low})
s13.close()
}.bind(this))
s12.run("MATCH p = (u:User {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'unrolledControl':result.records[0]._fields[0].low});
s12.close();
}.bind(this));
this.setState({'driversessions': [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13]})
}
s13.run("MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((u:User {name:{name}})-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN COUNT(DISTINCT(n))", {name:payload})
.then(function(result){
this.setState({'transitiveControl':result.records[0]._fields[0].low});
s13.close();
}.bind(this));
render() {
var domain = '@' + this.state.label.split('@').last()
return (
<div className={this.props.visible ? "" : "displaynone"}>
<dl className='dl-horizontal'>
this.setState({'driversessions': [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,props]});
}
isArray(object){
return object && typeof object === 'object' && object.constructor === Array;
}
convertToDisplayProp(propName){
var obj = this.state.propertyMap[propName];
var type = typeof obj;
if (type === 'undefined'){
return "No Data";
}else if (obj.hasOwnProperty('low')){
var t = obj.low;
if (t === 0){
return "Never";
}else{
return new Date(obj.low * 1000).toUTCString();
}
}else if (type === 'boolean'){
return obj.toString().toTitleCase();
}else if (obj === ""){
return "None";
}else{
return obj;
}
}
render() {
var domain = '@' + this.state.label.split('@').last();
return (
<div className={this.props.visible ? "" : "displaynone"}>
<dl className='dl-horizontal'>
<h4>
Node Info
User Info
</h4>
<dt>
Name
</dt>
<dd>
{this.state.label}
</dd>
<dt>
SAMAccountName
</dt>
<dd>
{this.state.samAccountName}
</dd>
<dt>
Display Name
</dt>
<dd>
{this.state.displayName}
</dd>
<dt>
Password Last Changed
</dt>
<dd>
{this.state.pwdLastChanged}
</dd>
<dt>
Sessions
</dt>
<dd>
<NodeALink
ready={this.state.sessions !== -1}
value={this.state.sessions}
click={function(){
emitter.emit('query', "MATCH (n:Computer)-[r:HasSession]->(m:User {name:{name}}) RETURN n,r,m", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>Group Membership</h4>
<dt>
First Degree Group Memberships
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeGroupMembership !== -1}
value={this.state.firstDegreeGroupMembership}
click={function(){
emitter.emit(
'query',
"MATCH p = (n:User {name:{name}})-[r:MemberOf]->(g:Group) RETURN p", {name:this.state.label}
)
}.bind(this)} />
</dd>
<dt>
Unrolled Group Memberships
</dt>
<dd>
<NodeALink
ready={this.state.unrolledGroupMembership !== -1}
value={this.state.unrolledGroupMembership}
click={function(){
emitter.emit('query', "MATCH p = (n:User {name:{name}})-[r:MemberOf*1..]->(g:Group) RETURN p", {name:this.state.label},
this.state.label)
}.bind(this)} />
</dd>
<dt>
Foreign Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroupMembership !== -1}
value={this.state.foreignGroupMembership}
click={function(){
emitter.emit('query',
"MATCH (n:Group) WHERE NOT n.name ENDS WITH {domain} WITH n MATCH (m:User {name:{name}}) WITH n,m MATCH p = (m)-[r:MemberOf*1..]->(n) RETURN p", {name: this.state.label, domain: domain})
}.bind(this)} />
</dd>
<br />
<h4>
Local Admin Rights
</h4>
<dt>
First Degree Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeLocalAdmin !== -1}
value={this.state.firstDegreeLocalAdmin}
click={function(){
emitter.emit('query', "MATCH p = (n:User {name:{name}})-[r:AdminTo]->(c:Computer) RETURN p", {name:this.state.label})
}.bind(this)} />
</dd>
<dt>
Group Delegated Local Admin Rights
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedLocalAdmin !== -1}
value={this.state.groupDelegatedLocalAdmin}
click={function(){
emitter.emit('query', "MATCH p=(n:User {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(c:Computer) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<dt>
Derivative Local Admin Rights
</dt>
<dd>
<NodeALink
ready={this.state.derivativeLocalAdmin !== -1}
value={this.state.derivativeLocalAdmin}
click={function(){
emitter.emit('query', "MATCH p = shortestPath((n:User {name:{name}})-[r:HasSession|AdminTo|MemberOf*1..]->(c:Computer)) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>
Outbound Object Control
</h4>
<dt>
First Degree Object Control
</dt>
<dd>
<NodeALink
ready={this.state.firstdegreeControl !== -1}
value={this.state.firstdegreeControl}
click={function(){
emitter.emit('query', "MATCH p = (u:User {name:{name}})-[r1:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label})
}.bind(this)} />
</dd>
<dt>
Group Delegated Object Control
</dt>
<dd>
<NodeALink
ready={this.state.unrolledControl !== -1}
value={this.state.unrolledControl}
click={function(){
emitter.emit('query', "MATCH p = (u:User {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<dt>
Transitive Object Control
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControl !== -1}
value={this.state.transitiveControl}
click={function(){
emitter.emit('query', "MATCH p = shortestPath((u:User {name:{name}})-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<br />
<h4>Inbound Object Control</h4>
<dt>
Explicit Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.firstdegreeControllers !== -1}
value={this.state.firstdegreeControllers}
click={function(){
emitter.emit('query', "MATCH p = (n)-[r:AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(u1:User {name: {name}}) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<dt>
Unrolled Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.unrolledControllers !== -1}
value={this.state.unrolledControllers}
click={function(){
emitter.emit('query', "MATCH p = (n1)-[r:MemberOf*1..]->(g:Group)-[r1:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(u:User {name: {name}}) WITH LENGTH(p) as pathLength, p, n1 WHERE NONE (x in NODES(p)[1..(pathLength-1)] WHERE x.name = u.name) AND NOT n1.name = u.name RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
<dt>
Transitive Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControllers !== -1}
value={this.state.transitiveControllers}
click={function(){
emitter.emit('query', "MATCH p = shortestPath((n1)-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(u1:User {name: {name}})) RETURN p", {name:this.state.label}
,this.state.label)
}.bind(this)} />
</dd>
</dl>
</div>
);
}
<dt>
Name
</dt>
<dd>
{this.state.label}
</dd>
<dt>
Display Name
</dt>
<dd>
{this.convertToDisplayProp("DisplayName")}
</dd>
<dt>
Password Last Changed
</dt>
<dd>
{this.convertToDisplayProp("PwdLastSet")}
</dd>
<dt>
Last Logon
</dt>
<dd>
{this.convertToDisplayProp("LastLogon")}
</dd>
<dt>
Enabled
</dt>
<dd>
{this.convertToDisplayProp("Enabled")}
</dd>
<dt>
Email
</dt>
<dd>
{this.convertToDisplayProp("Email")}
</dd>
<dt>
Service Principal Names
</dt>
{(() => {
if (this.state.propertyMap.ServicePrincipalNames.length === 0){
return <dd>None</dd>;
}
})()}
{Object.keys(this.state.propertyMap.ServicePrincipalNames).map(function(key){
var x = <dd key={key}>{this.state.propertyMap.ServicePrincipalNames[key]}</dd>;
return x;
}.bind(this))}
<dt>
Sessions
</dt>
<dd>
<NodeALink
ready={this.state.sessions !== -1}
value={this.state.sessions}
click={function(){
emitter.emit('query', "MATCH (n:Computer)-[r:HasSession]->(m:User {name:{name}}) RETURN n,r,m", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<h4>Group Membership</h4>
<dt>
First Degree Group Memberships
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeGroupMembership !== -1}
value={this.state.firstDegreeGroupMembership}
click={function(){
emitter.emit(
'query',
"MATCH p = (n:User {name:{name}})-[r:MemberOf]->(g:Group) RETURN p", {name:this.state.label}
);
}.bind(this)}
/>
</dd>
<dt>
Unrolled Group Memberships
</dt>
<dd>
<NodeALink
ready={this.state.unrolledGroupMembership !== -1}
value={this.state.unrolledGroupMembership}
click={function(){
emitter.emit('query', "MATCH p = (n:User {name:{name}})-[r:MemberOf*1..]->(g:Group) RETURN p", {name:this.state.label},
this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Foreign Group Membership
</dt>
<dd>
<NodeALink
ready={this.state.foreignGroupMembership !== -1}
value={this.state.foreignGroupMembership}
click={function(){
emitter.emit('query',
"MATCH (n:Group) WHERE NOT n.name ENDS WITH {domain} WITH n MATCH (m:User {name:{name}}) WITH n,m MATCH p = (m)-[r:MemberOf*1..]->(n) RETURN p", {name: this.state.label, domain: domain});
}.bind(this)}
/>
</dd>
<h4>
Local Admin Rights
</h4>
<dt>
First Degree Local Admin
</dt>
<dd>
<NodeALink
ready={this.state.firstDegreeLocalAdmin !== -1}
value={this.state.firstDegreeLocalAdmin}
click={function(){
emitter.emit('query', "MATCH p = (n:User {name:{name}})-[r:AdminTo]->(c:Computer) RETURN p", {name:this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Group Delegated Local Admin Rights
</dt>
<dd>
<NodeALink
ready={this.state.groupDelegatedLocalAdmin !== -1}
value={this.state.groupDelegatedLocalAdmin}
click={function(){
emitter.emit('query', "MATCH p=(n:User {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AdminTo]->(c:Computer) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Derivative Local Admin Rights
</dt>
<dd>
<NodeALink
ready={this.state.derivativeLocalAdmin !== -1}
value={this.state.derivativeLocalAdmin}
click={function(){
emitter.emit('query', "MATCH (c:Computer) WHERE NOT c.name={name} WITH c MATCH p = shortestPath((n:User {name:{name}})-[r:HasSession|AdminTo|MemberOf*1..]->(c)) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<h4>
Outbound Object Control
</h4>
<dt>
First Degree Object Control
</dt>
<dd>
<NodeALink
ready={this.state.firstdegreeControl !== -1}
value={this.state.firstdegreeControl}
click={function(){
emitter.emit('query', "MATCH p = (u:User {name:{name}})-[r1:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label});
}.bind(this)}
/>
</dd>
<dt>
Group Delegated Object Control
</dt>
<dd>
<NodeALink
ready={this.state.unrolledControl !== -1}
value={this.state.unrolledControl}
click={function(){
emitter.emit('query', "MATCH p = (u:User {name:{name}})-[r1:MemberOf*1..]->(g:Group)-[r2:AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(n) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Transitive Object Control
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControl !== -1}
value={this.state.transitiveControl}
click={function(){
emitter.emit('query', "MATCH (n) WHERE NOT n.name={name} WITH n MATCH p = shortestPath((u:User {name:{name}})-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(n)) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<h4>Inbound Object Control</h4>
<dt>
Explicit Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.firstdegreeControllers !== -1}
value={this.state.firstdegreeControllers}
click={function(){
emitter.emit('query', "MATCH p = (n)-[r:AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(u1:User {name: {name}}) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Unrolled Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.unrolledControllers !== -1}
value={this.state.unrolledControllers}
click={function(){
emitter.emit('query', "MATCH p = (n1)-[r:MemberOf*1..]->(g:Group)-[r1:AddMembers|AllExtendedRights|GenericAll|GenericWrite|WriteDacl|WriteOwner]->(u:User {name: {name}}) WITH LENGTH(p) as pathLength, p, n1 WHERE NONE (x in NODES(p)[1..(pathLength-1)] WHERE x.name = u.name) AND NOT n1.name = u.name RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
<dt>
Transitive Object Controllers
</dt>
<dd>
<NodeALink
ready={this.state.transitiveControllers !== -1}
value={this.state.transitiveControllers}
click={function(){
emitter.emit('query', "MATCH (n1) WHERE NOT n1.name={name} WITH n1 MATCH p = shortestPath((n1)-[r1:MemberOf|AddMembers|AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|WriteDacl|WriteOwner*1..]->(u1:User {name: {name}})) RETURN p", {name:this.state.label}
,this.state.label);
}.bind(this)}
/>
</dd>
</dl>
</div>
);
}
}
UserNodeData.propTypes = {
visible : React.PropTypes.bool.isRequired
}
visible : PropTypes.bool.isRequired
};

View File

@ -4,6 +4,7 @@
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
.max{
@ -94,6 +95,13 @@ div.tooltip-inner-custom {
width: 100%;
height: 100%;
background-color: lightgray;
overflow: hidden;
}
.dropdown-item > i{
float:right;
margin-top:3px;
margin-left: 2px;
}
.graph:focus {
@ -187,6 +195,12 @@ div.tooltip-inner-custom {
margin-bottom: 1em;
}
.dl-horizontal > h4 {
margin-top: 10px;
margin-bottom: 5px;
color: blue;
}
.dl-horizontal{
margin-right: 10px;
}
@ -763,7 +777,6 @@ div.tooltip-inner-custom {
}
.tab-content > div:nth-last-child(2) > div{
height: 600px;
max-height: 600px;
overflow-y: auto;
resize: vertical;
}

View File

@ -106,10 +106,11 @@ global.appStore = {
'ForceChangePassword': 'tapered',
'GenericAll': 'tapered',
'GenericWrite': 'tapered',
'WriteDACL': 'tapered',
'WriteDacl': 'tapered',
'WriteOwner': 'tapered',
'AddMembers': 'tapered',
'TrustedBy': 'curvedArrow'
'TrustedBy': 'curvedArrow',
'DCSync' : 'tapered'
}
},
lowResPalette: {

File diff suppressed because one or more lines are too long

View File

@ -10,32 +10,32 @@ export function generateUniqueId(sigmaInstance, isNode) {
}
}
return i
return i;
}
//Recursive function to highlight paths to start/end nodes
export function findGraphPath(sigmaInstance, reverse, nodeid) {
var target = reverse ? appStore.startNode : appStore.endNode
var target = reverse ? appStore.startNode : appStore.endNode;
//This is our stop condition for recursing
if (nodeid !== target.id) {
var edges = sigmaInstance.graph.adjacentEdges(nodeid)
var nodes = reverse ? sigmaInstance.graph.inboundNodes(nodeid) : sigmaInstance.graph.outboundNodes(nodeid)
var edges = sigmaInstance.graph.adjacentEdges(nodeid);
var nodes = reverse ? sigmaInstance.graph.inboundNodes(nodeid) : sigmaInstance.graph.outboundNodes(nodeid);
//Loop over the nodes near us and the edges connecting to those nodes
$.each(nodes, function(index, node) {
$.each(edges, function(index, edge) {
var check = reverse ? edge.source : edge.target
var check = reverse ? edge.source : edge.target;
//If an edge is pointing in the right direction, set its color
//Push the edge into our store and then
node = parseInt(node)
node = parseInt(node);
if (check === node) {
edge.color = reverse ? 'blue' : 'red';
appStore.highlightedEdges.push(edge);
findGraphPath(sigmaInstance, reverse, node);
}
})
})
});
});
} else {
return
return;
}
}
@ -45,192 +45,211 @@ export function clearSessions(){
}
function deleteSessions(){
var session = driver.session()
var session = driver.session();
session.run("MATCH ()-[r:HasSession]-() WITH r LIMIT 100000 DELETE r RETURN count(r)")
.then(function(results) {
session.close()
emitter.emit("refreshDBData")
var count = results.records[0]._fields[0].low
session.close();
emitter.emit("refreshDBData");
var count = results.records[0]._fields[0].low;
if (count === 0) {
emitter.emit('hideDBClearModal')
emitter.emit('hideDBClearModal');
} else {
deleteSessions();
}
})
});
}
export function clearDatabase() {
emitter.emit('openClearingModal');
deleteEdges()
deleteEdges();
}
function deleteEdges() {
var session = driver.session()
var session = driver.session();
session.run("MATCH ()-[r]-() WITH r LIMIT 100000 DELETE r RETURN count(r)")
.then(function(results) {
emitter.emit("refreshDBData");
session.close()
var count = results.records[0]._fields[0].low
session.close();
var count = results.records[0]._fields[0].low;
if (count === 0) {
deleteNodes()
deleteNodes();
} else {
deleteEdges()
deleteEdges();
}
})
});
}
function deleteNodes() {
var session = driver.session()
var session = driver.session();
session.run("MATCH (n) WITH n LIMIT 100000 DELETE n RETURN count(n)")
.then(function(results) {
emitter.emit("refreshDBData")
session.close()
var count = results.records[0]._fields[0].low
emitter.emit("refreshDBData");
session.close();
var count = results.records[0]._fields[0].low;
if (count === 0) {
emitter.emit('hideDBClearModal')
emitter.emit('hideDBClearModal');
} else {
deleteNodes()
deleteNodes();
}
})
});
}
export function findObjectType(header){
if (header.includes('UserName') && header.includes('ComputerName') && header.includes('Weight')){
return 'sessions';
}else if (header.includes('AccountName') && header.includes('AccountType') && header.includes('GroupName')){
return 'groupmembership';
}else if (header.includes('AccountName') && header.includes('AccountType') && header.includes('ComputerName')){
return 'localadmin';
}else if (header.includes('SourceDomain') && header.includes('TargetDomain') && header.includes('TrustDirection') && header.includes('TrustType') && header.includes('Transitive')){
return 'domain';
}else if (header.includes('ActiveDirectoryRights') && header.includes('ObjectType') && header.includes('PrincipalType') && header.includes('PrincipalName') && header.includes('ObjectName') && header.includes('ACEType') && header.includes('AccessControlType') && header.includes('IsInherited')){
return 'acl';
}else if (header.includes('AccountName') && header.includes('Enabled') && header.includes('PwdLastSet') && header.includes('LastLogon') && header.includes('Sid') && header.includes('SidHistory') && header.includes('HasSPN') && header.includes('ServicePrincipalNames')){
return 'userprops';
}else if (header.includes('AccountName') && header.includes('Enabled') && header.includes('PwdLastSet') && header.includes('LastLogon') && header.includes('OperatingSystem') && header.includes('Sid')){
return 'compprops';
}else{
return 'unknown';
}
}
export function buildGroupMembershipProps(rows) {
var users = []
var groups = []
var computers = []
var users = [];
var groups = [];
var computers = [];
$.each(rows, function(index, row) {
switch (row.AccountType) {
case 'user':
users.push({ account: row.AccountName.toUpperCase(), group: row.GroupName.toUpperCase() })
break
users.push({ account: row.AccountName.toUpperCase(), group: row.GroupName.toUpperCase() });
break;
case 'computer':
computers.push({ account: row.AccountName.toUpperCase(), group: row.GroupName.toUpperCase() })
break
computers.push({ account: row.AccountName.toUpperCase(), group: row.GroupName.toUpperCase() });
break;
case 'group':
groups.push({ account: row.AccountName.toUpperCase(), group: row.GroupName.toUpperCase() })
break
groups.push({ account: row.AccountName.toUpperCase(), group: row.GroupName.toUpperCase() });
break;
}
})
});
return { users: users, groups: groups, computers: computers }
return { users: users, groups: groups, computers: computers };
}
export function buildLocalAdminProps(rows) {
var users = []
var groups = []
var computers = []
var users = [];
var groups = [];
var computers = [];
$.each(rows, function(index, row) {
if (row.AccountName.startsWith('@')) {
return
return;
}
switch (row.AccountType) {
case 'user':
users.push({ account: row.AccountName.toUpperCase(), computer: row.ComputerName.toUpperCase() })
users.push({ account: row.AccountName.toUpperCase(), computer: row.ComputerName.toUpperCase() });
break;
case 'group':
groups.push({ account: row.AccountName.toUpperCase(), computer: row.ComputerName.toUpperCase() })
groups.push({ account: row.AccountName.toUpperCase(), computer: row.ComputerName.toUpperCase() });
break;
case 'computer':
computers.push({ account: row.AccountName.toUpperCase(), computer: row.ComputerName.toUpperCase() })
break
computers.push({ account: row.AccountName.toUpperCase(), computer: row.ComputerName.toUpperCase() });
break;
}
})
return { users: users, groups: groups, computers: computers }
});
return { users: users, groups: groups, computers: computers };
}
export function buildSessionProps(rows) {
var sessions = []
var sessions = [];
$.each(rows, function(index, row) {
if (row.UserName === 'ANONYMOUS LOGON@UNKNOWN' || row.UserName === '') {
return
return;
}
sessions.push({ account: row.UserName.toUpperCase(), computer: row.ComputerName.toUpperCase(), weight: row.Weight })
})
sessions.push({ account: row.UserName.toUpperCase(), computer: row.ComputerName.toUpperCase(), weight: row.Weight });
});
return sessions
return sessions;
}
export function buildDomainProps(rows) {
var domains = []
var domains = [];
$.each(rows, function(index, row) {
switch (row.TrustDirection) {
case 'Inbound':
domains.push({ domain1: row.TargetDomain.toUpperCase(), domain2: row.SourceDomain.toUpperCase(), trusttype: row.TrustType, transitive: row.Transitive })
domains.push({ domain1: row.TargetDomain.toUpperCase(), domain2: row.SourceDomain.toUpperCase(), trusttype: row.TrustType, transitive: row.Transitive });
break;
case 'Outbound':
domains.push({ domain1: row.SourceDomain.toUpperCase(), domain2: row.TargetDomain.toUpperCase(), trusttype: row.TrustType, transitive: row.Transitive })
domains.push({ domain1: row.SourceDomain.toUpperCase(), domain2: row.TargetDomain.toUpperCase(), trusttype: row.TrustType, transitive: row.Transitive });
break;
case 'Bidirectional':
domains.push({ domain1: row.TargetDomain.toUpperCase(), domain2: row.SourceDomain.toUpperCase(), trusttype: row.TrustType, transitive: row.Transitive })
domains.push({ domain1: row.SourceDomain.toUpperCase(), domain2: row.TargetDomain.toUpperCase(), trusttype: row.TrustType, transitive: row.Transitive })
break
domains.push({ domain1: row.TargetDomain.toUpperCase(), domain2: row.SourceDomain.toUpperCase(), trusttype: row.TrustType, transitive: row.Transitive });
domains.push({ domain1: row.SourceDomain.toUpperCase(), domain2: row.TargetDomain.toUpperCase(), trusttype: row.TrustType, transitive: row.Transitive });
break;
}
})
});
return domains
return domains;
}
export function buildACLProps(rows) {
var datadict = {}
var datadict = {};
$.each(rows, function(index, row) {
var b = row.ObjectName.toUpperCase()
var a = row.PrincipalName.toUpperCase()
var btype = row.ObjectType.toTitleCase()
var atype = row.PrincipalType.toTitleCase()
var rel = row.ActiveDirectoryRights
var extright = row.ACEType
var b = row.ObjectName.toUpperCase();
var a = row.PrincipalName.toUpperCase();
var btype = row.ObjectType.toTitleCase();
var atype = row.PrincipalType.toTitleCase();
var rel = row.ActiveDirectoryRights;
var extright = row.ACEType;
var rights = []
var rights = [];
if (extright === 'All'){
rights.push("AllExtendedRights")
rights.push("AllExtendedRights");
}else if (extright === 'User-Force-Change-Password'){
rights.push("ForceChangePassword")
rights.push("ForceChangePassword");
}else if (rel === "ExtendedRight"){
rights.push(extright)
rights.push(extright);
}
if (rel.includes("GenericAll")){
rights.push("GenericAll")
rights.push("GenericAll");
}
if (rel.includes("WriteDacl")){
rights.push("WriteDacl")
rights.push("WriteDacl");
}
if (rel.includes("WriteOwner")){
rights.push("WriteOwner")
rights.push("WriteOwner");
}
if (rel.includes("GenericWrite")){
rights.push("GenericWrite")
rights.push("GenericWrite");
}
if (rel.includes("WriteProperty") && extright === "Member"){
rights.push("AddMember")
rights.push("AddMember");
}
$.each(rights, function(index, record){
var hash = (atype + record + btype).toUpperCase()
var hash = (atype + record + btype).toUpperCase();
if (btype === 'Computer') {
return
return;
}
if (datadict[hash]) {
datadict[hash].props.push({
account: a,
principal: b
})
});
} else {
datadict[hash] = {
statement: 'UNWIND {props} AS prop MERGE (a:{} {name:prop.account}) WITH a,prop MERGE (b:{} {name: prop.principal}) WITH a,b,prop MERGE (a)-[r:{} {isACL:true}]->(b)'.format(atype, btype, record),
props: [{ account: a, principal: b }]
}
};
}
})
});
});
})
return datadict
return datadict;
}

View File

@ -1,5 +1,5 @@
global.sigma = require('linkurious')
require('./sigma.helpers.graph.min.js')
global.sigma = require('linkurious');
require('./sigma.helpers.graph.min.js');
Array.prototype.allEdgesSameType = function() {
for (var i = 1; i < this.length; i++) {
@ -18,192 +18,192 @@ sigma.classes.graph.addMethod('inboundNodes', function(id) {
return this.inNeighborsIndex.get(id).keyList();
});
var sigmaInstance = new sigma()
var sigmaInstance = new sigma();
process.on('message', function(m){
var data = JSON.parse(m)
params = {edge: data.edge,sibling: data.sibling, start: data.start, end: data.end}
var spotlightData = {}
sigmaInstance.graph.clear()
sigmaInstance.graph.read(data.graph)
sigmaInstance.graph.nodes().forEach(function(node){
node.degree = sigmaInstance.graph.degree(node.id)
})
var result = collapseEdgeNodes(sigmaInstance, params, spotlightData)
sigmaInstance = result[0]
spotlightData = result[1]
result = collapseSiblingNodes(sigmaInstance, params, spotlightData)
sigmaInstance = result[0]
spotlightData = result[1]
sigmaInstance.graph.nodes().forEach(function(node) {
var data = JSON.parse(m);
params = {edge: data.edge,sibling: data.sibling, start: data.start, end: data.end};
var spotlightData = {};
sigmaInstance.graph.clear();
sigmaInstance.graph.read(data.graph);
sigmaInstance.graph.nodes().forEach(function(node){
node.degree = sigmaInstance.graph.degree(node.id);
});
var result = collapseEdgeNodes(sigmaInstance, params, spotlightData);
sigmaInstance = result[0];
spotlightData = result[1];
result = collapseSiblingNodes(sigmaInstance, params, spotlightData);
sigmaInstance = result[0];
spotlightData = result[1];
sigmaInstance.graph.nodes().forEach(function(node) {
if (!spotlightData.hasOwnProperty(node.id)) {
spotlightData[node.id] = [node.label, 0, "", node.type, ""];
}
});
var toSend = {nodes: sigmaInstance.graph.nodes(), edges: sigmaInstance.graph.edges(), spotlight: spotlightData}
process.send(toSend)
})
var toSend = {nodes: sigmaInstance.graph.nodes(), edges: sigmaInstance.graph.edges(), spotlight: spotlightData};
process.send(toSend);
});
function collapseEdgeNodes(sigmaInstance, params, spotlightData){
var threshold = params.edge;
var threshold = params.edge;
if (threshold == 0){
return [sigmaInstance, spotlightData]
}
sigmaInstance.graph.nodes().forEach(function(node){
if (node.degree < threshold){
return
}
if (threshold == 0){
return [sigmaInstance, spotlightData];
}
sigmaInstance.graph.nodes().forEach(function(node){
if (node.degree < threshold){
return;
}
sigmaInstance.graph.adjacentNodes(node.id).forEach(function(anode){
if (params.end !== null && anode.label === params.end){
return
}
sigmaInstance.graph.adjacentNodes(node.id).forEach(function(anode){
if (params.end !== null && anode.label === params.end){
return;
}
if (params.start !== null && anode.label === params.start){
return
}
if (params.start !== null && anode.label === params.start){
return;
}
var edges = sigmaInstance.graph.adjacentEdges(anode.id);
if ((edges.length > 1 || edges.length === 0) || (anode.folded.nodes.length > 0)){
return
}
var edges = sigmaInstance.graph.adjacentEdges(anode.id);
if ((edges.length > 1 || edges.length === 0) || (anode.folded.nodes.length > 0)){
return;
}
var edge = edges[0];
var edge = edges[0];
if ((anode.type_user)
|| (anode.type_computer)
|| (anode.type_group && edge.label === 'AdminTo')){
if ((anode.type_user)
|| (anode.type_computer)
|| (anode.type_group && edge.label === 'AdminTo')){
node.isGrouped = true
node.folded.nodes.push(anode)
node.folded.edges.push(edge)
spotlightData[anode.id] = [anode.label, node.id, node.label, anode.type, node.type];
sigmaInstance.graph.dropNode(anode.id);
}
});
if (node.folded.nodes.length > 0){
node.glyphs.push({
'position': 'bottom-left',
'content': node.folded.nodes.length
})
}
})
node.isGrouped = true;
node.folded.nodes.push(anode);
node.folded.edges.push(edge);
spotlightData[anode.id] = [anode.label, node.id, node.label, anode.type, node.type];
sigmaInstance.graph.dropNode(anode.id);
}
});
if (node.folded.nodes.length > 0){
node.glyphs.push({
'position': 'bottom-left',
'content': node.folded.nodes.length
});
}
});
return [sigmaInstance, spotlightData]
return [sigmaInstance, spotlightData];
}
function collapseSiblingNodes(sigmaInstance, params, spotlightData){
var threshold = params.sibling
var threshold = params.sibling;
if (threshold === 0){
return [sigmaInstance, spotlightData]
}
if (threshold === 0){
return [sigmaInstance, spotlightData];
}
sigmaInstance.graph.nodes().forEach(function(node){
//Dont apply this logic to anything thats folded or isn't a computer
if (!node.type_computer || node.folded.nodes.length > 0){
return
}
sigmaInstance.graph.nodes().forEach(function(node){
//Dont apply this logic to anything thats folded or isn't a computer
if (!node.type_computer || node.folded.nodes.length > 0){
return;
}
//Start by getting all the edges attached to this node
var adjacent = sigmaInstance.graph.adjacentEdges(node.id)
var siblings = []
//Start by getting all the edges attached to this node
var adjacent = sigmaInstance.graph.adjacentEdges(node.id);
var siblings = [];
//Check to see if all the edges are the same type (i.e. AdminTo)
if (adjacent.length > 1 && adjacent.allEdgesSameType()){
//Get the "parents" by mapping the source from every edge
var parents = adjacent.map(
function(e){
return e.source
}
)
//Check to see if all the edges are the same type (i.e. AdminTo)
if (adjacent.length > 1 && adjacent.allEdgesSameType()){
//Get the "parents" by mapping the source from every edge
var parents = adjacent.map(
function(e){
return e.source;
}
);
//Generate our string to compare other nodes to
//by sorting the parents and turning it into a string
var checkString = parents.sort().join(',')
var testString;
//Generate our string to compare other nodes to
//by sorting the parents and turning it into a string
var checkString = parents.sort().join(',');
var testString;
//Loop back over nodes in the graph and look for any nodes
//with identical parents
sigmaInstance.graph.nodes().forEach(function(node2){
testString = sigmaInstance.graph.adjacentEdges(node2.id).map(
function(e){
return e.source;
}
).sort().join(',')
if (testString === checkString){
siblings.push(node2);
}
});
//Loop back over nodes in the graph and look for any nodes
//with identical parents
sigmaInstance.graph.nodes().forEach(function(node2){
testString = sigmaInstance.graph.adjacentEdges(node2.id).map(
function(e){
return e.source;
}
).sort().join(',');
if (testString === checkString){
siblings.push(node2);
}
});
if (siblings.length >= threshold){
//Generate a new ID for our grouped node
var nodeId = generateUniqueId(sigmaInstance, true);
if (siblings.length >= threshold){
//Generate a new ID for our grouped node
var nodeId = generateUniqueId(sigmaInstance, true);
sigmaInstance.graph.addNode({
id: nodeId,
x: node.x,
y: node.y,
degree: siblings.length,
label: "Grouped Computers",
type: 'Computer',
type_computer: true,
groupedNode: true,
glyphs: [{
position: 'bottom-left',
content: siblings.length
}],
folded: {
nodes: [],
edges: []
}
});
sigmaInstance.graph.addNode({
id: nodeId,
x: node.x,
y: node.y,
degree: siblings.length,
label: "Grouped Computers",
type: 'Computer',
type_computer: true,
groupedNode: true,
glyphs: [{
position: 'bottom-left',
content: siblings.length
}],
folded: {
nodes: [],
edges: []
}
});
//Generate new edges for each parent going to our new node
parents.forEach(function(parent){
var id = generateUniqueId(sigmaInstance, false);
//Generate new edges for each parent going to our new node
parents.forEach(function(parent){
var id = generateUniqueId(sigmaInstance, false);
sigmaInstance.graph.addEdge({
id: id,
source: parent,
target: nodeId,
label: 'AdminTo',
neo4j_type: 'AdminTo',
size: 1
})
})
sigmaInstance.graph.addEdge({
id: id,
source: parent,
target: nodeId,
label: 'AdminTo',
neo4j_type: 'AdminTo',
size: 1
});
});
var n = sigmaInstance.graph.nodes(nodeId);
//Loop over all the siblings, and push the edges into our new parent node
//Push the nodes in as well so we can unfold them
siblings.forEach(function(sibling){
sigmaInstance.graph.adjacentEdges(sibling.id).forEach(function(edge){
n.folded.edges.push(edge)
})
var n = sigmaInstance.graph.nodes(nodeId);
//Loop over all the siblings, and push the edges into our new parent node
//Push the nodes in as well so we can unfold them
siblings.forEach(function(sibling){
sigmaInstance.graph.adjacentEdges(sibling.id).forEach(function(edge){
n.folded.edges.push(edge);
});
n.folded.nodes.push(sibling)
spotlightData[sibling.id] = [sibling.label, nodeId, n.label, sibling.type, n.type];
sigmaInstance.graph.dropNode(sibling.id)
})
}
}
})
return [sigmaInstance, spotlightData]
n.folded.nodes.push(sibling);
spotlightData[sibling.id] = [sibling.label, nodeId, n.label, sibling.type, n.type];
sigmaInstance.graph.dropNode(sibling.id);
});
}
}
});
return [sigmaInstance, spotlightData];
}
function generateUniqueId(sigmaInstance, isNode){
var i = Math.floor(Math.random() * (100000 - 10 + 1)) + 10;
if (isNode){
while (typeof sigmaInstance.graph.nodes(i) !== 'undefined'){
i = Math.floor(Math.random() * (100000 - 10 + 1)) + 10;
}
}else{
while (typeof sigmaInstance.graph.edges(i) !== 'undefined'){
i = Math.floor(Math.random() * (100000 - 10 + 1)) + 10;
}
}
var i = Math.floor(Math.random() * (100000 - 10 + 1)) + 10;
if (isNode){
while (typeof sigmaInstance.graph.nodes(i) !== 'undefined'){
i = Math.floor(Math.random() * (100000 - 10 + 1)) + 10;
}
}else{
while (typeof sigmaInstance.graph.edges(i) !== 'undefined'){
i = Math.floor(Math.random() * (100000 - 10 + 1)) + 10;
}
}
return i
return i;
}