-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Delete dead code #8431
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
Delete dead code #8431
Conversation
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.
👍 Java
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.
JS 👍
Regarding this part of the PR: Why is codeql/javascript/ql/lib/semmle/javascript/security/dataflow/InsecureDownloadQuery.qll Lines 12 to 15 in 69353bb
A search for it only shows two results: https://cs.github.com/github/codeql?q=%22ConcreteSensitiveInsecureUrl%22 But for codeql/javascript/ql/lib/semmle/javascript/security/dataflow/ZipSlipQuery.qll Lines 13 to 16 in 6aad8d6
https://cs.github.com/github/codeql?q=%22ConcretePosixPath%22 Why is the first considered dead code, while the last is not? What am I missing? |
The first extends a non-abstract class, the second extends an abstract class. |
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.
C#/SsaImplCommon.qll
👍
@@ -189,12 +189,6 @@ module IO { | |||
} | |||
} | |||
|
|||
// "Direct" `IO` instances, i.e. cases where there is no more specific | |||
// subtype such as `File` | |||
private class IOInstanceStrict extends IOInstance { |
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.
@alexrford you added this class originally. Is its deadness unintentional?
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.
Yeah, I should have removed this as part of the refactoring in #8138
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.
Ok, cool. Just checking we're not deleting code that we want and is only dead because of a bug.
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.
C++ and QL 👍.
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.
👍 Ruby
* Holds if the SSA definition of `v` at `def` reaches uncertain SSA definition | ||
* `redef` in the same basic block, without crossing another SSA definition of `v`. | ||
*/ | ||
predicate ssaDefReachesUncertainDefWithinBlock( |
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.
Does this change preserve identical files?
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.
It does because all the identical files were modified :)
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.
Yes, the code is dead in all copies.
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.
... ah, and it looks like there's a PR check and it passed. :)
Python 👍 |
Deletes all dead code.
As found by a QL-for-QL query that attempts to overapproximate what code is alive.
Code is alive if:
from-where-select
or aquery predicate
imported by a.ql
file)..qll
file.DeadCodeQuery.qll
).Any code not marked as alive is dead, and is deleted by this PR.
No test or external code should be affected by this PR.
This PR is a followup to #8347, because I wanted to check if I had introduced dead code by deleting deprecations.
(I had not, the code was dead already).
There were some benign cases.
E.g. in the shared DataFlow library a lot of code is copy-pasted between stages, and not all the predicates are used in all the stages.
The dead code wasn't marked as unused by the CodeQL compiler for various reasons.
.ql
files that aren't used.The QL-for-QL code also contains predicate for detecting "unqueryable" code.
That is: code that cannot affect any query result (but it might be part of the public API).
I already found a bunch of interesting results using that code, but a QL-for-QL query needs more work to weed out benign results.