Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to introduce the
taint
command to provide an interactive shell (REPL) to explore a program with, like its call graph or dependencies, and identify potential taint analysis issues.It also acts as a nice standalone example for how to use the package's provided in this module directly, without needing to go through
go/analysis
.In hopes my future self (and perhaps others?) will benefit from this breakdown:
First, we need to determine the package "patterns" we want to use:
taint/cmd/taint/main.go
Lines 159 to 161 in b728a26
Next, we need to load our packages, applying our load pattern with a given configuration:
Here, we set the directory we're working with, amongst other information, like environment variables. We also provide a custom file parsing function. In the future, we can optimize our package loading using these fields. We also are excluding tests, which might need to be configurable in the future.
taint/cmd/taint/main.go
Lines 163 to 172 in b728a26
Once we have loaded packages, we can build the complete SSA program information:
taint/cmd/taint/main.go
Lines 180 to 186 in b728a26
Now we have the SSA value graph, we can create a call graph from that information. We're assuming there's only one logical program loaded (which isn't always true, to be clear), and create a call graph rooted in that program's
main
function:taint/cmd/taint/main.go
Lines 188 to 211 in b728a26
taint/cmd/taint/main.go
Line 219 in b728a26