Skip to content

Commit 9a0fb39

Browse files
atorralbasmowton
andcommitted
Model StartWithContext
Co-authored-by: Chris Smowton <[email protected]>
1 parent d3a9a5e commit 9a0fb39

File tree

3 files changed

+22
-4
lines changed
  • go/ql
    • lib/semmle/go/frameworks
    • test/library-tests/semmle/go/frameworks/AwsLambda

3 files changed

+22
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private class StartOrNewHandlerFunction extends Function {
4545
]) and
4646
handlerArgPos = 0
4747
or
48-
this.hasQualifiedName(awsLambdaPkg(), "StartHandlerWithContext") and
48+
this.hasQualifiedName(awsLambdaPkg(), ["StartHandlerWithContext", "StartWithContext"]) and
4949
handlerArgPos = 1
5050
}
5151

go/ql/test/library-tests/semmle/go/frameworks/AwsLambda/test.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ func Handler16(ctx context.Context, event Event) (*Response, error) {
148148
return &Response{Message: ""}, nil
149149
}
150150

151+
func Handler17(ctx context.Context, event Event) (*Response, error) {
152+
sink(ctx) // safe
153+
sink(event.Name) // $ hasTaintFlow="selection of Name"
154+
sink(event.Age) // $ hasTaintFlow="selection of Age"
155+
sink(event) // $ hasTaintFlow="event"
156+
return &Response{Message: ""}, nil
157+
}
158+
151159
func main() {
152160
lambda.Start(Handler0)
153161
lambda.Start(Handler1)
@@ -177,23 +185,31 @@ func main() {
177185
})
178186
lambda.StartHandlerWithContext(context.Background(), MyHandlerFunc(Handler12))
179187
lambda.StartHandlerWithContext(context.Background(), &Handler13{})
180-
lambda.StartWithOptions(Handler14)
188+
lambda.StartWithContext(context.Background(), Handler14)
189+
lambda.StartWithContext(context.Background(), func(ctx context.Context, event Event) (*Response, error) {
190+
sink(ctx) // safe
191+
sink(event.Name) // $ hasTaintFlow="selection of Name"
192+
sink(event.Age) // $ hasTaintFlow="selection of Age"
193+
sink(event) // $ hasTaintFlow="event"
194+
return &Response{Message: ""}, nil
195+
})
196+
lambda.StartWithOptions(Handler15)
181197
lambda.StartWithOptions(func(ctx context.Context, event Event) (*Response, error) {
182198
sink(ctx) // safe
183199
sink(event.Name) // $ hasTaintFlow="selection of Name"
184200
sink(event.Age) // $ hasTaintFlow="selection of Age"
185201
sink(event) // $ hasTaintFlow="event"
186202
return &Response{Message: ""}, nil
187203
})
188-
lambda.NewHandler(Handler15)
204+
lambda.NewHandler(Handler16)
189205
lambda.NewHandler(func(ctx context.Context, event Event) (*Response, error) {
190206
sink(ctx) // safe
191207
sink(event.Name) // $ hasTaintFlow="selection of Name"
192208
sink(event.Age) // $ hasTaintFlow="selection of Age"
193209
sink(event) // $ hasTaintFlow="event"
194210
return &Response{Message: ""}, nil
195211
})
196-
lambda.NewHandlerWithOptions(Handler16)
212+
lambda.NewHandlerWithOptions(Handler17)
197213
lambda.NewHandlerWithOptions(func(ctx context.Context, event Event) (*Response, error) {
198214
sink(ctx) // safe
199215
sink(event.Name) // $ hasTaintFlow="selection of Name"

go/ql/test/library-tests/semmle/go/frameworks/AwsLambda/vendor/github.com/aws/aws-lambda-go/lambda/stub.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)