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

ldap-escape

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldap-escape

Escape functions for LDAP filters and distinguished names to prevent LDAP injection attacks.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.1K
decreased by-2.14%
Maintainers
1
Weekly downloads
 
Created
Source

ldap-escape

Escape functions for LDAP filters and distinguished names to prevent LDAP injection attacks. Uses the escape codes from Active Directory: Characters to Escape.

Installation

npm install --save ldap-escape

Specification

escapes for search filter

CharacterEscape
*\2A
(\28
)\29
\\5C
NUL\00

escapes for distinguished names

CharacterEscape
,\,
\\\
#\#
+\+
<\<
>\>
;\;
"\"
=\=
SPC (leading or trailing)\

API

ldapEscape.filter(format, unsafe)

Parameters:

  • format string with ${propertyName} placeholder(s) where propertyName is the name of a property of unsafe
  • unsafe an object containing values to escape and substitute in the format string.

Returns:

  • safe string (when unsafe is supplied).
  • function (when unsafe is not supplied).

ldapEscape.dn(format, unsafe)

Parameters:

  • format string with ${propertyName} placeholder(s) where propertyName is the name of a property of unsafe
  • unsafe an object containing values to escape and substitute in the format string.

Returns:

  • safe string (when unsafe is supplied).
  • function (when unsafe is not supplied).

Example

"use strict";

var ldapEscape = require('ldap-escape');

var alice = {
    uid: 1337,
    cn: 'alice',
};

var bob = {
    uid: 42,
    cn: 'alice',
};

var safeFilter = ldapEscape.filter('(uid=${uid})', alice);
// -> (uid=1337)

var userEscape = ldapEscape.filter('(uid=${uid})');
safeFilter = userEscape(alice);
// -> (uid=1337)

safeFilter = userEscape(bob);
// -> (uid=42)

var safeDn = ldapEscape.dn('cn=${cn},dc=test', alice);
// -> cn=alice,dc=test

Testing

npm test

License

Copyright (c) 2015 Thomas Cort <linuxgeek@gmail.com>

Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Keywords

FAQs

Package last updated on 14 Nov 2015

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