Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d67d2c6bc9 | ||
|
|
d1305bc879 | ||
|
|
06e17a6591 | ||
|
|
8396c10a7b | ||
|
|
17c5ade3ce | ||
|
|
f4310c855f |
+1
-1
@@ -41,7 +41,7 @@ ENV PYTHONPATH="/usr/local/lib" \
|
|||||||
PROMPT_COMMAND="history -a"
|
PROMPT_COMMAND="history -a"
|
||||||
|
|
||||||
COPY bashrc /tmp
|
COPY bashrc /tmp
|
||||||
RUN echo "export HISTFILE=${TFW_HISTFILE}\n" >> /tmp/bashrc &&\
|
RUN echo "export HISTFILE=${TFW_HISTFILE}" >> /tmp/bashrc &&\
|
||||||
cat /tmp/bashrc >> /home/${AVATAO_USER}/.bashrc
|
cat /tmp/bashrc >> /home/${AVATAO_USER}/.bashrc
|
||||||
|
|
||||||
COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF}
|
COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF}
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
This is the beating heart of TFW – the Docker baseimage containing the internals of the framework.
|
This is the beating heart of TFW – the Docker baseimage containing the internals of the framework.
|
||||||
|
|
||||||
Every tutorial-framework based challenge has a `solvable` Docker image based on this one: their `Dockerfile`s begin with `FROM eu.gcr.io/avatao-challengestore/tutorial-framework`.
|
Every tutorial-framework based challenge has a `solvable` Docker image based on this one: their `Dockerfile`s begin with `FROM eu.gcr.io/avatao-challengestore/tutorial-framework`.
|
||||||
Note that TFW is not avaliable on Docker Hub due to legal reasons and is only accessible through local builds (dont't worry, we've got you covered with build scripts in the `test-tutorial-framework` repo).
|
Note that TFW is not avaliable on Docker Hub due to legal reasons and is only accessible through local builds (don't worry, we've got you covered with build scripts in the [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework) repo).
|
||||||
|
|
||||||
This document explains the general concepts of TFW and should be the first thing you read before getting started with development.
|
This document explains the general concepts of TFW and should be the first thing you read before getting started with development.
|
||||||
|
|
||||||
For more on building and running you should consult the `test-tutorial-framework` repo.
|
For more on building and running you should check the [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework) repo.
|
||||||
|
|
||||||
## The framework
|
## The framework
|
||||||
|
|
||||||
@@ -22,9 +22,9 @@ Frontend components use websockets to connect to the TFW server, to which you ca
|
|||||||
|
|
||||||
### Event handlers
|
### Event handlers
|
||||||
|
|
||||||
Imagine event handlers as callbacks that are invoked when TFW receives a specific type of message. For instance you could send a message to the framework when the user does something of note.
|
Imagine event handlers as callbacks that are invoked when TFW receives a specific type of message. For instance, you could send a message to the framework when the user does something of note.
|
||||||
|
|
||||||
This allows you to define actions triggered on the backend when the user presses a button on the frontend, moves the cursor to a specific area or anything like that.
|
Event handler allow you to define actions triggered on the backend when the user presses a button on the frontend or moves the cursor to a specific area, etc.
|
||||||
|
|
||||||
Event handlers use ZeroMQ to connect to the framework. Due to this they are as loosely-coupled as possible: usually they are running in separate processes and only communicate with TFW through ZMQ.
|
Event handlers use ZeroMQ to connect to the framework. Due to this they are as loosely-coupled as possible: usually they are running in separate processes and only communicate with TFW through ZMQ.
|
||||||
|
|
||||||
@@ -38,9 +38,9 @@ Inside Avatao this means that any of the content teams can use the framework wit
|
|||||||
Another unique feature of the framework is the FSM – finite state machine – representing the state of your challenge.
|
Another unique feature of the framework is the FSM – finite state machine – representing the state of your challenge.
|
||||||
This allows you to track users progressing with the tasks you've defined for them to complete.
|
This allows you to track users progressing with the tasks you've defined for them to complete.
|
||||||
|
|
||||||
For instance you could represent whether the user managed to create a malicious user with a state called `user_registered` and subscribe callbacks to events regarding that state (like entering or leaving).
|
For instance, you could represent whether the user managed to create a malicious user with a state called `user_registered` and subscribe callbacks to events regarding that state (like entering or leaving).
|
||||||
|
|
||||||
You could create challenges that can be completed in several different ways: imagine a state called `challenge_complete`, which represents when the challenge is completed. Several series of actions (triggers) could lead to this state.
|
You could create challenges that can be completed in several different ways: imagine a state called `challenge_complete`, which indicates if the challenge is completed. Several series of actions (triggers) could lead to this state.
|
||||||
|
|
||||||
This enables you to guide your users through the experience you've envisioned with your tutorial.
|
This enables you to guide your users through the experience you've envisioned with your tutorial.
|
||||||
We can provide a whole new level of interactivity in our challenges because we know what the user is doing.
|
We can provide a whole new level of interactivity in our challenges because we know what the user is doing.
|
||||||
@@ -48,12 +48,12 @@ This includes context-dependent hints and the automatic typing of commands to a
|
|||||||
|
|
||||||
### Frontend
|
### Frontend
|
||||||
|
|
||||||
Note that our frontend implementation is written in Angular. It is maintained and documented in the `frontend-tutorial-framework` repository.
|
Note that our frontend implementation is written in Angular. It is maintained and documented in the [frontend-tutorial-framework](https://github.com/avatao-content/frontend-tutorial-framework) repository.
|
||||||
|
|
||||||
### Messaging format
|
### Messaging format
|
||||||
|
|
||||||
The framework uses JSON messages internally and in exposed APIs as well.
|
The framework uses JSON messages internally and in exposed APIs as well.
|
||||||
These messages must comply some rules.
|
These messages must comply with some rules.
|
||||||
Don't worry, we are not too fond of rules around these parts.
|
Don't worry, we are not too fond of rules around these parts.
|
||||||
|
|
||||||
The TFW message format:
|
The TFW message format:
|
||||||
@@ -80,4 +80,4 @@ The TFW message format:
|
|||||||
|
|
||||||
Most of the components you need have docstrings included (hang on tight, this is work in progress) – refer to them for usage info.
|
Most of the components you need have docstrings included (hang on tight, this is work in progress) – refer to them for usage info.
|
||||||
|
|
||||||
To get started you should take a look at the `test-tutorial-framework` repository, which serves as an example project as well.
|
To get started you should take a look at the [test-tutorial-framework](https://github.com/avatao-content/test-tutorial-framework) repository, which serves as an example project as well.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
from .directory_monitoring_event_handler import DirectoryMonitoringEventHandler
|
from .directory_monitoring_event_handler import DirectoryMonitoringEventHandler
|
||||||
from .process_managing_event_handler import ProcessManagingEventHandler
|
from .process_managing_event_handler import ProcessManagingEventHandler
|
||||||
from .terminado_event_handler import TerminadoEventHandler
|
from .terminal_event_handler import TerminalEventHandler
|
||||||
from .ide_event_handler import IdeEventHandler
|
from .ide_event_handler import IdeEventHandler
|
||||||
from .history_monitor import HistoryMonitor, BashMonitor, GDBMonitor
|
from .history_monitor import HistoryMonitor, BashMonitor, GDBMonitor
|
||||||
from .terminal_commands import TerminalCommands
|
from .terminal_commands import TerminalCommands
|
||||||
|
|||||||
@@ -111,8 +111,11 @@ class IdeEventHandler(EventHandlerBase, MonitorManagerMixin):
|
|||||||
:param exclude: list of filenames that should not appear between files (for *.o, *.pyc, etc.)
|
:param exclude: list of filenames that should not appear between files (for *.o, *.pyc, etc.)
|
||||||
"""
|
"""
|
||||||
super().__init__(key)
|
super().__init__(key)
|
||||||
|
try:
|
||||||
self.filemanager = FileManager(allowed_directories=allowed_directories, working_directory=directory,
|
self.filemanager = FileManager(allowed_directories=allowed_directories, working_directory=directory,
|
||||||
selected_file=selected_file, exclude=exclude)
|
selected_file=selected_file, exclude=exclude)
|
||||||
|
except IndexError:
|
||||||
|
raise EnvironmentError(f'No file(s) in IdeEventHandler working_directory "{directory}"!')
|
||||||
MonitorManagerMixin.__init__(self, DirectoryMonitor, self.filemanager.workdir)
|
MonitorManagerMixin.__init__(self, DirectoryMonitor, self.filemanager.workdir)
|
||||||
|
|
||||||
self.commands = {'read': self.read,
|
self.commands = {'read': self.read,
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ from .terminado_mini_server import TerminadoMiniServer
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class TerminadoEventHandler(EventHandlerBase):
|
class TerminalEventHandler(EventHandlerBase):
|
||||||
"""
|
"""
|
||||||
Event handler responsible for managing terminal sessions for frontend xterm
|
Event handler responsible for managing terminal sessions for frontend xterm
|
||||||
sessions to connect to. You need to instanciate this in order for frontend
|
sessions to connect to. You need to instanciate this in order for frontend
|
||||||
@@ -5,14 +5,18 @@ from .fsm_base import FSMBase
|
|||||||
|
|
||||||
|
|
||||||
class LinearFSM(FSMBase):
|
class LinearFSM(FSMBase):
|
||||||
|
# pylint: disable=anomalous-backslash-in-string
|
||||||
"""
|
"""
|
||||||
This is a state machine for challenges with linear progression, consisting of
|
This is a state machine for challenges with linear progression, consisting of
|
||||||
a number of steps specified in the constructor. It automatically sets up a single
|
a number of steps specified in the constructor. It automatically sets up 2
|
||||||
action between states as such:
|
actions (triggers) between states as such:
|
||||||
0 ==step_1==> 1 ==step_2==> 2 ==step_3==> 3 ... and so on
|
(0) -- step_1 --> (1) -- step_2 --> (2) -- step_3 --> (3) ... and so on
|
||||||
|
\-step_next-/ \-step_next-/ \-step_next-/
|
||||||
"""
|
"""
|
||||||
def __init__(self, number_of_steps):
|
def __init__(self, number_of_steps):
|
||||||
self.states = list(map(str, range(number_of_steps)))
|
self.states = list(map(str, range(number_of_steps)))
|
||||||
self.transitions = [{'trigger': f'step_{int(index)+1}', 'source': index, 'dest': str(int(index)+1)}
|
self.transitions = []
|
||||||
for index in self.states[:-1]]
|
for index in self.states[:-1]:
|
||||||
|
self.transitions.append({'trigger': f'step_{int(index)+1}', 'source': index, 'dest': str(int(index)+1)})
|
||||||
|
self.transitions.append({'trigger': 'step_next', 'source': index, 'dest': str(int(index)+1)})
|
||||||
super(LinearFSM, self).__init__()
|
super(LinearFSM, self).__init__()
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ server {
|
|||||||
proxy_connect_timeout 7d;
|
proxy_connect_timeout 7d;
|
||||||
proxy_send_timeout 7d;
|
proxy_send_timeout 7d;
|
||||||
proxy_read_timeout 7d;
|
proxy_read_timeout 7d;
|
||||||
|
absolute_redirect off;
|
||||||
|
|
||||||
location = /ws {
|
location = /ws {
|
||||||
proxy_pass http://127.0.0.1:${TFW_WEB_PORT};
|
proxy_pass http://127.0.0.1:${TFW_WEB_PORT};
|
||||||
|
|||||||
Reference in New Issue
Block a user