From 019d4676bd1561cf5fba71d00fe4d9699aa21119 Mon Sep 17 00:00:00 2001 From: Luca Guidi Date: Sat, 16 Jul 2016 19:47:31 +0200 Subject: [PATCH] Generate new projects and apps with Subresource Integrity setting for production environment --- lib/hanami/generators/app/application.rb.tt | 5 +++++ .../generators/application/app/config/application.rb.tt | 5 +++++ test/fixtures/cdn/cdn/apps/web/application.rb | 5 +++++ test/fixtures/cdn/cdn_app/config/application.rb | 5 +++++ .../commands/application/new_app/config/application.rb | 5 +++++ test/fixtures/commands/generate/app/application.rb | 5 +++++ test/fixtures/rake/rake_tasks/apps/web/application.rb | 5 +++++ test/fixtures/rake/rake_tasks_app/config/application.rb | 5 +++++ test/fixtures/static_assets/apps/web/application.rb | 5 +++-- test/fixtures/static_assets_app/config/application.rb | 5 +++-- test/integration/assets_digest_mode/test_application.rb | 4 ++-- test/integration/assets_digest_mode/test_container.rb | 4 ++-- test/integration/cdn/test_application.rb | 2 +- test/integration/cdn/test_container.rb | 2 +- 14 files changed, 52 insertions(+), 10 deletions(-) diff --git a/lib/hanami/generators/app/application.rb.tt b/lib/hanami/generators/app/application.rb.tt index fb75f8d40..8757ef746 100644 --- a/lib/hanami/generators/app/application.rb.tt +++ b/lib/hanami/generators/app/application.rb.tt @@ -327,6 +327,11 @@ module <%= config[:classified_app_name] %> # scheme 'https' # host 'cdn.example.org' # port 443 + + # Subresource Integrity + # + # See: http://hanamirb.org/guides/assets/subresource-integrity + subresource_integrity :sha256 end end end diff --git a/lib/hanami/generators/application/app/config/application.rb.tt b/lib/hanami/generators/application/app/config/application.rb.tt index 0d38240ad..ce1942181 100644 --- a/lib/hanami/generators/application/app/config/application.rb.tt +++ b/lib/hanami/generators/application/app/config/application.rb.tt @@ -326,6 +326,11 @@ module <%= config[:classified_app_name] %> # scheme 'https' # host 'cdn.example.org' # port 443 + + # Subresource Integrity + # + # See: http://hanamirb.org/guides/assets/subresource-integrity + subresource_integrity :sha256 end end end diff --git a/test/fixtures/cdn/cdn/apps/web/application.rb b/test/fixtures/cdn/cdn/apps/web/application.rb index 4cf5db70a..c0e79062a 100644 --- a/test/fixtures/cdn/cdn/apps/web/application.rb +++ b/test/fixtures/cdn/cdn/apps/web/application.rb @@ -259,6 +259,11 @@ class Application < Hanami::Application scheme 'https' host 'cdn.example.org' port 443 + + # Subresource Integrity + # + # See: http://hanamirb.org/guides/assets/subresource-integrity + subresource_integrity :sha256 end end end diff --git a/test/fixtures/cdn/cdn_app/config/application.rb b/test/fixtures/cdn/cdn_app/config/application.rb index d9f5b04d6..f57139553 100644 --- a/test/fixtures/cdn/cdn_app/config/application.rb +++ b/test/fixtures/cdn/cdn_app/config/application.rb @@ -256,6 +256,11 @@ class Application < Hanami::Application scheme 'https' host 'cdn.example.org' port 443 + + # Subresource Integrity + # + # See: http://hanamirb.org/guides/assets/subresource-integrity + subresource_integrity :sha256 end end end diff --git a/test/fixtures/commands/application/new_app/config/application.rb b/test/fixtures/commands/application/new_app/config/application.rb index 03f86943b..d6e58b742 100644 --- a/test/fixtures/commands/application/new_app/config/application.rb +++ b/test/fixtures/commands/application/new_app/config/application.rb @@ -326,6 +326,11 @@ class Application < Hanami::Application # scheme 'https' # host 'cdn.example.org' # port 443 + + # Subresource Integrity + # + # See: http://hanamirb.org/guides/assets/subresource-integrity + subresource_integrity :sha256 end end end diff --git a/test/fixtures/commands/generate/app/application.rb b/test/fixtures/commands/generate/app/application.rb index f01584b47..cc724ef76 100644 --- a/test/fixtures/commands/generate/app/application.rb +++ b/test/fixtures/commands/generate/app/application.rb @@ -327,6 +327,11 @@ class Application < Hanami::Application # scheme 'https' # host 'cdn.example.org' # port 443 + + # Subresource Integrity + # + # See: http://hanamirb.org/guides/assets/subresource-integrity + subresource_integrity :sha256 end end end diff --git a/test/fixtures/rake/rake_tasks/apps/web/application.rb b/test/fixtures/rake/rake_tasks/apps/web/application.rb index 802e6ac0b..f07cf5101 100644 --- a/test/fixtures/rake/rake_tasks/apps/web/application.rb +++ b/test/fixtures/rake/rake_tasks/apps/web/application.rb @@ -282,6 +282,11 @@ class Application < Hanami::Application # scheme 'https' # host 'cdn.example.org' # port 443 + + # Subresource Integrity + # + # See: http://hanamirb.org/guides/assets/subresource-integrity + subresource_integrity :sha256 end end end diff --git a/test/fixtures/rake/rake_tasks_app/config/application.rb b/test/fixtures/rake/rake_tasks_app/config/application.rb index 7ae16dc75..86dffac47 100644 --- a/test/fixtures/rake/rake_tasks_app/config/application.rb +++ b/test/fixtures/rake/rake_tasks_app/config/application.rb @@ -279,6 +279,11 @@ class Application < Hanami::Application # scheme 'https' # host 'cdn.example.org' # port 443 + + # Subresource Integrity + # + # See: http://hanamirb.org/guides/assets/subresource-integrity + subresource_integrity :sha256 end end end diff --git a/test/fixtures/static_assets/apps/web/application.rb b/test/fixtures/static_assets/apps/web/application.rb index f78ff9bcd..08a3bf31d 100644 --- a/test/fixtures/static_assets/apps/web/application.rb +++ b/test/fixtures/static_assets/apps/web/application.rb @@ -242,8 +242,9 @@ class Application < Hanami::Application # port 443 assets do - compile false - digest true + compile false + digest true + subresource_integrity :sha256 end end end diff --git a/test/fixtures/static_assets_app/config/application.rb b/test/fixtures/static_assets_app/config/application.rb index ff57de4bf..786c5aa7a 100644 --- a/test/fixtures/static_assets_app/config/application.rb +++ b/test/fixtures/static_assets_app/config/application.rb @@ -238,8 +238,9 @@ class Application < Hanami::Application # port 443 assets do - compile false - digest true + compile false + digest true + subresource_integrity :sha256 end end end diff --git a/test/integration/assets_digest_mode/test_application.rb b/test/integration/assets_digest_mode/test_application.rb index 0c845ede9..ce3ec50bc 100644 --- a/test/integration/assets_digest_mode/test_application.rb +++ b/test/integration/assets_digest_mode/test_application.rb @@ -41,7 +41,7 @@ get '/' body = response.body - body.must_include %() - body.must_include %() + body.must_include %() + body.must_include %() end end diff --git a/test/integration/assets_digest_mode/test_container.rb b/test/integration/assets_digest_mode/test_container.rb index 6de18ca4b..c72879e92 100644 --- a/test/integration/assets_digest_mode/test_container.rb +++ b/test/integration/assets_digest_mode/test_container.rb @@ -41,7 +41,7 @@ get '/' body = response.body - body.must_include %() - body.must_include %() + body.must_include %() + body.must_include %() end end diff --git a/test/integration/cdn/test_application.rb b/test/integration/cdn/test_application.rb index 314390195..93f93f656 100644 --- a/test/integration/cdn/test_application.rb +++ b/test/integration/cdn/test_application.rb @@ -29,6 +29,6 @@ body = get("/").body body.must_include %() - body.must_include %() + body.must_include %() end end diff --git a/test/integration/cdn/test_container.rb b/test/integration/cdn/test_container.rb index 22d24b22e..aa0c3a55c 100644 --- a/test/integration/cdn/test_container.rb +++ b/test/integration/cdn/test_container.rb @@ -34,6 +34,6 @@ body = get("/").body body.must_include %() - body.must_include %() + body.must_include %() end end