New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pn-cli

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pn-cli - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

48

bin/pn-server.js

@@ -8,14 +8,46 @@ #!/usr/bin/env node

let includes = [], excludes = [], password = null;
const Head = {
Server: 'PhoenixNirvana-Framework'
}
function app(req, res){
console.log(req.method, req.url, req.headers);
// 如果设置了密码
if (!!password) {
// 客户头未包含X-AUTH或不等于password
if (req.headers['x-auth'] !== password) {
res.writeHead(403, Head);
res.end();
return;
}
}
let matches = /\/(?<module>.*?)\/(?<controller>.*?)\/(?<action>.*)/.exec(req.url.split('?')[0]);
if (!matches || matches.groups.action === '') {
res.writeHead(404);
res.writeHead(404, Head);
res.end();
return;
}
// allow access module, empty is allow all
if (includes.length>0 && !includes.includes(matches.groups.module)) {
res.writeHead(403, Head);
res.end();
return;
}
// deny access module
if (excludes.length>0 && excludes.includes(matches.groups.module)) {
res.writeHead(403, Head);
res.end();
return;
}
const uri = `${matches.groups.module}:${matches.groups.controller}/${matches.groups.action}?${req.url.split('?')[1]}`;
manage.run(uri).then(data => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(data);
if (typeof data === 'string') {
res.writeHead(200, Object.assign({'Content-Type': 'text/plain'}, Head));
res.end(data);
} else {
res.writeHead(200, Object.assign({'Content-Type': 'text/json'}, Head));
res.end(JSON.stringify(data));
}
}).catch(err => {

@@ -31,4 +63,10 @@ res.writeHead(404);

.command('server [port] [host]')
.action((port = 9002, host = '127.0.0.1') => {
const server = http.createServer(app).listen(port, host, () => {
.option('-i, --include <module list>', '仅允许指定模块列表,逗号分割')
.option('-e, --exclude <module list>', '排除指定模块列表,逗号分割')
.option('-a, --auth <password>', '授权码,客户端通过设置X-AUTH头指定')
.action((port = 9002, host = '127.0.0.1', opts) => {
includes = (opts.include) ? opts.include.split(/,\s*/) : [];
excludes = (opts.exclude) ? opts.exclude.split(/,\s*/) : [];
password = opts.auth;
http.createServer(app).listen(port, host, () => {
console.log(`listening ${host}:${port}`)

@@ -35,0 +73,0 @@ })

2

package.json
{
"name": "pn-cli",
"version": "0.0.14",
"version": "0.0.15",
"description": "phoenix nirvana manager",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc