http-security 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +21 -0
  5. data/.yardopts +1 -0
  6. data/ChangeLog.md +17 -0
  7. data/Gemfile +17 -0
  8. data/LICENSE.txt +20 -0
  9. data/README.md +90 -0
  10. data/Rakefile +34 -0
  11. data/http-security.gemspec +23 -0
  12. data/lib/http/security.rb +2 -0
  13. data/lib/http/security/exceptions.rb +8 -0
  14. data/lib/http/security/headers.rb +12 -0
  15. data/lib/http/security/headers/cache_control.rb +36 -0
  16. data/lib/http/security/headers/content_security_policy.rb +71 -0
  17. data/lib/http/security/headers/content_security_policy_report_only.rb +10 -0
  18. data/lib/http/security/headers/pragma.rb +24 -0
  19. data/lib/http/security/headers/public_key_pins.rb +60 -0
  20. data/lib/http/security/headers/public_key_pins_report_only.rb +10 -0
  21. data/lib/http/security/headers/set_cookie.rb +75 -0
  22. data/lib/http/security/headers/strict_transport_security.rb +29 -0
  23. data/lib/http/security/headers/x_content_type_options.rb +24 -0
  24. data/lib/http/security/headers/x_frame_options.rb +39 -0
  25. data/lib/http/security/headers/x_permitted_cross_domain_policies.rb +47 -0
  26. data/lib/http/security/headers/x_xss_protection.rb +34 -0
  27. data/lib/http/security/http_date.rb +13 -0
  28. data/lib/http/security/malformed_header.rb +33 -0
  29. data/lib/http/security/parsers.rb +14 -0
  30. data/lib/http/security/parsers/cache_control.rb +62 -0
  31. data/lib/http/security/parsers/content_security_policy.rb +128 -0
  32. data/lib/http/security/parsers/content_security_policy_report_only.rb +10 -0
  33. data/lib/http/security/parsers/expires.rb +19 -0
  34. data/lib/http/security/parsers/parser.rb +408 -0
  35. data/lib/http/security/parsers/pragma.rb +25 -0
  36. data/lib/http/security/parsers/public_key_pins.rb +43 -0
  37. data/lib/http/security/parsers/public_key_pins_report_only.rb +10 -0
  38. data/lib/http/security/parsers/set_cookie.rb +62 -0
  39. data/lib/http/security/parsers/strict_transport_security.rb +42 -0
  40. data/lib/http/security/parsers/x_content_type_options.rb +19 -0
  41. data/lib/http/security/parsers/x_frame_options.rb +47 -0
  42. data/lib/http/security/parsers/x_permitted_cross_domain_policies.rb +33 -0
  43. data/lib/http/security/parsers/x_xss_protection.rb +27 -0
  44. data/lib/http/security/response.rb +323 -0
  45. data/lib/http/security/version.rb +5 -0
  46. data/spec/data/alexa.csv +100 -0
  47. data/spec/headers/cache_control_spec.rb +40 -0
  48. data/spec/headers/content_security_policy_spec.rb +46 -0
  49. data/spec/headers/pragma_spec.rb +26 -0
  50. data/spec/headers/public_key_pins_spec.rb +68 -0
  51. data/spec/headers/set_cookie_spec.rb +122 -0
  52. data/spec/headers/strict_transport_security_spec.rb +39 -0
  53. data/spec/headers/x_content_type_options_spec.rb +26 -0
  54. data/spec/headers/x_frame_options_spec.rb +86 -0
  55. data/spec/headers/x_permitted_cross_domain_policies_spec.rb +108 -0
  56. data/spec/headers/x_xss_protection_spec.rb +59 -0
  57. data/spec/parsers/cache_control_spec.rb +26 -0
  58. data/spec/parsers/content_security_policy_report_only_spec.rb +48 -0
  59. data/spec/parsers/content_security_policy_spec.rb +74 -0
  60. data/spec/parsers/expires_spec.rb +71 -0
  61. data/spec/parsers/parser_spec.rb +317 -0
  62. data/spec/parsers/pragma_spec.rb +10 -0
  63. data/spec/parsers/public_key_pins_spec.rb +81 -0
  64. data/spec/parsers/set_cookie_spec.rb +55 -0
  65. data/spec/parsers/strict_transport_security_spec.rb +62 -0
  66. data/spec/parsers/x_content_type_options_spec.rb +10 -0
  67. data/spec/parsers/x_frame_options_spec.rb +24 -0
  68. data/spec/parsers/x_permitted_cross_domain_policies_spec.rb +34 -0
  69. data/spec/parsers/x_xss_protection_spec.rb +39 -0
  70. data/spec/response_spec.rb +262 -0
  71. data/spec/spec_helper.rb +13 -0
  72. data/tasks/alexa.rb +40 -0
  73. metadata +171 -0
@@ -0,0 +1,40 @@
1
+ ##
2
+ # Adapted from gist: https://gist.github.com/zerothabhishek/3015666
3
+ # Orginal author: zerothabhishek
4
+ #
5
+ # How to run:
6
+ # ruby scraper.rb
7
+ #
8
+ # Output:
9
+ # CSV file containing alexa 100
10
+ #
11
+ # Dependencies:
12
+ # ruby version > 1.9 # "ruby -v" to check
13
+ # nokogiri gem # "gem install nokogiri" to install
14
+ ##
15
+
16
+ require 'nokogiri'
17
+ require 'open-uri'
18
+ require 'csv'
19
+
20
+ namespace :alexa do
21
+ desc 'Scrapes the Alexa Top 100 and updates spec/data/alexa.csv'
22
+ task :scrape do
23
+ CSV.open("spec/data/alexa.csv","w") do |csv|
24
+ (0..3).each do |i|
25
+ url = "http://www.alexa.com/topsites/global;#{i} "
26
+ doc = Nokogiri::HTML(open(url))
27
+
28
+ doc.css(".site-listing").each do |li|
29
+ begin
30
+ site_name = li.css(".desc-container .desc-paragraph a")[0].content
31
+ site_rank = li.css(".count")[0].content
32
+
33
+ csv << [site_rank, site_name]
34
+ rescue
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: http-security
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dominic Owen
8
+ - Hal Brodigan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-07-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: parslet
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.5'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.5'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.0'
42
+ description: HTTP Security Header Parser
43
+ email:
44
+ - dwowen20@gmail.com
45
+ - hal@trailofbits.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - ".travis.yml"
53
+ - ".yardopts"
54
+ - ChangeLog.md
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - http-security.gemspec
60
+ - lib/http/security.rb
61
+ - lib/http/security/exceptions.rb
62
+ - lib/http/security/headers.rb
63
+ - lib/http/security/headers/cache_control.rb
64
+ - lib/http/security/headers/content_security_policy.rb
65
+ - lib/http/security/headers/content_security_policy_report_only.rb
66
+ - lib/http/security/headers/pragma.rb
67
+ - lib/http/security/headers/public_key_pins.rb
68
+ - lib/http/security/headers/public_key_pins_report_only.rb
69
+ - lib/http/security/headers/set_cookie.rb
70
+ - lib/http/security/headers/strict_transport_security.rb
71
+ - lib/http/security/headers/x_content_type_options.rb
72
+ - lib/http/security/headers/x_frame_options.rb
73
+ - lib/http/security/headers/x_permitted_cross_domain_policies.rb
74
+ - lib/http/security/headers/x_xss_protection.rb
75
+ - lib/http/security/http_date.rb
76
+ - lib/http/security/malformed_header.rb
77
+ - lib/http/security/parsers.rb
78
+ - lib/http/security/parsers/cache_control.rb
79
+ - lib/http/security/parsers/content_security_policy.rb
80
+ - lib/http/security/parsers/content_security_policy_report_only.rb
81
+ - lib/http/security/parsers/expires.rb
82
+ - lib/http/security/parsers/parser.rb
83
+ - lib/http/security/parsers/pragma.rb
84
+ - lib/http/security/parsers/public_key_pins.rb
85
+ - lib/http/security/parsers/public_key_pins_report_only.rb
86
+ - lib/http/security/parsers/set_cookie.rb
87
+ - lib/http/security/parsers/strict_transport_security.rb
88
+ - lib/http/security/parsers/x_content_type_options.rb
89
+ - lib/http/security/parsers/x_frame_options.rb
90
+ - lib/http/security/parsers/x_permitted_cross_domain_policies.rb
91
+ - lib/http/security/parsers/x_xss_protection.rb
92
+ - lib/http/security/response.rb
93
+ - lib/http/security/version.rb
94
+ - spec/data/alexa.csv
95
+ - spec/headers/cache_control_spec.rb
96
+ - spec/headers/content_security_policy_spec.rb
97
+ - spec/headers/pragma_spec.rb
98
+ - spec/headers/public_key_pins_spec.rb
99
+ - spec/headers/set_cookie_spec.rb
100
+ - spec/headers/strict_transport_security_spec.rb
101
+ - spec/headers/x_content_type_options_spec.rb
102
+ - spec/headers/x_frame_options_spec.rb
103
+ - spec/headers/x_permitted_cross_domain_policies_spec.rb
104
+ - spec/headers/x_xss_protection_spec.rb
105
+ - spec/parsers/cache_control_spec.rb
106
+ - spec/parsers/content_security_policy_report_only_spec.rb
107
+ - spec/parsers/content_security_policy_spec.rb
108
+ - spec/parsers/expires_spec.rb
109
+ - spec/parsers/parser_spec.rb
110
+ - spec/parsers/pragma_spec.rb
111
+ - spec/parsers/public_key_pins_spec.rb
112
+ - spec/parsers/set_cookie_spec.rb
113
+ - spec/parsers/strict_transport_security_spec.rb
114
+ - spec/parsers/x_content_type_options_spec.rb
115
+ - spec/parsers/x_frame_options_spec.rb
116
+ - spec/parsers/x_permitted_cross_domain_policies_spec.rb
117
+ - spec/parsers/x_xss_protection_spec.rb
118
+ - spec/response_spec.rb
119
+ - spec/spec_helper.rb
120
+ - tasks/alexa.rb
121
+ homepage: https://github.com/trailofbits/http-security#readme
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 1.9.1
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.4.7
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: HTTP Security Header Parser
145
+ test_files:
146
+ - spec/data/alexa.csv
147
+ - spec/headers/cache_control_spec.rb
148
+ - spec/headers/content_security_policy_spec.rb
149
+ - spec/headers/pragma_spec.rb
150
+ - spec/headers/public_key_pins_spec.rb
151
+ - spec/headers/set_cookie_spec.rb
152
+ - spec/headers/strict_transport_security_spec.rb
153
+ - spec/headers/x_content_type_options_spec.rb
154
+ - spec/headers/x_frame_options_spec.rb
155
+ - spec/headers/x_permitted_cross_domain_policies_spec.rb
156
+ - spec/headers/x_xss_protection_spec.rb
157
+ - spec/parsers/cache_control_spec.rb
158
+ - spec/parsers/content_security_policy_report_only_spec.rb
159
+ - spec/parsers/content_security_policy_spec.rb
160
+ - spec/parsers/expires_spec.rb
161
+ - spec/parsers/parser_spec.rb
162
+ - spec/parsers/pragma_spec.rb
163
+ - spec/parsers/public_key_pins_spec.rb
164
+ - spec/parsers/set_cookie_spec.rb
165
+ - spec/parsers/strict_transport_security_spec.rb
166
+ - spec/parsers/x_content_type_options_spec.rb
167
+ - spec/parsers/x_frame_options_spec.rb
168
+ - spec/parsers/x_permitted_cross_domain_policies_spec.rb
169
+ - spec/parsers/x_xss_protection_spec.rb
170
+ - spec/response_spec.rb
171
+ - spec/spec_helper.rb