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.
$ go run ./cmd/taint/main.go
... clears screen ...
Commands (tab complete)
- clear to clear screen.
- exit to quit.
> ...
Note
There are commands like callpath, check, pkgs, amongst a few others that are currently not shown in that top level help. That can be figured out later, maybe using cobra.
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.
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:
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:
https://github.com/picatz/taint/blob/b728a26a4f59e787ecce1207612d80932a9ceac1/cmd/taint/main.go#L159-L161
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.
https://github.com/picatz/taint/blob/b728a26a4f59e787ecce1207612d80932a9ceac1/cmd/taint/main.go#L163-L172
Once we have loaded packages, we can build the complete SSA program information:
https://github.com/picatz/taint/blob/b728a26a4f59e787ecce1207612d80932a9ceac1/cmd/taint/main.go#L180-L186
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:https://github.com/picatz/taint/blob/b728a26a4f59e787ecce1207612d80932a9ceac1/cmd/taint/main.go#L188-L211 https://github.com/picatz/taint/blob/b728a26a4f59e787ecce1207612d80932a9ceac1/cmd/taint/main.go#L219