From de9704facf98825109d59eb73a6cae39da92384d Mon Sep 17 00:00:00 2001 From: Admin MPCZ Date: Tue, 5 May 2026 18:50:28 +0200 Subject: [PATCH] chore: script test_qualys_filter.py pour debug syntaxe filter (V1 vs V2 avec ) --- scripts/test_qualys_filter.py | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 scripts/test_qualys_filter.py diff --git a/scripts/test_qualys_filter.py b/scripts/test_qualys_filter.py new file mode 100644 index 0000000..01b5003 --- /dev/null +++ b/scripts/test_qualys_filter.py @@ -0,0 +1,47 @@ +"""Test rapide du filter Qualys — exécuter depuis C:\\patchcenter.""" +import sys +sys.path.insert(0, ".") +import requests +import urllib3 + +from app.database import SessionLocal +from app.services.secrets_service import get_secret + +urllib3.disable_warnings() + +db = SessionLocal() +url = get_secret(db, "qualys_url").strip() +user = get_secret(db, "qualys_user").strip() +pwd = get_secret(db, "qualys_pass").strip() +db.close() + +ep = url.rstrip("/") + "/qps/rest/2.0/search/am/hostasset" +hdr = {"X-Requested-With": "PC", "Content-Type": "text/xml"} + +# Variante 1 : Criteria direct sous +body1 = ( + '' + '10' + '' + 'vpburadps1' + '' + '' +) +# Variante 2 : Criteria sous +body2 = ( + '' + '10' + '' + '' + 'vpburadps1' + '' + '' + '' +) + +for label, body in [("V1 sans ", body1), ("V2 avec ", body2)]: + print(f"\n=== {label} ===") + print("BODY:", body) + r = requests.post(ep, auth=(user, pwd), headers=hdr, data=body, verify=False, timeout=10) + print("STATUS:", r.status_code) + print(r.text[:800])