diff --git a/app/static/css/style.css b/app/static/css/style.css
index 71b3591..291ee92 100755
--- a/app/static/css/style.css
+++ b/app/static/css/style.css
@@ -111,6 +111,20 @@ input[type=text]{
color: var(--header-text);
}
+/* Make em perty so that people can see what they are typing */
+input[type=text]:focus::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
+ font-style: italic;
+ opacity: 0.3;
+}
+input[type=text]:focus:-ms-input-placeholder { /* Internet Explorer 10-11 */
+ font-style: italic;
+ opacity: 0.3;
+}
+input[type=text]:focus::-ms-input-placeholder { /* Microsoft Edge */
+ font-style: italic;
+ opacity: 0.3;
+}
+
.result-count {
position: fixed;
right: 0;
diff --git a/app/templates/home.html b/app/templates/home.html
index bed61a3..051bbb3 100644
--- a/app/templates/home.html
+++ b/app/templates/home.html
@@ -21,7 +21,7 @@
{% for target in targets %}
-  |
+  |
{{ target.hostname }} |
{{ target.address }} |
{{ target.ports[1:-1]|replace('|', ', ') }} |
diff --git a/app/views.py b/app/views.py
index bbd503b..e49b1de 100644
--- a/app/views.py
+++ b/app/views.py
@@ -5,6 +5,12 @@ from sqlalchemy import func
from sqlalchemy import or_
from app import app, db
+def targets_filter(targets, column, terms):
+ # Re-Usable Filtering For Columns, implicit AND with || operator support
+ for item in terms.replace(' ','').split(','):
+ targets = targets.filter(or_(*[column.like(item_or + '%') for item_or in item.split('||')]))
+ return targets
+
@app.route('/', methods=['GET'])
def get_home():
"""Render website's home page."""
@@ -25,22 +31,21 @@ def post_home():
os = request.form.get("os")
if os:
- targets = targets.where(target.os == os)
+ targets = targets_filter(targets, target.os, os)
hostname = request.form.get("hostname")
if hostname:
- targets = targets.filter(target.hostname.like('%'+hostname+'%'))
+ targets = targets_filter(targets, target.hostname, hostname)
address = request.form.get("address")
if address:
- targets = targets.filter(target.address.like('%'+address+'%'))
+ targets = targets_filter(targets, target.address, address)
ports = request.form.get("ports")
if ports:
+ # I needed a non-default case to handle ports since they have a | separator in the DB
for port in ports.replace(' ','').split(','):
- # Add additional indent to check for || case, I'm sorry for your eyes if you see this
targets = targets.filter(or_(*[target.ports.like('%|' + port_or + '|%') for port_or in port.split('||')]))
- #targets = targets.filter(target.ports.like('%|'+port+'|%'))
return render_template('home.html', targets=targets.all(), os=os,hostname=hostname,address=address,ports=ports,clientId=clientId)