12
12
end
13
13
14
14
def find_workspace ( wspace = nil )
15
- if ( wspace and wspace != "" )
15
+ if wspace and wspace != ""
16
16
return self . framework . db . find_workspace ( wspace ) || error ( 500 , "Invalid workspace" )
17
17
end
18
18
self . framework . db . workspace
@@ -416,7 +416,7 @@ def rpc_vulns(xopts)
416
416
wspace . vulns . includes ( :service ) . where ( conditions ) . offset ( offset ) . limit ( limit ) . each do |v |
417
417
vuln = { }
418
418
reflist = v . refs . map { |r | r . name }
419
- if ( v . service )
419
+ if v . service
420
420
vuln [ :port ] = v . service . port
421
421
vuln [ :proto ] = v . service . proto
422
422
else
@@ -495,7 +495,7 @@ def rpc_get_workspace(wspace)
495
495
wspace = find_workspace ( wspace )
496
496
ret = { }
497
497
ret [ :workspace ] = [ ]
498
- if ( wspace )
498
+ if wspace
499
499
w = { }
500
500
w [ :name ] = wspace . name
501
501
w [ :id ] = wspace . id
@@ -524,7 +524,7 @@ def rpc_set_workspace(wspace)
524
524
::ActiveRecord ::Base . connection_pool . with_connection {
525
525
db_check
526
526
workspace = find_workspace ( wspace )
527
- if ( workspace )
527
+ if workspace
528
528
self . framework . db . workspace = workspace
529
529
return { 'result' => "success" }
530
530
end
@@ -580,7 +580,7 @@ def rpc_add_workspace(wspace)
580
580
::ActiveRecord ::Base . connection_pool . with_connection {
581
581
db_check
582
582
wspace = self . framework . db . add_workspace ( wspace )
583
- return { 'result' => 'success' } if ( wspace )
583
+ return { 'result' => 'success' } if wspace
584
584
{ 'result' => 'failed' }
585
585
}
586
586
end
@@ -620,7 +620,7 @@ def rpc_get_host(xopts)
620
620
ret [ :host ] = [ ]
621
621
opts = fix_options ( xopts )
622
622
h = self . framework . db . get_host ( opts )
623
- if ( h )
623
+ if h
624
624
host = { }
625
625
host [ :created_at ] = h . created_at . to_i
626
626
host [ :address ] = h . address . to_s
@@ -669,7 +669,7 @@ def rpc_report_host(xopts)
669
669
opts , wspace = init_db_opts_workspace ( xopts )
670
670
671
671
res = self . framework . db . report_host ( opts )
672
- return { :result => 'success' } if ( res )
672
+ return { :result => 'success' } if res
673
673
{ :result => 'failed' }
674
674
}
675
675
end
@@ -695,7 +695,7 @@ def rpc_report_service(xopts)
695
695
::ActiveRecord ::Base . connection_pool . with_connection {
696
696
opts , wspace = init_db_opts_workspace ( xopts )
697
697
res = self . framework . db . report_service ( opts )
698
- return { :result => 'success' } if ( res )
698
+ return { :result => 'success' } if res
699
699
{ :result => 'failed' }
700
700
}
701
701
end
@@ -735,9 +735,9 @@ def rpc_get_service(xopts)
735
735
services = [ ]
736
736
sret = nil
737
737
738
- if ( host && opts [ :proto ] && opts [ :port ] )
738
+ if host && opts [ :proto ] && opts [ :port ]
739
739
sret = host . services . find_by_proto_and_port ( opts [ :proto ] , opts [ :port ] )
740
- elsif ( opts [ :proto ] && opts [ :port ] )
740
+ elsif opts [ :proto ] && opts [ :port ]
741
741
conditions = { }
742
742
conditions [ :state ] = [ Msf ::ServiceState ::Open ] if opts [ :up ]
743
743
conditions [ :proto ] = opts [ :proto ] if opts [ :proto ]
@@ -872,7 +872,7 @@ def rpc_get_client(xopts)
872
872
ret = { }
873
873
ret [ :client ] = [ ]
874
874
c = self . framework . db . get_client ( opts )
875
- if ( c )
875
+ if c
876
876
client = { }
877
877
host = c . host
878
878
client [ :host ] = host . address
@@ -909,7 +909,7 @@ def rpc_report_client(xopts)
909
909
::ActiveRecord ::Base . connection_pool . with_connection {
910
910
opts , wspace = init_db_opts_workspace ( xopts )
911
911
res = self . framework . db . report_client ( opts )
912
- return { :result => 'success' } if ( res )
912
+ return { :result => 'success' } if res
913
913
{ :result => 'failed' }
914
914
}
915
915
end
@@ -949,7 +949,7 @@ def rpc_report_note(xopts)
949
949
end
950
950
951
951
res = self . framework . db . report_note ( opts )
952
- return { :result => 'success' } if ( res )
952
+ return { :result => 'success' } if res
953
953
{ :result => 'failed' }
954
954
}
955
955
end
@@ -997,8 +997,8 @@ def rpc_notes(xopts)
997
997
note [ :time ] = n . created_at . to_i
998
998
note [ :host ] = ""
999
999
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
1002
1002
note [ :type ] = n . ntype . to_s
1003
1003
note [ :data ] = n . data . inspect
1004
1004
ret [ :notes ] << note
@@ -1360,7 +1360,7 @@ def rpc_report_vuln(xopts)
1360
1360
opts = fix_options ( xopts )
1361
1361
opts [ :workspace ] = find_workspace ( opts [ :workspace ] ) if opts [ :workspace ]
1362
1362
res = self . framework . db . report_vuln ( opts )
1363
- return { :result => 'success' } if ( res )
1363
+ return { :result => 'success' } if res
1364
1364
{ :result => 'failed' }
1365
1365
}
1366
1366
end
@@ -1398,12 +1398,12 @@ def rpc_events(xopts)
1398
1398
1399
1399
wspace . events . offset ( offset ) . limit ( limit ) . each do |e |
1400
1400
event = { }
1401
- event [ :host ] = e . host . address if ( e . host )
1401
+ event [ :host ] = e . host . address if e . host
1402
1402
event [ :created_at ] = e . created_at . to_i
1403
1403
event [ :updated_at ] = e . updated_at . to_i
1404
1404
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
1407
1407
event [ :info ] = e . info
1408
1408
ret [ :events ] << event
1409
1409
end
@@ -1430,7 +1430,7 @@ def rpc_report_event(xopts)
1430
1430
::ActiveRecord ::Base . connection_pool . with_connection {
1431
1431
opts , wspace = init_db_opts_workspace ( xopts )
1432
1432
res = self . framework . db . report_event ( opts )
1433
- { :result => 'success' } if ( res )
1433
+ { :result => 'success' } if res
1434
1434
}
1435
1435
end
1436
1436
@@ -1465,7 +1465,7 @@ def rpc_report_loot(xopts)
1465
1465
end
1466
1466
1467
1467
res = self . framework . db . report_loot ( opts )
1468
- { :result => 'success' } if ( res )
1468
+ { :result => 'success' } if res
1469
1469
}
1470
1470
end
1471
1471
@@ -1503,8 +1503,8 @@ def rpc_loots(xopts)
1503
1503
ret [ :loots ] = [ ]
1504
1504
wspace . loots . offset ( offset ) . limit ( limit ) . each do |l |
1505
1505
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
1508
1508
loot [ :ltype ] = l . ltype
1509
1509
loot [ :ctype ] = l . content_type
1510
1510
loot [ :data ] = l . data
@@ -1605,10 +1605,10 @@ def rpc_get_vuln(xopts)
1605
1605
1606
1606
host = self . framework . db . get_host ( opts )
1607
1607
1608
- return ret if ( not host )
1608
+ return ret if not host
1609
1609
vulns = [ ]
1610
1610
1611
- if ( opts [ :proto ] && opts [ :port ] )
1611
+ if opts [ :proto ] && opts [ :port ]
1612
1612
services = [ ]
1613
1613
sret = host . services . find_by_proto_and_port ( opts [ :proto ] , opts [ :port ] )
1614
1614
return ret if sret == nil
@@ -1800,7 +1800,7 @@ def rpc_driver(xopts)
1800
1800
# rpc.call('db.connect', {:driver=>'postgresql'})
1801
1801
def rpc_connect ( xopts )
1802
1802
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 ]
1804
1804
return { :result => 'failed' }
1805
1805
end
1806
1806
0 commit comments