def mk_rank(rank, default_rank, level):
    """Create a rank from a result rank, a default rank, and a level

    level can be one of: "pass", "warning", "error", "open", "notApplicable", or "note".
    These don't correspond very well to traditional scoring, but they're all we've got.

    Note that the Sarif "rank" is a float in the range 0.0..100.0, where larger
    values mean higher severity, whereas the CodeSonar notion of rank is the opposite.
    Also, the CodeSonar rank is heavily skewed. For example:
      base_rank  score
       0.0        73
       0.1        73
       0.5        72
       1.0        71
       2.0        69
       4.0        65
       8.0        55
      16.0        35
      32.0        10
      50.0         2
      80.0         0
    Consequently we must transform the Sarif rank to get the CodeSonar base rank.
    Note that we need to truncate the precision of this number, otherwise we risk
    returning different values on different platforms. Two digits after the
    decimal should be adequate.
    """
    def sarif_rank_to_cso_rank(rank):
        r = (100.0-rank)/100.0
        return (100.0*r*r*r)
    if rank is not None:
        return sarif_rank_to_cso_rank(rank)
    if default_rank is not None:
        return sarif_rank_to_cso_rank(default_rank)
    ldict = {None: 10.0, 'note': 16.0, 'warning': 8.0, 'error': 1.0}
    return ldict.get(level, 32.0)