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 allow-same-origin to deck/spyglass sandbox #22921

Merged
merged 1 commit into from
Nov 4, 2021
Merged
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 prow/cmd/deck/template/spyglass.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<div class="mdl-card__title lens-title"><h3 class="mdl-card__title-text">{{$config.Title}}</h3></div>
<div id="{{$config.Name}}-view-container" class="lens-view-content mdl-card__supporting-text">
<img src="/static/kubernetes-wheel.svg" alt="loading spinner" class="loading-spinner is-active lens-card-loading" id="{{$config.Name}}-loading">
<iframe class="lens-container" style="visibility: hidden;" id="iframe-{{$index}}" sandbox="allow-scripts allow-top-navigation allow-popups" data-lens-index="{{$index}}" data-lens-name="{{$config.Name}}"{{if $config.HideTitle}} data-hide-title="true"{{end}}></iframe>
<iframe class="lens-container" style="visibility: hidden;" id="iframe-{{$index}}" sandbox="allow-scripts allow-top-navigation allow-popups allow-same-origin" data-lens-index="{{$index}}" data-lens-name="{{$config.Name}}"{{if $config.HideTitle}} data-hide-title="true"{{end}}></iframe>
</div>
</div>
{{end}}
Expand Down
7 changes: 3 additions & 4 deletions prow/spyglass/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ future they can live elsewhere. Spyglass lenses have the following responsibilit
- Rendering HTML for human consumption

Lens frontends are run in sandboxed iframes (currently `sandbox="allow-scripts allow-top-navigation
allow-popups"`), which ensures that they can only interact with the world via the intended API. In
particular, this prevents lenses from interacting with other Deck pseudo-APIs or with the core
spyglass page.
allow-popups allow-same-origin"`), which ensures that they can only interact with the world via the
intended API. In particular, this prevents lenses from interacting with other Deck pseudo-APIs or with
the core spyglass page.

In order to provide this API to lenses, a library
([`prow/cmd/deck/static/spyglass/lens.ts`](../cmd/deck/static/spyglass/lens.ts)) is injected into
Expand Down Expand Up @@ -86,4 +86,3 @@ information from their frontend, in which case the following happens:
relevant lens endpoint
1. The **core** backend receives the request and invokes the **lens** backend with the relevant
information attached.

2 changes: 1 addition & 1 deletion prow/spyglass/lenses/html/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{/* Do _not_ hide this by default, that will break inner javascript that dynamically resizes. Hiding post-render is ok, so we hide on first resize request */}}
<tr class="initial" id="{{$title}}-tr">
<td colspan="2" style="border: 0px; padding: 0px;">
<iframe srcdoc="{{$content}}" title="{{$title}}" sandbox="allow-scripts allow-popups" id="{{$title}}" width="100%" scrolling="no"></iframe>
<iframe srcdoc="{{$content}}" title="{{$title}}" sandbox="allow-scripts allow-popups allow-same-origin" id="{{$title}}" width="100%" scrolling="no"></iframe>
</td>
</tr>
{{end}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ window.addEventListener(&quot;load&quot;, function(){
var config = { attributes: true, childList: true, characterData: true, subtree:true}; // PT2
observer.observe(window.document, config); // PT3
});
</script>" title="file.html" sandbox="allow-scripts allow-popups" id="file.html" width="100%" scrolling="no"></iframe>
</script>" title="file.html" sandbox="allow-scripts allow-popups allow-same-origin" id="file.html" width="100%" scrolling="no"></iframe>
</td>
</tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ window.addEventListener(&quot;load&quot;, function(){
var config = { attributes: true, childList: true, characterData: true, subtree:true}; // PT2
observer.observe(window.document, config); // PT3
});
</script>" title="file.html" sandbox="allow-scripts allow-popups" id="file.html" width="100%" scrolling="no"></iframe>
</script>" title="file.html" sandbox="allow-scripts allow-popups allow-same-origin" id="file.html" width="100%" scrolling="no"></iframe>
</td>
</tr>

Expand Down