Added || to port queries, using a comma is still an implicit AND

This commit is contained in:
rain
2023-06-19 19:02:56 -05:00
parent 00f9cf472c
commit ef551766d1
+4 -2
View File
@@ -2,6 +2,7 @@ from flask import render_template, request, redirect, url_for, flash
from sqlalchemy import select from sqlalchemy import select
from app.models import target from app.models import target
from sqlalchemy import func from sqlalchemy import func
from sqlalchemy import or_
from app import app, db from app import app, db
@app.route('/', methods=['GET']) @app.route('/', methods=['GET'])
@@ -37,8 +38,9 @@ def post_home():
ports = request.form.get("ports") ports = request.form.get("ports")
if ports: if ports:
for port in ports.replace(' ','').split(','): for port in ports.replace(' ','').split(','):
targets = targets.filter(target.ports.like('%|'+port+'|%')) # 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) return render_template('home.html', targets=targets.all(), os=os,hostname=hostname,address=address,ports=ports,clientId=clientId)