
Security News
npm Tooling Bug Incorrectly Marks One-Character Packages as Security Holders
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.
nproxy-plus
Advanced tools
基于Nproxy开发的本地代理转发服务器
npm install -g nproxy-plus
本地编写一个匹配规则文件,命名为例如rule.config.js:
module.exports = [
//替换单个本地文件
{
pattern : 'http://nproxy6.com/a.js',
responder : 'local',
options : {
file: '/repos/nproxy/test/support/files/replaced/c1.js'
}
},
//映射到本地路径
{
pattern : 'http://nproxy6.com/xx/',
responder : 'local',
options : {
file: '/repos/nproxy/test/support/files/replaced/'
}
},
//替换单个网络文件
{
pattern : 'http://nproxy6.com/b.js',
responder : 'web',
options : {
file: 'http://g.tbcdn.cn/kissy/k/1.4.0/seed-min.js'
}
},
//本地concat
{
pattern : 'http://nproxy6.com/c.js',
responder : 'concat',
options : {
dir : '/repos/nproxy/test/support/files/replaced/',
files: [
'c1.js',
'c2.js',
'c3.js',
'c1.js'
]
}
},
//网络combo
{
pattern : 'http://nproxy6.com/??c1.js,c2.js,js/he.js',
responder : 'combo',
options : {
base: '/repos/nproxy/test/support/files/replaced/'
}
},
//kissy模块实时编译
{
pattern : 'http://nproxy6.com/d.js',
responder : 'kissy-combo',
options : {
packages: [{
'name': 'mt',
'path': '/repos/tb-buy/mt',
'charset': 'gbk'
}],
input: '/repos/tb-buy/mt/index.js'
}
},
//使用自定义函数实现更复杂的匹配条件
{
pattern : function(url, pattern, req, res){
if(req.query.local && req.cookies.user == 'john'){
return true;
}
return false;
},
responder : function(pattern, options, req, res, next){
var html = xtemplateCompiler('xxx');
res.send(html);
},
options : {
tplPath: '/repos/nproxy/test/support/files/tpl/'
}
}
];
运行以下命令启动服务器
nproxy -l rule.config.js
设置浏览器代理为 127.0.0.1:8989
用法: nproxy [options]
选项:
-h, --help 输出使用方法
-V, --version 输出版本号
-l, --list [list] 指定匹配规则文件
-p, --port [port] 指定监听端口号
-t, --timeout [timeout] 设置请求超时时间
-w, --watch [path] 本地监听目录,当目录中的文件修改时重现加载匹配规则文件,默认只监听匹配规则文件
pattern : {String|Regx|Function} 匹配规则,可以是字符串,正则表达式和自定义函数
当为函数,匹配规则时,该函数会传递以下参数调用
function(url, pattern, req, res){}
url : 当前url
pattern : 当前函数引用
req : express的Request对象
res : express的Response对象
函数返回true表示规则匹配命中,返回false表示规则匹配失败
responder : {String|Function}
当为字符串,表示使用内置插件输入,当前支持的插件有
local : 本地文件或路径
web : 网络文件
concat : 本地文件根据配置打包
combo : 本地文件根据url combo格式打包
kissy-combo : 根据配置中的kissy配置输出实时编译后的kissy包内容
当为函数,在规则匹配命中后会调用此函数进行输出,该函数会传递以下参数调用
function(pattern, options, req, res, next){}
pattern : 匹配规则
options : 配置信息
req : express的Request对象
res : express的Response对象
next : express的next方法
options : {Object} 配置信息,在获取输出时会传递到插件函数中
本地代理服务器做的事情大同小异,可以将流程抽象化为:
Nproxy-Plus实现了一个简单的服务器框架,匹配和输出则可以由开发者自行实现
NProxy-Plus is available under the terms of the MIT License
FAQs
A cli proxy tool specialized in file replacing, extend from nproxy
The npm package nproxy-plus receives a total of 8 weekly downloads. As such, nproxy-plus popularity was classified as not popular.
We found that nproxy-plus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.

Research
/Security News
Newer packages in this compromise use native extensions and .pth loaders to execute JavaScript stealers in developer environments.

Research
Socket found 37 malicious PyPI wheels that abuse Python startup hooks to launch a Bun-powered credential stealer tied to Mini Shai-Hulud/Miasma.