Giter VIP home page Giter VIP logo

hubcommander's Introduction

HubCommander

HubCommander Logo

NetflixOSS Lifecycle Gitter chat

A user-extendable Slack bot for GitHub organization management.

HubCommander provides a chat-ops means for managing GitHub organizations. It creates a simple way to perform privileged GitHub organization management tasks without granting administrative or owner privileges to your GitHub organization members.



Service Master Develop
Travis CI Build Status Build Status

How does it work?

HubCommander is based on slackhq/python-rtmbot (currently, dependent on release 0.4.0)

You simply type !help, and the bot will output a list of commands that the bot supports. Typing the name of the command, for example: !CreateRepo, will output help text on how to execute the command.

At a minimum, you will need to have the following:

  • Python 3.5+
  • Slack and Slack credentials
  • A GitHub organization
  • A GitHub bot user with ownership level privileges

A Docker image is also available to help get up and running quickly.

Features

Out of the box, HubCommander has the following GitHub features:

  • Repository creation
  • Repository deletion
  • Repository description and website modification
  • Granting outside collaborators specific permissions to repositories
  • Repository default branch modification
  • Repository PR listing
  • Repository deploy Key listing/creation/deletion
  • Repository topics creation/deletion
  • Repository branch protection enabling/disabling

HubCommander also features the ability to:

  • Enable Travis CI on a GitHub repo
  • Safeguard commands with 2FA via Duo

You can add additional commands by creating plugins. For example, you can create a plugin to invite users to your organizations.

HubCommander also supports Slack ephemeral messages and threads.

Installation Documentation

Please see the documentation here for details.

Contributing

If you are interested in contributing to HubCommander, please review the contributing documentation.

hubcommander's People

Contributors

adubiz avatar apolikamixitos avatar aspyker avatar bboe avatar bmanuel avatar divyasharma59 avatar dmart avatar dogbone0714 avatar ebukoski avatar francois-d avatar goduncan avatar invisiblethreat avatar mikegrima avatar musawakiliml avatar noamran avatar retornam avatar rveguilla avatar sbalagopal avatar sgedward avatar sghill avatar swampdragons avatar timgates42 avatar viveksyngh avatar

Stargazers

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

Watchers

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

hubcommander's Issues

!CreateRepo should have a team parameter

Currently, the !CreateRepo will always assign a new repo to the specified default team.

However, I want to choose the target team in the command like so:

!CreateRepo <NewRepoName> <GitHubOrgAliasToPutTheRepoInToHere> <TargetTeam>

<TargetTeam> could be an optional parameter. If it is not supplied, the repo will go into the default team. Just like the current behaviour. If it is supplied, it will got into the specified team instead.

I would be happy to modify the !CreateRepo command and supply a pull request.

Question: Is there a place for these commands?

I'm sorry if this isn't the best place for this kind of conversation but I'm not sure where else to start it.

The company that I work for is a heavy user of AWS. For that reason I'm able to make some assumptions about where my hubcommander bot would be running and the resources that it would have available to it. I wanted to start learning Python and extend Hubcommander so I've added several commands, commands that I've put in a separate class to prevent missing out on other work that's merged here.

I'm waiting for #40 to be merged so I can refactor my code a bit. That said, when I've been able to do that I'm curious if there's a place for more opinionated commands/functionality like the below, maybe in a separate contrib directory with additional instructions on how to make use of them?

  • get_credentials method that uses EC2 SSM parameter store for retrieving credentials
  • !CreatePR to do the obvious
  • !AddReviewerGroup, !RemoveReviewerGroup, !ListReviewerGroups, !DescribeReviewerGroup, !AddToReviewerGroup, !RemoveFromReviewerGroup and finally, !AddReviewersToPR each would make use of SSM parameter store in some form. The goal is to use hubcommander for creating a pull request and allowing our developers to add reviewers to their PR by group without having to provide them admin access to the repo.
  • !CheckUsername will return the user's real name if they're still a member of your organization. Helpful for performing cleanup on a reviewer group in case an employee leaves the company.
  • !GetPRInfo returns the HTTP URL of a pull request
  • !ToggleAdminBranchProtection to do the obvious.

I wanted to ask before opening a PR. Thank you for any input you can offer!

Better/current documentation needed

Ordinarily, I would try to update the docs myself, but I just don't have time.
I got hubcommander working today, but it was more effort than it should have been due to outdated documentation.

A few things I had issue with:

  • In my org, I had to create a slack app in order to get a token. Then you must give the app the power to be a bot, and use the bot token for Oauth in order to get rtm:stream permission in particular
  • rtmbot.conf is seemingly ignored, and only exporting SLACK_TOKEN works.
  • The github plugin has been moved, but the docs do not reflect this, and link to the config.py location

Deploy Key Improvements

The !AddKey command's help text is missing the repo. The !AddKey command also needs to output a friendly message for when an invalid key was entered.

KeyError: 'text' in process_message

I noticed this error in rtmbot.log while testing locally. The link is being posted by my bot in response to it taking action. When it parses the link that it sends, this error is produced.

2017-05-13 14:16:02,909 Problem in Plugin Class: HubCommander: process_message
{'type': 'message', 'subtype': 'message_changed', 'message': {'type': 'message', 'text': '<https://www.youtube.com/watch?v=dNB_RjpWnsI>', 'ts': '1494684962.122327', 'attachment
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/rtmbot/core.py", line 205, in do
    func(data)
  File "/usr/lib/python3.5/site-packages/hubcommander/hubcommander.py", line 53, in process_message
    command_prefix = data["text"].split(" ")[0].lower()
KeyError: 'text'

Issue setting up with Linux for Windows: "AttributeError: 'NoneType' object has no attribute 'recv'"

Hi, I'm trying to set up hubcommander so I can do a PR. I've got Debian Wheezy on Linux Subsystem. I've done the following from scratch:

  • installed everything required
  • set up python-venv
  • run the basic_install without issues
  • set up rtmconf, activated the virtualenv, set up the exports
  • run rtmbot

I get the following stack trace when running the rtmbot command:

(venv) dylmye-debian@DYLMYE-HOME-PC:~/hacktober/python-rtmbot-0.4.0$ rtmbot
[-->] Enabling Auth Plugins
[✔] Completed enabling auth plugins plugins.
[-->] Enabling Command Plugins
[ ] Enabling Command Plugin: repeat
        [+] Adding command: '!Repeat'
        [+] Adding command: '!RepeatThread'
[+] Successfully enabled command plugin "repeat"
[ ] Enabling Command Plugin: github
        [+] Adding command: '!ListOrgs'
        [+] Adding command: '!DeleteRepo'
        [+] Adding command: '!AddCollab'
        [+] Adding command: '!SetDefaultBranch'
        [+] Adding command: '!SetTopics'
        [+] Adding command: '!ListPRs'
        [+] Adding command: '!GetKey'
        [+] Adding command: '!CreateRepo'
        [+] Adding command: '!SetRepoPermissions'
        [+] Adding command: '!ListKeys'
        [+] Adding command: '!SetHomepage'
        [+] Adding command: '!AddKey'
        [+] Adding command: '!DeleteKey'
        [+] Adding command: '!SetDescription'
        [+] Adding command: '!SetBranchProtection'
        [+] Adding command: '!AddUserToTeam'
[+] Successfully enabled command plugin "github"
[✔] Completed enabling command plugins.
Traceback (most recent call last):
  File "/usr/local/bin/rtmbot", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/rtmbot/bin/run_rtmbot.py", line 31, in main
    bot.start()
  File "/usr/local/lib/python3.5/dist-packages/rtmbot/core.py", line 99, in start
    self._start()
  File "/usr/local/lib/python3.5/dist-packages/rtmbot/core.py", line 86, in _start
    for reply in self.slack_client.rtm_read():
  File "/usr/local/lib/python3.5/dist-packages/slackclient/client.py", line 235, in rtm_read
    json_data = self.server.websocket_safe_read()
  File "/usr/local/lib/python3.5/dist-packages/slackclient/server.py", line 278, in websocket_safe_read
    data += "{0}\n".format(self.websocket.recv())
AttributeError: 'NoneType' object has no attribute 'recv'

Anything I'm missing out? Any additional information I can provide to help? Thank you!!

Prepare for 1.0 Release

Need to prepare for 1.0 HubCommander release!

  • We now have a logo (Need to submit PR).
  • We also have a much more sophisticated argument parsing capability.
  • We now have a generic bot framework that can do more than just GitHub!

It's time for 1.0. Need to make some small preparations first.

Duo support for multiple keys

The DUO plugin needs to better support multiple keys depending on the domain.

For example, users with @somedomain.com should be authenticated separately from users that may be members of @someotherdomain.com.

Right now, there is 1 set of credentials that are passed in. This should be easy to fix by making the credentials a dict for the domain. Then, it should check the domain a user is a member of to pick the correct credentials.

Add `!ListTeams` github command

Some of the commands (for example, !CreateRepo, !SetRepoPermissions) require team parameters. It could help people to be able to list all teams or search for a team to find the team they needed.

Follow-up to 0.4.0 rtmbot

Need to perform some additional tasks to ensure that the transition to 0.4.0 is smooth:

  1. Update documentation for plugin creation ✅
  2. Update documentation for rtmbot.conf to reflect the new place hubcommander is stored ✅
  3. Ensure that the Duo and Travis plugins are up to date and working properly ✅
  4. Test the basic_install.sh file to ensure that things are still working properly ✅
  5. Ensure that all cruft is left out of when generating the Docker image ✅

Make a decorator for arg-parsing

The current argument parsing logic is extremely verbose and highly repetitious.

Would like to make this a decorator for command plugins to make this much, much more seamless.

Branch Protection GH API has changed

Need to update the !SetBranchCommand since the GH API changed since I last committed the feature.

Need to send a DELETE instead of PATCH if disabling branch protection.

Prepare for release 1.1

With new support for slack threads and ephemeral messages, it's time for a 1.1 release!

Will first test the current develop branch and will then push a new release if all goes well.

Topic Support?

It appears that GitHub may have added Topics support via the API:
https://developer.github.com/v3/

It is currently a preview, and requires the following Accept header to be set: application/vnd.github.mercy-preview+json.

This would be a useful command to add, but would like to hold off until #30 is complete.

Add develop tag to docker hub image

Right now docker hub only allows pulling releases of hubcommander.
Could be very handy to be able to pull the develop branch directly, instead of waiting for a new release.
Right now if I want to deploy the develop branch I have to build the image myself, which is pretty easy thanks to the great build-docker.sh script, but having develop available for me directly from docker hub would be nice.
Thanks,
Yaron.

Make hubcommander a generic bot framework

I have been using hubcommander internally to run some bot commands without the github component. Would you be interested in not enabling the github plugin by default and turning hubcommander into a generic python slack bot framework? (Would be happy to submit a PR if it is!).

Support Slack Threads

Need to add support for Slack threading.

This could prove useful to reducing verbose messaging in the channels.

Support Slack Ephemeral Messages

Need to add support for Slack's ephemeral messages for more informational -- not super important for everyone else type of messages.

This could also prove useful for dealing with Duo auth messages.

Welcome users message

When new users enter a channel, they should be greeted with the !Help command output as an ephemeral message.

This will additionally help reduce spam.

This should also be set up in such a way to help users write custom messages as well.

Renamed GitHub repos throw off the bot

When a repository is renamed, GitHub redirects to the new location of the repo.

This causes issues when trying to create new repos over the old namespace. Need to investigate if there is a response code we can detect for when this happens and react properly.

Possible timing issue creating new repositories

Noticed an issue with repos that have - in them where team adding after repository creation sometimes fails.

I believe it may be an odd timing issue. Will try to insert a 3 second pause after repo creation before assigning teams.

Better logging

Need to have better debug logging in place for HubCommander.

Travis CI reports a 404 when trying to enable for repositories

Travis CI is reporting a 404 when attempting to enable on repositories that switched visibility (going from private -> public).

This will require some investigation.

I suspect that the issue is related to the synchronization. To test, I'm going to have the synchronization task operate against both public and private Travis to ensure that there are no consistency issues.

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.