Package dk.brics.automaton

Examples of dk.brics.automaton.Automaton


     *            as the {@link WebApp} to analyze
     * @return the {@link Automaton} representing the {@link URLPattern} of the
     *         {@link WebApp}
     */
    private Automaton getURLPatternAutomaton(Class<? extends WebApp> webAppClass) {
        Automaton automaton = urlPatternAutomatons.get(webAppClass);
        if (automaton == null) {
            automaton = constructURLPatternAutomaton(webAppClass);
            urlPatternAutomatons.put(webAppClass, automaton);
        }
        return automaton;
View Full Code Here


     *            as the WebMethod to analyze
     * @return the {@link Automaton} representing the {@link URLPattern} of the
     *         WebMethod
     */
    private Automaton getURLPatternAutomaton(Method method) {
        Automaton automaton = urlPatternAutomatons.get(method);
        if (automaton == null) {
            automaton = constructURLPatternAutomaton(method);
            urlPatternAutomatons.put(method, automaton);
        }
        return automaton;
View Full Code Here

     *            as the WebMethod to extract an URL from.
     * @return the corresponding {@link FilterGroup}
     */
    public FilterGroup getFilterGroup(Method webMethod) {
        Set<Method> urlPatternMatches = new HashSet<Method>();
        @SuppressWarnings("unchecked")
        Automaton prefixedURLPattern = concatenateWithSlash(
                getURLPatternAutomaton((Class<? extends WebApp>) webMethod
                        .getDeclaringClass()),
                getURLPatternAutomaton(webMethod));
        // for each webmethod in the webapps, check if it could be hit by the
        // possible url patterns
        for (Entry<Class<? extends WebApp>, RequestManager> entry : managers
                .entrySet()) {
            for (RegisteredMethod registeredMethod : entry.getValue()
                    .getWebMethods()) {
                final Method possibleTargetedMethod = registeredMethod
                        .getMethod();
                if (!webMethod.equals(possibleTargetedMethod)) {
                    Automaton prefixedPossibleTarget = concatenateWithSlash(
                            getURLPatternAutomaton(entry.getKey()),
                            getURLPatternAutomaton(possibleTargetedMethod));
                    final boolean intersects = !prefixedURLPattern
                            .intersection(prefixedPossibleTarget).isEmpty();
                    if (intersects)
View Full Code Here

        Integer index = MakeURLSignatureHandler.getMakeURLSignatures().get(
                expr.getMethod().getSignature());
        index = index == null ? -1 : index;

        ValueBox valueBox = expr.getArgBox(index);
        Automaton possibleValues;
        try {
            possibleValues = analysis.getAutomaton(valueBox);
        } catch (IllegalArgumentException e) {
            log.error(e.getMessage() + " \"" + expr.toString() + "\"");
            possibleValues = Automaton.makeEmpty();
View Full Code Here

     *            as the expression containing {@link XML#plug(String, Object)}
     * @return the automaton representing the possible names
     */
    public Automaton getPossibleGapNameValuesofXMLPlug(InvokeExpr expr) {
        ValueBox valueBox = expr.getArgBox(0);
        Automaton possibleValues = analysis.getAutomaton(valueBox);

        String methodNames = getReadableLanguage(possibleValues);
        SootMethod plug = expr.getMethod();

        log.debug(plug.getName() + " called from " + expr.getMethod().getName()
View Full Code Here

    private void linkMakeURL(StateMachine stateMachine, InvokeExpr expr,
            MyStringAnalysis analysis, Interface interfacee) {

        SootMethod makeURLMethod = expr.getMethod();

        Automaton possibleValues = analysis
                .getPossibleNameValuesOfMakeURLInvocation(expr);

        MethodStatementContainer container = stateMachine
                .getMakeURLLocation(expr);
        SootMethod enclosingMethod = container.getMethod();
View Full Code Here

                    makeURLstatement, targetedWebApp,
                    possibleWebMethodNamesAutomaton));
        } else {
            // check if the makeURL can hit more names than we have available: a
            // possible error
            Automaton possibleMethodNames = findMatcher(webMethodsByName);
            Automaton slack = possibleWebMethodNamesAutomaton
                    .minus(possibleMethodNames);
            final boolean hasSlack = !slack.isEmpty();
            if (hasSlack) {
                Feedbacks.add(new MayHitMoreUnexistingWebMethods(
                        makeURLEnclosingMethod, makeURLstatement, slack));
            }
        }
View Full Code Here

     * webmethods
     *
     * @return the constructed {@link Automaton}
     */
    private Automaton findMatcher(Collection<Method> methods) {
        Automaton a = Automaton.makeEmpty();
        for (Method m : methods) {
            String name = m.getName();
            a = a.union(Automaton.makeString(name));
        }
        a.determinize();
        a.minimize();
        return a;
    }
View Full Code Here

  /**
   * Builds the transition table data.
   */
  public void build() {
    RegExp regexp = new RegExp(this.expression);
    Automaton automata = regexp.toAutomaton(true);
    numOfStates = automata.getNumberOfStates();
    //System.out.println("Number of states " + numOfStates);
   
    State[] states = new State[numOfStates];
    automata.getStates().toArray(states);
   
    //Get Accepting states and starting state
    this.startingState = indexOf(automata.getInitialState(), states);
    this.buildAcceptingStates(states);
   
    //initialize the transition table
    this.transitionTable = new int[this.alphabetSize][numOfStates][numOfStates];
   
View Full Code Here

TOP

Related Classes of dk.brics.automaton.Automaton

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.