Regarding the difficulty of generating a collision with working code, wouldn't it be as "trivial" as generating a SHA-1 collision in the first place?
Just have the malicious code in a file and append a multiline comment block, then have your collision generator insert random junk into that comment block