inspec check: Allow 'Proprietary' as a valid license term.

Signed-off-by: James Stocks <jstocks@chef.io>
This commit is contained in:
Clinton Wolfe 2019-01-22 15:50:38 -05:00 committed by GitHub
commit 2f42803a90
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View file

@ -91,9 +91,9 @@ module Inspec
warnings.push("Missing profile #{field} in #{ref}")
end
# if version is set, ensure it is in SPDX format
if !params[:license].nil? && !Spdx.valid_license?(params[:license])
warnings.push("License '#{params[:license]}' needs to be in SPDX format. See https://spdx.org/licenses/.")
# if license is set, ensure it is in SPDX format or marked as proprietary
if !params[:license].nil? && !valid_license?(params[:license])
warnings.push("License '#{params[:license]}' needs to be in SPDX format or marked as 'Proprietary'. See https://spdx.org/licenses/.")
end
[errors, warnings]
@ -112,6 +112,10 @@ module Inspec
false
end
def valid_license?(value)
value =~ /^Proprietary[,;]?\b/ || Spdx.valid_license?(value)
end
def method_missing(sth, *args)
@logger.warn "#{ref} doesn't support: #{sth} #{args}"
@missing_methods.push(sth)

View file

@ -3,6 +3,6 @@ title: InSpec Profile
maintainer: The Authors
copyright: The Authors
copyright_email: you@example.com
license: Apache-2.0
license: Proprietary, All rights reserved
summary: An InSpec Compliance Profile
version: 0.1.0

View file

@ -294,7 +294,7 @@ describe Inspec::Profile do
it 'prints ok messages and counts the controls' do
logger.expect :info, nil, ["Checking profile in #{home}/mock/profiles/#{profile_id}"]
logger.expect :warn, nil, ["License 'Invalid License Name' needs to be in SPDX format. See https://spdx.org/licenses/."]
logger.expect :warn, nil, ["License 'Invalid License Name' needs to be in SPDX format or marked as 'Proprietary'. See https://spdx.org/licenses/."]
logger.expect :warn, nil, ['No controls or tests were defined.']
logger.expect :info, nil, ["Metadata OK."]