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

Add FirewallRule class #86

Closed
wants to merge 2 commits into from
Closed

Add FirewallRule class #86

wants to merge 2 commits into from

Conversation

ndowmon
Copy link
Contributor

@ndowmon ndowmon commented May 17, 2021

No description provided.

@@ -0,0 +1,59 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we need to port these changes to the AWS integration? It looks like we just put these rules in an array on a key for that integration.
https://bitbucket.org/jupiterone/jupiter-integration-aws/src/b1b082a76600f85738911adbea9d4112869059e7/src/integration-aws/ec2/converters/entities.ts?at=master#entities.ts-583

Copy link
Contributor

Choose a reason for hiding this comment

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

I also assume you already took a look at Rule, but thought I'd bring that up as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, if this goes through I think it'd be good to get it into existing integrations like AWS, since the JSON.stringify(ipPermission) operation makes these properties useless from a query language perspective.

I have looked at Rule but IMO a firewall rule is a super-specific class of configuration (as indicated by the common properties shared across all firewall rules)

mknoedel
mknoedel previously approved these changes May 17, 2021
Copy link
Contributor

@mknoedel mknoedel left a comment

Choose a reason for hiding this comment

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

Looks good to me so long as you have determined we need this. I would like a little documentation on the PR for easier debugging in the future before you merge this though.

@ndowmon ndowmon linked an issue May 17, 2021 that may be closed by this pull request
"type": "integer"
},
"source": {
"description": "Source of the firewall rule. Can be IP address, CIDR range, 'Any', or other firewall-defined options.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we recommend only * instead of Any?

"format": "ip"
},
"sourcePort": {
"description": "Source port of the firewall rule. Typically an integer between 0 and 65535, but could also be 'Any', '*', or range of ports.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Any, *, or "range of ports", will not be accepted when thetype is integer

"format": "ip"
},
"destinationPort": {
"description": "Destination port of the firewall rule. Typically an integer between 0 and 65535, but could also be 'Any', '*', or range of ports.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we recommend only * instead of Any?

"protocol": {
"description": "The protocol ",
"type": "string",
"examples": ["TCP", "UDP", "Any"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question about recommending * here?

@erkangz
Copy link
Member

erkangz commented May 18, 2021

I did not follow the change here closely. Why is this class needed?

I think we have a Rule and RuleSet class already?

@erkangz
Copy link
Member

erkangz commented May 18, 2021

With the AWS integration, details of each rule are captures as properties on the relationship between the entity and what is allowed to/from the entity.

I'm concerned that adding this will unnecessarily add more entities, which is undesired from both our perspective (data volume) and customer's (cost).

@ndowmon
Copy link
Contributor Author

ndowmon commented May 18, 2021

@erkangz yes, I see how this works in AWS. My concern with putting firewall rules on edges is that we cannot be as expressive on edges as we can on nodes (at least in J1QL). For example, there's not currently a way in J1QL to express direction of edges, representing ingress/egress, and edges do not allow array properties for IP addresses, ports, or protocols defined by these rules. Those are some of my main concerns when assigning firewall rules to edges.

As for creating a new class FirewallRule as opposed to using Rule, this is a pretty rare case where almost all firewall rules will share this collection of properties (sourcePort, sourceIp, destinationPort, destinationIp, protocol, action, direction), and none of these properties would be valid for almost any other type of Rule, so the distinction in my mind lends FirewallRule to its own classification.

@erkangz
Copy link
Member

erkangz commented May 21, 2021

@erkangz yes, I see how this works in AWS. My concern with putting firewall rules on edges is that we cannot be as expressive on edges as we can on nodes (at least in J1QL). For example, there's not currently a way in J1QL to express direction of edges, representing ingress/egress, and edges do not allow array properties for IP addresses, ports, or protocols defined by these rules. Those are some of my main concerns when assigning firewall rules to edges.

As for creating a new class FirewallRule as opposed to using Rule, this is a pretty rare case where almost all firewall rules will share this collection of properties (sourcePort, sourceIp, destinationPort, destinationIp, protocol, action, direction), and none of these properties would be valid for almost any other type of Rule, so the distinction in my mind lends FirewallRule to its own classification.

Valid concern. However, that's a query lang issue/limitation and I don't think we should change the data-model because of that. For direction, specifically to firewall rules, we do have ingress and egress boolean properties on the edge that can be used to filter on direction.

@aiwilliams
Copy link
Contributor

tldr; I would stick with the current approach until we can prove it won't work (perhaps examples from Azure or Google Cloud) and we should develop docs describing the firewall model and how to implement it.

A few thoughts:

  • We can make any entity class non-billable.
  • There would be number of rules X 2 more objects if we had another entity between a Firewall and the resources it relates to because of a rule (Firewall -> FirewallRule -> (Host|IpAddress|Network) vs Firewall -> (Host|IpAddress|Network)), but I think it very little data in the big scheme of things.
  • We want to relate the Firewall to each (Host|IpAddress|Network) represented in a rule, so it isn't necessary for these rule relationships to support string[] properties.
  • It is reasonable to anticipate we can make the query language support relationships better, though I believe we've added properties to entities in the past to get them into the index and duplicated property names to make queries look better, efforts that acknowledge it could be some time before the query language/service supports features to avoid those ingestion decisions.
  • It is understandable that early decisions can make it difficult to change things now, and there would need to be good reasons to go through pains to do so.

Here are some reasons I recall that relationships were chosen.

  1. Firewall rules simply define relationships between the Firewall and (Host|IpAddress|Network) entities, similar to a policy document (rules could be added as raw data of a Firewall).
  2. This query reads nicely: find Host that PROTECTS Firewall that ALLOWS Internet.
  3. This query reads less nice: find Host that PROTECTS Firewall that HAS Rule that ALLOWS Internet.
  4. This query allows listing specific rules just fine: find Host that PROTECTS Firewall that ALLOWS as rule Network where rule.inbound=true return rule.*.

@erkangz, do you have others?

@aiwilliams
Copy link
Contributor

Note that there is a TypeScript type for rule relationships:

export interface FirewallRuleProperties {

@ndowmon ndowmon closed this Jul 21, 2021
@zemberdotnet zemberdotnet deleted the add-FirewallRule branch August 24, 2022 19:25
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.

Create FirewallRule entity class
5 participants