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

Update ACL syntax and add support for protocol filtering #618

Merged
merged 14 commits into from
Jun 11, 2022

Conversation

juanfont
Copy link
Owner

@juanfont juanfont commented Jun 8, 2022

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.

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.
@juanfont
Copy link
Owner Author

juanfont commented Jun 8, 2022

Also addresses #572

@juanfont juanfont marked this pull request as ready for review June 8, 2022 16:15
@juanfont juanfont requested a review from kradalby as a code owner June 8, 2022 16:15
@juanfont juanfont changed the title [WIP] Update ACLs code Update ACL syntax and add support for protocol filtering Jun 8, 2022
@0passInc
Copy link

0passInc commented Jun 9, 2022

We had luck using this ACL on this PR; great work.

{
    "acls": [
        {
            "action": "accept",
            "src": ["tag:workstation"],
            "dst": ["tag:workstation:*", "tag:aws:*", "tag:prod:*", "tag:michael:80"],
        }
      ],
}

restanrm
restanrm previously approved these changes Jun 9, 2022
Copy link
Contributor

@restanrm restanrm left a 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) {
Copy link
Contributor

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) {
Copy link
Contributor

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

Copy link
Owner Author

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) {
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
needsWildcard := protocolNumber != 6 && protocolNumber != 17 && protocolNumber != 132 // nolint
needsWildcard := protocolNumber != 6 && protocolNumber != 17 && protocolNumber != 132

That wont do ;)

@kradalby kradalby merged commit 883bb92 into main Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants