Skip to content

Commit

Permalink
Merge pull request #26 from woneill/optional_tests
Browse files Browse the repository at this point in the history
Make nginx-14 and nginx-16 disabled by default based on #21
  • Loading branch information
chris-rock authored Nov 21, 2018
2 parents 591c291 + fc43237 commit a23b568
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions controls/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@
default: 'GET\|HEAD\|POST'
)

HTTP_METHODS_CHECK = attribute(
'http_methods_check',
description: 'Defines if http_methods should be checked in the nginx configuration',
default: false
)

NGINX_COOKIE_FLAG_MODULE = attribute(
'nginx_cookie_flag_module',
description: 'Defines if nginx has been compiled with nginx_cookie_flag_module',
default: false
)

only_if do
command('nginx').exist?
end
Expand Down Expand Up @@ -241,6 +253,7 @@
desc 'Disable insecure HTTP-methods and allow only necessary methods.'
ref 'OWASP HTTP Methods', url: 'https://www.owasp.org/index.php/Test_HTTP_Methods_(OTG-CONFIG-006)'

only_if { HTTP_METHODS_CHECK != false }
describe file(nginx_conf) do
its('content') { should match(/^\s*if\s+\(\$request_method\s+\!\~\s+\^\(#{HTTP_METHODS}\)\$\)\{?$/) }
end
Expand All @@ -259,6 +272,7 @@
impact 1.0
title 'Set cookie with HttpOnly and Secure flag'
desc 'You can mitigate most of the common Cross Site Scripting attack using HttpOnly and Secure flag in a cookie. Without having HttpOnly and Secure, it is possible to steal or manipulate web application session and cookies and it’s dangerous.'
only_if { NGINX_COOKIE_FLAG_MODULE != false }
describe parse_config(nginx_parsed_config, options_add_header) do
its('set_cookie_flag') { should include '* HttpOnly secure' }
end
Expand Down

0 comments on commit a23b568

Please sign in to comment.