adds better exploit module detection to msftidy

Instead of only looking for Msf::Exploit, it now looks to see if the next line has any contents besides whitespace and/or the word 'end'. This removes a false positive on spec/lib/msf/core/modules/loader/archive_spec.rb.  To implement this, a method named is_exploit_module? is implemented which can be adjusted if the current approach proves too simple in the future.  Additionally, some regex usage was made into a constant to reduce repeated regex compilations.  Also, @source.lines was being called repeatedly, so this was made into an internal attribute called @lines and the code was refactored to accommodate so the file contents aren't repeatedly split on line endings, instead just once.  Note @lines is an enumerator, not an Array, so things like .first and .each will work, the latter essentially replacing @source.each_line, however you cannot do stuff like @lines[1..10].  If certain indices are required, simply use each_with_index.

## Verification

- [x] Run tools/msftidy specs/ on master, note the errors and warnings generated
- [x] Run tools/msftidy specs/ on this branch, note that one error should no longer appear.  The error is

```
spec/lib/msf/core/modules/loader/archive_spec.rb - [ERROR] Exploit is missing a disclosure date
```
actually, that’s supposed to be

```
  if line =~ REGEX_MSF_EXPLOIT
```

On Aug 26, 2014, at 4:59 PM, Tod Beardsley <notifications@github.com> wrote:

> In tools/msftidy.rb:
> 
> > @@ -366,8 +349,37 @@ def check_old_rubies
> >      error("Fails alternate Ruby version check") if rubies.size != res.size
> >    end
> >  
> > +  def is_exploit_module?
> > +    ret = false
> > +    if @source =~ REGEX_MSF_EXPLOIT
> > +      # having Msf::Exploit is good indicator, but will false positive on
> > +      # specs and other files containing the string, but not really acting
> > +      # as exploit modules, so here we check the file for some actual contents
> > +      # this could be done in a simpler way, but this let's us add more later
> > +      msf_exploit_line_no = nil
> > +      @lines.each_with_index do |line, idx|
> > +        if line = REGEX_MSF_EXPLOIT
> eek assignment in an if, this makes a lot of people's eyes bleed.
> 
> Not a blocker, but probably a rubocop violation.
> 
> —
> Reply to this email directly or view it on GitHub.
>