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

CLI | Add threshold user input validation (AST-40169) #715

Merged
merged 11 commits into from
Apr 28, 2024

Conversation

AlvoBen
Copy link
Collaborator

@AlvoBen AlvoBen commented Apr 25, 2024

By submitting a PR to this repository, you agree to the terms within the Checkmarx Code of Conduct. Please see the contributing guidelines for how to create and submit a high-quality PR for this repo.

Description

Add threshold user input validation

References

https://checkmarx.atlassian.net/browse/AST-40169

Testing

  • Run tests localy
  • Added unit tests

Checklist

  • I have added documentation for new/changed functionality in this PR (if applicable).
  • I have updated the CLI help for new/changed functionality in this PR (if applicable).
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used

@pedrompflopes pedrompflopes requested a review from a team April 25, 2024 14:54
Copy link

github-actions bot commented Apr 25, 2024

Logo
Checkmarx One – Scan Summary & Details3e673869-502e-486d-8c0c-49c1ed05ea40

Policy Management Violations

Policy Name Rule(s) Break Build
[SAST-ML0] Not allowed NEW Sast vulnerabilities true

No New Or Fixed Issues Found

func parseThresholdLimit(limit string) (engineName string, intLimit int, err error) {
parts := strings.Split(limit, "=")
engineName = strings.Replace(parts[0], commonParams.KicsType, commonParams.IacType, 1)
if len(parts) > 1 {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can reduce Cyclomatic Complexity if you invert the condition:
if len(parts) <= 1
{
return engineName, intLimit, err
}

and later the logic you currently have inside len(parts) > 1

}

func normalizeThresholds(threshold string) string {
return strings.ReplaceAll(strings.ReplaceAll(threshold, " ", ""), ",", ";")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion:
any chance to make it more readable?

@AlvoBen AlvoBen merged commit 2980abc into main Apr 28, 2024
8 checks passed
@AlvoBen AlvoBen deleted the benalvo/add-threshould-input-check branch April 28, 2024 14:30
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.

4 participants