Skip to content

Commit 3697ef7

Browse files
committed
Small changes
1 parent 5cab256 commit 3697ef7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

go/ql/lib/semmle/go/frameworks/GinCors.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module GinCors {
1212
string packagePath() { result = package("github.com/gin-contrib/cors", "") }
1313

1414
/**
15-
* New function create a new gin Handler that passed to gin as middleware
15+
* A new function create a new gin Handler that passed to gin as middleware
1616
*/
1717
class New extends Function {
1818
New() { exists(Function f | f.hasQualifiedName(packagePath(), "New") | this = f) }
@@ -107,6 +107,9 @@ module GinCors {
107107
exists(Type t | t.hasQualifiedName(packagePath(), "Config") | v.getType() = t)
108108
}
109109

110+
/**
111+
* Get variable declaration of GinConfig
112+
*/
110113
SsaWithFields getV() { result = v }
111114
}
112115
}

go/ql/test/experimental/CWE-942/CorsMisconfiguration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ func main() {
191191
// })
192192
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
193193
// OK-ish: the input origin header is validated against a whitelist.
194-
if origin := req.Header.Get("Origin"); cors[origin] {
194+
if origin := req.Header.Get("Origin"); cors_map[origin] {
195195
w.Header().Set("Access-Control-Allow-Origin", origin)
196-
} else if len(origin) > 0 && cors["*"] {
196+
} else if len(origin) > 0 && cors_map["*"] {
197197
w.Header().Set("Access-Control-Allow-Origin", origin)
198198
}
199199

@@ -219,7 +219,7 @@ func main() {
219219
}
220220

221221
var (
222-
cors = map[string]bool{"*": true}
222+
cors_map = map[string]bool{"*": true}
223223
)
224224

225225
func GetAllowOrigin() []string {

0 commit comments

Comments
 (0)