Skip to content

introduce the --dryrun option to the notify command #43

Merged
hiboma merged 2 commits intomainfrom
notify-dryrun
Apr 16, 2025
Merged

introduce the --dryrun option to the notify command #43
hiboma merged 2 commits intomainfrom
notify-dryrun

Conversation

@hiboma
Copy link
Contributor

@hiboma hiboma commented Apr 16, 2025

If --dryrun is specified for notify, JSON is output to stdout without slack notification

notify に --dryrun を指定すると、緩やかな通知を行わずに、JSON を標準出力に出力します。

use case

After setting the exclusion in findings, use -dryrun to make sure that slack notifications are also excluded as intended.

findings に除外設定を入れた後に、slack 通知でも意図した通りに除外されているかを確かめるために —dryrun を用います

sample

$ ./control-controls notify controls/base.yml --overlay controls/foo.yml --stdout
{
  "blocks": [
    {
      "text": {
        "text": "*AWS Security Hub Notification*",
        "type": "mrkdwn"
      },
      "type": "section"
    },
    {
      "text": {
        "text": "CRITICALラベルのコントロールが存在します",
        "type": "mrkdwn"
      },
      "type": "section"
    },
    {
      "fields": [
        {
          "text": "*CRITICAL:*\n2",
          "type": "mrkdwn"
        },
        {
          "text": "*HIGH:*\n51",
          "type": "mrkdwn"
        }
      ],
      "type": "section"
    },
    {
      "fields": [
        {
          "text": "*MEDIUM:*\n203",
          "type": "mrkdwn"
        },
        {
          "text": "*LOW:*\n242",
          "type": "mrkdwn"
        }
      ],
      "type": "section"
    },
    {
      "text": {
        "text": "<https://ap-northeast-1.console.aws.amazon.com/securityhub/home?region=ap-northeast-1#/findings?search=*****|View findings>",
        "type": "mrkdwn"
      },
      "type": "section"
    }
  ]
}

… to stdout without sending a slack notification
@hiboma hiboma added the enhancement New feature or request label Apr 16, 2025
@hiboma hiboma self-assigned this Apr 16, 2025
@github-actions

This comment has been minimized.

@hiboma hiboma requested a review from n01e0 April 16, 2025 07:28
@hiboma hiboma marked this pull request as ready for review April 16, 2025 07:30
@github-actions
Copy link
Contributor

Code Metrics Report

Coverage Code to Test Ratio Test Execution Time
31.7% 1:0.4 4s

Code coverage of files in pull request scope (50.4%)

Files Coverage
cmd/notify.go 0.0%
sechub/notify.go 83.5%

Reported by octocov

@hiboma hiboma merged commit bce47f9 into main Apr 16, 2025
1 check passed
@hiboma hiboma deleted the notify-dryrun branch April 16, 2025 08:52
@github-actions github-actions bot mentioned this pull request Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants