class Sekureco::HtmlPage

Public Class Methods

new(html_doc) click to toggle source
# File lib/sekureco/html_page.rb, line 7
def initialize html_doc
  @html_doc = Nokogiri::HTML(html_doc)
end

Public Instance Methods

body() click to toggle source
# File lib/sekureco/html_page.rb, line 15
def body
  @html_doc.css("body").to_html
end
content() click to toggle source
# File lib/sekureco/html_page.rb, line 11
def content
  @html_doc.to_html
end
csrf_token() click to toggle source
# File lib/sekureco/html_page.rb, line 41
def csrf_token
  self.has_csrf_tokens? ? @html_doc.css('meta[name="csrf-token"]').first['content'] : ''
end
forms() click to toggle source
# File lib/sekureco/html_page.rb, line 33
def forms
  @html_doc.css("form")
end
has_csrf_tokens?() click to toggle source
# File lib/sekureco/html_page.rb, line 45
def has_csrf_tokens?
  !@html_doc.css('meta[name="csrf-token"]').empty?
end
has_forms?() click to toggle source
# File lib/sekureco/html_page.rb, line 37
def has_forms?
  @html_doc.at_css("form")
end
log() click to toggle source
# File lib/sekureco/html_page.rb, line 53
def log
  Sekureco.logger.info(self.to_s)
  Sekureco.logger.info("\n#{"=" * 80}\n")
end
parsed_body(black_list = []) click to toggle source
# File lib/sekureco/html_page.rb, line 19
def parsed_body black_list = []
  html = self.body.dup
  black_list.each { |word| html.gsub! word, "" }
  html.gsub(/(name=\"authenticity_token\" value=\".*\"|authenticity_token=[^;]*;|\?([^=]+=[^\&\"]+)+)/, '')
end
scripts_with(filter) click to toggle source
# File lib/sekureco/html_page.rb, line 29
def scripts_with filter
  @html_doc.css("script.#{filter}")
end
to_s() click to toggle source
# File lib/sekureco/html_page.rb, line 49
def to_s
  self.parsed_body
end