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.5.4 to 0.5.5

lib/pii/pii-item.js

1

lib/conf/config-default.js

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

"debug_apdex_enabled": bool('debug_apdex_enabled', false),
"mtid_mtrace_enabled": bool('mtid_mtrace_enabled' , false),

@@ -228,0 +227,0 @@ // debug add

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

Configuration.prototype.getLogSinkProperty = function (id, key) {
return this.getProperty("pii_mask_logsink_"+id + "_" + key);
}
Configuration.prototype.getSqlProperty = function (id, key) {
return this.getProperty("pii_mask_sql_"+id + "_" + key)
}
function toNumber(value) {

@@ -343,0 +351,0 @@ if(typeof value == 'number') {

@@ -35,4 +35,13 @@ /**

"logsink_max_buffer_size": num("logsink_max_buffer_size", 1024*64),
"logsink_max_wait_time": num("logsink_max_wait_time", 2000)
"logsink_max_wait_time": num("logsink_max_wait_time", 2000),
"pii_mask_logsink_enabled": bool("pii_mask_logsink_enabled", false),
"pii_mask_logsink_items": str("pii_mask_logsink_items", ""),
"pii_mask_logsink_replace": str("pii_mask_logsink_replace", "***"),
"pii_mask_sql_enabled": bool("pii_mask_sql_enabled", false),
"pii_mask_sql_items": str("pii_mask_sql_items", ""),
"pii_mask_sql_replace": str("pii_mask_sql_replace", "pii-included"),
};
module.exports = LogConfigDefault;

@@ -29,3 +29,3 @@ /**

fs = require('fs'),
Long = require('long');
PiiMask = require('../../pii/pii-mask');

@@ -42,2 +42,4 @@ function AgentInfo() {

AgentInfo.prototype.process = function (p) {
// PiiMask.update();
p.starttime = Date.now();

@@ -44,0 +46,0 @@ /*

@@ -8,24 +8,5 @@ /**

var CounterTask = require('../counter-task'),
StatSql = require('../../../stat/stat-sql'),
conf = require('../../../conf/configure'),
SecurityMaster = require('../../../net/security-master'),
TraceContextManager = require('../../../trace/trace-context-manager'),
MeterActiveX = require('../../meter/meter-activex'),
ActiveStackPack = require('../../../pack/activestack-pack'),
ParamPack = require('../../../pack/param-pack'),
EventPack = require('../../../pack/event-pack'),
ActiveStackStep = require('../../../step/activestack-step'),
DataPackSender = require('../../../data/datapack-sender'),
DataTextAgent = require('../../../data/datatext-agent'),
EventLevel = require('../../../data/event-level'),
MeterUsers = require('../../meter/meter-users'),
KeyGen = require('../../../util/keygen'),
TextTypes = require('../../../lang/text-types'),
ResourceProfile = require('../../../util/resourceprofile'),
Logger = require('../../../logger'),
HashUtil = require('../../../util/hashutil'),
KubeUtil = require('../../../util/kube-util'),
DateUtil = require('../../../util/dateutil'),
AwsEcsClientThread = require('./util/awsEcsClientThread'),
Long = require('long');
AwsEcsClientThread = require('./util/awsEcsClientThread');

@@ -39,6 +20,6 @@ function SystemECSTask() {

SystemECSTask.prototype.process = function (p) {
p.cpu_cores = 1;
p.host_ip = SecurityMaster.IP;
var ecs = AwsEcsClientThread;
p.cpu = ecs.cpu * conf.correction_factor_cpu;

@@ -50,3 +31,4 @@ p.cpu_sys = ecs.cpu_sys;

if (ecs.millicore > 0) {
p.metering = ecs.millicore /1024;
p.metering = ecs.millicore / 1024;
p.cpu_cores = Math.ceil(p.metering);
} else {

@@ -53,0 +35,0 @@ p.metering = p.cpu_cores;

@@ -1,3 +0,1 @@

var http = require('http');

@@ -12,14 +10,13 @@ /**

conf = require('../../../../conf/configure'),
Logger = require('../../../../logger'),
DateUtil = require('../../../../util/dateutil'),
Long = require('long');
Logger = require('../../../../logger'),
DateUtil = require('../../../../util/dateutil');
function AwsEcsClientThread() {
if (typeof AwsEcsClientThread.instance === "object") {
return AwsEcsClientThread.instance;
if (typeof AwsEcsClientThread.instance === "object") {
return AwsEcsClientThread.instance;
}
this.millicore = 0;
this.last_milli_check = 0;
this.check = AwsEcsClientThread.CHECK_MAX;
this.last_milli_check = 0;
this.check = AwsEcsClientThread.CHECK_MAX;

@@ -32,11 +29,15 @@

AwsEcsClientThread.instance = this;
var self = this;
setTimeout(function () {
self.run();
}, 100);
AwsEcsClientThread.instance = this;
};
AwsEcsClientThread.prototype = new AwsEcsClientThread();
AwsEcsClientThread.prototype.run = function() {
AwsEcsClientThread.prototype.run = function () {
var self = this;
try {
if (conf.aws_ecs_enabled) {
self.intervalIndex = setInterval(function(){
self.intervalIndex = setInterval(function () {
var meta_uri = process.env["ECS_CONTAINER_METADATA_URI"];

@@ -47,17 +48,11 @@ if (meta_uri != null) {

}
}, conf.aws_ecs_stat_interval || 3000);
var meta_uri = process.env["ECS_CONTAINER_METADATA_URI"];
if (meta_uri != null) {
this.getCpuLimit(meta_uri);
this.process(meta_uri);
}
}, conf.getProperty('aws_ecs_stat_interval', 3000));
}
} catch (e) {
Logger.printError('WHATAP ECS-ERR ' , 'run exception', e , true);
Logger.printError('WHATAP ECS-ERR ', 'run exception', e, true);
}
}
AwsEcsClientThread.prototype.stop = function(){
if(this.intervalIndex){
AwsEcsClientThread.prototype.stop = function () {
if (this.intervalIndex) {
clearInterval(this.intervalIndex);

@@ -68,3 +63,3 @@ this.intervalIndex = undefined;

AwsEcsClientThread.prototype.getCpuLimit = function(meta_uri){
AwsEcsClientThread.prototype.getCpuLimit = function (meta_uri) {
var self = this;

@@ -78,6 +73,20 @@

// var json = JSON.parse('{"DockerId":"e9950915-abaa-467f-9898-3bd0d4e6d0aa","Name":"web-application","DockerName":"ecs-web-application-1","Image":"nginx:latest","ImageID":"sha256:123456789abcdef...","Labels":{"com.amazonaws.ecs.cluster":"default","com.amazonaws.ecs.task-arn":"arn:aws:ecs:us-east-1:123456789012:task/default/1234567890abcdef","com.amazonaws.ecs.task-definition-family":"web-application","com.amazonaws.ecs.task-definition-version":"1"},"DesiredStatus":"RUNNING","KnownStatus":"RUNNING","Limits":{"CPU":256,"Memory":512},"CreatedAt":"2024-01-01T00:00:00.000Z","StartedAt":"2024-01-01T00:00:01.000Z","Type":"NORMAL","Networks":[{"NetworkMode":"awsvpc","IPv4Addresses":["172.31.10.100"],"AttachmentIndex":0,"MACAddress":"0a:1b:2c:3d:4e:5f","IPv4SubnetCIDRBlock":"172.31.0.0/20","DomainNameServers":["169.254.169.253"],"DomainNameSearchList":["us-east-1.compute.internal"],"PrivateDNSName":"ip-172-31-10-100.us-east-1.compute.internal","SubnetGatewayIpv4Address":"172.31.0.1/20"}],"ContainerARN":"arn:aws:ecs:us-east-1:123456789012:container/1234567890abcdef","LogDriver":"awslogs","LogOptions":{"awslogs-group":"/ecs/web-application","awslogs-region":"us-east-1","awslogs-stream":"ecs/web-application/1234567890abcdef"}}');
// 2025-01-23 ECS fargate
// var json = JSON.parse('{"DockerId":"a663f01570b14228b0795db9c8d11e16-2785547837","Name":"test_container","DockerName":"test_container","Image":"whataphub/ecs_sample:v0.0.4","ImageID":"sha256:748b5cd202288478bbdbd4baf8fe17c8b660163c24c513db5ccbe7a1bdcae0e0","Labels":{"com.amazonaws.ecs.cluster":"arn:aws:ecs:ap-northeast-2:592247757306:cluster/ecs_sample","com.amazonaws.ecs.container-name":"test_container","com.amazonaws.ecs.task-arn":"arn:aws:ecs:ap-northeast-2:592247757306:task/ecs_sample/a663f01570b14228b0795db9c8d11e16","com.amazonaws.ecs.task-definition-family":"ecs_task_sample","com.amazonaws.ecs.task-definition-version":"4"},"DesiredStatus":"RUNNING","KnownStatus":"RUNNING","Limits":{"CPU":2},"CreatedAt":"2025-01-23T04:42:03.843875803Z","StartedAt":"2025-01-23T04:42:03.843875803Z","Type":"NORMAL","Networks":[{"NetworkMode":"awsvpc","IPv4Addresses":["172.31.63.147"]}]}');
// if (json && json["Limits"]) {
// this.millicore = json.Limits.CPU;
// if (this.millicore < 128) {
// this.millicore *= 1024;
// }
// Logger.print("SysCPU", " ECS CPU Limits : " + (this.millicore / 1024) + "core", false)
// }
read(meta_uri, function(json){
if (json && json["Limits"]) {
var Limits = json["Limits"];
if(Limits){ millicore = Limits["CPU"]; }
this.millicore = json.Limits.CPU;
if (this.millicore < 128) {
this.millicore *= 1024;
}
Logger.print("WHATAP-811", "ECS CPU Limits : " + (this.millicore / 1024) + "core", false)
}

@@ -87,3 +96,3 @@ }, function(){

if (--self.check >= 0) {
Logger.printError('WHATAP ECS-ERR ' , 'not receive limit cpu', e , true);
Logger.printError('WHATAP-819' , 'not receive limit cpu', e , true);
}

@@ -93,51 +102,85 @@ })

AwsEcsClientThread.prototype.process = function(meta_uri) {
http.get(meta_uri + '/stats', function(res){
var statusCode = res.statusCode;
res.setEncoding('utf8');
AwsEcsClientThread.prototype.process = function (meta_uri) {
var self = this;
var rawData = '';
res.on('data', function(chunk){ rawData += chunk; });
res.on('end', function(){
try {
var stats = JSON.parse(rawData);
fetch(meta_uri + '/stats', {timeout: 3000})
.then(response => response.text())
.then(stats => {
if (!stats || stats.length === 0) {
self.reset();
return;
}
var precpu_stats = stats["precpu_stats"];
var cpu_stats = stats["cpu_stats"];
var memory_stats = stats["memory_stats"];
// let stats = '{"blkio_stats":{"io_merged_recursive":[],"io_queue_recursive":[],"io_service_bytes_recursive":[{"major":259,"minor":3,"op":"Read","value":0},{"major":259,"minor":3,"op":"Write","value":45514752},{"major":259,"minor":3,"op":"Sync","value":4268032},{"major":259,"minor":3,"op":"Async","value":41246720},{"major":259,"minor":3,"op":"Discard","value":0},{"major":259,"minor":3,"op":"Total","value":45514752}],"io_service_time_recursive":[],"io_serviced_recursive":[{"major":259,"minor":3,"op":"Read","value":0},{"major":259,"minor":3,"op":"Write","value":342},{"major":259,"minor":3,"op":"Sync","value":272},{"major":259,"minor":3,"op":"Async","value":70},{"major":259,"minor":3,"op":"Discard","value":0},{"major":259,"minor":3,"op":"Total","value":342}],"io_time_recursive":[],"io_wait_time_recursive":[],"sectors_recursive":[]},"cpu_stats":{"cpu_usage":{"percpu_usage":[5585610339,5944268076],"total_usage":15373171220,"usage_in_kernelmode":2150000000,"usage_in_usermode":7990000000},"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"id":"10b741d47dc649d5b321f83c7c14c950-441560335","memory_stats":{"limit":9223372036854772000,"max_usage":246165504,"stats":{"active_anon":0,"active_file":27439104,"cache":56365056,"dirty":0,"hierarchical_memory_limit":2147483648,"hierarchical_memsw_limit":9223372036854772000,"inactive_anon":98267136,"inactive_file":28925952,"mapped_file":0,"pgfault":303666,"pgmajfault":0,"pgpgin":199749,"pgpgout":161965,"rss":98402304,"rss_huge":0,"total_active_anon":0,"total_active_file":27439104,"total_cache":56365056,"total_dirty":0,"total_inactive_anon":98267136,"total_inactive_file":28925952,"total_mapped_file":0,"total_pgfault":303666,"total_pgmajfault":0,"total_pgpgin":199749,"total_pgpgout":161965,"total_rss":98402304,"total_rss_huge":0,"total_unevictable":0,"total_writeback":135168,"unevictable":0,"writeback":135168},"usage":168361984},"name":"simple-user-app","networks":{"eth1":{"rx_bytes":1604876131,"rx_dropped":0,"rx_errors":0,"rx_packets":1076062,"tx_bytes":6252490,"tx_dropped":0,"tx_errors":0,"tx_packets":74457}},"num_procs":0,"pids_stats":{},"precpu_stats":{"cpu_usage":{"percpu_usage":[5570558410,5925648831],"total_usage":15328276321,"usage_in_kernelmode":2140000000,"usage_in_usermode":7970000000},"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"preread":"2023-05-30T11:29:20.720196524Z","read":"2023-05-30T11:29:30.719936356Z","storage_stats":{}}';
// 2025-01-23 ECS fargate
// var stats = '{"read":"2025-01-23T04:42:03.844081622Z","preread":"0001-01-01T00:00:00Z","pids_stats":{},"blkio_stats":{"io_service_bytes_recursive":[],"io_serviced_recursive":[],"io_queue_recursive":[],"io_service_time_recursive":[],"io_wait_time_recursive":[],"io_merged_recursive":[],"io_time_recursive":[],"sectors_recursive":[]},"num_procs":0,"storage_stats":{},"cpu_stats":{"cpu_usage":{"total_usage":33451672,"percpu_usage":[22728826,10722846],"usage_in_kernelmode":10000000,"usage_in_usermode":20000000},"system_cpu_usage":397640000000,"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"precpu_stats":{"cpu_usage":{"total_usage":0,"usage_in_kernelmode":0,"usage_in_usermode":0},"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"memory_stats":{"usage":765952,"max_usage":5267456,"stats":{"active_anon":0,"active_file":0,"cache":0,"dirty":0,"hierarchical_memory_limit":4294967296,"hierarchical_memsw_limit":9223372036854771712,"inactive_anon":135168,"inactive_file":0,"mapped_file":0,"pgfault":2112,"pgmajfault":0,"pgpgin":1452,"pgpgout":1452,"rss":270336,"rss_huge":0,"total_active_anon":0,"total_active_file":0,"total_cache":0,"total_dirty":0,"total_inactive_anon":135168,"total_inactive_file":0,"total_mapped_file":0,"total_pgfault":2112,"total_pgmajfault":0,"total_pgpgin":1452,"total_pgpgout":1452,"total_rss":270336,"total_rss_huge":0,"total_unevictable":0,"total_writeback":0,"unevictable":0,"writeback":0},"limit":9223372036854771712},"name":"test_container","id":"a663f01570b14228b0795db9c8d11e16-2785547837","networks":{"eth1":{"rx_bytes":463375353,"rx_packets":310281,"rx_errors":0,"rx_dropped":0,"tx_bytes":250514,"tx_packets":2681,"tx_errors":0,"tx_dropped":0}}}';
// var stats = '{"read":"2025-01-23T04:52:53.853606208Z","preread":"2025-01-23T04:52:43.853359478Z","pids_stats":{},"blkio_stats":{"io_service_bytes_recursive":[],"io_serviced_recursive":[],"io_queue_recursive":[],"io_service_time_recursive":[],"io_wait_time_recursive":[],"io_merged_recursive":[],"io_time_recursive":[],"sectors_recursive":[]},"num_procs":0,"storage_stats":{},"cpu_stats":{"cpu_usage":{"total_usage":8111895890,"percpu_usage":[3973083470,4138812420],"usage_in_kernelmode":2220000000,"usage_in_usermode":5910000000},"system_cpu_usage":1692450000000,"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"precpu_stats":{"cpu_usage":{"total_usage":8023476115,"percpu_usage":[3922781879,4100694236],"usage_in_kernelmode":2180000000,"usage_in_usermode":5820000000},"system_cpu_usage":1672470000000,"online_cpus":2,"throttling_data":{"periods":0,"throttled_periods":0,"throttled_time":0}},"memory_stats":{"usage":66977792,"max_usage":98480128,"stats":{"active_anon":0,"active_file":0,"cache":0,"dirty":0,"hierarchical_memory_limit":4294967296,"hierarchical_memsw_limit":9223372036854771712,"inactive_anon":61906944,"inactive_file":0,"mapped_file":0,"pgfault":463386,"pgmajfault":0,"pgpgin":147477,"pgpgout":132323,"rss":62042112,"rss_huge":0,"total_active_anon":0,"total_active_file":0,"total_cache":0,"total_dirty":0,"total_inactive_anon":61906944,"total_inactive_file":0,"total_mapped_file":0,"total_pgfault":463386,"total_pgmajfault":0,"total_pgpgin":147477,"total_pgpgout":132323,"total_rss":62042112,"total_rss_huge":0,"total_unevictable":0,"total_writeback":0,"unevictable":0,"writeback":0},"limit":9223372036854771712},"name":"test_container","id":"a663f01570b14228b0795db9c8d11e16-2785547837","networks":{"eth1":{"rx_bytes":463489958,"rx_packets":311334,"rx_errors":0,"rx_dropped":0,"tx_bytes":1962223,"tx_packets":4432,"tx_errors":0,"tx_dropped":0}}}'
const o = JSON.parse(stats);
var system_cpu_usage = delta(precpu_stats, cpu_stats, "system_cpu_usage");
if (conf.getProperty('debug_aws_ecs_enabled', false)) {
Logger.print("AwsEcsClient", 30, "meta_uri=" + meta_uri + " stats\n" + JSON.stringify(o, null, 4));
}
var precpu_usage = precpu_stats["cpu_usage"];
var cpu_usage = cpu_stats["cpu_usage"];
const precpu_stats = o.precpu_stats || {};
const cpu_stats = o.cpu_stats || {};
const memory_stats = o.memory_stats || {};
var usage_tot = delta(precpu_usage, cpu_usage, "total_usage");
var usage_sys = delta(precpu_usage, cpu_usage, "usage_in_kernelmode");
var usage_usr = delta(precpu_usage, cpu_usage, "usage_in_usermode");
const system_cpu_usage = delta(precpu_stats, cpu_stats, "system_cpu_usage");
this.cpu = (usage_tot * 100) / system_cpu_usage;
this.cpu_sys = (usage_sys * 100) / system_cpu_usage;
this.cpu_user = (usage_usr * 100) / system_cpu_usage;
var mem_usage = memory_stats["usage"];
var mem_limit = memory_stats["limit"];
this.mem_pct = (mem_usage * 100) / mem_limit;
if (system_cpu_usage > 0) {
const precpu_usage = precpu_stats.cpu_usage || {};
const cpu_usage = cpu_stats.cpu_usage || {};
} catch (e) {
console.error(e.message);
const usage_tot = delta(precpu_usage, cpu_usage, "total_usage");
const usage_sys = delta(precpu_usage, cpu_usage, "usage_in_kernelmode");
const usage_usr = delta(precpu_usage, cpu_usage, "usage_in_usermode");
self.cpu = (usage_tot * 100.0) / system_cpu_usage;
self.cpu_sys = (usage_sys * 100.0) / system_cpu_usage;
self.cpu_user = (usage_usr * 100.0) / system_cpu_usage;
} else {
self.reset();
}
if (memory_stats) {
const mem_usage = memory_stats.usage || 0;
const memory_stats_stats = memory_stats.stats;
if (memory_stats_stats) {
const mem_limit = memory_stats_stats.hierarchical_memory_limit || 0;
self.mem_pct = (mem_usage * 100.0) / mem_limit;
} else {
self.mem_pct = 0;
}
} else {
self.mem_pct = 0;
}
})
.catch(error => {
Logger.printError("WHATAP-819", "ECS Process error: " + error, false)
self.reset();
});
};
});
AwsEcsClientThread.prototype.reset = function () {
this.cpu = 0;
this.cpu_sys = 0;
this.cpu_user = 0;
};
// reset 함수 추가
AwsEcsClientThread.prototype.reset = function () {
this.cpu = 0;
this.cpu_sys = 0;
this.cpu_user = 0;
};
AwsEcsClientThread.CHECK_MAX = 3;
function read(url, succ, fail){
http.get(url, function(res){
function read(url, succ, fail) {
http.get(url, function (res) {
var statusCode = res.statusCode;
if (statusCode !== 200) {
if(fail) fail();
if (fail) fail();

@@ -151,9 +194,11 @@ Logger.printError('WHATAP-999', 'read http call (not 200) ', e, true);

var rawData = '';
res.on('data', function(chunk){ rawData += chunk; });
res.on('end', function(){
res.on('data', function (chunk) {
rawData += chunk;
});
res.on('end', function () {
try {
var stats = JSON.parse(rawData);
if(succ) succ(stats);
if (succ) succ(stats);
} catch (e) {
if(fail) fail(e);
if (fail) fail(e);
Logger.printError('WHATAP-999', 'read http call (not application/json) ', e, true);

@@ -163,3 +208,3 @@ }

}).on('error', (e) => {
if(fail) fail(e);
if (fail) fail(e);
Logger.printError('WHATAP-999', 'read http call ', e, true);

@@ -170,7 +215,14 @@ });

function delta(j1, j2, key) {
if (!j1 || !j2)
return 0;
var v1 = j1[key];
var v2 = j2[key];
return v2 - v1;
if(v1 && v2)
return v2 - v1;
else
return 0;
}
module.exports = new AwsEcsClientThread();

@@ -193,10 +193,14 @@ /**

},
clearOldLog : function () {
if(conf.log_rotation_enabled === false || conf.log_enabled === false) { return; }
if(conf.log_keep_days <= 0) { return; }
clearOldLog: function () {
if (conf.log_rotation_enabled === false || conf.log_enabled === false) {
return;
}
if (conf.log_keep_days <= 0) {
return;
}
var root = conf['app.root'];
if(conf.getProperty('log_root', null)){
if (conf.getProperty('log_root', null)) {
root = conf.getProperty('log_root', null);
if(fs.existsSync(root) == false) {
if (fs.existsSync(root) == false) {
fs.mkdirSync(root, {recursive: true});

@@ -207,21 +211,21 @@ }

dir = path.join(root, 'logs'),
log_prefix = WHATAP_CONF+"-";
log_prefix = WHATAP_CONF + "-";
fs.readdir(dir, function (err, files) {
for(var i=0; i<files.length; i++) {
for (var i = 0; i < files.length; i++) {
var stat = fs.statSync(path.join(dir, files[i]));
if(stat.isDirectory()) {
if (stat.isDirectory()) {
return true;
}
var name = files[i];
if(name.indexOf(log_prefix) < 0) {
if (name.indexOf(log_prefix) < 0) {
return true;
}
var x = name.lastIndexOf('.');
if(x < 0) {
if (x < 0) {
return true;
}
var date = name.substr(log_prefix.length + 1, (x - log_prefix.length - 1));
if(date.length != 8) {
var date = name.substr(log_prefix.length, (x - log_prefix.length));
if (date.length != 8) {
return true;

@@ -232,8 +236,9 @@ }

try {
if (nowUnit - fileUnit > conflog_keep_days) {
fs.unlinkSync(path.join(dir, files[i]));
if (nowUnit - fileUnit > conf.log_keep_days) {
fs.rmSync(filePath);
}
} catch (e) { }
} catch (e) {
}
}
});

@@ -240,0 +245,0 @@ },

@@ -7,2 +7,3 @@ var conf = require('../conf/configure');

var ZipSend = require('./zip/zip-send');
var PiiMask = require('../pii/pii-mask')

@@ -45,2 +46,6 @@ function SenderUtil() {

if(conf.getProperty("pii_mask_logsink_enabled", false)){
// PiiMask.parseLogSink(p)
}
if(conf.getProperty('logsink_zip_enabled', false)){

@@ -47,0 +52,0 @@ ZipSend.getInstance().add(p);

@@ -55,3 +55,3 @@ /**

if (conf.mtrace_enabled) {
if (conf.getProperty('mtrace_enabled', false)) {
addTraceHeaders(info, ctx);

@@ -82,6 +82,6 @@ args[1] = info;

}
if (conf.stat_mtrace_enabled) {
if (conf.getProperty('stat_mtrace_enabled', false)) {
info.headers[conf._trace_mtrace_spec_key1] = transferSPEC_URL(ctx);
}
if (conf.mtid_mtrace_enabled && ctx.mtid.isZero() === false) {
if (ctx.mtid.isZero() === false) {
info.headers[conf._trace_mtrace_caller_key] = transferMTID_CALLERTX(ctx);

@@ -88,0 +88,0 @@ }

@@ -381,3 +381,3 @@ /**

/************************************/
if(conf.mtrace_enabled) {
if(conf.getProperty('mtrace_enabled', false)) {
var poid=req.headers['x-wtap-po'];

@@ -387,24 +387,22 @@ if (poid != null) {

try{
if(conf.mtid_mtrace_enabled) {
var mt_caller=req.headers[conf._trace_mtrace_caller_key];
if(mt_caller){
var x = mt_caller.indexOf(',');
if (x > 0) {
ctx.mtid = Hexa32.toLong32(mt_caller.substring(0, x));
ctx.mtid_build_checked = true;
var y = mt_caller.indexOf(',', x + 1);
if (y > 0) {
ctx.mdepth = parseInt(mt_caller.substring(x + 1, y));
var z = mt_caller.indexOf(',', y + 1);
if (z < 0) {
ctx.mcaller_txid = Hexa32.toLong32(mt_caller.substring(y + 1));
var mt_caller=req.headers[conf._trace_mtrace_caller_key];
if(mt_caller){
var x = mt_caller.indexOf(',');
if (x > 0) {
ctx.mtid = Hexa32.toLong32(mt_caller.substring(0, x));
ctx.mtid_build_checked = true;
var y = mt_caller.indexOf(',', x + 1);
if (y > 0) {
ctx.mdepth = parseInt(mt_caller.substring(x + 1, y));
var z = mt_caller.indexOf(',', y + 1);
if (z < 0) {
ctx.mcaller_txid = Hexa32.toLong32(mt_caller.substring(y + 1));
} else {
ctx.mcaller_txid = Hexa32.toLong32(mt_caller.substring(y + 1, z));
var z2 = mt_caller.indexOf(',', z + 1);
if (z2 < 0) {
ctx.mcaller_stepId = Hexa32.toLong32(mt_caller.substring(z + 1));
} else {
ctx.mcaller_txid = Hexa32.toLong32(mt_caller.substring(y + 1, z));
var z2 = mt_caller.indexOf(',', z + 1);
if (z2 < 0) {
ctx.mcaller_stepId = Hexa32.toLong32(mt_caller.substring(z + 1));
} else {
ctx.mcaller_stepId = Hexa32.toLong32(mt_caller.substring(z + 1, z2));
}
ctx.mcaller_stepId = Hexa32.toLong32(mt_caller.substring(z + 1, z2));
}

@@ -707,3 +705,3 @@ }

}
if(conf.mtid_mtrace_enabled && ctx.mtid.isZero()===false){
if(ctx.mtid.isZero()===false){
options.headers[conf._trace_mtrace_caller_key]=transferMTID_CALLERTX(ctx);

@@ -763,10 +761,23 @@ }

var req = original.apply(this, [options, wrappedCallback]);
var httpc_url = options.path
req.on('error', function (err) {
if (TraceContextManager.resume(ctx._id) === null) { return; }
ctx.is_httpc_error = true;
const isIgnoreHttpc = shouldIgnoreError(
err.code,
httpc_url,
httpc_status_ignore,
httpc_status_ignore_set);
if (transaction_status_error_enable && step.error.isZero()) {
step.error = StatError.addError(err.code, err.message, ctx.service_hash,
TextTypes.HTTPC_URL, step.url);
if (!isIgnoreHttpc && transaction_status_error_enable && step.error.isZero()) {
ctx.is_httpc_error = true;
step.error = StatError.addError(
err.code,
err.message,
ctx.service_hash,
TextTypes.HTTPC_URL,
step.url
);
if (ctx.error.isZero()) {

@@ -833,3 +844,3 @@ ctx.error = step.error;

if (statusCodeIgnore) {
var ignoreCodes = statusCodeIgnore.split(',');
const ignoreCodes = statusCodeIgnore.split(',').map(code => code.trim());
if (ignoreCodes.includes(String(statusCode))) {

@@ -841,5 +852,5 @@ return true;

if (statusIgnoreSet) {
var ignoreSet = statusIgnoreSet.split(',');
var setValue = url + ":" + statusCode;
if (ignoreSet.includes(setValue)) {
const ignoreSet = statusIgnoreSet.split(',').map(item => item.trim());
const urlStatusCombo = `${url}:${statusCode}`;
if (ignoreSet.includes(urlStatusCombo)) {
return true;

@@ -875,5 +886,3 @@ }

if (not_found_ignore) return false;
var is_ignore = ctx.is_httpc_error ?
shouldIgnoreError(res.statusCode, requestPath, httpc_status_ignore, httpc_status_ignore_set) :
shouldIgnoreError(res.statusCode, requestPath, status_ignore, status_ignore_set);
const is_ignore = shouldIgnoreError(res.statusCode, requestPath, status_ignore, status_ignore_set);
return !is_ignore;

@@ -880,0 +889,0 @@ }

@@ -208,2 +208,5 @@ /**

ctx.profile.push(result_step);
ctx.rs_count = ctx.rs_count ? ctx.rs_count + res.length : res.length;
MeterSql.addFetch(result_step.dbc, result_step.fetch, 0);

@@ -210,0 +213,0 @@ StatSql.addFetch(result_step.dbc, result_step.sqlhash, result_step.fetch, 0);

@@ -133,5 +133,7 @@ /**

result_step.fetch = args[1][0].length;
ctx.rs_count = ctx.rs_count ? ctx.rs_count + args[1][0].length : args[1][0].length;
} catch(e) {
}
ctx.profile.push(result_step);
MeterSql.addFetch(dbc_hash, result_step.fetch, 0);

@@ -138,0 +140,0 @@ StatSql.addFetch(dbc_hash, result_step.sqlhash, result_step.fetch, 0);

@@ -186,2 +186,7 @@ /**

ctx.profile.push(result_step);
ctx.rs_count = ctx.rs_count ? ctx.rs_count + args[1].length : args[1].length;
ctx.rs_time = ctx.rs_time ? ctx.rs_time + sql_step.elapsed : sql_step.elapsed;
// ctx.rs_time = ctx.rs_time ? ctx.rs_time + (result_step.start_time - ctx.getElapsedTime()) : result_step.start_time - ctx.getElapsedTime();
MeterSql.addFetch(result_step.dbc, result_step.fetch, 0);

@@ -188,0 +193,0 @@ StatSql.addFetch(result_step.dbc, result_step.sqlhash, result_step.fetch, 0);

@@ -187,2 +187,5 @@ /**

ctx.profile.push(result_step);
ctx.rs_count = ctx.rs_count ? ctx.rs_count + res.rowCount : res.rowCount;
MeterSql.addFetch(result_step.dbc, result_step.fetch, 0);

@@ -189,0 +192,0 @@ StatSql.addFetch(result_step.dbc, result_step.sqlhash, result_step.fetch, 0);

@@ -82,8 +82,8 @@ /**

var now = Date.now();
if (!socket_count.start_time) {
// if ((now - socket_count.start_time) > 1000) {
// socket_count.start_time = now;
// socket_count.count = 0;
// }
if (!socket_count.start_time || (now - socket_count.start_time) >= 1000) {
socket_count.start_time = now;
}
if ((now - socket_count.start_time) > 5000) {
socket_count.start_time = now;
socket_count.count = 0;

@@ -94,3 +94,3 @@ }

if (socket_count.count > trace_sampling_tps) {
MeterService.add(0, 1, 0, 0, 0, 0);
MeterService.add(0, 1, 0, SecurityMaster.PCODE, SecurityMaster.OKIND, SecurityMaster.OID);
return;

@@ -151,4 +151,3 @@ }

MeterService.add(wtx.service, wtx.elapsed,
wtx.errorLevel, ctx.mcaller_pcode, ctx.mcaller_okind, ctx.mcaller_oid);
MeterService.add(0, wtx.elapsed, 0, SecurityMaster.PCODE, SecurityMaster.OKIND, SecurityMaster.OID);

@@ -158,4 +157,2 @@ profile.oid = SecurityMaster.OID;

TraceContextManager.end(ctx._id);
setTimeout(function () {

@@ -162,0 +159,0 @@ DataProfileAgent.sendProfile(ctx, profile, false);

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

var Pack = require('./pack'),
PackEnum = require('./packenum');
PackEnum = require('./packenum'),
Logger = require('../logger');

@@ -55,15 +56,19 @@ function HitMapPack1() {

function writeArr( dout, arr) {
if(arr==null){
dout.writeByte(0);
}else{
var len = HitMapPack1.LENGTH - 1;
for (; len >= 0; len--) {
if (arr[len] != 0)
break;
try{
if (arr == null) {
dout.writeByte(0);
} else {
var len = HitMapPack1.LENGTH - 1;
for (; len >= 0; len--) {
if (arr[len] != 0)
break;
}
len = len + 1;
dout.writeByte(len);
for (var i = 0; i < len; i++) {
dout.writeUInt16BE(arr[i]);
}
}
len = len + 1;
dout.writeByte(len);
for (var i = 0; i < len; i++) {
dout.writeShort(arr[i]);
}
}catch (e) {
Logger.printError('WHATAP-088', 'Hit-map pack - write error', e, false);
}

@@ -70,0 +75,0 @@ }

{
"name": "whatap",
"homepage": "http://www.whatap.io",
"version": "0.5.4",
"releaseDate": "20241113",
"version": "0.5.5",
"releaseDate": "20250123",
"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