-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert the pdf consumer into the new SDK
add the instance ID to the report name formatting formatting fix tests
- Loading branch information
Showing
17 changed files
with
1,012 additions
and
1,131 deletions.
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 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,9 @@ | ||
SMITHY_INSTANCE_ID=8d719c1c-c569-4078-87b3-4951bd4012ee | ||
SMITHY_LOG_LEVEL=debug | ||
AWS_ACCESS_KEY_ID='' | ||
AWS_SECRET_ACCESS_KEY='' | ||
BUCKET_NAME='pdf-consumer-test' | ||
BUCKET_REGION='eu-north-1' | ||
SKIP_S3_UPLOAD=false | ||
SMITHY_STORE_TYPE=postgresql | ||
SMITHY_REMOTE_STORE_POSTGRES_DSN="postgresql://smithy:smithy1234@findings-db:5432/findings-db?sslmode=disable&connect_timeout=10" |
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,20 @@ | ||
FROM golang:1.23.3 AS builder | ||
COPY . /workdir | ||
WORKDIR /workdir | ||
# Install Playwright CLI with the correct version | ||
RUN go install github.com/playwright-community/playwright-go/cmd/[email protected] | ||
# Build your Go application | ||
RUN GOOS=linux GOARCH=amd64 go build -o /bin/reporter cmd/main.go | ||
|
||
# Stage 3: Final image | ||
FROM ubuntu:22.04 | ||
|
||
COPY --from=builder /bin/reporter / | ||
COPY --from=builder /go/ /go/ | ||
|
||
RUN apt-get update | ||
RUN apt-get install -y ca-certificates tzdata | ||
RUN ./go/bin/playwright install chromium --with-deps | ||
RUN rm -rf /var/lib/apt/lists/* | ||
|
||
CMD ["/reporter"] |
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,39 @@ | ||
|
||
This component implements | ||
a [reporter](https://github.com/smithy-security/smithy/blob/main/sdk/component/component.go) | ||
that prints vulnerability findings into a PDF and uploads it to an AWS | ||
S3 bucket. | ||
|
||
## 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 the following: | ||
|
||
| Environment Variable | Type | Required | Default | Description | | ||
|-----------------------|--------|----------|---------|----------------------------------------------------------------------| | ||
| AWS\_ACCESS\_KEY\_ID | string | yes | - | Your S3 access key ID for a user that has write access to the bucket | | ||
| AWS\_SECRET\_ACCESS\_KEY | string | yes | - | Your S3 access key for a user that has write access to the bucket | | ||
| BUCKET\_NAME | string | yes | - | Your S3 bucket name, e.g. "test-bucket" | | ||
| BUCKET\_REGION | string | yes | - | Your S3 bucket region, e.g. "us-west-1" | | ||
|
||
On AWS, you will need a new IAM user with programmatic access and | ||
with write permissions for your S3 bucket. | ||
|
||
## 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,40 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"time" | ||
|
||
"github.com/go-errors/errors" | ||
|
||
"github.com/smithy-security/smithy/new-components/reporters/pdf/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 { | ||
conf, err := reporter.NewConf(nil) | ||
if err != nil { | ||
return errors.Errorf("could not create new configuration: %w", err) | ||
} | ||
|
||
opts = append(opts, component.RunnerWithComponentName("pdf")) | ||
|
||
if err := component.RunReporter( | ||
ctx, | ||
reporter.NewReporter(conf), | ||
opts..., | ||
); err != nil { | ||
return errors.Errorf("could not run reporter: %w", err) | ||
} | ||
|
||
return nil | ||
} |
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,11 @@ | ||
services: | ||
reporter: | ||
build: | ||
context: . | ||
dockerfile: Dockerfile | ||
args: | ||
- COMPONENT_PATH=reporters/pdf | ||
- COMPONENT_BINARY_SOURCE_PATH=cmd/main.go | ||
platform: linux/amd64 | ||
env_file: | ||
- .env |
Oops, something went wrong.