As the violence between Israel and Hezbollah has escalated dramatically in recent days, civilians have paid a heavy price.
Hundreds of people in southern Lebanon have been killed and more than 1,600 wounded in Israeli airstrikes.
Hezbollah, meanwhile, has fired hundreds of rockets and other munitions into Israel.
More than 160,000 people have been displaced on either side of the border from the fighting, which many fear may be close to tipping into a full-scale war.
One senior analyst for the International Crisis Group said there's been a "very worrying shift" on both sides in recent days in terms of a willingness to cause civilian casualties.
In such a chaotic environment, just what exactly are both sides obligated to do under the law to prevent civilian casualties?
What are both sides obligated to do as a baseline?
The law of armed conflict is very straightforward on this question - they must only target military objectives and military personnel. They must not target civilians.
And even when launching attacks against legitimate military objectives, all parties to an armed conflict are under an obligation to, as much as possible, minimise the risk of collateral, civilian damage.
If it becomes clear at any point in the planning or the execution of an attack that there is going to be disproportionate civilian damage, then the attack should be called off or appropriate warnings should be given.
Warnings are complicated, though. There is no strict obligation to warn civilians in the law of conflict. Rather, there is a requirement to warn civilians if the circumstances permit.
So, for instance, if it's necessary to immediately attack a specific location because it's the only opportunity you would have to target an insurgent leader or legitimate high-value target, there's no obligation to give prior warning.
The other complication is that while the Israeli Defence Forces have been historically quite good about providing warnings through email blasts and leaflet drops, there are still physical constraints in places like Gaza and southern Lebanon. They are densely populated and quite geographically confined.
So the degree to which people can actually physically flee when they've been given a warning is debatable. How effective can a warning be if there's nowhere for them to go?
Distinguishing between civilian and military targets
All parties in a conflict are bound by the same obligation, which is to distinguish between civilians and the military.
That said, the law of armed conflict does allow for some collateral damage - which is defined as unavoidable incidental civilian casualties. The parties to a conflict need to take this into account in a proportionality assessment.
This places obligations on parties to a conflict to perhaps choose a different time or method of warfare to make the attacks more specific.
There are some aerial drone attacks and missile attacks that can be highly discriminate. For example, there are missiles that can be timed to only detonate inside a particular apartment, so that only the residents in that apartment are injured or killed. It does not bring down the entire building.
Where you start coming into problems are bombardments of entire buildings in order to target one really high-value individual - does this justify a much higher number of civilian casualties?
There is an element of the IDF using this justification because Hamas and Hezbollah are non-state groups and don't engage in regular tactics.
Is Hezbollah bound by the same rules?
Hezbollah is absolutely bound by the same rules as states. Nearly all the rules of the law of armed conflict are customary. This means everyone is bound by the law, even if they haven't been a signatory to a treaty like the Geneva Convention.
This means, for example, that Hezbollah must prevent casualties among Lebanese citizens, as well as Israelis. Under the law, Hezbollah does not only have to distinguish between civilians and the military in their active attacks. They also can't attempt to immunise their military assets by placing them in dense civilian areas.
And they need to do their utmost to remove civilians from areas where there are going to be military attacks.
Again, part of the complication is these are very enclosed spaces. So the question becomes exactly how far away do civilians need to be?
This is not just specific to Gaza, Lebanon or Israel - it's a question for most places that have densely built-out areas. Urban warfare is one of the really difficult areas for the law at the moment.
Where to from here?
The tactics being used by Hamas and Hezbollah are nothing new. There's always been a fairly consistent disregard for the law and brutality in a lot of their activities.
But if it can be proven the pager and walkie-talkie attacks on Hezbollah were carried out by the IDF, that's a new level of brutality for Israel, because that's an absolute violation of the protocol on booby traps and landmines. Israel is a party to that protocol.
The laws always get broken in times of armed conflict. But this has been quite unprecedented.
For legal and political reasons, there is value in actually acquitting yourself in a conflict with restraint. Parties to a conflict are still operating on the basis that eventually normal international relations have to resume. And it's far better to have those international relations resume without the other side believing you capable of barbarism.