A Palestinian worker walks inside al-Awdah food factory, which witnesses said was shelled and torched by the Israeli army during the offensive, in Deirl al-Balah in the central Gaza Strip August 14, 2014 (Photo: Reuters)
First Israel's Iron Dome air defence system protected millions from rocket attacks. Now the state is assembling a "legal Iron Dome" to defend itself against potential allegations of war crimes in Gaza.
For Israel, the threat of another fight -- not on the battlefield but in the courts -- materialised on Monday with the appointment of a UN committee to investigate "all violations of international human rights and humanitarian law" in the occupied Palestinian territories since mid-June.
Israel has been engaged in a bloody offensive in Gaza.
The investigators are due to present their findings to the UN Human Rights Council in March 2015 but Israel has already denounced its chairman, William Schabas, as anti-Israeli and its findings as inevitably biased.
But neither was it surprised. From the start of Operation Protective Edge, which began on July 8, the army has been preparing the ground for any legal fallout by forming its own committee of military experts.
"We created this investigative committee after Operation Pillar of Defence," Captain Arye Shalicar told AFP, referring to an eight-day assault on Gaza in November 2012.
"This time we activated it during the operation to document each event, particularly the most tragic in which lots of civilians were killed," he told AFP.
"The cornerstone of our work is principally provided by military intelligence, which examines each operation ahead of time," he said.
"For example, if a house in Gaza was used to fire a rocket on Israel, then according to the laws of war, it becomes a military position and therefore a legitimate target.
"If we're wrong, we should admit our mistake and learn from it."
Israel had boycotted a previous UN committee which looked into Operation Cast Lead, a major 22-day assault over New Year 2009 which killed 1,440 Palestinians and 13 Israelis.
Published in autumn 2009, the so-called Goldstone Report accused both Israel and Hamas of war crimes and "possibly crimes against humanity".
Since July 8, the current offensive has killed more than 1,960 Palestinians and 67 people on the Israeli side, although a five-day truce is now in force to give negotiators time to broker a longer-term ceasefire.
Israel has been accused all over the world of inflicting disproportionate casualties and collectively punishing Gaza's 1.8 million residents for rocket attacks perpetrated by hundreds of militants.
Braced for fresh accusations, Justice Minister Tzipi Livni has appointed a team of legal experts to draw up not only a line of defence, but also Israel's line of attack.
Israel says Hamas caused civilian casualties by using innocent women and children as human shields.
And it has defended its used of force as proportionate, saying no democracy could allow armed militants to threaten and attack millions of its people.
In a move designed to show Israel is capable of investigating itself, the attorney general's office has said it will investigate circumstances in which Palestinian civilians were needlessly killed.
The Palestinians, who in 2012 obtained non-member observer status at the United Nations, say they will soon try to haul Israelis before the International Criminal Court for alleged war crimes.
For Israel, perhaps the most serious outcome would be for foreign courts to issue arrest warrants for military officers or even politicians.
In 2009 a British court issued an arrest warrant for Livni, one of the most moderate voices in the current Israel government, after Palestinian activists made an application over her role as foreign minister during the war of New Year 2009.
Britain has since amended the law to ensure that private arrest warrants for such offences would first have to be approved by the chief prosecutor.
Prime Minister Benjamin Netanyahu lashed out Wednesday at the UN Human Rights Council, accusing it of granting "legitimacy to terror organisations" by investigating Israel and not mass killings perpetrated elsewhere in the Middle East.
Hamas, whose own activities will also be investigated by the commission, welcomed its creation and called for it to start work as soon as possible.
Schabas has urged Israel to cooperate with the inquiry.
"It's in Israel's interest to be there in that discussion and give its version of the events. If it doesn't, it leaves an unfortunate one-sided picture of it," he told Israel's Channel 2 television.