
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
@umbrelladocs/rdformat-validator
Advanced tools
Validate and fix Reviewdog Diagnostic Format (RD Format) - A comprehensive library and CLI tool for validating JSON data against the Reviewdog Diagnostic Format specification
A NodeJS library and CLI tool for validating JSON data against the Reviewdog Diagnostic Format specification.
npm install @umbrelladocs/rdformat-validator
# Install globally
npm install -g @umbrelladocs/rdformat-validator
# Or use with npx
npx @umbrelladocs/rdformat-validator --help
import { validate, validateAndFix, RDFormatValidator } from 'rdformat-validator';
```typescript
import { validate, validateAndFix, RDFormatValidator } from '@umbrelladocs/rdformat-validator';
// Quick validation
const result = await validate('{"diagnostics": []}');
console.log(result.valid); // true
// Validation with automatic fixing
const fixResult = await validateAndFix(invalidData, { fixLevel: 'basic' });
if (fixResult.fixedData) {
console.log('Fixed data:', fixResult.fixedData);
}
// Using the main validator class
const validator = new RDFormatValidator({
strictMode: true,
allowExtraFields: false
});
const result = await validator.validateFile('./diagnostics.json');
# Validate a single file
rdformat-validator diagnostics.json
# Validate multiple files
rdformat-validator file1.json file2.json
# Validate from stdin
cat diagnostics.json | rdformat-validator
# Validate and fix issues
rdformat-validator --fix diagnostics.json
# Output in JSON format
rdformat-validator --format json diagnostics.json
# Strict validation mode
rdformat-validator --strict --no-extra-fields diagnostics.json
The Reviewdog Diagnostic Format (RDFormat) is a standardized JSON format for representing code analysis results. It supports two main structures:
An array of individual diagnostic objects:
[
{
"message": "Line too long",
"location": {
"path": "src/main.js",
"range": {
"start": { "line": 10, "column": 1 },
"end": { "line": 10, "column": 120 }
}
},
"severity": "WARNING",
"source": {
"name": "eslint",
"url": "https://eslint.org"
}
}
]
A structured result object containing diagnostics and metadata:
{
"diagnostics": [
{
"message": "Missing semicolon",
"location": {
"path": "src/app.js",
"range": {
"start": { "line": 15, "column": 25 }
}
},
"severity": "ERROR",
"source": {
"name": "jshint"
}
}
],
"source": {
"name": "multi-linter",
"url": "https://example.com/multi-linter"
},
"severity": "ERROR"
}
RDFormatValidator
The primary validator class providing comprehensive validation functionality.
const validator = new RDFormatValidator({
strictMode: false, // Enable strict validation
allowExtraFields: true, // Allow extra fields not in spec
fixLevel: 'basic' // Fix level: 'basic' or 'aggressive'
});
Methods:
validateString(input: string, fix?: boolean)
- Validate JSON stringvalidateFile(filePath: string, fix?: boolean)
- Validate JSON filevalidateObject(data: any, fix?: boolean)
- Validate JavaScript objectgetSchema()
- Get the JSON schema used for validationsetOptions(options)
- Update validator optionsvalidate(input, options?)
Simple validation without fixing:
const result = await validate('{"diagnostics": []}');
console.log(result.valid); // boolean
console.log(result.errors); // ValidationError[]
console.log(result.warnings); // ValidationWarning[]
validateAndFix(input, options?)
Validation with automatic fixing:
const result = await validateAndFix(invalidData, { fixLevel: 'aggressive' });
if (result.fixedData) {
console.log('Data was fixed:', result.fixedData);
console.log('Applied fixes:', result.appliedFixes);
}
isValidRDFormat(input, options?)
Quick validation check:
const isValid = await isValidRDFormat(data);
console.log(isValid); // boolean
validateBatch(inputs, options?)
Validate multiple inputs simultaneously:
const results = await validateBatch([
'{"diagnostics": []}',
{ diagnostics: [] },
invalidData
]);
results.forEach((result, index) => {
console.log(`Input ${index}: ${result.valid ? 'valid' : 'invalid'}`);
});
validateAndFixBatch(inputs, options?)
Batch validation with fixing:
const results = await validateAndFixBatch(inputs, { fixLevel: 'basic' });
createValidationSummary(results)
Create a summary of validation results:
const summary = createValidationSummary(results);
console.log(`Valid: ${summary.validCount}/${summary.totalCount}`);
console.log(`Total errors: ${summary.totalErrors}`);
formatValidationErrors(errors, options?)
Format errors for display:
const formattedErrors = formatValidationErrors(result.errors, {
includeCode: true,
includeExpected: true
});
formattedErrors.forEach(error => console.log(error));
rdformat-validator [options] [files...]
Option | Description | Default |
---|---|---|
-f, --fix | Attempt to automatically fix common issues | false |
-o, --output <file> | Output file (default: stdout) | - |
-v, --verbose | Enable verbose output | false |
-s, --silent | Suppress non-error output | false |
--format <format> | Output format: json or text | text |
--strict | Enable strict validation mode | false |
--no-extra-fields | Disallow extra fields not in specification | false |
--fix-level <level> | Fix level: basic or aggressive | basic |
# Validate a single file
rdformat-validator diagnostics.json
# Validate multiple files
rdformat-validator file1.json file2.json file3.json
# Validate from stdin
cat diagnostics.json | rdformat-validator
echo '{"diagnostics": []}' | rdformat-validator
# Fix common issues
rdformat-validator --fix diagnostics.json
# Aggressive fixing
rdformat-validator --fix --fix-level aggressive diagnostics.json
# Save fixed output to file
rdformat-validator --fix --output fixed.json diagnostics.json
# JSON output format
rdformat-validator --format json diagnostics.json
# Verbose text output
rdformat-validator --verbose diagnostics.json
# Silent mode (only errors)
rdformat-validator --silent diagnostics.json
# Strict mode with no extra fields
rdformat-validator --strict --no-extra-fields diagnostics.json
# Combine with other options
rdformat-validator --strict --verbose --format json diagnostics.json
0
- Success (all files are valid)1
- Validation errors found or other errors occurredinterface RDFormatValidatorOptions {
strictMode?: boolean; // Enable strict validation (default: false)
allowExtraFields?: boolean; // Allow extra fields (default: true)
fixLevel?: 'basic' | 'aggressive'; // Fix level (default: 'basic')
}
basic
- Safe fixes that don't change data semantics
aggressive
- More extensive fixes that may change data
interface ValidationError {
path: string; // JSON path to error location
message: string; // Human-readable error message
code: string; // Error code for programmatic handling
value?: any; // The value that caused the error
expected?: string; // Description of expected value/format
}
REQUIRED_PROPERTY
- Missing required fieldINVALID_TYPE
- Wrong data typeINVALID_FORMAT
- Invalid format (e.g., invalid enum value)PARSE_ERROR
- JSON parsing errorUNEXPECTED_ERROR
- Unexpected system errorconst result = await validate(invalidData);
if (!result.valid) {
result.errors.forEach(error => {
console.log(`${error.path}: ${error.message} (${error.code})`);
});
}
Full TypeScript definitions are included:
import {
RDFormatValidator,
RDFormatValidatorOptions,
RDFormatValidatorResult,
ValidationError,
ValidationWarning,
Diagnostic,
DiagnosticResult,
Location,
Range,
Position,
Severity,
Source,
Code,
Suggestion
} from 'rdformat-validator';
#!/bin/bash
# Validate diagnostic output in CI
if ! rdformat-validator --silent diagnostics.json; then
echo "Invalid RDFormat data detected"
exit 1
fi
const { validateFile } = require('rdformat-validator');
async function validateDiagnostics() {
try {
const result = await validateFile('./output/diagnostics.json');
if (!result.valid) {
console.error('Validation failed:', result.errors);
process.exit(1);
}
console.log('Diagnostics are valid!');
} catch (error) {
console.error('Error:', error.message);
process.exit(1);
}
}
validateDiagnostics();
const { validate } = require('rdformat-validator');
function validateRDFormat(req, res, next) {
validate(req.body)
.then(result => {
if (!result.valid) {
return res.status(400).json({
error: 'Invalid RDFormat data',
details: result.errors
});
}
next();
})
.catch(next);
}
app.post('/diagnostics', validateRDFormat, (req, res) => {
// Handle valid RDFormat data
res.json({ status: 'success' });
});
MIT
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.
FAQs
Validate and fix Reviewdog Diagnostic Format (RD Format) - A comprehensive library and CLI tool for validating JSON data against the Reviewdog Diagnostic Format specification
We found that @umbrelladocs/rdformat-validator demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.