package net.websoup.wormscan; /* * This file is part of WormScan. * * WormScan is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import org.apache.oro.text.regex.Perl5Compiler; import org.apache.oro.text.regex.Pattern; import org.apache.oro.text.regex.MalformedPatternException; /** * Everything we know about a worm * Copyright: Copyright (c) 2001-2004 Andriy Rozeluk * @author Andriy Rozeluk * @version 1.6.1 */ public class Worm { private static Perl5Compiler p5; /** * The worm's full name */ private String name; /** * The worm's abbreviated name */ private String shortName; /** * Regular expression pattern string to find this worm */ private String patternString; /** * Compiled regular expression to find this worm */ private Pattern pattern; /** * Colour to use when displaying worm in output reports */ private String colour; /** * A tally of attacks this worm caused */ private int numAttacks = 0; static { p5 = new Perl5Compiler(); } public int getNumAttacks(){ return numAttacks; } public void resetNumAttacks(){ numAttacks = 0; } public void addAttack(){ numAttacks++; } public String getName(){ return name; } public void setName( String in ){ name = in; } public String getShortName(){ if ( shortName == null ) return name; return shortName; } public void setShortName( String in ){ shortName = in; } public String getPatternString(){ return patternString; } public void setPatternString( String in, boolean caseSensitive ) throws MalformedPatternException { patternString = in; if ( caseSensitive ){ pattern = p5.compile( patternString ); } else { pattern = p5.compile( patternString, p5.CASE_INSENSITIVE_MASK ); } } public Pattern getPattern(){ return pattern; } public String getColour(){ return colour; } public void setColour( String in ){ colour = in; } }