Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Dustul is a Dust-based an alternative to consul-template. It allows you
to subscribe to changes within Consul and render templates (using Dust template syntax) to disk as they occur. After rendering occurs, one or more commands can also be executed (e.g. service nginx restart
, etc...).
Dustul is a command-line utility. As such, it should be installed globally via npm i -g dustul
. Afterwards, getting started is a simple matter of creating a configuration file, as shown below.
Take note:
// config.js
module.exports = [
{
'config': {
/**
* Consul options
*/
'consul': {
'host': '192.168.50.2',
'port': 8500
}
},
/**
* The context object to be passed to Dust as Consul changes occur.
* Here you can define context helpers, pre-defined data, etc...
*/
'context': {
},
/**
* Consul subscriptions are defined here. As changes occur, incoming data is processed
* and assigned to the context object using the associated key. For example, our cities
* subscription will be processed and stored at context.cities.
*/
'watch': {
/**
* Subscribe to changes within Consul's key / value store.
*/
'cities': {
'method': 'kv.get',
'options': {
'key': 'config/env-app/cities',
'recurse': false
},
/**
* Optional callback. Allows you to manipulate incoming data before it is stored
* within the context object.
*/
'cb': (data) => {
return JSON.parse(data.Value);
}
},
/**
* Subscribe to a list of available Consul nodes.
*/
'nodes': {
'method': 'catalog.node.list'
},
/**
* Subscribe to a list of available Consul services.
*/
'services': {
'method': 'catalog.service.list'
},
/**
* Subscribe to a list of available Consul nodes for a specific service.
*/
'consul_nodes': {
'method': 'catalog.service.nodes',
'options': {
'service': 'consul'
}
}
},
/**
* This function is called just before Dust rendering occurs. Here you
* can make final modifications to your context object.
*/
'beforeRender': (consul, context) => {
context.date = new Date();
},
/**
* Whether or not to trim whitespace from the beginning and end of the rendered template
* before saving to disk. Default: false
*/
'trim': true,
/**
* An array of commands (and corresponding arguments) to be executed after rendering
* has completed. Values for command, args, and options are passed to Node's process.spawn
* method. Commands are run in order as a sequence.
*/
'commands': [
{
'command': 'service',
'args': ['nginx', 'restart'],
'options': {}
}
],
/**
* The path at which the rendered template will be saved. Relative paths
* are considered relative to the location at which Dustul is executed. You'd be better
* off sticking with absolute paths.
*/
'destination': '/etc/nginx/sites-enabled/my-site.conf',
/**
* The Dust template
*/
'template': `
upstream my_upstream {
{#consul_nodes}
server {Address};
{/consul_nodes}
}
server {
listen 80;
location / {
proxy_pass http://my_upstream;
}
}
`
}
];
Next, call Dustul and provide it with the path to your configuration file, as shown below.
$ dustul subscribe -c ./config.js
At the moment, Dustul only allows you to subscribe to changes within Consul's key value store. Short-term plans including adding support for subscribing to service and node changes, as well.
FAQs
CLI utility for rendering Dust templates as Consul values change
The npm package dustul receives a total of 0 weekly downloads. As such, dustul popularity was classified as not popular.
We found that dustul 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.