From cbbf7c2578bafccd20bf430e235e20378df63beb Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Thu, 11 Sep 2025 11:22:17 +0100 Subject: [PATCH 1/4] Include pre-update node in output --- .../go/dataflow/PostUpdateNodes/test.expected | 33 ++++++++++--------- .../go/dataflow/PostUpdateNodes/test.ql | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected index 5ee74a7cde4a..16a9cd0d1975 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected +++ b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected @@ -1,15 +1,18 @@ -| test.go:19:2:19:2 | definition of a | -| test.go:20:11:20:14 | &... | -| test.go:20:12:20:14 | selection of b | -| test.go:21:2:21:5 | selection of bs | -| test.go:21:2:21:8 | index expression | -| test.go:21:17:21:20 | &... | -| test.go:21:18:21:20 | struct literal | -| test.go:22:2:22:5 | selection of bs | -| test.go:22:2:22:8 | index expression | -| test.go:22:2:22:13 | implicit dereference | -| test.go:22:2:22:13 | selection of cptr | -| test.go:23:2:23:7 | implicit dereference | -| test.go:23:2:23:7 | selection of bptr | -| test.go:23:2:23:12 | implicit dereference | -| test.go:23:2:23:12 | selection of cptr | +| test.go:19:2:19:2 | definition of a | test.go:20:2:20:2 | a | +| test.go:19:2:19:2 | definition of a | test.go:21:2:21:2 | a | +| test.go:19:2:19:2 | definition of a | test.go:22:2:22:2 | a | +| test.go:19:2:19:2 | definition of a | test.go:23:2:23:2 | a | +| test.go:20:11:20:14 | &... | test.go:20:11:20:14 | &... | +| test.go:20:12:20:14 | selection of b | test.go:20:12:20:14 | selection of b | +| test.go:21:2:21:5 | selection of bs | test.go:21:2:21:5 | selection of bs | +| test.go:21:2:21:8 | index expression | test.go:21:2:21:8 | index expression | +| test.go:21:17:21:20 | &... | test.go:21:17:21:20 | &... | +| test.go:21:18:21:20 | struct literal | test.go:21:18:21:20 | struct literal | +| test.go:22:2:22:5 | selection of bs | test.go:22:2:22:5 | selection of bs | +| test.go:22:2:22:8 | index expression | test.go:22:2:22:8 | index expression | +| test.go:22:2:22:13 | implicit dereference | test.go:22:2:22:13 | implicit dereference | +| test.go:22:2:22:13 | selection of cptr | test.go:22:2:22:13 | selection of cptr | +| test.go:23:2:23:7 | implicit dereference | test.go:23:2:23:7 | implicit dereference | +| test.go:23:2:23:7 | selection of bptr | test.go:23:2:23:7 | selection of bptr | +| test.go:23:2:23:12 | implicit dereference | test.go:23:2:23:12 | implicit dereference | +| test.go:23:2:23:12 | selection of cptr | test.go:23:2:23:12 | selection of cptr | diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.ql b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.ql index 384b3346431c..ca2a9c5980b5 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.ql +++ b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.ql @@ -1,4 +1,4 @@ import go from DataFlow::PostUpdateNode pun -select pun +select pun, pun.getPreUpdateNode() From fa18fd2782b83c6d9ca9322218db95ad4c832b08 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Thu, 11 Sep 2025 11:24:53 +0100 Subject: [PATCH 2/4] Add method defs --- .../go/dataflow/PostUpdateNodes/test.expected | 37 ++++++++++--------- .../go/dataflow/PostUpdateNodes/test.go | 3 ++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected index 16a9cd0d1975..b50d556ba9de 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected +++ b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected @@ -1,18 +1,19 @@ -| test.go:19:2:19:2 | definition of a | test.go:20:2:20:2 | a | -| test.go:19:2:19:2 | definition of a | test.go:21:2:21:2 | a | -| test.go:19:2:19:2 | definition of a | test.go:22:2:22:2 | a | -| test.go:19:2:19:2 | definition of a | test.go:23:2:23:2 | a | -| test.go:20:11:20:14 | &... | test.go:20:11:20:14 | &... | -| test.go:20:12:20:14 | selection of b | test.go:20:12:20:14 | selection of b | -| test.go:21:2:21:5 | selection of bs | test.go:21:2:21:5 | selection of bs | -| test.go:21:2:21:8 | index expression | test.go:21:2:21:8 | index expression | -| test.go:21:17:21:20 | &... | test.go:21:17:21:20 | &... | -| test.go:21:18:21:20 | struct literal | test.go:21:18:21:20 | struct literal | -| test.go:22:2:22:5 | selection of bs | test.go:22:2:22:5 | selection of bs | -| test.go:22:2:22:8 | index expression | test.go:22:2:22:8 | index expression | -| test.go:22:2:22:13 | implicit dereference | test.go:22:2:22:13 | implicit dereference | -| test.go:22:2:22:13 | selection of cptr | test.go:22:2:22:13 | selection of cptr | -| test.go:23:2:23:7 | implicit dereference | test.go:23:2:23:7 | implicit dereference | -| test.go:23:2:23:7 | selection of bptr | test.go:23:2:23:7 | selection of bptr | -| test.go:23:2:23:12 | implicit dereference | test.go:23:2:23:12 | implicit dereference | -| test.go:23:2:23:12 | selection of cptr | test.go:23:2:23:12 | selection of cptr | +| file://:0:0:0:0 | [summary] to write: Argument[0] in copy | file://:0:0:0:0 | [summary param] 0 in copy | +| test.go:22:2:22:2 | definition of a | test.go:23:2:23:2 | a | +| test.go:22:2:22:2 | definition of a | test.go:24:2:24:2 | a | +| test.go:22:2:22:2 | definition of a | test.go:25:2:25:2 | a | +| test.go:22:2:22:2 | definition of a | test.go:26:2:26:2 | a | +| test.go:23:11:23:14 | &... | test.go:23:11:23:14 | &... | +| test.go:23:12:23:14 | selection of b | test.go:23:12:23:14 | selection of b | +| test.go:24:2:24:5 | selection of bs | test.go:24:2:24:5 | selection of bs | +| test.go:24:2:24:8 | index expression | test.go:24:2:24:8 | index expression | +| test.go:24:17:24:20 | &... | test.go:24:17:24:20 | &... | +| test.go:24:18:24:20 | struct literal | test.go:24:18:24:20 | struct literal | +| test.go:25:2:25:5 | selection of bs | test.go:25:2:25:5 | selection of bs | +| test.go:25:2:25:8 | index expression | test.go:25:2:25:8 | index expression | +| test.go:25:2:25:13 | implicit dereference | test.go:25:2:25:13 | implicit dereference | +| test.go:25:2:25:13 | selection of cptr | test.go:25:2:25:13 | selection of cptr | +| test.go:26:2:26:7 | implicit dereference | test.go:26:2:26:7 | implicit dereference | +| test.go:26:2:26:7 | selection of bptr | test.go:26:2:26:7 | selection of bptr | +| test.go:26:2:26:12 | implicit dereference | test.go:26:2:26:12 | implicit dereference | +| test.go:26:2:26:12 | selection of cptr | test.go:26:2:26:12 | selection of cptr | diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go index f9d4b3d8e65d..83dbecf1d216 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go +++ b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go @@ -4,6 +4,9 @@ type C struct { field int } +func (c C) m(a A) {} +func (c *C) mp(a A) {} + type B struct { cptr *C } From 84e70e166e0660aca47b6002b6bc9a1afef1ab6a Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Thu, 11 Sep 2025 11:27:56 +0100 Subject: [PATCH 3/4] Add direct method calls --- .../semmle/go/dataflow/PostUpdateNodes/test.expected | 5 +++++ .../library-tests/semmle/go/dataflow/PostUpdateNodes/test.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected index b50d556ba9de..5243c3816ec7 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected +++ b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected @@ -3,6 +3,8 @@ | test.go:22:2:22:2 | definition of a | test.go:24:2:24:2 | a | | test.go:22:2:22:2 | definition of a | test.go:25:2:25:2 | a | | test.go:22:2:22:2 | definition of a | test.go:26:2:26:2 | a | +| test.go:22:2:22:2 | definition of a | test.go:29:6:29:6 | a | +| test.go:22:2:22:2 | definition of a | test.go:30:7:30:7 | a | | test.go:23:11:23:14 | &... | test.go:23:11:23:14 | &... | | test.go:23:12:23:14 | selection of b | test.go:23:12:23:14 | selection of b | | test.go:24:2:24:5 | selection of bs | test.go:24:2:24:5 | selection of bs | @@ -17,3 +19,6 @@ | test.go:26:2:26:7 | selection of bptr | test.go:26:2:26:7 | selection of bptr | | test.go:26:2:26:12 | implicit dereference | test.go:26:2:26:12 | implicit dereference | | test.go:26:2:26:12 | selection of cptr | test.go:26:2:26:12 | selection of cptr | +| test.go:28:2:28:2 | definition of c | test.go:29:2:29:2 | c | +| test.go:28:2:28:2 | definition of c | test.go:30:2:30:2 | c | +| test.go:28:7:28:10 | struct literal | test.go:28:7:28:10 | struct literal | diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go index 83dbecf1d216..cc27c97fe47e 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go +++ b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go @@ -25,4 +25,8 @@ func f() { a.bs[3].cptr.field = 100 a.bptr.cptr.field = 101 + c := C{0} + c.m(a) + c.mp(a) + } From d9e7c89af0ef556d1863d02bd67c5f9ca695fa31 Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Thu, 11 Sep 2025 11:28:55 +0100 Subject: [PATCH 4/4] Add indirect method calls --- .../semmle/go/dataflow/PostUpdateNodes/test.expected | 2 ++ .../library-tests/semmle/go/dataflow/PostUpdateNodes/test.go | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected index 5243c3816ec7..9f29e364be9a 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected +++ b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.expected @@ -5,6 +5,8 @@ | test.go:22:2:22:2 | definition of a | test.go:26:2:26:2 | a | | test.go:22:2:22:2 | definition of a | test.go:29:6:29:6 | a | | test.go:22:2:22:2 | definition of a | test.go:30:7:30:7 | a | +| test.go:22:2:22:2 | definition of a | test.go:35:4:35:4 | a | +| test.go:22:2:22:2 | definition of a | test.go:36:5:36:5 | a | | test.go:23:11:23:14 | &... | test.go:23:11:23:14 | &... | | test.go:23:12:23:14 | selection of b | test.go:23:12:23:14 | selection of b | | test.go:24:2:24:5 | selection of bs | test.go:24:2:24:5 | selection of bs | diff --git a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go index cc27c97fe47e..3cb8656b96dd 100644 --- a/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go +++ b/go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/test.go @@ -29,4 +29,9 @@ func f() { c.m(a) c.mp(a) + // Indirect method calls - missing post-update nodes for the receivers + f := c.m + fp := c.mp + f(a) + fp(a) }