npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

check-inline-loader-plugin

v1.2.5

Published

通过白名单形式来检测是否存在未知内联loader

Downloads

17

Readme

check-inline-loader-plugin for Webpack

通过白名单形式来检测是否存在未知内联loader,用于避免黑客通过内联loader的形式向系统注入恶意脚本。

什么场景下需要使用 check-inline-loader-plugin

  1. 在线版自定义组件: 用户在线开发自定义组件;
  2. NPM版自定义组件: 用户通过NPM包的形式注入自定义组件;
  3. 云构建: 使用webpack构建用户提交的自定义代码;
  4. 待补充。

check-inline-loader-plugin的使用方法

1. 安装:

$ npm install --save-dev check-inline-loader-plugin

或者:

$ yarn add check-inline-loader-plugin --dev

2. 在 webpack 中添加 check-inline-loader-plugin

配置 你的webpack.config.js:

// 导入 check-inline-loader-plugin
const CheckInlineLoaderPlugin = require('check-inline-loader-plugin');

module.exports = {
  // ...
  plugins: [
    new CheckInlineLoaderPlugin({
      allowLoaders: [ // 设置loader白名单
        'html-webpack-plugin/lib/loader.js',
        'html-loader/dist/cjs.js',
        'babel-loader/lib/index.js',
        'vue-loader/dist/index.js',
        'vue-loader/dist/templateLoader.js',
        'vue-style-loader/index.js',
        'vue-loader/dist/stylePostLoader.js',
        'sass-loader/dist/cjs.js',
        'css-loader/dist/cjs.js',
        'postcss-loader/dist/cjs.js',
        'mini-css-extract-plugin/dist/loader.js',
        'params-replace-loader/index.js',
        // 'test-custom-loader/index.js',
      ],
      showUsedLoaders: true, // 是否输出当前已用到的loader
      showUnknownLoaders: true, // 是否输出当前检测到的未知loader
      errorMsg: '如需添加自定义loader,请联系平台管理员', // 错误提示内容
      exitMode: 'exit', // 出现未知loader时的退出程序模式,exit 或 throwError
    }),
  ],
}

注意事项

1、初次使用CheckInlineLoaderPlugin时,您可能并不太清楚当前项目中已经用到了哪些loader,您可以先在allowLoaders添加一个已知的loader,通过设置showUsedLoaders为true来测试输出当前已经用到的loader(可能需要多次执行构建才能获取完整的loader列表)。