-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'smithy-security:main' into main
- Loading branch information
Showing
3,137 changed files
with
2,401,658 additions
and
497 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,42 @@ | ||
# Used only to build Go binaries. | ||
FROM golang:1.23.3 AS builder | ||
|
||
ARG COMPONENT_PATH | ||
ARG COMPONENT_BINARY_SOURCE_PATH | ||
|
||
WORKDIR /wrk | ||
|
||
# Copy only go related files. | ||
COPY ${COMPONENT_PATH} ./ | ||
|
||
# Security hardening and building flags for minimal binaries. | ||
# | ||
# These CGO_CPPFLAGS help preventing overflows. | ||
# Add a small overhead at compile time. | ||
RUN CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all" \ | ||
# Makes memory exploitation harder. | ||
# Add a small overhead at compile time. | ||
GOFLAGS="-buildmode=pie" \ | ||
# CGO_ENABLED=0 \ | ||
GOOS="linux" \ | ||
GOARCH="amd64" \ | ||
go build -ldflags "-s -w" -trimpath -o app ${COMPONENT_BINARY_SOURCE_PATH} | ||
|
||
# Create a workspace to clone repos to. | ||
RUN mkdir -p /workspace | ||
|
||
# Used to actually run the binary in minimal image. | ||
FROM gcr.io/distroless/base-debian12:nonroot | ||
|
||
COPY --from=builder --chown=65534:65534 /wrk/app /bin/app | ||
COPY --from=builder --chown=65534:65534 /workspace /workspace | ||
|
||
# Run as UID for 'nobody' since k8s pod securityContext runAsNonRoot can't resolve the user ID: | ||
# https://github.com/kubernetes/kubernetes/issues/40958 | ||
USER 65534 | ||
|
||
# Setting the workdir where we'll clone repositories. | ||
WORKDIR /workspace | ||
|
||
# Set the binary as the entry point | ||
ENTRYPOINT ["/bin/app"] |
This file contains 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,6 @@ | ||
# This is for local setup only. | ||
SMITHY_INSTANCE_ID=8d719c1c-c569-4078-87b3-4951bd4012ee | ||
SMITHY_LOG_LEVEL=debug | ||
SMITHY_BACKEND_STORE_TYPE=local | ||
CUSTOM_ANNOTATION_NAME=reachability | ||
CUSTOM_ANNOTATION_VALUES={"foo":"bar"} |
This file contains 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 @@ | ||
# custom-annotation | ||
|
||
This component implements an [enricher](https://github.com/smithy-security/smithy/blob/main/sdk/component/component.go) | ||
that adds a custom json annotation to the fetched vulnerability findings associated with the workflow. | ||
|
||
## 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 | | ||
|----------------------------|--------|----------|---------|-------------------------------------------------------------------------| | ||
| CUSTOM\_ANNOTATION\_NAME | string | yes | - | The name of the annotation to be added. | | ||
| CUSTOM\_ANNOTATION\_VALUES | string | no | {} | Json annotations to be added as annotation. For example '{"foo":"bar"}' | | ||
|
||
## 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 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,42 @@ | ||
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/enrichers/custom-annotation/internal/annotation" | ||
) | ||
|
||
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("custom-annotation")) | ||
|
||
cfg, err := annotation.NewConf() | ||
if err != nil { | ||
return errors.Errorf("error reading annotation config: %w", err) | ||
} | ||
|
||
annotator, err := annotation.NewCustomAnnotator(cfg) | ||
if err != nil { | ||
return errors.Errorf("error creating custom annotation annotator: %w", err) | ||
} | ||
|
||
if err := component.RunEnricher(ctx, annotator, opts...); err != nil { | ||
return errors.Errorf("error enriching custom annotation: %w", err) | ||
} | ||
|
||
return nil | ||
} |
10 changes: 10 additions & 0 deletions
10
new-components/enrichers/custom-annotation/docker-compose.yaml
This file contains 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,10 @@ | ||
services: | ||
enricher: | ||
build: | ||
context: ../.. | ||
args: | ||
- COMPONENT_PATH=enrichers/custom-annotation | ||
- COMPONENT_BINARY_SOURCE_PATH=cmd/main.go | ||
platform: linux/amd64 | ||
env_file: | ||
- .env |
This file contains 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,47 @@ | ||
module github.com/smithy-security/smithy/new-components/enrichers/custom-annotation | ||
|
||
go 1.23.2 | ||
|
||
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.2-alpha | ||
github.com/stretchr/testify v1.9.0 | ||
google.golang.org/protobuf v1.35.1 | ||
) | ||
|
||
require ( | ||
github.com/Masterminds/goutils v1.1.1 // indirect | ||
github.com/Masterminds/semver/v3 v3.2.0 // indirect | ||
github.com/Masterminds/sprig/v3 v3.2.3 // indirect | ||
github.com/abice/go-enum v0.6.0 // indirect | ||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/golang/mock v1.6.0 // indirect | ||
github.com/google/uuid v1.6.0 // indirect | ||
github.com/huandu/xstrings v1.3.3 // indirect | ||
github.com/imdario/mergo v0.3.13 // indirect | ||
github.com/jonboulle/clockwork v0.4.0 // indirect | ||
github.com/labstack/gommon v0.4.1 // 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/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.2.0 // indirect | ||
github.com/spf13/cast v1.3.1 // indirect | ||
github.com/urfave/cli/v2 v2.26.0 // indirect | ||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect | ||
go.uber.org/mock v0.5.0 // indirect | ||
golang.org/x/crypto v0.3.0 // indirect | ||
golang.org/x/mod v0.18.0 // indirect | ||
golang.org/x/sync v0.8.0 // indirect | ||
golang.org/x/sys v0.21.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
golang.org/x/tools v0.22.0 // indirect | ||
golang.org/x/tools/cmd/cover v0.1.0-deprecated // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
Oops, something went wrong.