Submit URL through a POST request instead of a GET. Encore URL when querying the cache

travis
Raphaël Vinot 2015-03-11 18:14:25 +01:00
parent a113b4178e
commit 52cefba027
4 changed files with 21 additions and 5 deletions

View File

@ -375,8 +375,10 @@ def whois(server, port, domain, ignorelist, replacelist):
if domain.startswith('http'): if domain.startswith('http'):
fex = Faup() fex = Faup()
fex.decode(domain) fex.decode(domain)
domain = fex.get_domain().lower() d = fex.get_domain().lower()
s.send(domain + "\r\n") else:
d = domain
s.send(d + "\r\n")
response = '' response = ''
while True: while True:
d = s.recv(4096) d = s.recv(4096)

View File

@ -1,5 +1,6 @@
import json import json
import os import os
from base64 import urlsafe_b64decode
from flask import Flask, render_template, request, Response, redirect, url_for, flash from flask import Flask, render_template, request, Response, redirect, url_for, flash
from flask_mail import Mail, Message from flask_mail import Mail, Message
@ -273,6 +274,7 @@ def create_app(configfile=None):
@app.route('/get_cache/<path:url>') @app.route('/get_cache/<path:url>')
def get_cache(url): def get_cache(url):
url = urlsafe_b64decode(url.encode('utf-8'))
data = get_cached(url) data = get_cached(url)
dumped = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')) dumped = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
return dumped return dumped
@ -290,8 +292,10 @@ def create_app(configfile=None):
msg.body = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')) msg.body = json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
mail.send(msg) mail.send(msg)
@app.route('/submit/<path:url>') @app.route('/submit', methods=['POST'])
def send_mail(url): def send_mail():
data = json.loads(request.data)
url = data["url"]
if get_mail_sent(url): if get_mail_sent(url):
flash('Mail already sent to CIRCL.') flash('Mail already sent to CIRCL.')
else: else:

View File

@ -66,6 +66,15 @@
$scope.query('start', {"url": userInput}, check_validity); $scope.query('start', {"url": userInput}, check_validity);
}; };
$scope.submit_email = function() {
$scope.query('submit', {"url": $scope.query_url}, function(){
$scope.query_url = '';
$scope.urls = '';
$scope.input_url = '';
});
};
}); });
app.directive('uqUrlreport', function(globFct) { app.directive('uqUrlreport', function(globFct) {

View File

@ -57,7 +57,8 @@
</div> </div>
<div ng-show="urls"> <div ng-show="urls">
<br/> <br/>
<center><a href="submit/{{ query_url }}">Send report to CIRCL</a></center> <center><a ng-click="submit_email()">Send report to CIRCL</a></center>
<!-- <center><a href="submit/{{ query_url }}">Send report to CIRCL</a></center> -->
<br/> <br/>
</div> </div>
<div ng-repeat="url in urls"> <div ng-repeat="url in urls">