Skip to content

Commit

Permalink
Merge branch 'release-0.25.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
k0retux committed Aug 18, 2016
2 parents 8f9ebf1 + f0a6b6e commit 8292665
Show file tree
Hide file tree
Showing 24 changed files with 522 additions and 136 deletions.
67 changes: 48 additions & 19 deletions data_models/protocols/pppoe.py
Expand Up @@ -36,13 +36,22 @@ def build_data_model(self):

# refer to RFC 2516

def cycle_tags(tag):
tag.freeze()
if tag['.*/type'].get_current_raw_val() == 0x102:
tag['.*/type'].unfreeze()
tag.freeze()
tag['.*/type'].unfreeze()
tag.unfreeze(reevaluate_constraints=True)
return tag

tag_desc = \
{'name': 'tag',
'evolution_func': cycle_tags,
'contents': [
{'name': 'type',
'random': True,
'contents': UINT16_be(values=[0,0x0101,0x0102,0x0103,0x0104,0x0105,
0x0110,0x201,0x0202,0x0203]),
'contents': UINT16_be(values=[0x0101,0x0102,0x0103,0x0104,0x0105,
0x0110,0x201,0x0202,0x0203,0]),
'absorb_csts': AbsFullCsts()},
{'name': 'len',
'contents': UINT16_be(),
Expand Down Expand Up @@ -116,20 +125,24 @@ def build_data_model(self):

mh = ModelHelper(delayed_jobs=True, add_env=False)
tag_node = mh.create_graph_from_desc(tag_desc)
tag_node_4pads = tag_node.get_clone()

tag_service_name = tag_node.get_clone('tag_sn')
tag_service_name['.*/type'].set_values(value_type=UINT16_be(values=[0x0101]))

tag_host_uniq = tag_node.get_clone('tag_host_uniq')
tag_host_uniq['.*/type'].set_values(value_type=UINT16_be(values=[0x0103]))

tag_host_uniq_pads = tag_host_uniq.get_clone()

tag_ac_name = tag_node.get_clone('tag_ac_name') # Access Concentrator Name
tag_ac_name['.*/type'].set_values(value_type=UINT16_be(values=[0x0102]))

tag_sn_error = tag_node.get_clone('tag_sn_error') # Service Name Error
tag_sn_error['.*/type'].set_values(value_type=UINT16_be(values=[0x0202]))

tag_service_name_pads = tag_service_name.get_clone()
tag_node_pads = tag_node.get_clone()

pppoe_desc = \
{'name': 'pppoe',
'contents': [
Expand Down Expand Up @@ -168,19 +181,28 @@ def build_data_model(self):
'custo_clear': MH.Custo.NTerm.FrozenCopy,
'exists_if': (IntCondition(0x9), 'code'),
'contents': [
(tag_service_name, 1),
(tag_node, 0, 4)
(tag_service_name.get_clone(), 1),
(tag_node.get_clone(), 0, 4)
]},
{'name': '4pado',
'shape_type': MH.FullyRandom,
'custo_clear': MH.Custo.NTerm.FrozenCopy,
'exists_if': (IntCondition(0x7), 'code'),
'contents': [
(tag_ac_name, 1),
(tag_host_uniq.get_clone(), 1),
(tag_ac_name.get_clone(), 1),
(tag_service_name.get_clone(), 1),
{'name': 'host_uniq_stub',
'contents': String(values=[''])},
(tag_node.get_clone(), 0, 4)
],
'alt': [
{'conf': 'fuzz',
'shape_type': MH.Ordered,
'exists_if': (IntCondition(0x7), 'code'),
'contents': [
(tag_node.get_clone(), 0, 8),
(tag_host_uniq.get_clone(), 1),
(tag_ac_name.get_clone(), 1),
(tag_service_name.get_clone(), 1),
]}
]},
{'name': '4padr',
'shape_type': MH.FullyRandom,
Expand All @@ -198,27 +220,34 @@ def build_data_model(self):
# Accept PPPoE session Case
{'weight': 10,
'contents': [
(tag_service_name.get_clone(), 1),
{'name': ('host_uniq_stub', 2),
'contents': String(values=[''])},
(tag_node_4pads, 0, 4)
(tag_service_name_pads, 1),
(tag_host_uniq_pads, 1),
(tag_node_pads, 0, 4)
]},
# Reject PPPoE session Case
{'weight': 2,
'contents': [
(tag_sn_error, 1),
{'name': ('host_uniq_stub', 2)},
(tag_node_4pads, 0, 4)
(tag_host_uniq_pads, 1),
(tag_node_pads, 0, 4)
]},
],
'alt': [
{'conf': 'fuzz',
'exists_if': (IntCondition(0x65), 'code'),
'contents': [
(tag_node.get_clone(), 0, 8),
(tag_service_name_pads.get_clone(), 1),
(tag_host_uniq_pads.get_clone(), 1)
]}
]},
{'name': '4padt',
'shape_type': MH.FullyRandom,
'custo_clear': MH.Custo.NTerm.FrozenCopy,
'exists_if': (IntCondition(0xa7), 'code'),
'contents': [
{'name': ('host_uniq_stub', 3),
'contents': String(values=[''])},
(tag_node.get_clone(), 0, 4)
{'contents': tag_host_uniq.get_clone()},
{'contents': tag_node.get_clone(), 'qty': (0, 4)}
]}
]},
{'name': 'padding',
Expand Down
76 changes: 41 additions & 35 deletions data_models/protocols/pppoe_strategy.py
Expand Up @@ -24,6 +24,8 @@
from framework.tactics_helpers import *
from framework.scenario import *
from framework.global_resources import *
from framework.data_model_helpers import MH
from framework.target import *

tactics = Tactics()

Expand Down Expand Up @@ -60,6 +62,7 @@ def retrieve_X_from_feedback(env, current_step, next_step, feedback, x='padi', u
off = data.find(mac_dst)
data = data[off:]
result = msg_x.absorb(data, constraints=AbsNoCsts(size=True, struct=True))
print('\n [ ABS result: {!s} ]'.format(result))
if result[0] == AbsorbStatus.FullyAbsorbed:
try:
service_name = msg_x['.*/value/v101'].to_bytes()
Expand All @@ -76,17 +79,13 @@ def retrieve_X_from_feedback(env, current_step, next_step, feedback, x='padi', u
host_uniq = host_uniq.to_bytes()
env.host_uniq = host_uniq
t_fix_pppoe_msg_fields.host_uniq = host_uniq
elif update and hasattr(env, 'host_uniq'):
host_uniq = env.host_uniq
else:
pass

if update: # we update the seed of the data process
next_step.node.freeze()
try:
next_step.node['.*/tag_sn/value/v101'] = service_name
next_step.node['.*/tag_sn$'].unfreeze(recursive=True, reevaluate_constraints=True)
next_step.node.freeze()
next_step.node['.*/tag_sn$'].freeze()
except:
pass

Expand Down Expand Up @@ -145,38 +144,42 @@ def disrupt_data(self, dm, target, prev_data):
print("\n*** 'service_name' not found in the environment! ***")

if self.host_uniq:
new_tag = dm.get_data('tag_host_uniq')
new_tag['.*/v103'] = self.host_uniq
new_tag.unfreeze(recursive=True, reevaluate_constraints=True)
new_tag.freeze()
try:
n['.*/host_uniq_stub'].set_contents(new_tag)
prev_data.add_info("update 'host_uniq'")
if not n['.*/tag_host_uniq/.*/v103'].is_attr_set(MH.Attr.LOCKED) and \
not n['.*/tag_host_uniq/len'].is_attr_set(MH.Attr.LOCKED) and \
not n['.*/tag_host_uniq/type'].is_attr_set(MH.Attr.LOCKED):
n['.*/tag_host_uniq/.*/v103'] = self.host_uniq
tag_uniq = n['.*/tag_host_uniq$']
tag_uniq.unfreeze(recursive=True, reevaluate_constraints=True)
tag_uniq.freeze()
prev_data.add_info("update 'host_uniq' with: {!s}".format(self.host_uniq))
else:
print("\n*** 'tag_host_uniq' is currently fuzzed. ignore its update ***")
except:
print(error_msg.format('host_uniq_stub'))
print(error_msg.format('tag_host_uniq'))
else:
print("\n*** 'host_uniq_stub' not found in the environment! ***")
print("\n*** 'tag_host_uniq' not found in the environment! ***")

if self.reevaluate_csts:
n.unfreeze(recursive=True, reevaluate_constraints=True)
else:
try:
n['.*/length$'].unfreeze()
except:
print(error_msg.format('length'))

n.freeze()
n.show()
# n.show()

return prev_data

### PADI fuzz scenario ###
step_wait_padi = NoDataStep(fbk_timeout=1)

dp_pado = DataProcess(process=[('tTYPE', UI(init=1), UI(order=True)), 'FIX_FIELDS'], seed='pado')
dp_pado.append_new_process([('tSTRUCT', UI(init=1), UI(deep=True)), 'FIX_FIELDS'])
step_send_pado = Step(dp_pado)
step_wait_padi = NoDataStep(fbk_timeout=10, fbk_mode=Target.FBK_WAIT_UNTIL_RECV)

dp_pado = DataProcess(process=[('ALT', None, UI(conf='fuzz')),
('tTYPE', UI(init=20), UI(order=True, fuzz_mag=0.7)),
'FIX_FIELDS#pado1'], seed='pado')
dp_pado.append_new_process([('ALT', None, UI(conf='fuzz')),
('tSTRUCT', UI(init=1), UI(deep=True)), 'FIX_FIELDS#pado2'])
step_send_pado = Step(dp_pado, fbk_timeout=0.1, fbk_mode=Target.FBK_WAIT_FULL_TIME)
# step_send_pado = Step('pado')
step_end = Step('padt')
step_end = Step(DataProcess(process=[('FIX_FIELDS#pado3', None, UI(reevaluate_csts=True))],
seed='padt'), fbk_timeout=0.1, fbk_mode=Target.FBK_WAIT_FULL_TIME)

step_wait_padi.connect_to(step_send_pado, cbk_after_fbk=retrieve_padi_from_feedback_and_update)
step_send_pado.connect_to(step_end)
Expand All @@ -186,16 +189,19 @@ def disrupt_data(self, dm, target, prev_data):
sc1.set_anchor(step_wait_padi)

### PADS fuzz scenario ###
step_wait_padi = NoDataStep(fbk_timeout=1)
step_send_valid_pado = Step(DataProcess(process=[('FIX_FIELDS#2', None, UI(reevaluate_csts=True))],
seed='pado'))
step_send_padt = Step(DataProcess(process=[('FIX_FIELDS#3', None, UI(reevaluate_csts=True))],
seed='padt'), fbk_timeout=0.1)

dp_pads = DataProcess(process=[('tTYPE#2', UI(init=1), UI(order=True)), 'FIX_FIELDS'], seed='pads')
dp_pads.append_new_process([('tSTRUCT#2', UI(init=1), UI(deep=True)), 'FIX_FIELDS'])
step_send_fuzzed_pads = Step(dp_pads)
step_wait_padr = NoDataStep(fbk_timeout=1)
step_wait_padi = NoDataStep(fbk_timeout=10, fbk_mode=Target.FBK_WAIT_UNTIL_RECV)
step_send_valid_pado = Step(DataProcess(process=[('FIX_FIELDS#pads1', None, UI(reevaluate_csts=True))],
seed='pado'), fbk_timeout=0.1, fbk_mode=Target.FBK_WAIT_FULL_TIME)
step_send_padt = Step(DataProcess(process=[('FIX_FIELDS#pads2', None, UI(reevaluate_csts=True))],
seed='padt'), fbk_timeout=0.1, fbk_mode=Target.FBK_WAIT_FULL_TIME)

dp_pads = DataProcess(process=[('ALT', None, UI(conf='fuzz')),
('tTYPE#2', UI(init=1), UI(order=True, fuzz_mag=0.7)),
'FIX_FIELDS#pads3'], seed='pads')
dp_pads.append_new_process([('ALT', None, UI(conf='fuzz')),
('tSTRUCT#2', UI(init=1), UI(deep=True)), 'FIX_FIELDS#pads4'])
step_send_fuzzed_pads = Step(dp_pads, fbk_timeout=0.1, fbk_mode=Target.FBK_WAIT_FULL_TIME)
step_wait_padr = NoDataStep(fbk_timeout=10, fbk_mode=Target.FBK_WAIT_UNTIL_RECV)

step_wait_padi.connect_to(step_send_valid_pado, cbk_after_fbk=retrieve_padi_from_feedback)
step_send_valid_pado.connect_to(step_send_fuzzed_pads, cbk_after_fbk=retrieve_padr_from_feedback_and_update)
Expand Down
2 changes: 1 addition & 1 deletion data_models/tuto.py
Expand Up @@ -431,7 +431,7 @@ def keycode_helper(blob, constraints, node_internals):
]}

regex_desc = {'name': 'regex',
'contents': '(333|444)|(foo|bar)|[\d]|[th|is]'}
'contents': '(333|444)|(foo|bar)|\d|[th|is]'}


self.register(test_node_desc, abstest_desc, abstest2_desc, separator_desc,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Expand Up @@ -57,7 +57,7 @@
# The short X.Y version.
version = '0.25'
# The full version, including alpha/beta/rc tags.
release = '0.25.0'
release = '0.25.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
10 changes: 10 additions & 0 deletions docs/source/data_model.rst
Expand Up @@ -461,6 +461,16 @@ conf
Used within the scope of the description of an alternative
configuration. It set the name of the alternative configuration.

evolution_func
This attribute allows to provide a function that will be used in the case the described node is
instantiated more than once by a containing non-terminal node further to a
:meth:`framework.data_model.Node.freeze` operation (refer to the ``qty`` keyword).
The function will be called on every node instance (but the first one) before this node
incorporate the frozen form of the non-terminal. Besides, the node returned by the function will
be used as the base node for the next instantiation (which makes node evolution easier).
The function shall have the following signature::

func_name( Node ) --> Node

custo_set, custo_clear
These attributes are used to customize the behavior of the described node.
Expand Down
15 changes: 8 additions & 7 deletions docs/source/disruptors.rst
Expand Up @@ -243,17 +243,18 @@ Parameters:
| | desc: graph path regexp to select nodes on which the disruptor should
| | apply
| | default: None [type: str]
|_ singleton
| | desc: consume also terminal nodes with only one possible value
| | default: False [type: bool]
|_ nt_only
| | desc: walk through non-terminal nodes only
| | default: False [type: bool]
|_ order
| | desc: when set to True, the walking order is strictly guided by the
| | data structure. Otherwise, fuzz weight (if specified in the
| | data model) is used for ordering
| | default: True [type: bool]
|_ fix_all
| | desc: for each produced data, reevaluate the constraints on the whole
| | graph
| | default: True [type: bool]
|_ nt_only
| | desc: walk through non-terminal nodes only
| | default: False [type: bool]
Stateless Disruptors
====================
Expand Down
9 changes: 9 additions & 0 deletions docs/source/probes.rst
Expand Up @@ -65,6 +65,15 @@ Description:
This generic backend enables you to interact with a monitored system through an
serial line.

Shell_Backend
-------------

Reference:
:class:`framework.monitor.Shell_Backend`

Description:
This generic backend enables you to interact with a local monitored system
through a shell.

Generic Probes
==============
Expand Down
3 changes: 2 additions & 1 deletion docs/source/scenario.rst
Expand Up @@ -72,7 +72,8 @@ From line 9 to 11 we define 3 :class:`framework.scenario.Step`:
time duration that ``Fuddly`` should respect for collecting the feedback from the target (feedback
timeout). This timeout is actually handled by the ``Target`` object, which may decide to respect it
or not. For instance the ``NetworkTarget`` respect it while the ``EmptyTarget`` (default target)
do not.
do not. Note that the feedback mode (refer to :ref:`targets`) is also supported and can be set
through the parameter ``fbk_mode``.

- The second step commands the framework to send a data of type ``separator`` and change the
feedback timeout to 5.
Expand Down

0 comments on commit 8292665

Please sign in to comment.