I think that I broadly agree with the proposed interface in theory. If I run into any issues implementing it as described, I will come back here. My only additional suggestion is as-follows.
For some, the value of CBXP isn't just that it can FORMAT control blocks, but that it can EXPLORE control blocks. In a live system, our internal mappings and logic allow us to go from the PSA to a specific ASCB with no real difficulty. The problem is that if an exploiter wants to rely on this exploration capability as written, I don't know that they can. We can format the PSA given a buffer that starts with it, but WE don't have the insight to get the next control block in line (the CVT) if the caller doesn't get it for us. My proposal is that we leverage our "include" feature for this as follows:
def format(control_block: str, cbdata_raw: bytes, includes: list[str]) -> dict:
format("psa",psa_buffer,["cvt"])
{"psa":{...},
"includes":{"cvt": {"pointer":"0x00fd6228","length":1280}}
}
format("ascb",ascb_buffer,["*"])
{"ascb":{...}
"includes":{"assb": {"pointer":"...","length":2496},"oucb":{"pointer":"...","length:X}}
}
format("psa",psa_buffer,["**"])
{"psa":{...},
"cvt": {"pointer":"0x00fd6228","length":1280,"includes":{"ecvt":{},"asvt":{"ascb":{"assb":{},"oucb":{}}}}}
}
This gives cbxp's callers a programmatic way to use the work that cbxp is capable of to fully explore chains of control blocks. This may be difficult to chain together with a JSON schema, but it gives us the complex work, and means the caller only has to know the first control block to help them get where they're going.
Originally posted by @ElijahSwiftIBM in #21