This repository has been archived by the owner on Aug 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Updated material-branch to changes from master https://github.com/google/WebFundamentals/pull/1875 #1876
Closed
+228
−193
Closed
Updated material-branch to changes from master https://github.com/google/WebFundamentals/pull/1875 #1876
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<!-- // [TEMPLATE header_full] --> | ||
<title>Active mixed content example</title> | ||
<!-- // [START snippet1] --> | ||
<!-- An insecure script file loaded on a secure page --> | ||
<script src="http://localhost:8888/simple-example.js"></script> | ||
<script src="http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/simple-example.js"></script> | ||
|
||
<!-- An insecure stylesheet loaded on a secure page --> | ||
<link href="http://localhost:8888/style.css" rel="stylesheet"> | ||
<link href="http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/style.css" rel="stylesheet"> | ||
|
||
<style> | ||
.insecure-background { | ||
/* An insecure resources loaded from a style property on a secure page, this can | ||
happen in many places including, @font-face, cursor, background-image, and so on. */ | ||
background: url('http://localhost:8888/petelepage-thumb.jpg') no-repeat; | ||
background: url('http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/puppy-thumb.jpg') no-repeat; | ||
} | ||
</style> | ||
<!-- // [END snippet1] --> | ||
|
@@ -38,42 +39,46 @@ | |
|
||
</head> | ||
<body> | ||
<h1> | ||
Active mixed content! | ||
</h1> | ||
<p> | ||
View page over: <a href="http://localhost:8888/active-mixed-content.html">HTTP</a> - <a href="https://localhost:4443/active-mixed-content.html">HTTPS</a> | ||
</p> | ||
<p> | ||
Several examples of active mixed content. When viewed over HTTPS most browsers block this content and display errors in the JavaScript console. | ||
</p> | ||
<div class="insecure-style-holder"> | ||
<span style="ba">Insecure style loaded</span> | ||
</div> | ||
<div class="insecure-background"> | ||
Loading insecure background here... | ||
</div> | ||
<div role="main"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @petele ditto? |
||
<h1> | ||
Active mixed content! | ||
</h1> | ||
<p> | ||
View page over: <a href="http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/active-mixed-content.html">HTTP</a> - <a href="https://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/active-mixed-content.html">HTTPS</a> | ||
</p> | ||
<p> | ||
Several examples of active mixed content. When viewed over HTTPS most browsers block this content and display errors in the JavaScript console. | ||
</p> | ||
<div class="insecure-style-holder"> | ||
<span style="ba">Insecure style loaded</span> | ||
</div> | ||
<div class="insecure-background"> | ||
Loading insecure background here... | ||
</div> | ||
|
||
<p>Loading insecure iframe...</p> | ||
<!-- // [START snippet2] --> | ||
<!-- An insecure iframed page loaded on a secure page --> | ||
<iframe src="http://localhost:8888/image-gallery-example.html"></iframe> | ||
|
||
<!-- Flash resources also qualify as active mixed content and pose a | ||
serious security risk. Be sure to look for <object> tags with type set | ||
to "application/x-shockwave-flash", and an http:// data attribute. --> | ||
<p>Loading insecure iframe...</p> | ||
<!-- // [START snippet2] --> | ||
<!-- An insecure iframed page loaded on a secure page --> | ||
<iframe src="http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/image-gallery-example.html"></iframe> | ||
|
||
<!-- Flash resources also qualify as active mixed content and pose a | ||
serious security risk. Be sure to look for <object> tags with type set | ||
to "application/x-shockwave-flash", and an http:// data attribute. --> | ||
<!-- <object type="application/x-shockwave-flash" data="http://..."></object> --> | ||
|
||
<script> | ||
// An insecure resource loaded using XMLHttpRequest | ||
var request = new XMLHttpRequest(); | ||
request.addEventListener('load', function() { | ||
var jsonData = JSON.parse(request.responseText); | ||
document.getElementById('output').innerHTML += '<br>' + jsonData.data; | ||
}); | ||
request.open("GET", "http://localhost:8888/xmlhttprequest-data.js", true); | ||
request.send(); | ||
</script> | ||
<!-- // [END snippet2] --> | ||
<div id="output">Waiting for insecure script to run...</div> | ||
<script> | ||
// An insecure resource loaded using XMLHttpRequest | ||
var request = new XMLHttpRequest(); | ||
request.addEventListener('load', function() { | ||
var jsonData = JSON.parse(request.responseText); | ||
document.getElementById('output').innerHTML += '<br>' + jsonData.data; | ||
}); | ||
request.open("GET", "http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/xmlhttprequest-data.js", true); | ||
request.send(); | ||
</script> | ||
<!-- // [END snippet2] --> | ||
<div id="output">Waiting for insecure script to run...</div> | ||
</div> | ||
<!-- // [TEMPLATE footer] --> | ||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-47 KB
src/content/en/fundamentals/security/avoid-mixed-content/_code/petelepage.jpg
Binary file not shown.
Binary file renamed
BIN
+12.3 KB
...-mixed-content/_code/petelepage-thumb.jpg → ...avoid-mixed-content/_code/puppy-thumb.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.8 KB
src/content/en/fundamentals/security/avoid-mixed-content/_code/puppy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 17 additions & 13 deletions
30
src/content/en/fundamentals/security/avoid-mixed-content/_code/simple-example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<!-- // [TEMPLATE header_full] --> | ||
<title>Simple mixed content example</title> | ||
</head> | ||
<body> | ||
<h1> | ||
Simple mixed content example! | ||
</h1> | ||
<p> | ||
View page over: <a href="http://localhost:8888/simple-example.html">HTTP</a> - <a href="https://localhost:4443/simple-example.html">HTTPS</a> | ||
</p> | ||
<p> | ||
This page loads the script simple-example.js using HTTP. This is the simplest case of mixed content. When the simple-example.js file is requested by the browser, an attacker can inject code into the returned content and take control of the entire page. Thankfully, most modern browsers block this type of dangerous content by default and display an error in the JavaScript console. This can be seen when the page is viewed over HTTPS. | ||
</p> | ||
<div id="output">Waiting for insecure script to run...</div> | ||
<!-- // [START snippet1] --> | ||
<script src="http://localhost:8888/simple-example.js"></script> | ||
<!-- // [END snippet1] --> | ||
<div role="main"> | ||
<h1> | ||
Simple mixed content example! | ||
</h1> | ||
<p> | ||
View page over: <a href="http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/simple-example.html">HTTP</a> - <a href="https://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/simple-example.html">HTTPS</a> | ||
</p> | ||
<p> | ||
This page loads the script simple-example.js using HTTP. This is the simplest case of mixed content. When the simple-example.js file is requested by the browser, an attacker can inject code into the returned content and take control of the entire page. Thankfully, most modern browsers block this type of dangerous content by default and display an error in the JavaScript console. This can be seen when the page is viewed over HTTPS. | ||
</p> | ||
<div id="output">Waiting for insecure script to run...</div> | ||
<!-- // [START snippet1] --> | ||
<script src="http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/simple-example.js"></script> | ||
<!-- // [END snippet1] --> | ||
</div> | ||
<!-- // [TEMPLATE footer] --> | ||
</body> | ||
</html> |
54 changes: 29 additions & 25 deletions
54
src/content/en/fundamentals/security/avoid-mixed-content/_code/xmlhttprequest-example.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<!-- // [TEMPLATE header_full] --> | ||
<title>XMLHttpRequest mixed content example</title> | ||
</head> | ||
<body> | ||
<h1> | ||
XMLHttpRequest mixed content example! | ||
</h1> | ||
<p> | ||
View page over: <a href="http://localhost:8888/xmlhttprequest-example.html">HTTP</a> - <a href="https://localhost:4443/xmlhttprequest-example.html">HTTPS</a> | ||
</p> | ||
<p> | ||
This page constructs an HTTP URL dynamically in JavaScript, the URL is eventually used to load an insecure resource by XMLHttpRequest. When the xmlhttprequest-data.js file is requested by the browser, an attacker can inject code into the returned content and take control of the entire page. Thankfully, most modern browsers block this type of dangerous content by default and display an error in the JavaScript console. This can be seen when the page is viewed over HTTPS. | ||
</p> | ||
<div id="output">Waiting for data...</div> | ||
<!-- // [START snippet1] --> | ||
<script> | ||
var rootUrl = 'http://localhost:8888'; | ||
var resources = { | ||
jsonData: '/xmlhttprequest-data.js' | ||
}; | ||
var request = new XMLHttpRequest(); | ||
request.addEventListener('load', function() { | ||
var jsonData = JSON.parse(request.responseText); | ||
document.getElementById('output').innerHTML += '<br>' + jsonData.data; | ||
}); | ||
request.open('GET', rootUrl + resources.jsonData); | ||
request.send(); | ||
</script> | ||
<!-- // [END snippet1] --> | ||
<div role="main"> | ||
<h1> | ||
XMLHttpRequest mixed content example! | ||
</h1> | ||
<p> | ||
View page over: <a href="http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/xmlhttprequest-example.html">HTTP</a> - <a href="https://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content/xmlhttprequest-example.html">HTTPS</a> | ||
</p> | ||
<p> | ||
This page constructs an HTTP URL dynamically in JavaScript, the URL is eventually used to load an insecure resource by XMLHttpRequest. When the xmlhttprequest-data.js file is requested by the browser, an attacker can inject code into the returned content and take control of the entire page. Thankfully, most modern browsers block this type of dangerous content by default and display an error in the JavaScript console. This can be seen when the page is viewed over HTTPS. | ||
</p> | ||
<div id="output">Waiting for data...</div> | ||
<!-- // [START snippet1] --> | ||
<script> | ||
var rootUrl = 'http://googlesamples.github.io/web-fundamentals/samples/discovery-and-distribution/avoid-mixed-content'; | ||
var resources = { | ||
jsonData: '/xmlhttprequest-data.js' | ||
}; | ||
var request = new XMLHttpRequest(); | ||
request.addEventListener('load', function() { | ||
var jsonData = JSON.parse(request.responseText); | ||
document.getElementById('output').innerHTML += '<br>' + jsonData.data; | ||
}); | ||
request.open('GET', rootUrl + resources.jsonData, true); | ||
request.send(); | ||
</script> | ||
<!-- // [END snippet1] --> | ||
</div> | ||
<!-- // [TEMPLATE footer] --> | ||
</body> | ||
</html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petele - should I be removing this markup from master?