-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18284 from egregius313/egregius313/go/dataflow/so…
…urces/commandargs/os-args Go: Model `os.Args` as a `commandargs` source
- Loading branch information
Showing
7 changed files
with
48 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
category: minorAnalysis | ||
--- | ||
* Added a `commandargs` local source model for the `os.Args` variable. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/commandargs/test.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
testFailures | ||
invalidModelRow |
6 changes: 6 additions & 0 deletions
6
go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/commandargs/test.ext.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extensions: | ||
- addsTo: | ||
pack: codeql/threat-models | ||
extensible: threatModelConfiguration | ||
data: | ||
- ["commandargs", true, 0] |
19 changes: 19 additions & 0 deletions
19
go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/commandargs/test.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import go | ||
import ModelValidation | ||
import TestUtilities.InlineExpectationsTest | ||
|
||
module SourceTest implements TestSig { | ||
string getARelevantTag() { result = "source" } | ||
|
||
predicate hasActualResult(Location location, string element, string tag, string value) { | ||
exists(ActiveThreatModelSource s | | ||
s.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(), | ||
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and | ||
element = s.toString() and | ||
value = "" and | ||
tag = "source" | ||
) | ||
} | ||
} | ||
|
||
import MakeTest<SourceTest> |
9 changes: 9 additions & 0 deletions
9
go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/commandargs/test_os.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package test | ||
|
||
import "os" | ||
|
||
func loopThroughCommandArgs() { | ||
for _, arg := range os.Args { // $ source | ||
_ = arg | ||
} | ||
} |