syft icon indicating copy to clipboard operation
syft copied to clipboard

Include source file location information: line & character numbers

Open kzantow opened this issue 3 years ago • 1 comments

What would you like to be added: File sources with line numbers

Why is this needed: A number of tools, including Visual Studio Code and Github, require or otherwise need line numbers to provide more useful reporting to the end user. Github requires line numbers, but we are currently hardcoding this to line 1, which does not provide an especially useful rendering if a user tries to figure out where a problem originated: image

Additional context: There are 2 other tickets related to this in grype anchore/syft#1208 and the vs code extension anchore/grype#2

kzantow avatar Aug 23 '21 17:08 kzantow

summarizing from an online conversation:

Today the source.Location could be modified to include this information. It would be nice to include a couple different perspectives: a) capturing line numbers and b) capturing seek locations. An IDE may be more concerned with case A for display purposes while if you wanted to extract the value at that location lines are more difficult to work with an case B would be more useful (seek directly to the value).

Our catalogers are not very uniform when it comes to how easy it would be to deliver this value. Some cataloger parsers are scanning input files one line at a time (and getting seek info would be easy to do) while others are using unmarshal functions which obscure this information. I think adding in these considerations (A & B) optionally on source.Location makes sense, and we can enhance the catalogers one-at-a-time as-needed with this functionality.

wagoodman avatar Oct 19 '21 21:10 wagoodman