Skip to content

Commit

Permalink
Report misconfiguration in console
Browse files Browse the repository at this point in the history
  • Loading branch information
AvnerCohen committed Aug 25, 2020
1 parent c66d21a commit 5558968
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
http-headers-verifier (0.0.9)
http-headers-verifier (1.0.1)
typhoeus (~> 1.4)

GEM
Expand Down
18 changes: 12 additions & 6 deletions exe/http-headers-verifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,18 @@ def verify_headers!(actual_headers, rules)
def read_policies!(policy_files_names)
settings = {headers: [], ignored_headers: [], cookie_attr: {}, headers_to_avoid: []}
policy_files_names.each do |policy_name|
policy_data = YAML.load_file("./#{FILE_NAME_PREFIX}#{policy_name}.yml")

settings[:headers].push(policy_data['headers']) unless policy_data['headers'].nil?
settings[:ignored_headers].push(policy_data['ignored_headers']) unless policy_data['ignored_headers'].nil?
settings[:cookie_attr].merge!(policy_data['cookie_attr']) unless policy_data['cookie_attr'].nil?
settings[:headers_to_avoid].push(policy_data['headers_to_avoid']) unless policy_data['headers_to_avoid'].nil?
file_name = "./#{FILE_NAME_PREFIX}#{policy_name}.yml"
if File.exist?(file_name)
policy_data = YAML.load_file(file_name)
settings[:headers].push(policy_data['headers']) unless policy_data['headers'].nil?
settings[:ignored_headers].push(policy_data['ignored_headers']) unless policy_data['ignored_headers'].nil?
settings[:cookie_attr].merge!(policy_data['cookie_attr']) unless policy_data['cookie_attr'].nil?
settings[:headers_to_avoid].push(policy_data['headers_to_avoid']) unless policy_data['headers_to_avoid'].nil?
else
puts "💔 Misconfiguration, file #{file_name}, does not exist."
exit 1
end

end

settings[:headers].flatten!
Expand Down
2 changes: 1 addition & 1 deletion lib/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module HttpHeadersVerifier
VERSION = "0.0.9"
VERSION = "1.0.1"
end

0 comments on commit 5558968

Please sign in to comment.