Also, Rahab did not break the 9th Commandment and lie, either. She was using the art of war in protecting the interests of God's people. For she did not lie to protect herself or to cover up another sin or anything of that nature.
For in war time or in protecting your loved ones or God's people, a person can use the art of war to defend that which is good. This sometimes unfortunately involves deceiving and or eliminating your enemy; However, these things are not done out of selfish ambition, but they are done in order to preserve innocent lives or to protect the common good.
For the Hebrew midwives had lied to the Pharoah's servants to protect the innocent (Exodus 1).
And King David pretended he was crazy when he was not crazy in front of the enemy king of Gath named "Achish" (1 Samuel 21:10, 11, 12, 13, 14, 15).
Also, Elisha deceived the enemy when they were blinded by lying about where he was taking them. (2 Kings 6:19)
In addition in Joshua 8:
Joshua himself went in battle against the city of Ai, they pretended that they were being defeated and they retreated. They weren’t being defeated—it was a trap. The Israelites deceived them.