Skip to content

Commit

Permalink
s3 consumer done
Browse files Browse the repository at this point in the history
  • Loading branch information
northdpole committed Oct 14, 2023
1 parent 4fd2f51 commit d75047d
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 10 deletions.
1 change: 1 addition & 0 deletions components/consumers/aws-s3/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ go_binary(
srcs = [
"main.go",
],
static = True,
deps = [
"//api/proto/v1",
"//components/consumers",
Expand Down
18 changes: 18 additions & 0 deletions components/consumers/aws-s3/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ patches:
workspaces:
- name: source-code-ws
workspace: source-code-ws
params:
- name: consumer-aws-s3-access-key-id
value: $(params.consumer-aws-s3-access-key-id)
- name: consumer-aws-s3-secret-access-key
value: $(params.consumer-aws-s3-secret-access-key)
- name: consumer-aws-s3-bucket-name
value: $(params.consumer-aws-s3-bucket-name)
- name: consumer-aws-s3-bucket-region
value: $(params.consumer-aws-s3-bucket-region)
params:
- name: consumer-aws-s3-access-key-id
type: string
- name: consumer-aws-s3-secret-access-key
type: string
- name: consumer-aws-s3-bucket-name
type: string
- name: consumer-aws-s3-bucket-region
type: string
target:
kind: Pipeline
# Add anchors to Task.
Expand Down
6 changes: 3 additions & 3 deletions components/consumers/aws-s3/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var (
func main() {
flag.StringVar(&bucket, "bucket", "", "s3 bucket name")
flag.StringVar(&region, "region", "", "s3 bucket region")

if err := consumers.ParseFlags(); err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -50,10 +49,11 @@ func main() {
sendToS3(filename, bucket, region, s3Data)
}
}
func sendToS3(filename, bucket, region string, data []byte) {

func sendToS3(filename, bucket, region string, data []byte) {
sess, err := session.NewSession(&aws.Config{
Region: aws.String(region)},
Region: aws.String(region),
},
)
uploader := s3manager.NewUploader(sess)
_, err = uploader.Upload(&s3manager.UploadInput{
Expand Down
40 changes: 33 additions & 7 deletions components/consumers/aws-s3/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,40 @@ metadata:
labels:
v1.dracon.ocurity.com/component: consumer
spec:
volumes:
- name: scratch
emptyDir: {}
params:
- name: consumer-aws-s3-access-key-id
type: string
- name: consumer-aws-s3-secret-access-key
type: string
- name: consumer-aws-s3-bucket-name
type: string
- name: consumer-aws-s3-bucket-region
type: string
workspaces:
- name: source-code-ws
description: The workspace containing the source-code to scan.
steps:
- name: run-consumer
imagePullPolicy: IfNotPresent
image: ghcr.io/ocurity/dracon/components/consumers/aws-s3/image:latest
command: ["/app/components/consumers/aws-s3/aws-s3"]
args:
- "-in"
- "$(workspaces.source-code-ws.path)/.dracon/enrichers/"
- name: run-consumer
imagePullPolicy: IfNotPresent
image: ghcr.io/ocurity/dracon/components/consumers/aws-s3/image:latest
env:
- name: AWS_ACCESS_KEY_ID
value: "$(params.consumer-aws-s3-access-key-id)"
- name: AWS_SECRET_ACCESS_KEY
value: "$(params.consumer-aws-s3-secret-access-key)"
command: ["/app/components/consumers/aws-s3/aws-s3"]
args:
[
"-in",
"$(workspaces.source-code-ws.path)/.dracon/enrichers/",
"-bucket",
"$(params.consumer-aws-s3-bucket-name)",
"-region",
"$(params.consumer-aws-s3-bucket-region)",
]
volumeMounts:
- mountPath: /scratch
name: scratch
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/DependencyTrack/client-go v0.8.0
github.com/andygrunwald/go-jira v1.15.1
github.com/avast/retry-go/v4 v4.3.3
github.com/aws/aws-sdk-go v1.17.7
github.com/elastic/go-elasticsearch/v8 v8.3.0
github.com/golang-migrate/migrate/v4 v4.15.1
github.com/golang/protobuf v1.5.2
Expand Down Expand Up @@ -44,6 +45,7 @@ require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/asmfmt v1.3.2 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:l
github.com/avast/retry-go/v4 v4.3.3 h1:G56Bp6mU0b5HE1SkaoVjscZjlQb0oy4mezwY/cGH19w=
github.com/avast/retry-go/v4 v4.3.3/go.mod h1:rg6XFaiuFYII0Xu3RDbZQkxCofFwruZKW8oEF1jpWiU=
github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
github.com/aws/aws-sdk-go v1.17.7 h1:/4+rDPe0W95KBmNGYCG+NUvdL8ssPYBMxL+aSCg6nIA=
github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go-v2 v1.8.0/go.mod h1:xEFuWz+3TYdlPRuo+CqATbeDWIWyaT5uAPwPaWtgse0=
github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4=
Expand Down Expand Up @@ -659,7 +660,9 @@ github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
github.com/jmoiron/sqlx v1.3.1/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ=
Expand Down

0 comments on commit d75047d

Please sign in to comment.