Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spm-agent

Package Overview
Dependencies
Maintainers
3
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spm-agent - npm Package Compare versions

Comparing version 1.31.10 to 1.31.11

51

lib/util/spmconfig.js

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

var flatten = require('flat')
var unflatten = require('flat').unflatten
var util = require('util')
var RC = require('rc-yaml-2')
var fs = require('fs')
// load SPM receivers from file containing
// env vars e.g. SPM_RECEIVER_URL, EVENTS_RECEIVER_URL, LOGSENE_RECEIVER_URL
// the file overwrites the actual environment
// and is used by Sematext Enterprise or multi-region setups to
// setup receiver URLs
function loadEnvFromFile (fileName) {
try {
var receivers = fs.readFileSync(fileName).toString()
if (receivers) {
var lines = receivers.split('\n')
}
// console.log(new Date(), 'loading Sematext receiver URLs from ' + fileName)
lines.forEach(function (line) {
var kv = line.split('=')
if (kv.length === 2 && kv[1].length > 0) {
process.env[kv[0].trim()] = kv[1].trim()
// console.log(kv[0].trim() + ' = ' + kv[1].trim())
}
})
} catch (error) {
// ignore missing file or wrong format
// console.error(error.message)
}
}
var envFileName = '/etc/sematext/receivers.config'
/**
if (/win/.test(os.platform()) {
envFileName = process.env.ProgramData + '\\Sematext\\receivers.config'
}
**/
loadEnvFromFile(envFileName)
var spmDefaultConfig = {

@@ -48,6 +83,18 @@ tokens: {

SpmConfig.prototype.get = function (key) {
return this.rcFlat[key]
SpmConfig.prototype.get = function (flatKey) {
return this.rcFlat[flatKey]
}
SpmConfig.prototype.set = function (flatKey, value) {
var kv = {}
kv[flatKey] = value
kv.object = true
var result = unflatten(kv)
delete result.object
delete this.rcFlat
util._extend(this, result)
this.rcFlat = flatten(this)
return this
}
module.exports = new SpmConfig(process.env.SPM_AGENT_APP_TYPE || 'spmagent')

2

package.json
{
"name": "spm-agent",
"version": "1.31.10",
"version": "1.31.11",
"description": "Node.js agent framework for SPM by Sematext",

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

@@ -76,2 +76,14 @@ /*

})
it('SPM Config "set" accepts flat key', function (done) {
try {
config.set('a.b.0.name', 'test')
if (config.a.b[0].name === 'test') {
done()
} else {
done(new Error('set flat key: a.b.0.name != test'))
}
} catch (err) {
done(err)
}
})
})
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