New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

mosquitto-acl-parser

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mosquitto-acl-parser

Parse and Stringify Mosquitto ACLs

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

mosquitto-acl-parser

NPM version Dependency Status Build Status Coverage Status XO code style License

Parse and Stringify Mosquitto ACLs

This tiny module parses Mosquitto ACLs into a Javascript object and stringifies objects back into a ACL string.

Usage

npm install mosquitto-acl-parser

.parse(string)

const macl = require('mosquitto-acl-parser');

const acl = macl.parse(`# This affects access control for clients with no username.
topic read $SYS/#

# This only affects clients with username "roger".
user roger
topic foo/bar

# This affects all clients.
pattern write $SYS/broker/connection/%c/state`);

acl contains then...

{
  "topics": [
    {
      "perm": "read",
      "topic": "$SYS/#"
    }
  ],
  "users": {
    "roger": [
      {
        "perm": "readwrite",
        "topic": "foo/bar"
      }
    ]
  },
  "patterns": [
    {
      "perm": "write",
      "topic": "$SYS/broker/connection/%c/state"
    }
  ]
}

.stringify(acl)

const macl = require('mosquitto-acl-parser');

console.log(macl.stringify({
    topics: [
        {
            perm: 'read',
            topic: 'everyone/can/read  '
        },
        {
            perm: 'readwrite',
            topic: 'everyone/can/readwrite'
        }
    ],
    users: {
        user1: [
            {
                perm: 'read',
                topic: 'user1/can/read'
            },
            {
                perm: 'readwrite',
                topic: 'user1/can/readwrite'
            }
        ],
        user2: [
            {
                perm: 'read',
                topic: 'user2/can/read'
            },
            {
                perm: 'readwrite',
                topic: 'user2/can/readwrite'
            }
        ]
    },
    patterns: [
        {
            perm: 'read',
            topic: 'pattern/%u/can/read'
        },
        {
            perm: 'readwrite',
            topic: 'pattern/%u/can/readwrite'
        }
    ]
}));

Outputs...

# created by mosquitto-acl-parser

topic read everyone/can/read  
topic readwrite everyone/can/readwrite

user user1
topic read user1/can/read
topic readwrite user1/can/readwrite

user user2
topic read user2/can/read
topic readwrite user2/can/readwrite

pattern read pattern/%u/can/read
pattern readwrite pattern/%u/can/readwrite

License

MIT (c) 2017 Sebastian Raff

Keywords

mosquitto

FAQs

Package last updated on 12 May 2017

Did you know?

Socket

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.

Install

Related posts