Skip to content

Commit 1635ef9

Browse files
committed
Merge branch 'main' into convert
2 parents 3a03bb5 + f4388c8 commit 1635ef9

File tree

24 files changed

+1058
-257
lines changed

24 files changed

+1058
-257
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ node_modules/
7676
# some upgrade/downgrade checks create these files
7777
**/upgrades/*/*.dbscheme.stats
7878
**/downgrades/*/*.dbscheme.stats
79+
80+
# Mergetool files
81+
*.orig

docs/codeql/codeql-overview/codeql-changelog/codeql-cli-2.23.1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Golang
126126
""""""
127127

128128
* The second argument of the :code:`CreateTemp` function, from the :code:`os` package, is no longer a path-injection sink due to proper sanitization by Go.
129-
* The query "Uncontrolled data used in path expression" (:code:`go/path-injection`) now detects sanitizing a path by adding :code:`os.PathSeparator` or :code:`\ ` to the beginning.
129+
* The query "Uncontrolled data used in path expression" (:code:`go/path-injection`) now detects sanitizing a path by adding :code:`os.PathSeparator` or :code:``\`` to the beginning.
130130

131131
Java/Kotlin
132132
"""""""""""

javascript/ql/src/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Data flow is now tracked through the `Promise.try` and `Array.prototype.with` functions.
1111
* Query `js/index-out-of-bounds` no longer produces a false-positive when a strictly-less-than check overrides a previous less-than-or-equal test.
1212
* The query `js/remote-property-injection` now detects property injection vulnerabilities through object enumeration patterns such as `Object.keys()`.
13-
* The query "Permissive CORS configuration" (`js/cors-permissive-configuration`) has been promoted from experimental and is now part of the default security suite.
13+
* The query "Permissive CORS configuration" (`js/cors-permissive-configuration`) has been promoted from experimental and is now part of the default security suite. Thank you to @maikypedia who [submitted the original experimental query](https://github.com/github/codeql/pull/14342)!
1414

1515
## 2.0.3
1616

javascript/ql/src/change-notes/released/2.1.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
* Data flow is now tracked through the `Promise.try` and `Array.prototype.with` functions.
1111
* Query `js/index-out-of-bounds` no longer produces a false-positive when a strictly-less-than check overrides a previous less-than-or-equal test.
1212
* The query `js/remote-property-injection` now detects property injection vulnerabilities through object enumeration patterns such as `Object.keys()`.
13-
* The query "Permissive CORS configuration" (`js/cors-permissive-configuration`) has been promoted from experimental and is now part of the default security suite.
13+
* The query "Permissive CORS configuration" (`js/cors-permissive-configuration`) has been promoted from experimental and is now part of the default security suite. Thank you to @maikypedia who [submitted the original experimental query](https://github.com/github/codeql/pull/14342)!

rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class CallableScopeTree extends StandardTree, PreOrderTree, PostOrderTree, Scope
7777

7878
override AstNode getChildNode(int i) {
7979
i = 0 and
80-
result = this.getParamList().getSelfParam()
80+
result = this.getSelfParam()
8181
or
8282
result = this.getParam(i - 1)
8383
or

rust/ql/lib/codeql/rust/elements/internal/CallImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ module Impl {
102102
f = resolvePath(path) and
103103
path.getSegment().getIdentifier().getText() = methodName and
104104
exists(SelfParam self |
105-
self = f.getParamList().getSelfParam() and
105+
self = f.getSelfParam() and
106106
if self.isRef() then selfIsRef = true else selfIsRef = false
107107
)
108108
)

rust/ql/lib/codeql/rust/elements/internal/CallableImpl.qll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,25 @@ module Impl {
1717
*/
1818
class Callable extends Generated::Callable {
1919
override Param getParam(int index) { result = this.getParamList().getParam(index) }
20+
21+
/**
22+
* Gets the self parameter of this callable, if it exists.
23+
*/
24+
SelfParam getSelfParam() { result = this.getParamList().getSelfParam() }
25+
26+
/**
27+
* Holds if `getSelfParam()` exists.
28+
*/
29+
predicate hasSelfParam() { exists(this.getSelfParam()) }
30+
31+
/**
32+
* Gets the number of parameters of this callable, including `self` if it exists.
33+
*/
34+
int getNumberOfParamsInclSelf() {
35+
exists(int arr |
36+
arr = this.getNumberOfParams() and
37+
if this.hasSelfParam() then result = arr + 1 else result = arr
38+
)
39+
}
2040
}
2141
}

rust/ql/lib/codeql/rust/elements/internal/UnionImpl.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ module Impl {
2121
* ```
2222
*/
2323
class Union extends Generated::Union {
24+
/** Gets the struct field named `name`, if any. */
25+
pragma[nomagic]
26+
StructField getStructField(string name) {
27+
result = this.getStructFieldList().getAField() and
28+
result.getName().getText() = name
29+
}
30+
2431
override string toStringImpl() { result = "union " + this.getName().getText() }
2532
}
2633
}

rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module Impl {
109109
text = name.getText() and
110110
// exclude self parameters from functions without a body as these are
111111
// trait method declarations without implementations
112-
not exists(Function f | not f.hasBody() and f.getParamList().getSelfParam() = sp)
112+
not exists(Function f | not f.hasBody() and f.getSelfParam() = sp)
113113
)
114114
or
115115
exists(IdentPat pat |

rust/ql/lib/codeql/rust/internal/PathResolution.qll

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
private import rust
66
private import codeql.rust.elements.internal.generated.ParentChild
7+
private import codeql.rust.elements.internal.CallExprImpl::Impl as CallExprImpl
78
private import codeql.rust.internal.CachedStages
89
private import codeql.rust.frameworks.stdlib.Builtins as Builtins
910
private import codeql.util.Option
@@ -604,7 +605,13 @@ private class EnumItemNode extends TypeItemNode instanceof Enum {
604605
}
605606
}
606607

607-
private class VariantItemNode extends ItemNode instanceof Variant {
608+
/** An item that can be referenced with arguments. */
609+
abstract class ParameterizableItemNode extends ItemNode {
610+
/** Gets the arity this item. */
611+
abstract int getArity();
612+
}
613+
614+
private class VariantItemNode extends ParameterizableItemNode instanceof Variant {
608615
override string getName() { result = Variant.super.getName().getText() }
609616

610617
override Namespace getNamespace() {
@@ -617,6 +624,8 @@ private class VariantItemNode extends ItemNode instanceof Variant {
617624

618625
override Visibility getVisibility() { result = super.getEnum().getVisibility() }
619626

627+
override int getArity() { result = super.getFieldList().(TupleFieldList).getNumberOfFields() }
628+
620629
override predicate hasCanonicalPath(Crate c) { this.hasCanonicalPathPrefix(c) }
621630

622631
bindingset[c]
@@ -638,7 +647,7 @@ private class VariantItemNode extends ItemNode instanceof Variant {
638647
}
639648
}
640649

641-
class FunctionItemNode extends AssocItemNode instanceof Function {
650+
class FunctionItemNode extends AssocItemNode, ParameterizableItemNode instanceof Function {
642651
override string getName() { result = Function.super.getName().getText() }
643652

644653
override predicate hasImplementation() { Function.super.hasImplementation() }
@@ -648,6 +657,8 @@ class FunctionItemNode extends AssocItemNode instanceof Function {
648657
override TypeParam getTypeParam(int i) { result = super.getGenericParamList().getTypeParam(i) }
649658

650659
override Visibility getVisibility() { result = Function.super.getVisibility() }
660+
661+
override int getArity() { result = super.getNumberOfParamsInclSelf() }
651662
}
652663

653664
abstract class ImplOrTraitItemNode extends ItemNode {
@@ -712,8 +723,10 @@ final class ImplItemNode extends ImplOrTraitItemNode instanceof Impl {
712723
TypeParamItemNode getBlanketImplementationTypeParam() { result = this.resolveSelfTy() }
713724

714725
/**
715-
* Holds if this impl block is a blanket implementation. That is, the
726+
* Holds if this impl block is a [blanket implementation][1]. That is, the
716727
* implementation targets a generic parameter of the impl block.
728+
*
729+
* [1]: https://doc.rust-lang.org/book/ch10-02-traits.html#using-trait-bounds-to-conditionally-implement-methods
717730
*/
718731
predicate isBlanketImplementation() { exists(this.getBlanketImplementationTypeParam()) }
719732

@@ -865,7 +878,7 @@ private class ImplItemNodeImpl extends ImplItemNode {
865878
TraitItemNode resolveTraitTyCand() { result = resolvePathCand(this.getTraitPath()) }
866879
}
867880

868-
private class StructItemNode extends TypeItemNode instanceof Struct {
881+
private class StructItemNode extends TypeItemNode, ParameterizableItemNode instanceof Struct {
869882
override string getName() { result = Struct.super.getName().getText() }
870883

871884
override Namespace getNamespace() {
@@ -877,6 +890,8 @@ private class StructItemNode extends TypeItemNode instanceof Struct {
877890

878891
override Visibility getVisibility() { result = Struct.super.getVisibility() }
879892

893+
override int getArity() { result = super.getFieldList().(TupleFieldList).getNumberOfFields() }
894+
880895
override TypeParam getTypeParam(int i) { result = super.getGenericParamList().getTypeParam(i) }
881896

882897
override predicate hasCanonicalPath(Crate c) { this.hasCanonicalPathPrefix(c) }
@@ -1687,6 +1702,14 @@ private ItemNode resolvePathCand(RelevantPath path) {
16871702
or
16881703
not pathUsesNamespace(path, _) and
16891704
not path = any(MacroCall mc).getPath()
1705+
) and
1706+
(
1707+
not path = CallExprImpl::getFunctionPath(_)
1708+
or
1709+
exists(CallExpr ce |
1710+
path = CallExprImpl::getFunctionPath(ce) and
1711+
result.(ParameterizableItemNode).getArity() = ce.getNumberOfArgs()
1712+
)
16901713
)
16911714
}
16921715

0 commit comments

Comments
 (0)