Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept pre-existing rule with invalid name #192

Merged

Conversation

joejulian
Copy link
Contributor

This patch fixes up a pre-existing rule whose name does not
type-validate with a valid name (typically one without a numeric
prefix in the comment).

Fixes #116
Signed-off-by: Joe Julian me@joejulian.name

This patch fixes up a pre-existing rule whose name does not
type-validate with a valid name (typically one without a numeric
prefix in the comment).

Fixes puppetlabs#116
Signed-off-by: Joe Julian <me@joejulian.name>
@kbarber-jenkins-bot
Copy link

Can one of the admins verify this patch?

@joejulian
Copy link
Contributor Author

I still haven't built a vm for rspec testing so I don't know if the tests I wrote are any good yet.

@kbarber
Copy link
Contributor

kbarber commented May 30, 2013

@joejulian you don't need to build a VM, just install Vagrant + Virtualbox from dmg, deb or rpm, and follow the instructions: https://github.com/puppetlabs/puppetlabs-firewall#testing ... the necessary VM's get downloaded for you depending on what node set you choose.

# Puppet-firewall requires that all rules have comments (resource names) and match this
# regex and will fail if a rule in iptables does not have a comment. We get around this
# by appending a high level
if not /^\d+[[:alpha:][:digit:][:punct:][:space:]]+$/ =~ hash[:name]
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks almost correct, but if am I mistaken, won't the logic of this 'if' always apply even for the empty case which the next is meant to catch? Since hash[:name] == nil or '' will match this expression first ...

You almost want to do:

if ! hash[:name]
  ...
elsif not /^ ... / =~ hash[:name]
  ..
end

Don't you? Otherwise cases without a comment will just get a number, without the hexdigest to fill out the text.

@kbarber
Copy link
Contributor

kbarber commented Jun 3, 2013

ok to test

@kbarber-jenkins-bot
Copy link

Merged build triggered. (Status: PENDING, Details: null)

@kbarber-jenkins-bot
Copy link

Merged build started. (Status: PENDING, Details: http://box.bob.sh:8080/job/puppetlabs-firewall-system/229/)

@kbarber-jenkins-bot
Copy link

Merged build finished. (Status: SUCCESS, Details: http://box.bob.sh:8080/job/puppetlabs-firewall-system/229/)

kbarber added a commit that referenced this pull request Jun 3, 2013
Accept pre-existing rule with invalid name
@kbarber kbarber merged commit 78d8e43 into puppetlabs:master Jun 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants