Skip to content

Commit

Permalink
Upgrade to sailor 2.6.19 (#3)
Browse files Browse the repository at this point in the history
* Upgrade to sailor 2.6.19
* Annual audit of the component code to check if it exposes a sensitive data in the logs
* Annual npm vulnerabilities audit
  • Loading branch information
denyshld authored Dec 4, 2020
1 parent 94eb294 commit a72dae0
Show file tree
Hide file tree
Showing 14 changed files with 2,394 additions and 1,153 deletions.
10 changes: 10 additions & 0 deletions .circleci/build_slug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
echo "Building slug"
id=$(git archive $CIRCLE_BRANCH | docker run -e "NPM_CONFIG_PRODUCTION=false" -i -a stdin elasticio/appbuilder)
docker attach $id
RC=$?
if [ $RC -eq 0 ];then
echo "Build ok."
else
echo "Build failed"
exit 1
fi
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2
jobs:
test:
docker:
- image: circleci/node:14-stretch
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Audit Dependencies
command: npm audit --audit-level=high
- run:
name: Installing Dependencies
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- node_modules
- run:
name: Running Mocha Tests
command: npm test
- run:
name: Running Integration Tests
command: npm run integration-test
workflows:
version: 2
build_and_test:
jobs:
- test
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
'extends': 'airbnb-base',
'env': {
'mocha': true
},
'rules' : {
'no-plusplus' : 'off',
},
};
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## 1.0.1 (December 4, 2020)

* Upgrade to sailor 2.6.19
* Annual audit of the component code to check if it exposes a sensitive data in the logs
* Annual npm vulnerabilities audit

## 1.0.0 (December 5, 2016)

* Initial release of component
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[![CircleCI](https://circleci.com/gh/elasticio/ldap-component.svg?style=svg)](https://circleci.com/gh/elasticio/ldap-component)
# ldap-component
[![Travis Build Status][travis-image]][travis-url]
[![DependencyStatus][daviddm-image]][daviddm-url]

LDAP component for the [elastic.io platform](http://www.elastic.io)

Expand Down
3 changes: 0 additions & 3 deletions changelog.md

This file was deleted.

9 changes: 7 additions & 2 deletions component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"title": "LDAP",
"description": "Lightweight Directory Access Protocol is an open, vendor-neutral, industry standard application protocol for accessing and maintaining distributed directory information services over an Internet Protocol (IP) network. Directory services play an important role in developing intranet and Internet applications by allowing the sharing of information about users, systems, networks, services, and applications throughout the network. See https://github.com/elasticio/ldap-component for more documenation.",
"docsUrl": "https://github.com/elasticio/ldap-component",
"buildType": "docker",
"credentials": {
"fields": {
"url": {
Expand All @@ -26,9 +28,12 @@
},
"actions": {
"search": {
"title": "Perform LDAP search action",
"title": "Search",
"main": "./lib/actions/search.js",
"description": "Performs an LDAP search",
"help" : {
"description": "Performs an LDAP search",
"link": "/components/ldap/index.html#search"
},
"fields": {},
"metadata": {
"in": {
Expand Down
21 changes: 11 additions & 10 deletions lib/actions/search.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
'use strict';

const {messages} = require('elasticio-node');
const {createClient} = require('../baseClient');
const { messages } = require('elasticio-node');
const { createClient } = require('../baseClient');

exports.process = async function (msg, cfg) {
const client = await createClient(cfg);
const client = await createClient.call(this, cfg);

const searchOpts = {
scope: msg.body.scope,
filter: msg.body.filter
filter: msg.body.filter,
};
const searchResults = await client.search(msg.body.base, searchOpts);
searchResults.entries.forEach(entry => {
this.emit('data', messages.newMessageWithBody(entry.object));
});
const { entries } = searchResults;

for (let i = 0; i < entries.length; i++) {
// eslint-disable-next-line no-await-in-loop
await this.emit('data', messages.newMessageWithBody(entries[i].object));
}

await client.unbind();
client.unbind();
};
8 changes: 3 additions & 5 deletions lib/baseClient.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
'use strict';

const LdapClient = require('promised-ldap');

module.exports.createClient = async function (cfg) {
const client = new LdapClient({
url: cfg.url
url: cfg.url,
});

console.log(`Attempting to bind to ${cfg.url} ...`);
this.logger.info('Attempting to bind to provided url');
try {
await client.bind(cfg.user, cfg.password);
} catch (e) {
// Bind failures don't kill the connection.
await client.unbind();
client.unbind();
throw e;
}
return client;
Expand Down
Loading

0 comments on commit a72dae0

Please sign in to comment.