Class CannotAssignFromSanitizedOrError


final class CannotAssignFromSanitizedOrError extends TypedSymbolAccess
Blocks direct assignment from sanitized parameters to local variables. This prevents hiding the copy semantics of sanitized parameters.
someFunction(data as sanitized String)
  local <- data   // ERROR: Creates alias, hides copy semantics
  local := data   // ERROR: Same issue
  result: data    // OK: Returning the value is allowed
  this.field: data // OK: Storing in field is allowed
The developer should either use the sanitized parameter directly or make an explicit copy: local <- String(data)

Assignment to return variables and fields is allowed because: - Returning a sanitized value doesn't create confusing local aliases - Storing in a field is an intentional action to persist the sanitized value

  • Constructor Details

  • Method Details

    • accept

      void accept(IToken assignmentOp, ISymbol lhsSymbol, ISymbol rhsSymbol)
      Check if assignment from a sanitized parameter is allowed.
      Parameters:
      assignmentOp - The token representing the assignment operator
      lhsSymbol - The left-hand side symbol being assigned to
      rhsSymbol - The right-hand side symbol (potential sanitized parameter)