/*
 * Copyright 2017-2018 Baidu Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.baidu.openrasp.hook.server.websphere;

import com.baidu.openrasp.hook.server.ServerRequestHook;
import com.baidu.openrasp.tool.annotation.HookAnnotation;
import javassist.CannotCompileException;
import javassist.CtClass;
import javassist.NotFoundException;

import java.io.IOException;

/**
 * @Description: websphere请求hook点
 * @author anyang
 * @date 2018/8/13 15:13
 */
@HookAnnotation
public class WebsphereRequestHook extends ServerRequestHook {

    @Override
    public boolean isClassMatched(String className) {
        return "com/ibm/ws/webcontainer/servlet/ServletWrapper".equals(className);
    }

    @Override
    protected void hookMethod(CtClass ctClass) throws IOException, CannotCompileException, NotFoundException {
        String hookDesc = "(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V";
        String src = getInvokeStaticSrc(ServerRequestHook.class, "checkRequest",
                "$0,$1,$2", Object.class, Object.class, Object.class);
        insertBefore(ctClass, "handleRequest", hookDesc, src);
    }
}

@@ -1168,28 +1168,32 @@
 ner/
-servlet/ServletWrapp
+filter/WebAppFilterManag
 er%22.
@@ -1347,102 +1347,8 @@
 n %7B%0A
-        String hookDesc = %22(Ljavax/servlet/ServletRequest;Ljavax/servlet/ServletResponse;)V%22;%0A
     
@@ -1530,32 +1530,28 @@
 s, %22
-handleRequest%22, hookDesc
+invokeFilters%22, null
 , sr

modify websphere deploy war