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

fix: disable api update if disabled from UI #3487

Merged
merged 11 commits into from
Jun 21, 2023

Conversation

rish2320
Copy link
Contributor

@rish2320 rish2320 commented Jun 6, 2023

Description

Disable the API Update if the force security scanning is abled from UI.

Fixes #2574

How Has This Been Tested?

Tested all the using cases manually by Postman.

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.

@rish2320 rish2320 requested a review from prakash100198 June 6, 2023 13:06
impl.logger.Errorw("exception while getting unique client id", "error", err)
return nil, err
}
cm, err := impl.K8sUtil.GetConfigMap(ConfigMapNamespace, DashboardConfigMap, client)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle error here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return nil, err
}
cm, err := impl.K8sUtil.GetConfigMap(ConfigMapNamespace, DashboardConfigMap, client)
datamap := cm.Data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if cm is nil, handle that case also

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not able to see it handled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might not be showing that time, handled it.

@@ -68,6 +68,9 @@ import (
"go.uber.org/zap"
)

const DashboardConfigMap = "dashboard-cm"
const ConfigMapNamespace = "devtroncd"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check similar constants already used, remove namespace const.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dashboard-cm const is not used, removed namespace const.

return nil, err
}
cm, err := impl.K8sUtil.GetConfigMap(ConfigMapNamespace, DashboardConfigMap, client)
datamap := cm.Data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not able to see it handled

@@ -1413,6 +1418,24 @@ func (impl PipelineBuilderImpl) PatchCiPipeline(request *bean.CiPatchRequest) (c
ciConfig.AppWorkflowId = request.AppWorkflowId
ciConfig.UserId = request.UserId
if request.CiPipeline != nil {
client, err := impl.K8sUtil.GetClientForInCluster()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it works only for in cluster ? if not handle by cluster id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes working .

return nil, err
}
datamap := cm.Data
forceScanConfig, err := strconv.ParseBool(datamap["FORCE_SECURITY_SCANNING"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add nil check for datamap and add constant for KEY

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@vikramdevtron vikramdevtron self-requested a review June 13, 2023 07:33
vikramdevtron
vikramdevtron previously approved these changes Jun 13, 2023
@rish2320 rish2320 requested a review from prakash100198 June 15, 2023 12:38
@gitguardian
Copy link

gitguardian bot commented Jun 21, 2023

⚠️ GitGuardian has uncovered 2 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 Secret Commit Filename
141558 Generic High Entropy Secret 9880939 scripts/devtron-reference-helm-charts/cronjob-chart_1-5-0/env-values.yaml View secret
2763127 Generic High Entropy Secret 9880939 scripts/devtron-reference-helm-charts/cronjob-chart_1-5-0/secrets-test-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.

Our GitHub checks need improvements? Share your feedbacks!

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
8.1% 8.1% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@rish2320 rish2320 merged commit 7753c93 into main Jun 21, 2023
@rish2320 rish2320 deleted the disable-API-update-if-disabled-from-UI branch June 21, 2023 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Disable API update option when something is disable from UI
3 participants