Range#

class loop_detection.Range(start, end, name=None, max_card=inf, field=None)[source]#

Class for range rule representation

Parameters:
  • start (int) – start of the range (included)

  • end (int) – end of the range (included)

  • max_card (int, default = infinity) – maximum cardinality of the rule

  • field (str, default = None) – string for the name of the field the rule acts on (IP source, port range…)

start#
Type:

int

end#
Type:

int

max_card#
Type:

int

card#

cardinality of the rule

Type:

int

empty_flag#

1 if the rule is empty, 0 otherwise

Type:

int

field#
Type:

str

Examples

>>> r1 = Range(1,7)
>>> r2 = Range(0,4)
__and__(other)[source]#

Returns the result of set intersection

Parameters:

other (Range) –

Return type:

Range

Examples

>>> r1 = Range(1,7)
>>> r2 = Range(0,4)
>>> r1 & r2
[1, 4]
__lt__(other)[source]#

Check if self is included in other (equality is accepted)

Parameters:

other (Range OR WildcardExpr = '*' (other WildcardExpr instances not allowed)) –

Return type:

bool

Examples

>>> r1 = Range(1,7)
>>> r2 = Range(2,4)
>>> r2 < r1
True
union(other)[source]#

Returns the union of both rules if the result is continuous, None otherwise

Parameters:

other (Range) –

Return type:

Range or None

Examples

>>> r1 = Range(1,7)
>>> r2 = Range(8,10)
>>> r1.union(r2)
[1, 10]
>>> r3 = Range(9, 10)
>>> r1.union(r3) is None
True