Exemplo n.º 1
0
    def _get_obj_help(self, param, LR_gen_rate):
        my_type = self.interpret_type(
            param["type"]) if "type" in param else "ANY"
        # tluo: Force var convert types
        if random.randint(1, 2) < 2:
            new_name = "%s_%s" % (my_type, random.randint(1, 10))
        else:
            new_name = "shared_%s" % (random.randint(1, 10))
        cur_name = self._get_obj_table(my_type)
        if param['LorR'] == "l":
            new_or_use = util.w_choice(LR_gen_rate["l"])
            if new_or_use == "new" or not cur_name:
                self._add_to_obj_table(my_type, new_name)
                return self.add_random_context(new_name, my_type)
            else:
                self.type_confusion_1(cur_name, my_type)
                return self.add_random_context(cur_name, my_type)

        if param['LorR'] == "r":
            new_or_use = util.w_choice(LR_gen_rate["r"])
            if new_or_use == "reuse":
                if cur_name:
                    return self.add_random_context(cur_name, my_type)
                else:
                    new_or_use = "dyn"
            if new_or_use == "dyn":
                my_runtime = self._get_runtime_obj(my_type)
                if my_runtime:
                    return self.add_random_context(my_runtime, my_type)
            print "[E] No Right Value"
            raise

        print "_get_obj_help:", param, my_type
        print "             :", self.rtn_api_info[my_type]
Exemplo n.º 2
0
    def tag_webgl_api_helper(self, param={}):
        api_key = param["target"] if "target" in param else util.w_choice(
            self.api_weight)
        cur_api_name = self.api[api_key]["api"]
        if "name_only" in param:
            return cur_api_name
        #print cur_api_name, param
        cur_api_args = self.fill_args(api_key, param)
        if "args_only" in param:
            return cur_api_args
        caller = util.w_choice(self.api[api_key]["caller"])
        if "caller" in param and param["caller"]:
            if len(caller) > 0:
                return "%s.%s(%s)" % (caller, cur_api_name, cur_api_args)
            else:
                return "%s(%s)" % (cur_api_name, cur_api_args)

        rtn = self.api[api_key]["rtn"]
        if "full" in param and param["full"]:
            if len(caller) > 0:
                if len(rtn) > 0:
                    return "%s=%s.%s(%s);" % (rtn, caller, cur_api_name,
                                              cur_api_args)
                else:
                    return "%s.%s(%s);" % (caller, cur_api_name, cur_api_args)
            else:
                if len(rtn) > 0:
                    return "%s=%s(%s);" % (rtn, cur_api_name, cur_api_args)
                else:
                    return "%s(%s);" % (cur_api_name, cur_api_args)
Exemplo n.º 3
0
 def select_dom_event_name(self, param={}):
     if "type" not in param:
         return util.w_choice(JS_EVENT.dom_event_name)
     else:
         try:
             return util.w_choice(
                 JS_EVENT.dom_event_type[param["type"]]["name"])
         except:
             print "[!] Type (%s) wrong name!" % (param["type"])
             return ""
Exemplo n.º 4
0
 def init_type_obj(self):
     for init in self.simple_init:
         name = init.keys()[0]
         type = self.default_name[name]
         self._add_to_obj_table(type, name, 5)
         self.init_block.append("try{%s=%s;}catch(err){}" %
                                (name, util.w_choice(init[name])))
Exemplo n.º 5
0
    def tag_js_prop(self, param={}):
        prop_key = param["target"] if "target" in param else util.w_choice(
            self.prop_weight)
        cur_prop_name = self.prop[prop_key]["prop"]
        if "name_only" in param:
            return cur_prop_name

        caller = util.w_choice(self.prop[prop_key]["caller"])
        if "caller" in param and param["caller"]:
            if len(caller) > 0:
                return "%s.%s" % (caller, cur_prop_name)

        rtn = self.prop[prop_key]["rtn"]
        if "full" in param and param["full"]:
            if len(caller) > 0 and len(rtn) > 0:
                return "%s = %s.%s;" % (rtn, caller, cur_api_name)
            return "%s.%s" % (caller, cur_prop_name)
        return "?????????"
Exemplo n.º 6
0
 def select_css_selector(self, param={}):
     return util.w_choice(DOM_Selector.css_selector)
Exemplo n.º 7
0
 def select_dom_selector(self, param={}):
     return util.w_choice(DOM_Selector.dom_selecto)
Exemplo n.º 8
0
 def select_gl_tt_active_texture_target(self, param={}):
   return "g_ctx_gl." + util.w_choice(self.gl_tt_active_texture_target)
Exemplo n.º 9
0
 def select_gl_fb_pixel_data_type(self, param={}):
     return "g_ctx_gl." + util.w_choice(self.gl_fb_pixel_data_type)
Exemplo n.º 10
0
 def select_gl_fb_textarget(self, param={}):
     return "g_ctx_gl." + util.w_choice(self.gl_fb_textarget)
Exemplo n.º 11
0
 def select_Combo_register_window_event(self, param={}):
     events = [
         util.w_choice(JS_EVENT.register_window_event)
         for i in range(random.randint(1, 8))
     ]
     return "|".join(events)
Exemplo n.º 12
0
 def select_XPathResult_Type(self, param={}):
     return util.w_choice(self.XPathResult_Type)
Exemplo n.º 13
0
 def select_ctx_repetition(self, param={}):
     return util.w_choice(self.ctx_repetition)
Exemplo n.º 14
0
 def select_gl_type_enable(param={}):
     return util.w_choice(self.gl_type_enable)
Exemplo n.º 15
0
 def select_tree_walker_whatToShow(self, params= {}):
   events = [util.w_choice(DOM_Walker.tree_walker_whatToShow) for i in range(random.randint(1,len(DOM_Walker.tree_walker_whatToShow)-1))]
   return "|".join(events)
Exemplo n.º 16
0
 def select_gl_db_depth_func(self, param={}):
   return "g_ctx_gl." + util.w_choice(self.gl_db_depth_func)
   
Exemplo n.º 17
0
 def select_position(self, param={}):
   return util.w_choice(self.position)
Exemplo n.º 18
0
 def select_gl_tt_texture_type(self, param={}):
   return "g_ctx_gl." + util.w_choice(self.gl_tt_texture_type)
Exemplo n.º 19
0
 def select_gl_bf_usage(self, param={}):
     return "g_ctx_gl." + util.w_choice(self.gl_bf_usage)
Exemplo n.º 20
0
 def select_ctx_fillRule(self, param={}):
     return util.w_choice(self.ctx_fillRule)
Exemplo n.º 21
0
 def select_gl_st_fail(self, param={}):
   return "g_ctx_gl." + util.w_choice(self.gl_st_fail)
Exemplo n.º 22
0
 def select_from_grp(self, grp):
     if grp in self.grp_info:
         return util.w_choice(self.grp_info[grp])
     else:
         return grp
Exemplo n.º 23
0
 def select_1_register_window_event(self, param={}):
     return util.w_choice(JS_EVENT.register_window_event)
Exemplo n.º 24
0
 def select_gl_rb_internalFormat(self, param={}):
   return "g_ctx_gl." + util.w_choice(self.gl_rb_internalFormat)
Exemplo n.º 25
0
 def select_gl_fb_attachment(self, param={}):
     return "g_ctx_gl." + util.w_choice(self.gl_fb_attachment)
Exemplo n.º 26
0
 def select_gl_bl_factor(self, param={}):
   return "g_ctx_gl." + util.w_choice(self.gl_bl_factor)
Exemplo n.º 27
0
 def select_gl_fb_pixel_format(self, param={}):
     return "g_ctx_gl." + util.w_choice(self.gl_fb_pixel_format)
Exemplo n.º 28
0
 def _get_obj_table(self, cls, name=None):
     if cls not in self.obj_table:
         return None
     return util.w_choice(self.obj_table[cls])
Exemplo n.º 29
0
 def gao_range(self, myRange=None):
     myRange = "$$[JSRandObj??LorR==rvalue&&type==Range]" if not myRange else myRange
     return util.w_choice(self.range_gao_range) % (myRange)
Exemplo n.º 30
0
 def select_gl_bl_equation(self, param={}):
   return "g_ctx_gl." + util.w_choice(self.gl_bl_equation)