| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
There are two lost results for go/ql/src/InconsistentCode/UnhandledCloseWritableHandle.ql on go/ql/test/query-tests/InconsistentCode/UnhandledCloseWritableHandle/tests.go. They have the exact same cause: in the following function func closeFileDeferredIndirect(f *os.File) {
var cont = func() {
f.Close() // NOT OK, if `f` is writable
}
defer cont()
}we don't have flow from capture variable f in the function literal to the use of f in f.Close(). This flow used to be caught by this disjunct in basicLocalFlowStep: // SSA -> Instruction
exists(SsaDefinition pred, IR::Instruction succ |
succ = pred.getVariable().getAUse() and
nodeFrom = ssaNode(pred) and
nodeTo = instructionNode(succ)
)but now that has changed to: // SSA defn -> first SSA use
exists(SsaExplicitDefinition pred, IR::Instruction succ | succ = pred.getAFirstUse() |
nodeFrom = ssaNode(pred) and
nodeTo = instructionNode(succ)
)
or
// SSA use -> successive SSA use
// Note this case includes Phi node traversal
exists(IR::Instruction pred, IR::Instruction succ | succ = getAnAdjacentUse(pred) |
nodeFrom = instructionNode(pred) and
nodeTo = instructionNode(succ)
)capture variable f is an SsaImplicitDefinition rather than an SsaExplicitDefinition, so the first of these disjuncts doesn't catch it. I am not sure which of these disjuncts should be amended to capture this flow. |
Sorry, something went wrong.
|
Presumably this is because of switching from SsaDefinition to SsaExplicitDefintion, I suppose with intent to exclude phi nodes, but also excluding SsaVariableCapture by mistake. |
Sorry, something went wrong.
|
DCA showed a few extra alerts, which I've pushed a commit to fix, and perhaps a very slight increase in analysis time. |
Sorry, something went wrong.
|
I have just rebased this and fixed new test failures. DCA shows no significant performance change. There are three lost cleartext-logging results on one repo, which have the same source and sinks right next to each other, so there is probably one cause. I looked into it for a while and didn't see the problem. |
Sorry, something went wrong.
|
Rebased again and ran DCA. The same alerts were lost as last time. This run might show a slight performance regression, about 3%, most notably on the two largest projects. I will do a QA run to test performance more thoroughly and see if there are more alert regressions (which might be easier to debug than the ones in DCA). |
Sorry, something went wrong.
There was a problem hiding this comment.
This pull request switches the Go dataflow analysis from a def-use flow model to a use-use flow model. This is a significant architectural change that affects how taint and dataflow propagation is tracked throughout the codebase.
Key changes:
Copilot reviewed 106 out of 106 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Test files (.go) | Added intermediate variable copies and comments explaining sanitization flow issues |
| Expected test files (.expected) | Updated to reflect new flow model with [postupdate] annotations and adjusted line numbers |
Sorry, something went wrong.
|
@smowton Do you think you'll have a chance to review this this week? I'm happy to talk you through it, or answer any questions. Obviously the changes to QL code are more important to review than the test changes, so I'd focus your attention there. Note that the commit history starts by doing everything needed to get tests passing and DCA and QA good for use-use flow and then making proper post-update nodes and doing the same again. So it is clear whether a test change is due to use-use flow or proper post-update nodes. The most recent DCA run:
The most recent QA run (I haven't finished going through the alert changes):
|
Sorry, something went wrong.
This can be easily expressed in terms of `WriteNode.writesFieldPreUpdate`.
When tracing back from nil checks on interfaces, ignore post-update nodes. There will always be a corresponding pre-update node that contains the information we want.
|
@smowton The latest QA run looks good. When I looked into two lost results for go/impossible-interface-nil-check and I realised that it needs a small fix, which I've added. It's only a quality query, so I don't think we need to redo QA or anything. I've also update the change note to include a bug I incidentally fixed during the refactor. I think this is ready to merge. |
Sorry, something went wrong.
There was a problem hiding this comment.
Haven't re-reviewed
Sorry, something went wrong.
| rewindReads(bb, i, v) = 1 and result = getDefReachingEndOf(bb.getImmediateDominator(), v) | ||
| } | ||
|
|
||
| private module AdjacentUsesImpl { |
There was a problem hiding this comment.
Was it not possible to use the shared SSA library?
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is a resurrection of github/codeql-go#460. Rebasing seems to have gone okay. There are more test changes. I am currently going through them to see if they are expected or if they indicate that something need to change.