Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # ldap-escape
  2. Template literal tag functions for LDAP filters and distinguished names to prevent [LDAP injection](https://www.owasp.org/index.php/LDAP_injection) attacks.
  3. Uses the escape codes from [Active Directory: Characters to Escape](http://social.technet.microsoft.com/wiki/contents/articles/5312.active-directory-characters-to-escape.aspx).
  4. ## Installation
  5. npm install --save ldap-escape
  6. ## Specification
  7. ### escapes for search filter
  8. | Character | Escape |
  9. |-----------|--------|
  10. | `*` | `\2A` |
  11. | `(` | `\28` |
  12. | `)` | `\29` |
  13. | `\` | `\5C` |
  14. | `NUL` | `\00` |
  15. ### escapes for distinguished names
  16. | Character | Escape |
  17. |-----------------------------|--------|
  18. | `,` | `\,` |
  19. | `\` | `\\` |
  20. | `#` | `\#` |
  21. | `+` | `\+` |
  22. | `<` | `\<` |
  23. | `>` | `\>` |
  24. | `;` | `\;` |
  25. | `"` | `\"` |
  26. | `=` | `\=` |
  27. | `SPC` (leading or trailing) | `\ ` |
  28. ## Template Literal Tag Functions
  29. ### ldapEscape.filter
  30. Escapes input for use as an LDAP filter.
  31. ### ldapEscape.dn
  32. Escapes input for use as an LDAP distinguished name.
  33. ## Examples
  34. ### Escape a Search Filter
  35. "use strict";
  36. const ldapEscape = require('ldap-escape');
  37. const uid = 1337;
  38. console.log(ldapEscape.filter`uid=${uid}`); // -> '(uid=1337)'
  39. ### Escape a DN
  40. "use strict";
  41. const ldapEscape = require('ldap-escape');
  42. const cn = 'alice';
  43. console.log(ldapEscape.dn`cn=${cn},dc=test`); // -> 'cn=alice,dc=test'
  44. ## Testing
  45. npm test
  46. ## License
  47. See [LICENSE.md](https://github.com/tcort/ldap-escape/blob/master/LICENSE.md)