Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add security related headers for static resources #24272

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<air.maven.version>3.3.9</air.maven.version>

<dep.antlr.version>4.7.1</dep.antlr.version>
<dep.airlift.version>0.215</dep.airlift.version>
<dep.airlift.version>0.216</dep.airlift.version>
<dep.packaging.version>${dep.airlift.version}</dep.packaging.version>
<dep.slice.version>0.38</dep.slice.version>
<dep.testing-mysql-server-5.version>0.6</dep.testing-mysql-server-5.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
import com.facebook.presto.transaction.TransactionManagerConfig;
import com.facebook.presto.util.PrestoDataDefBindingHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.net.HttpHeaders;
import com.google.inject.Binder;
import com.google.inject.Provides;
import com.google.inject.Scopes;
Expand Down Expand Up @@ -141,8 +142,12 @@ public class CoordinatorModule
@Override
protected void setup(Binder binder)
{
httpServerBinder(binder).bindResource("/ui", "webapp").withWelcomeFile("index.html");
httpServerBinder(binder).bindResource("/tableau", "webapp/tableau");
httpServerBinder(binder).bindResource("/ui", "webapp").withWelcomeFile("index.html")
.withExtraHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff")
.withExtraHeader(HttpHeaders.CONTENT_SECURITY_POLICY, "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; frame-ancestors 'self'");
httpServerBinder(binder).bindResource("/tableau", "webapp/tableau")
.withExtraHeader(HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff")
.withExtraHeader(HttpHeaders.CONTENT_SECURITY_POLICY, "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; frame-ancestors 'self'");

// discovery server
install(installModuleIf(EmbeddedDiscoveryConfig.class, EmbeddedDiscoveryConfig::isEnabled, new EmbeddedDiscoveryModule()));
Expand Down
4 changes: 2 additions & 2 deletions presto-ui/src/static/dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="../vendor/html5shiv/html5shiv.min.js"></script>
<script src="../vendor/respond/respond.min.js"></script>
<![endif]-->

<!-- jQuery -->
Expand Down
4 changes: 2 additions & 2 deletions presto-ui/src/static/embedded_plan.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="vendor/html5shiv/html5shiv.min.js"></script>
<script src="vendor/respond/respond.min.js"></script>
<![endif]-->

<!-- jQuery -->
Expand Down
4 changes: 2 additions & 2 deletions presto-ui/src/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="vendor/html5shiv/html5shiv.min.js"></script>
<script src="vendor/respond/respond.min.js"></script>
<![endif]-->

<!-- jQuery -->
Expand Down
4 changes: 2 additions & 2 deletions presto-ui/src/static/plan.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="vendor/html5shiv/html5shiv.min.js"></script>
<script src="vendor/respond/respond.min.js"></script>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @yhwang , thanks for the work. Just wondering why did we vendor these, instead of getting from CDN?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question and the answer is Cross-Domain JavaScript Source File Inclusion.
We already include most of the 3rd party libs except these two. So I directly included them as well. Besides, the script-src attribute of the CSP header has self as the value. I don't want to add oss.maxcdn.com just for these two libs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying, it seems you are trying to follow the standard here. May be some one more expert can comment on the right path here.

<![endif]-->

<!-- jQuery -->
Expand Down
4 changes: 2 additions & 2 deletions presto-ui/src/static/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="vendor/html5shiv/html5shiv.min.js"></script>
<script src="vendor/respond/respond.min.js"></script>
<![endif]-->

<!-- jQuery -->
Expand Down
4 changes: 2 additions & 2 deletions presto-ui/src/static/res_groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="vendor/html5shiv/html5shiv.min.js"></script>
<script src="vendor/respond/respond.min.js"></script>
<![endif]-->

<!-- jQuery -->
Expand Down
4 changes: 2 additions & 2 deletions presto-ui/src/static/sql_client.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="vendor/html5shiv/html5shiv.min.js"></script>
<script src="vendor/respond/respond.min.js"></script>
<![endif]-->

<!-- jQuery -->
Expand Down
4 changes: 2 additions & 2 deletions presto-ui/src/static/stage.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="vendor/html5shiv/html5shiv.min.js"></script>
<script src="vendor/respond/respond.min.js"></script>
<![endif]-->

<!-- jQuery -->
Expand Down
4 changes: 2 additions & 2 deletions presto-ui/src/static/timeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<script src="vendor/html5shiv/html5shiv.min.js"></script>
<script src="vendor/respond/respond.min.js"></script>
<![endif]-->

<!-- jQuery -->
Expand Down
Loading
Loading