Firewall policy optimization method and device, equipment and storage medium
Through bipartite graph optimization and tree structure construction of firewall policies, combined with subnet address objects and policy openness, the problem of low firewall policy optimization efficiency is solved, reducing the number of rules and simplifying policy management.
Patent Information
- Application Number
- CN202311398158.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-26
- Publication Date
- 2024-10-18
AI Technical Summary
Existing firewall policy optimization solutions are inefficient, leading to duplication of policies, increased firewall load, and reduced performance.
The bipartite graph of the original firewall policy is used for optimization, a tree structure is constructed, the target policy is determined based on the subnet address object and leaf nodes, the number of rules is updated through the policy openness, and the number of rules is reduced to improve efficiency.
Without losing security, reduce the complexity of firewall policy management, improve optimization efficiency, reduce the number of rules, and simplify policy management.
Smart Images

Figure CN118802216A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network security technology, and in particular to a firewall policy optimization method, device, equipment and storage medium. Background Art
[0002] As the number of firewall devices increases, the number of policies configured on the firewall is huge. At the same time, faced with a large number of complex policies, policy management becomes extremely difficult.
[0003] At present, the policy conversion is performed by customizing the policy conversion rules, defining the firewall policy model, initializing the existing equipment, centrally managing and distributing the policies, regularly detecting the policies and updating the policy set, and continuing to distribute the policies after the policy detection is completed. However, the existing firewall policy optimization scheme can only confirm the duplicate and invalid policies after the firewall policies are subjected to complex and numerous policy query judgments. The workload of firewall policy optimization and maintenance is large, and duplicate policies are prone to occur. There are defects such as increasing the firewall load and even reducing the firewall performance, which leads to low efficiency of firewall policy optimization. Summary of the invention
[0004] The embodiments of the present application provide a firewall policy optimization method, apparatus, device and storage medium to solve the problem of low efficiency of firewall policy optimization.
[0005] In a first aspect, an embodiment of the present application provides a firewall policy optimization method, including:
[0006] Using the bipartite graph of the original firewall policy, the original firewall policy is optimized to obtain a first target firewall policy; the first target firewall policy includes a policy for allowing data packets to pass through the firewall;
[0007] Constructing a tree structure of the first target firewall policy, and determining a second target firewall policy based on the subnet address object and the leaf nodes of the tree structure;
[0008] The first target firewall policy is updated according to the second target firewall policy and the number of rules and policy openness thereof; the number of rules of the first target firewall policy is greater than the number of rules of the second target firewall policy.
[0009] In one embodiment, updating the first target firewall policy according to the second target firewall policy and the number of rules and policy openness thereof includes:
[0010] If the number of rules is less than or equal to the set upper limit of the number of rules, and the policy openness is less than or equal to the set upper limit of the policy openness, the first target firewall policy is updated to the second target firewall policy.
[0011] In one embodiment, after determining the second target firewall policy based on the subnet address object and the leaf node of the tree structure, the method further includes:
[0012] If the number of rules is greater than the set upper limit of the number of rules, or the policy openness is greater than the set upper limit of the policy openness, the second target firewall policy is added to the tree structure as a child node of the leaf node.
[0013] In one embodiment, determining the policy openness includes:
[0014] A ratio of the number of rules of the first target firewall policy to the number of rules of the second target firewall policy is determined, and the ratio is used as the policy openness.
[0015] In one embodiment, the determining the second target firewall policy based on the subnet address object and the leaf node of the tree structure includes:
[0016] The subnet address object is used to replace the leaf nodes of the tree structure to obtain the second target firewall policy.
[0017] In one embodiment, the bipartite graph of the original firewall policy is adopted, and the original firewall policy is optimized to obtain a first target firewall policy, including:
[0018] If the target address in the original firewall policy does not have a hierarchical structure, based on the bipartite graph, multiple rules in the original firewall policy are merged into one rule to obtain the first target firewall policy;
[0019] If the target address in the original firewall policy has a hierarchical structure, the rules in the original firewall policy are grouped based on the bipartite graph, and layer-by-layer matching and decision making are performed according to the hierarchical structure of the target address to obtain the first target firewall policy.
[0020] In one embodiment, the original firewall policy includes a plurality of rules, each rule is composed of a destination address object, a destination service object, and an action, wherein the action represents the operation performed by the firewall on the matched traffic.
[0021] In a second aspect, an embodiment of the present application provides a firewall policy optimization device, including:
[0022] A firewall policy optimization module, configured to use a bipartite graph of an original firewall policy to optimize the original firewall policy to obtain a first target firewall policy; the first target firewall policy includes a policy for allowing data packets to pass through the firewall;
[0023] A second target firewall policy determination module, configured to construct a tree structure of the first target firewall policy, and determine a second target firewall policy based on a subnet address object and a leaf node of the tree structure;
[0024] An updating module is used to update the first target firewall policy according to the second target firewall policy and its rule quantity and policy openness; the rule quantity of the first target firewall policy is greater than the rule quantity of the second target firewall policy.
[0025] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory storing a computer program, wherein when the processor executes the program, the steps of the firewall policy optimization method described in the first aspect are implemented.
[0026] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the firewall policy optimization method described in the first aspect are implemented.
[0027] The firewall policy optimization method, device, equipment and storage medium provided in the embodiment of the present application optimize the original firewall policy by adopting the bipartite graph of the original firewall policy to obtain the first target firewall policy; construct a tree structure of the first target firewall policy, and determine the second target firewall policy based on the subnet address object and the leaf node of the tree structure; update the first target firewall policy according to the second target firewall policy and its number of rules and policy openness. When the present application uses the subnet to replace the IP address in the rule, by introducing the policy openness, the number of rules in the firewall policy is reduced without excessive loss of security, and the complexity of firewall policy management is further reduced, thereby improving the optimization efficiency of the firewall policy. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0029] Figure 1 It is a flowchart of the firewall policy optimization method provided in the embodiment of the present application;
[0030] Figure 2 This is a schematic diagram of an example of a strategy construction in which the destination address has no hierarchical structure provided in an embodiment of the present application;
[0031] Figure 3is a schematic diagram of an address object group structure provided in an embodiment of the present application;
[0032] Figure 4 This is a schematic diagram of an example of a policy construction with a hierarchical structure of a destination address provided in an embodiment of the present application;
[0033] Figure 5 It is a module schematic diagram of the overall technical solution provided by the embodiment of the present application;
[0034] Figure 6 It is a structural diagram of a firewall policy optimization device provided in an embodiment of the present application;
[0035] Figure 7 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0037] Figure 1 Schematic diagram of the process flow of the firewall policy optimization method provided in the embodiment of the present application. Figure 1 , the embodiment of the present application provides a firewall policy optimization method, which may include:
[0038] S100, using the bipartite graph of the original firewall policy, optimizing the original firewall policy to obtain a first target firewall policy;
[0039] It should be noted that the original firewall policy refers to the unoptimized firewall policy, which includes multiple rules (i.e., firewall rules). The firewall rules refer to a set of rules defined on the firewall to control the access and transmission of network traffic and describe how to handle packets entering and leaving the firewall. Each rule consists of a destination address object, a destination service object, and an action, where the action represents the operation performed by the firewall on the matched packets, such as allow (pass), discard (drop), etc.
[0040] For example, a rule is defined as a triple r=<A,S,Action> ,in:
[0041] A is a set of destination address objects, corresponding to a set of address objects defined using the destination-ip command. The destination address object is used to specify the destination IP address or address range to which the data packet is to go.
[0042] S is a set of destination service objects, corresponding to a set of service objects defined using the service command. The destination service object is used to specify the target service or port that the data packet is to access.
[0043] Action is the action taken, and its value is drop or pass. If the action is drop, it means that the data packet is intercepted and discarded, and if the action is pass, it means that the data packet is allowed to pass through the firewall.
[0044] Based on the above definition, the rule r =<A,S,Action> Corresponding to a set of atomic rules, the set is obtained by listing all combinations of destination addresses and destination services in a rule, that is, atom(r) = {<a,s,Action> |a∈A,s∈S}. Then, define the firewall policy as an ordered set of rules p= <r1,r2,…,r n >, based on the policy definition method, a firewall policy corresponds to a set of atomic rules, which is obtained based on the following method:
[0045] First, sort the atomic rules corresponding to all rules according to the order of firewall rules (pre-set execution order); then, for all atomic rules with the same "address-service" combination, only keep the first one; then delete all atomic rules with the action of drop. The atomic rule set atom(p) corresponding to the firewall policy is formally defined as:
[0046]
[0047] That is, the atomic rule set corresponding to the firewall policy is: it only contains atomic rules with the action of pass. The "address-object" tuple in each atomic rule is allowed to pass by a certain rule, and all rules before this rule do not prohibit this tuple.
[0048] It should be noted that the address object in the address object group can be a single address object or another address object group; if the address object in the address object group is an address object group, it indicates that the destination address (ie, destination IP) has a hierarchical structure.
[0049] If the target address in the original firewall policy does not have a hierarchical structure, then based on the bipartite graph, multiple rules in the original firewall policy are merged into one rule to obtain the first target firewall policy.
[0050] For example, since the description of the destination IP does not contain a hierarchical structure, that is, no address object group is defined, when constructing a policy, the address objects in the atomic rule set can be freely combined to reduce the number of rules.
[0051] Among them, the algorithm for constructing the strategy is as follows:
[0052] (1) Input atomic rule set W = {<a,s,pass> |a∈X,s∈Y}, where X={a1,a2,…,a x} is a set of addresses, Y = {s1,s2,…,s y} is a collection of services.
[0053] (2) Construct a bipartite graph G =<X,E,Y> , where E = {(a,s)|<a,s,pass> ∈W}.
[0054] (3) Find a partition of the bipartite graph G G1∪G2∪…∪G m =G, so that each branch G i = <X i ,E i ,Y i >(1≤i≤m) are all complete bipartite graphs.
[0055] (4) According to the bipartite graph G, determine the construction strategy p = <r1,r2,…,r m >, where r i = <X i ,Y i ,pass>.
[0056] For example, suppose the atomic rule set W is:
[0057] W={<a1,s1,pass> ,<a1,s2,pass> , 2, s2,pass>,<a3,s2,pass>};
[0058] Among them, the bipartite graph corresponding to the atomic rule set W and its partition are as follows Figure 2 As shown, based on the bipartite graph, the corresponding construction strategy p (i.e., the first target firewall strategy) is:
[0059] p=<<{a1},{s1},pass>,<{a1,a2,a3},{s2},pass>>.
[0060] from Figure 2 It can be seen that the bipartite graph divides the firewall rules into two groups, one group represents the destination address and the other group represents the service object; since the destination addresses a1, a2, and a3 correspond to the same service object s2, the rules corresponding to the destination addresses a1, a2, and a3 can be merged into a new rule, thereby reducing the number of rules and improving the efficiency of policy matching.
[0061] If the target address in the original firewall policy has a hierarchical structure, the rules in the original firewall policy are grouped based on the bipartite graph, and layer-by-layer matching and decision making are performed according to the hierarchical structure of the target address to obtain the first target firewall policy.
[0062] For example, when the description of the destination IP has a hierarchical structure, the firewall operation and maintenance personnel have consciously defined some address object groups before defining the rules. These address object groups are meaningful, for example, they all belong to a certain department. Therefore, when constructing policies, these address object groups should be retained and used as much as possible.
[0063] The definition of address object group is a special directed acyclic graph (DAG) aog=<A,E,a0> ,in:
[0064] A is a set of destination address objects. For a∈A, type(a) indicates the type of a, which has two possible values: host or group-object. Host indicates a single address object; group-object indicates an address object group.
[0065] E is a set of directed edges. For e =<a,b> ∈E, a, b∈A, type(a)=group-object.
[0066] a0∈A is the only node in the graph with in-degree 0, called the root of the graph, denoted by a0=root(aog).
[0067] For the address object group aog=<A,E,a0>, its leaf node set leaf(aog)={a∈A|type(a)=host}. A single address object a can also be regarded as an address object group with only one node.
[0068] The definition rule is a triple r = <AOG, S, Action>, where:
[0069] AOG is a set of address object groups, corresponding to a set of address object groups defined using the destination-ip command;
[0070] S is the set of target service objects, corresponding to a group of service objects defined using the service command;
[0071] Action is the action taken, and the possible values are drop or pass.
[0072] Based on the above definition method, a rule r = <AOG, S, Action> corresponds to a set of atomic rules, that is:
[0073] atom(r) = {<a, s, Action> | a ∈ ∪ aog∈AOG leaf(aog), s ∈ S};
[0074] The definition of the policy p and the set of atomic rules corresponding to p is the same in form as the definition in "The destination IP has no hierarchical structure".
[0075] To make the best use of the already defined address object groups as much as possible, the input of the policy generation algorithm includes:
[0076] The original policy p = <r1, r2,..., r n >, where r n = <AOG i , S i , Action i > (1 ≤ i ≤ n);
[0077] The set of atomic rules W = {<a, s, pass> | a ∈ X, s ∈ Y}, where X = {a1, a2,..., a x} is the set of addresses, and Y = {s1, s2,..., s y} is the set of services.
[0078] The set of atomic rules W satisfies the following conditions, where each atomic rule comes from a certain rule in the original policy, that is
[0079] The algorithm for constructing the new policy is as follows:
[0080] (1) Define
[0081] (2) Construct a bipartite graph G = <U, E, V>, where U = X, V = Y, and E = {(a, s) | <a, s, pass> ∈ W}.
[0082] (3) Repeat the following operations:
[0083] 3.1) If there exists r = <AOG, S, Action> ∈ p, aog = <A, Edge, a0> ∈ AOG, b ∈ A, satisfying and That is, there is a set of addresses {a (1) ,a (2) ,…,a (l)} is defined as address object group b, then b is said to dominate {a (1) ,a (2) ,…,a (l)}.
[0084] 3.2) If there exists a complete bipartite subgraph G of G * = * ,E * ,V * >, and b dominates U * , then construct a bipartite graph G′= <U′,E′,V * >, where:
[0085] U′=U∪{b};
[0086] e′=E\{(a,s)|a∈U * ,s∈V *}∪{(b,s)|s∈V *}. That is, use b instead of U * With V * connected.
[0087] G′ obtained in this way is still recorded as G=<U,E,V>.
[0088] Construct an address object group with b as the root aog=<{b}∪U * ,{(b,a)|a∈U *},b>, and join the collection
[0089] (4) Identify a partition of graph G G1∪G2∪…∪G m =G, so that each branch G i = <X i ,E i ,Y i >(1≤i≤m) are all complete bipartite graphs.
[0090] (5) Corresponding to each branch G i = <X i ,E i ,Y i >, construct rule r′ i = <AOG′ i ,S′ i ,pass>, where:
[0091] AOG′ i Initialized to an empty set, for x∈X i ,like If there is aog with x as the root, add aog to AOG′ i ;like If there is no aog with x as the root, then x is a single address. Join AOG i .
[0092] S′ i =Y i .
[0093] (6) The final constructed strategy p′ = <r′1,r′2,…,r′ m >.
[0094] For example, the original policy appears as follows Figure 3 The address object group aog1 is shown.
[0095] The atomic rule set W is:
[0096] {<a1,s1,pass>,<a1,s2,pass>,<a2,s2,pass> ,<a3,s2,pass> ,<a3,s3,pass> ,<a4,s3,pass>}
[0097] refer to Figure 4 , the construction process of the new strategy is:
[0098] Rule r′1 constructed from branch G1 = <{aog1},{s2},pass>;
[0099] Rules constructed from branch G2
[0100] Rules constructed from branch G3
[0101] Then the constructed strategy p′=<r′1,r′2,r′3> , where policy p′ is the optimized firewall policy, that is, the first target firewall policy.
[0102] from Figure 3 and Figure 4 From the firewall policy optimization process in , it can be seen that since the address objects a1 and a2 are child nodes of b, the connection between a1, a2 and s2 can be replaced by the connection between b and s2; further, since the address objects a3 and b are child nodes of c, the connection between a3, b and s2 can be replaced by the connection between c and s2, and so on, to obtain the first target firewall policy.
[0103] S200, constructing a tree structure of the first target firewall policy, and determining a second target firewall policy based on a subnet address object and a leaf node of the tree structure;
[0104] It should be noted that after determining the first target firewall policy, since it is possible that a rule needs to be defined for one IP address or a few IP addresses, the number of rules in the policy is large, which increases the difficulty of managing and maintaining the rules. Based on this, the embodiment of the present application uses a subnet address object to reduce the number of rules.
[0105] A tree structure of the first target firewall policy is constructed, and a second target firewall policy is determined based on the subnet address object and the leaf nodes of the tree structure. Specifically, according to the rules in the first target firewall policy, tree nodes are created to form a tree structure; then, the leaf nodes of the tree structure are replaced with the subnet address object to obtain the second target firewall policy.
[0106] For example, in the embodiment of the present application, in the case where the destination IP does not have a hierarchy, subnet address objects are used to reduce the number of rules, thereby obtaining a second target firewall policy.
[0107] The syntax of a subnet address object is: [object-id]network subnet ip-address mask-length. It represents all IP address objects in the subnet, that is, subnet subnet=<a,lengrh> It is the set of all IP addresses in the subnet.
[0108] For rules r1, r2, ..., r constructed according to the above algorithm k , where r i = i ,S,pass>(1≤i≤k), if Then you can use the rule<subnet,S,pass> To replace the original k rules.
[0109] If the address set And the ports in the set S of IP addresses in A' should not be accessed, then in the rule<subnet,S,pass> Before, you need to add rules<A′,S,drop> .
[0110] For policy p2 obtained from policy p1 using the above subnet substitution method, define is the openness of policy p2, which indicates the degree of security degradation of the firewall policy. |atom(p1)| represents the set size of policy p1, and |atom(p2)| represents the set size of policy p2. The set size can be represented by the number of rules in the policy set, that is, the more rules there are, the larger the set is.
[0111] The algorithm for reducing the number of rules without excessively reducing security is defined as follows:
[0112] (1) Input a policy p that contains only pass rules, a set of inaccessible address-port pairs F, an upper limit on the number of rules n, and an upper limit on the policy openness o;
[0113] (2) Construct a tree T with policy p as the root node; then, randomly select a leaf node q of the tree T, select an appropriate subnet, and use the subnet replacement method to obtain a new policy q′ (i.e., the second target firewall policy), that is, replace the leaf node with the address object of the subnet, where the set F needs to be used.
[0114] S300: Update the first target firewall policy according to the second target firewall policy and the number of its rules and policy openness.
[0115] After determining the second target firewall policy, the number of rules in the second target firewall policy is obtained, and the ratio of the number of rules in the first target firewall policy to the number of rules in the second target firewall policy is determined, and the ratio is used as the policy openness; then, the first target firewall policy is updated according to the second target firewall policy, its number of rules and the policy openness.
[0116] Specifically, if the number of rules is less than or equal to the set upper limit of the number of rules, and the policy openness is less than or equal to the set upper limit of the policy openness, the first target firewall policy is updated to the second target firewall policy.
[0117] If the number of rules is greater than the set upper limit of the number of rules, or the policy openness is greater than the set upper limit of the policy openness, the second target firewall policy is added to the tree structure as a child node of the leaf node.
[0118] For example, if Then add q′ as a child node of q to the tree T;
[0119] if Then return q′ and the algorithm ends.
[0120] Optionally, the random algorithm may also terminate when a preset calculation time is reached.
[0121] The firewall policy optimization method provided in the embodiment of the present application optimizes the original firewall policy by adopting the bipartite graph of the original firewall policy to obtain the first target firewall policy; the first target firewall policy includes a policy that allows data packets to pass through the firewall; constructs a tree structure of the first target firewall policy, and determines the second target firewall policy based on the subnet address object and the leaf nodes of the tree structure; updates the first target firewall policy according to the second target firewall policy and its number of rules and policy openness; the number of rules of the first target firewall policy is greater than the number of rules of the second target firewall policy. When the present application uses the subnet to replace the IP address in the rule, by introducing the policy openness, the number of rules in the firewall policy is reduced without excessive loss of security, and the complexity of firewall policy management is further reduced, thereby improving the optimization efficiency of the firewall policy.
[0122] In order to further analyze and explain the firewall policy optimization method proposed in this application, refer to Figure 5 The following examples.
[0123] like Figure 5 As shown, the overall technical solution of the embodiment of the present application includes the following modules:
[0124] Firewall policy analysis: Analyze the firewall policy and identify the object groups, rules, etc. defined therein;
[0125] Identification of missed firewall rules: Using the firewall's own policy hit counting function, it can be identified that some firewall rules are not hit, and then the missed rules are deleted;
[0126] Optimized firewall policy generation: Using bipartite graphs, the original policies are split, merged, etc. to regenerate optimized firewall policies.
[0127] The embodiments of the present application focus on analyzing and explaining firewall policy analysis and optimized firewall policy generation.
[0128] The firewall policy syntax involved in the embodiment of the present application is shown in Table 1:
[0129] Table 1 Firewall policy
[0130]
[0131]
[0132]
[0133] From the syntax description of the firewall policy in Table 1, it can be seen that in the firewall rule, the destination IP address used as a filtering condition is represented as an address object group, and the address object in the address object group can be another address object group, that is, the description of the destination IP can exist in a hierarchical structure.
[0134] The embodiment of the present application defines a policy optimization algorithm for the case where the destination IP does not have a hierarchical structure, and then proposes a method for reducing the number of rules without excessively reducing security, and finally handles the case where the destination IP has a hierarchical structure.
[0135] 1. Strategy optimization algorithm when the destination IP does not have a hierarchy.
[0136] The definition rule is a triple r=<A,S,Action> ,in:
[0137] A is a collection of destination address objects, corresponding to a set of address objects defined using the destination-ip command.
[0138] S is a set of destination service objects, corresponding to a set of service objects defined using the service command.
[0139] Action is the action taken, and its value is drop or pass.
[0140] Based on the above definition, the rule r =<A,S,Action> Corresponding to a set of atomic rules, the set is obtained by listing all combinations of destination addresses and destination services in a rule, that is, atom(r) = {<a,s,Action> |a∈A,s∈S}.
[0141] Then, define a policy as an ordered set of rules p= <r1,r2,…,r n >, based on the policy definition method, a policy corresponds to a set of atomic rules, which is obtained based on the following method:
[0142] First, sort the atomic rules corresponding to all rules in the order of the rules; then, for all atomic rules with the same "address-service" combination, only keep the first one; then delete all atomic rules with the action of drop. The formal definition of atom(p) is:
[0143]
[0144] That is, the atomic rule set atom(p) corresponding to the policy is: it only contains atomic rules with the action of pass. The "address-object" tuple in each atomic rule is allowed to pass by a certain rule, and all rules before this rule do not prohibit this tuple.
[0145] In this case, since the description of the destination IP does not contain a hierarchical structure, that is, no address object group is defined, when constructing a policy, the address objects in the atomic rule set can be freely combined to reduce the number of rules.
[0146] Among them, the algorithm for constructing the strategy is as follows:
[0147] (1) Input atomic rule set W = {<a, s, pass> | a∈X, s∈Y}, where X = {a1, a2, …, a x} is a set of addresses, Y = {s1,s2,…,s y} is a collection of services.
[0148] (2) Construct a bipartite graph G =<X,E,Y> , where E = {(a,s)|<a,s,pass> ∈W}.
[0149] (3) Find a partition of the bipartite graph G G1∪G2∪…∪G m =G, so that each branch G i = <X i ,E i ,Y i >(1≤i≤m) are all complete bipartite graphs.
[0150] (4) According to the bipartite graph G, determine the construction strategy p = <r1,r2,…,r m >, where r i = <X i ,Y i ,pass>.
[0151] For example, suppose the atomic rule set W is:
[0152] W={<a1,s1,pass> ,<a1,s2,pass> ,<a2,s2,pass> ,<a3,s2,pass>};
[0153] Among them, the bipartite graph corresponding to the atomic rule set W and its partition are as follows Figure 2 As shown, based on this bipartite graph, the corresponding construction strategy p is:
[0154] p=<<{a1},{s1},pass>,<{a1,a2,a3},{s2},pass>>.
[0155] 2. Reduce the number of rules in the policy.
[0156] When constructing a firewall policy based on the destination IP without a hierarchical structure, it is possible that a rule must be defined for one or a few IP addresses, resulting in a large number of rules in the policy, increasing the difficulty of managing and maintaining the rules. Based on this, the embodiment of the present application can use subnet address objects to reduce the number of rules.
[0157] The syntax of a subnet address object is: [object-id]network subnet ip-address mask-length. It represents all IP address objects in the subnet, that is, subnet subnet=<a,lengrh> It is the set of all IP addresses in the subnet.
[0158] For rules r1, r2, ..., r constructed according to the above algorithm k , where r i =<A i ,S,pass>(1≤i≤k), if Then you can use the rule<subnet,S,pass> To replace the original k rules.
[0159] If the address set And the ports in the set S of IP addresses in A' should not be accessed, then in the rule<subnet,S,pass> Before, you need to add rules<A′,S,drop> .
[0160] For policy p2 obtained from policy p1 using the above subnet substitution method, define is the openness of policy p2, which indicates the degree of security degradation of the firewall policy.
[0161] The algorithm for reducing the number of rules without excessively reducing security is defined as follows:
[0162] (1) Input a policy p that contains only pass rules, a set of inaccessible address-port pairs F, an upper limit on the number of rules n, and an upper limit on the policy openness o;
[0163] (2) Construct a tree T with strategy p as the root node and repeat the following operations:
[0164] Randomly select a leaf node q of the tree T, select an appropriate subnet, and use the subnet replacement method to obtain a new strategy q′ (the set F needs to be used in this process);
[0165] if Then add q′ as a child node of q to the tree T;
[0166] if Then return q′ and the algorithm ends.
[0167] Optionally, the random algorithm may also terminate when a preset calculation time is reached.
[0168] 3. Strategy optimization algorithm when the destination IP exists in a hierarchical structure.
[0169] When the description of the destination IP has a hierarchical structure, the firewall operation and maintenance personnel have consciously defined some address object groups before defining the rules. These address object groups are meaningful, for example, they all belong to a certain department. Therefore, when constructing policies, these address object groups should be retained and used as much as possible.
[0170] The definition of address object group is a special directed acyclic graph (DAG) aog=<A,E,a0> ,in:
[0171] A is a set of destination address objects. For a∈A, type(a) indicates the type of a, which has two possible values: host or group-object. Host indicates a single address object; group-object indicates an address object group.
[0172] E is a set of directed edges. For e = <a, b> ∈ E, a, b ∈ A, type (a) = group-object.
[0173] a0∈A is the only node in the graph with in-degree 0, called the root of the graph, denoted by a0=root(aog).
[0174] For address object group aog=<A,E,a0> , its leaf node set leaf(aog) = {a∈A|type(a) = host}. A single address object a can also be regarded as an address object group with only one node.
[0175] The definition rule is a triple r = <AOG, S, Action>, where:
[0176] AOG is a set of address object groups, corresponding to a set of address object groups defined using the destination-ip command;
[0177] S is the set of destination service objects, corresponding to a set of service objects defined using the service command;
[0178] Action is the action taken, possible values are drop or pass.
[0179] Based on the above definition method, a rule r = <AOG, S, Action> corresponds to a set of atomic rules, that is:
[0180] atom(r) = { <a, s, Action> | a ∈ ∪ aog∈AOG leaf(aog), s ∈ S};
[0181] The definition of the policy p and the set of atomic rules corresponding to p is the same in form as the definition in "The destination IP has no hierarchy".
[0182] To make the best use of the already defined address object groups as much as possible, the input of the policy generation algorithm includes:
[0183] The original policy p = <r1, r2, …, r n >, where r n = <AOG i , S i , Action i > (1 ≤ i ≤ n);
[0184] The set of atomic rules W = { <a, s, pass> | a ∈ X, s ∈ Y}, where X = {a1, a2, …, a x} is the set of addresses, and Y = {s1, s2, …, s y} is the set of services.
[0185] The set of atomic rules W satisfies the following conditions, where each atomic rule comes from a certain rule in the original policy, that is
[0186] The algorithm for constructing the new policy is as follows:
[0187] (1) Define
[0188] (2) Construct a bipartite graph G = <U, E, V>, where U = X, V = Y, and E = { (a, s) | <a, s, pass> ∈ W}.
[0189] (3) Repeat the following operations:
[0190] 3.1) If there exists r = <AOG, S, Action> ∈ p, aog = <A, Edge, a0> ∈ AOG, b ∈ A, satisfying and That is, there is a set of addresses {a (1) , a (2) , …, a (l)} that has just been defined as the address object group b, then b is said to dominate {a (1) , a(2) ,…,a (l)}.
[0191] 3.2) If there exists a complete bipartite subgraph G of G * =<U * ,E * ,V * >, and b dominates U * , then construct a bipartite graph G′= <U′,E′,V * >, where:
[0192] U′=U∪{b};
[0193] E′=E\{(a,s)|a∈U * ,s∈V *}∪{(b,s)|s∈V *}. That is, use b instead of U * With V * connected.
[0194] G′ obtained in this way is still recorded as G=<U,E,V>.
[0195] Construct an address object group with b as the root aog=<{b}∪U * ,{(b,a)|a∈U *},b>, and join the collection
[0196] (4) Identify a partition of graph G G1∪G2∪…∪G m =G, so that each branch G i = <X i ,E i ,Y i >(1≤i≤m) are all complete bipartite graphs.
[0197] (5) Corresponding to each branch G i = <X i ,E i ,Y i >, construct rule r′ i = <AOG′ i ,S′ i ,pass>, where:
[0198] AOG′ i Initialized to an empty set, for x∈X i ,like If there is aog with x as the root, add aog to AOG′ i ;like If there is no aog with x as the root, then x is a single address. Join AOGi .
[0199] S′ i =Y i .
[0200] (6) The final constructed strategy p′=<r′1,r′2,…,r′ m >.
[0201] For example, the original policy appears as follows Figure 3 The address object group aog1 is shown.
[0202] The atomic rule set W is:
[0203] {<a1,s1,pass> ,<a1,s2,pass> ,<a2,s2,pass> ,<a3,s2,pass> ,<a3,s3,pass> ,<a4,s3,pass>}
[0204] refer to Figure 4 , the construction process of the new strategy is:
[0205] Rule r′1 constructed from branch G1 = <{aog1},{s2},pass>;
[0206] Rules constructed from branch G2
[0207] Rules constructed from branch G3
[0208] Then the constructed strategy p′=<r′1,r′2,r′3> .
[0209] The embodiments of the present application have the following advantages:
[0210] Improve the efficiency of firewall policy optimization: Generate new firewall policies through firewall policy syntax, define the policy as a set of triple atomic rules, freely combine address objects in the atomic rule set, and reduce the number of rules. Then, convert the atomic rules into a bipartite graph, and then construct a complete bipartite graph in the bipartite graph to achieve atomic rule merging, which greatly improves the efficiency of firewall optimization.
[0211] Remove the limitations of optimized firewall policies: When subnets are used to replace IP addresses in rules, the resulting security loss is presented in a quantified way by introducing the concept of policy openness, thus achieving a balance between security and ease of use in practice.
[0212] Optimize firewall policies based on the departmental division of the enterprise network: Reduce the complexity of firewall policy management by making full use of the defined address object groups. According to the policy generation algorithm, the automatically generated firewall policy has the protection semantics that is completely equivalent to the atomic rule set, and at the same time, the atomic rules are merged as much as possible to improve the practicality of the policy.
[0213] The firewall policy optimization device provided in the embodiment of the present application is described below. The firewall policy optimization device described below and the firewall policy optimization method described above can be referenced to each other.
[0214] refer to Figure 6 , Figure 6 60 is a schematic diagram of the structure of the firewall policy optimization device provided in the embodiment of the present application. The firewall policy optimization device provided in the embodiment of the present application includes a firewall policy optimization module 601, a second target firewall policy determination module 602 and an update module 603.
[0215] The firewall policy optimization module 601 is used to use the bipartite graph of the original firewall policy to optimize the original firewall policy to obtain a first target firewall policy; the first target firewall policy includes a policy that allows data packets to pass through the firewall;
[0216] A second target firewall policy determination module 602, configured to construct a tree structure of the first target firewall policy, and determine a second target firewall policy based on a subnet address object and a leaf node of the tree structure;
[0217] The updating module 603 is used to update the first target firewall policy according to the second target firewall policy and its rule quantity and policy openness; the rule quantity of the first target firewall policy is greater than the rule quantity of the second target firewall policy.
[0218] The firewall policy optimization device provided by the embodiment of the present application optimizes the original firewall policy by adopting the bipartite graph of the original firewall policy to obtain the first target firewall policy; the first target firewall policy includes a policy that allows data packets to pass through the firewall; constructs a tree structure of the first target firewall policy, and determines the second target firewall policy based on the subnet address object and the leaf node of the tree structure; updates the first target firewall policy according to the second target firewall policy and its number of rules and policy openness; the number of rules of the first target firewall policy is greater than the number of rules of the second target firewall policy. When the present application uses the subnet to replace the IP address in the rule, by introducing the policy openness, the number of rules in the firewall policy is reduced without excessive loss of security, and the complexity of firewall policy management is further reduced, thereby improving the optimization efficiency of the firewall policy.
[0219] In one embodiment, the update module 603 is specifically configured to:
[0220] If the number of rules is less than or equal to the set upper limit of the number of rules, and the policy openness is less than or equal to the set upper limit of the policy openness, the first target firewall policy is updated to the second target firewall policy.
[0221] In one embodiment, the second target firewall policy determination module 602 is further configured to:
[0222] If the number of rules is greater than the set upper limit of the number of rules, or the policy openness is greater than the set upper limit of the policy openness, the second target firewall policy is added to the tree structure as a child node of the leaf node.
[0223] In one embodiment, the update module 603 is further configured to:
[0224] A ratio of the number of rules of the first target firewall policy to the number of rules of the second target firewall policy is determined, and the ratio is used as the policy openness.
[0225] In one embodiment, the second target firewall policy determination module 602 is specifically configured to:
[0226] The subnet address object is used to replace the leaf nodes of the tree structure to obtain the second target firewall policy.
[0227] In one embodiment, the firewall policy optimization module 601 is specifically used to:
[0228] If the target address in the original firewall policy does not have a hierarchical structure, based on the bipartite graph, multiple rules in the original firewall policy are merged into one rule to obtain the first target firewall policy;
[0229] If the target address in the original firewall policy has a hierarchical structure, the rules in the original firewall policy are grouped based on the bipartite graph, and layer-by-layer matching and decision making are performed according to the hierarchical structure of the target address to obtain the first target firewall policy.
[0230] In one embodiment, the original firewall policy includes a plurality of rules, each rule is composed of a destination address object, a destination service object, and an action, wherein the action represents the operation performed by the firewall on the matched traffic.
[0231] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call a computer program in the memory 730 to execute the steps of the firewall policy optimization method, for example including:
[0232] Using the bipartite graph of the original firewall policy, the original firewall policy is optimized to obtain a first target firewall policy; the first target firewall policy includes a policy for allowing data packets to pass through the firewall;
[0233] Constructing a tree structure of the first target firewall policy, and determining a second target firewall policy based on the subnet address object and the leaf nodes of the tree structure;
[0234] The first target firewall policy is updated according to the second target firewall policy and the number of rules and policy openness thereof; the number of rules of the first target firewall policy is greater than the number of rules of the second target firewall policy.
[0235] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0236] On the other hand, an embodiment of the present application further provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the firewall policy optimization method provided in the above embodiments are implemented, for example, including:
[0237] Using the bipartite graph of the original firewall policy, the original firewall policy is optimized to obtain a first target firewall policy; the first target firewall policy includes a policy for allowing data packets to pass through the firewall;
[0238] Constructing a tree structure of the first target firewall policy, and determining a second target firewall policy based on the subnet address object and the leaf nodes of the tree structure;
[0239] The first target firewall policy is updated according to the second target firewall policy and the number of rules and policy openness thereof; the number of rules of the first target firewall policy is greater than the number of rules of the second target firewall policy.
[0240] On the other hand, an embodiment of the present application further provides a computer program product, the computer program product including a computer program, the computer program can be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer can perform the steps of the firewall policy optimization method provided in the above embodiments, for example, including:
[0241] Using the bipartite graph of the original firewall policy, the original firewall policy is optimized to obtain a first target firewall policy; the first target firewall policy includes a policy for allowing data packets to pass through the firewall;
[0242] Constructing a tree structure of the first target firewall policy, and determining a second target firewall policy based on the subnet address object and the leaf nodes of the tree structure;
[0243] The first target firewall policy is updated according to the second target firewall policy and the number of rules and policy openness thereof; the number of rules of the first target firewall policy is greater than the number of rules of the second target firewall policy.
[0244] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0245] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0246] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A firewall policy optimization method, characterized in that: include: Using the bipartite graph of the original firewall policy, optimizing the original firewall policy to obtain a first target firewall policy; The first target firewall policy includes a policy for allowing data packets to pass through the firewall; Constructing a tree structure of the first target firewall policy, and determining a second target firewall policy based on the subnet address object and the leaf nodes of the tree structure; The first target firewall policy is updated according to the second target firewall policy and the number of rules and policy openness thereof; the number of rules of the first target firewall policy is greater than the number of rules of the second target firewall policy.
2. The firewall policy optimization method according to claim 1, characterized in that: The updating of the first target firewall policy according to the second target firewall policy and the number of rules and policy openness thereof includes: If the number of rules is less than or equal to the set upper limit of the number of rules, and the policy openness is less than or equal to the set upper limit of the policy openness, the first target firewall policy is updated to the second target firewall policy.
3. The firewall policy optimization method according to claim 2, characterized in that: After determining the second target firewall policy based on the subnet address object and the leaf node of the tree structure, the method further includes: If the number of rules is greater than the set upper limit of the number of rules, or the policy openness is greater than the set upper limit of the policy openness, the second target firewall policy is added to the tree structure as a child node of the leaf node.
4. The firewall policy optimization method according to claim 1, characterized in that: Determine the openness of the strategy, including: A ratio of the number of rules of the first target firewall policy to the number of rules of the second target firewall policy is determined, and the ratio is used as the policy openness.
5. The firewall policy optimization method according to claim 1, characterized in that: The determining of the second target firewall policy based on the subnet address object and the leaf node of the tree structure includes: The subnet address object is used to replace the leaf nodes of the tree structure to obtain the second target firewall policy.
6. The method for optimizing firewall policies according to claim 1, characterized in that: The bipartite graph using the original firewall policy is used to optimize the original firewall policy to obtain a first target firewall policy, including: If the target address in the original firewall policy does not have a hierarchical structure, based on the bipartite graph, multiple rules in the original firewall policy are merged into one rule to obtain the first target firewall policy; If the target address in the original firewall policy has a hierarchical structure, the rules in the original firewall policy are grouped based on the bipartite graph, and layer-by-layer matching and decision making are performed according to the hierarchical structure of the target address to obtain the first target firewall policy.
7. The firewall policy optimization method according to claim 1, characterized in that: The original firewall policy includes a plurality of rules, each rule is composed of a destination address object, a destination service object and an action, and the action represents the operation performed by the firewall on the matched traffic.
8. A firewall policy optimization device, characterized in that: include: A firewall policy optimization module, configured to use a bipartite graph of an original firewall policy to optimize the original firewall policy to obtain a first target firewall policy; The first target firewall policy includes a policy for allowing data packets to pass through the firewall; A second target firewall policy determination module, configured to construct a tree structure of the first target firewall policy, and determine a second target firewall policy based on a subnet address object and a leaf node of the tree structure; An updating module, configured to update the first target firewall policy according to the second target firewall policy and the number of its rules and the policy openness; The number of rules of the first target firewall policy is greater than the number of rules of the second target firewall policy.
9. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, the steps of the firewall policy optimization method according to any one of claims 1 to 7 are implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the firewall policy optimization method according to any one of claims 1 to 7 are implemented.
