]> iEval git - gruntmaster-page.git/commitdiff
Use Subresource Integrity
authorMarius Gavrilescu <marius@ieval.ro>
Wed, 15 Apr 2015 15:47:26 +0000 (18:47 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Wed, 15 Apr 2015 17:08:38 +0000 (20:08 +0300)
make_static.PL
tmpl/skel.en

index 10532b9a8dbd502663ba66c505f36b92534d592c..758efc1f39349e85975563488c3ba2a9ecf90dd6 100644 (file)
@@ -5,8 +5,9 @@ use warnings;
 use CSS::Minifier::XS qw//;
 use JavaScript::Minifier::XS qw//;
 
+use Digest::SHA qw/sha256_base64/;
 use IO::Compress::Gzip qw/gzip/;
-use File::Slurp qw/read_file write_file/;
+use File::Slurp qw/read_file write_file edit_file_lines/;
 
 mkdir 'static';
 mkdir 'static/css';
@@ -57,3 +58,10 @@ for (<js/*>) {
                last
        }
 }
+
+edit_file_lines {
+       my ($file) = m,(static.*\.(?:css|js)),;
+       return unless $file;
+       my $hash = sha256_base64 scalar read_file $file;
+       s/integrity=".*"/integrity="sha256-$hash="/;
+} 'tmpl/skel.en'
index 3006e14decbb10c51aaf03c6107e31f31d481d23..459d37b1dac02e040be8189b0ea7204b3a9ef7f7 100644 (file)
@@ -3,10 +3,10 @@
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 
-<link href="/static/css/cyborg.css" title="cyborg" rel="stylesheet">
-<link href="/static/css/slate.css" title="slate" rel="alternate stylesheet">
-<link href="/static/css/readable.css" title="readable" rel="alternate stylesheet">
-<script src="/static/js.js" type="text/javascript" async defer></script>
+<link href="/static/css/cyborg.css" title="cyborg" rel="stylesheet" integrity="x">
+<link href="/static/css/slate.css" title="slate" rel="alternate stylesheet" integrity="x">
+<link href="/static/css/readable.css" title="readable" rel="alternate stylesheet" integrity="x">
+<script src="/static/js.js" type="text/javascript" async defer integrity="x"></script>
 
 <body>
 <div class="container-fluid">
This page took 0.033076 seconds and 4 git commands to generate.