Http Headers Verifier
Assertation framework for http-headers on top of live endpoints, Verify a pre-defined HTTP headers configurations.
Unlike some other similar projects, this is not meant to enforce best practices, instead it is meant to define policies on top of headers and enforce them. As a side effect, this means you can define specific OWASP (for example) best practices and verify them, but unlike testing for best practices, this is inteneded to verify an expected headers configuration behavior.
Relevant use cases are for example when updating nginx/caddy configuration or when moving from one web-server to another and expecting to maintain a specific set of header config.
Usage
usage: http-headers-verifier.rb [comma seperated policy names] [url] [?verbose]
Example
$> http-headers-verifier.rb default,hs-default https://my.login.page/login verbose
Starting verification of policies default, hs-default, hs-production:
π Expected Header 'Cache-Control' matched!
π Expected Header 'Content-Type' matched!
π Expected Header 'Vary' matched!
π Expected Header 'Content-Security-Policy' matched!
π Expected Header 'Expires' matched!
π Expected Header 'X-Frame-Options' matched!
π Expected Header 'X-XSS-Protection' matched!
π Expected Header 'X-Content-Type-Options' matched!
π Expected Header 'X-Whoami' matched!
π Expected Header 'Strict-Transport-Security' matched!
π Extra Header 'date' marked for ignore!
π Extra Header 'content-length' marked for ignore!
π Cookie 'AWSALB' passed verification!
π Cookie 'AWSALBCORS' passed verification!
π Cookie 'session' passed verification!
π Success !
Or in non-verbose mode:
$> http-headers-verifier.rb default,hs-default https://my.login.page/loginlogin
Starting verification of policies default, hs-default, hs-production:
π Invalid cookie config 'COOKIE_NAME':
πΊ Cookie not secure.
π± Failed !
Installation
Add this line to your application's Gemfile:
gem 'http-headers-verifier'
And then execute:
$ bundle
Or install it yourself as:
$ gem install http-headers-verifier
Configuration
Policy configuration is a series of YAML files, with the following naming convention:
headers-rules-*.yml
Where * is the policy named to be used in the command line.
Configuration has the following YMAL blockes:
---
headers:
cookie_attr:
ignored_headers:
headers_to_avoid:
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/AvnerCohen/http-headers-verifier. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Http Headers Verifier
projectβs codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.