Git Product home page Git Product logo

hubot-stackstorm's People

Contributors

agaffney avatar amaline avatar amanda11 avatar arm4b avatar armab avatar arulvelu21 avatar blag avatar cbrenton avatar charlottestjohn avatar cognifloyd avatar deluxetom avatar dependabot[bot] avatar emedvedev avatar enykeev avatar humblearner avatar itxaka avatar jfryman avatar jinpingh avatar kami avatar lakshmi-kannan avatar livelace avatar logic855 avatar m4dcoder avatar manasdk avatar marcbachmann avatar nmaludy avatar nzlosh avatar shusugmt avatar tonybaloney 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

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

hubot-stackstorm's Issues

st2chatops exits because command doesn't match format string

Version: st2 3.1.0, on Python 3.6.8

Duplicate:
With default action alias !pack get <pack>. If run !pack get pack=example, the st2chatops exits with exception.

[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] ERROR Failed to create an alias execution: { name: 'APIError',
 status: 400,
 message:
  'Command "pack get pack=core" doesn\'t match format string "pack get {{ pack }}"' }
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] DEBUG SlackClient#send() room: GJJCKM0HF, message: [object Object]
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] ERROR undefined
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] ERROR {"name":"APIError","status":400,"message":"Command \"pack get pack=core\" doesn't match format string \"pack get {{ pack }}\""}
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] INFO Hubot will shut down ...
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] INFO Disconnected from Slack RTM
[Fri Jun 28 2019 21:50:39 GMT+0000 (Coordinated Universal Time)] INFO Exiting...

All the alias matching should be performed on the server

Right now hubot plugin basically duplicates all the API logic for alias matching. That's bad because hard to maintain and error prone.

StackStorm API offers all the primitives for performing alias matching and everything else server-side. All the bot plugins should be very thin and simple wrappers around the API and be trivially to maintain (right now it's exactly the opposite).

That's something I already mentioned as blocker a long time ago when we worked on improved ChatOps, but it never materialized, we just added more regexes which makes everything even harder to maintain.

Parameters are not passed when sending a direct message to hubot via slack

Using the docs as an example, with this configuration:

formats:
  - "google {{query}}"

sending as a direct message to hubot via slack (untested on other messaging providers) google foo sets query=foo. However, sending: ! google foo does not set query=foo

I tested this on 1.3.2. If someone else could verify, that would help.

Unable to load stackstorm

When starting st2chatops, it fails with following errors:
ERROR Unable to load /opt/stackstorm/chatops/node_modules/hubot-stackstorm/scripts/stackstorm: TypeError: Object prototype may only be an Object or null
at Function.create (native)
at module.exports (/opt/stackstorm/chatops/node_modules/st2client/index.js:122:17)
at module.exports (/opt/stackstorm/chatops/node_modules/hubot-stackstorm/scripts/stackstorm.js:114:13)
at Robot.loadFile (/opt/stackstorm/chatops/node_modules/hubot/src/robot.coffee:358:11, :226:13)
at /opt/stackstorm/chatops/node_modules/hubot-stackstorm/index.js:38:13
at Array.forEach (native)
at module.exports (/opt/stackstorm/chatops/node_modules/hubot-stackstorm/index.js:33:13)
at Robot.loadExternalScripts (/opt/stackstorm/chatops/node_modules/hubot/src/robot.coffee:401:11, :272:39)
at /opt/stackstorm/chatops/node_modules/hubot/bin/hubot:119:11, :126:26
at fs.js:268:14
at Object.oncomplete (fs.js:107:15)

hubot-stackstorm not responding with result in Mattermost

Original forum thread: https://forum.stackstorm.com/t/st2chatops-with-mattermost-not-replying/711

Created at the request of @armab

Good morning,

Currently, hubot-stackstorm does not respond with the output/result of a stackstorm command on Mattermost.

Here is what happens when I send !pack get docker

  1. Bot successfully reads my command.
  2. Stackstorm successfully runs the command.
  3. The output is sent to the event stream.
  4. Bot receives the message (this can be seen in the logs as Chatops message received followed by the JSON of the correct output)
  5. Bot does nothing else.

I have tested this with Mattermost 5.4.0, 5.9.0 and 5.12.3 on two different networks (one connected to the Internet and one not). I have tried using the Slack adapter with the same settings instead and it works as expected. I have tried using errbot with a Mattermost adapter and a Stackstorm adapter and it also works.

I recommend reading the forum thread at the top of this issue if you have any questions, as it has been most likely answered in there.

Default values for aliases don't function as expected

aliases/roll.yaml:

---
name: "roll"
action_ref: "ansible.playbook"
description: "Perform a rolling deployment with Ansible playbook"
formats:
  - "roll1 {{playbook=deploy.yaml}} {{cwd=/opt/server-tooling/rollin}} {{inventory-file=test}} {{limit=10.2.30.121}}"

Sending:

bob roll1 playbook=deploy.yaml cwd=/opt/server-tooling/rollin inventory-file=test

Results in:

Action ansible.playbook completed.
status : failed
execution: 56391f6b02ebd505aa3bc807

result :
--------
return_code : 1
stderr : ERROR: Specified --limit does not match any hosts
Executed command "/opt/stackstorm/virtualenvs/ansible/bin/ansible-playbook --limit=inventory-file=test --inventory-file=test deploy.yaml"

Notice how it clobbered the the limit parameter and didn't inject the default.

ERROR: Unauthorized

Running it on production with authentication enabled. At start it works ok, but after some period of time when trying to run chatops command I get:

error

Version:
hubot-stackstorm 0.2.1

Log:

[Wed Jul 29 2015 16:50:44 GMT+0000 (UTC)] INFO Connecting...
[Wed Jul 29 2015 16:50:44 GMT+0000 (UTC)] INFO Logged in as chatopsbot of ..., but not yet connected
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO Slack client now connected
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO Performing authentication...
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO /opt/hubot/node_modules/hubot-stackstorm/scripts/stackstorm.js is using deprecated documentation syntax
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO Loading commands....
[Wed Jul 29 2015 16:50:45 GMT+0000 (UTC)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Wed Jul 29 2015 16:52:45 GMT+0000 (UTC)] INFO Loading commands....
[Wed Jul 29 2015 16:54:45 GMT+0000 (UTC)] INFO Loading commands....
...
(note exactly 24h interval)
...
[Thu Jul 30 2015 16:48:47 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 16:50:47 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 16:50:47 GMT+0000 (UTC)] ERROR Failed to retrieve commands: {
    "faultstring": "Unauthorized"
}
[Thu Jul 30 2015 16:52:47 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 16:52:47 GMT+0000 (UTC)] ERROR Failed to retrieve commands: {
    "faultstring": "Unauthorized"
}

Seems something related to expired tokens,
because after restarting hubot it returns back to normal.

Command's parameters get their case lowered.

Hello.

Commands sent to the hubot, which passes them later to stackstorm, get their case lowered. I am seeing that this is done to get a matching command, but this causes different issues later. E.g., passing a hostname to ansible. Ansible looks for the exact name in its inventory. I think this can be worked around by copying the command to a temp var, changing it to lower case and get a matching command from it, then treating the original command accordingly. I will try to implement it locally on my server.

Thanks.

Feature Request: Have chatops post_message formatting be toggleable between code / text

When a message is routed through chatops.post_message, it is automatically prepended with "/code". For our particular use case, we would prefer to have the ability to toggle code on/of

https://github.com/StackStorm/hubot-stackstorm/blob/master/lib/format_data.js#L71

Reasons we want it!

  • Ability to change user's karma (hipchat filters out karma changes in code blocks)
  • Ability to have the bot use emoticons (hipchat code blocks display emoticons as text only)
  • Hipchat code block w/ replies to users breaks formatting, so that it just says User Name: /code stuff

Bot and Private Messages


This screenshot demonstrates what I mean.
Such behavior is documented somewhere (don't remember exactly where), but I found it not so user-friendly.

I think that bot should react in PM for the same commands as user writes in channel AND optionally, if you think it makes good sense, for commands without alias (eg. !).


Tiny things to provide more obvious and predictable communication interface, making sure user don't need to keep in mind special cases like that.

Long messages to Slack are truncated

If chatops.post_message is given a sufficiently long message, it is truncated, and its length does not seem to be adjustable. I tested via the Slack documentation-based tester, and the full message is retained. It appears to be truncated at some point by hubot-stackstorm.

Setting ST2_MAX_MESSAGE_LENGTH had no effect. I believe that is the case because of this comment.

Help command should only list commands the user is allowed to run

A customer asked for this feature.

The !help command currently just dumps every command that is loaded by st2chatops. This is due to how hubot commands are loaded (into robot.commands) and how the hubot-help plugin works.

It would be helpful if the bot only dumped out commands that the authenticated ChatOps user can run. This would reduce confusion, because the situation right now amounts to:

  1. User chats !help
  2. Hubot dumps all loaded ST2 commands
  3. User starts trying to run listed commands
  4. ST2 RBAC returns authorization errors
  5. User has to iterate through entire list to figure out what they can run

A few additional notes:

  • SECURITY: If results are dumped back into a public channel and that channel history is accessible to all users, it would allow a malicious user or an attacker to target users that can run commands the attacker is interested in.
  • ChatOps RBAC extensions to only allow certain commands to only be run in certain channels/by certain users (#2481, #4559) will have different results depending on which channel the !help is run from, or it would require a complete listing of the allowed commands on a per-channel basis. This listing can grow very quickly, so this feature would greatly complicate that feature.
    Example:
    !help
    
    #public-channel
    ---------------
    * do_thing_1
    * do_thing_2
    
    #private-channel-aaylmao
    ------------------------
    * do_thing_1
    * do_thing_3
    * do_thing_4
    
    #private-channel-omgstahp
    -------------------------
    * do_thing_2
    * do_thing_5
    
  • ChatOps RBAC extensions to only allow certain users to run some commands with only certain parameters (eg: restrictions on hostname parameter) will similarly be complicated by this feature.

Cannot change the URL in st2 bot information.

I'm not able to change the URL in st2 bot info.
After modifying the ST2_WEBUI_URL to a static ip in st2chatops.env and modifying webui_base_url in st2.conf and doing a st2ctl restart. The link still point to the hostname instead of the static value.
OS: Linux version 3.13.0-100-generic (buildd@lgw01-52) (gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
This is a single node install using the curl installer.

export ST2_HOSTNAME="${ST2_HOSTNAME:-localhost}"
export NODE_TLS_REJECT_UNAUTHORIZED=0
export EXPRESS_PORT=8081
export HUBOT_LOG_LEVEL=debug
export HUBOT_NAME=hubot
export HUBOT_ALIAS='!'
export ST2_API="${ST2_API:-https://${ST2_HOSTNAME}/api}"
export ST2_AUTH_URL="${ST2_AUTH_URL:-https://${ST2_HOSTNAME}/auth}"
export ST2_API_KEY=secret_key
export ST2_WEBUI_URL=https://10.40.0.117
 export HUBOT_ADAPTER=slack
 export HUBOT_SLACK_TOKEN=xoxb-super-secret

Not all aliases reaching hubot-stackstorm

We have approximately 135 aliases:

# st2 action-alias list -j -a all | jq '.[].formats[]' | egrep "^\""  | wc -l
135

Not all of them are being made available to hubot.

When dumping Raw actions from ST2 API during loadCommands in /opt/stackstorm/chatops/node_modules/hubot-stackstorm/scripts/stackstorm.js, it was determined that about 100 aliases were making it.

npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)

When I try to run npm install hubot-stackstorm
I am getting this issue :

root@56914a14ea3b:~/myhubot# npm install hubot-stackstorm
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for st2client

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-08-27T09_31_24_173Z-debug.log
`

When using the action chatops.post_message Slack notifications display NO FALLBACK DEFINED

While doing some testing of the ChatOPS interface, I've noticed notifications from StackStorm via hubot to Slack show the following text:

NO FALLBACK DEFINED

This is due to the fallback part of payload in robot.emit 'slack-attachment', payload has not been defined. This really should be a combination of the pretext and the text with no formatting. So that notifications (and systems that do not support attachments) can display the message.

Jon.

found 1 moderate severity vulnerability

I can see an issue of " hubot-stackstorm" package installation :

root@bef5e65692ca:/myhubot# npm install hubot-stackstorm
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)

  • [email protected]
    added 27 packages from 61 contributors and audited 305 packages in 10.924s
    found 1 moderate severity vulnerability
    run npm audit fix to fix them, or npm audit for details
    root@bef5e65692ca:/myhubot# ^C
    root@bef5e65692ca:/myhubot# npm audit fix
    up to date in 1.29s
    fixed 0 of 1 vulnerability in 305 scanned packages
    1 vulnerability required manual review and could not be updated

Problem with @mention in Slack

When result message from the bot contains attachment, @mention doesn't work in Slack:

Good

^^ correct & highlighted @mention, you're notified in Slack

Bad

^^ @mention is just a plain text here, no Slack notification from bot


As @emedvedev said, something was changed in Slack API.

Original discussion with code example:

hubot loads with a syntax error

This get emitted upon startup and repeats until Hubot eventually shuts down

[Mon Sep 21 2015 17:34:11 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Mon Sep 21 2015 17:34:11 GMT+0000 (UTC)] ERROR SyntaxError: Unexpected token <
  at Object.parse (native)
  at /opt/hubot/node_modules/hubot-stackstorm/scripts/stackstorm.js:117:28
  at IncomingMessage.<anonymous> (/opt/hubot/node_modules/hubot/node_modules/scoped-http-client/src/index.js:95:22)
  at IncomingMessage.emit (events.js:129:20)
  at _stream_readable.js:908:16
  at process._tickCallback (node.js:355:11)

ChatOps via private messages fails with 500

reported by @mick27 from IRC

When playing with chatops commands in the room (Slack room in our case) - it works ok.

When sending private message to bot, it returns 500:
pm
(reproduced in Slack)

PM most probably is not the best way for ChatOps, but we should avoid user confusion here.

At least should be some more user-friendly message asking to use chat room (otherwise fix chatops via PM).

RBAC for ChatOps in StackStorm

User Story

As a privileged user (ops/sysadmin) I want to be able to apply one off commands (for debugging/fixes) and/or run my configuration management solution through Chatops/Slack/Rocketchat. At the same time I want to grant read only or a layer of both authentication and authorization to other stakeholders/single channel users. Also restrict/limit the specific calls a user can make to the channel bots and/or list which commands unprivileged users could access (better example may be 2 channels for two authorizations steps or 2 bots in one channel). Ideally security/auditing could; ping, status, metrics, report, etc. to the channel or render reports/audits/charts/etc, or only make available lower risk commands (e.g. ansible playbook w/o declaring git branch or arbitrary cmd - where code being applied can only come from master branch) to restrict team members to only be able to push "approved" code.

Issue

  1. In reviewing the code I noticed the condition for a 2FA command: https://github.com/StackStorm/hubot-stackstorm/blob/master/scripts/stackstorm.js#L94 . What is current/planned use (if any) of this to date? is/will it manage 2FA from StackStorm, hubot, or any 3rd party SAML/LDAP/OAuth service?
  2. I've come around a number of hubot scripts - are any of these potentially useful or being considered for integration?

Hubot doesn't reconnect to the stream on API restart

hm, so after I restart with st2ctl restart, my bot stops receiving events from st2 :simple_smile:
until I restart the bot too

A community report. I've run into that issue a couple times, too. Not sure if we should solve in st2client or here.

st2chatops is not reconnecting when auth token expires

After a period of time st2chatops auth token expires and an error is seen in the logs:

$ journalctl -u st2chatops | grep ERROR
Apr 29 03:34:24 stackstorm.domain.tld hubot[108611]: [Sun Apr 29 2018 03:34:24 GMT-0400 (EDT)] ERROR Stream error: Event { type: 'error' }
Apr 29 03:34:26 stackstorm.domain.tld hubot[108611]: [Sun Apr 29 2018 03:34:26 GMT-0400 (EDT)] ERROR Stream error: Event { type: 'error', status: 401 }

After this, the bot responds with ACKs but any chatops.post_messages are not echo'd into ChatOps because it is no longer able to listen on the stream.

For more details and explanation please see the original issue here: StackStorm/st2#4119

Support responding in thread (Slack)

Hi,
I want to confirm if there is plan to support sending response from stackstorm to the command originating thread. Acknowledgement message from Hubot is sent in the same thread but response from chatops.post_message action is sent to channel instead of thread.

Tunable formatting prefix-suffix

Hello.

Can we move hardcoded formatting markdown characters from format_data.js to some kind of configuration file? Not all chat servers support it. I had to temporary remove it for Let's Chat server.

[ansible@dc1udtlhkvm01 lib]$ fgrep -A1 '```' ./*
./format_data.js://    return util.format('```\n%s```', table.toString());
./format_data.js-    return util.format('\n%s', table.toString());
--
./format_data.js://    return util.format('```\n%s\n```', JSON.stringify(data, null, 4));
./format_data.js-    return util.format('\n%s\n', JSON.stringify(data, null, 4));
--
./format_data.js://    return util.format('```\n%s\n```', data);
./format_data.js-    return util.format('\n%s\n', data);

Thanks :)

Help on an alias with parameters shows misleading jinja delimiters

I defined a chatops alias like that:

name: "mypack_doc"
action_ref: "mypack.doc"
description: "Launch a documentation build & upload results on website."
formats:
  - "(doc|docs|dox|docu) {{branch=master}}"

and in the slack channel, when I ask for help, i get that:

stanleyAPP [6:08 PM] 
!(doc|docs|dox|docu) {{branch=master}} - Launch a documentation build & upload results on website.

I think the jinja delimiters {{ and }} should be strippped from the help output, since they are misleading my users who just copy/paste them...

The (|) enabling choice, is less problematic to grasp, apparently...

WDYT ?

Whisper Not Working with Hubot/Hipchat

Executing a "st2 run chatops.post_message message="test" channel="REDACTED" user="REDACTED" whisper=True" command does not result in a whisper message being sent to the user. Logs show a successful run. Executing without the "channel=" value results in error
"'channel' is a required property for url: http://127.0.0.1:9101/v1/executions"

Aliases description is not shown in !help

Hello.

Is it possible to show stackstorm's action-aliases descriptions after their format in hubot's help? Would be nice to give some hints for users. Thanks in advance.

API call to /v1/actionalias fails over HTTPS

Currently, hubot-stackstorm leverages the built-in http client (node-scoped-http-client) to make API calls. This is separate from the authenticate method which uses the request library. Currently the authentication works over https and returns an auth token. However, the subsequent API calls fail over https with the error: unable to verify the first certificate. Perhaps it's better to use the same approach for API calls as is used for authentication?

Currently, the workaround for this is to put the following env into hubot.conf
export NODE_TLS_REJECT_UNAUTHORIZED=0
but this approach is vulnerable to MITM attacks.

Display formatting that contains []'s {{ }}'s do not load into hubot

Just noticed an odd problem, the following display formatting works:

formats:
  - display: "alertlogic scan list [<customer_id>]"
    representation:
      - "alertlogic scan list {{customer_id=0}}"

Which displays via hubot as:

! alertlogic scan list [<customer_id>] - List all the AlertLogic scans for a customer_id to account of key.

However if you combine [ ] with {{var}} as follows:

formats:
  - display: "alertlogic scan list [{{customer_id}}]"
    representation:
      - "alertlogic scan list {{customer_id=0}}"

You get no aliases in Hubot and the hubot logs contain the following:

[Fri Mar 04 2016 15:11:42 GMT+0000 (UTC)] ERROR Failed to retrieve commands from "https://my-st2-server:443/api": Invalid regular expression: /alertlogic scan list [\s*([\s\S]+?)\s*](\s+(\S+)\s*=("([\s\S]*?)"|'([\s\S]*?)'|({[\s\S]*?})|(\S+))\s*)*$/: Unmatched ')'

It very much looks like parsing of display is happening when you include {{ var }} I've always done this as I was following the examples at https://stackstorm.com/2015/12/08/stackstorm-1-2-0-the-new-chatops/.

Jon.

chatops.post_message seems to be ignoring Slack pretext

Originally logged here: StackStorm/st2#4561, @nzlosh suggested I might re-log it here.

SUMMARY

chatops.post_message seems to be ignoring Slack pretext.

ISSUE TYPE

Pick one below and delete the rest:

  • Bug Report
STACKSTORM VERSION

st2 2.10.1, on Python 2.7.6

OS / ENVIRONMENT / INSTALL METHOD

Standard docker install.

STEPS TO REPRODUCE
st2 run chatops.post_message channel=testing message='To get a list of commands type: ```!help```' extra='{"slack": {"color":"#f48527","pretext":"Hey <!channel>, Ready for ChatOps?","title": "Ansible and ChatOps. Get started :rocket:","title_link":"https://stackstorm.com/2015/06/24/ansible-chatops-get-started-%f0%9f%9a%80/","author_name":"by StackStorm - IFTTT for Ops","author_link":"https://stackstorm.com/","author_icon":"https://stackstorm.com/wp/wp-content/uploads/2015/01/favicon.png","image_url":"https://i.imgur.com/HWN8T78.png","fields":[{"title":"Documentation","value":"https://docs.stackstorm.com/chatops/","short":true}]}}' > /dev/null
EXPECTED RESULTS

A pretext line in the Slack channel.

ACTUAL RESULTS

Pretext line missing.

Expose Execution URL as a variable

In some previous ChatOps version the URL with results was always included in message:

Execution Details available at: http://...

In the new and more flexible ChatOps version with formatting and everything it's missing now.

Some tasks could be really long-running and having full execution URL would be nice, so user can include it with own formatted result message (Jinja2 stuff in Action Alias). Ideally to make it available as ready-to use variable.

Hubot feature request

For transparency and clarity on who works with stackstorm via chatops, it would be beneficial to lock down hubot to specific channels, ensuring no one ( except certain users, or workspace admins) are able to add hubot to public/private channels, and disabling the DM functionality.

Feature Request: Action executed in: Xsec

That rather should be placed in st2 repo, but I'll leave it here to track ChatOps issues/features better

There are long-running actions like deploy, provision, VM creation and so on, - all pretty popular ChatOps citizens. Showing how much time did it take to execute an action would be great.

Add action execution time as jinja variable, so it could be used in result templating:

Also, from the user's side it would be nice to have optional way to pretty-format it:

3s, but 1m 20s. You got the point: make it useful, not just: Action executed in 4328 seconds.

Probably creating new Jinja filters for that would work or whatever.

Use new slack "blocks" instead of "attachments"

"attachments" is now legacy. I'm filing this issue so that this is on the radar to figure out what that means for our hubot.

https://api.slack.com/reference/messaging/blocks
https://api.slack.com/reference/messaging/attachments#legacy_fields

Playing around, I can use do something like:

extra:
  slack:
    text: some msg
    attachments:
      - blocks:
          - type: section
            text:
              type: plain_text
              text: section header
          - type: divider

however, this failed

extra:
  slack:
    text: some msg
    attachments:
      - blocks:
          - type: section
            text:
              type: plain_text
              text: section header
          - type: divider
          - type: actions
            elements:
              type: button
              text: windows link to file on NAS
              url: "file://///nas_server/share/path/filename.csv"

Other stuff might be broken as well.

Weird output in chatops

Hello.

Not sure if this is hubot-stackstorm issue or not, but I am getting weirdly formatted output in the slack chatroom:
Weird formatting

However running st2 run action [same action] from console it comes up just fine:
console

Same nice output in WebUI of stackstorm2:
webui

And raw data from the st2 job itself looks fine too (at least I do not see backslashes there marking lines divisioning like in shell scripts when you do not want to have long lines you break them with backslashes):
raw

Could you guys look at it and point out at who's at fault here: stackstorm, hubot-slack or hubot-stackstorm? Thanks in advance.

Support for "Button attachments"

I am not able to send the message with button attachments. If I send simple message{non-attachment message} its working fine. If i send message with extra param from the stackstorm the message is not getting displayed in the channel.

If I have changed the line 137 in post_data.js under lib folder from attachments: content to attachments: content.attachments ? content.attachments : content then the button gets displayed.

Please help on this issue. Is this a right fix

message from stackstorm

action:
  ref: chatops.post_message
  parameters:
    channel: "bq97zw96ypnrjp15h9ey4bhu5o"
    #channel: "#town-square"
    message: "Trying button action"
    extra:
      color: "#ff0000"
      mattermost:
           attachments:
                 - pretext: "This is the attachment pretext."
                   text: "This is the attachment text."
                   actions:
                      - name: "Ephemeral Message"
                        integration:
                              url: "https://x.x.x.x/hubot/buttonaction"
                              context:
                                  action: "do_something_ephemeral"
                      - name: "Update"
                        integration:
                              url: "https://x.x.x.x/hubot/buttonaction"
                              context:
                                  action: "do_something_update"

ERROR Failed to retrieve commands: null

Received this error this AM while provisioning a new node with st2express latest (Atlas Image v0.13).

[Thu Jul 30 2015 18:26:39 GMT+0000 (UTC)] INFO /opt/hubot/hubot/node_modules/hubot-stackstorm/scripts/stackstorm.js is using deprecated documentation syntax
[Thu Jul 30 2015 18:26:39 GMT+0000 (UTC)] DEBUG Successfully authenticated.
[Thu Jul 30 2015 18:26:39 GMT+0000 (UTC)] INFO Loading commands....
[Thu Jul 30 2015 18:26:39 GMT+0000 (UTC)] ERROR Failed to retrieve commands: null

Hubot was setup using st2installer, configured to point to Slack. Aliases are indeed setup and active on the server.

root@st2express:/opt/hubot/hubot# st2 action-alias list
+---------------------------+-------+-----------------------+-------------------------------------+---------+
| ref                       | pack  | name                  | description                         | enabled |
+---------------------------+-------+-----------------------+-------------------------------------+---------+
| hubot.hubot_branch        | hubot | hubot_branch          | Show the currently deployed hubot   | True    |
|                           |       |                       | branch                              |         |
| hubot.hubot_deploy        | hubot | hubot_deploy          | Deploy a specific git branch of     | True    |
|                           |       |                       | deployed Hubot                      |         |
| hubot.hubot_restart       | hubot | hubot_restart         | Restart Hubot                       | True    |
| packs.deploy_pack         | packs | deploy_pack           | Download StackStorm packs via       | True    |
|                           |       |                       | ChatOps                             |         |
| packs.pack_info           | packs | pack_info             | Get StackStorm pack information via | True    |
|                           |       |                       | ChatOps                             |         |
| st2.st2_actions_list      | st2   | st2_actions_list      | List available StackStorm actions.  | True    |
| st2.st2_executions_get    | st2   | st2_executions_get    | Retrieve details for a single       | True    |
|                           |       |                       | execution.                          |         |
| st2.st2_executions_list   | st2   | st2_executions_list   | List available StackStorm           | True    |
|                           |       |                       | executions.                         |         |
| st2.st2_executions_re_run | st2   | st2_executions_re_run | Re-run an action execution.         | True    |
| st2.st2_rules_list        | st2   | st2_rules_list        | List available StackStorm rules.    | True    |
| st2.st2_sensors_list      | st2   | st2_sensors_list      | List available StackStorm sensors.  | True    |
+---------------------------+-------+-----------------------+-------------------------------------+---------+

Hubot v0.2.1, StackStorm version 0.12.0-3

Update st2client.js to support customizing st2stream url

Currently, URL for st2stream is fixed to $ST2_API/stream

This is not ideal if running 1ppc mode in st2-docker because without that, st2chatops need to rely on st2web container running nginx which proxies /api/stream to st2stream backend.

Add tests for #182/#183

#182 was a regression, but we should add a test for that so we don't regress again in the future. Opening this issue to track the status of that.

Want to load commands only for specific pack aliases

This is issue which i solved. This is just info sharing. Please close this issue.
Currently stackstorm.js script loads all enabled aliases of all packs installed in st2. For scaling of hubot necessary to restrict specific packs to specific hubot instance. I might send PR if i have time but basically i did below changes to stackstorm.js . Hope its helpful for someone. Concept is inspired from new environment variable introduced here #133 ST2_ALIAS_PACK_RESTRICTION

In st2chatops.env file:
export ST2_ALIAS_PACK_RESTRICTION=packs,pack1Name,pack2Name

In scripts/stackstorm.js file:
// To restrict adding aliases from only specific packs.
env.ST2_ALIAS_PACK_RESTRICTION = env.ST2_ALIAS_PACK_RESTRICTION || null;

var loadCommands = function() {
robot.logger.info('Loading commands....');

api.actionAlias.list()
  .then(function (aliases) {
    // Remove all the existing commands
    command_factory.removeCommands();
    if (env.ST2_ALIAS_PACK_RESTRICTION) {
    robot.logger.info('Aliases only from following packs will be loaded: ' + env.ST2_ALIAS_PACK_RESTRICTION);
    var packs = env.ST2_ALIAS_PACK_RESTRICTION;
    var packsList = packs.split(","); 
    _.each(aliases, function (alias) {
      if (packsList.indexOf(alias.pack) !== -1){
      var name = alias.name;
      var formats = alias.formats;
      var description = alias.description;

      if (alias.enabled === false) {
        return;
      }

      if (!formats || formats.length === 0) {
        robot.logger.error('No formats specified for command: ' + name);
        return;
      }

      _.each(formats, function (format) {
        var command = formatCommand(robot.logger, name, format.display || format, description);
        command_factory.addCommand(command, name, format.display || format, alias,
                                   format.display ? utils.DISPLAY : false);

        _.each(format.representation, function (representation) {
          command = formatCommand(robot.logger, name, representation, description);
          command_factory.addCommand(command, name, representation, alias, utils.REPRESENTATION);
        });
      });
    }});
    }
    else {
    robot.logger.info('Env variable ST2_ALIAS_PACK_RESTRICTION is not set. No aliases from any pack will be loaded ');
    }
    robot.logger.info(command_factory.st2_hubot_commands.length + ' commands are loaded');
  })
  .catch(function (err) {
    var error_msg = 'Failed to retrieve commands from "%s": %s';
    robot.logger.error(util.format(error_msg, env.ST2_API, err.message));
  });

};

source_channel need to be string and not integer

If the source_channel is not a String, like Telegram, the POST in /api/v1/aliasexecution fail with message:

Nov  6 17:14:40 stackstorm hubot: [Mon Nov 06 2017 17:14:40 GMT-0200 (-02)] DEBUG Sending command payload: {"name":"remote_shell_cmd","format":"(run|execute) {{cmd}} on {{hosts}}","command":"execute date on localhost","user":"test","source_channel":123456,"notification_route":"hubot"}
Nov  6 17:14:40 stackstorm gunicorn: 2017-11-06 17:14:40,374 INFO [-] c278448b-9896-43ed-b0e4-b298d60f9897 - 400 58 181.033ms (content_length=58,request_id='c278448b-9896-43ed-b0e4-b298d60f9897',runtime=181.033,remote_addr='127.0.0.1',status=400,method='POST',path='/v1/aliasexecution')
Nov  6 17:14:40 stackstorm hubot: [Mon Nov 06 2017 17:14:40 GMT-0200 (-02)] ERROR Failed to create an alias execution: { name: 'APIError',
Nov  6 17:14:40 stackstorm hubot: status: 400,
Nov  6 17:14:40 stackstorm hubot: message: '123456 is not of type \'string\'' }

My workarround is edit the file scripts/stackstorm.js and set:

--- chatops/node_modules/hubot-stackstorm/scripts/stackstorm.js 2017-11-06 17:13:59.878000000 -0200
+++ chatops/node_modules/hubot-stackstorm/scripts/stackstorm.edit.js    2017-11-06 17:18:03.657000000 -0200
@@ -266,7 +266,7 @@
         postDataHandler.postData({
           whisper: false,
           user: addressee.name,
-          channel: addressee.room,
+          channel: String(addressee.room),
           message: message,
           extra: {
             color: '#F35A00'
@@ -283,7 +283,7 @@
       'format': format_string,
       'command': command,
       'user': addressee.name,
-      'source_channel': addressee.room,
+      'source_channel': String(addressee.room),
       'notification_route': env.ST2_ROUTE || 'hubot'
     };

@@ -296,7 +296,7 @@
         'parameters': {
           'uuid': twofactor_id,
           'user': addressee.name,
-          'channel': addressee.room,
+          'channel': String(addressee.room),
           'hint': action_alias.description
         }
       });

Disable DM

Hey guys, - newbie here.. is there a way to disable direct messaging hubot on slack to run commands? Would like to keep all comms in a specific channel.

New authentication token should be retrieved when the current one expires

The bot should retrieve a new authentication token when the current one expires - currently it doesn't.

The best solution (imo) for this is to add alias related functionality to st2client.js and handle re-authentication transparently in the client. This way we don't need to reinvent the wheel in 2 places and the client needs and should support this functionality anyways.

Related st2client.js issue - StackStorm/st2client.js#25

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.