Elon Musk’s comments about Jess Phillips were “reprehensible”, John Swinney has said, as he suggested rules about foreign donations to UK political parties should be tightened.