Skip to content

Commit 29b97f4

Browse files
author
Brent Cook
committed
remove superfluous parens on ifs
1 parent 97d671d commit 29b97f4

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

lib/msf/core/rpc/v10/rpc_db.rb

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def db
1212
end
1313

1414
def find_workspace(wspace = nil)
15-
if(wspace and wspace != "")
15+
if wspace and wspace != ""
1616
return self.framework.db.find_workspace(wspace) || error(500, "Invalid workspace")
1717
end
1818
self.framework.db.workspace
@@ -416,7 +416,7 @@ def rpc_vulns(xopts)
416416
wspace.vulns.includes(:service).where(conditions).offset(offset).limit(limit).each do |v|
417417
vuln = {}
418418
reflist = v.refs.map { |r| r.name }
419-
if(v.service)
419+
if v.service
420420
vuln[:port] = v.service.port
421421
vuln[:proto] = v.service.proto
422422
else
@@ -495,7 +495,7 @@ def rpc_get_workspace(wspace)
495495
wspace = find_workspace(wspace)
496496
ret = {}
497497
ret[:workspace] = []
498-
if(wspace)
498+
if wspace
499499
w = {}
500500
w[:name] = wspace.name
501501
w[:id] = wspace.id
@@ -524,7 +524,7 @@ def rpc_set_workspace(wspace)
524524
::ActiveRecord::Base.connection_pool.with_connection {
525525
db_check
526526
workspace = find_workspace(wspace)
527-
if(workspace)
527+
if workspace
528528
self.framework.db.workspace = workspace
529529
return { 'result' => "success" }
530530
end
@@ -580,7 +580,7 @@ def rpc_add_workspace(wspace)
580580
::ActiveRecord::Base.connection_pool.with_connection {
581581
db_check
582582
wspace = self.framework.db.add_workspace(wspace)
583-
return { 'result' => 'success' } if(wspace)
583+
return { 'result' => 'success' } if wspace
584584
{ 'result' => 'failed' }
585585
}
586586
end
@@ -620,7 +620,7 @@ def rpc_get_host(xopts)
620620
ret[:host] = []
621621
opts = fix_options(xopts)
622622
h = self.framework.db.get_host(opts)
623-
if(h)
623+
if h
624624
host = {}
625625
host[:created_at] = h.created_at.to_i
626626
host[:address] = h.address.to_s
@@ -669,7 +669,7 @@ def rpc_report_host(xopts)
669669
opts, wspace = init_db_opts_workspace(xopts)
670670

671671
res = self.framework.db.report_host(opts)
672-
return { :result => 'success' } if(res)
672+
return { :result => 'success' } if res
673673
{ :result => 'failed' }
674674
}
675675
end
@@ -695,7 +695,7 @@ def rpc_report_service(xopts)
695695
::ActiveRecord::Base.connection_pool.with_connection {
696696
opts, wspace = init_db_opts_workspace(xopts)
697697
res = self.framework.db.report_service(opts)
698-
return { :result => 'success' } if(res)
698+
return { :result => 'success' } if res
699699
{ :result => 'failed' }
700700
}
701701
end
@@ -735,9 +735,9 @@ def rpc_get_service(xopts)
735735
services = []
736736
sret = nil
737737

738-
if(host && opts[:proto] && opts[:port])
738+
if host && opts[:proto] && opts[:port]
739739
sret = host.services.find_by_proto_and_port(opts[:proto], opts[:port])
740-
elsif(opts[:proto] && opts[:port])
740+
elsif opts[:proto] && opts[:port]
741741
conditions = {}
742742
conditions[:state] = [Msf::ServiceState::Open] if opts[:up]
743743
conditions[:proto] = opts[:proto] if opts[:proto]
@@ -872,7 +872,7 @@ def rpc_get_client(xopts)
872872
ret = {}
873873
ret[:client] = []
874874
c = self.framework.db.get_client(opts)
875-
if(c)
875+
if c
876876
client = {}
877877
host = c.host
878878
client[:host] = host.address
@@ -909,7 +909,7 @@ def rpc_report_client(xopts)
909909
::ActiveRecord::Base.connection_pool.with_connection {
910910
opts, wspace = init_db_opts_workspace(xopts)
911911
res = self.framework.db.report_client(opts)
912-
return { :result => 'success' } if(res)
912+
return { :result => 'success' } if res
913913
{ :result => 'failed' }
914914
}
915915
end
@@ -949,7 +949,7 @@ def rpc_report_note(xopts)
949949
end
950950

951951
res = self.framework.db.report_note(opts)
952-
return { :result => 'success' } if(res)
952+
return { :result => 'success' } if res
953953
{ :result => 'failed' }
954954
}
955955
end
@@ -997,8 +997,8 @@ def rpc_notes(xopts)
997997
note[:time] = n.created_at.to_i
998998
note[:host] = ""
999999
note[:service] = ""
1000-
note[:host] = n.host.address if(n.host)
1001-
note[:service] = n.service.name || n.service.port if(n.service)
1000+
note[:host] = n.host.address if n.host
1001+
note[:service] = n.service.name || n.service.port if n.service
10021002
note[:type ] = n.ntype.to_s
10031003
note[:data] = n.data.inspect
10041004
ret[:notes] << note
@@ -1360,7 +1360,7 @@ def rpc_report_vuln(xopts)
13601360
opts = fix_options(xopts)
13611361
opts[:workspace] = find_workspace(opts[:workspace]) if opts[:workspace]
13621362
res = self.framework.db.report_vuln(opts)
1363-
return { :result => 'success' } if(res)
1363+
return { :result => 'success' } if res
13641364
{ :result => 'failed' }
13651365
}
13661366
end
@@ -1398,12 +1398,12 @@ def rpc_events(xopts)
13981398

13991399
wspace.events.offset(offset).limit(limit).each do |e|
14001400
event = {}
1401-
event[:host] = e.host.address if(e.host)
1401+
event[:host] = e.host.address if e.host
14021402
event[:created_at] = e.created_at.to_i
14031403
event[:updated_at] = e.updated_at.to_i
14041404
event[:name] = e.name
1405-
event[:critical] = e.critical if(e.critical)
1406-
event[:username] = e.username if(e.username)
1405+
event[:critical] = e.critical if e.critical
1406+
event[:username] = e.username if e.username
14071407
event[:info] = e.info
14081408
ret[:events] << event
14091409
end
@@ -1430,7 +1430,7 @@ def rpc_report_event(xopts)
14301430
::ActiveRecord::Base.connection_pool.with_connection {
14311431
opts, wspace = init_db_opts_workspace(xopts)
14321432
res = self.framework.db.report_event(opts)
1433-
{ :result => 'success' } if(res)
1433+
{ :result => 'success' } if res
14341434
}
14351435
end
14361436

@@ -1465,7 +1465,7 @@ def rpc_report_loot(xopts)
14651465
end
14661466

14671467
res = self.framework.db.report_loot(opts)
1468-
{ :result => 'success' } if(res)
1468+
{ :result => 'success' } if res
14691469
}
14701470
end
14711471

@@ -1503,8 +1503,8 @@ def rpc_loots(xopts)
15031503
ret[:loots] = []
15041504
wspace.loots.offset(offset).limit(limit).each do |l|
15051505
loot = {}
1506-
loot[:host] = l.host.address if(l.host)
1507-
loot[:service] = l.service.name || l.service.port if(l.service)
1506+
loot[:host] = l.host.address if l.host
1507+
loot[:service] = l.service.name || l.service.port if l.service
15081508
loot[:ltype] = l.ltype
15091509
loot[:ctype] = l.content_type
15101510
loot[:data] = l.data
@@ -1605,10 +1605,10 @@ def rpc_get_vuln(xopts)
16051605

16061606
host = self.framework.db.get_host(opts)
16071607

1608-
return ret if( not host)
1608+
return ret if not host
16091609
vulns = []
16101610

1611-
if(opts[:proto] && opts[:port])
1611+
if opts[:proto] && opts[:port]
16121612
services = []
16131613
sret = host.services.find_by_proto_and_port(opts[:proto], opts[:port])
16141614
return ret if sret == nil
@@ -1800,7 +1800,7 @@ def rpc_driver(xopts)
18001800
# rpc.call('db.connect', {:driver=>'postgresql'})
18011801
def rpc_connect(xopts)
18021802
opts = fix_options(xopts)
1803-
if(not self.framework.db.driver and not opts[:driver])
1803+
if not self.framework.db.driver and not opts[:driver]
18041804
return { :result => 'failed' }
18051805
end
18061806

0 commit comments

Comments
 (0)