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

fix: lynis testDB path #886

Merged
merged 1 commit into from
Nov 2, 2023
Merged

fix: lynis testDB path #886

merged 1 commit into from
Nov 2, 2023

Conversation

chrisgacsal
Copy link
Contributor

@chrisgacsal chrisgacsal commented Nov 2, 2023

Description

The lynis show dbdir command returns the path to the test database directory where the output string has a trailing newline character which is not removed before generating the path for the tests.db file. This results a bogus file path like /usr/local/lynis/db /tests.db and triggers an error as the tests.db file is not accessable.

This fix make sure that the command output is sanitized by removing leading/trailing whitespaces and the path is cleaned before using it to assemble the file path for tests.db.

Switch to filepath from path for working with filesystem paths as the latter is not meant to be used with OS filesystem paths.

Also rename testdb variable to testDB in order to make it aligned with Go naming convention.

Type of Change

[x] Bug Fix
[ ] New Feature
[ ] Breaking Change
[ ] Refactor
[ ] Documentation
[ ] Other (please describe)

Checklist

  • I have read the contributing guidelines
  • Existing issues have been referenced (where applicable)
  • I have verified this change is not present in other open pull requests
  • Functionality is documented
  • All code style checks pass
  • New code contribution is covered by automated tests
  • All new and existing tests pass

@chrisgacsal chrisgacsal requested a review from a team as a code owner November 2, 2023 11:02
@chrisgacsal chrisgacsal self-assigned this Nov 2, 2023
@chrisgacsal chrisgacsal added bug Something isn't working component:api Issues related to API and removed component:api Issues related to API labels Nov 2, 2023
The `lynis show dbdir` command returns the path to the test database
directory on the where the output string has a trailing newline
character which is not removed before generating the path for the
`tests.db` file. This results a bogus file path liek
`/usr/local/lynis/db /tests.db` and triggers an error as the `tests.db`
file is not accessable.

This fix make sure that the command output is sanitized by removing
leading/trailing whitespaces and the path is cleaned before using it to
assemble the file path for `tests.db`.

Switch to `filepath` from `path` for working with filesystem paths
as the latter is not meant to be used with OS filesystem paths.

Also rename `testdb` variable to `testDB` in order to make it aligned
with Go naming convention.
Copy link

github-actions bot commented Nov 2, 2023

Hey!

Your images are ready:

  • ghcr.io/openclarity/vmclarity-apiserver-dev:pr886-b2d1ae595d173ee082ee6e7659c481859f4c5e74
  • ghcr.io/openclarity/vmclarity-orchestrator-dev:pr886-b2d1ae595d173ee082ee6e7659c481859f4c5e74
  • ghcr.io/openclarity/vmclarity-ui-backend-dev:pr886-b2d1ae595d173ee082ee6e7659c481859f4c5e74
  • ghcr.io/openclarity/vmclarity-ui-dev:pr886-b2d1ae595d173ee082ee6e7659c481859f4c5e74
  • ghcr.io/openclarity/vmclarity-cli-dev:pr886-b2d1ae595d173ee082ee6e7659c481859f4c5e74

@chrisgacsal chrisgacsal added this pull request to the merge queue Nov 2, 2023
Merged via the queue into main with commit 28d9f05 Nov 2, 2023
32 checks passed
@chrisgacsal chrisgacsal deleted the fix-lynis-testdb-path branch November 2, 2023 11:54
@chrisgacsal chrisgacsal mentioned this pull request Nov 6, 2023
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants