Skip to content

Commit

Permalink
Merge pull request #178 from rkoumis/172-post-to-flowsynth-compile-tr…
Browse files Browse the repository at this point in the history
…y-again

Be able to pre-fill the flowsynth compile page via GET or POST
  • Loading branch information
rkoumis authored Sep 10, 2024
2 parents 07776dc + 87457d4 commit 010aee5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
21 changes: 21 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,27 @@ build mode wizards. After the synth has been submitted, a pcap will be generated
and a download link provided. The pcap can also be directly submitted from the web interface
to Dalton, to be used in a Suricata or Snort job.

It's also possible to pre-populate the compile page, either via a GET or POST request.

Example 1:

.. code:: text
http://127.0.0.1/flowsynth/compile?flowsynth=_flowsynth_code_goes_here_
Example 2:

.. code-block:: html

<form action="http://127.0.0.1/flowsynth/compile" method="POST">
<div>
<label for="synth">What do you want to synth?</label>
<textarea rows=20 class="field span11" name="synth"></textarea>
</div>
<input type="submit">
</form>


Zeek
====

Expand Down
24 changes: 12 additions & 12 deletions app/flowsynth.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import random
import subprocess
import shlex
import hashlib
import os
import logging
import json
import sys
import logging
import os
import random
import tempfile
import re
import shlex
import subprocess
import tempfile
from logging.handlers import RotatingFileHandler
from . import certsynth

from flask import Blueprint, render_template, request, Response, redirect
from flask import Blueprint, Response, redirect, render_template, request

from . import certsynth
from .dalton import FS_BIN_PATH as BIN_PATH
from .dalton import FS_PCAP_PATH as PCAP_PATH

Expand Down Expand Up @@ -254,7 +253,7 @@ def compile_fs():
proc = subprocess.Popen(shlex.split(command), stdout = subprocess.PIPE, stderr = subprocess.PIPE)
output = proc.communicate()[0]

#parse flowsynth json
# parse flowsynth json
try:
synthstatus = json.loads(output)
except ValueError:
Expand All @@ -268,9 +267,10 @@ def compile_fs():
#render the results page
return render_template('/pcapwg/packet.html', buildstatus = synthstatus, filename=fname)

@flowsynth_blueprint.route('/compile')
@flowsynth_blueprint.route('/compile', methods=['GET', 'POST'])
def compile_page():
return render_template('/pcapwg/compile.html', page='compile')
flowsynth = request.values.get('flowsynth', '')
return render_template('/pcapwg/compile.html', page='compile', flowsynth_code=flowsynth)

@flowsynth_blueprint.route('/about')
def about_page():
Expand Down

0 comments on commit 010aee5

Please sign in to comment.