File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -138,8 +138,9 @@ The following configuration keys are supported:
138138 server is on a non-standard port. See: [ wrap-ssl-redirect] [ 9 ] .
139139
140140 - ` :xss-protection ` -
141- Enable the X-XSS-Protection header that tells supporting browsers
142- to use heuristics to detect XSS attacks. See: [ wrap-xss-protection] [ 10 ] .
141+ ** Deprecated** Enable the X-XSS-Protection header. This is [ no
142+ longer considered best practice] [ 13 ] and should be avoided.
143+ See: [ wrap-xss-protection] [ 10 ] .
143144
144145- ` :session ` -
145146 A map of options for configuring session handling via the Ring
@@ -175,6 +176,7 @@ The following configuration keys are supported:
175176[ 10 ] : https://ring-clojure.github.io/ring-headers/ring.middleware.x-headers.html#var-wrap-xss-protection
176177[ 11 ] : https://ring-clojure.github.io/ring/ring.middleware.session.html
177178[ 12 ] : https://ring-clojure.github.io/ring/ring.middleware.flash.html
179+ [ 13 ] : https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
178180
179181
180182## License
Original file line number Diff line number Diff line change 4444 :session {:flash true
4545 :cookie-attrs {:http-only true , :same-site :strict }}
4646 :security {:anti-forgery true
47- :xss-protection {:enable? true , :mode :block }
4847 :frame-options :sameorigin
4948 :content-type-options :nosniff }
5049 :static {:resources " public" }
Original file line number Diff line number Diff line change 2222 (is (= (set (keys (:headers resp)))
2323 #{" X-Frame-Options"
2424 " X-Content-Type-Options"
25- " X-XSS-Protection"
2625 " Content-Type"
2726 " Set-Cookie" }))
2827 (is (= (get-in resp [:headers " X-Frame-Options" ]) " SAMEORIGIN" ))
2928 (is (= (get-in resp [:headers " X-Content-Type-Options" ]) " nosniff" ))
30- (is (= (get-in resp [:headers " X-XSS-Protection" ]) " 1; mode=block" ))
3129 (is (= (get-in resp [:headers " Content-Type" ]) " application/octet-stream" ))
3230 (let [set-cookie (first (get-in resp [:headers " Set-Cookie" ]))]
3331 (is (.startsWith set-cookie " ring-session=" ))
9997 (is (= (set (keys (:headers resp)))
10098 #{" X-Frame-Options"
10199 " X-Content-Type-Options"
102- " X-XSS-Protection"
103100 " Strict-Transport-Security"
104101 " Content-Type"
105102 " Set-Cookie" }))
106103 (is (= (get-in resp [:headers " X-Frame-Options" ]) " SAMEORIGIN" ))
107104 (is (= (get-in resp [:headers " X-Content-Type-Options" ]) " nosniff" ))
108- (is (= (get-in resp [:headers " X-XSS-Protection" ]) " 1; mode=block" ))
109105 (is (= (get-in resp [:headers " Strict-Transport-Security" ])
110106 " max-age=31536000; includeSubDomains" ))
111107 (is (= (get-in resp [:headers " Content-Type" ]) " application/octet-stream" ))
171167 (is (= @resp {:status 200
172168 :headers {" Content-Type" " application/octet-stream" }
173169 :body " foo" })))))
170+
171+ (testing " XSS protection enabled"
172+ (let [handler (-> (constantly (response " foo" ))
173+ (wrap-defaults
174+ (-> site-defaults
175+ (assoc-in [:security :xss-protection :enable? ] true )
176+ (assoc-in [:security :xss-protection :mode ] :block ))))
177+ resp (handler (request :get " /" ))]
178+ (is (not (nil? (get-in resp [:headers " X-XSS-Protection" ]))))
179+ (is (= (get-in resp [:headers " X-XSS-Protection" ]) " 1; mode=block" ))))
You can’t perform that action at this time.
0 commit comments