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

inputs.iptables - does not catch some rules: invalid regexp #3058

Closed
alteist opened this issue Jul 26, 2017 · 0 comments · Fixed by #3060
Closed

inputs.iptables - does not catch some rules: invalid regexp #3058

alteist opened this issue Jul 26, 2017 · 0 comments · Fixed by #3060
Labels
bug unexpected problem or unintended behavior
Milestone

Comments

@alteist
Copy link

alteist commented Jul 26, 2017

Bug: inputs.iptables plugin does not read some rules, because it expects comments only in the end of each line of iptables output, but some of these lines do not end with comment.

Example:
# iptables -nvL SHAPER -t mangle -x | tail -2
0 0 ACCEPT all -- * * 1.3.5.7 0.0.0.0/0 /* test */
0 0 CLASSIFY all -- * * 1.3.5.7 0.0.0.0/0 /* test2 */ CLASSIFY set 1:4

# telegraf --config /etc/telegraf/telegraf.conf --input-filter iptables --test
* Plugin: inputs.iptables, Collection 1
> iptables,ruleid=test,dc=somedc,host=somehost,table=mangle,chain=SHAPER bytes=0i,pkts=0i 1501092198000000000
As you can see, test2 rule ommited by plugin parser.

Reason:
https://github.com/influxdata/telegraf/blob/master/plugins/inputs/iptables/iptables.go#L98
var valuesRe = regexp.MustCompile(^\s*([0-9]+)\s+([0-9]+)\s+.?(/*\s(.)\s*/)?$)

Fix: The end of regexp */)?$ must be rewriten to something like */)?+.*?$

I don't know golang and it's toolchain, so cannot check it, but I'm pretty sure the problem is here.

@danielnelson danielnelson added the bug unexpected problem or unintended behavior label Jul 26, 2017
@danielnelson danielnelson added this to the 1.4.0 milestone Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants