Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Slight refactor of scbctl #2682

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

Merged

Conversation

ddddddO
Copy link
Contributor

@ddddddO ddddddO commented Sep 27, 2024

Description

Refactor scbctl👍!

  • Remove extra processing in scbctl cmd's buildTree function ( 80f408b )
  • Replace Map to Slice ( 1e1ac14 )
    • Golang's map does not guarantee ordering, so I changed it from a map to a slice so that the result of each execution is the same each time.

    • I think it will solve the problem.

    • The following is a log of multiple runs of go test before and after the change at local.

      Before

      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.027s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.021s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.019s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.020s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      --- FAIL: TestBuildTree (0.00s)
          --- FAIL: TestBuildTree/Complex_cascade (0.00s)
              cascading_test.go:125: 
                      Error Trace:    /home/ddddddo/github.com/ddddddO/secureCodeBox/scbctl/cmd/cascading_test.go:125
                      Error:          Not equal: 
                                      expected: "Scans\n└── root\n    ├── child1\n    │   └── grandchild\n    └── child2\n"
                                      actual  : "Scans\n└── root\n    ├── child2\n    └── child1\n        └── grandchild\n"
                                  
                                      Diff:
                                      --- Expected
                                      +++ Actual
                                      @@ -2,5 +2,5 @@
                                       └── root
                                      -    ├── child1
                                      -    │   └── grandchild
                                      -    └── child2
                                      +    ├── child2
                                      +    └── child1
                                      +        └── grandchild
                                       
                      Test:           TestBuildTree/Complex_cascade
      🆕 Creating a new scan with name 'nmap' and parameters 'scanme.nmap.org'
      🚀 Successfully created a new Scan 'nmap'
      🆕 Creating a new scan with name 'nmap' and parameters 'scanme.nmap.org -p 90'
      🚀 Successfully created a new Scan 'nmap'
      🆕 Creating a new scan with name 'scanme-nmap-org' and parameters 'scanme.nmap.org'
      🚀 Successfully created a new Scan 'scanme-nmap-org'
      🆕 Creating a new scan with name 'nmap' and parameters 'scanme.nmap.org'
      🚀 Successfully created a new Scan 'nmap'
      🆕 Creating a new scan with name 'kubeaudit' and parameters '--namespace some-other-namespace'
      🚀 Successfully created a new Scan 'kubeaudit'
      Error: you must use '--' to separate scan parameters
      Error: you must use '--' to separate scan parameters
      triggered new Scan for ScheduledScan 'nmap'
      Error: could not find ScheduledScan 'nonexistent-scan' in namespace 'foobar'
      Error: accepts 1 arg(s), received 0
      triggered new Scan for ScheduledScan 'nmap'
      FAIL
      FAIL    github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.025s
      FAIL
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$

      After

      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.019s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.019s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.025s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.023s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.017s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.025s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.019s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.034s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.019s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.021s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.023s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.022s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.024s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.020s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.018s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.026s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./... -count=1
      ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       0.021s
      ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$

Checklist

  • Test your changes as thoroughly as possible before you commit them. Preferably, automate your test by unit/integration tests.

    ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$ go test ./...
    ok      github.com/secureCodeBox/secureCodeBox/scbctl/cmd       (cached)
    ddddddo@debian:~/github.com/ddddddO/secureCodeBox/scbctl/cmd$
  • Make sure that all your commits are signed-off and that you are added to the Contributors file.

  • Make sure that all CI finish successfully.

  • Optional (but appreciated): Make sure that all commits are Verified.

Copy link

netlify bot commented Sep 27, 2024

Deploy Preview for docs-securecodebox canceled.

Name Link
🔨 Latest commit e910103
🔍 Latest deploy log https://app.netlify.com/sites/docs-securecodebox/deploys/66f8192314f6480008aea9ae

@ddddddO ddddddO force-pushed the slight_change_building_tree_of_scbctl branch from 3ae6971 to 80f408b Compare September 27, 2024 14:39
Signed-off-by: ddddddO <[email protected]>
@ddddddO ddddddO changed the title Remove extra processing in scbctl cmd's buildTree function Slight refactor of scbctl Sep 27, 2024
@ddddddO
Copy link
Contributor Author

ddddddO commented Sep 28, 2024

@J12934
Hi!
Please review this pull request as I think it will resolve this problem👍

@ddddddO
Copy link
Contributor Author

ddddddO commented Sep 28, 2024

fyi @Freedisch

Hi!
I have made a few changes to the source code🙇

@J12934
Copy link
Member

J12934 commented Sep 28, 2024

Hi @ddddddO

Thank you for taking a deeper look at this 🙌

Can you add yourself to the contributors file: https://github.com/secureCodeBox/secureCodeBox/blob/main/CONTRIBUTORS.md

Then we should be ready to merge 😊

Copy link

@ddddddO
Copy link
Contributor Author

ddddddO commented Sep 28, 2024

@J12934

Thanks for the review!
And thanks for putting my name on the CONTRIBUTORS.md even though it is a small code change!

@J12934
Copy link
Member

J12934 commented Sep 28, 2024

The nikto test failures like 99.99% unrelated to this. Will try restarting it, will take a look at them if that doesn't help

@ddddddO
Copy link
Contributor Author

ddddddO commented Sep 29, 2024

It looks like this test is not failing on any commit other than this PullRequest... It's a mystery...

Any other PullRequest ci that is also failing😵
https://github.com/secureCodeBox/secureCodeBox/actions/runs/11082815384

It appears that this test (nikto test) has been failing recently.
I checked the first page of the list of failed GitHubActions below:
https://github.com/secureCodeBox/secureCodeBox/actions?query=is%3Afailure

Sorry I have no idea 🙇, but there has been a recent change in sullo/nikto (commits since sullo/nikto@890e895?), so maybe that has something to do with it.

@J12934
Copy link
Member

J12934 commented Sep 30, 2024

@ddddddO had a look regarding the nikto issues :)
Think i found a workaround: #2685

@ddddddO
Copy link
Contributor Author

ddddddO commented Sep 30, 2024

@J12934
Excellent🎉! Thank you!

@J12934 J12934 merged commit a2f3028 into secureCodeBox:main Sep 30, 2024
53 checks passed
@J12934
Copy link
Member

J12934 commented Sep 30, 2024

Ok build now went through after a second fix 😊

Merge the PR now. Thanks again for the contribution and the patience 😅

@ddddddO
Copy link
Contributor Author

ddddddO commented Oct 1, 2024

I saw sullo/nikto#843 👍 Thank you very much!

@ddddddO ddddddO deleted the slight_change_building_tree_of_scbctl branch October 1, 2024 11:04
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.

2 participants