-
Notifications
You must be signed in to change notification settings - Fork 15
Slack to new sdk #727
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
Closed
Closed
Slack to new sdk #727
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/go-errors/errors" | ||
|
||
"github.com/smithy-security/smithy/new-components/reporters/slack/internal/reporter" | ||
"github.com/smithy-security/smithy/sdk/component" | ||
) | ||
|
||
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 | ||
} | ||
c := http.Client{} | ||
slackLogger, err := reporter.NewSlackLogger(config, &c) | ||
if err != nil { | ||
return err | ||
} | ||
if err := component.RunReporter( | ||
ctx, | ||
slackLogger, | ||
opts..., | ||
); err != nil { | ||
return errors.Errorf("could not run reporter: %w", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: slack | ||
description: "Logs findings to slack" | ||
type: reporter | ||
parameters: | ||
- name: slack_webhook | ||
type: string | ||
value: "" | ||
steps: | ||
- name: | ||
image: "new-components/reporters/slack" | ||
env_vars: | ||
- SLACK_WEBHOOK: {{ .parameters.slack_webhook }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/sdk v0.0.5-alpha | ||
github.com/stretchr/testify v1.10.0 | ||
google.golang.org/protobuf v1.36.5 | ||
) | ||
|
||
require ( | ||
ariga.io/atlas v0.32.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.6 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/go-openapi/inflect v0.21.2 // indirect | ||
github.com/golang/mock v1.6.0 // indirect | ||
github.com/google/go-cmp v0.7.0 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/hashicorp/hcl/v2 v2.23.0 // indirect | ||
github.com/huandu/xstrings v1.5.0 // indirect | ||
github.com/jackc/pgpassfile v1.0.0 // indirect | ||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect | ||
github.com/jackc/pgx/v5 v5.7.2 // indirect | ||
github.com/jonboulle/clockwork v0.5.0 // indirect | ||
github.com/labstack/gommon v0.4.2 // indirect | ||
github.com/mattn/go-colorable v0.1.14 // 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.1 // indirect | ||
github.com/sqlc-dev/sqlc v1.28.0 // indirect | ||
github.com/urfave/cli/v2 v2.27.6 // indirect | ||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect | ||
github.com/zclconf/go-cty v1.16.2 // indirect | ||
github.com/zclconf/go-cty-yaml v1.1.0 // indirect | ||
go.uber.org/mock v0.5.0 // indirect | ||
golang.org/x/crypto v0.36.0 // indirect | ||
golang.org/x/mod v0.24.0 // indirect | ||
golang.org/x/net v0.37.0 // indirect | ||
golang.org/x/sync v0.12.0 // indirect | ||
golang.org/x/sys v0.31.0 // indirect | ||
golang.org/x/text v0.23.0 // indirect | ||
golang.org/x/tools v0.31.0 // indirect | ||
golang.org/x/tools/cmd/cover v0.1.0-deprecated // indirect | ||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 // indirect | ||
google.golang.org/grpc v1.71.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.