Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable insecure HTTP-methods #29

Open
rndmh3ro opened this issue Aug 21, 2018 · 0 comments
Open

Disable insecure HTTP-methods #29

rndmh3ro opened this issue Aug 21, 2018 · 0 comments

Comments

@rndmh3ro
Copy link
Member

Test nginx-14 checks if the string if ( $request_method !~ ^(GET|HEAD|POST)$ ) { exists in the in the nginx.conf. So far, so good. However there should also be a check that the correct error-code is returned, if the wrong request method is used.

Therefore I propose the following regex that checks if the output of nginx -T contains the following:

if ( $request_method !~ ^(GET|HEAD|POST)$ ) {
 return 405;
 }

the regex:

  describe parse_config(nginx_parsed_config, options) do
    its('content') { should match(/^\s*if\s+\(\s*\$request_method\s+\!\~\s+\^\(#{HTTP_METHODS}\)\$\s*\)\s*\{?$\s*return\s+405;\s+}$/) }
  end

Regexr:
https://regexr.com/3u94m

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant