Server.Notification.Mastodon

Create a post on a Mastodon server. This could be used for automated alerting purposes, sharing IOCs, etc.

This artifact can be called from within another artifact to include data from the artifact results in the message/status.

This could also be turned into a server event artifact to send a notification or post to Mastodon when a particular event occurs.

Ex.

SELECT * from Artifact.Server.Notification.Mastodon(Status=YourMessage/Status)


name: Server.Notification.Mastodon
author: Wes Lambert -- @therealwlambert
description: |
  Create a post on a Mastodon server. This could be used for automated alerting purposes, sharing IOCs, etc.

  This artifact can be called from within another artifact to include data from the artifact results in the message/status.
  
  This could also be turned into a server event artifact to send a notification or post to Mastodon when a particular event occurs.

  Ex.

    `SELECT * from Artifact.Server.Notification.Mastodon(Status=YourMessage/Status)`

type: SERVER

parameters:
    - name: Status
      type: string
      description: The message/status to be posted to Mastodon.
      default:
    
    - name: MastodonServer
      type: string
      description: Mastodon server. Leave blank here if using server metadata store.
      default:

    - name: MastodonToken
      type: string
      description: Token for Mastodon. Leave blank here if using server metadata store.
      default:

sources:
  - query: |
        LET Creds <= if(
            condition=MastodonToken,
            then=MastodonToken,
            else=server_metadata().MastodonToken)
        
        LET Server <= if(
            condition=MastodonServer,
            then=MastodonServer,
            else=server_metadata().MastodonServer)

        SELECT * FROM http_client(
            url='https://'+ Server +'/api/v1/statuses',
            headers=dict(`Authorization`='Bearer ' + Creds, `Content-Type`="application/json"),
            method="POST",
            data=dict(`status`=Status)
        )