github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/transform/staticlark/testdata/control_funcs.star (about)

     1  def get_secret():
     2    return 3
     3  
     4  def get_public():
     5    return 4
     6  
     7  def modify(v):
     8    return v * 2
     9  
    10  def dangerous(s, t):
    11    print('Leak %d' % s)
    12  
    13  def something(a, b, c):
    14    s = a + 1
    15    t = b + 2
    16    m = 0
    17    if c < 10:
    18      # c influences control flow, therefore
    19      # it is considered sensitive
    20      m = a + 3
    21    else:
    22      # TODO: validate that `m` is derived from `a`
    23      # using linear analysis (incorrectly) would have the `else`
    24      # branch override the `then` branch. Rather, the two branches
    25      # need to be unioned
    26      m = b + 4
    27    dangerous(m, t)
    28  
    29  def top():
    30    x = get_public()
    31    y = modify(get_public())
    32    z = get_secret()
    33    something(x, y, z)
    34  
    35  top()