Your question is Validate String Input for Injection. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
WatchGuard security surfaces such as Firebox management APIs and WatchGuard Cloud services must reject input containing common injection signatures. Implement a validator that returns True when an input contains one of the specified suspicious patterns, and False otherwise.
Before matching, normalize the input by repeatedly URL-decoding it up to two times, converting HTML entities, lowercasing it, and replacing each whitespace run with one space. Do not remove punctuation, because punctuation is significant for several signatures.
Implement is_suspicious(value), where value is a string. Return a boolean. Treat an empty string as safe. Detect these case-insensitive signatures after normalization:
union select, drop table, or an expression such as ' or 1=1.;, &&, or || followed by cat, curl, wget, nc, or whoami.<script tag, javascript:, or an onerror= or onload= attribute.The validator only needs to recognize the listed signatures. It is not expected to prove that arbitrary input is safe.
def is_suspicious(value):