Skip to content

Commit

Permalink
Merge pull request #65 from awslabs/fix-cli-rebuild
Browse files Browse the repository at this point in the history
Fix #60 + small updates in documentation.
  • Loading branch information
victornicolet authored Apr 3, 2024
2 parents 3e3d32a + 417a4c9 commit d9b00a5
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 46 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# Argot


## Overview

Argot is a collection of tools:
Expand Down
19 changes: 19 additions & 0 deletions analysis/dataflow/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,25 @@ func NewAnalyzerState(p *ssa.Program, l *config.LogGroup, c *config.Config,
return state, nil
}

// CopyTo copies pointers in receiver into argument (shallow copy of everything except mutex).
// Do not use two copies in separate routines.
func (s *AnalyzerState) CopyTo(b *AnalyzerState) {
b.BoundingInfo = s.BoundingInfo
b.Config = s.Config
b.EscapeAnalysisState = s.EscapeAnalysisState
b.FlowGraph = s.FlowGraph
b.Globals = s.Globals
b.ImplementationsByType = s.ImplementationsByType
b.Logger = s.Logger
b.PointerAnalysis = s.PointerAnalysis
b.errors = s.errors
b.Program = s.Program
b.keys = s.keys
b.reachableFunctions = s.reachableFunctions
// copy everything except mutex

}

// Size returns the number of method implementations collected
func (s *AnalyzerState) Size() int {
return len(s.ImplementationsByType)
Expand Down
10 changes: 3 additions & 7 deletions cmd/argot-cli/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,6 @@ func cmdIntra(tt *term.Terminal, c *dataflow.AnalyzerState, command Command) boo
tt.Escape.Blue, cmdIntraName, tt.Escape.Reset)
writeFmt(tt, "\t -v print the intermediate result every time a block is analyzed\n")
writeFmt(tt, "\t -h print this help message\n")

if state.CurrentFunction == nil {
WriteErr(tt, "You must first focus on a function to run this command!")
WriteErr(tt, "Example: > focus command-line-arguments.main")
}

return false
}

Expand All @@ -324,9 +318,11 @@ func cmdIntra(tt *term.Terminal, c *dataflow.AnalyzerState, command Command) boo
}

if state.CurrentFunction == nil {
WriteErr(tt, "You must first focus on a function to run the intraprocedural analysis.")
WriteErr(tt, "You must first focus on a function to run this command!")
WriteErr(tt, "Example: > focus command-line-arguments.main")
return false
}

var flowInfo *dataflow.FlowInformation

// This is the function that will be called after each block
Expand Down
6 changes: 4 additions & 2 deletions cmd/argot-cli/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func cmdRebuild(tt *term.Terminal, c *dataflow.AnalyzerState, _ Command) bool {
Tests: false,
}
initialPackages, _ := packages.Load(p, flag.Args()...)
state.InitialPackages = initialPackages
// Build the newState with all analyses
newState, err := dataflow.NewInitializedAnalyzerState(c.Logger, c.Config, program)
if err != nil {
Expand All @@ -82,7 +81,10 @@ func cmdRebuild(tt *term.Terminal, c *dataflow.AnalyzerState, _ Command) bool {
}
}
// Reassign state elements
c = newState
newState.CopyTo(c)
state.CurrentFunction = nil
state.CurrentDataflowInformation = nil
state.InitialPackages = initialPackages
return false
}

Expand Down
10 changes: 5 additions & 5 deletions doc/00_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ We need analyses that ensure the [soundness](https://cacm.acm.org/blogs/blog-cac

## Solution

The Automated Reasoning Go Tools (Argot) is a program analysis tool set, which at its core implements a whole-program [dataflow analysis](https://en.wikipedia.org/wiki/Data-flow_analysis) upon which other analyses are built. The main feature of this tool set is a tool for [**taint analysis**](https://en.wikipedia.org/wiki/Taint_checking), which is an approach to verifying that no sensitive data coming from a source reaches a function that should not handle such sensitive data. The tool set also contains functionality to analyze dependency imports, reachable functions or apply a backward dataflow analysis, among others.
The Automated Reasoning Go Tools (Argot) is an experimental program analysis tool set, which at its core implements a whole-program [dataflow analysis](https://en.wikipedia.org/wiki/Data-flow_analysis) upon which other analyses are built. The main feature of this tool set is a tool for [**taint analysis**](https://en.wikipedia.org/wiki/Taint_checking), which is an approach to verifying that no sensitive data coming from a source reaches a function that should not handle such sensitive data. The tool set also contains functionality to analyze dependency imports, reachable functions or apply a backward dataflow analysis, among others.



Expand All @@ -23,18 +23,18 @@ The Automated Reasoning Go Tools (Argot) is a program analysis tool set, which a
### Tools in Argot

The following tools are included in Argot:
- the `taint` tool allows you to perform taint analysis in your program (see [Taint Analysis](01_taint.md#taint-analysis))
- the `backtrace` tool allows you to find all the backwards data flows from a function call (see [Backtrace Analysis](02_backtrace.md#backtrace-analysis))
- the `taint` tool allows you to perform taint analysis in your program (see [Taint Analysis](01_taint.md#taint-analysis)).
- the `backtrace` tool allows you to find all the backwards data flows from a function call (see [Backtrace Analysis](02_backtrace.md#backtrace-analysis)).
- the `argot-cli` is an interactive analysis tool, which lets the user run multiple analyses on the program and inspect various levels of debugging information (see [Argot CLI](03_argotcli.md#argot-cli)). This tool is intended for the advanced user who understands the underlying program representations more in detail.
- the `compare` tool, which can be used to compare the results of different reachability analyses together, on different platforms. This is useful for the user who wants to make sure the results given by some of the analyses are consistent with their assumptions, or the user that is trying to eliminate unneeded functions or dependencies (see [Compare Tool](04_compare.md#compare-tool))
- the `compare` tool, which can be used to compare the results of different reachability analyses together, on different platforms. This is useful for the user who wants to make sure the results given by some of the analyses are consistent with their assumptions, or the user that is trying to eliminate unneeded functions or dependencies (see [Compare Tool](04_compare.md#compare-tool)).
- the `defer` tool runs an analysis that computes the possible deferred functions that can run at each return point of a function (see [Defer Analysis](05_defer.md#defer-analysis)).
- the `dependencies` tool scans for the input package's dependencies and returns the list of dependencies along with the count of reachable functions within each dependency (see [Dependencies](06_dependencies.md#dependency-scanner)).
- the `maypanic` tool inspects the input packages to find goroutines with unrecovered panics (see [May Panic Analysis](07_maypanic.md#may-panic-analysis)).
- the `packagescan` tool scans the input packages to find usages of specific packages in the code, such as usages of the `unsafe` package (see [Package Scanner](08_packagescan.md#package-scanner)).
- the `reachability` tool inspects the code to find which functions are reachable, and which are not (see [Reachability Tool](09_reachability.md#reachability-tool)).
- the `render` tool can be used to render various representations of the code, such as its [Static Single Assignment](https://en.wikipedia.org/wiki/Static_single-assignment_form) (SSA) form or its callgraph (see [Render Tool](10_render.md#render-tool)).
- the `static-commands` tool analyzes the code to find usages of `os/exec.Command` that are defined statically.
- the `racerg` tool, an experimental tool for data race detection (See [RacerG](11_racerg.md#racerg-sound-and-scalable-static-data-race-detector-for-go))
- the `racerg` tool, an experimental tool for data race detection (See [RacerG](11_racerg.md#racerg-sound-and-scalable-static-data-race-detector-for-go)).

These tools can be used by developers to better understand their code, through the analysis of higher-level representations. For example, one can understand how the code is organized by looking at the callgraph, which abstract away the code and retains only the caller/callee information. In general, we do not state guarantees about the correctness of these tools, except for the dataflow analyses (see [taint analysis](01_taint.md#taint-analysis) and [backtrace](02_backtrace.md#backtrace-analysis))). However, we believe the representations obtained for each of these tools are useful enough to aid programmers.

Expand Down
Loading

0 comments on commit d9b00a5

Please sign in to comment.