Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Rule show value of Secret Action Field #6125

Open
philipphomberger opened this issue Feb 6, 2024 · 0 comments
Open

Disable Rule show value of Secret Action Field #6125

philipphomberger opened this issue Feb 6, 2024 · 0 comments

Comments

@philipphomberger
Copy link

SUMMARY

Provide a quick summary of your bug report.

STACKSTORM VERSION

Paste the output of st2 --version:
st2 3.8.1

OS, environment, install method

Post what OS you are running this on, along with any other relevant information/

Deploy with Ansible
RHEL8 VM

Description

If you create a rule and configure the webhook for the Teams channel (Secret field), the URL is masked and that's what it's supposed to be.
If you deactivate the rule and refresh the page, the webhook URL is displayed in plain text
And vice versa, i.e. if the rule is deactivated and you enter the page again, the url is masked, but is displayed in plain text again when activated (+refresh). And the URL is corrupted. You have to copy the webhook-url again, only then the rule works again.

Teams channel Action and YAML File:

YAML

---
name: "send_teams_message"
runner_type: "python-script"
description: "Send Message to Teams Channel."
enabled: true
entry_point: "send_teams_message.py"
parameters:
    webhook_url:
        type: "string"
        description: "Webhook Teamschannel Integration."
        required: true
        secret: true
        position: 0
    sectionTitle:
        type: "string"
        description: "Webhook Teamschannel Integration."
        required: true
        default: "Groot Agent: Groot have fix Test"
        position: 1
    activityTitle:
        type: "string"
        description: "Webhook Teamschannel Integration."
        default: "activityTitle"
        required: true
        position: 2
    activitySubtitle:
        type: "string"
        description: "Webhook Teamschannel Integration."
        required: true
        default: "activitySubtitle"
        position: 3
    activityText:
        type: "string"
        description: "Webhook Teamschannel Integration."
        required: true
        default: "activityText"
        position: 4
    text:
        type: "string"
        description: "Webhook Teamschannel Integration."
        required: true
        default: "Text"
        position: 5

Action:

import pymsteams
from lib.base import BaseActionMsTeams


class send_teams_message(BaseActionMsTeams):
    def getTeamsMessage(
        self, sectionTitle, activityTitle, activitySubtitle, activityText, text
    ):
        myMessageSection = pymsteams.cardsection()
        myMessageSection.title(sectionTitle)
        myMessageSection.activityTitle(activityTitle)
        myMessageSection.activitySubtitle(activitySubtitle)
        myMessageSection.activityImage(
            "https://avatars.githubusercontent.com/u/4969009?s=200&v=4"
        )
        myMessageSection.activityText(activityText)
        myMessageSection.text(text)
        myMessageSection.addImage(
            "https://avatars.githubusercontent.com/u/4969009?s=200&v=4",
            ititle="Stackstorm Logo",
        )
        return myMessageSection

    def sendTeamsMessage(self, webhook_url, myMessageSection):
        myTeamsMessage = pymsteams.connectorcard(webhook_url)

        myTeamsMessage.addSection(myMessageSection)
        myTeamsMessage.summary("I am GROOT!")
        myTeamsMessage.send()
        last_status_code = myTeamsMessage.last_http_response.status_code
        return last_status_code

    def run(
        self,
        webhook_url,
        sectionTitle,
        activityTitle,
        activitySubtitle,
        activityText,
        text,
    ):
        if webhook_url == "none":
            webhook_url = self.web_hook_global
        teams_section = self.getTeamsMessage(
            sectionTitle, activityTitle, activitySubtitle, activityText, text
        )
        teams_message = self.sendTeamsMessage(webhook_url, teams_section)

        if teams_message == 200:
            return (True, teams_message)
        else:
            print(teams_message)
            raise ValueError(f"Sending failes.")
```

Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant