Section 54. If, in an action against a corporation, it appears to the court that one of the objects of the action is to obtain a judgment against the corporation in order to enforce an alleged liability of a person who has been or is a stockholder or officer thereof, any such person may be permitted, on petition, to defend such action, and in such case the court may require of him or of a person in his behalf, a bond with sufficient surety or sureties, conditioned to pay to the plaintiff all costs which may accrue and be taxed to him after the filing of said petition.