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

Slack to new sdk #727

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions new-components/reporters/slack/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is for local setup only.
SMITHY_INSTANCE_ID=8d719c1c-c569-4078-87b3-4951bd4012ee
SMITHY_LOG_LEVEL=debug
SLACK_WEBHOOK=""
30 changes: 30 additions & 0 deletions new-components/reporters/slack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# slack

This component implements a [reporter](https://github.com/smithy-security/smithy/blob/main/sdk/component/component.go)
that sends a summary of results to slack.

## Environment variables

The component uses environment variables for configuration.

It requires the component
environment variables defined [here](https://github.com/smithy-security/smithy/blob/main/sdk/README.md#component).
as well as the following:

| Environment Variable | Type | Required | Default | Description |
|----------------------------|--------|----------|---------|-------------------------------------------------------------------------|
| SLACK\_WEBHOOK | string | yes | - | The slack webhook to POST results to|

## How to run

Execute:

```shell
docker-compose up --build --force-recreate --remove-orphans
```

Then shutdown with:

```shell
docker-compose down --rmi all
```
39 changes: 39 additions & 0 deletions new-components/reporters/slack/cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"context"
"log"
"time"

"github.com/go-errors/errors"

"github.com/smithy-security/smithy/sdk/component"

"github.com/smithy-security/smithy/new-components/reporters/slack/internal/reporter"
)

func main() {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancel()

if err := Main(ctx); err != nil {
log.Fatalf("unexpected error: %v", err)
}
}

func Main(ctx context.Context, opts ...component.RunnerOption) error {
opts = append(opts, component.RunnerWithComponentName("slack"))
config, err := reporter.NewConf(nil)
if err != nil {
return err
}
if err := component.RunReporter(
ctx,
reporter.NewSlackLogger(config),
opts...,
); err != nil {
return errors.Errorf("could not run reporter: %w", err)
}

return nil
}
10 changes: 10 additions & 0 deletions new-components/reporters/slack/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
reporter:
build:
context: ../..
args:
- COMPONENT_PATH=reporters/json-logger
- COMPONENT_BINARY_SOURCE_PATH=cmd/main.go
platform: linux/amd64
env_file:
- .env
64 changes: 64 additions & 0 deletions new-components/reporters/slack/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module github.com/smithy-security/smithy/new-components/reporters/slack

go 1.23.3

require (
github.com/go-errors/errors v1.5.1
github.com/smithy-security/pkg/env v0.0.1
github.com/smithy-security/smithy/new-components/reporters/json-logger v0.0.0-20250129163355-efa198ee139a
github.com/smithy-security/smithy/sdk v0.0.4-alpha
github.com/stretchr/testify v1.10.0
google.golang.org/protobuf v1.36.4
)

require (
ariga.io/atlas v0.29.0 // indirect
dario.cat/mergo v1.0.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.3.1 // indirect
github.com/Masterminds/sprig/v3 v3.3.0 // indirect
github.com/abice/go-enum v0.6.0 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/bmatcuk/doublestar v1.3.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/hcl/v2 v2.18.1 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.6.0 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-sqlite3 v1.14.24 // indirect
github.com/mattn/goveralls v0.0.12 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/cast v1.7.0 // indirect
github.com/sqlc-dev/sqlc v1.27.0 // indirect
github.com/urfave/cli/v2 v2.27.5 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/zclconf/go-cty v1.14.4 // indirect
go.uber.org/mock v0.5.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.28.0 // indirect
golang.org/x/tools/cmd/cover v0.1.0-deprecated // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.65.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading