Merge pull request #1280 from grimm26/apt

improved regex for matching deb sources
This commit is contained in:
Christoph Hartmann 2016-11-09 11:19:13 -06:00 committed by GitHub
commit 2c75a2c8db
3 changed files with 27 additions and 1 deletions

View file

@ -89,7 +89,8 @@ module Inspec::Resources
active = false if raw_line != line
# eg.: deb http://archive.ubuntu.com/ubuntu/ wily main restricted
parse_repo = /^\s*(\S+)\s+"?([^ "\t\r\n\f]+)"?\s+(\S+)\s+(.*)$/.match(line)
# or : deb [trusted=yes] http://archive.ubuntu.com/ubuntu/ wily main restricted
parse_repo = /^\s*(\S+)\s+(?:\[\S+\])?\s*"?([^ "\t\r\n\f]+)"?\s+(\S+)\s+(.*)$/.match(line)
# check if we got any result and the second param is an url
next if parse_repo.nil? || !parse_repo[2] =~ HTTP_URL_RE

View file

@ -10,6 +10,14 @@ when 'ubuntu'
uri 'ppa:nginx/stable'
distribution node['lsb']['codename']
end
apt_repository 'chef-stable' do
uri 'https://packages.chef.io/stable-apt'
key 'https://downloads.chef.io/packages-chef-io-public.key'
distribution node['lsb']['codename']
components ['main']
trusted true
end
when 'debian'
# use plain repo
apt_repository 'nginx' do
@ -17,4 +25,12 @@ when 'debian'
distribution node['lsb']['codename']
components ['nginx']
end
apt_repository 'chef-stable' do
uri 'https://packages.chef.io/stable-apt'
key 'https://downloads.chef.io/packages-chef-io-public.key'
distribution node['lsb']['codename']
components ['main']
trusted true
end
end

View file

@ -22,6 +22,11 @@ if os[:name] == 'ubuntu'
it { should_not be_enabled }
end
describe apt('https://packages.chef.io/stable-apt') do
it { should exist }
it { should be_enabled }
end
elsif os[:family] == 'debian'
describe apt('http://nginx.org/packages/debian') do
@ -34,4 +39,8 @@ elsif os[:family] == 'debian'
it { should_not be_enabled }
end
describe apt('https://packages.chef.io/stable-apt') do
it { should exist }
it { should be_enabled }
end
end