mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
6.2 KiB
6.2 KiB
Improvements to C# analysis
General improvements
- Control flow analysis has been improved for
catchclauses with filters.
New queries
| Query | Tags | Purpose |
|---|---|---|
Arbitrary file write during zip extraction ("Zip Slip") (cs/zipslip) |
security, external/cwe/cwe-022 | Identifies zip extraction routines which allow arbitrary file overwrite vulnerabilities. |
Local scope variable shadows member (cs/local-shadows-member) |
maintainability, readability | Replaces the existing queries Local variable shadows class member (cs/local-shadows-class-member), Local variable shadows struct member (cs/local-shadows-struct-member), Parameter shadows class member (cs/parameter-shadows-class-member), and Parameter shadows struct member (cs/parameter-shadows-struct-member). |
Changes to existing queries
| Query | Expected impact | Change |
|---|---|---|
Constant condition (cs/constant-condition) |
More results | The query has been generalized to report alerts for the old queries Null-coalescing left operand is constant (cs/constant-null-coalescing) and Switch selector is constant (cs/constant-switch-selector). |
Exposing internal representation (cs/expose-implementation) |
Different results | The query has been rewritten, based on the equivalent Java query. |
Local variable shadows class member (cs/local-shadows-class-member) |
No results | The query has been replaced by the new query: Local scope variable shadows member (cs/local-shadows-member). |
Local variable shadows struct member (cs/local-shadows-struct-member) |
No results | The query has been replaced by the new query: Local scope variable shadows member (cs/local-shadows-member). |
Missing Dispose call on local IDisposable (cs/local-not-disposed) |
Fewer false positive results | The query identifies more cases where the local variable may be disposed by a library call. |
Nested loops with same variable (cs/nested-loops-with-same-variable) |
Fewer false positive results | Results are no longer highlighted in nested loops that share the same condition, and do not use the variable after the inner loop. |
Null-coalescing left operand is constant (cs/constant-null-coalescing) |
No results | The query has been removed, as alerts for this problem are now reported by the new query: Constant condition (cs/constant-condition). |
Parameter shadows class member (cs/parameter-shadows-class-member) |
No results | The query has been replaced by the new query: Local scope variable shadows member (cs/local-shadows-member). |
Parameter shadows struct member (cs/parameter-shadows-struct-member) |
No results | The query has been replaced by the new query: Local scope variable shadows member (cs/local-shadows-member). |
Potentially incorrect CompareTo(...) signature (cs/wrong-compareto-signature) |
Fewer false positive results | Results are no longer highlighted in constructed types. |
Switch selector is constant (cs/constant-switch-selector) |
No results | The query has been removed, as alerts for this problem are now reported by the new query: Constant condition (cs/constant-condition). |
Useless upcast (cs/useless-upcast) |
Fewer false positive results | The query has been improved to cover more cases where upcasts may be needed. |
Changes to code extraction
- The
intopart ofjoinclauses is now extracted. - The
whenpart of constant cases is now extracted. - Fixed a bug where
while(x is T y) ...was not extracted correctly.
Changes to QL libraries
- A new non-member predicate
mayBeDisposed()can be used to determine if a variable is potentially disposed inside a library. It will analyze the CIL code in the library to determine this. - The predicate
getCondition()has been moved fromTypeCasetoCaseStmt. It is now possible to get the condition of aConstCaseusing itsgetCondition()predicate. - Several control flow graph entities have been renamed (the old names are deprecated but are still available in this release for backwards compatibility):
ControlFlowNodehas been renamed toControlFlow::Node.CallableEntryNodehas been renamed toControlFlow::Nodes::EntryNode.CallableExitNodehas been renamed toControlFlow::Nodes::ExitNode.ControlFlowEdgeTypehas been renamed toControlFlow::SuccessorType.ControlFlowEdgeSuccessorhas been renamed toControlFlow::SuccessorTypes::NormalSuccessor.ControlFlowEdgeConditionalhas been renamed toControlFlow::SuccessorTypes::ConditionalSuccessor.ControlFlowEdgeBooleanhas been renamed toControlFlow::SuccessorTypes::BooleanSuccessor.ControlFlowEdgeNullnesshas been renamed toControlFlow::SuccessorTypes::NullnessSuccessor.ControlFlowEdgeMatchinghas been renamed toControlFlow::SuccessorTypes::MatchingSuccessor.ControlFlowEdgeEmptinesshas been renamed toControlFlow::SuccessorTypes::EmptinessSuccessor.ControlFlowEdgeReturnhas been renamed toControlFlow::SuccessorTypes::ReturnSuccessor.ControlFlowEdgeBreakhas been renamed toControlFlow::SuccessorTypes::BreakSuccessor.ControlFlowEdgeContinuehas been renamed toControlFlow::SuccessorTypes::ContinueSuccessor.ControlFlowEdgeGotoLabelhas been renamed toControlFlow::SuccessorTypes::GotoLabelSuccessor.ControlFlowEdgeGotoCasehas been renamed toControlFlow::SuccessorTypes::GotoCaseSuccessor.ControlFlowEdgeGotoDefaulthas been renamed toControlFlow::SuccessorTypes::GotoDefaultSuccessor.ControlFlowEdgeExceptionhas been renamed toControlFlow::SuccessorTypes::ExceptionSuccessor.
You should update any custom queries that use these entities to ensure that they continue working when the old names are removed in a future release.