@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { EXCEPTIONAL_YIELD_CHECKER.reportOnExceptionalYield(context.getNode(), this); } }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { EXCEPTIONAL_YIELD_CHECKER.reportOnExceptionalYield(context.getNode(), this); } }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { EXCEPTIONAL_YIELD_CHECKER.reportOnExceptionalYield(context.getNode(), this); }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { EXCEPTIONAL_YIELD_CHECKER.reportOnExceptionalYield(context.getNode(), this); } }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { EXCEPTIONAL_YIELD_CHECKER.reportOnExceptionalYield(context.getNode(), this); } }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { EXCEPTIONAL_YIELD_CHECKER.reportOnExceptionalYield(context.getNode(), this); }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); context.getState().getValuesWithConstraints(LockConstraint.LOCKED).stream() .flatMap(lockedSv -> FlowComputation.flowWithoutExceptions(node, lockedSv, LockConstraint.LOCKED::equals, LockConstraint.UNLOCKED::equals, LOCK_CONSTRAINT_DOMAIN).stream()) .flatMap(Flow::firstFlowLocation) .forEach(this::reportIssue); }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); context.getState().getValuesWithConstraints(LockConstraint.LOCKED).stream() .flatMap(lockedSv -> FlowComputation.flowWithoutExceptions(node, lockedSv, LockConstraint.LOCKED::equals, LockConstraint.UNLOCKED::equals, LOCK_CONSTRAINT_DOMAIN).stream()) .flatMap(Flow::firstFlowLocation) .forEach(this::reportIssue); }
private ProgramState handleMinMaxInvocation(CheckerContext context, MethodInvocationTree syntaxNode) { if (!MIN_MAX_MATCHER.matches(syntaxNode)) { return context.getState(); } ProgramState programState = context.getState(); ProgramState psBeforeInvocation = context.getNode().programState; List<SymbolicValue> args = psBeforeInvocation.peekValues(2); List<ConstraintsByDomain> constraintsByArgs = args.stream().map(programState::getConstraints).collect(Collectors.toList()); checkRangeInconsistencies(context, syntaxNode, constraintsByArgs); return context.getState(); }
private ProgramState handleMinMaxInvocation(CheckerContext context, MethodInvocationTree syntaxNode) { if (!MIN_MAX_MATCHER.matches(syntaxNode)) { return context.getState(); } ProgramState programState = context.getState(); ProgramState psBeforeInvocation = context.getNode().programState; List<SymbolicValue> args = psBeforeInvocation.peekValues(2); List<ConstraintsByDomain> constraintsByArgs = args.stream().map(programState::getConstraints).collect(Collectors.toList()); checkRangeInconsistencies(context, syntaxNode, constraintsByArgs); return context.getState(); }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); Set<SymbolicValue> svToReport = symbolicValuesToReport(context); svToReport.forEach(sv -> processUnclosedSymbolicValue(node, sv)); }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); Set<SymbolicValue> svToReport = symbolicValuesToReport(context); svToReport.forEach(sv -> processUnclosedSymbolicValue(node, sv)); }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); context.getState().getValuesWithConstraints(OPENED).forEach(sv -> processUnclosedSymbolicValue(node, sv)); }
@Override public void checkEndOfExecutionPath(CheckerContext context, ConstraintManager constraintManager) { if (context.getState().exitingOnRuntimeException()) { return; } ExplodedGraph.Node node = context.getNode(); context.getState().getValuesWithConstraints(OPENED).forEach(sv -> processUnclosedSymbolicValue(node, sv)); }
private void reportIssue(Tree tree, SymbolicValue denominator, Symbol denominatorSymbol) { ExpressionTree expression = getDenominator(tree); String operation = tree.is(Tree.Kind.REMAINDER, Tree.Kind.REMAINDER_ASSIGNMENT) ? "modulation" : "division"; String expressionName = expression.is(Tree.Kind.IDENTIFIER) ? ("\"" + ((IdentifierTree) expression).name() + "\"") : "this expression"; List<Class<? extends Constraint>> domains = Collections.singletonList(ZeroConstraint.class); Set<Flow> flows = FlowComputation.flow(context.getNode(), denominator, domains, denominatorSymbol).stream() .filter(f -> !f.isEmpty()) .map(f -> Flow.builder() .add(new JavaFileScannerContext.Location("Division by zero.", tree)) .addAll(f) .build()) .collect(Collectors.toSet()); context.reportIssue(expression, DivisionByZeroCheck.this, "Make sure " + expressionName + " can't be zero before doing this " + operation + ".", flows); }
private void handleAssignment(CheckerContext context, AssignmentExpressionTree assignmentExpressionTree) { SymbolicValueSymbol assignedVariable = context.getState().peekValueSymbol(); Symbol assignedSymbol = assignedVariable.symbol(); if (assignedSymbol == null // Rule S3959 returns the same SV after each intermediate operations, // meaning that 'stream = stream.map(...);' would be detected as redundant assignment if not explicitly excluded || STREAM_TYPES.stream().anyMatch(assignedSymbol.type()::is)) { return; } ExplodedGraph.Node node = context.getNode(); ProgramState previousState = node.programState; SymbolicValue oldValue = previousState.getValue(assignedSymbol); SymbolicValue newValue = assignedVariable.symbolicValue(); Symbol fromSymbol = previousState.peekValueSymbol().symbol(); assignmentsByMethod.peek().put(assignmentExpressionTree, new AssignmentDataHolder(assignedSymbol, oldValue, newValue, fromSymbol, node)); }
@Override public ProgramState checkPostStatement(CheckerContext context, Tree syntaxNode) { if (syntaxNode.is(Tree.Kind.METHOD_INVOCATION)) { MethodInvocationTree mit = (MethodInvocationTree) syntaxNode; if (MAP_GET.matches(mit)) { ProgramState psBeforeInvocation = context.getNode().programState; ProgramState psAfterInvocation = context.getState(); SymbolicValue keySV = psBeforeInvocation.peekValue(0); SymbolicValue mapSV = psBeforeInvocation.peekValue(1); SymbolicValue valueSV = psAfterInvocation.peekValue(); mapGetInvocations.put(mapSV, new MapGetInvocation(valueSV, keySV, mit)); } } return super.checkPostStatement(context, syntaxNode); }
@Override public ProgramState checkPostStatement(CheckerContext context, Tree syntaxNode) { if (syntaxNode.is(Tree.Kind.METHOD_INVOCATION)) { MethodInvocationTree mit = (MethodInvocationTree) syntaxNode; if (MAP_GET.matches(mit)) { ProgramState psBeforeInvocation = context.getNode().programState; ProgramState psAfterInvocation = context.getState(); SymbolicValue keySV = psBeforeInvocation.peekValue(0); SymbolicValue mapSV = psBeforeInvocation.peekValue(1); SymbolicValue valueSV = psAfterInvocation.peekValue(); mapGetInvocations.put(mapSV, new MapGetInvocation(valueSV, keySV, mit)); } } return super.checkPostStatement(context, syntaxNode); }
@Override public ProgramState checkPostStatement(CheckerContext context, Tree syntaxNode) { if (syntaxNode.is(Tree.Kind.SWITCH_STATEMENT, Tree.Kind.THROW_STATEMENT) && context.getConstraintManager().isNull(context.getState(), context.getState().peekValue())) { NullDereferenceIssue issue = new NullDereferenceIssue(context.getNode(), context.getState().peekValue(), syntaxNode); detectedIssues.peek().add(issue); context.createSink(); return context.getState(); } List<ProgramState> programStates = setNullConstraint(context, syntaxNode); for (ProgramState programState : programStates) { context.addTransition(programState); } return context.getState(); }
@Override public ProgramState checkPostStatement(CheckerContext context, Tree syntaxNode) { if (syntaxNode.is(Tree.Kind.SWITCH_STATEMENT, Tree.Kind.THROW_STATEMENT) && context.getConstraintManager().isNull(context.getState(), context.getState().peekValue())) { NullDereferenceIssue issue = new NullDereferenceIssue(context.getNode(), context.getState().peekValue(), syntaxNode); detectedIssues.peek().add(issue); context.createSink(); return context.getState(); } List<ProgramState> programStates = setNullConstraint(context, syntaxNode); for (ProgramState programState : programStates) { context.addTransition(programState); } return context.getState(); }