Skip to content

Commit

Permalink
Remove unnecessary escape
Browse files Browse the repository at this point in the history
Also add developer tools shortcut
  • Loading branch information
rvazarkar committed Sep 2, 2016
1 parent 309f73d commit f5040d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
5 changes: 4 additions & 1 deletion main.js
Expand Up @@ -49,9 +49,12 @@ function createWindow () {
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" },
{ label: "Open Developer Tools", accelerator: "CmdOrCtrl+Shift+I", click (item, focusedWindow){
mainWindow.webContents.openDevTools()
}},
{ label: "Reload", accelerator: 'CmdOrCtrl+R', click (item, focusedWindow){
if (focusedWindow) focusedWindow.reload()
}}
},}
]}
];

Expand Down
22 changes: 9 additions & 13 deletions src/js/utils.js
Expand Up @@ -2,10 +2,6 @@ export function escapeRegExp(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\\\$&');
}

export function escapeSingleQuotes(s){
return s.replace("'", "\\'")
}

export function buildAuthHeader(){
db = storage.get('database-info', function(error, data){
return "Basic " + btoa(db.user + ":" + db.password)
Expand Down Expand Up @@ -358,13 +354,13 @@ export function buildMergeQuery(rows, type){

var userQuery, computerQuery, groupQuery, domainQuery;
if (type === 'sessions'){
userQuery = "MERGE (user:User {name:'{}'}) WITH user MERGE (computer:Computer {name: '{}'}) WITH user,computer MERGE (computer)-[:HasSession {Weight : '{}'}]-(user)"
userQuery = 'MERGE (user:User {name:"{}"}) WITH user MERGE (computer:Computer {name: "{}"}) WITH user,computer MERGE (computer)-[:HasSession {Weight : "{}"}]-(user)'
$.each(rows, function(i, row){
if (row.UserName === 'ANONYMOUS LOGON@UNKNOWN' || row.UserName === ''){
return
}
row.UserName = escapeSingleQuotes(row.UserName.toUpperCase())
row.ComputerName = escapeSingleQuotes(row.ComputerName.toUpperCase())
row.UserName = row.UserName.toUpperCase()
row.ComputerName = row.ComputerName.toUpperCase()
queries.statements.push({"statement": userQuery.format(row.UserName, row.ComputerName, row.Weight)})
})
}else if (type === 'groupmembership'){
Expand All @@ -373,8 +369,8 @@ export function buildMergeQuery(rows, type){
computerQuery = 'MERGE (computer:Computer {name: "{}"}) WITH computer MERGE (group:Group {name: "{}"}) with computer,group MERGE (computer)-[:MemberOf]-(group)'

$.each(rows, function(i, row){
row.AccountName = escapeSingleQuotes(row.AccountName.toUpperCase())
row.GroupName = escapeSingleQuotes(row.GroupName.toUpperCase())
row.AccountName = row.AccountName.toUpperCase()
row.GroupName = row.GroupName.toUpperCase()
switch(row.AccountType){
case 'user':
queries.statements.push({"statement": userQuery.format(row.AccountName, row.GroupName)})
Expand All @@ -393,8 +389,8 @@ export function buildMergeQuery(rows, type){
computerQuery = 'MERGE (computer1:Computer {name: "{}"}) WITH computer1 MERGE (computer2:Computer {name: "{}"}) WITH computer1,computer2 MERGE (computer1)-[:AdminTo]->(computer2)'

$.each(rows, function(i, row){
row.AccountName = escapeSingleQuotes(row.AccountName.toUpperCase())
row.ComputerName = escapeSingleQuotes(row.ComputerName.toUpperCase())
row.AccountName = row.AccountName.toUpperCase()
row.ComputerName = row.ComputerName.toUpperCase()
if (row.AccountName.startsWith('@')){
return
}
Expand All @@ -413,8 +409,8 @@ export function buildMergeQuery(rows, type){
}else{
domainQuery = 'MERGE (domain1:Domain {name: "{}"}) WITH domain1 MERGE (domain2:Domain {name: "{}"}) WITH domain1,domain2 MERGE (domain1)-[:TrustedBy {TrustType : "{}", Transitive: "{}"}]->(domain2)'
$.each(rows, function(i, row){
row.TargetDomain = escapeSingleQuotes(row.TargetDomain.toUpperCase())
row.SourceDomain = escapeSingleQuotes(row.SourceDomain.toUpperCase())
row.TargetDomain = row.TargetDomain.toUpperCase()
row.SourceDomain = row.SourceDomain.toUpperCase()
switch(row.TrustDirection){
case 'Inbound':
queries.statements.push({"statement": domainQuery.format(row.TargetDomain, row.SourceDomain, row.TrustType, row.Transitive)})
Expand Down

0 comments on commit f5040d7

Please sign in to comment.