Skip to content

fix(misconf): do not skip loading documents from subdirectories #8526

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

Merged
merged 2 commits into from
Mar 22, 2025

Conversation

nikpivkin
Copy link
Contributor

Description

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

// The virtual file system uses a slash ('/') as a path separator,
// but OPA uses the filepath package, which is OS-dependent.
// Therefore, we need to collect all the paths ourselves and pass them to OPA.
for _, root := range dataPaths {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the loading of data files on windows

}
return nil
}); err != nil {
log.Error("Failed to collect data file paths", log.String("root", root), log.Err(err))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@simar7 I wanted to return an error here but I was failing this test. It was succeeding before because it ignored the error. Was this done premeditated? I find this test strange and it's not clear what it covers. Let me know if it's better to return an error here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which test are you referring to? The link just points to scanner_test.go file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current behavior ignores the error (if any) that gets returned by fs.WalkDir. The test is simply simulating a case where an invalid filesystem is passed in and therefore fs.WalkDir will return an error.

But should we return an error here if we are unable to override the filesystem for data? This would only happen if the passed in srcFS isn't nil. In other cases we simply ignore it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

srcFS is only used to load data if no file system with data is passed through options. Therefore an error can occur in both cases. But I think I understood that the test is just checking that the data was not loaded.

@nikpivkin nikpivkin marked this pull request as ready for review March 12, 2025 05:38
@nikpivkin nikpivkin requested a review from simar7 as a code owner March 12, 2025 05:38
@simar7 simar7 added this pull request to the merge queue Mar 22, 2025
Merged via the queue into aquasecurity:main with commit de7eb13 Mar 22, 2025
12 checks passed
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.

2 participants