New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aspecto/privacy-rules

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aspecto/privacy-rules

Aspecto Privacy Rules Engine

  • 0.0.9
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

Aspecto Privacy Rules

Privacy rules allow to specify which requests or fields need to be blocked or scrambled. Rules are described in a JSON with a certain structure and can be executed by PrivacyEngine.

Example


// specify some rules
const blockRule: PrivacyRuleDef = {
    conditions: [{ conditionType: 'always' }],
    actions: [{ actionType: 'block-request' }],
};

const scrambleFieldRule: PrivacyRuleDef = {
    conditions: [{ conditionType: 'route', conditionData: { filterType: 'by-value', filterValue: '/users/' } }],
    actions: [
        {
            actionType: 'scramble-field',
            actionData: {
                fieldTypes: ['header', 'body-json', 'query-param'],
                filter: { filterType: 'by-key', filterValue: 'Authentication' },
            },
        },
        {
            actionType: 'scramble-field',
            actionData: {
                fieldTypes: ['header', 'body-json', 'query-param'],
                filter: { filterType: 'by-key', filterValue: 'Bearer' },
            },
        },
    ],
};

const blockFieldRule: PrivacyRuleDef = {
    conditions: [{ conditionType: 'service', conditionData: { filterType: 'by-value', filterValue: 'user-service' } }],
    actions: [
        {
            actionType: 'block-field',
            actionData: {
                fieldTypes: ['header', 'body-json', 'query-param'],
                filter: { filterType: 'by-key', filterValue: 'Authentication' },
            },
        },
        {
            actionType: 'block-field',
            actionData: {
                fieldTypes: ['header', 'body-json', 'query-param'],
                filter: { filterType: 'by-key', filterValue: 'Bearer' },
            },
        },
    ],
};

// example message (http request-response)
export const sampleMessage: AspectoMessage = {
    packageName: 'user-service',
    HTTP_REQUEST: {
        route: { path: '/users/' },
        body: { user: 'daniel', password: 'craig' },
        query: {
            auth: 'token',
            param1: 'notprivate',
        },
        requestHeaders: {
            Bearer: 'req-token',
        },
        responseHeaders: {
            Authentication: 'resp-token',
        },
    },
};

// create an instance of the engine, set rules and execute them
const privacyEngine = new PrivacyEngine();
const rules: any[] = [blockRule, blockFieldRule, scrambleFieldRule];
privacyEngine.setRules(rules);
// this will mutate the message, blocking or scrambling certain fields
const result = privacyEngine.executeRules(sampleMessage);

FAQs

Package last updated on 13 Jan 2020

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