silo_manager 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/silo_manager +99 -26
  2. data/lib/nexpose.rb +53 -0
  3. metadata +4 -4
data/bin/silo_manager CHANGED
@@ -412,7 +412,6 @@ def list_mtu
412
412
  main_selected = false
413
413
 
414
414
  while !main_selected
415
- mtu_list = []
416
415
  begin
417
416
  @client_api.login
418
417
  mtu_list = @client_api.list_mtu
@@ -450,6 +449,90 @@ def list_mtu
450
449
  end
451
450
  end
452
451
 
452
+ def list_silo_profiles
453
+ main_selected = false
454
+
455
+ while !main_selected
456
+
457
+ begin
458
+ @client_api.login
459
+ silo_profile_map = @client_api.list_silo_profiles
460
+ rescue Exception => e
461
+ puts e.message
462
+ end
463
+
464
+ puts "To return to the main menu type ':main'"
465
+ puts "For detailed information on a specific silo profile enter the id"
466
+ puts "Or just hit enter to list all ids"
467
+
468
+ id = get_string_input 'Silo Profile ID', true
469
+ if id == :main
470
+ return
471
+ elsif id.nil?
472
+ puts 'List of Silo Profile IDs:'
473
+ silo_profile_map.each do |silo_profiles|
474
+ puts silo_profiles[:id]
475
+ end
476
+ else
477
+ id_found = false
478
+ silo_profile_map.each do |silo_profiles|
479
+ if silo_profiles[:id].eql?(id)
480
+ puts silo_profiles.inspect
481
+ id_found = true
482
+ break
483
+ end
484
+ end
485
+
486
+ if !id_found
487
+ puts "Silo Profile ID not found"
488
+ end
489
+ end
490
+
491
+ end
492
+ end
493
+
494
+ def list_silos
495
+ main_selected = false
496
+
497
+ while !main_selected
498
+
499
+ begin
500
+ @client_api.login
501
+ silo_map = @client_api.list_silos
502
+ rescue Exception => e
503
+ puts e.message
504
+ end
505
+
506
+ puts "To return to the main menu type ':main'"
507
+ puts "For detailed information on a specific silo enter the id"
508
+ puts "Or just hit enter to list all ids"
509
+
510
+ id = get_string_input 'Silo ID', true
511
+ if id == :main
512
+ return
513
+ elsif id.nil?
514
+ puts 'List of Silo IDs:'
515
+ silo_map.each do |silos|
516
+ puts silos[:id]
517
+ end
518
+ else
519
+ id_found = false
520
+ silo_map.each do |silos|
521
+ if silos[:id].eql?(id)
522
+ puts silos.inspect
523
+ id_found = true
524
+ break
525
+ end
526
+ end
527
+
528
+ if !id_found
529
+ puts "Silo ID not found"
530
+ end
531
+ end
532
+
533
+ end
534
+ end
535
+
453
536
  def delete_mtu
454
537
  while true
455
538
  puts "To return to the main menu type ':main'"
@@ -488,30 +571,14 @@ end
488
571
  def delete_silo_profile
489
572
  while true
490
573
  puts "To return to the main menu type ':main'"
491
- puts "Enter 1 to enter an ID and 2 for name"
492
- input = gets
493
- name, id = nil
494
- case input
495
- when /1/
496
- id = get_string_input 'Silo Profile Id', true, true
497
- if id == :main
498
- return
499
- end
500
- when /2/
501
- name = get_string_input 'Silo Profile Name', true, true
502
- if name == :main
503
- return
504
- end
505
- when /:main/
506
- return
507
- else
508
- puts 'Invalid input'
509
- next
574
+ id = get_string_input 'Silo Profile Id', true, true
575
+ if id == :main
576
+ return
510
577
  end
511
578
 
512
579
  begin
513
580
  @client_api.login
514
- @client_api.delete_silo_profile name, id
581
+ @client_api.delete_silo_profile nil, id
515
582
  puts 'Successfully deleted silo profile!'
516
583
  rescue Exception => e
517
584
  puts e.message
@@ -564,9 +631,11 @@ def get_main_select
564
631
  puts "2. Create a new silo-profile"
565
632
  puts "3. Create a new silo"
566
633
  puts "4. List multi-tenant users"
567
- puts "5. Delete a multi-tenant user"
568
- puts "6. Delete a silo profile"
569
- puts "7. Delete a silo"
634
+ puts "5. List silo profiles"
635
+ puts "6. List silos"
636
+ puts "7. Delete a multi-tenant user"
637
+ puts "8. Delete a silo profile"
638
+ puts "9. Delete a silo"
570
639
 
571
640
  id = gets.chomp
572
641
  if id =~ /quit/i
@@ -609,10 +678,14 @@ begin
609
678
  when 4
610
679
  list_mtu
611
680
  when 5
612
- delete_mtu
681
+ list_silo_profiles
613
682
  when 6
614
- delete_silo_profile
683
+ list_silos
615
684
  when 7
685
+ delete_mtu
686
+ when 8
687
+ delete_silo_profile
688
+ when 9
616
689
  delete_silo
617
690
 
618
691
  else
data/lib/nexpose.rb CHANGED
@@ -667,6 +667,37 @@ module NexposeAPI
667
667
  r.success
668
668
  end
669
669
 
670
+ #-------------------------------------------------------------------------
671
+ # Lists all the silo profiles and their attributes.
672
+ #-------------------------------------------------------------------------
673
+ def list_silo_profiles
674
+ xml = make_xml('SiloProfileListingRequest')
675
+ r = execute xml, '1.2'
676
+
677
+ if r.success
678
+ res = []
679
+ r.res.elements.each("//SiloProfileSummary") do |silo_profile|
680
+ res << {
681
+ :id => silo_profile.attributes['id'],
682
+ :name => silo_profile.attributes['name'],
683
+ :description => silo_profile.attributes['description'],
684
+ :global_report_template_count => silo_profile.attributes['global-report-template-count'],
685
+ :global_scan_engine_count => silo_profile.attributes['global-scan-engine-count'],
686
+ :global_scan_template_count => silo_profile.attributes['global-scan-template-count'],
687
+ :licensed_module_count => silo_profile.attributes['licensed-module-count'],
688
+ :restricted_report_section_count => silo_profile.attributes['restricted-report-section-count'],
689
+ :all_licensed_modules => silo_profile.attributes['all-licensed-modules'],
690
+ :all_global_engines => silo_profile.attributes['all-global-engines'],
691
+ :all_global_report_templates => silo_profile.attributes['all-global-report-templates'],
692
+ :all_global_scan_templates => silo_profile.attributes['all-global-scan-templates']
693
+ }
694
+ end
695
+ res
696
+ else
697
+ false
698
+ end
699
+ end
700
+
670
701
  #-------------------------------------------------------------------------
671
702
  # Delete a silo profile
672
703
  #-------------------------------------------------------------------------
@@ -770,6 +801,28 @@ module NexposeAPI
770
801
  r.success
771
802
  end
772
803
 
804
+ #-------------------------------------------------------------------------
805
+ # Lists all the silos and their attributes.
806
+ #-------------------------------------------------------------------------
807
+ def list_silos
808
+ xml = make_xml('SiloListingRequest')
809
+ r = execute xml, '1.2'
810
+
811
+ if r.success
812
+ res = []
813
+ r.res.elements.each("//SiloSummary") do |silo_profile|
814
+ res << {
815
+ :id => silo_profile.attributes['id'],
816
+ :name => silo_profile.attributes['name'],
817
+ :description => silo_profile.attributes['description']
818
+ }
819
+ end
820
+ res
821
+ else
822
+ false
823
+ end
824
+ end
825
+
773
826
  #-------------------------------------------------------------------------
774
827
  # Delete a silo
775
828
  #-------------------------------------------------------------------------
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: silo_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-13 00:00:00.000000000 -05:00
12
+ date: 2011-10-14 00:00:00.000000000 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: librex
17
- requirement: &24097104 !ruby/object:Gem::Requirement
17
+ requirement: &23289708 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: 0.0.32
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *24097104
25
+ version_requirements: *23289708
26
26
  description: ! ' This is a tool is used to provide CRUD silo operations for Nexpose.
27
27
 
28
28
  '