Checkmarx / kics

Find security vulnerabilities, compliance issues, and infrastructure misconfigurations early in the development cycle of your infrastructure-as-code with KICS by Checkmarx.
https://kics.io
Apache License 2.0
2.06k stars 307 forks source link

assets found in wrong location when having multiple sibling 'kics*' repos with different names #6384

Open ittaigilat-cx opened 1 year ago

ittaigilat-cx commented 1 year ago

I have two kics repos on my laptop at .../kics/... and .../kics2/... I am working on kics2 but I get queries from kics/assets/queries/... running (instead of those from kics2)

Expected Behavior

kics2 must run queries from kics2/assets/queries

Actual Behavior

kics2 runs queries from kics/assets/queries

Steps to Reproduce the Problem

as explained above

Specifications

The issue is in the implementation of function GetDefaultQueryPath(lines 133-154) in internal/console/helpers/helpers. go. In line 142 a directory 'kics' is assumed to be a part of the default kics deployment location, when the deployment can be placed in a directory called 'kuku'. To fix this code and make it more robust I recommend searching for the 'assets/queries' relative path.

Here is the test log for running TestHelpers_GetDefaultQueryPath:

Running tool: C:\Program Files\Go\bin\go.exe test -timeout 30s -run ^TestHelpers_GetDefaultQueryPath$ github.com/Checkmarx/kics/internal/console/helpers === RUN TestHelpers_GetDefaultQueryPath panic: test timed out after 30s running tests: TestHelpers_GetDefaultQueryPath (30s) goroutine 37 [running]: testing.(*M).startAlarm.func1() C:/Program Files/Go/src/testing/testing.go:2241 +0x3c5 created by time.goFunc C:/Program Files/Go/src/time/sleep.go:176 +0x32 goroutine 1 [chan receive]: testing.(*T).Run(0xc00005da00, {0x9af63f?, 0x2d0c73?}, 0xa062b8) C:/Program Files/Go/src/testing/testing.go:1630 +0x405 testing.runTests.func1(0x108c840?) C:/Program Files/Go/src/testing/testing.go:2036 +0x45 testing.tRunner(0xc00005da00, 0xc00023fc88) C:/Program Files/Go/src/testing/testing.go:1576 +0x10b testing.runTests(0xc0003ace60?, {0x107db00, 0xd, 0xd}, {0x20?, 0x100c000407468?, 0x108bf60?}) C:/Program Files/Go/src/testing/testing.go:2034 +0x489 testing.(*M).Run(0xc0003ace60) C:/Program Files/Go/src/testing/testing.go:1906 +0x63a main. Main() _testmain.go:71 +0x1aa goroutine 5 [runnable, locked to thread]: syscall.SyscallN(0x7ffa1cec1ae0?, {0xc000073cd0?, 0x3?, 0x0?}) C:/Program Files/Go/src/runtime/syscall_windows.go:557 +0x109 syscall.Syscall(0x8e3480?, 0x1?, 0xc000073d68?, 0x5?, 0x2?) C:/Program Files/Go/src/runtime/syscall_windows.go:495 +0x3b syscall.SetCurrentDirectory(0x992c0b?) C:/Program Files/Go/src/syscall/zsyscall_windows.go:1040 +0x55 syscall.Chdir({0x992c0b?, 0xc000073da8?}) C:/Program Files/Go/src/syscall/syscall_windows.go:519 +0x4c os.Chdir({0x992c0b, 0x2}) C:/Program Files/Go/src/os/file.go:288 +0x27 github.com/Checkmarx/kics/test.ChangeCurrentDir({0x993c1e, 0x4}) c:/Checkmarx/Git/Kics/kics-gpt/test/helpers.go:66 +0x9a github.com/Checkmarx/kics/internal/console/helpers.TestHelpers_GetDefaultQueryPath(0xc00005dba0) c:/Checkmarx/Git/Kics/kics-gpt/internal/console/helpers/helpers_test.go:187 +0x45 testing.tRunner(0xc00005dba0, 0xa062b8) C:/Program Files/Go/src/testing/testing.go:1576 +0x10b created by testing.(*T).Run C:/Program Files/Go/src/testing/testing.go:1629 +0x3ea FAIL github.com/Checkmarx/kics/internal/console/helpers 30.612s > Test run finished at 5/15/2023, 6:45:07 PM <
JoaoAtGit commented 12 months ago

Hi @ittaigilat-cx, how are you ? I was looking into this issue opened by you, and I have a question why not use the flag --queries-path ? Best regards, João

gabriel-cx commented 7 months ago

Hi @ittaigilat-cx ,

Do you still have the same issue with the latest version (v1.7.12)?