@@ -3,82 +3,36 @@ private import go
33module LocalSources {
44 private import semmle.go.dataflow.DataFlow
55 private import semmle.go.dataflow.TaintTracking
6+ private import semmle.go.dataflow.ExternalFlow as ExternalFlow
67 private import semmle.go.Scopes
7-
8- abstract class Range extends DataFlow:: Node { }
9-
10- // ========== Sources ==========
11-
12- abstract class Sources extends DataFlow:: Node { }
13-
14- // ----------------------------------------------------
15- // Used for finding Selections or Calls for Go imports
16- // ----------------------------------------------------
178
18- //class UseOfGoImports extends Sources {
19- //UseOfGoImports () {
20- //exists ( ValueEntity read,
21- //DataFlow::Package pkg |
22- //read.getScope().getEntity(_) = pkg.getScope().getEntity(_)
23- //and ( this.toString().regexpMatch("selection of.*")
24- //or this.toString().regexpMatch("call to .*") )
25- //)
26- //}
27- //}
28-
29- // ----------------------------------------------------
30-
31- class OsCmd extends LocalSources:: Range {
32- OsCmd ( ) {
33- exists ( ValueEntity read ,
34- DataFlow:: Package pkg |
35- read .getScope ( ) .getEntity ( _) = pkg .getScope ( ) .getEntity ( _)
36- and this .toString ( ) = "selection of Run"
37- )
38- }
39- }
9+ /**
10+ * A source of data that is controlled by the local user.
11+ */
12+ abstract class Range extends DataFlow:: Node { }
4013
41- class OsExec extends LocalSources:: Range {
42- OsExec ( ) {
43- exists ( ValueEntity read ,
44- DataFlow:: Package pkg |
45- read .getScope ( ) .getEntity ( _) = pkg .getScope ( ) .getEntity ( _)
46- and this .toString ( ) = "selection of Command"
47- )
14+ /**
15+ * Support for Local Sources
16+ */
17+ class MaDLocalSource extends Range {
18+ MaDLocalSource ( ) { ExternalFlow:: sourceNode ( this , "local" ) }
4819 }
49- }
5020
51- class OsArgs extends LocalSources:: Range {
52- OsArgs ( ) {
53- exists ( ValueEntity read ,
54- DataFlow :: Package pkg |
55- read . getScope ( ) . getEntity ( _ ) = pkg . getScope ( ) . getEntity ( _ )
56- and this . toString ( ) = "selection of Args"
57- )
21+ class OsCmd extends LocalSources:: Range {
22+ OsCmd ( ) {
23+ exists ( ValueEntity read , DataFlow :: Package pkg |
24+ read . getScope ( ) . getEntity ( _ ) = pkg . getScope ( ) . getEntity ( _ ) and
25+ this . toString ( ) = "selection of Run"
26+ )
27+ }
5828 }
59- }
60-
61- // Not currently working (need a test case)
62- //class OsGetenv extends Sources, DataFlow::CallNode {
63- //OsGetenv() {
64- //// https://pkg.go.dev/os#Getenv
65- //this.getTarget().hasQualifiedName(package("os", ""), "Getenv")
66- //or
67- //// https://pkg.go.dev/os#Environ
68- //this.getTarget().hasQualifiedName(package("os", ""), "Environ")
69- //}
70- //}
7129
72- // https://pkg.go.dev/flag
73- class Flag extends LocalSources:: Range {
74- Flag ( ) {
75- exists ( ValueEntity read ,
76- DataFlow:: Package pkg |
77- read .getScope ( ) .getEntity ( _) = pkg .getScope ( ) .getEntity ( _)
78- and
79- ( this .toString ( ) = "selection of String"
80- or this .toString ( ) = "selection of Parse" )
30+ class OsExec extends LocalSources:: Range {
31+ OsExec ( ) {
32+ exists ( ValueEntity read , DataFlow:: Package pkg |
33+ read .getScope ( ) .getEntity ( _) = pkg .getScope ( ) .getEntity ( _) and
34+ this .toString ( ) = "selection of Command"
8135 )
8236 }
37+ }
8338}
84- }
0 commit comments