<commit_before>#!/usr/bin/env ruby

require 'rubygems'
require "pdf/writer"

require 'nessus_db_model'
require 'findings'

report = "report-mccamey.pdf"
assessment_title = "McCamey Hospital"

assessment_date = "24 May 2010"
assessment_assessor = "<NAME>, CISSP"
company_name = "RT & Associates"
assessment_objective = "The primary objective of this engagement was to fulfill requirements for annual security assessments under the HIPAA guidelines"

#assessment_title = "SIAN"
#company_name = "Tangent Security"
#assessment_objective = "The primary objective of this engagement was to fulfill requirements for network certification"

#create our new pdf
pdf = PDF::Writer.new
#set the PDFS Font
pdf.select_font "Times-Roman"

findings = Findings.new
findings.number_of_hosts = Host.find(:all).count
findings.number_of_risks = Item.find(:all, :conditions => ["severity IN (0,1,2,3,4)"]).count
findings.number_of_critical = Item.find(:all, :conditions => ["severity = 3"]).count
findings.number_of_high = Item.find(:all, :conditions => ["severity = 2"]).count
findings.number_of_medium = Item.find(:all, :conditions => ["severity = 1"]).count
findings.number_of_low = Item.find(:all, :conditions => ["severity = 0"]).count
#findings.number_of_none = Item.find(:all, :conditions => ["severity = 0"]).count
findings.findings_by_service = Item.find_by_sql("SELECT svc_name, count(*) as c FROM items where svc_name != 'unknown' and svc_name != 'general' group by svc_name order by c desc limit 10").map(&:svc_name)#Item.find(:all, :group => :svc_name).map(&:svc_name)
findings.other_operating_systems = Host.find(:all, :conditions => ["os not like '%%Windows%%'"], :group => :os).map(&:os)
findings.windows_operating_systems = Host.find(:all, :conditions => ["os like '%%Windows%%'"], :group => :os).map(&:os)
findings.critical_findings = Item.find(:all, :conditions => ["severity = 3"], :joins => "INNER JOIN plugins ON items.plugin_id = plugins.id", :order => 'plugins.cvss_base_score')
findings.high_findings = Item.find(:all, :conditions => ["severity = 2"])
findings.top_plugins = Item.find_by_sql("SELECT *, count(plugin_id) FROM items WHERE plugin_id NOT IN (1) AND severity in (3) GROUP BY plugin_id ORDER BY count(plugin_id) DESC LIMIT 5").map(&:plugin_id)


#print out the header, centered
pdf.text("CONFIDENTIAL", :font_size => 16, :justification => :center)
#pdf.text("UNCLASSIFIED", :font_size => 16, :justification => :center)
pdf.text("\n")
pdf.text(assessment_title, :font_size => 20, :justification => :center)
pdf.text("Information Systems Risk Report", :font_size => 16, :justification => :center)
pdf.text("\n")
pdf.text("This report prepared by:", :font_size => 12, :justification => :center)
pdf.text(assessment_assessor, :font_size => 12, :justification => :center)
pdf.text("\n")
pdf.text("\n")

#print out the executive summary ( pdf/writer indents by default)
pdf.text("<b>Executive Summary</b>", :font_size => 14, :justification => :left)
pdf.text("This report details the findings discovered during an audit of the networks operated by #{assessment_title} on #{assessment_date} by #{company_name}. #{assessment_objective}. The primary activity executed by #{company_name} was to evaluate the security of the network at #{assessment_title} by performing an on-site assessment of computer network security through automated scanning and analysis. This engagement did not include the auditing of wireless devices, external networks or system exploitation. ", :font_size => 12, :justification => :left)
pdf.text("\n")
#pdf.text("\tThis report details information system risks discovered during an audit of the networks operated by #{assessment_title} on #{assessment_date} by RT & Associates. The primary activity executed by RT & Associates was to evaluate the security of the network at #{assessment_title} by performing an on site assessment of computer network security, excluding wireless device scanning and detection. There were a total of #{numofhosts} hosts scanned during this assessment with a total of #{numofrisks} risks discovered during this assessment. The majority of risks discovered can easiled be corrected with simple configuration changes to the affected system or the application of the appropriate patch. Due to the limited time frame of the assessment and the fact that networks are dynamic entities, vulnerabilities may arise that were not identified during this assessment. Because new vulnerabilities emerge often, networks require continuing vigilance to mitigate these vulnerabilities and threats.", :font_size => 12, :justification => :left)
pdf.text("#{company_name} identified a total of #{findings.number_of_hosts} hosts containing a total of #{findings.number_of_risks} risks discovered during this assessment. The majority of the risks discovered can easily be corrected through configuration changes, system hardening, and effective patch management. Due to the scoping of this engagement and the fact that networks are dynamic entities, vulnerabilities may arise that were not identified during this assessment. Because new vulnerabilities emerge often, networks require continued vigilance to mitigate the potential for threats to exploit vulnerabilities.", :font_size => 12, :justification => :left)
pdf.text("\n")

#Scope may change by assessment and things performed
#pdf.text("<b>Scope</b>", :font_size => 14, :justification => :left)<commit_msg>Abstracting the report generation script<commit_after>#!/usr/bin/env ruby

require 'rubygems'
require "pdf/writer"
require 'choice'
require 'nessus_db_model'
require 'findings'

module NessusDB
  class ExecutiveSummary
	attr_accessor :title, :author, :classification, :findings, :output_file, :date
	PROGRAM_VERSION = "1.0"
    def generate_report
    end
    
    def main
		Choice.options do
	    	banner sprintf 'NessusDB - Executive Summary Generator v%s', PROGRAM_VERSION
	        header '<NAME>'
    	    header 'http://hammackj.com'
        	header 'Usage: executive_summary.rb [OPTIONS]'
	        header ''

    	    header 'Options:'
    
        	option :author do
          		short '-a'
		        long '--author AUTHOR'
          		desc 'Author of the report'
	        end

        	option :title do
          		short '-t'
		        long '--title TITLE'
          		desc 'Title of the report'
			end
			
			option :date do
				short '-d'
				long '--date DATE'
				desc 'Date of assessment'
			end
  
		end
    end
  end
end



report = "report-mccamey.pdf"
assessment_title = "McCamey Hospital"

assessment_date = "24 May 2010"
assessment_assessor = "<NAME>, CISSP"
company_name = "RT & Associates"
assessment_objective = "The primary objective of this engagement was to fulfill requirements for annual security assessments under the HIPAA guidelines"

#assessment_title = "SIAN"
#company_name = "Tangent Security"
#assessment_objective = "The primary objective of this engagement was to fulfill requirements for network certification"

#create our new pdf
pdf = PDF::Writer.new
#set the PDFS Font
pdf.select_font "Times-Roman"

findings = Findings.new
#findings.number_of_hosts = Host.find(:all).count
#findings.number_of_risks = Item.find(:all, :conditions => ["severity IN (0,1,2,3,4)"]).count
#findings.number_of_critical = Item.find(:all, :conditions => ["severity = 3"]).count
#findings.number_of_high = Item.find(:all, :conditions => ["severity = 2"]).count
#findings.number_of_medium = Item.find(:all, :conditions => ["severity = 1"]).count
#findings.number_of_low = Item.find(:all, :conditions => ["severity = 0"]).count
#findings.number_of_none = Item.find(:all, :conditions => ["severity = 0"]).count
#findings.findings_by_service = Item.find_by_sql("SELECT svc_name, count(*) as c FROM items where svc_name != 'unknown' and svc_name != 'general' group by svc_name order by c desc limit 10").map(&:svc_name)#Item.find(:all, :group => :svc_name).map(&:svc_name)
#findings.other_operating_systems = Host.find(:all, :conditions => ["os not like '%%Windows%%'"], :group => :os).map(&:os)
#findings.windows_operating_systems = Host.find(:all, :conditions => ["os like '%%Windows%%'"], :group => :os).map(&:os)
#findings.critical_findings = Item.find(:all, :conditions => ["severity = 3"], :joins => "INNER JOIN plugins ON items.plugin_id = plugins.id", :order => 'plugins.cvss_base_score')
#findings.high_findings = Item.find(:all, :conditions => ["severity = 2"])
#findings.top_plugins = Item.find_by_sql("SELECT *, count(plugin_id) FROM items WHERE plugin_id NOT IN (1) AND severity in (3) GROUP BY plugin_id ORDER BY count(plugin_id) DESC LIMIT 5").map(&:plugin_id)


#print out the header, centered
pdf.text("CONFIDENTIAL", :font_size => 16, :justification => :center)
#pdf.text("UNCLASSIFIED", :font_size => 16, :justification => :center)
pdf.text("\n")
pdf.text(assessment_title, :font_size => 20, :justification => :center)
pdf.text("Information Systems Risk Report", :font_size => 16, :justification => :center)
pdf.text("\n")
pdf.text("This report prepared by:", :font_size => 12, :justification => :center)
pdf.text(assessment_assessor, :font_size => 12, :justification => :center)
pdf.text("\n")
pdf.text("\n")

#print out the executive summary ( pdf/writer indents by default)
pdf.text("<b>Executive Summary</b>", :font_size => 14, :justification => :left)
pdf.text("This report details the findings discovered during an audit of the networks operated by #{assessment_title} on #{assessment_date} by #{company_name}. #{assessment_objective}. The primary activity executed by #{company_name} was to evaluate the security of the network at #{assessment_title} by performing an on-site assessment of computer network security through automated scanning and analysis. This engagement did not include the auditing of wireless devices, external networks or system exploitation. ", :font_size => 12, :justification => :left)
pdf.text("\n")
#pdf.text("\tThis report details information system risks discovered during an audit of the networks operated by #{assessment_title} on #{assessment_date} by RT & Associates. The primary activity executed by RT & Associates was to evaluate the security of the network at #{assessment_title} by performing an on site assessment of computer network security, excluding wireless device scanning and detection. There were a total of #{numofhosts} hosts scanned during this assessment with a total of #{numofrisks} risks discovered during this assessment. The majority of risks discovered can easiled be corrected with simple configuration changes to the affected system or the application of the appropriate patch. Due to the limited time frame of the assessment and the fact that networks are dynamic entities, vulnerabilities may arise that were not identified during this assessment. Because new vulnerabilities emerge often, networks require continuing vigilance to mitigate these vulnerabilities and threats.", :font_size => 12, :justification => :left)
pdf.text("#{company_name} identified a total of #{findings.number_of_hosts} hosts containing a total of #{findings.number_of_risks} risks discovered during this assessment. The majority of the risks discovered can easily be corrected through configuration changes, system hardening, and effective patch management. Due to the scoping of this engagement and the fact that networks are dynamic entities, vulnerabilities may arise that were not identified during this assessment. Because new vulnerabilities emerge often, networks require continued vigilance to mitigate the potential for threats to exploit vulnerabilities.", :font_size => 12, :justification => :left)
pdf.text("\n")

#Scope may change by assessment and things performed
#pdf.text("<b>Scope</b>", :font_size => 14, :justification => :left)
{'fraction_non_alphanumeric': 0.11272169167803547, 'fraction_numerical': 0.007844474761255117, 'mean_word_length': 5.437431394072448, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 88, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '877843', 'n_tokens_mistral': 3441, 'n_tokens_neox': 3229, 'n_words': 1221}