Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
[!IMPORTANT] This repository is only sporadically maintained. Breaking API changes will be maintained on a best efforts basis.
Collaborators are welcome, as are PRs for enhancements.
Bug reports unrelated to API changes may not get the attention you want.
By using this module, you can create a Webex Teams messaging bot quickly in just a couple of lines of code.
This module does not require you to set up an ngrok tunnel to receive incoming messages when behind a firewall or inside a LAN. This package instead uses a websocket to receive messages from the Webex cloud.
You can find a sample project, using OpenAI/ChatGPT with this library here: https://github.com/fbradyirl/openai_bot
Only Python 3.9 is tested at this time.
pip install webex_bot
If you need optional proxy support, use this command instead:
pip install webex_bot[proxy]
export WEBEX_TEAMS_ACCESS_TOKEN=<your bots token>
python example.py
See example.py for details:
import os
from webex_bot.commands.echo import EchoCommand
from webex_bot.webex_bot import WebexBot
# (Optional) Proxy configuration
# Supports https or wss proxy, wss prioritized.
proxies = {
'https': 'http://proxy.esl.example.com:80',
'wss': 'socks5://proxy.esl.example.com:1080'
}
# Create a Bot Object
bot = WebexBot(teams_bot_token=os.getenv("WEBEX_TEAMS_ACCESS_TOKEN"),
approved_rooms=['06586d8d-6aad-4201-9a69-0bf9eeb5766e'],
bot_name="My Teams Ops Bot",
include_demo_commands=True,
proxies=proxies)
# Add new commands for the bot to listen out for.
bot.add_command(EchoCommand())
# Call `run` for the bot to wait for incoming messages.
bot.run()
where EchoCommand is defined as:
import logging
from webexteamssdk.models.cards import Colors, TextBlock, FontWeight, FontSize, Column, AdaptiveCard, ColumnSet, \
Text, Image, HorizontalAlignment
from webexteamssdk.models.cards.actions import Submit
from webex_bot.formatting import quote_info
from webex_bot.models.command import Command
from webex_bot.models.response import response_from_adaptive_card
log = logging.getLogger(__name__)
class EchoCommand(Command):
def __init__(self):
super().__init__(
command_keyword="echo",
help_message="Echo Words Back to You!",
chained_commands=[EchoCallback()])
def pre_execute(self, message, attachment_actions, activity):
"""
(optional function).
Reply before running the execute function.
Useful to indicate the bot is handling it if it is a long running task.
:return: a string or Response object (or a list of either). Use Response if you want to return another card.
"""
image = Image(url="https://i.postimg.cc/2jMv5kqt/AS89975.jpg")
text1 = TextBlock("Working on it....", weight=FontWeight.BOLDER, wrap=True, size=FontSize.DEFAULT,
horizontalAlignment=HorizontalAlignment.CENTER, color=Colors.DARK)
text2 = TextBlock("I am busy working on your request. Please continue to look busy while I do your work.",
wrap=True, color=Colors.DARK)
card = AdaptiveCard(
body=[ColumnSet(columns=[Column(items=[image], width=2)]),
ColumnSet(columns=[Column(items=[text1, text2])]),
])
return response_from_adaptive_card(card)
def execute(self, message, attachment_actions, activity):
"""
If you want to respond to a submit operation on the card, you
would write code here!
You can return text string here or even another card (Response).
This sample command function simply echos back the sent message.
:param message: message with command already stripped
:param attachment_actions: attachment_actions object
:param activity: activity object
:return: a string or Response object (or a list of either). Use Response if you want to return another card.
"""
text1 = TextBlock("Echo", weight=FontWeight.BOLDER, size=FontSize.MEDIUM)
text2 = TextBlock("Type in something here and it will be echo'd back to you. How useful is that!",
wrap=True, isSubtle=True)
input_text = Text(id="message_typed", placeholder="Type something here", maxLength=30)
input_column = Column(items=[input_text], width=2)
submit = Submit(title="Submit",
data={
"callback_keyword": "echo_callback"})
card = AdaptiveCard(
body=[ColumnSet(columns=[Column(items=[text1, text2], width=2)]),
ColumnSet(columns=[input_column]),
], actions=[submit])
return response_from_adaptive_card(card)
class EchoCallback(Command):
def __init__(self):
super().__init__(
card_callback_keyword="echo_callback",
delete_previous_message=True)
def execute(self, message, attachment_actions, activity):
return quote_info(attachment_actions.inputs.get("message_typed"))
echo
and off you go!
execute
functions to include the extra activity
parameter. def execute(self, message, attachment_actions, activity):
log.info(
f"activity={activity} ")
email = activity["actor"]['emailAddress']
return quote_info(f"person email is '{email}'")
pre_execute
function to Command. (optional function to overide). Reply before running the execute function.
Useful to indicate the bot is handling it if it is a long running task.pre_card_load_reply
overide. Reply before sending the initial card. Useful if it takes a long time
for the card to load.chained_commands
as a parameter of Command. This allows multiple related cards to be added at once.FAQs
Python package for a Webex Bot based on websockets.
We found that webex-bot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.