Creating a virtual patch
Typically, you will know that there is a need to apply a virtual patch because you are notified of a vulnerability in one of the following ways:
A bug report from users
A code review finds vulnerabilities in your code
The vendor of your web application releases a notice of a vulnerability
A new exploit is being used in the wild
You are being actively attacked
Of these alternatives, the last two options present an extra sense of urgency, as any vulnerabilities that have actual exploits available for them make it a certainty that a worm/attack tool will soon become available that automates the attack on a large scale.
Rather than wait before you are being attacked, it is of course always better to be ahead of the game and be aware of possible exploits before they start being used in the wild. Most vendors have a security notification email list, so make sure you're subscribed to that for any third-party web applications you are using. Other good places to learn about new...