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

Support scs engine In scan create Resubmit command (AST-63906) #840

Merged
merged 13 commits into from
Aug 26, 2024

Conversation

Korjen97
Copy link
Contributor

@Korjen97 Korjen97 commented Aug 20, 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

Support SCS engine with scan create --resubmit coomand_ add tests for two cases (with scoreCard and with out).

References

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

Testing

Two Unit Tests: First for adding scoreCard in the scan with resubmit ( added Token flag and Url flag) and second without ScoreCard

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

@OrShamirCM OrShamirCM requested a review from a team August 20, 2024 08:23
Copy link

github-actions bot commented Aug 20, 2024

Logo
Checkmarx One – Scan Summary & Details94290bf0-989b-450a-ad0d-0c5c763f031b

Policy Management Violations

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

No New Or Fixed Issues Found

SCSMapConfig := make(map[string]interface{})
SCSConfig := wrappers.SCSConfig{}
SCSMapConfig[resultsMapType] = commonParams.MicroEnginesType // scs is still microengines in the scans API
userScanTypes, _ := cmd.Flags().GetString(commonParams.ScanTypes)
SCSRepoToken, _ := cmd.Flags().GetString(commonParams.SCSRepoTokenFlag)
SCSRepoURL, _ := cmd.Flags().GetString(commonParams.SCSRepoURLFlag)
SCSEngines, _ := cmd.Flags().GetString(commonParams.SCSEnginesFlag)
if resubmitConfig != nil {
for _, config := range resubmitConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Extract this scope to a new method - createSCSResubmitConfig(...).
This will make the function more readable and will answer the Single Responsibility Principle.

Also, it will probably fix your lint error

result, _ := addSCSScan(cmdCommand, resubmitConfig)

expectedConfig := wrappers.SCSConfig{
Twoms: "true",
Copy link
Collaborator

Choose a reason for hiding this comment

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

trueString

{
Type: commonParams.ScsType,
Value: map[string]interface{}{
configTwoms: "true",
Copy link
Collaborator

Choose a reason for hiding this comment

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

trueString

{
Type: commonParams.ScsType,
Value: map[string]interface{}{
configTwoms: "true",
Copy link
Collaborator

Choose a reason for hiding this comment

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

trueString

@AlvoBen
Copy link
Collaborator

AlvoBen commented Aug 20, 2024

Great job!

@Korjen97 Korjen97 changed the title Itay/Support scs engine with scan create resubmit and tests (AST-63906) Support scs engine In scan create Resubmit command(AST-63906) Aug 20, 2024
@Korjen97 Korjen97 changed the title Support scs engine In scan create Resubmit command(AST-63906) Support scs engine In scan create Resubmit command (AST-63906) Aug 20, 2024
if resubmitConfig != nil {
scsConfig = createResubmitConfig(resubmitConfig, scsRepoToken, scsRepoURL)
SCSMapConfig[resultsMapValue] = &scsConfig
return SCSMapConfig, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

dont you need the config builder to finish his work first?

func createResubmitConfig(resubmitConfig []wrappers.Config, scsRepoToken, scsRepoURL string) wrappers.SCSConfig {
scsConfig := wrappers.SCSConfig{}
for _, config := range resubmitConfig {
resubmitTwoms := config.Value[configTwoms]
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the difference between the regular config building and resubmit? Can't we re-use the regular build config?

@Korjen97 Korjen97 merged commit 76e8af6 into main Aug 26, 2024
9 checks passed
@Korjen97 Korjen97 deleted the Itay/support-SCS-in-scan-create branch August 26, 2024 10:40
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.

3 participants