Skip to content

Commit 0c51e18

Browse files
Merge pull request #981 from tskirvin/main
(MODULES-6876) lib/puppet/provider/firewall/iptables.rb - comments cleanup for parsing
2 parents be50446 + 78a8504 commit 0c51e18

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
44

5+
## Unversioned
6+
7+
### iptables.rb
8+
9+
There are cases where spaces and quotes in iptables comments generated by
10+
mainstream sources (e.g. podman) were causing rules to not parse properly.
11+
We didn't fix the whole problem, but we removed those comments for parsing
12+
purposes.
13+
514
## [v3.2.0](https://github.com/puppetlabs/puppetlabs-firewall/tree/v3.2.0) (2021-09-06)
615

716
[Full Changelog](https://github.com/puppetlabs/puppetlabs-firewall/compare/v3.1.0...v3.2.0)
@@ -43,6 +52,7 @@ All notable changes to this project will be documented in this file. The format
4352

4453
- Fixed link to REFERENCE.md [\#993](https://github.com/puppetlabs/puppetlabs-firewall/pull/993) ([Samgarr](https://github.com/Samgarr))
4554
- Update README.md [\#986](https://github.com/puppetlabs/puppetlabs-firewall/pull/986) ([arjenz](https://github.com/arjenz))
55+
>>>>>>> upstream/main
4656
4757
## [v3.0.0](https://github.com/puppetlabs/puppetlabs-firewall/tree/v3.0.0) (2021-03-01)
4858

lib/puppet/provider/firewall/iptables.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,11 @@ def self.rule_to_hash(line, table, counter)
575575
keys << :table
576576
end
577577

578+
# manually remove comments if they made it this far
579+
if %r{-m comment --comment}.match?(values)
580+
values = values.sub(%r{-m comment --comment "((?:\\"|[^"])*)"}, {})
581+
end
582+
578583
valrev = values.scan(%r{("([^"\\]|\\.)*"|\S+)}).transpose[0].reverse
579584

580585
if keys.length != valrev.length

0 commit comments

Comments
 (0)