Skip to content

Lombok-generated method incorrectly indexed #788

Open
@stevev-neosec

Description

@stevev-neosec

Using Docker image retrieved with docker pull --platform=linux/arm64 sourcegraph/scip-java:0.10.4.

Indexing project - https://github.com/hendisantika/spring-boot-swagger
project hash: bf21451 and possibly others

Generated index (text format): p1.java.scip.txt.json

In the Student class, all getters and setters are generated by Lombok via @Data. For all of the getters, the SCIP index defines a multiline occurrence with `symbol_roles:

EXCEPT for getAddress().

Example:

  occurrences {
    range: 26
    range: 24
    range: 27
    range: 5
    symbol: "semanticdb maven maven/com.hendisantika.springboot.swagger/springboot-swagger 0.0.1-SNAPSHOT com/hendisantika/springboot/swagger/model/Student#getAge()."
    symbol_roles: 1
  }
  ...
  symbols {
    symbol: "semanticdb maven maven/com.hendisantika.springboot.swagger/springboot-swagger 0.0.1-SNAPSHOT com/hendisantika/springboot/swagger/model/Student#getAge()."
    kind: Method
    display_name: "getAge"
    signature_documentation {
      relative_path: "src/main/java/com/hendisantika/springboot/swagger/model/Student.java"
      language: "java"
      text: "@SuppressWarnings(\"all\")\n@Generated\npublic Integer getAge()"
    }
  }
  ...
  occurrences {
    range: 34
    range: 25
    range: 35
    symbol: "semanticdb maven maven/com.hendisantika.springboot.swagger/springboot-swagger 0.0.1-SNAPSHOT com/hendisantika/springboot/swagger/model/Student#getAddress()."
    symbol_roles: 1
  }
  ...
  symbols {
    symbol: "semanticdb maven maven/com.hendisantika.springboot.swagger/springboot-swagger 0.0.1-SNAPSHOT com/hendisantika/springboot/swagger/model/Student#getAddress()."
    kind: Method
    display_name: "getAddress"
    signature_documentation {
      relative_path: "src/main/java/com/hendisantika/springboot/swagger/model/Student.java"
      language: "java"
      text: "@SuppressWarnings(\"all\")\n@Generated\npublic Address getAddress()"
    }
  }

In the case of the two problematic endpoints, each of those happens to call the getAddress() method in a streaming filter:

.filter(e -> e.getValue().getAddress().getCity().equals(cityName))

If you look at the example SCIP occurrences above, you see that the range for getAddress() exactly matches the location in the original source of getAddress() within the line this.address = p.getAddress();. The SCIP index is incorrect because this is not the line on which the method is defined, it is a line on which it is referenced.

Note that this is not a problem for getAge(). If you look at it’s defining occurrence above, you’ll see that it has a multiline range.

One additional use case was tested by changing the above .filter example to:

.filter(e -> e.getValue().getFirstName().equals(cityName))

The SCIP index was re-generated and the resulting indexing did not have any issues.

For some reason this was specific to the getAddress() method.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions