Giter VIP home page Giter VIP logo

hubot-symphony's Introduction

hubot-symphony

Hubot adapter for Symphony hosted by the Symphony Program part of FINOS

Hubot is a chatops tool developed by GitHub, with this adapter you can get up and running with a programmable bot written in JavaScript/Coffescript in a few minutes. This project wraps a small number of the Symphony REST APIs required for two-way bot communication and user lookup together with offline test cases, the adapter is in use both by Symphony clients and by Symphony themselves.

In mid-2018 Symphony released their own JavaScript API together with a Yeoman generator which facilitates creating simple bots, unless you wish to make use of existing Hubot scripts it's recommended to use this instead. See the developer site here and symphony-api-client-node.

FINOS - Incubating

Build Status Coverage Status Code Climate Greenkeeper badge

semantic-release Commitizen friendly

NPM

Usage

You must pass the following environment variables to hubot

  • HUBOT_SYMPHONY_HOST set to the url of your pod without the https:// prefix
  • HUBOT_SYMPHONY_PUBLIC_KEY set to the location of your bot account .pem public key file
  • HUBOT_SYMPHONY_PRIVATE_KEY set to the location of your bot account .pem private key file
  • HUBOT_SYMPHONY_PASSPHRASE set to the passphrase associated with your bot account private key

There are also optional arguments which should be used if you are running on-premise

  • HUBOT_SYMPHONY_KM_HOST set to the url of your key manager without the https:// prefix
  • HUBOT_SYMPHONY_AGENT_HOST set to the url of your agent without the https:// prefix
  • HUBOT_SYMPHONY_SESSIONAUTH_HOST set to the url of your session auth without the https:// prefix

These arguments are passed through to the NodeJs request module as described here.

Non-standard messaging

If you want to send a rich message you can call send just pass messageML directly to the send method instead of plaintext. The various supported tags are documented here. If you want to send Structured Objects you can call send with an Object instead of a String (note the text must be valid messageML).

module.exports = (robot) ->
  robot.respond /pug me/i, (msg) ->
    msg.http("http://pugme.herokuapp.com/random")
      .get() (err, res, body) ->
        pug = JSON.parse(body).pug
        // send url as text
        msg.send pug
        // send url as link
        msg.send "<messageML><a href=\"#{pug}\"/></messageML>"
        // send url as a card
        msg.send "<messageML><card iconSrc=\"#{iconSrc}\" accent=\"tempo-bg-color--blue\"><header>PUG!</header><body><img src=\"#{pug}\"/><br/><a href=\"#{pug}\"/></body></card></messageML>"
        // send message with a structured object
        msg.send {
          text: myMessageML,
          data: myStructuredObjectJson
        }

If you want to send a direct message to a user in response to a webhook you can interact with the adapter via the robot variable:

module.exports = (robot) ->
  robot.router.post '/hubot/webhook', (req, res) ->
    email = req.params.email
    message = req.params.message
    robot.adapter.sendDirectMessageToEmail(email, message)
    res.send 'OK'

Diagnostics

A simple diagnostic script is included to help confirm that you have all the necessary pieces to get started. You can run this as follows:

git clone https://github.com/symphonyoss/hubot-symphony.git
cd hubot-symphony
npm install
npm run diagnostic -- --publicKey [key1.pem] --privateKey [key2.pem] --passphrase [changeit] --host [host.symphony.com]

If you are running on-premise you can add optional fifth / sixth / seventh arguments

git clone https://github.com/symphonyoss/hubot-symphony.git
cd hubot-symphony
npm install
npm run diagnostic -- --publicKey [key1.pem] --privateKey [key2.pem] --passphrase [changeit] --host [host.symphony.com] --kmhost [keymanager.host.com] --agenthost [agent.host.com] --sessionhost [session.host.com]

If the script runs as expected it will obtain and log both session and key manager tokens, look up and log some details of the bot account and then create a datafeed and poll. If you send a message using the Symphony client to the bot account you should see the details logged.

Whitesource reports

To check security and legal compliance, the build integrates with Whitesource to submit and validate the list of third-party packages used by the build.

Simply run the following commands from the root project folder.

export WHITESOURCE_API_KEY=<WhiteSource API Key>
npm install ; npm run whitesource

The <WhiteSource API Key> can be retrieved from the WhiteSource project dashboard.

If any issue is found, a file called ws-log-policy-violations.json will be generated in root project folder; if no issue is found, metrics will be sent to the WhiteSource project dashboard (available to project committers).

Contribute

Contributions are accepted via GitHub pull requests. All contributors must be covered by contributor license agreements to comply with the Code Contribution Process.

  1. Fork it (https://github.com/symphonyoss/hubot-symphony/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Read our contribution guidelines and Community Code of Conduct
  4. Commit your changes (git commit -am 'Add some fooBar')
  5. Push to the branch (git push origin feature/fooBar)
  6. Create a new Pull Request

License

The code in this repository is distributed under the Apache License, Version 2.0.

Copyright 2016-2019 Jon Freedman

Note

The privateKey.pem and publicKey.pem files under test/resources have been generated at random and are not real keys.

hubot-symphony's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hubot-symphony's Issues

hubot-symphony community activity

As part of the FINOS project lifecycle work happening with the Symphony PMC, this project has been given an INCUBATING status.

So an informed decision is made by the Symphony PMC whether to ACTIVATE this project, can active contributors to this repository register themselves with a ๐Ÿ‘ to best inform the Symphony PMC.

Thank you.

Disappearing Data-feed - Recreate new Data-Feed

Have noticed the below in my logs. After a series of successful polls to the data feed,

[Wed Aug 17 2016 22:35:28 GMT-0400 (EDT)] DEBUG received 204 response from /agent/v2/datafeed/d46665fd-e400-4ac4-8303-846eafe1330d/read: undefined
[Wed Aug 17 2016 22:35:28 GMT-0400 (EDT)] DEBUG Polling datafeed d46665fd-e400-4ac4-8303-846eafe1330d
[Wed Aug 17 2016 22:35:59 GMT-0400 (EDT)] DEBUG received 204 response from /agent/v2/datafeed/d46665fd-e400-4ac4-8303-846eafe1330d/read: undefined
[Wed Aug 17 2016 22:35:59 GMT-0400 (EDT)] DEBUG Polling datafeed d46665fd-e400-4ac4-8303-846eafe1330d

We suddenly see a data-feed dissappear,

[Wed Aug 17 2016 22:35:59 GMT-0400 (EDT)] DEBUG received 400 response from /agent/v2/datafeed/d46665fd-e400-4ac4-8303-846eafe1330d/read: {"code":400,"message":"Could not find a datafeed with the provided id"}
[Wed Aug 17 2016 22:35:59 GMT-0400 (EDT)] DEBUG Received 0 datafeed messages
[Wed Aug 17 2016 22:35:59 GMT-0400 (EDT)] DEBUG Polling datafeed d46665fd-e400-4ac4-8303-846eafe1330d
[Wed Aug 17 2016 22:36:00 GMT-0400 (EDT)] DEBUG received 400 response from /agent/v2/datafeed/d46665fd-e400-4ac4-8303-846eafe1330d/read: {"code":400,"message":"Could not find a datafeed with the provided id"}
[Wed Aug 17 2016 22:36:00 GMT-0400 (EDT)] DEBUG Received 0 datafeed messages

Need the reconnect logic to be triggered when this event occurs.
"code":400,"message":"Could not find a datafeed with the provided id"

Fix semantic release with @symphonyoss npm org

I've updated package.json but I had to change the NPM_TOKEN in travis to successfully release so deployments are currently done using my account. I don't really care but you may want to change this to use the symphonyoss account that used to do the releases (seems npm have deleted that...)? As I suspected the versioning has reset to 1.0.0 - not sure how to fix that...

See https://www.npmjs.com/package/@symphonyoss/hubot-symphony

Can you look into how to bump the next version to 3.0.7, do a release and notify the dev list that any users need to update their dependencies from hubot-symphony to @symphonyoss\hubot-symphony please?

You may also want this as a reference for future projects.

  • Build 280 : failed using npm publish (c81795a)
  • Build 281 : pushed to NPM but failed to update github releases - probably due to version mismatch npm publish --access public (e7b506a)

Correct copyright notices in NOTICE and source headers

The legal acceptance criteria had previously stated that all contributed code needed to represent that the Symphony Software Foundation was the copyright holder, but this was an unfortunate mistake - in virtually all cases, copyright remains held by the contributor of the project, and (via the CCLA / ICLA) is licensed to the Foundation.

In preparation for a v1.0 release of the Hubot โ†”๏ธŽ Symphony integration, it would be ideal if the copyright notices in the NOTICE file and headers of all source code files were updated to show the correct copyright holder of the contribution.

Test git-release for hubot-symphony first release and document Version management

Create Symphony OSS NPMJS organisation

  • Follow https://docs.npmjs.com/orgs/what-are-orgs
  • Change package.json to reflect keyword and other elements that identify symphonyoss as "owner/maintainer" of the project
  • Document NPM requirements to apply for the Foundation projects and the lifecycle of projects being published (ie. can a published project be removed from the public repository? it appears so)
  • Investigate announcement/notification features (something similar to https://www.artifact-listener.org , but for NPMJS repo)

Can I construct my own request for testing?

My Hubot (Gifbot) is working all right. Is there a way for me to send a self constructed request (via postman or some cURL request) to the coffee script? If yes, please can someone guide me?

New adapter method to send a single-party instant message to a username / email address

In order to allow users to link webhooks to single-party instant messages rather than rooms add functionality that can be accessed via robot.adapter.sendDirectMessageToUsername or robot.adapter.sendDirectMessageToEmail.

These will need to resolve to a userID via pod/v1/user/name/:username/get or pod/v1/user?email=:email and then call pod/v1/im/create

Allow connection requests to be auto-accepted

There are two use cases for this:

  • When the Bot is communicating externally, in order to talk to the Bot the external user needs to have requested a connection and the bot needs to approve this.
  • If/when someone joins a room you can automatically send a greeting message to a user.

Add "what" and "why" to top of readme

Currently the README doesn't really describe what this project is, and why I might want to use it. It would be ideal to add this information to the top of the README, so that potential consumers who may not be familiar with the project can figure out what it's for (this should also include links out to Hubot and Symphony docs, so that anyone who isn't familiar with those can educate themselves on them too).

The first section of this README is a good example of what I'm thinking.

Run diagnostic command continuously against ODP

It would be very cool to instruct Travis CI to run the diagnostic command (on every commit) against the Foundation Dev Pod (foundation-dev.symphony.com).
In order to achieve it, it is necessary to:

  1. download the User Identity certificates in the build box; this is now possible and the symphony-java-sample-bots project already runs integration-tests successfully - https://travis-ci.org/symphonyoss/symphony-java-sample-bots
  2. run the diagnostic command with npm (just follow https://github.com/symphonyoss/hubot-symphony/blob/dev/run-odp.sh)
  3. send a message - from another service account - to the one that executed the diagnostic command on step 2

The only part that is missing is 3 and I'm not sure if hubot-symphony has the code to allow it.

NPM artifact signing for release

To avoid tampering with NPM artifacts published (and maintained) by the Foundation, it is strongly recommended (if not mandatory, from a Foundation Security standpoint) to sign artifacts in order to prove their authenticity and avoid man-in-the-middle attacks.

The Java (Maven) release already includes such feature, which is widely endorsed by Maven Central (check https://symphonyoss.atlassian.net/wiki/display/FM/Software+Development+Onboarding#SoftwareDevelopmentOnboarding-MavenReleaseFeatures), but for NPM it's up to the project to enforce it, as it's not mandatory.

Looking for an NPM package that helps with the signing/deployment of GPG-signed artifacts.

Remove ghooks dependency

Although switching to husky is supposed to be trivial it's possible to commit to github with an invalid message from Windows. I've re-added the ghooks dependency for now pending further investigation across multiple OS.

Behind a proxy and bypass proxy for internal url

Hello
i'm behind a corporate proxy
I export HTTP_PROXY and HTTPS_PROXY environment value in the script which start the Symphony Hubot.
We have a Local KeyManager, and we setup the environment variable HUBOT_SYMPHONY_KM_HOST to the correct value. When Symphony redirec to the KM url , the Hubot reach the Proxy as well...and should not for internal url.
So we need to bypass proxy settings for internal url. How can we do that ?

Thanks for your help

Cannot connect to foundation-dev pod

I'm trying to run the diagnostic on the foundation-dev pod.
For clarity, below are reported the endpoints needed to connect to the Foundation Dev Pod:

It seems that Pod, Agent and SessionAuth endpoints share the same hostname, hence the issue.

npm run diagnostic -- --publicKey ./certs/publicCert.pem --privateKey ./certs/privateKey.pem --passphrase changeit --host foundation-dev.symphony.com --kmhost foundation-dev-api.symphony.com
> hubot-symphony@ diagnostic /Users/m/w/projects/hubot-symphony
> coffee src/diagnostic.coffee "--publicKey" "./certs/publicCert.pem" "--privateKey" "./certs/privateKey.pem" "--passphrase" "changeit" "--host" "foundation-dev.symphony.com" "--kmhost" "foundation-dev-api.symphony.com"

[Mon Oct 03 2016 13:26:24 GMT-0400 (EDT)] INFO Running diagnostics against https://foundation-dev.symphony.com
[Mon Oct 03 2016 13:26:24 GMT-0400 (EDT)] INFO Connecting to foundation-dev.symphony.com
[Mon Oct 03 2016 13:26:24 GMT-0400 (EDT)] INFO Using separate KeyManager foundation-dev-api.symphony.com
[Mon Oct 03 2016 13:26:24 GMT-0400 (EDT)] INFO Connection initiated, starting tests...
[Mon Oct 03 2016 13:26:24 GMT-0400 (EDT)] INFO Key manager token: 0100af4aed8f3bc6895fc512e8c1150b93eb9c172a0c929c081a6b3e8c46405a1cfc5c315dd6c4421929c7576e7363def4162d67a5def78b1bf058adc6059b53f3cb55ac181b82a6835ba622a5c5aaf00248d6539ba88338f74d7c1e73dd71f9a0394b17c08b215ee9e18197ea2d779b2a41a5f0d22f5b9b074d4e2de330cb50b7426e73a0759bac28bd88e8d82cf174eec4c42a82fd24b48b0d483630bb78f1734f49f7b7e03e6a12d049904963154b1e5d9457e003fc6934758fcd4214
[Mon Oct 03 2016 13:26:24 GMT-0400 (EDT)] INFO Session token: undefined
[Mon Oct 03 2016 13:26:24 GMT-0400 (EDT)] INFO Initialising with sessionToken: undefined and keyManagerToken: 0100af4aed8f3bc6895fc512e8c1150b93eb9c172a0c929c081a6b3e8c46405a1cfc5c315dd6c4421929c7576e7363def4162d67a5def78b1bf058adc6059b53f3cb55ac181b82a6835ba622a5c5aaf00248d6539ba88338f74d7c1e73dd71f9a0394b17c08b215ee9e18197ea2d779b2a41a5f0d22f5b9b074d4e2de330cb50b7426e73a0759bac28bd88e8d82cf174eec4c42a82fd24b48b0d483630bb78f1734f49f7b7e03e6a12d049904963154b1e5d9457e003fc6934758fcd4214
[Mon Oct 03 2016 13:26:25 GMT-0400 (EDT)] WARNING received 404 response from /agent/v1/datafeed/create: "<html>\n<head><title>404 Not Found</title></head>\n<body bgcolor=\"white\">\n<center><h1>404 Not Found</h1></center>\n<hr><center>nginx/1.6.3</center>\n</body>\n</html>\n"
[Mon Oct 03 2016 13:26:25 GMT-0400 (EDT)] ERROR Failed to receive a message: Error: received 404 response from /agent/v1/datafeed/create: "<html>\n<head><title>404 Not Found</title></head>\n<body bgcolor=\"white\">\n<center><h1>404 Not Found</h1></center>\n<hr><center>nginx/1.6.3</center>\n</body>\n</html>\n"
[Mon Oct 03 2016 13:26:25 GMT-0400 (EDT)] WARNING received 401 response from /pod/v1/sessioninfo: {"code":301,"message":"No sessionToken token"}
[Mon Oct 03 2016 13:26:25 GMT-0400 (EDT)] ERROR Failed to fetch userId: Error: received 401 response from /pod/v1/sessioninfo: {"code":301,"message":"No sessionToken token"}

The solution may be to add to the hubot-symphony constructor the following parameters:

  • sessionhost
  • agenthost
  • podhost

Use some sort of backoff strategy to deal with failure to create / poll datafeed

Currently if Symphony refuses to create a datafeed the adaptor will bomb

[Fri Aug 12 2016 08:24:40 GMT-0400 (EDT)] WARNING received undefined error response from /agent/v1/datafeed/create: Error: connect ECONNREFUSED 104.196.126.237:8444
[Fri Aug 12 2016 08:24:40 GMT-0400 (EDT)] ERROR Error: Unable to create datafeed: Error: Error: connect ECONNREFUSED 104.196.126.237:8444
at ~/node_modules/hubot-symphony/src/adapter.coffee:82:41, <js>:117:42

Should probably do an exponential backoff and call process.exit 1 after a timeout using https://github.com/MathieuTurcotte/node-backoff

Improved license checking for transitive dependencies

Using VersionEye, it is possible to parse a yarn.lock file (located in the project root folder) and get useful information regarding transitive dependencies used (in production) by hubot-symphony.

Changes added to https://github.com/symphonyoss/hubot-symphony/pull/34/files

A preview of VersionEye dashboard is available on https://www.versioneye.com/user/projects/58a2d0a90f3d4f00445dabee

Thanks @reiz for helping figuring out VersionEye configuration!

Check hubot project status with GitHub

https://github.com/github/hubot/blob/master/CONTRIBUTING.md says

We like to at least comment on, if not accept, pull requests within a few days.

but the last commit to hubot was May 2016 and the pull request to add Symphony to the list of adapters has sat in their queue for 8 months (hubotio/hubot#1228).

Would be great to get some colour from GitHub directly on what's going on with the project (if it's long-term maintenance no big deal, just clear the PR queue...)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.