Skip to content

Commit 25fbd9c

Browse files
authored
Merge branch 'main' into python/rewrite-InsecureContextConfiguration
2 parents 072df5d + bdad847 commit 25fbd9c

File tree

97 files changed

+2324
-251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2324
-251
lines changed

cpp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Xunit;
22
using Semmle.Autobuild.Shared;
3+
using Semmle.Util;
34
using System.Collections.Generic;
45
using System;
56
using System.Linq;
@@ -75,6 +76,15 @@ int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory,
7576
throw new ArgumentException("Missing RunProcess " + pattern);
7677
}
7778

79+
int IBuildActions.RunProcess(string cmd, string args, string? workingDirectory, IDictionary<string, string>? env, BuildOutputHandler onOutput, BuildOutputHandler onError)
80+
{
81+
var ret = (this as IBuildActions).RunProcess(cmd, args, workingDirectory, env, out var stdout);
82+
83+
stdout.ForEach(line => onOutput(line));
84+
85+
return ret;
86+
}
87+
7888
public IList<string> DirectoryDeleteIn = new List<string>();
7989

8090
void IBuildActions.DirectoryDelete(string dir, bool recursive)
@@ -184,6 +194,15 @@ public void DownloadFile(string address, string fileName)
184194
if (!DownloadFiles.Contains((address, fileName)))
185195
throw new ArgumentException($"Missing DownloadFile, {address}, {fileName}");
186196
}
197+
198+
public IDiagnosticsWriter CreateDiagnosticsWriter(string filename) => new TestDiagnosticWriter();
199+
}
200+
201+
internal class TestDiagnosticWriter : IDiagnosticsWriter
202+
{
203+
public IList<DiagnosticMessage> Diagnostics { get; } = new List<DiagnosticMessage>();
204+
205+
public void AddEntry(DiagnosticMessage message) => this.Diagnostics.Add(message);
187206
}
188207

189208
/// <summary>
@@ -243,6 +262,7 @@ CppAutobuilder CreateAutoBuilder(bool isWindows,
243262
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_TRAP_DIR"] = "";
244263
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_SOURCE_ARCHIVE_DIR"] = "";
245264
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_ROOT"] = $@"C:\codeql\{codeqlUpperLanguage.ToLowerInvariant()}";
265+
Actions.GetEnvironmentVariable[$"CODEQL_EXTRACTOR_{codeqlUpperLanguage}_DIAGNOSTIC_DIR"] = "";
246266
Actions.GetEnvironmentVariable["CODEQL_JAVA_HOME"] = @"C:\codeql\tools\java";
247267
Actions.GetEnvironmentVariable["CODEQL_PLATFORM"] = "win64";
248268
Actions.GetEnvironmentVariable["SEMMLE_DIST"] = @"C:\odasa";

cpp/autobuilder/Semmle.Autobuild.Cpp/CppAutobuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Semmle.Autobuild.Shared;
2+
using Semmle.Util;
23

34
namespace Semmle.Autobuild.Cpp
45
{
@@ -21,7 +22,7 @@ public CppAutobuildOptions(IBuildActions actions) : base(actions)
2122

2223
public class CppAutobuilder : Autobuilder<CppAutobuildOptions>
2324
{
24-
public CppAutobuilder(IBuildActions actions, CppAutobuildOptions options) : base(actions, options) { }
25+
public CppAutobuilder(IBuildActions actions, CppAutobuildOptions options) : base(actions, options, new DiagnosticClassifier()) { }
2526

2627
public override BuildScript GetBuildScript()
2728
{

cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,17 @@ module Impl<FullStateConfigSig Config> {
959959
not inBarrier(p)
960960
}
961961

962+
/**
963+
* Gets an additional term that is added to `branch` and `join` when deciding whether
964+
* the amount of forward or backward branching is within the limit specified by the
965+
* configuration.
966+
*/
967+
pragma[nomagic]
968+
private int getLanguageSpecificFlowIntoCallNodeCand1(ArgNodeEx arg, ParamNodeEx p) {
969+
flowIntoCallNodeCand1(_, arg, p) and
970+
result = getAdditionalFlowIntoCallNodeTerm(arg.projectToNode(), p.projectToNode())
971+
}
972+
962973
/**
963974
* Gets the amount of forward branching on the origin of a cross-call path
964975
* edge in the graph of paths between sources and sinks that ignores call
@@ -968,6 +979,7 @@ module Impl<FullStateConfigSig Config> {
968979
private int branch(NodeEx n1) {
969980
result =
970981
strictcount(NodeEx n | flowOutOfCallNodeCand1(_, n1, _, n) or flowIntoCallNodeCand1(_, n1, n))
982+
+ sum(ParamNodeEx p1 | | getLanguageSpecificFlowIntoCallNodeCand1(n1, p1))
971983
}
972984

973985
/**
@@ -979,6 +991,7 @@ module Impl<FullStateConfigSig Config> {
979991
private int join(NodeEx n2) {
980992
result =
981993
strictcount(NodeEx n | flowOutOfCallNodeCand1(_, n, _, n2) or flowIntoCallNodeCand1(_, n, n2))
994+
+ sum(ArgNodeEx arg2 | | getLanguageSpecificFlowIntoCallNodeCand1(arg2, n2))
982995
}
983996

984997
/**

cpp/ql/lib/experimental/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,3 +565,12 @@ private class MyConsistencyConfiguration extends Consistency::ConsistencyConfigu
565565
any()
566566
}
567567
}
568+
569+
/**
570+
* Gets an additional term that is added to the `join` and `branch` computations to reflect
571+
* an additional forward or backwards branching factor that is not taken into account
572+
* when calculating the (virtual) dispatch cost.
573+
*
574+
* Argument `arg` is part of a path from a source to a sink, and `p` is the target parameter.
575+
*/
576+
int getAdditionalFlowIntoCallNodeTerm(ArgumentNode arg, ParameterNode p) { none() }

cpp/ql/lib/semmle/code/cpp/Declaration.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Declaration extends Locatable, @declaration {
186186
predicate hasDefinition() { exists(this.getDefinition()) }
187187

188188
/** DEPRECATED: Use `hasDefinition` instead. */
189-
predicate isDefined() { this.hasDefinition() }
189+
deprecated predicate isDefined() { this.hasDefinition() }
190190

191191
/** Gets the preferred location of this declaration, if any. */
192192
override Location getLocation() { none() }

cpp/ql/lib/semmle/code/cpp/Function.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Function extends Declaration, ControlFlowNode, AccessHolder, @function {
4141
* `min<int>(int, int) -> int`, and the full signature of the uninstantiated
4242
* template on the first line would be `min<T>(T, T) -> T`.
4343
*/
44-
string getFullSignature() {
44+
deprecated string getFullSignature() {
4545
exists(string name, string templateArgs, string args |
4646
result = name + templateArgs + args + " -> " + this.getType().toString() and
4747
name = this.getQualifiedName() and

cpp/ql/lib/semmle/code/cpp/commons/Alloc.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ predicate freeFunction(Function f, int argNum) { argNum = f.(DeallocationFunctio
1212
*
1313
* DEPRECATED: Use `DeallocationExpr` instead (this also includes `delete` expressions).
1414
*/
15-
predicate freeCall(FunctionCall fc, Expr arg) { arg = fc.(DeallocationExpr).getFreedExpr() }
15+
deprecated predicate freeCall(FunctionCall fc, Expr arg) {
16+
arg = fc.(DeallocationExpr).getFreedExpr()
17+
}
1618

1719
/**
1820
* Is e some kind of allocation or deallocation (`new`, `alloc`, `realloc`, `delete`, `free` etc)?

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,17 @@ module Impl<FullStateConfigSig Config> {
959959
not inBarrier(p)
960960
}
961961

962+
/**
963+
* Gets an additional term that is added to `branch` and `join` when deciding whether
964+
* the amount of forward or backward branching is within the limit specified by the
965+
* configuration.
966+
*/
967+
pragma[nomagic]
968+
private int getLanguageSpecificFlowIntoCallNodeCand1(ArgNodeEx arg, ParamNodeEx p) {
969+
flowIntoCallNodeCand1(_, arg, p) and
970+
result = getAdditionalFlowIntoCallNodeTerm(arg.projectToNode(), p.projectToNode())
971+
}
972+
962973
/**
963974
* Gets the amount of forward branching on the origin of a cross-call path
964975
* edge in the graph of paths between sources and sinks that ignores call
@@ -968,6 +979,7 @@ module Impl<FullStateConfigSig Config> {
968979
private int branch(NodeEx n1) {
969980
result =
970981
strictcount(NodeEx n | flowOutOfCallNodeCand1(_, n1, _, n) or flowIntoCallNodeCand1(_, n1, n))
982+
+ sum(ParamNodeEx p1 | | getLanguageSpecificFlowIntoCallNodeCand1(n1, p1))
971983
}
972984

973985
/**
@@ -979,6 +991,7 @@ module Impl<FullStateConfigSig Config> {
979991
private int join(NodeEx n2) {
980992
result =
981993
strictcount(NodeEx n | flowOutOfCallNodeCand1(_, n, _, n2) or flowIntoCallNodeCand1(_, n, n2))
994+
+ sum(ArgNodeEx arg2 | | getLanguageSpecificFlowIntoCallNodeCand1(arg2, n2))
982995
}
983996

984997
/**

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,3 +318,12 @@ private class MyConsistencyConfiguration extends Consistency::ConsistencyConfigu
318318
// consistency alerts enough that most of them are interesting.
319319
}
320320
}
321+
322+
/**
323+
* Gets an additional term that is added to the `join` and `branch` computations to reflect
324+
* an additional forward or backwards branching factor that is not taken into account
325+
* when calculating the (virtual) dispatch cost.
326+
*
327+
* Argument `arg` is part of a path from a source to a sink, and `p` is the target parameter.
328+
*/
329+
int getAdditionalFlowIntoCallNodeTerm(ArgumentNode arg, ParameterNode p) { none() }

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,17 @@ module Impl<FullStateConfigSig Config> {
959959
not inBarrier(p)
960960
}
961961

962+
/**
963+
* Gets an additional term that is added to `branch` and `join` when deciding whether
964+
* the amount of forward or backward branching is within the limit specified by the
965+
* configuration.
966+
*/
967+
pragma[nomagic]
968+
private int getLanguageSpecificFlowIntoCallNodeCand1(ArgNodeEx arg, ParamNodeEx p) {
969+
flowIntoCallNodeCand1(_, arg, p) and
970+
result = getAdditionalFlowIntoCallNodeTerm(arg.projectToNode(), p.projectToNode())
971+
}
972+
962973
/**
963974
* Gets the amount of forward branching on the origin of a cross-call path
964975
* edge in the graph of paths between sources and sinks that ignores call
@@ -968,6 +979,7 @@ module Impl<FullStateConfigSig Config> {
968979
private int branch(NodeEx n1) {
969980
result =
970981
strictcount(NodeEx n | flowOutOfCallNodeCand1(_, n1, _, n) or flowIntoCallNodeCand1(_, n1, n))
982+
+ sum(ParamNodeEx p1 | | getLanguageSpecificFlowIntoCallNodeCand1(n1, p1))
971983
}
972984

973985
/**
@@ -979,6 +991,7 @@ module Impl<FullStateConfigSig Config> {
979991
private int join(NodeEx n2) {
980992
result =
981993
strictcount(NodeEx n | flowOutOfCallNodeCand1(_, n, _, n2) or flowIntoCallNodeCand1(_, n, n2))
994+
+ sum(ArgNodeEx arg2 | | getLanguageSpecificFlowIntoCallNodeCand1(arg2, n2))
982995
}
983996

984997
/**

0 commit comments

Comments
 (0)