Skip to content

Commit 0eddaa0

Browse files
committed
syscall environment variables
1 parent 9f00a00 commit 0eddaa0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

go/ql/lib/ext/syscall.model.yml

+7
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,10 @@ extensions:
2020
- ["syscall", "Conn", True, "SyscallConn", "", "", "Argument[receiver]", "ReturnValue[0]", "taint", "manual"]
2121
- ["syscall", "RawConn", True, "Read", "", "", "Argument[receiver]", "Argument[0]", "taint", "manual"]
2222
- ["syscall", "RawConn", True, "Write", "", "", "Argument[0]", "Argument[receiver]", "taint", "manual"]
23+
- addsTo:
24+
pack: codeql/go-all
25+
extensible: sourceModel
26+
data:
27+
- ["syscall", "", False, "Environ", "", "", "ReturnValue", "environment", "manual"]
28+
- ["syscall", "", False, "Getenv", "", "", "ReturnValue[0]", "environment", "manual"]
29+
- ["syscall", "ProcAttr", True, "Env", "", "", "", "environment", "manual"]

go/ql/test/library-tests/semmle/go/dataflow/flowsources/local/environment/test.go

+13
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/joho/godotenv"
99
"github.com/kelseyhightower/envconfig"
1010
"os"
11+
"syscall"
1112
)
1213

1314
func osEnvironmentVariables() {
@@ -97,3 +98,15 @@ func envyEnvironmentVariables() {
9798

9899
fmt.Printf("HOME: %s\n", homeDir)
99100
}
101+
102+
func syscallEnvironmentVariables() {
103+
for _, envVar := range syscall.Environ() { // $ source
104+
fmt.Println("%s", envVar)
105+
}
106+
107+
home, err := syscall.Getenv("HOME") // $ source
108+
if err != nil {
109+
return
110+
}
111+
fmt.Println("HOME: %s", home)
112+
}

0 commit comments

Comments
 (0)