Socket
Socket
Sign inDemoInstall

@contrast/rewriter

Package Overview
Dependencies
Maintainers
16
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrast/rewriter

A transpilation tool mainly used for instrumentation


Version published
Weekly downloads
26K
decreased by-2.15%
Maintainers
16
Weekly downloads
 
Created
Source

@contrast/rewriter

Provides a configured service for rewriting code.

Basic idea: Enabled features can register rewrite transforms to support their end goal.

Example: Assess

Assess will register transforms for + -> contrast_add() so that it can perform propagation via instrumentation of contrast_add().

Example Service Usage
const { Rewriter } = require('.');

const rewriter = new Rewriter({ config, logger });

rewriter.addTransforms({
  BinaryExpression(path) {
    const method = methodLookups[path.node.operator];
    if (method) {
      path.replaceWith(
        t.callExpression(
          expression('ContrastMethods.%%method%%')({ method }), [
            path.node.left,
            path.node.right
          ]
        )
      );
    }
  }
});

const result = rewriter.rewriteFile({
  content: 'function add(x, y) { return x + y; }'
});

FAQs

Package last updated on 16 Jun 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