Skip to content

Commit

Permalink
Add new properties to user/computer
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Oct 5, 2017
1 parent 200d698 commit 5f366ac
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 52 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"babel": {
"presets": [
"es2015",
"env",
"stage-0",
"react"
]
Expand All @@ -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",
Expand Down
51 changes: 31 additions & 20 deletions src/components/SearchContainer/Tabs/ComputerNodeData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export default class ComputerNodeData extends Component {

this.state = {
label: "",
os: "None",
unconstrained: "None",
explicitAdmins: -1,
unrolledAdmins: -1,
firstDegreeGroupMembership: -1,
Expand All @@ -22,7 +20,8 @@ export default class ComputerNodeData extends Component {
groupDelegatedControl: -1,
transitiveControl: -1,
derivativeLocalAdmins: -1,
driversessions: []
driversessions: [],
propertyMap: {}
};

emitter.on('computerNodeClicked', this.getNodeData.bind(this));
Expand All @@ -34,8 +33,6 @@ export default class ComputerNodeData extends Component {
});
this.setState({
label: payload,
os: "None",
unconstrained: "None",
explicitAdmins: -1,
unrolledAdmins: -1,
firstDegreeGroupMembership: -1,
Expand All @@ -47,7 +44,8 @@ export default class ComputerNodeData extends Component {
firstdegreeControl: -1,
groupDelegatedControl: -1,
transitiveControl: -1,
derivativeLocalAdmins: -1
derivativeLocalAdmins: -1,
propertyMap: {}
});

var s1 = driver.session();
Expand All @@ -66,14 +64,9 @@ export default class ComputerNodeData extends Component {

var propCollection = driver.session();
propCollection.run("MATCH (c:Computer {name:{name}}) RETURN c", {name:payload})
.then(function(results){
var props = results.records[0]._fields[0].properties;
if (props.hasOwnProperty('UnconstrainedDelegation')){
this.setState({'unconstrained': props.UnconstrainedDelegation.toString().toTitleCase()});
}
if (props.hasOwnProperty('OperatingSystem')){
this.setState({'os': props.OperatingSystem});
}
.then(function(result){
var properties = result.records[0]._fields[0].properties;
this.setState({propertyMap: properties});
propCollection.close();
}.bind(this));

Expand Down Expand Up @@ -158,6 +151,22 @@ export default class ComputerNodeData extends Component {
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')){
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"}>
Expand All @@ -173,13 +182,19 @@ export default class ComputerNodeData extends Component {
OS
</dt>
<dd>
{this.state.os}
{this.convertToDisplayProp("OperatingSystem")}
</dd>
<dt>
Enabled
</dt>
<dd>
{this.convertToDisplayProp("Enabled")}
</dd>
<dt>
Allows Unconstrained Delegation
</dt>
<dd>
{this.state.unconstrained}
{this.convertToDisplayProp("UnconstrainedDelegation")}
</dd>
<dt>
Sessions
Expand All @@ -194,7 +209,6 @@ export default class ComputerNodeData extends Component {
}.bind(this)}
/>
</dd>
<br />
<h4>Local Admins</h4>
<dt>
Explicit Admins
Expand Down Expand Up @@ -237,7 +251,6 @@ export default class ComputerNodeData extends Component {
}.bind(this)}
/>
</dd>
<br />
<h4>Group Memberships</h4>
<dt>
First Degree Group Membership
Expand Down Expand Up @@ -278,7 +291,6 @@ export default class ComputerNodeData extends Component {
}.bind(this)}
/>
</dd>
<br />
<h4>Local Admin Rights</h4>
<dt>
First Degree Local Admin
Expand Down Expand Up @@ -319,7 +331,6 @@ export default class ComputerNodeData extends Component {
}.bind(this)}
/>
</dd>
<br />
<h4>Outbound Object Control</h4>
<dt>
First Degree Object Control
Expand Down
51 changes: 51 additions & 0 deletions src/components/SearchContainer/Tabs/NodePropItem.jsx
Original file line number Diff line number Diff line change
@@ -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>
];
}

}
}
88 changes: 61 additions & 27 deletions src/components/SearchContainer/Tabs/UserNodeData.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import React, { Component } from 'react';
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();

this.state = {
label: "",
displayName: "None",
pwdLastChanged: "None",
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
foreignGroupMembership: -1,
Expand All @@ -23,7 +24,8 @@ export default class UserNodeData extends Component {
firstdegreeControl: -1,
unrolledControl: -1,
transitiveControl: -1,
driversessions : []
driversessions : [],
propertyMap: {ServicePrincipalNames: []}
};

emitter.on('userNodeClicked', this.getNodeData.bind(this));
Expand All @@ -36,8 +38,6 @@ export default class UserNodeData extends Component {

this.setState({
label: payload,
displayName: "None",
pwdLastChanged: "None",
firstDegreeGroupMembership: -1,
unrolledGroupMembership: -1,
foreignGroupMembership: -1,
Expand All @@ -50,7 +50,8 @@ export default class UserNodeData extends Component {
transitiveControllers: -1,
firstdegreeControl: -1,
unrolledControl: -1,
transitiveControl: -1
transitiveControl: -1,
propertyMap: {ServicePrincipalNames: []}
});

var domain = '@' + payload.split('@').last();
Expand All @@ -71,19 +72,8 @@ export default class UserNodeData extends Component {

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;
if (properties.hasOwnProperty('PwdLastSet')){
this.setState({'pwdLastChanged': new Date(properties.PwdLastSet.low * 1000).toUTCString() });
}

if (properties.hasOwnProperty("DisplayName")){
var dname = properties.DisplayName;
if (dname === ""){
dname = "None";
}
this.setState({'displayName': dname });
}
.then(function(result){
this.setState({propertyMap: properties});
props.close();
}.bind(this));

Expand Down Expand Up @@ -168,13 +158,33 @@ export default class UserNodeData extends Component {
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')){
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
Expand All @@ -186,14 +196,38 @@ export default class UserNodeData extends Component {
Display Name
</dt>
<dd>
{this.state.displayName}
{this.convertToDisplayProp("DisplayName")}
</dd>
<dt>
Password Last Changed
</dt>
<dd>
{this.state.pwdLastChanged}
{this.convertToDisplayProp("PwdLastSet")}
</dd>
<dt>
Last Logon
</dt>
<dd>
{this.convertToDisplayProp("LastLogon")}
</dd>
<dt>
Enabled
</dt>
<dd>
{this.convertToDisplayProp("Enabled")}
</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>
Expand All @@ -207,7 +241,7 @@ export default class UserNodeData extends Component {
}.bind(this)}
/>
</dd>
<br />

<h4>Group Membership</h4>
<dt>
First Degree Group Memberships
Expand Down Expand Up @@ -250,7 +284,7 @@ export default class UserNodeData extends Component {
}.bind(this)}
/>
</dd>
<br />

<h4>
Local Admin Rights
</h4>
Expand Down Expand Up @@ -292,7 +326,7 @@ export default class UserNodeData extends Component {
}.bind(this)}
/>
</dd>
<br />

<h4>
Outbound Object Control
</h4>
Expand Down Expand Up @@ -334,7 +368,7 @@ export default class UserNodeData extends Component {
}.bind(this)}
/>
</dd>
<br />

<h4>Inbound Object Control</h4>
<dt>
Explicit Object Controllers
Expand Down Expand Up @@ -382,5 +416,5 @@ export default class UserNodeData extends Component {
}

UserNodeData.propTypes = {
visible : React.PropTypes.bool.isRequired
visible : PropTypes.bool.isRequired
};
Loading

0 comments on commit 5f366ac

Please sign in to comment.