Preprocessing in xgboost cv

In the xgboost cv class, I understand a preprocessing function which accepts the train and test data for each cv fold can be passed to the fpreproc parameter.
My question is how can I define the function such that the fit is done on the training part of the data after which a transform is then done for both train and test data. This is to avoid information leakage during cross-validation as implemented in the Scikit-learn cross_val_score function.

Thanks