github / github/codeql

False positive in Go / Golang context when logging using %T

未關閉
#18,926 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
false-positive Go
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

**Description of the false positive**

[The warning](https://github.com/developerproductivity/costpuller/security/code-scanning/2) is "Clear-text logging of sensitive information", but what is actually logged is the _type_ of the variable which holds the information and not the information itself.

CodeQL correctly determines that a variable potentially holding a piece of sensitive information is [referenced in a `log.Fatalf()` call](https://github.com/developerproductivity/costpuller/blob/517634a461440261d5f0e5a3ccab0326e32c69a0/cloudability.go#L214-L214), but it misses the fact that the reference is processed using a `%T` format specifier which will result in the log receiving the _type_ of the data and not the _value_ of the data:

```go
apiKeyPair, ok := apiKeyPairAny.([]any)
if !ok {
log.Fatalf("Error reading Cloudability API keypair, expected an array, found %T",
apiKeyPairAny)
```

**Possible workaround**

I'm hoping that the following will suffice to work around the problem, but it's ugly and really shouldn't be necessary!

```go
log.Fatalf("Error reading Cloudability API keypair, expected an array, found %v",
reflect.TypeOf(apiKeyPairAny).String())
```

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。