Exemplo n.º 1
0
    def validate( self , param ):
        """
        @return: True if the value is valid, False otherwise
        """
        value = param.getValue()
        if param.isout():
            if value is not None : #not possible for the user to modify an isout parameter 
                return False
            else:               
                #####################################################
                #                                                   #
                #  check if the Parameter have a secure filenames   #
                #                                                   #
                #####################################################
                
                try:
                    debug = param.getDebug()
                    if debug > 1:
                        b_log.debug( "check if the Parameter have a secure filename" )
    
                    #getFilenames returns a list of unix file mask, result of a code evaluation
                    #None is returned if there is no mask for a parameter.
                    masks = param.getFilenames( ) 
                    for mask in masks :
                        if mask is None:
                            continue
                        mySafeMask = safeMask( mask )
                        if debug > 1:
                            b_log.debug( "filename= %s    safeMask = %s" % (mask, mySafeMask))
                        if  not mySafeMask or mySafeMask != mask :
                            raise MobyleError , "have an unsecure filenames value before safeMask: %s , after safeMask: %s" % (mask, mySafeMask)
                        elif debug > 1:
                            b_log.debug( "filename = %s ...........OK" % mask )
                                               
                except UnDefAttrError :
                    b_log.debug("no filenames")

        else:
            if value is None:
                return True
            else:
                return True            
Exemplo n.º 2
0
    def validate( self , param ):
        """
        """
        value = param.getValue()

        if param.isout():
            if value is not None : #un parametre isout ne doit pas etre modifier par l'utilisateur 
                return False
            else:
                #####################################################
                #                                                   #
                #  check if the Parameter have a secure filenames   #
                #                                                   #
                #####################################################
                try:
                    debug = param.getDebug()
                    if debug > 1:
                        b_log.debug( "check if the Parameter have a secure filename" )
    
                    #getFilenames return list of strings representing a unix file mask which is the result of a code evaluation
                    #getFilenames return None if there is no mask for a parameter.
                    filenames = param.getFilenames( ) 
                    for filename in filenames :
                        if filename is None:
                            continue
                        mask = safeMask( filename )
                        if debug > 1:
                            b_log.debug( "filename= %s    safeMask = %s"%(filename, mask))
                        if  not mask or mask != filename :
                            raise MobyleError , "have an unsecure filenames value before safeMask: %s , after safeMask: %s"%( filename , mask )
                        else:
                            if debug > 1:
                                b_log.debug( "filename = %s ...........OK" % filename )
                                               
                except UnDefAttrError :
                    b_log.debug("no filenames")
        else:#the param is an inFile
            if value is None:
                return True
            else:
                return True