New Sink: Webex - #560
Conversation
* Added webex_sink * Bug fix with fileblocks, code refactoring, documentation add and minor bug fixes
Job Action Added
|
Hey, thanks for the PR! We're a little behind schedule due to the holidays. Just want to say thank you and that we haven't forgotten about this. |
| python-versions = ">=3.5" | ||
|
|
||
| [package.extras] | ||
| dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy (>=0.900,!=0.940)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "sphinx", "sphinx-notfound-page", "zope.interface"] |
There was a problem hiding this comment.
what command did you use to update the dependencies?
There was a problem hiding this comment.
poetry lock --no-update
|
|
||
|
|
||
| INVESTIGATE_ICON = "\U0001F50E" | ||
| SILENCE_ICON = "\U0001F515" |
There was a problem hiding this comment.
You can switch these with the actual icons , 🔕🔎 just a syntactic sugar
There was a problem hiding this comment.
Updated. Let me know if its ok or anything needs to be changed.
| ATTACHMENT_CONTENT_TYPE = "application/vnd.microsoft.card.adaptive" | ||
|
|
||
| CARD_TYPES = { | ||
| 1: "AdaptiveCard", |
There was a problem hiding this comment.
I think an enum could be more suitable instead of these dicts. you could use string enums as well
There was a problem hiding this comment.
Updated. Let me know if its ok or anything needs to be changed.
|
|
||
| return message_content, table_blocks, file_blocks, description | ||
|
|
||
| def _create_pdf(self, file_blocks: List[FileBlock]): |
There was a problem hiding this comment.
I tested the sink, and the PDF workaround does not seem to work (I've added an image). To be honest, while the idea is clever, it is also very fragile. Also complicates the code.
I suggest we lose that part and send all the files separately with different messages or stop at the limit. Hopefully, they will add multifile support soon.
I didn't take it lightly but I think it will be a better approach
There was a problem hiding this comment.
I will update it and send the files separately.
There was a problem hiding this comment.
Updated. Let me know if its ok or anything needs to be changed.
| adaptive_card["body"] = [message_content_container] | ||
|
|
||
| #Parsing table blocks for adaptive card | ||
| if table_blocks: |
There was a problem hiding this comment.
The table block has an to_markdown option as well , might work here as well?
I would take that table code to a different function if not just to separate the logic
There was a problem hiding this comment.
Yes I tried to send the table using markdown but the rows and columns were not aligned properly thats why used adaptive cards to send table. I will separate the logic.
There was a problem hiding this comment.
Updated. Let me know if its ok or anything needs to be changed.
Thanks for reviewing
* Added webex_sink * Bug fix with fileblocks, code refactoring, documentation add and minor bug fixes * Added Enums and replaced emoji code with emoji icons
… function. (#7) * Added webex_sink * Bug fix with fileblocks, code refactoring, documentation add and minor bug fixes * Added Enums and replaced emoji code with emoji icons * Removed PDF functionality and seperated JSON creation logic from the adaptivecard function logic * Formatted using Black
| # This function sends the files individually to webex | ||
| for blocks in files: | ||
| file_type = ( | ||
| FileTypes.PHOTO if is_image(blocks.filename) else FileTypes.DOCUMENT |
There was a problem hiding this comment.
It seems this enum is reduandent here, you could just check is_image
There was a problem hiding this comment.
Updated. Let me know if its ok or anything needs to be changed.
| file_type = ( | ||
| FileTypes.PHOTO if is_image(blocks.filename) else FileTypes.DOCUMENT | ||
| ) | ||
| if file_type is FileTypes.DOCUMENT: |
There was a problem hiding this comment.
I just want to make sure if you tried to use the same logic in the Slack sink for the files.
there is this function which you can apply on the files to convert to png. ( which will save the image handling you do)
https://github.com/robusta-dev/robusta/blob/master/src/robusta/core/reporting/utils.py#L36
Also using the tempFile for the files you upload, such as here
https://github.com/robusta-dev/robusta/blob/master/src/robusta/integrations/slack/sender.py#L141
It seems to save the extra handle between image/nonimage
There was a problem hiding this comment.
Updated. Let me know if its ok or anything needs to be changed.
I was using the logic used in telegram sink used in send_file function.
Thanks for linking the files and helping on how to improve the code. ❤️ .
RoiGlinik
left a comment
There was a problem hiding this comment.
Hey @alikhanxgrid Great Work.
I tested it looks good,
I forgot some minor changes regarding the files but after that, it's good to go
Thanks for the hard work 👍
* Added webex_sink * Bug fix with fileblocks, code refactoring, documentation add and minor bug fixes * Added Enums and replaced emoji code with emoji icons * Removed PDF functionality and seperated JSON creation logic from the adaptivecard function logic * Formatted using Black * Changes in _send_files and _separate_blocks function
* Added webex_sink * Bug fix with fileblocks, code refactoring, documentation add and minor bug fixes * Added Enums and replaced emoji code with emoji icons * Removed PDF functionality and seperated JSON creation logic from the adaptivecard function logic * Formatted using Black * Changes in _send_files and _separate_blocks function

Issue
New Sink: Webex
Description
This PR integrates Webex as a sink to Robusta. Main logic of sending Findings to Webex is in sender.py file. The docs/ folder contain the instructions for configuring Webex with your Robusta deployment.
Checklist
README.md, or thedocsdirectory)