mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 07:41:32 +00:00
Create new FSM for SQL injection tutorial
This commit is contained in:
parent
638c1b96ae
commit
4a810b4229
@ -3,7 +3,8 @@ import logging
|
|||||||
from tornado.websocket import WebSocketHandler
|
from tornado.websocket import WebSocketHandler
|
||||||
from util import parse_anchor_from_message
|
from util import parse_anchor_from_message
|
||||||
|
|
||||||
from buttons import fsm
|
# from buttons import fsm
|
||||||
|
from sql_injection_fsm import fsm
|
||||||
import component_connector
|
import component_connector
|
||||||
|
|
||||||
|
|
||||||
|
32
src/app/sql_injection_fsm.py
Normal file
32
src/app/sql_injection_fsm.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
from transitions import Machine
|
||||||
|
|
||||||
|
import component_connector
|
||||||
|
|
||||||
|
|
||||||
|
class SQLInjectionFSM:
|
||||||
|
states = ['start', 'stripped_code', 'sql', 'commented_code', 'sql_with_substitutions', 'sql_output', 'end']
|
||||||
|
transitions = [
|
||||||
|
{'trigger': 'anchor_webide', 'source': 'start', 'dest': 'stripped_code'},
|
||||||
|
{'trigger': 'anchor_login', 'source': 'stripped_code', 'dest': 'sql'},
|
||||||
|
{'trigger': 'anchor_logger', 'source': 'sql', 'dest': 'commented_code'},
|
||||||
|
{'trigger': 'anchor_webide', 'source': 'commented_code', 'dest': 'sql_with_substitutions'},
|
||||||
|
{'trigger': 'anchor_logger', 'source': 'sql_with_substitutions', 'dest': 'sql_output'},
|
||||||
|
{'trigger': 'anchor_logger', 'source': 'sql_output', 'dest': 'end'},
|
||||||
|
{'trigger': 'reset', 'source': '*', 'dest': 'start'},
|
||||||
|
]
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.machine = Machine(model=self,
|
||||||
|
states=SQLInjectionFSM.states,
|
||||||
|
transitions=SQLInjectionFSM.transitions,
|
||||||
|
initial='start',
|
||||||
|
send_event=True,
|
||||||
|
ignore_invalid_triggers=True,
|
||||||
|
after_state_change='forward_message')
|
||||||
|
|
||||||
|
def forward_message(self, event_data):
|
||||||
|
message = event_data.kwargs.get('message')
|
||||||
|
component_connector.send_message(message)
|
||||||
|
|
||||||
|
|
||||||
|
fsm = SQLInjectionFSM()
|
Loading…
Reference in New Issue
Block a user