File tree Expand file tree Collapse file tree 4 files changed +27
-1
lines changed
Expand file tree Collapse file tree 4 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ module github.com/utmstack/UTMStack/threadwinds-ingestion
33go 1.25.4
44
55require (
6+ github.com/AtlasInsideCorp/AtlasInsideAES v1.0.0
67 github.com/lib/pq v1.10.9
78 github.com/opensearch-project/opensearch-go/v2 v2.3.0
89 github.com/threatwinds/go-sdk v1.0.47
Original file line number Diff line number Diff line change 1+ github.com/AtlasInsideCorp/AtlasInsideAES v1.0.0 h1:TBiBl9KCa4i4epY0/q9WSC4ugavL6+6JUkOXWDnMM6I =
2+ github.com/AtlasInsideCorp/AtlasInsideAES v1.0.0 /go.mod h1:cRhQ3TS/VEfu/z+qaciyuDZdtxgaXgaX8+G6Wa5NzBk =
13github.com/aws/aws-sdk-go v1.44.263 /go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI =
24github.com/aws/aws-sdk-go-v2 v1.18.0 /go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw =
35github.com/aws/aws-sdk-go-v2/config v1.18.25 /go.mod h1:dZnYpD5wTW/dQF0rRNLVypB396zWCcPiBIvdvSWHEg4 =
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
1212 "github.com/threatwinds/go-sdk/catcher"
1313 "github.com/utmstack/UTMStack/threadwinds-ingestion/config"
1414 "github.com/utmstack/UTMStack/threadwinds-ingestion/internal/models"
15+ "github.com/utmstack/UTMStack/threadwinds-ingestion/utils"
1516)
1617
1718type BackendClient struct {
@@ -150,7 +151,19 @@ func (c *BackendClient) GetThreadWindsConfig(ctx context.Context) (*ThreadWindsC
150151 config .APIKey = param .ConfParamValue
151152 config .KeyID = param .ID
152153 case "utmstack.tw.apiSecret" :
153- config .APISecret = param .ConfParamValue
154+ if param .ConfParamDatatype == "password" && param .ConfParamValue != "" {
155+ decrypted , err := utils .DecryptValue (param .ConfParamValue )
156+ if err != nil {
157+ return nil , fmt .Errorf ("failed to decrypt API Secret: %w" , err )
158+ }
159+ config .APISecret = decrypted
160+ catcher .Info ("API Secret decrypted successfully" , map [string ]any {
161+ "encrypted_length" : len (param .ConfParamValue ),
162+ "decrypted_length" : len (decrypted ),
163+ })
164+ } else {
165+ config .APISecret = param .ConfParamValue
166+ }
154167 config .SecretID = param .ID
155168 }
156169 }
Original file line number Diff line number Diff line change 1+ package utils
2+
3+ import (
4+ "github.com/AtlasInsideCorp/AtlasInsideAES"
5+ )
6+
7+ func DecryptValue (encryptedValue string ) (string , error ) {
8+ passphrase := Getenv ("ENCRYPTION_KEY" )
9+ return AtlasInsideAES .AESDecrypt (encryptedValue , []byte (passphrase ))
10+ }
You can’t perform that action at this time.
0 commit comments