entity type, * category, the argument naming the target, and the argument that makes * the call destructive (`force` on a delete, a note to the customer). * * Only tools whose arguments carry WooCommerce's REST field names are * listed - `regular_price`, `amount`, `status` - so the add-on's facts read * them as they read a REST request. A listed tool given `meta` or * `meta_data` writes meta the facts cannot see: it is left unclassified, * so it is held. */ final class ToolMap { /** * A tool the adapter lists as a read: typed, so the firewall's guard * for administrator-run agents leaves it to the rules (AF-25.15), and * the add-on's defaults hold only writes. Lists hold store and content * reads only; reads that can expose secrets - settings, gateways, * options, meta, users, files, logs - are left unlisted, so an * administrator-run agent's call waits for a person. * * @param list $reads The adapter's read tools. * @param string $tool Tool name. */ public static function read( array $reads, string $tool ): ?Classification { return in_array( $tool, $reads, true ) ? new Classification( ToolClassifier::ENTITY, 'read' ) : null; } /** * Classify a call from a table. * * @param array $table Tool => [type, category, target argument, destructive argument]. * @param string $tool Tool name. * @param array $arguments Arguments. */ public static function classify( array $table, string $tool, array $arguments ): ?Classification { $row = $table[ $tool ] ?? null; if ( null === $row || array_key_exists( 'meta', $arguments ) || array_key_exists( 'meta_data', $arguments ) ) { return null; } $target = isset( $row[2] ) && is_numeric( $arguments[ $row[2] ] ?? null ) ? (int) $arguments[ $row[2] ] : null; $destructive = isset( $row[3] ) && WcRouteClassifier::truthy( $arguments[ $row[3] ] ?? null ) ? true : null; return new Classification( $row[0], $row[1], null !== $target && $target > 0 ? $target : null, $destructive ); } }