- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.8k
Go: Switch from def-use flow to use-use flow #14751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            64 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      16a11b4
              
                Switch to use-use dataflow. This will make post-update nodes easy to …
              
              
                owen-mc 4484d5b
              
                Add missing QLDoc
              
              
                owen-mc 5267671
              
                Clean up code in basicLocalFlowStep
              
              
                owen-mc b474315
              
                Include first step from SsaVariableCapture
              
              
                owen-mc 49b8b0b
              
                Remove local flow step from SSA defn to SSA capture
              
              
                owen-mc 4e04d27
              
                Adjust SafeFormatArgumentSanitizer to use-use flow
              
              
                owen-mc b2a9cec
              
                Fix Allocation Size Overflow for use-use flow
              
              
                owen-mc 9068315
              
                Fix IncorrectIntegerConversion for use-use flow
              
              
                owen-mc a3eb010
              
                Optimise join order for varBlockReaches
              
              
                smowton 32de211
              
                Use `_` instead of exists variable x2
              
              
                owen-mc 3594dba
              
                Make insecure randomness test more realistic
              
              
                owen-mc 5210665
              
                Test result that was missing is now found
              
              
                owen-mc c20abf6
              
                Line numbers change because 3 lines were added
              
              
                owen-mc 14301e0
              
                Expected changes in dataflow edges
              
              
                owen-mc d13d717
              
                Fix QLDoc typo
              
              
                owen-mc 7a515c1
              
                Pull out post-update node logic into predicate
              
              
                owen-mc c8b8e25
              
                Convert post-update logic to IR (part 1)
              
              
                owen-mc 203952f
              
                Convert post-update logic to IR (part 2)
              
              
                owen-mc ad18018
              
                Implement `writesComponent` at IR level
              
              
                owen-mc 05a16dc
              
                Convert post-update logic to IR (part 3)
              
              
                owen-mc 89ae0e3
              
                Inline predicate only used once
              
              
                owen-mc 9892836
              
                Switch order of PUN test output
              
              
                owen-mc a0c647c
              
                Add Email Injection tests for reverse flow models
              
              
                owen-mc 118def8
              
                Make separate post-update nodes
              
              
                owen-mc d2230c5
              
                Expected changes in test output
              
              
                owen-mc ac71f9c
              
                Expected change in test output
              
              
                owen-mc 3229630
              
                Make store step to send stmt's channel use post-update node
              
              
                owen-mc 8a3bd84
              
                Fix test expectations for Cleartext Logging
              
              
                owen-mc cf6cfe2
              
                Non-initializing writes should target post-update nodes
              
              
                owen-mc 748c53a
              
                Refactor: Create `writesFieldOnSsaWithFields`
              
              
                owen-mc 6215587
              
                Fix flow to variable capture
              
              
                owen-mc 3906f25
              
                Adjust Stack Exposure test so it passes
              
              
                owen-mc 5efc8ac
              
                Fix backwards flow through TaintTracking::FunctionModel
              
              
                owen-mc 6cb6953
              
                Add missing qldocs
              
              
                owen-mc a9420d4
              
                Fix bad join order
              
              
                owen-mc 52b6539
              
                Typo
              
              
                owen-mc f5f6d64
              
                Add change notes
              
              
                owen-mc 25f1823
              
                Fix email injection sink that needs local flow
              
              
                owen-mc 4ee236d
              
                Delete commented out code
              
              
                owen-mc 1d9a93a
              
                Rename helper predicate
              
              
                owen-mc b1bcbec
              
                Use slightly less confusing syntax
              
              
                owen-mc 630a844
              
                Rename confusing predicate and add qldoc
              
              
                owen-mc 7b42618
              
                Rephrase change note to avoid technical terms
              
              
                owen-mc 1144bb9
              
                Convert OpenUrlRedirect tests to InlineExpectations
              
              
                owen-mc 414bab1
              
                Add OpenUrlRedirect tests for Url.Host field
              
              
                owen-mc c9a2816
              
                Fix OpenUrlRedirect barrier for write to Url.Host
              
              
                owen-mc 489b843
              
                Add and use `WriteNode.writesFieldPreUpdate`
              
              
                owen-mc 2ffb638
              
                Delete `WriteNode.writesFieldOnSsaWithFields`
              
              
                owen-mc 6fcd358
              
                Fix pointer content store step for write to field of pointer dereference
              
              
                owen-mc 59e3c14
              
                Add and use `WriteNode.writesElementPreUpdate`
              
              
                owen-mc 8a21a4f
              
                Deprecate `WriteNode.writesComponent`
              
              
                owen-mc 620ae33
              
                Make SafeUrlFlow test more comprehensive (failing)
              
              
                owen-mc 6e4dbe8
              
                Fix SafeUrlFlow so test passes
              
              
                owen-mc 8b04d0a
              
                Convert SSRF tests to inline expectations tests
              
              
                owen-mc c9ce2c8
              
                Add test for assignment to Url.Host field
              
              
                owen-mc f0f5fc7
              
                Improve SSRF additional flow step
              
              
                owen-mc 6d6852f
              
                Test PathAssignmentBarrier for OpenUrlRedirect
              
              
                owen-mc c006777
              
                Simplify PathAssignmentBarrier
              
              
                owen-mc 2629369
              
                Improve additional flow step for Host field
              
              
                owen-mc 7fdda87
              
                Fix `go/impossible-interface-nil-check` for separate post-update nodes
              
              
                owen-mc d8891e3
              
                Small improvement to `go/unhandled-writable-file-close`
              
              
                owen-mc 4d48628
              
                Preserve old behaviour of `Write.writesComponent`
              
              
                owen-mc cce44b1
              
                Update change notes for api changes
              
              
                owen-mc f35d28d
              
                Change note for bug fix in `go/unvalidated-url-redirection`
              
              
                owen-mc File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| category: breaking | ||
| --- | ||
| * The member predicate `writesField` on `DataFlow::Write` now uses the post-update node for `base` when that is the node being updated, which is in all cases except initializing a struct literal. A new member predicate `writesFieldPreUpdate` has been added for cases where this behaviour is not desired. | ||
| * The member predicate `writesElement` on `DataFlow::Write` now uses the post-update node for `base` when that is the node being updated, which is in all cases except initializing an array/slice/map literal. A new member predicate `writesElementPreUpdate` has been added for cases where this behaviour is not desired. | 
        
          
  
    
      
          
            4 changes: 4 additions & 0 deletions
          
          4 
        
  go/ql/lib/change-notes/2025-09-19-use-use-flow-proper-post-update-nodes.md
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: majorAnalysis | ||
| --- | ||
| * The shape of the Go data-flow graph has changed. Previously for code like `x := def(); use1(x); use2(x)`, there would be edges from the definition of `x` to each use. Now there is an edge from the definition to the first use, then another from the first use to the second, and so on. This means that data-flow barriers work differently - flow will not reach any uses after the barrier node. Where this is not desired it may be be necessary to add an additional flow step to propagate the flow forward. Additionally, when a variable may be subject to a side-effect, such as updating an array, passing a pointer to a function that might write through it or writing to a field of a struct, there is now a dedicated post-update node representing the variable after this side-effect has taken place. Previously post-update nodes were aliases for either a variable's definition, or were equal to the pre-update node. This led to backwards steps in the data-flow graph, which could cause false positives. For example, in the previous code there would be an edge from `x` in `use2(x)` back to the definition of `x`. If we define our sources as any argument of `use2` and our sinks as any argument of `use1` then this would lead to a false positive path. Now there are distinct post-update nodes and no backwards edge to the definition, so we will not find this false positive path. | 
        
          
  
    
      
          
            4 changes: 4 additions & 0 deletions
          
          4 
        
  go/ql/lib/change-notes/2025-10-02-unvalidated-url-redirection-struct-init-fix.md
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: minorAnalysis | ||
| --- | ||
| * For the query `go/unvalidated-url-redirection`, when untrusted data is assigned to the `Host` field of a `url.URL` struct, we consider the whole struct untrusted. We now also include the case when this happens during struct initialization, for example `&url.URL{Host: untrustedData}`. | 
        
          
  
    
      
          
            4 changes: 4 additions & 0 deletions
          
          4 
        
  go/ql/lib/change-notes/2025-10-02-writenode-writescomponent-deprecated.md
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: deprecated | ||
| --- | ||
| * The member predicate `writesComponent` on `DataFlow::Write` has been deprecated. Instead, use `writesFieldPreUpdate` and `writesElementPreUpdate`, or their new versions `writesField` and `writesElement`. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it not possible to use the shared SSA library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got stuck trying to do that before, so since I had an almost-working implementation already I decided to get that merged and switch to the shared SSA library at some point in the future.