Commit 1acce89a authored by ale's avatar ale

Automatically recompute integrity hashes in templates

Uses 'go generate' to invoke sri.py.
parent 85ff167e
Pipeline #604 passed with stages
in 4 minutes and 8 seconds
......@@ -1239,7 +1239,7 @@ var _templatesPageHtml = []byte(`{{define "header"}}<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{if .U2FSignRequest}}<meta name="u2f_request" value="{{json .U2FSignRequest}}">{{end}}
<link rel="stylesheet" href="/static/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M">
<link rel="stylesheet" href="/static/css/signin.css" integrity="sha384-zxlIX2SfN6SpDKbrkQNcrn07kaD/iSlYdEKRCab8ZAcTEvpWshVV4xqTpoQaeyPq">
<link rel="stylesheet" href="/static/css/signin.css" integrity="sha384-cd2kbbMX+cYhUlp/Xc7Mu9yBphBGNEvZpeIltWsgUMlkt1kNO3hytQQeTglDcMF/">
<title>Sign In</title>
</head>
......@@ -1255,7 +1255,7 @@ var _templatesPageHtml = []byte(`{{define "header"}}<!DOCTYPE html>
<script src="/static/js/bootstrap-4.0.0-beta.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"></script>
{{if .U2FSignRequest}}
<script type="text/javascript" src="/static/js/u2f-api.js" integrity="sha384-9ChevE6pp8ArGK03HgolnFjZbF3webZQtYkwcabzbcI28Lx1/2x2j2fbaAWD4cgR"></script>
<script type="text/javascript" src="/static/js/u2f.js" integrity="sha384-Aw1M0kx84dOGmcbSKwVf6MWXFfyF8YK7LFfpAPqBMG+843kqUeyHNUpEom8kSIiz"></script>
<script type="text/javascript" src="/static/js/u2f.js" integrity="sha384-vd6lytRvVm189G5gr34wlOvN672vVBceTZqV+lTSeec0DBLc0GlWLyKDHc6mrIZS"></script>
{{end}}
</body>
</html>
......@@ -1272,7 +1272,7 @@ func templatesPageHtml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "templates/page.html", size: 1493, mode: os.FileMode(436), modTime: time.Unix(1510996183, 0)}
info := bindataFileInfo{name: "templates/page.html", size: 1493, mode: os.FileMode(436), modTime: time.Unix(1511203590, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
......
package server
//go:generate python sri.py templates/*.html
//go:generate go-bindata --nocompress --pkg server static/... templates/...
import (
......
......@@ -3,9 +3,10 @@
# Automatically fix Subresource Integrity links in the HTML templates.
#
# Pass templates as command-line arguments. Expects to be run from the
# resources/ directory.
# base resource directory.
#
import glob
import re
import sys
from hashlib import sha384
......@@ -44,9 +45,10 @@ def fix_sri(path):
if __name__ == '__main__':
for path in sys.argv[1:]:
try:
fix_sri(path)
except Exception as e:
print >>sys.stderr, "Error fixing %s: %s" % (path, e)
for arg in sys.argv[1:]:
for path in glob.glob(arg):
try:
fix_sri(path)
except Exception as e:
print >>sys.stderr, "Error fixing %s: %s" % (path, e)
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{{if .U2FSignRequest}}<meta name="u2f_request" value="{{json .U2FSignRequest}}">{{end}}
<link rel="stylesheet" href="/static/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M">
<link rel="stylesheet" href="/static/css/signin.css" integrity="sha384-zxlIX2SfN6SpDKbrkQNcrn07kaD/iSlYdEKRCab8ZAcTEvpWshVV4xqTpoQaeyPq">
<link rel="stylesheet" href="/static/css/signin.css" integrity="sha384-cd2kbbMX+cYhUlp/Xc7Mu9yBphBGNEvZpeIltWsgUMlkt1kNO3hytQQeTglDcMF/">
<title>Sign In</title>
</head>
......@@ -21,7 +21,7 @@
<script src="/static/js/bootstrap-4.0.0-beta.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1"></script>
{{if .U2FSignRequest}}
<script type="text/javascript" src="/static/js/u2f-api.js" integrity="sha384-9ChevE6pp8ArGK03HgolnFjZbF3webZQtYkwcabzbcI28Lx1/2x2j2fbaAWD4cgR"></script>
<script type="text/javascript" src="/static/js/u2f.js" integrity="sha384-Aw1M0kx84dOGmcbSKwVf6MWXFfyF8YK7LFfpAPqBMG+843kqUeyHNUpEom8kSIiz"></script>
<script type="text/javascript" src="/static/js/u2f.js" integrity="sha384-vd6lytRvVm189G5gr34wlOvN672vVBceTZqV+lTSeec0DBLc0GlWLyKDHc6mrIZS"></script>
{{end}}
</body>
</html>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment