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

start:bugfix wrong interpretation of subversion of docker #1156

Merged
merged 5 commits into from
Aug 7, 2023

Conversation

smoogie
Copy link
Contributor

@smoogie smoogie commented Aug 7, 2023

- What I did
Changed how we check the docker version to accept single digits.
More about the issue here: #1154
Also, this issue can be connected: #1155

I also changed some tests that run on "make test" - as two tests failed locally.

More details:

When we validate the docker version, we read the version and subversion from specific characters of the string that represent the version. As in some cases, subversion has one digit instead of two, subversion's string consists of a number and "." for example, "0.". When we pass such string to strconv.Atoi, we receive an error. This cause the error in version validation.

The simplest proposed solution is to split a string on "." - if we have "X.", it will grab X, if there is no dot - everything will still work.

A better solution would be to split the whole string correctly and grab specific version and subversion string as described in the issue #1154. But as other users have a similar problem #1155, this hotfix should be enough for the moment.

Additional changes are connected with running tests locally with the command "make test". If we pull only this repository, we do not have a directory filepath.Join(testutil.RootPath, "..", "horusec-examples-vulnerabilities"), so the test fails. This is why it was replaced with testutil.RootPath. This way, tests can be run on that code without errors by everyone independently from other projects. But probably, the test stopped to test specific cases. I may assume that that missing directory contained some vulnerabilities that would be found by horusec but should be ignored with the defined configuration, and this way test passes. Now it is passing as there are no directories with issues, not due to ignoring them during test... I suggest creating another ticket to fix that specific test.

The last change was also connected with tests. When we run tests, directory .horusec is created that contains a copy of all files and directories. So when we run file.GetPathFromFilename(filePath, volume) in TestGetFilePathIntoBasePath returns the path from .horusec subfolder, not from the root ex. .horusec/8faf537b-f096-4665-ac8b-0810beb4a574/internal/utils/file/file_test.go instead of internal/utils/file/file_test.go. This way, assert.equal failing. With little changes in directories that we search and assertion, the test pass (and is still correct).

- How to verify it
For a fix on docker validation, it is enough to test it on the configuration mentioned here: #1154
First, test the master branch, and later test the fixed version.

For changes in tests, you should clone the repo on a fresh environment without any other repos/projects and pull the master branch - check the errors on "make test". Next, check the same way the changed version. Tests should pass now.

- Description for the changelog
Support single-digit subversions of docker

@smoogie smoogie requested a review from a team as a code owner August 7, 2023 16:32
@guilhermepaulozup
Copy link
Contributor

LGTM. Thanks for your contribution!

@brunoduruzup brunoduruzup self-requested a review August 7, 2023 23:20
@guilhermepaulozup guilhermepaulozup merged commit 873d410 into ZupIT:main Aug 7, 2023
9 of 13 checks passed
guilhermepaulozup pushed a commit that referenced this pull request Aug 7, 2023
* 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 <80854347+brunoduruzup@users.noreply.github.com>
@renatovieiradesouza
Copy link

The error still persists, do I need to adjust the version? I didn't see any new releases

guilhermepaulozup pushed a commit that referenced this pull request Aug 8, 2023
* 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
@guilhermepaulozup
Copy link
Contributor

The error still persists, do I need to adjust the version? I didn't see any new releases

The final release have not been pushed yet, the fixes are currently in a Beta release:

https://github.com/ZupIT/horusec/releases/tag/v2.9.0-beta.3

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.

None yet

4 participants