Skip to content

Commit

Permalink
Validate file name for apt configuration files
Browse files Browse the repository at this point in the history
Closes #122
  • Loading branch information
Thom May committed Mar 23, 2015
1 parent e159b8f commit d9da784
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/preference.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(*args)
:pin,
:pin_priority

attribute :package_name, :kind_of => String, :name_attribute => true
attribute :package_name, :kind_of => String, :name_attribute => true, :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-|\.)+$/ ]

This comment has been minimized.

Copy link
@helgi

helgi Mar 24, 2015

I am not sure I understand why the regex is being so strict. I used to be able to pass in package* without any issue, I understand glob is for that but I don't see any difference between those two at this point. Both package_name and glob both feed into build_pref

Would it be possible to allow * in the package name regex instead?

This comment has been minimized.

Copy link
@thommay

thommay Mar 25, 2015

Contributor

@helgi The problem is that the name is used for the file name - and apt applies the above regex as a glob to find the files it'll load. From apt_preferences(5):

 The files have either no or "pref" as filename extension
       and only contain alphanumeric, hyphen (-), underscore (_) and period
       (.) characters.

This comment has been minimized.

Copy link
@helgi

helgi Mar 25, 2015

That makes sense. I pass in package_name specifically (or did, am doing glob now to get tests passing again) and did the resource name separately.

Probably a special case the way I did it so I'll just accept it as is, glob works well enough :)

attribute :glob, :kind_of => String
attribute :pin, :kind_of => String
attribute :pin_priority, :kind_of => String
2 changes: 1 addition & 1 deletion resources/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def initialize(*args)
:uri

# name of the repo, used for source.list filename
attribute :repo_name, :kind_of => String, :name_attribute => true
attribute :repo_name, :kind_of => String, :name_attribute => true, :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-|\.)+$/ ]
attribute :uri, :kind_of => String
attribute :distribution, :kind_of => String
attribute :components, :kind_of => Array, :default => []
Expand Down

1 comment on commit d9da784

@fsultan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also causes an issue with the current version of the debian cookbook [https://github.com/reaktor/chef-debian/issues/16]

Please sign in to comment.