Example #1
0
    def _createArgCheckDescriptions(self, model):

        argChecks = []  # one element per argument
        retval = []

        # Note: we subtract 1 here so that we don't output
        # the cluster that is unbound to any of the args.
        nArgs = model.getNumberOfArguments() - 1

        if (model.topCheckHists == [[]]):
            l = []
            for i in range(nArgs):
                l.append('')
            return l

        for i in range(nArgs):

            # for i in range(len(model.topCheckHists) - 1):
            # for i in range(len(model.topCheckHists)):

            try:
                topCheckHist = model.topCheckHists[i]
            except IndexError:
                return []

            argChecks.append([])

            for (clusterId, nOcc) in topCheckHist:

                condCode = [
                    model.conditionsCode[model.nodeIdToConditionIndex[y]] for y
                    in model.conditionClusters.clusterIdToDatapoint[clusterId]
                ]

                argChecks[-1].append(condCode)

            checksForArg = uniqListOfLists(argChecks[-1])

            if checksForArg == []:
                retval.append('')
                continue

            conditionStrs = []
            for conditionCluster in checksForArg:
                cndRegex = self._conditionsToRegex(conditionCluster)

                cndRegex = '"%s"' % (cndRegex)
                conditionStrs.append(
                    self.escapeIt(
                        '\n it.code.matches(String.format(%s, Pattern.quote(s)))'
                        % cndRegex))

            retval.append('arg%dSanitizer = { it, s -> ' % (i) +
                          "||".join(conditionStrs) + '\n};\n')

        return retval
    def _createArgCheckDescriptions(self, model):
        
        argChecks = [] # one element per argument
        retval = []
        
        # Note: we subtract 1 here so that we don't output
        # the cluster that is unbound to any of the args.
        nArgs = model.getNumberOfArguments() -1

        
        if(model.topCheckHists == [[]]):
            l = []
            for i in range(nArgs):
                l.append('')
            return l
        
        for i in range(nArgs):
        
        # for i in range(len(model.topCheckHists) - 1):    
        # for i in range(len(model.topCheckHists)):
            
            try:
                topCheckHist = model.topCheckHists[i]
            except IndexError:
                return []

            argChecks.append([])
            
            for (clusterId,nOcc) in topCheckHist:
                
                condCode = [model.conditionsCode[model.nodeIdToConditionIndex[y]]
                            for y in model.conditionClusters.clusterIdToDatapoint[clusterId]]
                                
                argChecks[-1].append(condCode)


            checksForArg = uniqListOfLists(argChecks[-1])
            
            if checksForArg == []:
                retval.append('')
                continue
            
            conditionStrs = []
            for conditionCluster in checksForArg:
                cndRegex = self._conditionsToRegex(conditionCluster)

                cndRegex = '"%s"' % (cndRegex)
                conditionStrs.append(self.escapeIt('\n it.code.matches(String.format(%s, Pattern.quote(s)))' % cndRegex))
                
            retval.append('arg%dSanitizer = { it, s -> ' % (i) +   "||".join(conditionStrs) + '\n};\n')
        
        return retval
Example #3
0
 def checkToSink(self, checkId):
     retval = self.contentProvider.getControlledSinks(checkId)
     return uniqListOfLists(retval)