See e.g. Maimonides Hilkhoth Rotzeach U'Shemirath Hanefesh 11:8
כל המשקין האסורין משום גילוי שנתגלו בין ביום בין בלילה אסורין ואפילו היה בצדן אדם ישן אין אימת ישן על הזוחלין. וכמה ישהו ויאסרו כדי שיצא הרחש מתחת אזן כלי וישתה ויחזור למקומו
When a liquid is forbidden if left uncovered, it is forbidden whether it was left uncovered during the day or during the night. This applies even when a person was sleeping beside the liquid. For crawling animals are not afraid of sleeping men.
For how long must a liquid be left uncovered to be forbidden? For as long as it takes for a crawling animal to emerge from under the container, drink, and return to its place.
Based on Terumoth 8:4
יַיִן שֶׁל תְּרוּמָה שֶׁנִּתְגַּלָּה, יִשָּׁפֵךְ, וְאֵין צָרִיךְ לוֹמַר שֶׁל חֻלִּין. שְׁלֹשָׁה מַשְׁקִין אֲסוּרִים מִשּׁוּם גִּלּוּי, הַמַּיִם וְהַיַּיִן וְהֶחָלָב. וּשְׁאָר כָּל הַמַּשְׁקִין מֻתָּרִים. כַּמָּה יִשְׁהוּ וְיִהְיוּ אֲסוּרִין, כְּדֵי שֶׁיֵּצֵא הָרַחַשׁ מִמָּקוֹם קָרוֹב וְיִשְׁתֶּה:
If wine that is Terumah is left uncovered, it must be poured out. It is not necessary to say this if it is Chulin [non-sacred produce]. Three kinds of liquids become forbidden if left uncovered: water, wine, and milk. All other liquids [even if left uncovered] are permitted. How long must they be left [uncovered] for them to become forbidden? As long as [it would take] for a snake to come out from a nearby place and drink [from it].