Class: Risu::Models::Host

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/risu/models/host.rb

Overview

Host Model

Class Method Summary collapse

Class Method Details

.ip_listString

Generates a list of hosts from the database

Returns:

  • (String)

    of hosts n delimited



54
55
56
57
58
59
60
61
62
63
# File 'lib/risu/models/host.rb', line 54

def ip_list
	ips = Array.new
	hosts = Host.where("ip is not NULL").order("ip").to_a

	hosts.each do |host|
		ips << host.ip if host.ip != nil
	end

	ips.join("\n")
end

.not_os_aixObject



396
397
398
# File 'lib/risu/models/host.rb', line 396

def not_os_aix
	where("os NOT LIKE '%AIX%'")
end

.not_os_ciscoActiveRecord::Relation

Negation query for all hosts with a Cisco based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



344
345
346
# File 'lib/risu/models/host.rb', line 344

def not_os_cisco
	where("os NOT LIKE '%CISCO%'")
end

.not_os_freebsdActiveRecord::Relation

Negation query for all hosts with a FreeBSD based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



316
317
318
# File 'lib/risu/models/host.rb', line 316

def not_os_freebsd
	where("os NOT LIKE '%FreeBSD%'")
end

.not_os_linuxActiveRecord::Relation

Negation query for all hosts with a Linux based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



302
303
304
# File 'lib/risu/models/host.rb', line 302

def not_os_linux
	where("os NOT LIKE '%Linux%'")
end

.not_os_netbsdActiveRecord::Relation

Negation query for all hosts with a NETbsd based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



330
331
332
# File 'lib/risu/models/host.rb', line 330

def not_os_netbsd
	where("os NOT LIKE '%NetBsd%'")
end

.not_os_osxActiveRecord::Relation

Negation query for all hosts with a Mac OSX based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



386
387
388
# File 'lib/risu/models/host.rb', line 386

def not_os_osx
	where("os NOT LIKE '%Mac OS X%'")
end

.not_os_vmware_esxActiveRecord::Relation

Negation query for all hosts with a VMware ESX based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



372
373
374
# File 'lib/risu/models/host.rb', line 372

def not_os_vmware_esx
	where("os NOT LIKE '%VMware ESX%'")
end

.not_os_vxworksActiveRecord::Relation

Negation query for all hosts with a VXWorks based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



358
359
360
# File 'lib/risu/models/host.rb', line 358

def not_os_vxworks
	where("os NOT LIKE '%VxWorks%'")
end

.not_os_windowsActiveRecord::Relation

Negation query for all hosts with a Windows based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



75
76
77
# File 'lib/risu/models/host.rb', line 75

def not_os_windows
	where("os NOT LIKE '%Windows%'")
end

.not_os_windows_10ActiveRecord::Relation

Negation query for all hosts with a Windows 10 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



280
281
282
# File 'lib/risu/models/host.rb', line 280

def not_os_windows_10
	where("os NOT LIKE '%Windows 10%'")
end

.not_os_windows_2kActiveRecord::Relation

Negation query for all hosts with a Windows 2000 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



148
149
150
# File 'lib/risu/models/host.rb', line 148

def not_os_windows_2k
	where("os NOT LIKE '%Windows 2000%'")
end

.not_os_windows_2k12ActiveRecord::Relation

Negation query for all hosts with a Windows Server 2012 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



233
234
235
# File 'lib/risu/models/host.rb', line 233

def not_os_windows_2k12
	where("os NOT LIKE '%Windows Server 2012%'")
end

.not_os_windows_2k3ActiveRecord::Relation

Negation query for all hosts with a Windows Server 2003 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



182
183
184
# File 'lib/risu/models/host.rb', line 182

def not_os_windows_2k3
	where("os NOT LIKE '%Windows Server 2003%'")
end

.not_os_windows_2k8ActiveRecord::Relation

Negation query for all hosts with a Windows Server 2008 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



216
217
218
# File 'lib/risu/models/host.rb', line 216

def not_os_windows_2k8
	where("os NOT LIKE '%Windows Server 2008%'")
end

.not_os_windows_7ActiveRecord::Relation

Negation query for all hosts with a Windows 7 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



250
251
252
# File 'lib/risu/models/host.rb', line 250

def not_os_windows_7
	where("os NOT LIKE '%Windows 7%'")
end

.not_os_windows_8ActiveRecord::Relation

Negation query for all hosts with a Windows 8 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



266
267
268
# File 'lib/risu/models/host.rb', line 266

def not_os_windows_8
	where("os NOT LIKE '%Windows 8%'")
end

.not_os_windows_95ActiveRecord::Relation

Negation query for all hosts with a Windows 95 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



131
132
133
# File 'lib/risu/models/host.rb', line 131

def not_os_windows_95
	where("os NOT LIKE '%Windows 95%'")
end

.not_os_windows_98ActiveRecord::Relation

Negation query for all hosts with a Windows 98 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



103
104
105
# File 'lib/risu/models/host.rb', line 103

def not_os_windows_98
	where("os NOT LIKE '%Windows 98%'")
end

.not_os_windows_meActiveRecord::Relation

Negation query for all hosts with a Windows 98 based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



117
118
119
# File 'lib/risu/models/host.rb', line 117

def not_os_windows_me
	where("os NOT LIKE '%Windows Millennium%'")
end

.not_os_windows_ntActiveRecord::Relation

Negation query for all hosts with a Windows NT based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



89
90
91
# File 'lib/risu/models/host.rb', line 89

def not_os_windows_nt
	where("os NOT LIKE '%Windows NT%'")
end

.not_os_windows_vistaActiveRecord::Relation

Negation query for all hosts with a Windows Vista based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



199
200
201
# File 'lib/risu/models/host.rb', line 199

def not_os_windows_vista
	where("os NOT LIKE '%Windows Vista%'")
end

.not_os_windows_xpActiveRecord::Relation

Negation query for all hosts with a Windows XP based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



165
166
167
# File 'lib/risu/models/host.rb', line 165

def not_os_windows_xp
	where("os NOT LIKE '%Windows XP%'")
end

.os_aixObject



391
392
393
# File 'lib/risu/models/host.rb', line 391

def os_aix
	where("os LIKE '%AIX%'")
end

.os_ciscoActiveRecord::Relation

Queries for all hosts with a Cisco IOS based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



337
338
339
# File 'lib/risu/models/host.rb', line 337

def os_cisco
	where("os LIKE '%CISCO%'")
end

.os_freebsdActiveRecord::Relation

Queries for all hosts with a FreeBSD based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



309
310
311
# File 'lib/risu/models/host.rb', line 309

def os_freebsd
	where("os LIKE '%FreeBSD%'")
end

.os_linuxActiveRecord::Relation

Queries for all hosts with a Linux based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



295
296
297
# File 'lib/risu/models/host.rb', line 295

def os_linux
	where("os LIKE '%Linux%'")
end

.os_netbsdActiveRecord::Relation

Queries for all hosts with a NetBSD based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



323
324
325
# File 'lib/risu/models/host.rb', line 323

def os_netbsd
	where("os LIKE '%NetBsd%'")
end

.os_osxActiveRecord::Relation

Queries for all hosts with a Mac OSX based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



379
380
381
# File 'lib/risu/models/host.rb', line 379

def os_osx
	where("os LIKE '%Mac OS X%'")
end

.os_otherActiveRecord::Relation

Queries for all hosts with a Unknown Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



403
404
405
# File 'lib/risu/models/host.rb', line 403

def os_other
	not_os_osx.not_os_linux.not_os_netbsd.not_os_freebsd.not_os_cisco.not_os_vxworks.not_os_vmware_esx.not_os_windows.not_os_aix
end

.os_vmware_esxActiveRecord::Relation

Queries for all hosts with a VMware ESX based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



365
366
367
# File 'lib/risu/models/host.rb', line 365

def os_vmware_esx
	where("os LIKE '%VMware ESX%'")
end

.os_vxworksActiveRecord::Relation

Queries for all hosts with a VXWorks based Operating system

Returns:

  • (ActiveRecord::Relation)

    with the query results



351
352
353
# File 'lib/risu/models/host.rb', line 351

def os_vxworks
	where("os LIKE '%VxWorks%'")
end

.os_windowsActiveRecord::Relation

Queries for hosts with a Windows based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



68
69
70
# File 'lib/risu/models/host.rb', line 68

def os_windows
	where("os LIKE '%Windows%'")#.group(:os)
end

.os_windows_10ActiveRecord::Relation

Queries for hosts with a Windows 10 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



273
274
275
# File 'lib/risu/models/host.rb', line 273

def os_windows_10
	where("os LIKE '%Windows 10%'")
end

.os_windows_2kActiveRecord::Relation

Queries for hosts with a Windows 2000 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



138
139
140
# File 'lib/risu/models/host.rb', line 138

def os_windows_2k
	where("os LIKE '%Windows 2000%'")
end

.os_windows_2k12ActiveRecord::Relation

Queries for hosts with a Windows Server 2012 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



223
224
225
# File 'lib/risu/models/host.rb', line 223

def os_windows_2k12
	where("os LIKE '%Windows Server 2012%'")
end

.os_windows_2k3ActiveRecord::Relation

Queries for hosts with a Windows Server 2003 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



172
173
174
# File 'lib/risu/models/host.rb', line 172

def os_windows_2k3
	where("os LIKE '%Windows Server 2003%'")
end

.os_windows_2k8ActiveRecord::Relation

Queries for hosts with a Windows Server 2008 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



206
207
208
# File 'lib/risu/models/host.rb', line 206

def os_windows_2k8
	where("os LIKE '%Windows Server 2008%'")
end

.os_windows_7ActiveRecord::Relation

Queries for hosts with a Windows 7 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



240
241
242
# File 'lib/risu/models/host.rb', line 240

def os_windows_7
	where("os LIKE '%Windows 7%'")
end

.os_windows_8ActiveRecord::Relation

Queries for hosts with a Windows 8 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



257
258
259
# File 'lib/risu/models/host.rb', line 257

def os_windows_8
	where("os LIKE '%Windows 8%'")
end

.os_windows_95ActiveRecord::Relation

Queries for hosts with a Windows 95 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



124
125
126
# File 'lib/risu/models/host.rb', line 124

def os_windows_95
	where("os LIKE '%Windows 95%'")
end

.os_windows_98ActiveRecord::Relation

Queries for hosts with a Windows 98 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



96
97
98
# File 'lib/risu/models/host.rb', line 96

def os_windows_98
	where("os LIKE '%Windows 98%'")
end

.os_windows_meActiveRecord::Relation

Queries for hosts with a Windows 98 based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



110
111
112
# File 'lib/risu/models/host.rb', line 110

def os_windows_me
	where("os LIKE '%Windows 98%'")
end

.os_windows_ntActiveRecord::Relation

Queries for hosts with a Windows NT based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



82
83
84
# File 'lib/risu/models/host.rb', line 82

def os_windows_nt
	where("os LIKE '%Windows NT%'")
end

.os_windows_otherActiveRecord::Relation

Queries for hosts with a Windows Operating System that are not 2000, XP, 2003, Vista, 2008 or 7

Returns:

  • (ActiveRecord::Relation)

    with the query results



288
289
290
# File 'lib/risu/models/host.rb', line 288

def os_windows_other
	not_os_windows_2k12.not_os_windows_8.not_os_windows_7.not_os_windows_2k8.not_os_windows_vista.not_os_windows_2k3.not_os_windows_xp.not_os_windows_2k.not_os_windows_nt
end

.os_windows_vistaActiveRecord::Relation

Queries for hosts with a Windows Vista based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



189
190
191
# File 'lib/risu/models/host.rb', line 189

def os_windows_vista
	where("os LIKE '%Windows Vista%'")
end

.os_windows_xpActiveRecord::Relation

Queries for hosts with a Windows XP based Operating System

Returns:

  • (ActiveRecord::Relation)

    with the query results



155
156
157
# File 'lib/risu/models/host.rb', line 155

def os_windows_xp
	where("os LIKE '%Windows XP%'")
end

.other_os_graphStringIO

Deprecated.

Graphs the percentage of other “non Windows” Operating Systems

Returns:

  • (StringIO)

    Binary image object of the results



490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/risu/models/host.rb', line 490

def other_os_graph
	g = Gruff::Pie.new(GRAPH_WIDTH)
	g.title = "Other Operating Systems Percentage"
	g.sort = false
	g.marker_count = 1
	g.theme = {
		:colors => Risu::GRAPH_COLORS,
		:background_colors => %w(white white)
	}

	linux = Host.os_linux.to_a.size
	osx = Host.os_osx.to_a.size
	freebsd = Host.os_freebsd.to_a.size
	netbsd = Host.os_netbsd.to_a.size
	cisco = Host.os_cisco.to_a.size
	vxworks = Host.os_vxworks.to_a.size
	esx = Host.os_vmware_esx.to_a.size
	aix = Host.os_aix.to_a.size
	other = Host.os_other.to_a.size

	g.data("Linux", linux) unless linux == 0
	g.data("OSX", osx) unless osx == 0
	g.data("FreeBSD", freebsd) unless freebsd == 0
	g.data("NetBSD", netbsd) unless netbsd == 0
	g.data("Cisco IOS", cisco) unless cisco == 0
	g.data("VxWorks", vxworks) unless vxworks == 0
	g.data("VMware", esx) unless esx == 0
	g.data("AIX", aix) unless aix == 0
	g.data("Other", other) unless other == 0

	#Creates very odd graphs
	#Host.os_other.each do |host|
	# g.data(host.os, Host.where(:os => host.os).size) unless host.os == nil
	#end

	StringIO.new(g.to_blob)
end

.other_os_graph_has_data?Boolean

Deprecated.

Returns:

  • (Boolean)


460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/risu/models/host.rb', line 460

def other_os_graph_has_data?
	linux = Host.os_linux.to_a.size
	osx = Host.os_osx.to_a.size
	freebsd = Host.os_freebsd.to_a.size
	netbsd = Host.os_netbsd.to_a.size
	cisco = Host.os_cisco.to_a.size
	vxworks = Host.os_vxworks.to_a.size
	esx = Host.os_vmware_esx.to_a.size
	aix = Host.os_aix.to_a.size
	other = Host.os_other.to_a.size

	if linux == 0 &&
		osx == 0 &&
		freebsd == 0 &&
		netbsd == 0 &&
		cisco == 0 &&
		vxworks == 0 &&
		esx == 0 &&
		aix == 0 &&
		other == 0
		return false
	else
		return true
	end
end

.other_os_graph_textObject

Deprecated.

turn the os counts into blocks



731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
# File 'lib/risu/models/host.rb', line 731

def other_os_graph_text
	text = "This graph shows the percentage of the different Non-Windows based operating systems " +
	"found on the #{Report.title} network.\n\n"

	linux = Host.os_linux.to_a.size
	osx = Host.os_osx.to_a.size
	freebsd = Host.os_freebsd.to_a.size
	netbsd = Host.os_netbsd.to_a.size
	cisco = Host.os_cisco.to_a.size
	vxworks = Host.os_vxworks.to_a.size
	esx = Host.os_vmware_esx.to_a.size
	aix = Host.os_aix.to_a.size
	other = Host.os_other.to_a.size

	other_os_count = linux + osx + freebsd + netbsd + cisco + vxworks + esx + aix + other

	linux_percent = (linux.to_f / other_os_count.to_f) * 100
	aix_percent = (aix.to_f / other_os_count.to_f) * 100
	freebsd_percent = (freebsd.to_f / other_os_count.to_f) * 100
	vmware_percent = (esx.to_f / other_os_count.to_f) * 100

	#todo add other os's here

	text << "#{linux_percent.to_i}% of the non-windows network are running an Linux based operating system. " if linux_percent >= 1
	text << "#{aix_percent.to_i}% of the non-windows network are running an AIX based operating system. " if aix_percent >= 1
	text << "#{freebsd_percent.to_i}% of the non-windows network are running an FreeBSD based operating system. " if freebsd_percent >= 1
	text << "#{vmware_percent.to_i}% of the non-windows network are running an VMware based operating system. " if vmware_percent >= 1

	text << "\n\n"<< unsupported_os_aix if aix > 0
	text << "\n\n" << unsupported_os_freebsd if freebsd > 0

	return text
end

.sortedArray

Sorts all of the hosts where the ip address is not null

Returns:

  • (Array)

    With all the Ip’s in sorted order



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/risu/models/host.rb', line 37

def sorted
	hosts = Host.where("ip is not NULL").order("ip").to_a

	#Sort the ips in natural order.
	hosts.sort! do |a,b|
		ip1 = IPAddr.new a.ip
		ip2 = IPAddr.new b.ip

		ip1 <=> ip2
	end

	return hosts
end

.top_n_vulnerable(n) ⇒ Object



768
769
770
771
772
773
774
775
776
777
778
779
780
# File 'lib/risu/models/host.rb', line 768

def top_n_vulnerable(n)
	hosts = Item.risks_by_host(Host.count).size
	hosts = hosts.sort_by {|k, v| v}
	hosts.reverse!

	i = 0
	hosts[0...n].each do |host_id, count|
		hosts[i] = Host.where(:id => host_id)
		i = i + 1
	end

	hosts[0...n]
end

.top_vuln_graph(limit = 10) ⇒ StringIO

Deprecated.

Generates a graph of the high and medium findings count per host

Returns:

  • (StringIO)

    Binary image object of the results



412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/risu/models/host.rb', line 412

def top_vuln_graph(limit=10)
	g = Gruff::Bar.new(GRAPH_WIDTH)
	g.title = sprintf "Top 10 Hosts with Notable Findings Count"
	g.sort = false
	g.marker_count = 1
	g.theme = {
		:colors => Risu::GRAPH_COLORS,
		:background_colors => %w(white white)
	}

	Item.risks_by_host(limit).to_a.each do |item|
		ip = Host.find_by_id(item.host_id).name
		count = Item.where(:host_id => item.host_id).where(:severity => 4).size

		if count > 0
			g.data(ip, count)
		end
	end

	StringIO.new(g.to_blob)
end

.unique_hosts_with_common_missing_patchesObject



826
827
828
829
830
831
832
833
834
835
836
837
838
839
# File 'lib/risu/models/host.rb', line 826

def unique_hosts_with_common_missing_patches
	results = Array.new

	common_patches = Plugin.where(:family_name => "Risu Rollup Plugins").group(:id)
	hosts = Host.all

	hosts.each do |host|
		common_patches.each do |plugin|
			results.push(host.id) if host.items.where(:plugin_id => plugin.id).count > 0
		end
	end

	results.uniq
end

.unique_hosts_with_common_missing_patches_countObject



822
823
824
# File 'lib/risu/models/host.rb', line 822

def unique_hosts_with_common_missing_patches_count
	unique_hosts_with_common_missing_patches().size
end

.unique_hosts_with_criticalObject



785
786
787
788
789
# File 'lib/risu/models/host.rb', line 785

def unique_hosts_with_critical
	hosts = Item.critical_risks_by_host(Host.all.size).size
	hosts = hosts.sort_by {| _k, v | v}
	hosts.reverse!
end

.unique_hosts_with_critical_and_highObject



805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
# File 'lib/risu/models/host.rb', line 805

def unique_hosts_with_critical_and_high
	hosts = Array.new
	crit = Item.critical_risks_by_host(Host.all.size)

	crit.each do |item|
		hosts.push(item.host_id)
	end

	high = Item.high_risks_by_host(Host.all.size)

	high.each do |item|
		hosts.push(item.host_id)
	end

	hosts.uniq
end

.unique_hosts_with_critical_and_high_countObject



801
802
803
# File 'lib/risu/models/host.rb', line 801

def unique_hosts_with_critical_and_high_count
	unique_hosts_with_critical_and_high().size
end

.unique_hosts_with_highObject



794
795
796
797
798
# File 'lib/risu/models/host.rb', line 794

def unique_hosts_with_high
	hosts = Item.high_risks_by_host(Host.all.size).size
	hosts = hosts.sort_by {| _k, v | v}
	hosts.reverse!
end

.uniquie_hosts_with_critical_high_commonObject



841
842
843
844
# File 'lib/risu/models/host.rb', line 841

def uniquie_hosts_with_critical_high_common
	hosts = unique_hosts_with_common_missing_patches() + unique_hosts_with_critical_and_high()
	hosts.uniq
end

.uniquie_hosts_with_critical_high_common_countObject



846
847
848
# File 'lib/risu/models/host.rb', line 846

def uniquie_hosts_with_critical_high_common_count
	uniquie_hosts_with_critical_high_common().size
end

.unsupported_os?Boolean

Returns:

  • (Boolean)


622
623
624
625
626
627
628
629
630
631
632
633
# File 'lib/risu/models/host.rb', line 622

def unsupported_os?
	aix_text = unsupported_os_aix
	win_text = unsupported_os_windows
	freebsd_text = unsupported_os_freebsd

	#If all the text is nil just return nil
	if aix_text == "" && win_text == "" && freebsd_text == ""
		return false
	end

	return true
end

.unsupported_os_aixObject

Deprecated.


705
706
707
708
709
710
711
712
713
714
# File 'lib/risu/models/host.rb', line 705

def unsupported_os_aix
	text = ""
	aix = Host.os_aix.where("OS LIKE 'AIX 5.%'")

	text = "AIX 5.x is an unsupported operating system since IBM has stopped support as of April 2011. " +
	"Please see http://www-03.ibm.com/systems/power/software/aix/ for more information " +
	"about obtaining a newer supported version.\n\n" if aix.size >= 1

	return text
end

.unsupported_os_freebsdObject

Deprecated.


718
719
720
721
722
723
724
725
726
# File 'lib/risu/models/host.rb', line 718

def unsupported_os_freebsd
	text = ""
	freebsd = Host.os_freebsd.where("OS LIKE 'FreeBSD 5.%'")

	text = "FreeBSD 5 support ended on 2008-05-31. Upgrade to FreeBSD 8.2 or 7.4. For more information, " +
	"see : http://www.freebsd.org/security/\n\n" if freebsd.size >= 1

	return text
end

.unsupported_os_textObject

Deprecated.


638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
# File 'lib/risu/models/host.rb', line 638

def unsupported_os_text
	if !unsupported_os?
		return nil
	end

	aix_text = unsupported_os_aix
	win_text = unsupported_os_windows
	freebsd_text = unsupported_os_freebsd

	unsupported_os_text = "Several unsupported operating systems were discovered on the network. " +
	"These operating systems are no longer updated by the specific vendor. These operating systems should be " +
	"updated and replaced as soon as possible. If possible, disconnected from the network until updated.\n\n"

	unsupported_os_text << "#{win_text}" if win_text != ""
	unsupported_os_text << "#{aix_text}" if aix_text != ""
	unsupported_os_text << "#{freebsd_text}" if freebsd_text != ""

	return unsupported_os_text
end

.unsupported_os_windowsObject

Deprecated.


660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
# File 'lib/risu/models/host.rb', line 660

def unsupported_os_windows
	win_95_text = ""
	win_98_text = ""
	win_me_text = ""
	win_nt_text = ""
	win_2000_text = ""
	win_xp_text = ""
	win_2003_text = ""

	win_95 = Host.os_windows_95
	win_98 = Host.os_windows_98
	win_me = Host.os_windows_me
	win_nt = Plugin.where(:plugin_name => "Microsoft Windows NT 4.0 Unsupported Installation Detection")
	win_2000 = Plugin.where(:plugin_name => "Microsoft Windows 2000 Unsupported Installation Detection")
	win_xp = Plugin.where(:plugin_name => "Microsoft Windows XP Unsupported Installation Detection")
	win_2003 = Plugin.where(:plugin_name => "Microsoft Windows Server 2003 Unsupported Installation Detection")

	#Host.os_windows.not_os_windows_7.not_os_windows_2008.not_os_windows_vista.not_os_windows_2003.not_os_windows_xp

	win_95_text = "Windows 95 is an unsupported operating system; Microsoft has stopped support as of December 2001. " +
	"Please see http://en.wikipedia.org/wiki/Windows_95 for more information.\n\n" if win_95.size >= 1

	win_98_text = "Windows 98 is an unsupported operating system; Microsoft has stopped support as of July 2006. " +
	"Please see http://support.microsoft.com/gp/lifean18 for more information.\n\n" if win_98.size >= 1

	win_me_text = "Windows Millennium is an unsupported operating system; Microsoft has stopped support as of July 2006. " +
	"Please see http://support.microsoft.com/gp/lifean18 for more information.\n\n" if win_me.size >= 1

	win_nt_text = "Windows NT is an unsupported operating system; Microsoft has stopped support as of December 2004. " +
	"Please see http://windows.microsoft.com/en-us/windows/products/lifecycle for more information.\n\n" if win_nt.size >= 1

	win_2000_text = "Windows 2000 is an unsupported operating system; Microsoft has stopped support as of July 2010. " +
	"Please see http://windows.microsoft.com/en-us/windows/products/lifecycle for more information.\n\n" if win_2000.size >= 1

	win_xp_text = "Windows XP is an unsupported operating system; Microsoft has stopped support as of April 2014. " +
	"Please see http://windows.microsoft.com/en-us/windows/products/lifecycle for more information.\n\n" if win_xp.size >= 1

	win_2003_text = "Windows 2003 is an unsupported operating system; Microsoft has stopped support as of July 2015. " +
	"Please see http://windows.microsoft.com/en-us/windows/products/lifecycle for more information.\n\n" if win_2003.size >= 1

	return "#{win_95_text}#{win_98_text}#{win_me_text}#{win_nt_text}#{win_2000_text}#{win_xp_text}#{win_2003_text}"
end

.windows_os_graphStringIO

Deprecated.

Graphs the percentage of Windows Operating Systems

Returns:

  • (StringIO)

    Binary image object of the results



532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
# File 'lib/risu/models/host.rb', line 532

def windows_os_graph
	g = Gruff::Pie.new(GRAPH_WIDTH)
	g.title = "Windows Operating Systems By Percentage"
	g.sort = false
	g.marker_count = 1
	g.theme = {
		:colors => Risu::GRAPH_COLORS,
		:background_colors => %w(white white)
	}

	nt = Host.os_windows_nt.to_a.size
	w2k = Host.os_windows_2k.to_a.size
	xp = Host.os_windows_xp.to_a.size
	w2k3 = Host.os_windows_2k3.to_a.size
	vista = Host.os_windows_vista.to_a.size
	w2k8 = Host.os_windows_2k8.to_a.size
	w2k12 = Host.os_windows_2k12.to_a.size
	w7 = Host.os_windows_7.to_a.size
	w8 = Host.os_windows_8.to_a.size
	w10 = Host.os_windows_10.to_a.size
	other = (Host.os_windows.os_windows_other).to_a.size

	g.data("NT", nt) if nt >= 1
	g.data("2000", w2k) if w2k >= 1
	g.data("XP", xp) if xp >= 1
	g.data("Server 2003", w2k3) if w2k3 >= 1
	g.data("Vista", vista) if vista >= 1
	g.data("Server 2008", w2k8) if w2k8 >= 1
	g.data("Server 2012", w2k12) if w2k12 >= 1
	g.data("7", w7) if w7 >= 1
	g.data("8", w8) if w8 >= 1
	g.data("10", w10) if w10 >= 1
	g.data("Other Windows", other) if other >= 1

	StringIO.new(g.to_blob)
end

.windows_os_graph_has_data?Boolean

Deprecated.

Returns:

  • (Boolean)


437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/risu/models/host.rb', line 437

def windows_os_graph_has_data?
	nt = Host.os_windows_nt.to_a.size
	w2k = Host.os_windows_2k.to_a.size
	xp = Host.os_windows_xp.to_a.size
	w2k3 = Host.os_windows_2k3.to_a.size
	vista = Host.os_windows_vista.to_a.size
	w2k8 = Host.os_windows_2k8.to_a.size
	w2k12 = Host.os_windows_2k12.to_a.size
	w7 = Host.os_windows_7.to_a.size
	w8 = Host.os_windows_8.to_a.size
	other = (Host.os_windows.os_windows_other).to_a.size

	if nt == 0 && w2k == 0 && xp == 0 && w2k3 == 0 && vista == 0 && w2k8 == 0 && w2k12 == 0 && w7 == 0 && w8 == 0 && other == 0
		return false
	else
		return true
	end
end

.windows_os_graph_textObject

Deprecated.


572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
# File 'lib/risu/models/host.rb', line 572

def windows_os_graph_text
	nt = Host.os_windows_nt.to_a.size
	w2k = Host.os_windows_2k.to_a.size
	xp = Host.os_windows_xp.to_a.size
	w2k3 = Host.os_windows_2k3.to_a.size
	vista = Host.os_windows_vista.to_a.size
	w2k8 = Host.os_windows_2k8.to_a.size
	w2k12 = Host.os_windows_2k12.to_a.size
	w7 = Host.os_windows_7.to_a.size
	w8 = Host.os_windows_8.to_a.size
	w10 = Host.os_windows_10.to_a.size
	other = (Host.os_windows.os_windows_other).to_a.size

	windows_os_count = nt + w2k + xp + w2k3 + vista + w7 + w8 + w2k8 + w2k12 + other

	nt_percent = (nt.to_f / windows_os_count.to_f) * 100
	w2k_percent = (w2k.to_f / windows_os_count.to_f) * 100
	xp_percent = (xp.to_f / windows_os_count.to_f) * 100
	w2k3_percent = (w2k3.to_f / windows_os_count.to_f) * 100
	vista_percent = (vista.to_f / windows_os_count.to_f) * 100

	w2k8_percent = (w2k8.to_f / windows_os_count.to_f) * 100
	w7_percent = (w7.to_f / windows_os_count.to_f) * 100
	w8_percent = (w8.to_f / windows_os_count.to_f) * 100
	w10_percent = (w10.to_f / windows_os_count.to_f) * 100
	w2k12_percent = (w2k12.to_f / windows_os_count.to_f) * 100

	text = "This graph shows the percentage of the different Microsoft Windows based operating systems " +
	"found on the #{Report.title} network.\n\n"

	# @TODO this should be a table sorted by %
	text << "#{nt_percent.round.to_i}% (#{nt}) of the network is Windows NT.\n" if nt_percent >= 1
	text << "#{w2k_percent.round.to_i}% (#{w2k}) of the network is Windows 2000.\n" if w2k_percent >= 1
	text << "#{xp_percent.round.to_i}% (#{xp}) of the network is Windows XP.\n" if xp_percent >= 1
	text << "#{w2k3_percent.round.to_i}% (#{w2k3}) of the network is Windows Server 2003.\n" if w2k3_percent >= 1
	text << "#{vista_percent.round.to_i}% (#{vista}) of the network is Windows Vista.\n" if vista_percent >= 1
	text << "#{w2k8_percent.round.to_i}% (#{w2k8}) of the network is Windows Server 2008.\n" if w2k8_percent >= 1
	text << "#{w7_percent.round.to_i}% (#{w7}) of the network is Windows 7.\n" if w7_percent >= 1
	text << "#{w8_percent.round.to_i}% (#{w8}) of the network is Windows 8.\n" if w8_percent >= 1
	text << "#{w10_percent.round.to_i}% (#{w10}) of the network is Windows 10.\n" if w10_percent >= 1
	text << "#{w2k12_percent.round.to_i}% (#{w2k12}) of the network is Windows Server 20012.\n" if w2k12_percent >= 1

	text << "\n\n" << unsupported_os_windows if nt > 0 or w2k > 0 or xp > 0

	return text
end