Using random values to define behavior

43 views
Skip to first unread message

Michael Stahl

unread,
Jul 7, 2021, 12:07:13 PM7/7/21
to GraphWalker
Hi - 
Is there any way to define a variable (via "actions" or any other way) to get a random value? 

Here is what I deal with:
- I have code that builds a binary file (a blob of bytes)
- The maximum size of the binary file is limited
- The content of the binary file is comprised of building blocks. 

For example: Say I have three building blocks: A, B, C
Sizeof(A) = 50
Sizeof(B) = 20
Sizeof(C) can be anywhere between 1 and 30

Max file size: 100

So the file can contain: 
AA
 
or BBBBB

or ABB

etc.

Of course it can also contain C, but then I need to have the size of C to know what else can go into the file. For example, if sizeof(C) = 30 then the file can contain (for example):

AC
CBC
ABC
CCC

But if size(C) = 10, then I can also have 

CCCCAC
BCBA

etc.

My goal is to use AltWalker to create many cases of the file content, so I can test the parser for this file. 

I do this by defining a model that goes through edges that "AddA", "AddB", "AddC".  I control the loop of generation by looking at the number of bytes left after each addition of a component. So for example in "AddA" I have a guard: leftover > 49. 

The problem is that in order to cover many cases of C's size, I need a way to randomly set the size of C to different values between 1-30.

 Any ideas? 

Thanks,
Michael 




Michael Stahl

unread,
Jul 9, 2021, 8:23:32 AM7/9/21
to GraphWalker
Robert Dezmerean provided a solution that works with AltWalker. 

See: 



Michael
Reply all
Reply to author
Forward
0 new messages