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

whatap

Package Overview
Dependencies
Maintainers
0
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

whatap - npm Package Compare versions

Comparing version 0.4.98 to 0.5.0

lib/conf/log-config-default.js

11

lib/conf/config-default.js

@@ -14,3 +14,3 @@ /**

var v=process.env[k];
return v?Boolean(v):defValue;
return v ? (v === 'true') : defValue;
};

@@ -158,4 +158,4 @@ function str(k, defValue){

"ignore_sql_error_code_set": str('ignore_sql_error_code_set', ''),
"ignore_nextjs_build_file_enabled": bool('ignore_nextjs_build_file_enabled', true),
"ignore_nextjs_build_file_path": str('ignore_nextjs_build_file_path', '/_next/'),
"ignore_build_file_enabled": bool('ignore_build_file_enabled', true),
"ignore_build_file_path": str('ignore_build_file_path', '/_next/'),

@@ -264,2 +264,7 @@ //2017.05.02 AUTO ONAME

"stat_ipurl_max_count": num("stat_ipurl_max_count", 10000),
"grpc_profile_enabled": bool("grpc_profile_enabled", true),
"grpc_profile_stream_client_enabled": bool("grpc_profile_stream_client_enabled", true),
"grpc_profile_stream_server_enabled": bool("grpc_profile_stream_server_enabled", true),
"grpc_profile_ignore_method": bool("grpc_profile_ignore_method", true),
};

@@ -266,0 +271,0 @@

@@ -20,2 +20,3 @@ /**

ConfigDefault = require("./config-default"),
LogConfigDefault = require("./log-config-default"),
ConfSysMon = require('./conf-sys-mon'),

@@ -31,2 +32,3 @@ MapValue = require('./../value/map-value'),

this.apply(ConfigDefault);
this.apply(LogConfigDefault);

@@ -70,2 +72,9 @@ this.inx = 0;

});
var logDefKeys = Object.keys(LogConfigDefault);
logDefKeys.forEach(function (key) {
if(LogConfigDefault[key]) {
p[key] = LogConfigDefault[key];
}
});
if(process.env.WHATAP_SERVER_HOST){

@@ -117,4 +126,4 @@ p['whatap.server.host']=process.env.WHATAP_SERVER_HOST;

if(newKeys.indexOf(key) < 0) {
if(ConfigDefault[key] != null) {
self[key] = ConfigDefault[key];
if(ConfigDefault[key] !== null || LogConfigDefault[key] !== null) {
self[key] = ConfigDefault[key] !== null ? ConfigDefault[key] : LogConfigDefault[key];
} else {

@@ -267,3 +276,3 @@ delete self[key];

Configuration.prototype.getProperty = function(key, defaultValue) {
if(!this[key]){
if(this[key] === undefined){
return defaultValue;

@@ -270,0 +279,0 @@ } else{

@@ -18,3 +18,5 @@ /**

TraceContextManager = require('../trace/trace-context-manager'),
Logger = require('../logger');
Logger = require('../logger'),
StatusDetector = require('../topology/status-detector'),
BlobValue = require('../value/blob-value');

@@ -30,6 +32,6 @@ var ControlHandler = function () {

ControlHandler.prototype.process = function (p) {
ControlHandler.prototype.process = async function (p) {
switch (p.getPackType()) {
case PackEnum.PARAMETER:
this.handle(p);
await this.handle(p);
break;

@@ -41,3 +43,3 @@ default:

ControlHandler.prototype.handle = function (p) {
ControlHandler.prototype.handle = async function (p) {
var self = this;

@@ -121,3 +123,3 @@ if (!this._dataPackSender) {

case ParamDef.LOADED_CLASS_REDEFINE:
self._dataPackSender.sendResponseHide(p.getResponse());
self._dataPackSender.sendResponseHide(p.getResponse());
break;

@@ -188,3 +190,3 @@ case ParamDef.NODE_MODULE_DEPENDENCY:

props[key] = val
}
}
Configure.saveProperty(props);

@@ -230,2 +232,13 @@ } catch (e) {

break;
case ParamDef.GET_TOPOLOGY:
try {
const node = await new StatusDetector().process();
if (node) {
p.putValue("node", new BlobValue(node.toBytes()));
}
this._dataPackSender.sendResponseHide(p.getResponse());
} catch (e) {
Logger.printError('WHATAP-203', 'Node Module Dependency ', e, true);
}
break;
}

@@ -232,0 +245,0 @@ }

@@ -32,3 +32,4 @@ /**

PgSqlObserver = require('../observers/pgsql-observer').PgSqlObserver,
ScheduleObserver = require('../observers/schedule-observer').ScheduleObserver;
ScheduleObserver = require('../observers/schedule-observer').ScheduleObserver,
GRpcObserver = require('../observers/grpc-observer').GRpcObserver;

@@ -106,4 +107,4 @@ var Configuration = require('./../conf/configure'),

var self = this;
if(self._initialized) {
return;
if(self._initialized) {
return;
}

@@ -114,3 +115,3 @@ self._initialized = true;

self.findRoot();
Logger.initializer.process();

@@ -122,3 +123,3 @@ Logger.print('WHATAP-001', 'Start initialize WhaTap Agent... Root[' + self._conf['app.root'] + ']', true);

}
NodeUtil.getPackageJson();

@@ -138,3 +139,3 @@ PackageCtrHelper.dynamicHook();

}
self._securityMaster.run( function (err) {

@@ -187,3 +188,3 @@ if(err) {

}
WhatapUtil.printWhatap();

@@ -275,3 +276,4 @@ self.connectCount = 0;

observes.push(ScheduleObserver);
// observes.push(GRpcObserver);
var packageToObserve = {};

@@ -278,0 +280,0 @@ observes.forEach(function(observeObj) {

@@ -99,3 +99,3 @@ /**

e.level = EventLevel.INFO;
DataPackSender.send(e);
DataPackSender.sendPack(e);
}

@@ -102,0 +102,0 @@ }

@@ -170,2 +170,18 @@ /**

var sendLogSinkPack = function(p){
if (p == null)
return;
p.pcode = secuMaster.PCODE;
p.oid = secuMaster.OID;
p.okind=secuMaster.OKIND;
p.onode=secuMaster.ONODE;
if (conf.getProperty('logsink_high_secure_enabled', false)) {
TcpRequestMgr.add(NetFlag.SECURE_CYPHER, p);
}else{
TcpRequestMgr.add(NetFlag.SECURE_HIDE, p);
}
};
var sendEventPack = function(p){

@@ -255,2 +271,3 @@ return sendPack(p);

sendStatUserAgentPack : sendStatUserAgentPack,
sendLogSinkPack : sendLogSinkPack,

@@ -257,0 +274,0 @@ sendRealtimeUserPack : sendRealtimeUserPack,

@@ -188,3 +188,3 @@ /**

startProcessQueue() {
if (!this.processing) {
if (!this.isProcessing) {
this.processQueue()

@@ -194,3 +194,3 @@ }

stopProcessQueue() {
this.processing = false;
this.isProcessing = false;
}

@@ -197,0 +197,0 @@ }

@@ -171,2 +171,8 @@ /**

}
if(conf.getProperty('log_root', null)){
root = conf.getProperty('log_root', null);
if(fs.existsSync(root) == false) {
fs.mkdirSync(root, {recursive: true});
}
}
var dir = path.join(root, 'logs');

@@ -192,4 +198,10 @@ if(fs.existsSync(dir) == false) {

var root = conf['app.root'];
if(conf.getProperty('log_root', null)){
root = conf.getProperty('log_root', null);
if(fs.existsSync(root) == false) {
fs.mkdirSync(root, {recursive: true});
}
}
var nowUnit = DateUtil.getDateUnit(),
root = conf['app.root'],
dir = path.join(root, 'logs'),

@@ -238,2 +250,8 @@ log_prefix = WHATAP_CONF+"-";

var root = conf['app.root'];
if(conf.getProperty('log_root', null)){
root = conf.getProperty('log_root', null);
if(fs.existsSync(root) == false) {
fs.mkdirSync(root, {recursive: true});
}
}
if(root==null ){

@@ -282,2 +300,8 @@ return null;

var root = conf['app.root'];
if(conf.getProperty('log_root', null)){
root = conf.getProperty('log_root', null);
if(fs.existsSync(root) == false) {
fs.mkdirSync(root, {recursive: true});
}
}
if(root==null){

@@ -284,0 +308,0 @@ return o;

@@ -37,2 +37,3 @@ /**

exports.GET_ACTIVE_TRANSACTION_DETAIL = 26;
exports.GET_TOPOLOGY = 27

@@ -39,0 +40,0 @@ exports.NODE_MODULE_DEPENDENCY = 101;

@@ -10,2 +10,11 @@ /**

var HttpStepX = require('../step/http-stepx');
const Hexa32 = require("../util/hexa32");
const SecurityMaster = require("../net/security-master");
const conf = require("../conf/configure");
const KeyGen = require("../util/keygen");
const HashUtil = require("../util/hashutil");
const DataTextAgent = require("../data/datatext-agent");
const shimmer = require('../core/shimmer');
var GlobalObserver = function (agent) {

@@ -30,4 +39,135 @@ this.agent = agent;

});
shimmer.wrap(mod, 'fetch', function(original) {
return function(...args) {
var info = args[1] ? args[1] : {};
var ctx = TraceContextManager._asyncLocalStorage.getStore();
if (ctx) {
interTxTraceAutoOn(ctx);
if (conf.mtrace_enabled) {
if (info.headers) {
info.headers['x-wtap-po'] = transferPOID(ctx);
} else {
info.headers = {
'x-wtap-po': transferPOID(ctx)
};
}
if (conf.stat_mtrace_enabled) {
info.headers[conf._trace_mtrace_spec_key1] = transferSPEC_URL(ctx);
}
if (conf.mtid_mtrace_enabled && ctx.mtid.isZero() === false) {
info.headers[conf._trace_mtrace_caller_key] = transferMTID_CALLERTX(ctx);
}
args[1] = info;
}
}
const promise = original.apply(this, args);
promise.then(response => {
var ctx = TraceContextManager._asyncLocalStorage.getStore();
if (ctx && args[0]) {
const url = new URL(args[0]);
ctx.httpc_host = url.hostname;
ctx.httpc_url = url.pathname;
ctx.httpc_port = url.port || (url.protocol === 'https:' ? 443 : 80);
var step = new HttpStepX();
step.start_time = ctx.getElapsedTime();
step.url = HashUtil.hashFromString(ctx.httpc_url);
DataTextAgent.HTTPC_URL.add(step.url, ctx.httpc_url);
step.host = HashUtil.hashFromString(ctx.httpc_host);
DataTextAgent.HTTPC_HOST.add(step.host, ctx.httpc_host);
step.port = ctx.httpc_port;
ctx.profile.push(step);
}
}).catch(e => {
Logger.printError("WHATAP-704", "Promise error occurred during fetch: " + e, false);
});
return promise;
};
});
};
var transfer_poid;
function transferPOID(ctx) {
if (transfer_poid)
return transfer_poid;
transfer_poid = Hexa32.toString32(SecurityMaster.PCODE) + ','
+ Hexa32.toString32(SecurityMaster.OKIND) + ',' + Hexa32.toString32(SecurityMaster.OID);
return transfer_poid;
}
function transferMTID_CALLERTX(ctx) {
if (ctx.transfer_id)
return ctx.transfer_id;
var x = Hexa32.toString32(ctx.mtid) + ',' + (ctx.mdepth + 1) + ',' + Hexa32.toString32(ctx.txid);
ctx.transfer_id = x;
return ctx.transfer_id;
}
function transferSPEC_URL(ctx) {
if (ctx.transfer_info)
return ctx.transfer_info;
var x = conf.mtrace_spec + ',' + ctx.service_hash;
ctx.transfer_info = x;
return ctx.transfer_info;
}
var check_seq = 1;
function interTxTraceAutoOn(ctx) {
if (conf.mtrace_enabled == false || ctx.httpc_checked || ctx.mtid.isZero() === false)
return;
ctx.httpc_checked = true;
if (conf.mtrace_rate >= 100) {
ctx.mtid = KeyGen.next();
return;
}
check_seq++;
switch (Math.floor(conf.mtrace_rate / 10)) {
case 10:
ctx.mtid = KeyGen.next();
break;
case 9:
if (check_seq % 10 !== 0)
ctx.mtid = KeyGen.next();
break;
case 8:
if (check_seq % 5 !== 0)
ctx.mtid = KeyGen.next();
break;
case 7:
if (check_seq % 4 !== 0)
ctx.mtid = KeyGen.next();
break;
case 6:
if (check_seq % 3 !== 0)
ctx.mtid = KeyGen.next();
break;
case 5:
if (check_seq % 2 === 0)
ctx.mtid = KeyGen.next();
break;
case 4:
if (check_seq % 3 === 0 || check_seq % 5 === 0)
ctx.mtid = KeyGen.next();
break;
case 3:
if (check_seq % 4 === 0 || check_seq % 5 === 0)
ctx.mtid = KeyGen.next();
break;
case 2:
if (check_seq % 5 === 0)
ctx.mtid = KeyGen.next();
break;
case 1:
if (check_seq % 10 === 0)
ctx.mtid = KeyGen.next();
break;
}
}
exports.GlobalObserver = GlobalObserver;

@@ -62,4 +62,4 @@ /**

var profile_http_parameter_keys = conf.getProperty('profile_http_parameter_keys', '');
var ignore_nextjs_build_file_enabled = conf.getProperty('ignore_nextjs_build_file_enabled', true);
var ignore_nextjs_build_file_path = conf.getProperty('ignore_nextjs_build_file_path', '/_next/');
var ignore_build_file_enabled = conf.getProperty('ignore_build_file_enabled', true);
var ignore_build_file_path = conf.getProperty('ignore_build_file_path', '/_next/');
conf.on('trace_http_client_ip_header_key', function(newProperty) {

@@ -122,7 +122,7 @@ configIpHeaderKey = newProperty;

})
conf.on('ignore_nextjs_build_file_enabled', function (newProps) {
ignore_nextjs_build_file_enabled = newProps;
conf.on('ignore_build_file_enabled', function (newProps) {
ignore_build_file_enabled = newProps;
})
conf.on('ignore_nextjs_build_file_path', function (newProps) {
ignore_nextjs_build_file_path = newProps;
conf.on('ignore_build_file_path', function (newProps) {
ignore_build_file_path = newProps;
})

@@ -246,3 +246,3 @@ var staticConents = function (newProps) {

if(ignore_http_method && ignore_http_method.toUpperCase().split(',').includes(req.method)) { return null; }
if (ignore_nextjs_build_file_enabled && ignore_nextjs_build_file_path && ignore_nextjs_build_file_path.split(',').some(path => req.url.startsWith(path))) {
if (ignore_build_file_enabled && ignore_build_file_path && ignore_build_file_path.split(',').some(path => req.url.startsWith(path))) {
return null;

@@ -249,0 +249,0 @@ }

@@ -7,16 +7,31 @@ /**

var TraceContextManager = require('../trace/trace-context-manager');
const TraceContextManager = require('../trace/trace-context-manager');
const conf = require('../conf/configure');
const LogTracer = require('../logsink/log-tracer');
var ProcessObserver = function (agent) {
let logsink_enabled = conf.getProperty('logsink_enabled', false);
let logTracer = logsink_enabled ? new LogTracer() : null;
conf.on('logsink_enabled', function(newProperty) {
logsink_enabled = newProperty;
logTracer = logsink_enabled ? new LogTracer() : null;
});
const ProcessObserver = function (agent) {
this.agent = agent;
this.packages = ['process'];
};
ProcessObserver.prototype.inject = function (mod, moduleName) {
var self = this;
self.agent.aop.before(mod, 'nextTick', function (obj, args) {
var cached_id = TraceContextManager.getCurrentId();
self.agent.aop.functionHook(args, -1, function (obj, args) {
if(cached_id != null) {
this._hookNextTick(mod);
this._hookStdOutWrite();
this._hookStdErrWrite();
};
ProcessObserver.prototype._hookNextTick = function (mod) {
this.agent.aop.before(mod, 'nextTick', (obj, args) => {
const cached_id = TraceContextManager.getCurrentId();
this.agent.aop.functionHook(args, -1, (obj, args) => {
if (cached_id != null) {
TraceContextManager.resume(cached_id);
cached_id = null;
}

@@ -27,2 +42,36 @@ });

ProcessObserver.prototype._hookStdOutWrite = function () {
this.agent.aop.after(process.stdout, 'write', (obj, args) => {
if (conf.getProperty('logsink_enabled', false) && args[0]) {
return;
let content = typeof args[0] === 'string' ? args[0] : (args[0].message || '');
try {
const parsedContent = JSON.parse(content);
content = parsedContent.message ? parsedContent.message : JSON.stringify(parsedContent);
} catch (e) {
}
if (logTracer && content) {
logTracer.addStdWrite(content, conf.logsink_category_stdout);
}
}
});
};
ProcessObserver.prototype._hookStdErrWrite = function () {
this.agent.aop.after(process.stderr, 'write', (obj, args) => {
if (conf.getProperty('logsink_enabled', false) && args[0]) {
return;
let content = typeof args[0] === 'string' ? args[0] : (args[0].message || '');
try {
const parsedContent = JSON.parse(content);
content = parsedContent.message ? parsedContent.message : JSON.stringify(parsedContent);
} catch (e) {
}
if (logTracer && content) {
logTracer.addStdWrite(content, conf.logsink_category_stderr);
}
}
});
};
module.exports.ProcessObserver = ProcessObserver;

@@ -9,8 +9,8 @@ var TraceContextManager = require('../trace/trace-context-manager'),

Logger = require('../logger');
const shimmer = require('../core/shimmer');
var RedisObserver = function (agent) {
this.agent = agent;
this.aop = agent.aop;
this.packages = ['redis'];
this.packages = ['redis', 'ioredis'];
};

@@ -27,3 +27,3 @@

var dbc_hash= 0;
var dbc_hash = 0;
var dbc;

@@ -33,4 +33,4 @@ var dbc_time;

function (obj, args, lctx) {
if(dbc_hash === 0){
if(args.length > 0) {
if (dbc_hash === 0) {
if (args.length > 0) {
var info = (args[0] || {});

@@ -49,3 +49,3 @@ dbc = 'redis://';

var updateCommand = new Set(['set', 'lSet', 'lset', 'hSet', 'hset', 'zAdd', 'zadd']);
var deleteCommand = new Set(['del', 'lRem', 'sRem', 'srem', 'hDel', 'hdel', 'zRem', 'zrem']);
var deleteCommand = new Set(['del', 'lRem', 'sRem', 'srem', 'hDel', 'hdel', 'zRem', 'zrem']);
var commands = new Set([...selectCommand, ...insertCommand, ...updateCommand, ...deleteCommand]);

@@ -56,3 +56,5 @@ commands.forEach(function (command) {

var ctx = TraceContextManager.getCurrentContext();
if(ctx == null) {return;}
if (ctx == null) {
return;
}

@@ -70,8 +72,8 @@ var dbc_step = new DBCStep();

const values = [];
for(let i = 1; i < args.length; i++)
for (let i = 1; i < args.length; i++)
values.push(args[i]);
var sql = 'Redis ' + command + ': ' + JSON.stringify([key]);
if(values.length > 0)
sql += ' ' + JSON.stringify(values);
// if (values.length > 0)
// sql += ' ' + JSON.stringify(values);
sql_step.hash = HashUtil.hashFromString(sql);

@@ -82,3 +84,3 @@ sql_step.start_time = ctx.getElapsedTime();

ctx.profile.push(sql_step);
} catch(e) {
} catch (e) {
Logger.printError("WHATAP-605", "Redis CRUD error", e, false);

@@ -162,4 +164,60 @@ sql_step = null;

});
var ioredis_dbc_hash = 0;
var ioredis_dbc;
self.aop.both(mod.prototype, 'sendCommand', function (obj, args, lctx) {
if (ioredis_dbc_hash === 0) {
if (obj && Object.keys(obj.options).length > 0) {
var info = obj.options
ioredis_dbc = 'redis://';
ioredis_dbc += info.host || '';
ioredis_dbc += ':';
ioredis_dbc += info.port || '';
ioredis_dbc_hash = HashUtil.hashFromString(ioredis_dbc);
}
}
}, function (obj, args, ret, lctx) {
var selectCommand = new Set(['get', 'hget', 'hmget', 'zrange', 'smembers', 'lrange']);
var insertCommand = new Set(['set', 'hset', 'hmset', 'zadd', 'lset', 'sadd', 'lpush', 'rpush']);
var updateCommand = new Set(['set', 'lset', 'hset', 'zadd']);
var deleteCommand = new Set(['del', 'lrem', 'srem', 'hdel', 'zrem']);
var commands = new Set([...selectCommand, ...insertCommand, ...updateCommand, ...deleteCommand]);
if(!args[0] || (args[0] && !args[0].name)){
return;
}
var command = args[0].name;
if(commands.has(command.toLowerCase())){
var ctx = TraceContextManager.getCurrentContext();
if (ctx == null) {
return;
}
var dbc_step = new DBCStep();
dbc_step.hash = ioredis_dbc_hash;
dbc_step.start_time = ctx.getElapsedTime();
DataTextAgent.DBC.add(ioredis_dbc_hash, ioredis_dbc);
ctx.profile.push(dbc_step);
var sql_step;
var args = args[0].args;
try {
sql_step = new SqlStepX();
let key = args[0];
if(typeof key === 'string')
key = [key];
var sql = 'Redis ' + command + ': ' + JSON.stringify(key);
sql_step.hash = HashUtil.hashFromString(sql);
sql_step.start_time = ctx.getElapsedTime();
DataTextAgent.SQL.add(sql_step.hash, sql);
ctx.profile.push(sql_step);
} catch (e) {
Logger.printError("WHATAP-605", "Redis CRUD error", e, false);
sql_step = null;
}
}
})
};
exports.RedisObserver = RedisObserver;

@@ -30,3 +30,3 @@ /**

for(key in this.attr) {
for(var key in this.attr) {
dout.writeText(key);

@@ -33,0 +33,0 @@ dout.writeText(this.attr[key]);

@@ -35,2 +35,3 @@ /**

exports.ZIP = 0x170b;
exports.LOGSINK = 0x170a;

@@ -62,4 +63,5 @@ exports.PACK_NAME = {

0x1601 : 'TAG_COUNT',
0x170b : 'ZIP'
0x170b : 'ZIP',
0x170a : 'LOGSINK',
};

@@ -13,3 +13,2 @@ /**

DataInputX = require('../io/data-inputx');
var zlib = require('zlib');

@@ -16,0 +15,0 @@ function ZipPack() {

{
"name": "whatap",
"homepage": "http://www.whatap.io",
"version": "0.4.98",
"releaseDate": "20240709",
"version": "0.5.0",
"releaseDate": "20240812",
"description": "Monitoring and Profiling Service",

@@ -7,0 +7,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