forked from evolvingweb/puppet-apt
-
Notifications
You must be signed in to change notification settings - Fork 461
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prior to this commit there was a possibility that malformed strings could be passed as the resources name. This could lead to unsafe executions on a remote system. This was also a possibility for the options parameter as it was constrained to a string. In addition, commands were not properly broken out in to arrays of arguments when passed to the exec resource. This commit fixes the above by adding validation to the resource name ensuring that the given ppa name conforms to expectation. Also, commands are now broken down in to arrays of arguments appropriately. This ensures safer execution on the remote system. Given that the options parameter, passed as a raw string, could lead to unsafe code execution it was reasonable to change the accepted type to an `Optional[Array[String]]. This means that an array of options can now be passed to the exec resource inside the original command.
- Loading branch information
Showing
6 changed files
with
102 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class { 'apt': } | ||
|
||
# Example declaration of an Apt PPA | ||
apt::ppa { 'ppa:openstack-ppa/bleeding-edge': } | ||
apt::ppa { 'ppa:ubuntuhandbook1/apps': } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
# This fact lists the .list filenames that are used by apt. | ||
Facter.add(:apt_sources) do | ||
confine osfamily: 'Debian' | ||
setcode do | ||
sources = ['sources.list'] | ||
Dir.glob('/etc/apt/sources.list.d/*.list').each do |file| | ||
sources.push(File.basename(file)) | ||
end | ||
sources | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<%- | Array $command, String $sources_list_d_path, String $sources_list_d_filename | -%> | ||
|
||
<%= $command.join(' ') %> | ||
|
||
if [ $? -gt 0 ]; then | ||
rm <%= $sources_list_d_path %>/<%= $sources_list_d_filename %> | ||
exit 1 | ||
fi |