Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion operator/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![operator logo](https://docs.securecodebox.io/img/Logo_Color.svg)

The secureCodeBox operator is runniing on kubernetes and the core component of the complete secureCodeBox stack, responsible for operating all scans and ressources.
The secureCodeBox operator is running on kubernetes and the core component of the complete secureCodeBox stack, responsible for managing all scans and resources.

<!-- end -->

Expand Down Expand Up @@ -32,6 +32,8 @@ helm install securecodebox-operator secureCodeBox/operator
| minio.enabled | bool | `true` | |
| minio.resources.requests.memory | string | `"256Mi"` | |
| resources | object | `{"limits":{"cpu":"100m","memory":"30Mi"},"requests":{"cpu":"100m","memory":"20Mi"}}` | CPU/memory resource requests/limits (see: https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/, https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/) |
| s3.authType | string | `"access-secret-key"` | Authentication method. Supports access-secret-key (used by most s3 endpoint) and aws-irsa (Used by AWS EKS IAM Role to Kubenetes Service Account Binding. Support for AWS IRSA is considered experimental in the secureCodeBox) |
| s3.awsStsEndpoint | string | `"https://sts.amazonaws.com"` | STS Endpoint used in AWS IRSA Authentication. Change this to the sts endpoint of your aws region. Only used when s3.authType is set to "aws-irsa" |
| s3.bucket | string | `"my-bucket"` | |
| s3.enabled | bool | `false` | |
| s3.endpoint | string | `"fra1.digitaloceanspaces.com"` | |
Expand Down
2 changes: 1 addition & 1 deletion operator/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![operator logo](https://docs.securecodebox.io/img/Logo_Color.svg)

The secureCodeBox operator is runniing on kubernetes and the core component of the complete secureCodeBox stack, responsible for operating all scans and ressources.
The secureCodeBox operator is running on kubernetes and the core component of the complete secureCodeBox stack, responsible for managing all scans and resources.

<!-- end -->

Expand Down
32 changes: 24 additions & 8 deletions operator/controllers/execution/scans/scan_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net/url"
"os"
"strings"
"time"

"github.com/go-logr/logr"
Expand All @@ -31,7 +32,8 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/minio/minio-go/v6"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
executionv1 "github.com/secureCodeBox/secureCodeBox/operator/apis/execution/v1"
)

Expand Down Expand Up @@ -130,11 +132,11 @@ func (r *ScanReconciler) handleFinalizer(scan *executionv1.Scan) error {
if containsString(scan.ObjectMeta.Finalizers, s3StorageFinalizer) {
bucketName := os.Getenv("S3_BUCKET")
r.Log.V(0).Info("Deleting External Files from FileStorage", "ScanUID", scan.UID)
err := r.MinioClient.RemoveObject(bucketName, fmt.Sprintf("scan-%s/%s", scan.UID, scan.Status.RawResultFile))
err := r.MinioClient.RemoveObject(context.Background(), bucketName, fmt.Sprintf("scan-%s/%s", scan.UID, scan.Status.RawResultFile), minio.RemoveObjectOptions{})
if err != nil && err.Error() != errNotFound {
return err
}
err = r.MinioClient.RemoveObject(bucketName, fmt.Sprintf("scan-%s/findings.json", scan.UID))
err = r.MinioClient.RemoveObject(context.Background(), bucketName, fmt.Sprintf("scan-%s/findings.json", scan.UID), minio.RemoveObjectOptions{})

if err != nil && err.Error() != errNotFound {
return err
Expand All @@ -153,7 +155,7 @@ func (r *ScanReconciler) PresignedGetURL(scanID types.UID, filename string, dura
bucketName := os.Getenv("S3_BUCKET")

reqParams := make(url.Values)
rawResultDownloadURL, err := r.MinioClient.PresignedGetObject(bucketName, fmt.Sprintf("scan-%s/%s", string(scanID), filename), duration, reqParams)
rawResultDownloadURL, err := r.MinioClient.PresignedGetObject(context.Background(), bucketName, fmt.Sprintf("scan-%s/%s", string(scanID), filename), duration, reqParams)
if err != nil {
r.Log.Error(err, "Could not get presigned url from s3 or compatible storage provider")
return "", err
Expand All @@ -165,7 +167,7 @@ func (r *ScanReconciler) PresignedGetURL(scanID types.UID, filename string, dura
func (r *ScanReconciler) PresignedPutURL(scanID types.UID, filename string, duration time.Duration) (string, error) {
bucketName := os.Getenv("S3_BUCKET")

rawResultDownloadURL, err := r.MinioClient.PresignedPutObject(bucketName, fmt.Sprintf("scan-%s/%s", string(scanID), filename), duration)
rawResultDownloadURL, err := r.MinioClient.PresignedPutObject(context.Background(), bucketName, fmt.Sprintf("scan-%s/%s", string(scanID), filename), duration)
if err != nil {
r.Log.Error(err, "Could not get presigned url from s3 or compatible storage provider")
return "", err
Expand All @@ -175,8 +177,6 @@ func (r *ScanReconciler) PresignedPutURL(scanID types.UID, filename string, dura

func (r *ScanReconciler) initS3Connection() *minio.Client {
endpoint := os.Getenv("S3_ENDPOINT")
accessKeyID := os.Getenv("S3_ACCESS_KEY")
secretAccessKey := os.Getenv("S3_SECRET_KEY")
if os.Getenv("S3_PORT") != "" {
endpoint = fmt.Sprintf("%s:%s", endpoint, os.Getenv("S3_PORT"))
}
Expand All @@ -186,8 +186,24 @@ func (r *ScanReconciler) initS3Connection() *minio.Client {
useSSL = false
}

var creds *credentials.Credentials

if authType, ok := os.LookupEnv("S3_AUTH_TYPE"); ok && strings.ToLower(authType) == "aws-irsa" {
stsEndpoint := ""
if configuredStsEndpoint, ok := os.LookupEnv("S3_AWS_IRSA_STS_ENDPOINT"); ok {
stsEndpoint = configuredStsEndpoint
}

creds = credentials.NewIAM(stsEndpoint)
} else {
creds = credentials.NewEnvMinio()
}

// Initialize minio client object.
minioClient, err := minio.New(endpoint, accessKeyID, secretAccessKey, useSSL)
minioClient, err := minio.New(endpoint, &minio.Options{
Creds: creds,
Secure: useSSL,
})
if err != nil {
r.Log.Error(err, "Could not create minio client to communicate with s3 or compatible storage provider")
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.15

require (
github.com/go-logr/logr v0.1.0
github.com/minio/minio-go/v6 v6.0.50
github.com/minio/minio-go/v7 v7.0.6
github.com/onsi/ginkgo v1.11.0
github.com/onsi/gomega v1.8.1
k8s.io/api v0.17.2
Expand Down
Loading