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

PAN support application any with service application-default #5310

Merged
merged 4 commits into from
Jan 3, 2020

Conversation

sfraint
Copy link
Member

@sfraint sfraint commented Dec 23, 2019

Add support for any application, which was previously unhandled in Batfish.

In Palo Alto security rules, application-default can be specified as service match, which effectively defers traffic matching to application inspection. In that case, the special any application should match any application defined on the device.

After this PR, Batfish assumes that all traffic will match the any application.

@batfish-bot
Copy link

This change is Reviewable

@codecov
Copy link

codecov bot commented Dec 24, 2019

Codecov Report

Merging #5310 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@             Coverage Diff              @@
##             master    #5310      +/-   ##
============================================
+ Coverage      73.4%    73.4%   +<.01%     
- Complexity    31992    32007      +15     
============================================
  Files          2624     2624              
  Lines        128981   129057      +76     
  Branches      15512    15523      +11     
============================================
+ Hits          94682    94739      +57     
- Misses        26797    26815      +18     
- Partials       7502     7503       +1
Impacted Files Coverage Δ Complexity Δ
...epresentation/palo_alto/PaloAltoConfiguration.java 85.8% <100%> (+0.03%) 253 <0> (+1) ⬆️
...tfish/datamodel/visitors/HeaderSpaceConverter.java 27.27% <0%> (-11.19%) 3% <0%> (ø)
...ish/representation/cumulus/CumulusConversions.java 88.01% <0%> (-8.77%) 128% <0%> (+117%)
.../src/main/java/org/batfish/datamodel/flow/Hop.java 53.33% <0%> (-6.67%) 5% <0%> (-1%)
...col/src/main/java/org/batfish/role/InferRoles.java 89.54% <0%> (-1.37%) 50% <0%> (-1%)
...src/main/java/org/batfish/coordinator/PoolMgr.java 64.04% <0%> (-1.13%) 15% <0%> (-1%)
...rg/batfish/dataplane/ibdp/EigrpRoutingProcess.java 92.72% <0%> (-0.39%) 68% <0%> (-1%)
...batfish/src/main/java/org/batfish/main/Driver.java 38.25% <0%> (-0.25%) 28% <0%> (ø)
...sh/representation/cisco_xr/CiscoXrConversions.java 30.47% <0%> (-0.04%) 49% <0%> (ø)
.../cumulus_nclu/CumulusNcluConfigurationBuilder.java 86.25% <0%> (-0.02%) 251% <0%> (ø)
... and 8 more

Copy link
Member Author

@sfraint sfraint left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion


projects/batfish/src/main/java/org/batfish/representation/palo_alto/PaloAltoConfiguration.java, line 1018 at r2 (raw file):

Quoted 7 lines of code…
        if (rule.getAction() == LineAction.PERMIT) {
          // Since Batfish cannot currently match above L4, we follow Cisco-fragments-like logic:
          // When permitting an application, optimistically permit all traffic where the L4 rule
          // matches, assuming it is this application. But when blocking a specific application, do
          // not block all matching L4 traffic, since we can't know it is this specific application.
          serviceDisjuncts.addAll(matchApplications(rule, vsys));
        }

is this the desired behavior even when any is in the set of applications for a deny rule? i.e. no traffic will match a "deny any application" rule w/ application-default specified

I haven't seen any deny rules referencing any application with application-default specified, but it is surely possible

@dhalperi
Copy link
Member

dhalperi commented Jan 2, 2020


projects/batfish/src/main/java/org/batfish/representation/palo_alto/PaloAltoConfiguration.java, line 1018 at r2 (raw file):

Previously, sfraint (Spencer Fraint) wrote…
        if (rule.getAction() == LineAction.PERMIT) {
          // Since Batfish cannot currently match above L4, we follow Cisco-fragments-like logic:
          // When permitting an application, optimistically permit all traffic where the L4 rule
          // matches, assuming it is this application. But when blocking a specific application, do
          // not block all matching L4 traffic, since we can't know it is this specific application.
          serviceDisjuncts.addAll(matchApplications(rule, vsys));
        }

is this the desired behavior even when any is in the set of applications for a deny rule? i.e. no traffic will match a "deny any application" rule w/ application-default specified

I haven't seen any deny rules referencing any application with application-default specified, but it is surely possible

Don't you mean all traffic will match?

@dhalperi
Copy link
Member

dhalperi commented Jan 2, 2020


projects/batfish/src/main/java/org/batfish/representation/palo_alto/PaloAltoConfiguration.java, line 1044 at r2 (raw file):

Quoted 4 lines of code…
      // Assume all traffic matches some application under the "any" definition
      if (name.equals(CATCHALL_APPLICATION_NAME)) {
        return ImmutableList.of(TrueExpr.INSTANCE);
      }

This almost certainly needs to go down below where we check built-ins? Although hopefully no one overrides the any built-in?

Copy link
Member Author

@sfraint sfraint left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 3 files reviewed, 2 unresolved discussions (waiting on @dhalperi, @progwriter, and @sfraint)


projects/batfish/src/main/java/org/batfish/representation/palo_alto/PaloAltoConfiguration.java, line 1018 at r2 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

Don't you mean all traffic will match?

yes, meant all traffic will match, and no traffic will be permitted

Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @progwriter and @sfraint)


projects/batfish/src/main/java/org/batfish/representation/palo_alto/PaloAltoConfiguration.java, line 1018 at r2 (raw file):

Previously, sfraint (Spencer Fraint) wrote…

yes, meant all traffic will match, and no traffic will be permitted

Is that not the only case this comes up?


projects/batfish/src/main/java/org/batfish/representation/palo_alto/PaloAltoConfiguration.java, line 1035 at r2 (raw file):

  }

  private List<AclLineMatchExpr> matchApplications(SecurityRule rule, Vsys vsys) {

Is this function only used above? If so, rename to something that indicates that?

bad attempt: matchServiceForApplications

Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @progwriter and @sfraint)

a discussion (no related file):
Please rename PR to better indicate the change. We absolutely have support for the any application.


@sfraint sfraint changed the title PAN support application any PAN support application any with service application-default Jan 2, 2020
Copy link
Member Author

@sfraint sfraint left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dhalperi, @progwriter, and @sfraint)

a discussion (no related file):

Previously, dhalperi (Dan Halperin) wrote…

Please rename PR to better indicate the change. We absolutely have support for the any application.

Updated



projects/batfish/src/main/java/org/batfish/representation/palo_alto/PaloAltoConfiguration.java, line 1018 at r2 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

Is that not the only case this comes up?

Chatted more offline about this and decided maybe we should handle the case where a deny rule uses any application with application-default service, since we currently will never match or deny traffic due to a rule like that.

This also seems like something we can add separately from this PR.


projects/batfish/src/main/java/org/batfish/representation/palo_alto/PaloAltoConfiguration.java, line 1044 at r2 (raw file):
Did you mean create a built-in for any instead of special-asing it here?

And you cannot override the any built-in 🙂

>>> set vsys vsys1 application any description testing
Server error :  'any' is invalid. 'any' is not allowed

Copy link
Member Author

@sfraint sfraint left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 3 files reviewed, all discussions resolved (waiting on @dhalperi and @progwriter)


projects/batfish/src/main/java/org/batfish/representation/palo_alto/PaloAltoConfiguration.java, line 1035 at r2 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

Is this function only used above? If so, rename to something that indicates that?

bad attempt: matchServiceForApplications

done, didn't think of anything much better so sticking with that

Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @progwriter)

@sfraint sfraint merged commit 110e598 into master Jan 3, 2020
@sfraint sfraint deleted the pan-any-app branch January 3, 2020 17:31
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.

None yet

3 participants