File tree Expand file tree Collapse file tree 4 files changed +14
-10
lines changed
test/library-tests/semmle/go/frameworks Expand file tree Collapse file tree 4 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ module Afero {
92
92
predicate aferoSanitizer ( DataFlow:: Node n ) {
93
93
exists ( Function f |
94
94
f .hasQualifiedName ( aferoPackage ( ) , [ "NewBasePathFs" , "NewIOFS" ] ) and
95
- DataFlow :: localFlow ( f .getACall ( ) , n )
95
+ TaintTracking :: localTaint ( f .getACall ( ) , n )
96
96
)
97
97
}
98
98
@@ -103,10 +103,12 @@ module Afero {
103
103
*
104
104
* e.g.`n2 := &afero.Afero{Fs: afero.NewBasePathFs(osFS, "./")}` n1 is `afero.NewBasePathFs(osFS, "./")`
105
105
*/
106
- predicate additionalTaintStep ( DataFlow:: Node n1 , DataFlow:: Node n2 ) {
107
- exists ( StructLit st | st .getType ( ) .hasQualifiedName ( aferoPackage ( ) , "Afero" ) |
108
- n1 .asExpr ( ) = st .getAnElement ( ) .( KeyValueExpr ) .getAChildExpr ( ) and
109
- n2 .asExpr ( ) = st
110
- )
106
+ class AdditionalTaintStep extends TaintTracking:: AdditionalTaintStep {
107
+ override predicate step ( DataFlow:: Node n1 , DataFlow:: Node n2 ) {
108
+ exists ( StructLit st | st .getType ( ) .hasQualifiedName ( aferoPackage ( ) , "Afero" ) |
109
+ n1 .asExpr ( ) = st .getAnElement ( ) .( KeyValueExpr ) .getAChildExpr ( ) and
110
+ n2 .asExpr ( ) = st
111
+ )
112
+ }
111
113
}
112
114
}
Original file line number Diff line number Diff line change @@ -13,7 +13,9 @@ module FileSystemAccessTest implements TestSig {
13
13
tag = "FileSystemAccess"
14
14
)
15
15
or
16
- exists ( DataFlow:: Node succ , DataFlow:: Node pred | Afero:: additionalTaintStep ( pred , succ ) |
16
+ exists ( DataFlow:: Node succ , DataFlow:: Node pred |
17
+ any ( Afero:: AdditionalTaintStep adts ) .step ( pred , succ )
18
+ |
17
19
succ .hasLocationInfo ( location .getFile ( ) .getAbsolutePath ( ) , location .getStartLine ( ) ,
18
20
location .getStartColumn ( ) , location .getEndLine ( ) , location .getEndColumn ( ) ) and
19
21
element = succ .toString ( ) and
Original file line number Diff line number Diff line change @@ -4,10 +4,11 @@ package main
4
4
5
5
import (
6
6
"fmt"
7
- "github.com/spf13/afero"
8
7
"net/http"
9
8
"os"
10
9
"regexp"
10
+
11
+ "github.com/spf13/afero"
11
12
)
12
13
13
14
func main () {
@@ -63,8 +64,7 @@ func Afero(writer http.ResponseWriter, request *http.Request) {
63
64
fmt .Println ("Afero:" )
64
65
newBasePathFs := afero .NewBasePathFs (osFS , "tmp" )
65
66
basePathFs0 := & afero.Afero {Fs : newBasePathFs } // $ succ=Afero pred=newBasePathFs
66
- // following is a FP, and in a dataflow configuration if we use Afero::additionalTaintStep then we won't have following in results
67
- fmt .Println (basePathFs0 .ReadFile (filepath )) // $ SPURIOUS: FileSystemAccess=filepath
67
+ fmt .Println (basePathFs0 .ReadFile (filepath ))
68
68
69
69
// IOFS ==> OK
70
70
fmt .Println ("IOFS:" )
You can’t perform that action at this time.
0 commit comments