-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
machines: Fix security and broken packaging in noVNC
Using unsafe-inline Content-Security-Policy opens up a security in something as wild as noVNC. We simply shouldn't have unsafe-inline or unsafe-eval in our packages. In addition the noVNC component should be installed efficiently, in a single bundle, not having to load 15 javascript files. The bundle should be compressed, with unnecessary dependencies removed. I've added a small custom Webpack loader to perform the task of combining these files. This also allows development on this component to work with pure webpack without automake and friends. We also properly track the dependencies and changes here. Closes #7388
- Loading branch information
1 parent
0a68585
commit ce65bbe
Showing
6 changed files
with
241 additions
and
206 deletions.
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* This is a webpack loader that concatenates files | ||
* before the loaded javascript. Multiple files can | ||
* be specified. | ||
* | ||
* require("cat?./file1.js&./file2.js|module"); | ||
*/ | ||
|
||
var fs = require("fs"); | ||
var path = require("path"); | ||
|
||
module.exports = function(source) { | ||
var loader = this; | ||
|
||
loader.cacheable(); | ||
|
||
var callback = loader.async(); | ||
|
||
var files = loader.query.substring(1).split("&"); | ||
var content = [ source ]; | ||
|
||
function step() { | ||
if (files.length == 0) { | ||
callback(null, content.join("\n")); | ||
return; | ||
} | ||
|
||
var filename = require.resolve(files.pop()); | ||
loader.addDependency(filename); | ||
|
||
fs.readFile(filename, "utf-8", function(err, data) { | ||
if (err) | ||
return callback(err); | ||
content.unshift(data); | ||
step(); | ||
}); | ||
} | ||
|
||
step(); | ||
}; |
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
Oops, something went wrong.