fix: make dotfile loading optional, defaulting to off#112
Open
fix: make dotfile loading optional, defaulting to off#112
Conversation
When loading via Dir.glob on a real filesystem, Ruby's glob engine skips hidden files and directories (those starting with '.') because the default '*' pattern does not match dot-prefixed names. The zip filesystem adapter (rubyzip's Zip::FileSystem) does not share this behaviour and could return dotfiles from its glob, leading to inconsistent results depending on how the environment was loaded. Add a `load_dotfiles:` keyword argument (default: false) to ModuleLoader and thread it through EnvironmentLoader. When false, any file whose path relative to the compliance_profiles base directory contains a component beginning with '.' -- whether the filename itself (.profile.yaml) or an intermediate directory (.hidden/profile.yaml) -- is skipped after the glob. EnvironmentLoader::Zip passes load_dotfiles: true so that its existing behaviour (loading dotfiles from zip archives) is preserved and callers who depend on it are not silently broken. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rather than hard-coding load_dotfiles: true in the super() call, accept it as a keyword argument so callers can opt out of dotfile loading when reading from a zip archive. The default remains true to preserve the existing zip-loader behaviour. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add expectations to environment_loader_spec and zip_spec confirming that load_dotfiles is passed correctly to ModuleLoader in each case: - EnvironmentLoader defaults to load_dotfiles: false and forwards true when explicitly requested. - EnvironmentLoader::Zip defaults to load_dotfiles: true (preserving historical zip behaviour) and forwards false when requested. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses inconsistent dotfile handling between filesystem-based and zip-based environment loading by introducing an explicit load_dotfiles: option and enforcing consistent filtering semantics.
Changes:
- Add
load_dotfiles:keyword argument (defaultfalse) toComplianceEngine::ModuleLoaderand thread it throughComplianceEngine::EnvironmentLoader. - Implement dotfile (and dot-directory) filtering in
ModuleLoaderwhenload_dotfiles: false. - Default
EnvironmentLoader::Ziptoload_dotfiles: trueto preserve historical zip behavior, with specs covering both defaults and overrides.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
lib/compliance_engine/module_loader.rb |
Adds load_dotfiles: option and filters out dotfile/dot-directory paths when disabled. |
lib/compliance_engine/environment_loader.rb |
Threads load_dotfiles: through to each ModuleLoader instance (default off). |
lib/compliance_engine/environment_loader/zip.rb |
Defaults zip loader to load_dotfiles: true and passes it to EnvironmentLoader. |
spec/classes/compliance_engine/module_loader_spec.rb |
Adds tests validating default exclusion and opt-in inclusion of dotfiles. |
spec/classes/compliance_engine/environment_loader_spec.rb |
Verifies EnvironmentLoader passes load_dotfiles: through to ModuleLoader. |
spec/classes/compliance_engine/environment_loader/zip_spec.rb |
Verifies zip loader default (true) and override behavior for load_dotfiles:. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When loading via Dir.glob on a real filesystem, Ruby's glob engine skips hidden files and directories (those starting with '.') because the default '*' pattern does not match dot-prefixed names. The zip filesystem adapter (rubyzip's Zip::FileSystem) does not share this behaviour and could return dotfiles from its glob, leading to inconsistent results depending on how the environment was loaded.
Add a
load_dotfiles:keyword argument (default: false) to ModuleLoader and thread it through EnvironmentLoader. When false, any file whose path relative to the compliance_profiles base directory contains a component beginning with '.' -- whether the filename itself (.profile.yaml) or an intermediate directory (.hidden/profile.yaml) -- is skipped after the glob.EnvironmentLoader::Zip passes load_dotfiles: true so that its existing behaviour (loading dotfiles from zip archives) is preserved and callers who depend on it are not silently broken.
Closes #52