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

Initial development for versa application to reserve enum. #347

Merged
merged 4 commits into from
Aug 23, 2023

Conversation

sdatta09
Copy link
Contributor

@sdatta09 sdatta09 commented Aug 9, 2023

Enum added for Versa App development since Versa routers are service aware router like Paolo Alto Routers.
Once this Enum is reviewed and approved , other changes can be checked in.
pylint has been run and no new warnings introduced by the code change

pylint has been run and no new warnings introduced.
           pylint run : no warnings
versa_test.py: tests for Versa acls added
          pylint run. Only see unused import warnings.
          Tests were run without any errors
versa.md: Documentation for Versa ACLs

Please note that these are initial commits. More
commits wil be done as needed.
Copy link
Collaborator

@abhindes abhindes left a comment

Choose a reason for hiding this comment

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

I'm still going through this.

@@ -0,0 +1,877 @@
# Copyright 2011 Google Inc. All Rights Reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

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

please update

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in the next commit

#import six


ICMP_TERM_LIMIT = 8
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted


if self.term.versa_application:
predef_str = 'predefined-services-list ['
for predef in self.term.versa_application:
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably need to do some validation checking here on what valid versa applications are.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

versa.application is a list and it is check in Line 237

'tenant',
'policy'))
_VERSA_UNSUPPORTED_TERM_OPTIONS = set(('icmp_type',
'stateless_reply',
Copy link
Collaborator

Choose a reason for hiding this comment

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

stateless_reply fields are used to skip the reply flows if the firewall is stateful. Since Versa is stateful, we can remove this from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not being used. Deleted

if len(val) > 0:
if 'template' in mstr:
self.templatename = val
elif 'tenant' in mstr:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is tenant a required field? Could you provide an example of what might be populated in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a skeleton of the config.

Comment on lines 587 to 604
# we need to remove icmp from the protocol and add it to the
#pan-application list
if term.protocol and 'icmp' in ' '.join(term.protocol):
term.protocol.remove('icmp')
term.versa_application.append('ICMP')
# Because Versa terms can contain inet and inet6 addresses. We have to
# have ability to recover proper AF for ICMP type we need.
# If protocol is empty or we cannot map to inet or inet6 we insert bogus
# af_type name which will cause new_term.NormalizeIcmpTypes to fail.

#if not term.protocol:
# icmp_af_type = 'unknown_af_icmp'
#else:
# icmp_af_type = self._AF_ICMP_MAP.get(
# term.protocol[0], 'unknown_af_icmp')
#tmp_icmptype = new_term.NormalizeIcmpTypes(
# term.icmp_type, term.protocol, icmp_af_type)

Copy link
Collaborator

@abhindes abhindes Aug 16, 2023

Choose a reason for hiding this comment

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

Some cleanup necessary here to support icmpv6 correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will deal with icmpv6 in the next round

@sdatta09
Copy link
Contributor Author

sdatta09 commented Aug 16, 2023 via email

return self.target

def PrintTreeInt(self,num=0):
"""Internal function to the tree. Does recursion"""
Copy link
Collaborator

@abhindes abhindes Aug 16, 2023

Choose a reason for hiding this comment

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

We might need to check if the default recursion depths are sufficient for large policies here. Might want to move away from recursion if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already verified with multiple tests.

self.addrbook = addrbook
self.app = []

if term.source_zone:
Copy link
Collaborator

Choose a reason for hiding this comment

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

qq on Versa: Is intra-Zone traffic permitted by default, or denied by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deny

if self.term.action:
self.BuildTermLogging(access_pn)

#print("\n".join(set_term.PrintTree()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment on lines 422 to 423
#current_date = datetime.datetime.utcnow().date()
#exp_info_date = current_date + datetime.timedelta(weeks=exp_info)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment on lines 432 to 435
#if self._NOVERBOSE in filter_options[4:]:
# verbose = False

# TODO(robankeny): Clean up option section.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

Comment on lines 587 to 588
# we need to remove icmp from the protocol and add it to the
#pan-application list
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@@ -0,0 +1,476 @@
# Copyright 2012 Google Inc. All Rights Reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

pol = policy.ParsePolicy(GOOD_HEADER_1 + ICMP_TYPE_TERM_1 , self.naming)
self.assertRaises(versa.VersaUnsupportedTerm, versa.Versa, pol, EXP_INFO)

def testIcmpV6(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do so

_IPSET5 = [nacaddr.IP('10.0.0.0/24')]


class VersaTest(absltest.TestCase):
Copy link
Collaborator

Choose a reason for hiding this comment

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

We probably will need to add some more unit test coverage. The generator has a ton of different options and it will help to have more cases covered - https://github.com/google/capirca/blob/master/doc/generator_patterns.md#test-coverage

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely

Copy link
Collaborator

@abhindes abhindes left a comment

Choose a reason for hiding this comment

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

I've done a second round of reviews and left comments. We can follow up on these.

Changes for expiration, platform, platform-exclude, logging
Added tests for expiration, platform, platform-exclude, multiple
terms, logging ipv4/v6. Renamed terms for better understanding.
Ran pylint on versa.py and versa-test.py
Added Versa policy file and verified using aclgen.py
@copybara-service copybara-service bot merged commit d145ca4 into google:master Aug 23, 2023
1 of 7 checks passed
copybara-service bot pushed a commit that referenced this pull request Sep 12, 2023
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.

2 participants