From ef551766d133b71641139492254ca9791bee997e Mon Sep 17 00:00:00 2001 From: rain Date: Mon, 19 Jun 2023 19:02:56 -0500 Subject: [PATCH] Added || to port queries, using a comma is still an implicit AND --- app/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/views.py b/app/views.py index 48975dc..bbd503b 100644 --- a/app/views.py +++ b/app/views.py @@ -2,6 +2,7 @@ from flask import render_template, request, redirect, url_for, flash from sqlalchemy import select from app.models import target from sqlalchemy import func +from sqlalchemy import or_ from app import app, db @app.route('/', methods=['GET']) @@ -37,8 +38,9 @@ def post_home(): ports = request.form.get("ports") if ports: 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)