class PermissiveCORSDetector extends BasicInjectionDetector {

    private static final String PERMISSIVE_CORS = "PERMISSIVE_CORS";
    private static final String HTTP_SERVLET_RESPONSE_CLASS = "javax.servlet.http.HttpServletResponse";
    private static final String HEADER_KEY = "Access-Control-Allow-Origin";

    private static final InvokeMatcherBuilder SERVLET_RESPONSE_ADD_HEADER_METHOD = invokeInstruction()
            .atClass(HTTP_SERVLET_RESPONSE_CLASS).atMethod("addHeader")
            .withArgs("(Ljava/lang/String;Ljava/lang/String;)V");

    private static final InvokeMatcherBuilder SERVLET_RESPONSE_SET_HEADER_METHOD = invokeInstruction()
            .atClass(HTTP_SERVLET_RESPONSE_CLASS).atMethod("setHeader")
            .withArgs("(Ljava/lang/String;Ljava/lang/String;)V");

    public PermissiveCORSDetector(BugReporter bugReporter) {
        super(bugReporter);
    }

    @Override
    protected InjectionPoint getInjectionPoint(InvokeInstruction invoke, ConstantPoolGen cpg,
            InstructionHandle handle) {
        assert invoke != null && cpg != null;

        if (SERVLET_RESPONSE_ADD_HEADER_METHOD.matches(invoke, cpg)) {
            return new InjectionPoint(new int[] { 0 }, PERMISSIVE_CORS);
        }

        if (SERVLET_RESPONSE_SET_HEADER_METHOD.matches(invoke, cpg)) {
            return new InjectionPoint(new int[] { 0 }, PERMISSIVE_CORS);
        }
        return InjectionPoint.NONE;
    }

    @Override
    protected int getPriorityFromTaintFrame(TaintFrame fact, int offset) throws DataflowAnalysisException {<FILL_FUNCTION_BODY>}
}

        // Get the value of the Access-Control-Allow-Origin parameter (Second argument from setHeader(2nd,1rst))
        Taint headerKeyTaint = fact.getStackValue(1);
        if (!(HEADER_KEY.equalsIgnoreCase(headerKeyTaint.getConstantValue()))) { //Ignore unknown/dynamic header name
            return Priorities.IGNORE_PRIORITY;
        }

        Taint headerValueTaint = fact.getStackValue(0);
        if (State.TAINTED.equals(headerValueTaint.getState())) { //If the value is tainted
            return Priorities.HIGH_PRIORITY;
        }
        else if (State.UNKNOWN.equals(headerValueTaint.getState())) {
            return Priorities.NORMAL_PRIORITY;
        }

        String headerValue = headerValueTaint.getConstantOrPotentialValue();
        if (headerValue == null) {
            return Priorities.IGNORE_PRIORITY;
        }
        else if (headerValue.contains("*") || "null".equalsIgnoreCase(headerValue)) {  //If the value is a wildcard
            return Priorities.HIGH_PRIORITY;
        }

        return Priorities.IGNORE_PRIORITY;
    
<methods>public void registerVisitor(com.h3xstream.findsecbugs.taintanalysis.TaintFrameAdditionalVisitor) <variables>static com.h3xstream.findsecbugs.injection.ClassMethodSignature OBJECT,private static final com.h3xstream.findsecbugs.injection.SinksLoader SINKS_LOADER,private final Map<com.h3xstream.findsecbugs.injection.ClassMethodSignature,com.h3xstream.findsecbugs.injection.InjectionPoint> injectionMap