Adjust Stack Exposure test so it passes

A minor bug in our CFG means that we evaluate the base of a
SliceExpr before the bounds. Since the bounds may have side
effects, as in this case, it would be better to evaluate them first.
But in the short term I am just adjusting the test to make it work.
This commit is contained in:
Owen Mansel-Chan
2025-09-18 17:02:40 +01:00
parent 62155876c5
commit 3906f2560d
2 changed files with 6 additions and 5 deletions

View File

@@ -1,8 +1,8 @@
edges
| test.go:14:2:14:4 | definition of buf | test.go:17:10:17:12 | buf | provenance | |
| test.go:15:28:15:30 | buf [postupdate] | test.go:18:10:18:12 | buf | provenance | |
nodes
| test.go:14:2:14:4 | definition of buf | semmle.label | definition of buf |
| test.go:17:10:17:12 | buf | semmle.label | buf |
| test.go:15:28:15:30 | buf [postupdate] | semmle.label | buf [postupdate] |
| test.go:18:10:18:12 | buf | semmle.label | buf |
subpaths
#select
| test.go:17:10:17:12 | buf | test.go:14:2:14:4 | definition of buf | test.go:17:10:17:12 | buf | HTTP response depends on $@ and may be exposed to an external user. | test.go:14:2:14:4 | definition of buf | stack trace information |
| test.go:18:10:18:12 | buf | test.go:15:28:15:30 | buf [postupdate] | test.go:18:10:18:12 | buf | HTTP response depends on $@ and may be exposed to an external user. | test.go:15:28:15:30 | buf [postupdate] | stack trace information |

View File

@@ -12,7 +12,8 @@ var logger log.Logger
func handlePanic(w http.ResponseWriter, r *http.Request) {
buf := make([]byte, 2<<16)
buf = buf[:runtime.Stack(buf, true)]
stackLen := runtime.Stack(buf, true)
buf = buf[:stackLen]
// BAD: printing a stack trace back to the response
w.Write(buf)
// GOOD: logging the response to the server and sending