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

opa-compile-response-parser

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opa-compile-response-parser

An Open Policy Agent Compile Response Parser

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

opa-compile-response-parser

GitHub stars npm version unpkg npm bundle size (minified + gzip) Build Status

An Open Policy Agent Compile Response Parser

Open Policy Agent provides a compile API that allows you partially evaluate your policy.

This library can parse the compile JSON response and allow you to access the Rego AST (Abstract Syntax Tree) in the response body by Rego language structure.

Moreover, it further processes the AST to:

  • eliminate tautological rules
    • e.g. r { x; false } => false
  • replace rule reference with inline value
    • e.g. r1 { r2 } r2 { true } => r1 { true } => true

API document

https://t83714.github.io/opa-compile-response-parser/

Examples

import OpaCompileResponseParser from "opa-compile-response-parser";

const parser = new OpaCompileResponseParser();
parser.parse(jsonResponse);

const result = parser.evaluate();
/**
 returned evaluate result:
    interface CompleteRuleResult {
        fullName: string;
        name: string;
        value: RegoValue;
        isCompleteEvaluated: boolean;
        residualRules?: RegoRule[];
    }
*/

// --- Print residual rules as human readable string
console.log(parser.evaluateAsHumanReadableString());
More Examples

Todo

  • replace rule reference with inline rules

Compatibility

Tested with Open Policy Agent version 0.37.2

Keywords

FAQs

Package last updated on 18 Sep 2022

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

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