Semi permeable membrane
In my opinion, it should work by size exclusion. Bacteria are on the size of few microns, whereas the pores in semi-permeable membranes are on the size of nanometers. Therefore, bacteria will not pass through the membrane. 

Viruses are usually smaller than bacteria, and so maybe more likely to pass through such a membrane. However, you have not included the pore size of the semipermeable membrane in question, and so I am unable to give a more specific answer at this point. If the pores of the membrane are very small, even viruses will not be able to pass through it.