Class: Dawn::Kb::OwaspRorCheatSheet::SecurityRelatedHeaders

Inherits:
Object
  • Object
show all
Includes:
PatternMatchCheck
Defined in:
lib/dawn/kb/owasp_ror_cheatsheet/security_related_headers.rb

Constant Summary

Constants included from PatternMatchCheck

PatternMatchCheck::EXCLUSION_LIST

Constants included from BasicCheck

BasicCheck::ALLOWED_FAMILIES

Instance Attribute Summary

Attributes included from PatternMatchCheck

#attack_pattern, #attack_pattern_is_regex, #avoid_comments, #negative_search, #root_dir

Attributes included from BasicCheck

#applies, #aux_links, #check_family, #cve, #cvss, #cwe, #debug, #evidences, #fixes_version, #kind, #message, #mitigated, #name, #osvdb, #owasp, #priority, #release_date, #remediation, #ruby_version, #ruby_vulnerable_versions, #severity, #status, #target_version, #title

Instance Method Summary collapse

Methods included from PatternMatchCheck

#must_exclude?, #vuln?

Methods included from BasicCheck

#applies_to?, #cve_link, #cvss_score, families, #family, #family=, #lint, #mitigated?, #nvd_link, #osvdb_link, #rubysec_advisories_link

Methods included from Utils

#__debug_me_and_return, #debug_me, #debug_me_and_return_false, #debug_me_and_return_true

Constructor Details

#initializeSecurityRelatedHeaders

Returns a new instance of SecurityRelatedHeaders.


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dawn/kb/owasp_ror_cheatsheet/security_related_headers.rb', line 7

def initialize
  message = "To set a header value, simply access the response.headers object as a hash inside your controller (often in a before/after_filter). Rails 4 provides the \"default_headers\" functionality that will automatically apply the values supplied. This works for most headers in almost all cases."

  super({
    :name=>"Owasp Ror CheatSheet: Security Related Headers",
    :kind=>Dawn::KnowledgeBase::PATTERN_MATCH_CHECK,
    :applies=>["rails"],
    :glob=>"**/controllers/*.rb",
    :aux_links=>["https://www.owasp.org/index.php/Ruby_on_Rails_Cheatsheet"],
    :message=>message,
    :attack_pattern => [
      "response.headers\\['X-Frame-Options'\\] = 'DENY'",
      "response.headers\\['X-Content-Type-Options'\\] = 'nosniff'",
      "response.headers\\['X-XSS-Protection'\\] = '1'",
      "ActionDispatch::Response.default_headers = {
          'X-Frame-Options' => 'DENY',
          'X-Content-Type-Options' => 'nosniff',
          'X-XSS-Protection' => '1;'
        }"],
    :negative_search=>true,
    :check_family=>:owasp_ror_cheatsheet,
    :severity=>:info,
    :mitigation=>"Use response headers like X-Frame-Options, X-Content-Type-Options, X-XSS-Protection in your project."
  })
end