refactor: Refactor ci and multi cluster cicd#6505
Conversation
ci service and trigger service creation
| } | ||
| workflowRequest, err = impl.updateWorkflowRequestWithBuildCacheData(workflowRequest, scope) | ||
| if err != nil { | ||
| impl.Logger.Errorw("error, updateWorkflowRequestWithBuildCacheData", "workflowRequest", workflowRequest, "err", err) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that sensitive information such as passwords is not logged in clear text. Instead, we can either omit the sensitive information from the logs or obfuscate it. In this case, we will omit the password from the log message to prevent any potential security risks.
We will modify the logging statement on line 765 to exclude the Password field from the workflowRequest object. This change will be made in the file pkg/build/trigger/HandlerService.go.
| @@ -71,2 +71,11 @@ | ||
|
|
||
| func obfuscateSensitiveData(workflowRequest *types.WorkflowRequest) *types.WorkflowRequest { | ||
| // Create a copy of the workflowRequest to avoid modifying the original object | ||
| obfuscatedRequest := *workflowRequest | ||
| for i := range obfuscatedRequest.CiProjectDetails { | ||
| obfuscatedRequest.CiProjectDetails[i].GitOptions.Password = "****" | ||
| } | ||
| return &obfuscatedRequest | ||
| } | ||
|
|
||
| type HandlerService interface { | ||
| @@ -764,3 +773,3 @@ | ||
| if err != nil { | ||
| impl.Logger.Errorw("error, updateWorkflowRequestWithBuildCacheData", "workflowRequest", workflowRequest, "err", err) | ||
| impl.Logger.Errorw("error, updateWorkflowRequestWithBuildCacheData", "workflowRequest", obfuscateSensitiveData(workflowRequest), "err", err) | ||
| return nil, nil, nil, nil, err |
| } | ||
| _, numBytes, err := blobStorageService.Get(request) | ||
| if err != nil { | ||
| impl.Logger.Errorw("error occurred while downloading file", "request", request, "error", err) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that sensitive information such as BlobStorageS3SecretKey is not logged in clear text. The best way to fix this without changing existing functionality is to remove the sensitive information from the logging statement. We can log the request without including sensitive fields or obfuscate the sensitive information before logging.
We will modify the logging statement on line 1945 to exclude the sensitive information from the request object. This can be done by creating a copy of the request object with the sensitive fields removed or obfuscated before logging.
| @@ -1944,3 +1944,5 @@ | ||
| if err != nil { | ||
| impl.Logger.Errorw("error occurred while downloading file", "request", request, "error", err) | ||
| safeRequest := *request | ||
| safeRequest.AwsS3BaseConfig.Passkey = "REDACTED" | ||
| impl.Logger.Errorw("error occurred while downloading file", "request", safeRequest, "error", err) | ||
| return nil, errors.New("failed to download resource") |
| } | ||
| _, numBytes, err := blobStorageService.Get(request) | ||
| if err != nil { | ||
| impl.logger.Errorw("error occurred while downloading file", "request", request, "error", err) |
Check failure
Code scanning / CodeQL
Clear-text logging of sensitive information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the problem, we need to ensure that sensitive information such as BlobStorageS3SecretKey is not logged in clear text. The best way to fix this is to remove the sensitive information from the logging call or to obfuscate it before logging.
In this case, we will remove the sensitive information from the logging call. Specifically, we will modify the logging statement on line 213 to exclude the request object, which contains the sensitive information.
| @@ -212,3 +212,3 @@ | ||
| if err != nil { | ||
| impl.logger.Errorw("error occurred while downloading file", "request", request, "error", err) | ||
| impl.logger.Errorw("error occurred while downloading file", "error", err) | ||
| return nil, errors.New("failed to download resource") |
|
|
The migration files have successfully passed the criteria!! |


Description
Fixes https://github.com/devtron-labs/sprint-tasks/issues/692
Checklist:
Does this PR introduce a user-facing change?