代码之家  ›  专栏  ›  技术社区  ›  Prince Ashitaka

Boofuzz基于组值创建嵌套块

  •  1
  • Prince Ashitaka  · 技术社区  · 6 年前

    我有两个错误, 1) BLOCK NAME ALREADY EXISTS: 1,

    2) 我想使用s\u块中的值来依赖于在s\u组中选择的值。

    我用的代码是下图:-

    s_initialize(name="LOGIN-RQ")
    
    with s_block("LOGIN"):
        s_group("Priority", ["1","2","3"])
    
        if(s_block_start("1", dep="Priority", dep_value="1", dep_compare="==")):
            # handle '1' - for A priority
            s_static("A")
            s_group("Type", ["1","2"])
    
            # handle '11 - for A priority Emergency'
            if(s_block_start("1", dep="Type", dep_value="1", dep_compare="==")):
                s_static("Emergency")
                s_static("#")
                s_string("1ab121-2345-2212-123ad21") # auth id
                s_static("#")
                s_static("Registered")
            s_block_end()
    
            if(s_block_start("2", dep_value="2", dep_compare="==")):
                s_static("Frequent")
            s_block_end()
        s_block_end()
    
        if(s_block_start("2", dep="Priority", dep_value="2", dep_compare="==")):
            s_static("B")
        s_block_end()
    
        if(s_block_start("3")):
            s_static("C")
            s_group("Category", ["1","2"])
    
            if(s_block_start("1", dep="Category", dep_value="1", dep_compare="==")):
                s_static("Anonymous")
                # handle anonymous category
            s_block_end()
    
            if(s_block_start("2", dep="Category", dep_value="2", dep_compare="==")):
                s_static("Registered")
            s_block_end()
        s_block_end()
    
    session.connect(session.root, s_get("LOGIN-RQ"))
    session.fuzz()
    

    预期可能结果:-

    1A1Emergency#1ab121-2345-2212-123ad21#Registered
    1A2Frequent
    2B
    3C1Anonymous
    3C2Registered
    

    请帮忙

    1 回复  |  直到 6 年前
        1
  •  1
  •   Prince Ashitaka    6 年前

    耶!

    终于找到了。

    我必须更新块名并为这些块提供组名,然后一切都开始工作。此代码涵盖所有预期的可能场景。

    在这里张贴工作代码,希望这将有帮助

    s_initialize(name="LOGIN-RQ")
    with s_block("LOGIN"):
        s_group("Priority", ["1","2","3"])
    
        if(s_block_start("Priority1", group="Priority", dep="Priority", dep_value="1", dep_compare="==")):
            # handle '1' - for A priority
            #res = s_get_name_value('1')
            s_static("A")
            s_group("Type", ["1","2"])
            if s_block_start("Type1", group="Type", dep="Type", dep_value="1", dep_compare="==") :
                    s_static("Emergency")
                    s_static("#")
                    s_static("1ab121-2345-2212-123ad21") # auth id
                    s_static("#")
                    s_static("Registered")
            s_block_end("1")
    
            if(s_block_start("Type2", group="Type", dep="Type", dep_value="2", dep_compare="==")):
                s_static("Frequent")
            s_block_end()
        s_block_end()
    
        if(s_block_start("Priority2", group="Priority", dep="Priority", dep_value="2", dep_compare="==")):
            s_static("B")
        s_block_end()
    
        if(s_block_start("Priority3", group="Priority", dep="Priority", dep_value="3", dep_compare="==")):
            s_static("C")
            s_group("Category", ["1","2"])
    
            if(s_block_start("Category1", group="Category", dep="Category", dep_value="1", dep_compare="==")):
                s_static("Anonymous")
                # handle anonymous category
            s_block_end()
    
            if(s_block_start("Category2", group="Category", dep="Category", dep_value="2", dep_compare="==")):
                s_static("Registered")
            s_block_end()
        s_block_end()
    
        if(s_block_start("Priority6", group="Priority", dep="Priority", dep_value="6", dep_compare="==")):
            s_static("NEVER")
        s_block_end()
    
    session.connect(session.root, s_get("LOGIN-RQ"))
    session.fuzz()
    
    推荐文章