Socket
Socket
Sign inDemoInstall

rabbit-validator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rabbit-validator - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

src/Failure.js

36

cli.js

@@ -5,17 +5,23 @@ #!/usr/bin/env node

import { strict as assert } from 'assert';
import {
validateFromFile,
} from './validate.js';
import validate from './src/validate.js';
const [,,filePath] = process.argv;
const [,, filePath, usageFilePath] = process.argv;
if (!filePath) {
console.error('usage: rabbit-validator <path/definitions.json> [<path/usage.json>]');
console.error(' usage.json is a fail containing array of objects { vhost, exchange, queue } | { vhost, queue } of used RabbitMQ resources.');
process.exit(1);
}
const fullFilePath = path.resolve(filePath);
const fullUsageFilePath = usageFilePath && path.resolve(usageFilePath);
const logError = (error) => {
assert.equal(typeof error.failures, 'function');
const failures = error.failures();
assert.equal(Array.isArray(failures), true);
const logFailures = (failures) => {
assert.equal(Array.isArray(failures), true, `Invalid list of failures: ${failures}`);
console.error(
failures.map((failure) => {
return `At ${failure.path.join('.')}: ${failure.message}`;
if (failure.path) {
return `At ${failure.path.join('.')}: ${failure.message}`;
}
return failure.message;
}).join('\n'),

@@ -25,8 +31,8 @@ );

console.debug(`Validating a definitions file at ${fullFilePath}`);
console.debug(`Validating a definitions file at ${fullFilePath}${fullUsageFilePath ? ' with usage stats from ' + fullUsageFilePath : ''}`);
// [err, validatedObject]
const [err] = validateFromFile(fullFilePath);
if (err) {
logError(err);
// Failure[]
const failures = validate(fullFilePath, fullUsageFilePath);
if (failures.length) {
logFailures(failures);
process.exit(1);

@@ -33,0 +39,0 @@ } else {

{
"name": "rabbit-validator",
"version": "1.0.0",
"version": "1.1.0",
"type": "module",
"description": "Validator for the definition files of RabbitMQ",
"main": "validate.js",
"main": "src/validate.js",
"bin": "cli.js",
"scripts": {
"lint": "eslint .",
"test": "tap ./test.js"
"test": "tap ./test/*.js"
},
"keywords": ["rabbit", "RabbitMQ", "amqp", "validation", "validator", "definitions.json", "definition", "configuration", "config"],
"keywords": [
"rabbit",
"RabbitMQ",
"amqp",
"validation",
"validator",
"definitions.json",
"definition",
"configuration",
"config"
],
"author": "Rauno Viskus",

@@ -22,5 +32,5 @@ "license": "MIT",

"devDependencies": {
"eslint": "^8.29.0",
"tap": "^16.3.2"
"eslint": "^8.36.0",
"tap": "^16.3.4"
}
}

@@ -6,4 +6,14 @@ # RabbitMQ definitions.json file validator

- validates the shape of the json,
- asserts all the names only to contain "normal" printable characters: `a-z0-9:_./\-*#`.
- asserts all the names only to contain ASCII printable characters: `a-z0-9:_./\-*#`,
- when second path argument is provided, also checks usage against a fixed list.
## `usage.json`
`usage.json` should contain json array of following objects:
- `{ vhost: string, queue: string }` if the entry represents interacting with queue directly or
- `{ vhost: string, exchange: string, queue: string }` if the entry represents interacting with queue through an exchange.
Such statistics can be fetch from Prometheus API for example.
## Usage

@@ -15,3 +25,3 @@

# Install from npm and run
npx rabbit-validator [path/to/definitions.json]
npx rabbit-validator <path/definitions.json> [<path/usage.json>]
```

@@ -24,5 +34,5 @@

npx rabbit-validator [path/to/definitions.json]
npx rabbit-validator <path/definitions.json> [<path/usage.json>]
# or to force npx offline:
npx --offline rabbit-validator [path/to/definitions.json]
npx --offline rabbit-validator <path/definitions.json> [<path/usage.json>]

@@ -38,3 +48,3 @@ # --offline is not required if previously installed, but errors if

rabbit-validator [path/to/definitions.json]
rabbit-validator <path/definitions.json> [<path/usage.json>]
```

@@ -45,5 +55,5 @@

```bash
git clone git@github.com:Rauno56/rabbit-validator.git
git clone git@github.com:rauno56/rabbit-validator.git
cd rabbit-validator
npx . [path/to/definitions.json]
npx . <path/definitions.json> [<path/usage.json>]
```

@@ -50,0 +60,0 @@

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