首页 > 解决方案 > Webpack 安全问题 - css-loader

问题描述

所以我有一个简单的反应应用程序的 suuuuper 基本 webpack 设置。我一直在使用 css-loader 为 webpack 翻译我的 CSS。但是我收到了一个安全警告……似乎没有发布的解决方案。

这是警告:

│ Critical      │ Command Injection                                            │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ macaddress                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ No patch available                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ css-loader [dev]                                             │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ css-loader > cssnano > postcss-filter-plugins > uniqid >     │
│               │ macaddress                                                   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/654      

如您所见,问题不在于 webpack 本身,而在于这个 macaddress 包。我不知道该怎么办。它说它是“关键的”....有解决办法吗?我可以使用css-loader以外的东西吗?

这是我完整的 webpack.config.js 文件:

const HtmlWebPackPlugin = require('html-webpack-plugin'); 

module.exports={
    module: {
        rules: [
            {
                test: /\.js$/, 
                exclude: [
                    "/node_modules/",
                    "src/tests/"
                ],  
                use: {
                    loader: "babel-loader"
                }
            }, 
            {
                test: /\.scss$/,
                use: [
                    {
                        loader: "style-loader" // creates style nodes for JS strings
                    }, 
                    {
                        loader: "css-loader" // translates CSS into CommonJS
                    }, 
                    {
                        loader: "sass-loader" // compiles Sass to CSS
                    }
                ]
            },
            {
                test: /\.html$/, 
                use: [
                    { 
                        loader: "html-loader" 
                    }
                ]
            }

        ]
    }, 
    plugins: [
        new HtmlWebPackPlugin({
            template: "./public/index.html", // where to read
            filename: "./index.html" // where to put code
        })
    ]
}

我只想要一个没有安全问题的工作 webpack 设置。提前致谢。

标签: reactjswebpack

解决方案


正如@David Tyron 所发布的,在 GitHub 上打开了一个问题,发布2.0.3应该可以解决它。尝试更新。


推荐阅读