What kind of resistance to occupation is legal according to international law?
from the International Committee of the Red Cross (emphasis added)
After effective occupation of territory, members of the territory’s armed forces who have not surrendered, organized resistance movements and genuine national liberation movements may resist the occupation. If they do so, they must distinguish themselves from the civilian population, or on the basis of GP I, at least carry their weapons openly during attacks and deployments.
Civilians who take a direct part in such hostilities lose their protection against attack for the time of their direct participation, but not their civilian status. If they do not participate directly in hostilities or no longer do so, they are protected against attacks.
Indirect support for the resistance movement, such as providing information or non-military supplies, does not constitute taking a direct part in hostilities. Those so engaged are civilians and therefore protected against attack. They may, however, be in contravention of security laws passed by the occupying power. In that case, they can be tried and sentenced or their freedom of movement restricted.
Palestinian right to fight occupation not only moral, but legal as well