Skip to content

Commit 873d410

Browse files
start:bugfix wrong interpretation of subversion of docker (#1156)
* Support single-digit subversions of docker * Fix: wrong path in test * fix paths test due to the .horusec dir creation during tests * simplify test code --------- Co-authored-by: Bruno Duru <[email protected]>
1 parent f807fde commit 873d410

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

internal/controllers/language_detect/language_detect_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func TestLanguageDetectIgnoreFilesGithubFolder(t *testing.T) {
7777
cfg.EnableGitHistoryAnalysis = true
7878
cfg.EnableCommitAuthor = true
7979
cfg.FilesOrPathsToIgnore = []string{"**/leaks/**", "**/yaml/**"}
80-
cfg.ProjectPath = filepath.Join(testutil.RootPath, "..", "horusec-examples-vulnerabilities")
80+
cfg.ProjectPath = testutil.RootPath
8181

8282
analysisID := uuid.New()
8383

internal/controllers/requirements/docker/docker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"errors"
2020
"fmt"
2121
"strconv"
22+
"strings"
2223

2324
"github.com/ZupIT/horusec-devkit/pkg/utils/logger"
2425

@@ -86,7 +87,7 @@ func getVersionAndSubVersion(fullVersion string) (int, int, error) {
8687
if err != nil {
8788
return 0, 0, ErrDockerNotInstalled
8889
}
89-
subversion, err := strconv.Atoi(fullVersion[3:5])
90+
subversion, err := strconv.Atoi(strings.Split(fullVersion[3:5], ".")[0])
9091
if err != nil {
9192
return 0, 0, ErrDockerNotInstalled
9293
}

internal/utils/file/file_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ import (
3030
func TestGetFilePathIntoBasePath(t *testing.T) {
3131
t.Run("Should return path correctly", func(t *testing.T) {
3232
filePath := filepath.Join("file", "file_test.go")
33-
volume := testutil.RootPath
33+
volume := filepath.Join(testutil.RootPath, "internal")
3434
response, err := file.GetPathFromFilename(filePath, volume)
3535
assert.NoError(t, err)
3636
assert.NotEqual(t, response, filePath)
37-
assert.Equal(t, filepath.Join("internal", "utils", "file", "file_test.go"), response)
37+
assert.Equal(t, filepath.Join("utils", "file", "file_test.go"), response)
3838
})
3939
t.Run("Should return filePath because not found", func(t *testing.T) {
4040
filePath := "some_other_not_existing_file.go"

0 commit comments

Comments
 (0)