Socket
Socket
Sign inDemoInstall

webpack-subresource-integrity

Package Overview
Dependencies
293
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0-rc.3 to 1.1.0-rc.4

examples/mini-css-extract-plugin/index.js

29

index.js

@@ -0,1 +1,8 @@

/**
* Copyright (c) 2015-present, Waysact Pty Ltd
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var crypto = require('crypto');

@@ -179,7 +186,25 @@ var path = require('path');

Array.from(util.findChunks(chunk)).reverse().forEach(childChunk => {
self.warnIfHotUpdate(compilation, assets[childChunk.files[0]].source());
var sourcePath;
// This can happen with invalid Webpack configurations
if (childChunk.files.length === 0) return;
sourcePath = util.getChunkFilename(compilation, childChunk);
if (childChunk.files.indexOf(sourcePath) < 0) {
self.warnOnce(
compilation,
'Cannot determine asset for chunk ' + childChunk.id + ', computed="' + sourcePath +
'", available=' + childChunk.files[0] + '. Please report this full error message ' +
'along with your Webpack configuration at ' +
'https://github.com/waysact/webpack-subresource-integrity/issues/new'
);
sourcePath = childChunk.files[0];
}
self.warnIfHotUpdate(compilation, assets[sourcePath].source());
newAsset = self.replaceAsset(
assets,
hashByChunkId,
childChunk.files[0]);
sourcePath);
hashByChunkId.set(childChunk.id, newAsset.integrity);

@@ -186,0 +211,0 @@ });

@@ -0,1 +1,8 @@

/**
* Copyright (c) 2015-present, Waysact Pty Ltd
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var Template = require('webpack/lib/Template');

@@ -2,0 +9,0 @@ var util = require('./util');

4

package.json
{
"name": "webpack-subresource-integrity",
"version": "1.1.0-rc.3",
"version": "1.1.0-rc.4",
"description": "Webpack plugin for enabling Subresource Integrity",

@@ -10,2 +10,3 @@ "engines": {

"scripts": {
"codeclimate": "docker run --interactive --tty --rm --env CODECLIMATE_CODE=\"$PWD\" --volume \"$PWD\":/code --volume /var/run/docker.sock:/var/run/docker.sock --volume /tmp/cc:/tmp/cc codeclimate/codeclimate",
"coverage": "nyc $(npm bin)/mocha --exit --timeout 20000",

@@ -63,2 +64,3 @@ "test": "karma start --single-run && mocha --exit --timeout 20000",

"lodash": "^4.17.5",
"mini-css-extract-plugin": "^0.2.0",
"mocha": "^5.0.1",

@@ -65,0 +67,0 @@ "module-alias": "^2.0.6",

@@ -15,3 +15,3 @@ # webpack-subresource-integrity

- Optional integration with [html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin)
- Support for code splitting (integrity for lazy-loaded chunks)
- Automatic support for code splitting (integrity for lazy-loaded chunks)
- Compatible with Webpack 1.x, 2.x, 3.x and 4.x

@@ -173,4 +173,4 @@

Copyright (c) 2015-2018 Waysact Pty Ltd
Copyright (c) 2015-present Waysact Pty Ltd
MIT (see [LICENSE](LICENSE))
var crypto = require("crypto");
var path = require("path");
/**
* Copyright (c) 2015-present, Waysact Pty Ltd
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function addIfNotExist(set, item) {

@@ -98,2 +105,33 @@ if (set.has(item)) return true;

function isInitialChunk(chunk) {
if (chunk.isOnlyInitial) {
return chunk.isOnlyInitial();
}
if (chunk.isInitial) {
return chunk.isInitial();
}
return chunk.initial;
}
function getChunkFilename(compilation, chunk) {
var filename = compilation.mainTemplate.outputOptions.filename || "bundle.js";
var chunkFilename = compilation.mainTemplate.outputOptions.chunkFilename || ("[id]." + filename);
var args = [isInitialChunk(chunk) ? filename : chunkFilename, {
hash: compilation.hash.substr(0, compilation.mainTemplate.outputOptions.hashDigestLength),
hashWithLength: length => compilation.hash.substr(0, length),
chunk: {
id: chunk.id,
hash: chunk.hash.substr(0, compilation.mainTemplate.outputOptions.hashDigestLength),
hashWithLength: length => chunk.hash.substr(0, length),
name: chunk.name
}
}];
if (compilation.mainTemplate.getAssetPath) {
return compilation.mainTemplate.getAssetPath.apply(compilation.mainTemplate, args);
}
args.unshift("asset-path");
return compilation.mainTemplate.applyPluginsWaterfall.apply(compilation.mainTemplate, args);
}
module.exports.computeIntegrity = computeIntegrity;

@@ -107,1 +145,2 @@ module.exports.findChunks = findChunks;

module.exports.makePlaceholder = makePlaceholder;
module.exports.getChunkFilename = getChunkFilename;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc