overrides the visitor to look for suspicious operations on toString
176450
@Override
    public void sawOpcode(int seen) {
        String methodPackage = null;
        try {
            stack.precomputation(this);

            if (seen == Const.INVOKEVIRTUAL) {
                methodPackage = processInvokeVirtual();

            } else if (OpcodeUtils.isAStore(seen)) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item item = stack.getStackItem(0);
                    Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen));
                    if (item.getUserValue() != null) {
                        XMethod xm = item.getReturnValueOf();
                        if (xm != null) {
                            toStringRegisters.put(reg, xm.getPackageName());
                        } else {
                            toStringRegisters.remove(reg);
                        }
                    } else {
                        toStringRegisters.remove(reg);
                    }
                }
            } else if (OpcodeUtils.isALoad(seen)) {
                Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen));
                methodPackage = toStringRegisters.get(reg);
            }
        } catch (ClassNotFoundException cnfe) {
            bugReporter.reportMissingClass(cnfe);
        } finally {
            TernaryPatcher.pre(stack, seen);
            stack.sawOpcode(this, seen);
            TernaryPatcher.post(stack, seen);
            if ((methodPackage != null) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item item = stack.getStackItem(0);
                item.setUserValue(methodPackage);
            }
        }
    }
1149488
def visit_and_update(self, visitor_fn):
        """"""
        new_inner = self.inner_expression.visit_and_update(visitor_fn)

        if new_inner is not self.inner_expression:
            return visitor_fn(UnaryTransformation(self.operator, new_inner))
        else:
            return visitor_fn(self)
971184
@Trivial
    private boolean isStringValueUndefined(Object str) {
        if (str instanceof SerializableProtectedString) {
            // Avoid constructing a String from a ProtectedString
            char[] contents = ((SerializableProtectedString) str).getChars();
            for (char ch : contents)
                if (ch > '\u0020')
                    return false; // See the description of String.trim()
            return true;
        } else {
            return (str == null || ((String) str).trim().isEmpty());
        }

    }
1177668
private Node tryFoldStringIndexOf(
      Node n, String functionName, Node lstringNode, Node firstArg) {
    checkArgument(n.isCall());
    checkArgument(lstringNode.isString());

    String lstring = NodeUtil.getStringValue(lstringNode);
    boolean isIndexOf = functionName.equals("indexOf");
    Node secondArg = firstArg.getNext();
    String searchValue = NodeUtil.getStringValue(firstArg);
    // searchValue must be a valid string.
    if (searchValue == null) {
      return n;
    }
    int fromIndex = isIndexOf ? 0 : lstring.length();
    if (secondArg != null) {
      // Third-argument and non-numeric second arg are problematic. Discard.
      if (secondArg.getNext() != null || !secondArg.isNumber()) {
        return n;
      } else {
        fromIndex = (int) secondArg.getDouble();
      }
    }
    int indexVal = isIndexOf ? lstring.indexOf(searchValue, fromIndex)
                             : lstring.lastIndexOf(searchValue, fromIndex);
    Node newNode = IR.number(indexVal);
    n.replaceWith(newNode);
    reportChangeToEnclosingScope(newNode);

    return newNode;
  }
822089
def to_s
      str = ''
      if @scheme
        str << @scheme
        str << ':'
      end

      if @opaque
        str << @opaque

      else
        if @registry
          str << @registry
        else
          if @host
            str << '//'
          end
          if self.userinfo
            str << self.userinfo
            str << '@'
          end
          if @host
            str << @host
          end
          if @port && @port != self.default_port
            str << ':'
            str << @port.to_s
          end
        end

        str << path_query
      end

      if @fragment
        str << '#'
        str << @fragment
      end

      str
    end
166928
function inspect (s) {
  return s
    .replace(/\\/g, '\\\\')
    .replace(/\n/g, '\\n')
    .replace(/\t/g, '\\t')
    .replace(/"/g, '\\"')
    .replace(/\r/g, '\\r')
}
336903
private void verifyOperation(UpdateOperation operation) {
        if (this.operation == null) {
            this.operation = operation;
        } else if (this.operation != operation) {
            throw new JeppettoException("Can't switch operation type to '" + operation + "'.  '"
                                        + this.operation + "' is already in use.");
        }
    }
746675
boolean scanOperator() {
		if (state != 100) {
			return false;
		}
		
		Tok tok;
		switch (peek()) {
		case '+':		// + - * / % ++ --
			if (next() == '+') {
				tok = new Tok(Sym.INC, beginRow);
				next();
			} else {
				tok = new Tok(Sym.ADD, beginRow);
			}
			return ok(tok);
		case '-':
			if (next() == '-') {
				tok = new Tok(Sym.DEC, beginRow);
				next();
			} else {
				tok = new Tok(Sym.SUB, beginRow);
			}
			return ok(tok);
		case '*':
			tok = new Tok(Sym.MUL, beginRow);
			next();
			return ok(tok);
		case '/':
			tok = new Tok(Sym.DIV, beginRow);
			next();
			return ok(tok);
		case '%':
			tok = new Tok(Sym.MOD, beginRow);
			next();
			return ok(tok);
		case '=':		// = == != < <= > >=
			if (next() == '=') {
				tok = new Tok(Sym.EQUAL, beginRow);
				next();
			} else {
				tok = new Tok(Sym.ASSIGN, beginRow);
			}
			return ok(tok);
		case '!':
			if (next() == '=') {
				tok = new Tok(Sym.NOTEQUAL, beginRow);
				next();
			} else {
				tok = new Tok(Sym.NOT, beginRow);
			}
			return ok(tok);
		case '<':
			if (next() == '=') {
				tok = new Tok(Sym.LE, beginRow);
				next();
			} else {
				tok = new Tok(Sym.LT, beginRow);
			}
			return ok(tok);
		case '>':
			if (next() == '=') {
				tok = new Tok(Sym.GE, beginRow);
				next();
			} else {
				tok = new Tok(Sym.GT, beginRow);
			}
			return ok(tok);
		case '&':		// ! && ||
			if (next() == '&') {
				tok = new Tok(Sym.AND, beginRow);
				next();
			} else {
				throw new ParseException("Unsupported operator: '&'", location);
			}
			return ok(tok);
		case '|':
			if (next() == '|') {
				tok = new Tok(Sym.OR, beginRow);
				next();
			} else {
				throw new ParseException("Unsupported operator: '|'", location);
			}
			return ok(tok);
		case '?':		// ? ??
			if (next() == '?') {
				tok = new Tok(Sym.NULL_SAFE, beginRow);
				next();
			} else {
				tok = new Tok(Sym.QUESTION, beginRow);
			}
			return ok(tok);
		case '.':		// . .. : :: , ;
			if (next() == '.') {
				tok = new Tok(Sym.RANGE, beginRow);
				next();
			} else {
				tok = new Tok(Sym.DOT, ".", beginRow);
			}
			return ok(tok);
		case ':':
			if (next() == ':') {
				tok = new Tok(Sym.STATIC, beginRow);
				next();
			} else {
				tok = new Tok(Sym.COLON, beginRow);
			}
			return ok(tok);
		case ',':
			tok = new Tok(Sym.COMMA, beginRow);
			next();
			return ok(tok);
		case ';':
			tok = new Tok(Sym.SEMICOLON, beginRow);
			next();
			return ok(tok);
		case '(':		// ( ) [ ] { }
			tok = new Tok(Sym.LPAREN, beginRow);
			next();
			return ok(tok);
		case ')':
			tok = new Tok(Sym.RPAREN, beginRow);
			next();
			return ok(tok);
		case '[':
			tok = new Tok(Sym.LBRACK, beginRow);
			next();
			return ok(tok);
		case ']':
			tok = new Tok(Sym.RBRACK, beginRow);
			next();
			return ok(tok);
		case '{':
			tok = new Tok(Sym.LBRACE, beginRow);
			next();
			return ok(tok);
		case '}':
			tok = new Tok(Sym.RBRACE, beginRow);
			next();
			return ok(tok);
		default :
			return fail();
		}
	}
396283
function isString(value, message, id) {
    if (message === void 0) { message = ''; }
    if (id === void 0) { id = ''; }
    if (this.enabled && !(typeof value === 'string' || value instanceof String)) {
        throw TypeException.unexpectedType(assertionTypes.IS_STRING, value, '<string>', message, id);
    }
}
612760
def _make_c_string_check(string):
    """"""
    if isinstance(string, bytes):
        if b"\x00" in string:
            raise InvalidDocument("BSON keys / regex patterns must not "
                                  "contain a NUL character")
        try:
            _utf_8_decode(string, None, True)
            return string + b"\x00"
        except UnicodeError:
            raise InvalidStringData("strings in documents must be valid "
                                    "UTF-8: %r" % string)
    else:
        if "\x00" in string:
            raise InvalidDocument("BSON keys / regex patterns must not "
                                  "contain a NUL character")
        return _utf_8_encode(string)[0] + b"\x00"
547114
@Override
    public void sawOpcode(int seen) {
        Integer tosIsSyncColReg = null;
        try {
            stack.precomputation(this);

            if (seen == Const.INVOKESPECIAL) {
                tosIsSyncColReg = checkConstructors();
            } else if (seen == Const.INVOKESTATIC) {
                tosIsSyncColReg = checkStaticCreations();
            } else if ((seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE)) {
                tosIsSyncColReg = checkSelfReturningMethods();
            } else if (isAStore(seen)) {
                dealWithStoring(seen);
            } else if (isALoad(seen)) {
                int reg = RegisterUtils.getALoadReg(this, seen);
                RegisterInfo cri = suspectLocals.get(Integer.valueOf(reg));
                if ((cri != null) && !cri.getIgnore()) {
                    tosIsSyncColReg = Integer.valueOf(reg);
                }
            } else if (((seen == Const.PUTFIELD) || (seen == Const.ARETURN)) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item item = stack.getStackItem(0);
                suspectLocals.remove(item.getUserValue());
            }

            if (!suspectLocals.isEmpty()) {
                if (isStandardInvoke(seen)) {
                    String sig = getSigConstantOperand();
                    int argCount = SignatureUtils.getNumParameters(sig);
                    if (stack.getStackDepth() >= argCount) {
                        for (int i = 0; i < argCount; i++) {
                            OpcodeStack.Item item = stack.getStackItem(i);
                            RegisterInfo cri = suspectLocals.get(item.getUserValue());
                            if (cri != null) {
                                if (SignatureUtils.similarPackages(SignatureUtils.getPackageName(SignatureUtils.stripSignature(getClassConstantOperand())),
                                        SignatureUtils.getPackageName(SignatureUtils.stripSignature(this.getClassName())), 2)) {
                                    cri.setPriority(LOW_PRIORITY);
                                } else {
                                    cri.setIgnore();
                                }
                            }
                        }
                    }
                } else if (seen == Const.MONITORENTER) {
                    // Assume if synchronized blocks are used then something
                    // tricky is going on.
                    // There is really no valid reason for this, other than
                    // folks who use
                    // synchronized blocks tend to know what's going on.
                    if (stack.getStackDepth() > 0) {
                        OpcodeStack.Item item = stack.getStackItem(0);
                        suspectLocals.remove(item.getUserValue());
                    }
                } else if ((seen == Const.AASTORE) && (stack.getStackDepth() > 0)) {
                    OpcodeStack.Item item = stack.getStackItem(0);
                    suspectLocals.remove(item.getUserValue());
                }
            }

            reportTroublesomeLocals();
        } finally {
            TernaryPatcher.pre(stack, seen);
            stack.sawOpcode(this, seen);
            TernaryPatcher.post(stack, seen);
            if ((tosIsSyncColReg != null) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item item = stack.getStackItem(0);
                item.setUserValue(tosIsSyncColReg);
            }
        }
    }
136604
private void detectNestedInvocations(Method daoMethod) {
		if (!Config.IN_PRODUCTION && !daoMethod.getName().startsWith("read")) {
			StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
			for (StackTraceElement stackTraceElement : stackTraceElements) {
				if (daoMethod.getDeclaringClass().getName().equals(stackTraceElement.getClassName()) &&
						!daoMethod.getName().equals(stackTraceElement.getMethodName())) {
					throw new RuntimeException(Utils.
							formatMessage("Method {0}.{1}() was invoked from another method in the same "
							+ "class - {2}.{3}(). DAO implementations should avoid this as it causes objects to be "
							+ "indexed and cached twice per request.",
							daoMethod.getDeclaringClass().getSimpleName(), daoMethod.getName(),
							stackTraceElement.getClassName(), stackTraceElement.getMethodName()));
				}
			}
		}
	}
1181774
function isEscapeingAt(string, index) {
	if (index === 0) { return false; }
	let i = index - 1;
	while (
		i >= 0 && string[i] === '\\'
	) { --i; }
	return (index - i) % 2 === 0;
}
22794
@Override
    public void sawOpcode(int seen) {
        boolean sawSBToString = false;
        try {

            stack.precomputation(this);
            if ((seen >= Const.IRETURN) && (seen <= Const.ARETURN)) {
                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item item = stack.getStackItem(0);

                    Integer register = Integer.valueOf(item.getRegisterNumber());
                    Object constant = registerConstants.get(register);
                    if (CONSTANT_DOESNT_EXIST.equals(constant)) {
                        throw new StopOpcodeParsingException();
                    }

                    String returnSig = item.getSignature();
                    if ((returnSig != null) && returnSig.startsWith(Values.SIG_ARRAY_PREFIX)) {
                        XField f = item.getXField();
                        if ((f == null) || (!f.isStatic())) {
                            throw new StopOpcodeParsingException();
                        }
                    }

                    constant = item.getConstant();
                    if (constant == null) {
                        throw new StopOpcodeParsingException();
                    }
                    if (Boolean.TRUE.equals(item.getUserValue()) && ("".equals(constant))) {
                        throw new StopOpcodeParsingException();
                    }
                    if ((returnConstant != null) && (!returnConstant.equals(constant))) {
                        throw new StopOpcodeParsingException();
                    }

                    returnRegister = Integer.valueOf(item.getRegisterNumber());
                    returnConstant = constant;
                    returnPC = getPC();
                }
            } else if ((seen == Const.GOTO) || (seen == Const.GOTO_W)) {
                if (stack.getStackDepth() > 0) {
                    // Ternaries confuse us too much, if the code has a ternary well - oh well
                    throw new StopOpcodeParsingException();
                }
            } else if (seen == Const.ATHROW) {
                throw new StopOpcodeParsingException();
            } else if (seen == Const.INVOKEVIRTUAL) {
                String clsName = getClassConstantOperand();
                if (SignatureUtils.isPlainStringConvertableClass(clsName)) {
                    sawSBToString = Values.TOSTRING.equals(getNameConstantOperand());
                }
            } else if (((seen >= Const.ISTORE) && (seen <= Const.ASTORE_3)) || (seen == Const.IINC)) {
                Integer register = Integer.valueOf(getRegisterOperand());
                if ((returnRegister.intValue() != -1) && (register.equals(returnRegister))) {
                    throw new StopOpcodeParsingException();
                }

                if (stack.getStackDepth() > 0) {
                    OpcodeStack.Item item = stack.getStackItem(0);
                    Object constant = item.getConstant();

                    Object regConstant = registerConstants.get(register);
                    if (regConstant != null) {
                        if ((constant == null) || !constant.equals(regConstant)) {
                            registerConstants.put(register, CONSTANT_DOESNT_EXIST);
                        }
                    } else {
                        if (item.getSignature().contains(Values.SIG_ARRAY_PREFIX)) {
                            registerConstants.put(register, CONSTANT_DOESNT_EXIST);
                        } else {
                            registerConstants.put(register, constant == null ? CONSTANT_DOESNT_EXIST : constant);
                        }
                    }
                } else {
                    registerConstants.put(register, CONSTANT_DOESNT_EXIST);
                }

                if (returnRegister.equals(register)) {
                    Object constant = registerConstants.get(returnRegister);
                    if (CONSTANT_DOESNT_EXIST.equals(constant)) {
                        throw new StopOpcodeParsingException();
                    }
                }
            }

        } finally {
            TernaryPatcher.pre(stack, seen);
            stack.sawOpcode(this, seen);
            TernaryPatcher.post(stack, seen);
            if (sawSBToString && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item item = stack.getStackItem(0);
                item.setUserValue(Boolean.TRUE);
            }
        }
    }
624487
def obfuscate_class(tokens, index, replace, replacement, *args):
    
    def return_replacement(replacement):
        CLASS_REPLACEMENTS[replacement] = replace
        return replacement
    tok = tokens[index]
    token_type = tok[0]
    token_string = tok[1]
    prev_tok = tokens[index-1]
    prev_tok_string = prev_tok[1]
    if token_type != tokenize.NAME:
        return None # Skip this token
    if token_string.startswith('__'):
        return None
    if prev_tok_string != '.':
        if token_string == replace:
            return return_replacement(replacement)
490887
def skip(self, regex):
        
        return self.scan_full(regex, return_string=False, advance_pointer=True)
381038
function(segment, strict) {
		if (!_.isString(segment)) {
			throw new TypeError('segment must be of type string');
		}
		if (!_.isBoolean(strict)) {
			strict = true;
		}
		segment = segment.replace(illegalCharacters, '');
		if (strict && osType === "Windows_NT") {
			segment = segment.replace(illegalNames, '');
			while (illegalTrailingCharacters.test(segment)) {
				segment = segment.replace(illegalTrailingCharacters, '');
			}
		}
		return segment;
	}