Skip to content

Commit

Permalink
Add source and vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
akwick committed Dec 14, 2016
1 parent 1dd9322 commit b6e0d43
Show file tree
Hide file tree
Showing 230 changed files with 45,796 additions and 0 deletions.
52 changes: 52 additions & 0 deletions RunAnalysis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Run the default analysis

## Requierements
3. Clone the repository to a folder you prefer: `$ git clone https://git.cased.de/git/ec-spride-sse-internal-goretech`
0. Installed go with version >= 1.5
1. If the `$GOPATH` is not set, then: export GOPATH=$HOME/go (this directory is your workspace, create it somewhere)
2. `ln -s PATH_TO_GIT/goretech $GOPATH/src/goretech`
2. `$ cd $GOPATH/src/goretech/analysis`
8. add missing packages via go get
* `go get golang.org/x/tools/go/ssa`
* `go get github.com/stretchr/testify/assert`
* `go get github.com/pkg/errors`
* `go get github.com/smartystreets/goconvey/convey`
* if you want to debug: `$ go get github.com/mailgun/godebug`



## Build the analysis

0. cd $GOPATH/src/goretech/analysis
1. go build

## Run the analysis

0. ./analysis -path="path to go-files as relative part from $GOPATH/src" -src="path to source code file which should analyzed" -ssf="path to the sources and sinks file"
`./analysis -src="tests/exampleCode/hello.go"`
1. The -src flag is mandatory, the path, ssf, allpkgs, pkgs and ptrflag are optional.
2. The default parameter are:
- path = goretech/analysis
- It is important to change the path if you are not running our examples.

- ssf = ./sourcesAndSinks.txt
- allpkgs = false
- pkgs = ""
- ptr = true
3. `./analysis -h` prints a short help for the flags.

# Test Results

We have several tests which ensures some functionality of our analysis.
The results are available via [Jenkins](https://envisage.ifi.uio.no:8080/jenkins/view/Vs-dev/job/GoRETech/)
Are more detailed descriptions about running tests on your machine are in tests.md

# Debug the program

The repository has a small shell script which can build a debug file.
A reference for the commands is in the [repository of godebug](https://github.com/mailgun/godebug).

```
$ ./debug.sh
$ ./analysis.debug -src="fileyouwanttodebug"
```
4 changes: 4 additions & 0 deletions debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
#Builds the analysis.debug file with some instrumentations

godebug build -instrument="goretech/analysis/lattice/taint,goretech/analysis/lattice,goretech/analysis/worklist"
77 changes: 77 additions & 0 deletions lattice/lattice.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Package lattice holds the interfaces and concrete implementations for
// lattices which are used during the analysis.
package lattice

import (
"golang.org/x/tools/go/pointer"
"golang.org/x/tools/go/ssa"
)

// Latticer describes the lattice interface.
// A lattice contains ssa.Values which points to a Valuer
type Latticer interface {
// LeastUpperBound returns the lub of two lattices
LeastUpperBound(l2 Latticer) (Latticer, error)
// GreatestLowerBound returns the glb of two lattices
GreatestLowerBound(l2 Latticer) (Latticer, error)
// LeastElement returns the least element (_|_)
LeastElement() (Latticer, error)
// Less returns true if l1 < l2
Less(l2 Latticer) (bool, error)
// Equal returns true if l1 == l2
Equal(l2 Latticer) (bool, error)
// LessEqual returns true if l1 <= l2
LessEqual(l2 Latticer) (bool, error)
// Greater returns true if l1 > l2
Greater(l2 Latticer) (bool, error)
// GreaterEqual returns true if l1 >= l2
GreaterEqual(l2 Latticer) (bool, error)
// BottomLattice returns the lowest lattice
BottomLattice() Latticer
// DeepCopy returns a deep copy of the lattice
DeepCopy() Latticer
// String returns a readable string of the lattice
String() string
// GetVal returns the abstract value of key of the lattice
GetVal(key ssa.Value) Valuer
// SetVal sets key to val in the lattice
SetVal(key ssa.Value, val Valuer) error
}

// Pter describes the methods a pointer lattice needs
type Pter interface {
// Embedd Latticer interface
Latticer
// GetPtr returns the pointer.Pointer for the key
GetPtr(key ssa.Value) pointer.Pointer
// SetPtr sets the ptr as the pointer for the key
SetPtr(key ssa.Value, ptr pointer.Pointer)
// GetLat returns an instance of Latticer
GetLat() Latticer
// GetPTrs returns a map of all variables and the corresponding pointer
GetPtrs() map[ssa.Value]pointer.Pointer
}

// Valuer defines the methods of a value inside a Latticer
type Valuer interface {
// BottomElement returns the bottom element of a lattice value
BottomElement() Valuer
// TopElement returns the top element of a lattice value
TopElement() Valuer
// LeastUpperBound returns the the lub of lv1 and lv2
LeastUpperBound(lv2 Valuer) (Valuer, error)
// GreatestLowerBound returns the the glb of lv1 and lv2
GreatestLowerBound(lv2 Valuer) (Valuer, error)
// Less returns true if lv1 < lv2
Less(lv2 Valuer) (bool, error)
// Equal returns true if lv1 == lv2
Equal(lv2 Valuer) (bool, error)
// LessEqual returns true if lv1 <= lv2
LessEqual(lv2 Valuer) (bool, error)
// Greater returns true if lv1 > lv2
Greater(lv2 Valuer) (bool, error)
// GreaterEqual returns true if lv1 >= lv2
GreaterEqual(lv2 Valuer) (bool, error)
// String returns a readable string of the value
String() string
}
Loading

0 comments on commit b6e0d43

Please sign in to comment.