Skip to content

Commit

Permalink
start:bugfix wrong interpretation of subversion of docker (#1156)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
smoogie authored and guilhermepaulozup committed Aug 8, 2023
1 parent f807fde commit b3e237f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func TestLanguageDetectIgnoreFilesGithubFolder(t *testing.T) {
cfg.EnableGitHistoryAnalysis = true
cfg.EnableCommitAuthor = true
cfg.FilesOrPathsToIgnore = []string{"**/leaks/**", "**/yaml/**"}
cfg.ProjectPath = filepath.Join(testutil.RootPath, "..", "horusec-examples-vulnerabilities")
cfg.ProjectPath = testutil.RootPath

analysisID := uuid.New()

Expand Down
3 changes: 2 additions & 1 deletion internal/controllers/requirements/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"
"strconv"
"strings"

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

Expand Down Expand Up @@ -86,7 +87,7 @@ func getVersionAndSubVersion(fullVersion string) (int, int, error) {
if err != nil {
return 0, 0, ErrDockerNotInstalled
}
subversion, err := strconv.Atoi(fullVersion[3:5])
subversion, err := strconv.Atoi(strings.Split(fullVersion[3:5], ".")[0])
if err != nil {
return 0, 0, ErrDockerNotInstalled
}
Expand Down
4 changes: 2 additions & 2 deletions internal/utils/file/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (
func TestGetFilePathIntoBasePath(t *testing.T) {
t.Run("Should return path correctly", func(t *testing.T) {
filePath := filepath.Join("file", "file_test.go")
volume := testutil.RootPath
volume := filepath.Join(testutil.RootPath, "internal")
response, err := file.GetPathFromFilename(filePath, volume)
assert.NoError(t, err)
assert.NotEqual(t, response, filePath)
assert.Equal(t, filepath.Join("internal", "utils", "file", "file_test.go"), response)
assert.Equal(t, filepath.Join("utils", "file", "file_test.go"), response)
})
t.Run("Should return filePath because not found", func(t *testing.T) {
filePath := "some_other_not_existing_file.go"
Expand Down

0 comments on commit b3e237f

Please sign in to comment.