It is reported that ʿUmar b. Al-Khaṭṭāb – Allāh be pleased with him – said:
Do not expose yourself to what does not concern you, stay away from your enemy, beware of [taking as] your friend anyone except the trustworthy amongst people – and there is no one who is trustworthy except one who fears Allāh; and do not accompany the sinner in case you learn his sinfulness, and do not let him know your secrets, and consult those who fear Allāh for your affairs.
Ibn Abī Shaybah, Al-Muṣannaf 34476.