'''
mutant.py

Copyright 2006 Andres Riancho

This file is part of w3af, w3af.sourceforge.net .

w3af 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 version 2 of the License.

w3af 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 w3af; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

'''

class mutant:
	'''
	This class is a wrapper for fuzzable requests that have been modified.
	'''
	def __init__( self, freq ):
		self._freq = freq
		self._fuzzableType = None
		self._var = ''
	
	''' this methods are from the mutant '''
	def getFuzzableReq( self ): return self._freq
	def setFuzzableReq( self, freq ): self._freq = freq

	def setVar( self, var): self._var = var
	def getVar( self ): return self._var
	
	def setModValue( self, mutantStr ):
		self._freq.getFuzzable()[ self._fuzzableType ][ self._var ] = mutantStr
	
	def getModValue( self ): 
		return self._freq.getFuzzable()[ self._fuzzableType ][ self._var ]
	
	def printModValue( self ):
		if self._fuzzableType == 'headers':
			return 'The sent header is: ' + str( self._freq.getFuzzable()[ self._fuzzableType ] ) + ' .'
		else:
			return 'The sent data is: ' + str( self.getDc() ) + ' .'
	
	''' this methods are forwarded to the fuzzed request '''
	def setDc( self, dataContainer ): return self._freq.setDc( dataContainer )
	def getDc( self ): return self._freq.getDc()

	def getMethod( self ):	return self._freq.getMethod()
	def setMethod( self, m ):	return self._freq.setMethod( m )
	
	def getURL( self ): return self._freq.getURL()
	def setURL( self, u ): return self._freq.setURL( u )
	
	def getURI( self ): return self._freq.getURI()
	def setURI( self, u ): return self._freq.setURI( u )
	
	def getHeaders( self ): return self._freq.getHeaders()
	def setHeaders( self, h ): return self._freq.setHeaders( h )
	
	def getCookie( self ): return self._freq.getCookie()
	def setCookie( self, c ): return self._freq.setCookie( c )
	
	def getFuzzable( self ): return self._freq.getFuzzable()
	def setFuzzable( self , type, value): 
		self._fuzzableType = type
		return self._freq.setFuzzable( type, value )
	
	def getData( self ): return self._freq.getData()
	def getFileVariables( self ): return self._freq.getFileVariables()
