Skip to content

Commit 7a126a2

Browse files
authored
Merge branch 'github:main' into UnsafeUnpack
2 parents 8ef2aa0 + 6c0b50c commit 7a126a2

File tree

27 files changed

+447
-145
lines changed

27 files changed

+447
-145
lines changed

cpp/ql/test/library-tests/dataflow/taint-tests/localTaint.expected

Lines changed: 100 additions & 100 deletions
Large diffs are not rendered by default.

cpp/ql/test/library-tests/dataflow/taint-tests/standalone_iterators.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class int_iterator_by_trait {
2727
template<>
2828
struct std::iterator_traits<int_iterator_by_trait> {
2929
typedef input_iterator_tag iterator_category;
30+
typedef int value_type;
31+
typedef size_t difference_type;
32+
typedef int* pointer;
33+
typedef int& reference;
3034
};
3135

3236
class non_iterator {
@@ -69,6 +73,10 @@ class insert_iterator_by_trait {
6973
template<>
7074
struct std::iterator_traits<insert_iterator_by_trait> {
7175
typedef output_iterator_tag iterator_category;
76+
typedef int value_type;
77+
typedef size_t difference_type;
78+
typedef int* pointer;
79+
typedef int& reference;
7280
};
7381

7482
class container {

docs/codeql/writing-codeql-queries/metadata-for-codeql-queries.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The following properties are supported by all query files:
4545
| | | ``high`` | |
4646
| | | ``very-high`` | |
4747
+-----------------------+---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
48-
| ``@problem.severity`` | | ``error`` | Defines the level of severity of any alerts generated by a non-security query. This, along with the ``@precision`` property, determines how the results are displayed on GitHub. |
48+
| ``@problem.severity`` | | ``error`` | Defines the level of severity of any alerts generated by a non-security query. This, along with the ``@precision`` property, determines how the results are displayed on GitHub. For more information, see the `Query metadata style guide <https://github.com/github/codeql/blob/main/docs/query-metadata-style-guide.md>`__. |
4949
| | | ``warning`` | |
5050
| | | ``recommendation`` | |
5151
+-----------------------+---------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

go/extractor/util/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func GetPkgDir(pkgpath string, flags ...string) string {
170170
// DepErrors checks there are any errors resolving dependencies for `pkgpath`. It passes the `go
171171
// list` command the flags specified by `flags`.
172172
func DepErrors(pkgpath string, flags ...string) bool {
173-
out, err := runGoList("{{if .DepsErrors}}{{else}}error{{end}}", []string{pkgpath}, flags...)
173+
out, err := runGoList("{{if .DepsErrors}}error{{else}}{{end}}", []string{pkgpath}, flags...)
174174
if err != nil {
175175
// if go list failed, assume dependencies are broken
176176
return false

ruby/Cargo.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ruby/extractor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ clap = "3.0"
1616
tracing = "0.1"
1717
tracing-subscriber = { version = "0.3.3", features = ["env-filter"] }
1818
rayon = "1.5.0"
19-
num_cpus = "1.13.0"
19+
num_cpus = "1.14.0"
2020
regex = "1.7.1"
2121
encoding = "0.2"
2222
lazy_static = "1.4.0"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Access to headers stored in the `env` of Rack requests is now recognized as a source of remote input.

ruby/ql/lib/codeql/ruby/Frameworks.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ private import codeql.ruby.frameworks.ActiveSupport
1616
private import codeql.ruby.frameworks.Archive
1717
private import codeql.ruby.frameworks.Arel
1818
private import codeql.ruby.frameworks.GraphQL
19+
private import codeql.ruby.frameworks.Rack
1920
private import codeql.ruby.frameworks.Rails
2021
private import codeql.ruby.frameworks.Railties
2122
private import codeql.ruby.frameworks.Stdlib

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPublic.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,9 @@ class CallableNode extends ExprNode {
10021002
/** Gets the `n`th positional parameter. */
10031003
ParameterNode getParameter(int n) { this.getParameterPosition(result).isPositional(n) }
10041004

1005+
/** Gets the number of positional parameters of this callable. */
1006+
final int getNumberOfParameters() { result = count(this.getParameter(_)) }
1007+
10051008
/** Gets the keyword parameter of the given name. */
10061009
ParameterNode getKeywordParameter(string name) {
10071010
this.getParameterPosition(result).isKeyword(name)

ruby/ql/lib/codeql/ruby/frameworks/ActionController.qll

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -301,27 +301,39 @@ private module Request {
301301
override Http::Server::RequestInputKind getKind() { result = Http::Server::bodyInputKind() }
302302
}
303303

304-
/**
305-
* A method call on `request` which returns the rack env.
306-
* This is a hash containing all the information about the request. Values
307-
* under keys starting with `HTTP_` are user-controlled.
308-
*/
309-
private class EnvCall extends RequestMethodCall {
310-
EnvCall() { this.getMethodName() = ["env", "filtered_env"] }
311-
}
304+
private module Env {
305+
abstract private class Env extends DataFlow::LocalSourceNode { }
306+
307+
/**
308+
* A method call on `request` which returns the rack env.
309+
* This is a hash containing all the information about the request. Values
310+
* under keys starting with `HTTP_` are user-controlled.
311+
*/
312+
private class RequestEnvCall extends DataFlow::CallNode, Env {
313+
RequestEnvCall() { this.getMethodName() = ["env", "filtered_env"] }
314+
}
312315

313-
/**
314-
* A read of a user-controlled parameter from the request env.
315-
*/
316-
private class EnvHttpAccess extends DataFlow::CallNode, Http::Server::RequestInputAccess::Range {
317-
EnvHttpAccess() {
318-
this = any(EnvCall c).getAMethodCall("[]") and
319-
this.getArgument(0).getConstantValue().getString().regexpMatch("^HTTP_.+")
316+
private import codeql.ruby.frameworks.Rack
317+
318+
private class RackEnv extends Env {
319+
RackEnv() { this = any(Rack::AppCandidate app).getEnv().getALocalUse() }
320320
}
321321

322-
override Http::Server::RequestInputKind getKind() { result = Http::Server::headerInputKind() }
322+
/**
323+
* A read of a user-controlled parameter from the request env.
324+
*/
325+
private class EnvHttpAccess extends DataFlow::CallNode, Http::Server::RequestInputAccess::Range {
326+
EnvHttpAccess() {
327+
this = any(Env c).getAMethodCall("[]") and
328+
exists(string key | key = this.getArgument(0).getConstantValue().getString() |
329+
key.regexpMatch("^HTTP_.+") or key = "PATH_INFO"
330+
)
331+
}
323332

324-
override string getSourceType() { result = "ActionDispatch::Request#env[]" }
333+
override Http::Server::RequestInputKind getKind() { result = Http::Server::headerInputKind() }
334+
335+
override string getSourceType() { result = "ActionDispatch::Request#env[]" }
336+
}
325337
}
326338
}
327339

0 commit comments

Comments
 (0)