Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: handler error while while helm deployment #6082

Merged
merged 4 commits into from
Nov 14, 2024
Merged

Conversation

ayu-devtron
Copy link
Contributor

@ayu-devtron ayu-devtron commented Nov 13, 2024

Description

Fixes https://github.com/devtron-labs/sprint-tasks/issues/1257

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?


@ayu-devtron ayu-devtron changed the title fix: handler error while while checking for cluster fix: handler error while while helm deployment Nov 13, 2024
@@ -782,6 +782,10 @@
// Rollback tx on error.
defer tx.Rollback()
upgradeAppRequest, err = impl.updateInstalledApp(ctx, upgradeAppRequest, tx)
if err != nil {
impl.logger.Errorw("error while performing updateInstalledApp", "upgradeRequest", upgradeAppRequest, "err", err)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by an access to Password
flows to a logging call.

Copilot Autofix AI 4 months ago

To fix the problem, we need to ensure that sensitive information is not logged in clear text. The best way to fix this issue without changing existing functionality is to remove the sensitive information from the log message or obfuscate it before logging.

  • Identify the logging statement that logs the upgradeAppRequest object.
  • Remove or obfuscate the sensitive information (e.g., passwords) from the upgradeAppRequest object before logging it.
  • Ensure that the fix is applied to all relevant logging statements in the file.
Suggested changeset 1
pkg/appStore/installedApp/service/AppStoreDeploymentService.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go
--- a/pkg/appStore/installedApp/service/AppStoreDeploymentService.go
+++ b/pkg/appStore/installedApp/service/AppStoreDeploymentService.go
@@ -566,2 +566,10 @@
 
+func sanitizeUpgradeAppRequest(request *appStoreBean.InstallAppVersionDTO) *appStoreBean.InstallAppVersionDTO {
+	sanitizedRequest := *request
+	if sanitizedRequest.InstallAppVersionChartDTO != nil && sanitizedRequest.InstallAppVersionChartDTO.InstallAppVersionChartRepoDTO != nil {
+		sanitizedRequest.InstallAppVersionChartDTO.InstallAppVersionChartRepoDTO.Password = "****"
+	}
+	return &sanitizedRequest
+}
+
 func (impl *AppStoreDeploymentServiceImpl) updateInstalledApp(ctx context.Context, upgradeAppRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) {
@@ -785,3 +793,3 @@
 	if err != nil {
-		impl.logger.Errorw("error while performing updateInstalledApp", "upgradeRequest", upgradeAppRequest, "err", err)
+		impl.logger.Errorw("error while performing updateInstalledApp", "upgradeRequest", sanitizeUpgradeAppRequest(upgradeAppRequest), "err", err)
 		return nil, err
EOF
@@ -566,2 +566,10 @@

func sanitizeUpgradeAppRequest(request *appStoreBean.InstallAppVersionDTO) *appStoreBean.InstallAppVersionDTO {
sanitizedRequest := *request
if sanitizedRequest.InstallAppVersionChartDTO != nil && sanitizedRequest.InstallAppVersionChartDTO.InstallAppVersionChartRepoDTO != nil {
sanitizedRequest.InstallAppVersionChartDTO.InstallAppVersionChartRepoDTO.Password = "****"
}
return &sanitizedRequest
}

func (impl *AppStoreDeploymentServiceImpl) updateInstalledApp(ctx context.Context, upgradeAppRequest *appStoreBean.InstallAppVersionDTO, tx *pg.Tx) (*appStoreBean.InstallAppVersionDTO, error) {
@@ -785,3 +793,3 @@
if err != nil {
impl.logger.Errorw("error while performing updateInstalledApp", "upgradeRequest", upgradeAppRequest, "err", err)
impl.logger.Errorw("error while performing updateInstalledApp", "upgradeRequest", sanitizeUpgradeAppRequest(upgradeAppRequest), "err", err)
return nil, err
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@ayu-devtron ayu-devtron changed the title fix: handler error while while helm deployment misc: handler error while while helm deployment Nov 14, 2024
@ayu-devtron ayu-devtron merged commit cf1f6e6 into main Nov 14, 2024
8 of 9 checks passed
@ayu-devtron ayu-devtron deleted the helm-deploy-panic branch November 14, 2024 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants