Skip to content

Commit

Permalink
fix 3 tuple rule generation
Browse files Browse the repository at this point in the history
If the port is not present, 'any' is not required, just the empty string
  • Loading branch information
JustinAzoff committed Feb 23, 2018
1 parent 99f013e commit b2b336f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions dumbno.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def make_rule_fragment(protocol, host, port):
#ip based ACL, no ports
if protocol.startswith("ip"):
return a
port_wildcard = "any" if host else ""
ap = ("eq %s" % port) if port else port_wildcard
ap = ("eq %s" % port) if port else ""

return a + " " + ap

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup

setup(name='dumbno',
version='0.8.1',
version='0.8.2',
zip_safe=True,
py_modules = ["dumbno"],
install_requires=[
Expand Down
2 changes: 1 addition & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_make_rule():
dict(s="1.2.3.4", d="5.6.7.8")),
('tcp host 1.2.3.4 eq 123 host 5.6.7.8 eq 567',
dict(s="1.2.3.4", d="5.6.7.8", sp=123, dp=567, proto='tcp')),
('tcp host 1.2.3.4 any host 5.6.7.8 eq 567',
('tcp host 1.2.3.4 host 5.6.7.8 eq 567',
dict(s="1.2.3.4", d="5.6.7.8", dp=567, proto='tcp')),
('tcp any host 5.6.7.8 eq 567',
dict(d="5.6.7.8", dp=567, proto='tcp')),
Expand Down

0 comments on commit b2b336f

Please sign in to comment.