Article 51 of the UN Charter guarantees its members "the inherent right to...individual self defense" against "an armed attack." Hamas fires rockets at civilian targets in southern Israel. If this is not an "armed attack" under Article 51, then I don't know what is. Rocketing civilian population centers, as Hamas is doing, is also a war crime. International law prohibits, even during a declared war, the deliberate targeting of civilians or the bombing of areas of civilian population centers with absolutely no military significance. If anything, an armed attack that is also a war crime justifies the right of self-defense even more.
What then are Israel's rights under international law? What have, and what would, other nations whose cities and towns were attacked by enemy rockets do? Israel certainly has the right to counterattack its enemy, destroy its capacity to fire rockets and engage in "belligerent reprisal." Rockets are fired from densely populated areas, precisely in order to force Israel into choosing between allowing its own civilians to continue to be killed by its inaction, or taking actions that risk hurting some Palestinian civilians. Either way Hamas wins. If Israel does nothing, then Hamas accuses it of impotence. If it does something, then Hamas accuses it of disproportionality.