syscall environment variables

This commit is contained in:
Ed Minnix
2024-08-21 00:36:48 -04:00
parent 9f00a0060d
commit 0eddaa0664
2 changed files with 20 additions and 0 deletions

View File

@@ -20,3 +20,10 @@ extensions:
- ["syscall", "Conn", True, "SyscallConn", "", "", "Argument[receiver]", "ReturnValue[0]", "taint", "manual"]
- ["syscall", "RawConn", True, "Read", "", "", "Argument[receiver]", "Argument[0]", "taint", "manual"]
- ["syscall", "RawConn", True, "Write", "", "", "Argument[0]", "Argument[receiver]", "taint", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["syscall", "", False, "Environ", "", "", "ReturnValue", "environment", "manual"]
- ["syscall", "", False, "Getenv", "", "", "ReturnValue[0]", "environment", "manual"]
- ["syscall", "ProcAttr", True, "Env", "", "", "", "environment", "manual"]

View File

@@ -8,6 +8,7 @@ import (
"github.com/joho/godotenv"
"github.com/kelseyhightower/envconfig"
"os"
"syscall"
)
func osEnvironmentVariables() {
@@ -97,3 +98,15 @@ func envyEnvironmentVariables() {
fmt.Printf("HOME: %s\n", homeDir)
}
func syscallEnvironmentVariables() {
for _, envVar := range syscall.Environ() { // $ source
fmt.Println("%s", envVar)
}
home, err := syscall.Getenv("HOME") // $ source
if err != nil {
return
}
fmt.Println("HOME: %s", home)
}