Skip to content

Commit

Permalink
Rename whitelist_file to allow_file
Browse files Browse the repository at this point in the history
Note: This is a breaking change.

Signed-off-by: Balasankar "Balu" C <[email protected]>
  • Loading branch information
balasankarc committed Aug 16, 2021
1 parent 0efd9b5 commit 0964181
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,19 @@ omnibus manifest PROJECT -l warn

This will output a JSON-formatted manifest containing the resolved version of every software definition.

## Whitelisting Libraries
## Allowing/Ignoring Libraries

Sometimes a platform has libraries that need to be whitelisted so the healthcheck can pass. The whitelist found in the [healthcheck](https://github.com/chef/omnibus/blob/master/lib/omnibus/health_check.rb) code comprises the minimal required for successful builds on supported platforms.
Sometimes a platform has libraries that need to be allowed so the healthcheck can pass. The allowlist found in the [healthcheck](https://github.com/chef/omnibus/blob/master/lib/omnibus/health_check.rb) code comprises the minimal required for successful builds on supported platforms.

To add your own whitelisted library, simply add a regex to your software definition in your omnibus project as follows:
To add your own allowed library, simply add a regex to your software definition in your omnibus project as follows:

```
whitelist_file /libpcrecpp\.so\..+/
allow_file /libpcrecpp\.so\..+/
```

It is typically a good idea to add a conditional to whitelist based on the specific platform that requires it.
It is typically a good idea to add a conditional to allowlist based on the specific platform that requires it.

_Warning: You should only add libraries to the whitelist that are guaranteed to be on the system you install to; if a library comes from a non-default package you should instead build it into the package._
_Warning: You should only add libraries to the allowlist that are guaranteed to be on the system you install to; if a library comes from a non-default package you should instead build it into the package._

## Changelog

Expand Down
6 changes: 3 additions & 3 deletions lib/omnibus/health_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ def hex
#
# @return [Array<String, Regexp>]
#
def whitelist_files
def allow_files
project.library.components.inject([]) do |array, component|
array += component.whitelist_files
array += component.allow_files
array
end
end
Expand Down Expand Up @@ -446,7 +446,7 @@ def check_for_bad_library(bad_libs, current_library, name, linked)
safe ||= true if reg.match(name)
end

whitelist_files.each do |reg|
allow_files.each do |reg|
safe ||= true if reg.match(current_library)
end

Expand Down
14 changes: 7 additions & 7 deletions lib/omnibus/software.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,20 +540,20 @@ def version(val = NULL, &block)
# Add a file to the healthcheck allowlist.
#
# @example
# whitelist_file '/path/to/file'
# allow_file '/path/to/file'
#
# @param [String, Regexp] file
# the name of a file to ignore in the healthcheck
#
# @return [Array<String>]
# the list of currently allowed files
#
def whitelist_file(file)
def allow_file(file)
file = Regexp.new(file) unless file.is_a?(Regexp)
whitelist_files << file
whitelist_files.dup
allow_files << file
allow_files.dup
end
expose :whitelist_file
expose :allow_file

#
# The path relative to fetch_dir where relevant project files are
Expand Down Expand Up @@ -926,8 +926,8 @@ def dependencies
#
# @return [Array<String>]
#
def whitelist_files
@whitelist_files ||= []
def allow_files
@allow_files ||= []
end

#
Expand Down
18 changes: 9 additions & 9 deletions spec/unit/software_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module Omnibus
it_behaves_like "a cleanroom setter", :license_file, %{license_file 'LICENSES/artistic.txt'}
it_behaves_like "a cleanroom setter", :skip_transitive_dependency_licensing, %{skip_transitive_dependency_licensing true}
it_behaves_like "a cleanroom setter", :dependency_licenses, %{dependency_licenses [{license: "MIT"}]}
it_behaves_like "a cleanroom setter", :whitelist_file, %{whitelist_file '/opt/whatever'}
it_behaves_like "a cleanroom setter", :allow_file, %{allow_file '/opt/whatever'}
it_behaves_like "a cleanroom setter", :relative_path, %{relative_path '/path/to/extracted'}
it_behaves_like "a cleanroom setter", :build, %|build {}|
it_behaves_like "a cleanroom getter", :project_dir
Expand Down Expand Up @@ -453,17 +453,17 @@ module Omnibus
end
end

describe "#whitelist_file" do
it "appends to the whitelist_files array" do
expect(subject.whitelist_files.size).to eq(0)
subject.whitelist_file(%r{foo/bar})
expect(subject.whitelist_files.size).to eq(1)
describe "#allow_file" do
it "appends to the allow_files array" do
expect(subject.allow_files.size).to eq(0)
subject.allow_file(%r{foo/bar})
expect(subject.allow_files.size).to eq(1)
end

it "converts Strings to Regexp instances" do
subject.whitelist_file "foo/bar"
expect(subject.whitelist_files.size).to eq(1)
expect(subject.whitelist_files.first).to be_kind_of(Regexp)
subject.allow_file "foo/bar"
expect(subject.allow_files.size).to eq(1)
expect(subject.allow_files.first).to be_kind_of(Regexp)
end
end

Expand Down

0 comments on commit 0964181

Please sign in to comment.