PolyGerrit: Run crisper after vulcanizing

This makes the app CSP compliant[1] by splitting out JS from HTML.

[1] http://www.html5rocks.com/en/tutorials/security/content-security-policy/#inline-code-considered-harmful

Change-Id: Ifec20c0d7ebcaab6df905a16c3621ecffb80ae98
This commit is contained in:
Dave Borowitz
2015-12-04 13:16:43 -05:00
parent 6fc269e537
commit d8a42b3c2a
3 changed files with 26 additions and 7 deletions

View File

@@ -142,16 +142,28 @@ def vulcanize(
extra_flags = [],
visibility = ['PUBLIC']):
genrule(
name = name,
name = '%s__vulcanized' % name,
cmd = ' '.join([
'unzip', '-qd', '$SRCDIR',
] + ['$(location %s)' % c for c in components] + [
'unzip', '-qd', '$SRCDIR', '$(location %s)' % components,
'&&', run_npm_binary('//lib/js:vulcanize')
] + VULCANIZE_FLAGS + extra_flags + [
'--out-html', '$OUT',
'$SRCDIR/%s' % app,
]),
srcs = srcs,
out = '%s.html' % name,
out = '%s.vulcanized.html' % name,
visibility = visibility,
)
genrule(
name = name,
cmd = ' '.join([
'cd', '$TMP',
'&&', run_npm_binary('//lib/js:crisper'), '--always-write-script',
'--source', '$(location :%s__vulcanized)' % name,
'--html', '%s.vulcanized.html' % name,
'--js', '%s.js' % name,
'&&', 'zip', '$OUT', '%s.vulcanized.html' % name, '%s.js' % name,
]),
out = '%s.vulcanized.zip',
)

View File

@@ -21,6 +21,13 @@ npm_binary(
sha1 = '59d457122a161e42cc1625bbab8179c214b7ac11',
)
npm_binary(
name = 'crisper',
version = '2.0.1',
sha1 = 'b3b8bacc1f6d119af26664b8620e6a978aa7f7d3',
repository = GERRIT,
)
npm_binary(
name = 'vulcanize',
version = '1.14.0',

View File

@@ -23,7 +23,7 @@ genrule(
'cd $TMP/polygerrit_ui',
'cp $(location :processed_index) index.html',
'mkdir -p {elements,bower_components/webcomponentsjs}',
'cp $(location :polygerrit) elements/gr-app.vulcanized.html',
'unzip -qd elements $(location :gr-app)',
'cp -rp $SRCDIR/* .',
'unzip -p $(location //polygerrit-ui:polygerrit_components) %s>%s' % (WEBJS, WEBJS),
'cd $TMP',
@@ -45,10 +45,10 @@ genrule(
)
vulcanize(
name = 'polygerrit',
name = 'gr-app',
app = 'elements/gr-app.html',
srcs = APP_SRCS,
components = ['//polygerrit-ui:polygerrit_components'],
components = '//polygerrit-ui:polygerrit_components',
)