lookupCapabilityByName function

String lookupCapabilityByName(
  1. Map table,
  2. String function
)

Resolve a base-function capability by BARE function name alone, ignoring the (attacker-controllable) call-site module. Scans the known base modules in capabilityModuleNames and returns the capability of the single base function named function, or '' when no base function has that name.

Every base function has a globally-unique bare name across the base modules, so at most one module yields a hit and the result is unambiguous. This backstops lookupCapability for ball audit: the engine dispatches a call by base-function identity, not by call.module, so a program can name a base call with a bogus module ({module: "harmless", function: "mutex_create"}) and slip past a (module, function) capability lookup — issue #402. Fails closed: an unrecognized name yields '', so a genuine user call is still treated as a user call.

Implementation

String lookupCapabilityByName(Map table, String function) {
  final modules = capabilityModuleNames();
  for (final m in modules) {
    final cap = lookupCapability(table, m, function);
    if (cap.isNotEmpty) {
      return cap;
    }
  }
  return '';
}