Skip to content

Commit

Permalink
make trailing slash optional on handler and fix dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Dowling committed Jan 21, 2020
1 parent 0e92ae2 commit 50807e4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion demo/apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ COPY . /var/www/TRX/

RUN chown -R www-data:www-data /var/www/TRX/

CMD ["python", "project.py", "runserver"]
CMD ["python3", "project.py", "runserver"]
2 changes: 1 addition & 1 deletion demo/gunicorn/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ COPY . /var/www/TRX/

RUN chown -R www-data:www-data /var/www/TRX/

CMD ["python", "project.py", "runserver"]
CMD ["python3", "project.py", "runserver"]
2 changes: 1 addition & 1 deletion maltego_trx/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def handle_run(name, args, app):
if command == "runserver":
print("\n=== Maltego Transform Server: v%s ===\n" % VERSION)
print_transforms()
app.run(host="0.0.0.0", port=8080, debug=True)
app.run(host="0.0.0.0", port=8080, debug=False)
elif command == "list":
print_transforms()
elif command == "local" and len(args) > 3:
Expand Down
8 changes: 7 additions & 1 deletion maltego_trx/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


URL_TEMPLATE = '/run/<transform_name>/'
URL_TEMPLATE_NO_SLASH = '/run/<transform_name>'


def get_exception_message(msg="An exception occurred with the transform. Check the logs for more details."):
Expand Down Expand Up @@ -53,7 +54,7 @@ def run_transform(transform_name, client_msg):
app = Flask(__name__)
application = app # application variable for usage with apache mod wsgi

@app.route(URL_TEMPLATE, methods=['GET', 'POST'])

def transform_runner(transform_name):
transform_name = transform_name.lower()
if transform_name in mapping:
Expand All @@ -68,6 +69,11 @@ def transform_runner(transform_name):
return "No transform found with the name '%s'." % transform_name, 404


# Add the route with and without the slash, since POSTs can't be redirected
app.route(URL_TEMPLATE_NO_SLASH, methods=['GET', 'POST'])(transform_runner)
app.route(URL_TEMPLATE, methods=['GET', 'POST'])(transform_runner)


@app.route('/', methods=['GET', 'POST'])
def index():
return "You have reached a Maltego Transform Server.", 200

0 comments on commit 50807e4

Please sign in to comment.