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

K8s client app develop #5889

Open
wants to merge 49 commits into
base: develop
Choose a base branch
from
Open

Conversation

kripanshdevtron
Copy link
Contributor

Description

Fixes #

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?


Copy link

gitguardian bot commented Sep 23, 2024

⚠️ GitGuardian has uncovered 4 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
2763127 Triggered Generic High Entropy Secret 9dbc1fb scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/secrets-test-values.yaml View secret
141558 Triggered Generic High Entropy Secret 9dbc1fb scripts/devtron-reference-helm-charts/deployment-chart_1-1-0/env-values.yaml View secret
10220829 Triggered Generic High Entropy Secret 08d8e82 charts/devtron/devtron-bom.yaml View secret
10220829 Triggered Generic High Entropy Secret 08d8e82 charts/devtron/values.yaml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@kripanshdevtron kripanshdevtron changed the base branch from main to develop September 23, 2024 13:40
}
err, clusterEntity := impl.convertToEntity(cluster)
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", cluster, "error", err)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

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

Copilot Autofix AI 4 days ago

To fix the problem, we need to ensure that sensitive information such as passwords 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 logging statement. Specifically, we should avoid logging the entire cluster object and instead log only the non-sensitive fields.

  1. Identify the logging statement that includes sensitive information.
  2. Modify the logging statement to exclude sensitive fields such as PPassword.
  3. Ensure that the logging statement still provides useful information for debugging without exposing sensitive data.
pkg/cluster/repository/ClusterFileBasedRepository.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/cluster/repository/ClusterFileBasedRepository.go b/pkg/cluster/repository/ClusterFileBasedRepository.go
--- a/pkg/cluster/repository/ClusterFileBasedRepository.go
+++ b/pkg/cluster/repository/ClusterFileBasedRepository.go
@@ -72,3 +72,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while converting model to entity", "model", cluster, "error", err)
+		impl.logger.Errorw("error occurred while converting model to entity", "clusterId", cluster.Id, "clusterName", cluster.ClusterName, "error", err)
 		return errors.New("failed to update cluster")
EOF
@@ -72,3 +72,3 @@
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", cluster, "error", err)
impl.logger.Errorw("error occurred while converting model to entity", "clusterId", cluster.Id, "clusterName", cluster.ClusterName, "error", err)
return errors.New("failed to update cluster")
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
func (impl *ClusterFileBasedRepository) convertToEntity(model *Cluster) (error, *ClusterEntity) {
configJson, err := json.Marshal(model.Config)
if err != nil {
impl.logger.Errorw("error occurred while converting to entity", "model", model, "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.
Sensitive data returned by an access to PPassword
flows to a logging call.
Sensitive data returned by an access to Password
flows to a logging call.
Sensitive data returned by an access to PPassword
flows to a logging call.
Sensitive data returned by an access to PPassword
flows to a logging call.

Copilot Autofix AI 4 days ago

To fix the problem, we need to ensure that sensitive information is not logged in clear text. The best way to fix this without changing existing functionality is to remove the sensitive information from the log message. Specifically, we should avoid logging the entire model object and instead log only non-sensitive parts of it.

pkg/cluster/repository/ClusterFileBasedRepository.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/cluster/repository/ClusterFileBasedRepository.go b/pkg/cluster/repository/ClusterFileBasedRepository.go
--- a/pkg/cluster/repository/ClusterFileBasedRepository.go
+++ b/pkg/cluster/repository/ClusterFileBasedRepository.go
@@ -168,3 +168,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while converting to entity", "model", model, "err", err)
+		impl.logger.Errorw("error occurred while converting to entity", "clusterName", model.ClusterName, "err", err)
 		return errors.New("failed to process cluster data"), nil
EOF
@@ -168,3 +168,3 @@
if err != nil {
impl.logger.Errorw("error occurred while converting to entity", "model", model, "err", err)
impl.logger.Errorw("error occurred while converting to entity", "clusterName", model.ClusterName, "err", err)
return errors.New("failed to process cluster data"), nil
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
func (impl *ClusterFileBasedRepository) Update(model *Cluster) error {
err, entity := impl.convertToEntity(model)
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", 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.
Sensitive data returned by an access to PPassword
flows to a logging call.
Sensitive data returned by an access to PPassword
flows to a logging call.

Copilot Autofix AI 4 days ago

To fix the problem, we should avoid logging sensitive information directly. Instead, we can log non-sensitive parts of the model object or obfuscate the sensitive fields before logging. Specifically, we should remove the model object from the logging statement in the Update method of ClusterFileBasedRepository.go.

pkg/cluster/repository/ClusterFileBasedRepository.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/cluster/repository/ClusterFileBasedRepository.go b/pkg/cluster/repository/ClusterFileBasedRepository.go
--- a/pkg/cluster/repository/ClusterFileBasedRepository.go
+++ b/pkg/cluster/repository/ClusterFileBasedRepository.go
@@ -317,3 +317,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while converting model to entity", "error", err)
 		return errors.New("failed to update cluster")
@@ -323,3 +323,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while updating cluster", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while updating cluster", "error", err)
 		return errors.New("failed to update cluster")
EOF
@@ -317,3 +317,3 @@
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
impl.logger.Errorw("error occurred while converting model to entity", "error", err)
return errors.New("failed to update cluster")
@@ -323,3 +323,3 @@
if err != nil {
impl.logger.Errorw("error occurred while updating cluster", "model", model, "error", err)
impl.logger.Errorw("error occurred while updating cluster", "error", err)
return errors.New("failed to update cluster")
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
result := impl.dbConnection.Model(entity).Updates(entity)
err = result.Error
if err != nil {
impl.logger.Errorw("error occurred while updating cluster", "model", model, "error", 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.
Sensitive data returned by an access to PPassword
flows to a logging call.
Sensitive data returned by an access to PPassword
flows to a logging call.

Copilot Autofix AI 4 days ago

To fix the problem, we need to ensure that sensitive information is not logged in clear text. The best way to achieve this is to obfuscate or omit the sensitive fields from the log messages. Specifically, we should avoid logging the Password field from the model object.

  1. Identify the logging statements that include the model object.
  2. Modify these logging statements to exclude sensitive information.
  3. Ensure that the rest of the logging information remains intact for debugging purposes.
pkg/cluster/repository/ClusterFileBasedRepository.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/cluster/repository/ClusterFileBasedRepository.go b/pkg/cluster/repository/ClusterFileBasedRepository.go
--- a/pkg/cluster/repository/ClusterFileBasedRepository.go
+++ b/pkg/cluster/repository/ClusterFileBasedRepository.go
@@ -317,3 +317,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while converting model to entity", "model", obfuscateSensitiveInfo(model), "error", err)
 		return errors.New("failed to update cluster")
@@ -323,3 +323,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while updating cluster", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while updating cluster", "model", obfuscateSensitiveInfo(model), "error", err)
 		return errors.New("failed to update cluster")
@@ -333,3 +333,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while converting model to entity", "model", obfuscateSensitiveInfo(model), "error", err)
 		return errors.New("failed to delete cluster")
@@ -339,3 +339,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while deleting cluster", "model", model, "err", err)
+		impl.logger.Errorw("error occurred while deleting cluster", "model", obfuscateSensitiveInfo(model), "err", err)
 		return errors.New("failed to delete cluster")
EOF
@@ -317,3 +317,3 @@
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
impl.logger.Errorw("error occurred while converting model to entity", "model", obfuscateSensitiveInfo(model), "error", err)
return errors.New("failed to update cluster")
@@ -323,3 +323,3 @@
if err != nil {
impl.logger.Errorw("error occurred while updating cluster", "model", model, "error", err)
impl.logger.Errorw("error occurred while updating cluster", "model", obfuscateSensitiveInfo(model), "error", err)
return errors.New("failed to update cluster")
@@ -333,3 +333,3 @@
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
impl.logger.Errorw("error occurred while converting model to entity", "model", obfuscateSensitiveInfo(model), "error", err)
return errors.New("failed to delete cluster")
@@ -339,3 +339,3 @@
if err != nil {
impl.logger.Errorw("error occurred while deleting cluster", "model", model, "err", err)
impl.logger.Errorw("error occurred while deleting cluster", "model", obfuscateSensitiveInfo(model), "err", err)
return errors.New("failed to delete cluster")
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
func (impl *ClusterFileBasedRepository) Delete(model *Cluster) error {
err, entity := impl.convertToEntity(model)
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

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

Copilot Autofix AI 4 days ago

To fix the problem, we need to ensure that sensitive information is not logged in clear text. The best way to do this is to avoid logging the model object directly. Instead, we can log non-sensitive parts of the model or provide a sanitized version of the model for logging purposes.

  • Identify the logging statements that include the model object.
  • Replace these logging statements with ones that exclude sensitive information.
  • Ensure that the sensitive fields such as PPassword are not included in the logs.
pkg/cluster/repository/ClusterFileBasedRepository.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/cluster/repository/ClusterFileBasedRepository.go b/pkg/cluster/repository/ClusterFileBasedRepository.go
--- a/pkg/cluster/repository/ClusterFileBasedRepository.go
+++ b/pkg/cluster/repository/ClusterFileBasedRepository.go
@@ -317,3 +317,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while converting model to entity", "modelId", model.Id, "error", err)
 		return errors.New("failed to update cluster")
@@ -323,3 +323,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while updating cluster", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while updating cluster", "modelId", model.Id, "error", err)
 		return errors.New("failed to update cluster")
@@ -333,3 +333,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while converting model to entity", "modelId", model.Id, "error", err)
 		return errors.New("failed to delete cluster")
@@ -339,3 +339,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while deleting cluster", "model", model, "err", err)
+		impl.logger.Errorw("error occurred while deleting cluster", "modelId", model.Id, "err", err)
 		return errors.New("failed to delete cluster")
EOF
@@ -317,3 +317,3 @@
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
impl.logger.Errorw("error occurred while converting model to entity", "modelId", model.Id, "error", err)
return errors.New("failed to update cluster")
@@ -323,3 +323,3 @@
if err != nil {
impl.logger.Errorw("error occurred while updating cluster", "model", model, "error", err)
impl.logger.Errorw("error occurred while updating cluster", "modelId", model.Id, "error", err)
return errors.New("failed to update cluster")
@@ -333,3 +333,3 @@
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
impl.logger.Errorw("error occurred while converting model to entity", "modelId", model.Id, "error", err)
return errors.New("failed to delete cluster")
@@ -339,3 +339,3 @@
if err != nil {
impl.logger.Errorw("error occurred while deleting cluster", "model", model, "err", err)
impl.logger.Errorw("error occurred while deleting cluster", "modelId", model.Id, "err", err)
return errors.New("failed to delete cluster")
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
result := impl.dbConnection.Delete(entity)
err = result.Error
if err != nil {
impl.logger.Errorw("error occurred while deleting cluster", "model", model, "err", err)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

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

Copilot Autofix AI 4 days ago

To fix the problem, we need to ensure that sensitive information such as PPassword is not logged in clear text. The best way to achieve this is to remove the sensitive fields from the log messages or replace them with obfuscated values.

  1. Identify the log statements where the model is being logged.
  2. Remove the sensitive fields from the log messages or replace them with obfuscated values.
  3. Ensure that the changes do not affect the existing functionality of the code.
pkg/cluster/repository/ClusterFileBasedRepository.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/cluster/repository/ClusterFileBasedRepository.go b/pkg/cluster/repository/ClusterFileBasedRepository.go
--- a/pkg/cluster/repository/ClusterFileBasedRepository.go
+++ b/pkg/cluster/repository/ClusterFileBasedRepository.go
@@ -317,3 +317,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while converting model to entity", "modelId", model.Id, "error", err)
 		return errors.New("failed to update cluster")
@@ -323,3 +323,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while updating cluster", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while updating cluster", "modelId", model.Id, "error", err)
 		return errors.New("failed to update cluster")
@@ -333,3 +333,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
+		impl.logger.Errorw("error occurred while converting model to entity", "modelId", model.Id, "error", err)
 		return errors.New("failed to delete cluster")
@@ -339,3 +339,3 @@
 	if err != nil {
-		impl.logger.Errorw("error occurred while deleting cluster", "model", model, "err", err)
+		impl.logger.Errorw("error occurred while deleting cluster", "modelId", model.Id, "err", err)
 		return errors.New("failed to delete cluster")
EOF
@@ -317,3 +317,3 @@
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
impl.logger.Errorw("error occurred while converting model to entity", "modelId", model.Id, "error", err)
return errors.New("failed to update cluster")
@@ -323,3 +323,3 @@
if err != nil {
impl.logger.Errorw("error occurred while updating cluster", "model", model, "error", err)
impl.logger.Errorw("error occurred while updating cluster", "modelId", model.Id, "error", err)
return errors.New("failed to update cluster")
@@ -333,3 +333,3 @@
if err != nil {
impl.logger.Errorw("error occurred while converting model to entity", "model", model, "error", err)
impl.logger.Errorw("error occurred while converting model to entity", "modelId", model.Id, "error", err)
return errors.New("failed to delete cluster")
@@ -339,3 +339,3 @@
if err != nil {
impl.logger.Errorw("error occurred while deleting cluster", "model", model, "err", err)
impl.logger.Errorw("error occurred while deleting cluster", "modelId", model.Id, "err", err)
return errors.New("failed to delete cluster")
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Copy link

sonarcloud bot commented Sep 27, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
3.6% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

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