Compare commits
5
Commits
7a2fa00f4a
..
v0.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ceeabc810 | ||
|
|
aca99bc6d4 | ||
|
|
073d39ccba | ||
|
|
9ec7d5152e | ||
|
|
a677e627a8 |
@@ -16,7 +16,7 @@ func TestSecurityHeaders(t *testing.T) {
|
|||||||
h := SecurityHeaders(pages)
|
h := SecurityHeaders(pages)
|
||||||
rec := httptest.NewRecorder()
|
rec := httptest.NewRecorder()
|
||||||
h.ServeHTTP(rec, httptest.NewRequest("GET", "/", nil))
|
h.ServeHTTP(rec, httptest.NewRequest("GET", "/", nil))
|
||||||
wantCSP := "default-src 'self'; script-src 'self' 'unsafe-inline'; frame-ancestors 'none'"
|
wantCSP := "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; frame-ancestors 'none'"
|
||||||
if got := rec.Header().Get("Content-Security-Policy"); got != wantCSP {
|
if got := rec.Header().Get("Content-Security-Policy"); got != wantCSP {
|
||||||
t.Errorf("CSP = %q, want %q", got, wantCSP)
|
t.Errorf("CSP = %q, want %q", got, wantCSP)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
btn.className = 'theme-card';
|
btn.className = 'theme-card';
|
||||||
btn.setAttribute('aria-pressed', current === t.id ? 'true' : 'false');
|
btn.setAttribute('aria-pressed', current === t.id ? 'true' : 'false');
|
||||||
btn.innerHTML = '<strong>' + t.name + '</strong>' +
|
btn.innerHTML = '<strong>' + t.name + '</strong>' +
|
||||||
'<span class="swatches">' + t.colors.map(function (c) {
|
'<span class="swatches">' + colors.map(function (c) {
|
||||||
return '<span class="swatch" style="background:' + c + '"></span>';
|
return '<span class="swatch" style="background:' + c + '"></span>';
|
||||||
}).join('') + '</span>';
|
}).join('') + '</span>';
|
||||||
btn.addEventListener('click', function () {
|
btn.addEventListener('click', function () {
|
||||||
|
|||||||
+1
-1
@@ -344,7 +344,7 @@ func SecurityHeaders(next http.Handler) http.Handler {
|
|||||||
// is harmless and arguably desirable.
|
// is harmless and arguably desirable.
|
||||||
h := w.Header()
|
h := w.Header()
|
||||||
h.Set("Content-Security-Policy",
|
h.Set("Content-Security-Policy",
|
||||||
"default-src 'self'; script-src 'self' 'unsafe-inline'; frame-ancestors 'none'")
|
"default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; frame-ancestors 'none'")
|
||||||
h.Set("Referrer-Policy", "no-referrer")
|
h.Set("Referrer-Policy", "no-referrer")
|
||||||
h.Set("X-Content-Type-Options", "nosniff")
|
h.Set("X-Content-Type-Options", "nosniff")
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
|
|||||||
Reference in New Issue
Block a user