Skip to content

Commit 76a3306

Browse files
committed
Go: convert UncontrolledAllocationSize test to .qlref
1 parent e379795 commit 76a3306

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed
Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
1-
invalidModelRow
2-
testFailures
1+
#select
2+
| UncontrolledAllocationSizeBad.go:20:27:20:30 | sink | UncontrolledAllocationSizeBad.go:11:12:11:16 | selection of URL | UncontrolledAllocationSizeBad.go:20:27:20:30 | sink | This memory allocation depends on a $@. | UncontrolledAllocationSizeBad.go:11:12:11:16 | selection of URL | user-provided value |
3+
edges
4+
| UncontrolledAllocationSizeBad.go:11:12:11:16 | selection of URL | UncontrolledAllocationSizeBad.go:11:12:11:24 | call to Query | provenance | Src:MaD:1 MaD:2 |
5+
| UncontrolledAllocationSizeBad.go:11:12:11:24 | call to Query | UncontrolledAllocationSizeBad.go:13:15:13:20 | source | provenance | |
6+
| UncontrolledAllocationSizeBad.go:13:15:13:20 | source | UncontrolledAllocationSizeBad.go:13:15:13:29 | call to Get | provenance | MaD:3 |
7+
| UncontrolledAllocationSizeBad.go:13:15:13:29 | call to Get | UncontrolledAllocationSizeBad.go:14:28:14:36 | sourceStr | provenance | |
8+
| UncontrolledAllocationSizeBad.go:14:2:14:37 | ... := ...[0] | UncontrolledAllocationSizeBad.go:20:27:20:30 | sink | provenance | |
9+
| UncontrolledAllocationSizeBad.go:14:28:14:36 | sourceStr | UncontrolledAllocationSizeBad.go:14:2:14:37 | ... := ...[0] | provenance | Config |
10+
models
11+
| 1 | Source: net/http; Request; true; URL; ; ; ; remote; manual |
12+
| 2 | Summary: net/url; URL; true; Query; ; ; Argument[receiver]; ReturnValue; taint; manual |
13+
| 3 | Summary: net/url; Values; true; Get; ; ; Argument[receiver]; ReturnValue; taint; manual |
14+
nodes
15+
| UncontrolledAllocationSizeBad.go:11:12:11:16 | selection of URL | semmle.label | selection of URL |
16+
| UncontrolledAllocationSizeBad.go:11:12:11:24 | call to Query | semmle.label | call to Query |
17+
| UncontrolledAllocationSizeBad.go:13:15:13:20 | source | semmle.label | source |
18+
| UncontrolledAllocationSizeBad.go:13:15:13:29 | call to Get | semmle.label | call to Get |
19+
| UncontrolledAllocationSizeBad.go:14:2:14:37 | ... := ...[0] | semmle.label | ... := ...[0] |
20+
| UncontrolledAllocationSizeBad.go:14:28:14:36 | sourceStr | semmle.label | sourceStr |
21+
| UncontrolledAllocationSizeBad.go:20:27:20:30 | sink | semmle.label | sink |
22+
subpaths

go/ql/test/query-tests/Security/CWE-770/UncontrolledAllocationSize.ql

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
query: Security/CWE-770/UncontrolledAllocationSize.ql
2+
postprocess:
3+
- utils/test/PrettyPrintModels.ql
4+
- utils/test/InlineExpectationsTestQuery.ql

go/ql/test/query-tests/Security/CWE-770/UncontrolledAllocationSizeBad.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
func OutOfMemoryBad(w http.ResponseWriter, r *http.Request) {
11-
source := r.URL.Query()
11+
source := r.URL.Query() // $ Source
1212

1313
sourceStr := source.Get("n")
1414
sink, err := strconv.Atoi(sourceStr)
@@ -17,7 +17,7 @@ func OutOfMemoryBad(w http.ResponseWriter, r *http.Request) {
1717
return
1818
}
1919

20-
result := make([]string, sink) // $hasTaintFlow="sink"
20+
result := make([]string, sink) // $ Alert
2121
for i := 0; i < sink; i++ {
2222
result[i] = fmt.Sprintf("Item %d", i+1)
2323
}

0 commit comments

Comments
 (0)