Learning Robust Representations for Malicious Content Detection via Contrastive Sampling and Uncertainty Estimation