-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Update ACL syntax and add support for protocol filtering #618
Conversation
Implements #617. Tailscale has changed the format of their ACLs to use a more firewall-y terms ("users" & "ports" -> "src" & "dst"). They have also started using all-lowercase tags. This PR applies these changes.
Also addresses #572 |
We had luck using this ACL on this PR; great work.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good !
acls_test.go
Outdated
@@ -143,7 +143,7 @@ func (s *Suite) TestValidExpandTagOwnersInUsers(c *check.C) { | |||
|
|||
// this test should validate that we can expand a group in a TagOWner section and | |||
// match properly the IP's of the related hosts. The owner is valid and the tag is also valid. | |||
// the tag is matched in the Ports section. | |||
// the tag is matched in the Destinations section. | |||
func (s *Suite) TestValidExpandTagOwnersInPorts(c *check.C) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you rename this as well ?
@@ -628,7 +642,8 @@ func Test_expandTagOwners(t *testing.T) { | |||
|
|||
func Test_expandPorts(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should be renamed too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that one actually expands ports :)
// Also returns a boolean indicating if the protocol | ||
// requires all the destinations to use wildcard as port number (only TCP, | ||
// UDP and SCTP support specifying ports). | ||
func parseProtocol(protocol string) ([]int, bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these numbers will trigger "magicnumber" when the linter is up and running, and in any case, it would be better to probably have constants for these
acls_test.go
Outdated
c.Assert(rules, check.NotNil) | ||
|
||
c.Assert(rules, check.HasLen, 3) | ||
c.Assert(rules[0].IPProto[0], check.Equals, 6) // tcp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is why we want constants.
acls.go
Outdated
if err != nil { | ||
return nil, false, err | ||
} | ||
needsWildcard := protocolNumber != 6 && protocolNumber != 17 && protocolNumber != 132 // nolint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needsWildcard := protocolNumber != 6 && protocolNumber != 17 && protocolNumber != 132 // nolint | |
needsWildcard := protocolNumber != 6 && protocolNumber != 17 && protocolNumber != 132 |
That wont do ;)
Implements #617.
Tailscale has changed the format of their ACLs to use a more firewall-y terms ("users" & "ports" -> "src" & "dst"). They have also started using all-lowercase tags.
Also, protocol filtering support :)
This PR implements these changes.